Module: kamailio
Branch: master
Commit: 99403c83f2163350eda3b76180947b1fddcdf500
URL:
https://github.com/kamailio/kamailio/commit/99403c83f2163350eda3b76180947b1…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2019-11-21T13:40:21+01:00
core: events - support for basic void core callbacks
- can be used to allow modules execute their code from core for specific needs
---
Modified: src/core/events.c
Modified: src/core/events.h
---
Diff:
https://github.com/kamailio/kamailio/commit/99403c83f2163350eda3b76180947b1…
Patch:
https://github.com/kamailio/kamailio/commit/99403c83f2163350eda3b76180947b1…
---
diff --git a/src/core/events.c b/src/core/events.c
index 5f71cd8f22..70d7179697 100644
--- a/src/core/events.c
+++ b/src/core/events.c
@@ -362,3 +362,16 @@ int sr_event_enabled(int type)
return 0;
}
+
+/**
+ *
+ */
+static sr_corecb_t _ksr_corecb = {0};
+
+/**
+ *
+ */
+sr_corecb_t *sr_corecb_get(void)
+{
+ return &_ksr_corecb;
+}
diff --git a/src/core/events.h b/src/core/events.h
index 9c4c54a2e5..6282e65a5a 100644
--- a/src/core/events.h
+++ b/src/core/events.h
@@ -79,4 +79,20 @@ int sr_event_enabled(int type);
void sr_core_ert_init(void);
void sr_core_ert_run(sip_msg_t *msg, int e);
+typedef void (*sr_corecb_void_f)(void);
+typedef struct sr_corecb {
+ sr_corecb_void_f app_ready;
+ sr_corecb_void_f app_shutdown;
+} sr_corecb_t;
+
+sr_corecb_t *sr_corecb_get(void);
+
+#define sr_corecb_void_exec(fname) \
+ do { \
+ sr_corecb_t *__cbp = sr_corecb_get(); \
+ if(__cbp && __cbp->fname) { \
+ __cbp->fname(); \
+ } \
+ } while(0);
+
#endif