Module: kamailio
Branch: master
Commit: 13c2300f736c74faa6b4557f6146e0b7de9f89da
URL: 
https://github.com/kamailio/kamailio/commit/13c2300f736c74faa6b4557f6146e0b7de9f89da

Author: Daniel-Constantin Mierla <mico...@gmail.com>
Committer: Daniel-Constantin Mierla <mico...@gmail.com>
Date: 2017-04-10T17:20:38+02:00

mqueue: exported functions to kemi framework

---

Modified: src/modules/mqueue/mqueue_mod.c

---

Diff:  
https://github.com/kamailio/kamailio/commit/13c2300f736c74faa6b4557f6146e0b7de9f89da.diff
Patch: 
https://github.com/kamailio/kamailio/commit/13c2300f736c74faa6b4557f6146e0b7de9f89da.patch

---

diff --git a/src/modules/mqueue/mqueue_mod.c b/src/modules/mqueue/mqueue_mod.c
index 8f2c610..aa8f9ff 100644
--- a/src/modules/mqueue/mqueue_mod.c
+++ b/src/modules/mqueue/mqueue_mod.c
@@ -34,6 +34,7 @@
 #include "../../core/rpc_lookup.h"
 #include "../../core/parser/parse_param.h"
 #include "../../core/shm_init.h"
+#include "../../core/kemi.h"
 
 #include "mqueue_api.h"
 #include "api.h"
@@ -325,3 +326,88 @@ static int mqueue_rpc_init(void)
        }
        return 0;
 }
+
+/**
+ *
+ */
+static int ki_mq_add(sip_msg_t* msg, str* mq, str* key, str* val)
+{
+       if(mq_item_add(mq, key, val)<0)
+               return -1;
+       return 1;
+}
+
+/**
+ *
+ */
+static int ki_mq_fetch(sip_msg_t* msg, str* mq)
+{
+       int ret;
+       ret = mq_head_fetch(mq);
+       if(ret<0)
+               return ret;
+       return 1;
+}
+
+/**
+ *
+ */
+static int ki_mq_size(sip_msg_t *msg, str *mq)
+{
+       int ret;
+
+       ret = _mq_get_csize(mq);
+
+       if(ret < 0 && mq!=NULL)
+               LM_ERR("mqueue %.*s not found\n", mq->len, mq->s);
+
+       return ret;
+}
+
+/**
+ *
+ */
+static int ki_mq_pv_free(sip_msg_t* msg, str *mq)
+{
+       mq_pv_free(mq);
+       return 1;
+}
+
+/**
+ *
+ */
+/* clang-format off */
+static sr_kemi_t sr_kemi_mqueue_exports[] = {
+       { str_init("mqueue"), str_init("mq_add"),
+               SR_KEMIP_INT, ki_mq_add,
+               { SR_KEMIP_STR, SR_KEMIP_STR, SR_KEMIP_STR,
+                       SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
+       },
+       { str_init("mqueue"), str_init("mq_fetch"),
+               SR_KEMIP_INT, ki_mq_fetch,
+               { SR_KEMIP_STR, SR_KEMIP_NONE, SR_KEMIP_NONE,
+                       SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
+       },
+       { str_init("mqueue"), str_init("mq_size"),
+               SR_KEMIP_INT, ki_mq_size,
+               { SR_KEMIP_STR, SR_KEMIP_NONE, SR_KEMIP_NONE,
+                       SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
+       },
+       { str_init("mqueue"), str_init("mq_pv_free"),
+               SR_KEMIP_INT, ki_mq_pv_free,
+               { SR_KEMIP_STR, SR_KEMIP_NONE, SR_KEMIP_NONE,
+                       SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
+       },
+
+       { {0, 0}, {0, 0}, 0, NULL, { 0, 0, 0, 0, 0, 0 } }
+};
+/* clang-format on */
+
+/**
+ *
+ */
+int mod_register(char *path, int *dlflags, void *p1, void *p2)
+{
+       sr_kemi_modules_add(sr_kemi_mqueue_exports);
+       return 0;
+}


_______________________________________________
sr-dev mailing list
sr-dev@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev

Reply via email to