presence_xml: use common prefix for global variables
authorDaniel-Constantin Mierla <miconda@gmail.com>
Wed, 15 Apr 2020 07:19:56 +0000 (09:19 +0200)
committerDaniel-Constantin Mierla <miconda@gmail.com>
Wed, 15 Apr 2020 07:21:11 +0000 (09:21 +0200)
src/modules/presence_xml/add_events.c
src/modules/presence_xml/notify_body.c
src/modules/presence_xml/presence_xml.c
src/modules/presence_xml/presence_xml.h
src/modules/presence_xml/xcap_auth.c

index 01e9109..a7e82aa 100644 (file)
 #include "add_events.h"
 #include "presence_xml.h"
 
 #include "add_events.h"
 #include "presence_xml.h"
 
-extern int disable_presence;
-extern int disable_winfo;
-extern int disable_bla;
-extern int disable_xcapdiff;
+extern int pxml_disable_presence;
+extern int pxml_disable_winfo;
+extern int pxml_disable_bla;
+extern int pxml_disable_xcapdiff;
 
 static str pu_415_rpl = str_init("Unsupported media type");
 
 
 static str pu_415_rpl = str_init("Unsupported media type");
 
@@ -49,7 +49,7 @@ int xml_add_events(void)
 {
        pres_ev_t event;
 
 {
        pres_ev_t event;
 
-       if(!disable_presence) {
+       if(!pxml_disable_presence) {
                /* constructing presence event */
                memset(&event, 0, sizeof(pres_ev_t));
                event.name.s = "presence";
                /* constructing presence event */
                memset(&event, 0, sizeof(pres_ev_t));
                event.name.s = "presence";
@@ -75,7 +75,7 @@ int xml_add_events(void)
                LM_DBG("added 'presence' event to presence module\n");
        }
 
                LM_DBG("added 'presence' event to presence module\n");
        }
 
-       if(!disable_winfo) {
+       if(!pxml_disable_winfo) {
                /* constructing presence.winfo event */
                memset(&event, 0, sizeof(pres_ev_t));
                event.name.s = "presence.winfo";
                /* constructing presence.winfo event */
                memset(&event, 0, sizeof(pres_ev_t));
                event.name.s = "presence.winfo";
@@ -94,7 +94,7 @@ int xml_add_events(void)
                LM_DBG("added 'presence.winfo' event to presence module\n");
        }
 
                LM_DBG("added 'presence.winfo' event to presence module\n");
        }
 
-       if(!disable_bla) {
+       if(!pxml_disable_bla) {
                /* constructing bla event */
                memset(&event, 0, sizeof(pres_ev_t));
                event.name.s = "dialog;sla";
                /* constructing bla event */
                memset(&event, 0, sizeof(pres_ev_t));
                event.name.s = "dialog;sla";
@@ -114,7 +114,7 @@ int xml_add_events(void)
                LM_DBG("added 'dialog;sla' event to presence module\n");
        }
 
                LM_DBG("added 'dialog;sla' event to presence module\n");
        }
 
-       if(!disable_xcapdiff) {
+       if(!pxml_disable_xcapdiff) {
                /* constructing xcap-diff event */
                memset(&event, 0, sizeof(pres_ev_t));
                event.name.s = "xcap-diff";
                /* constructing xcap-diff event */
                memset(&event, 0, sizeof(pres_ev_t));
                event.name.s = "xcap-diff";
index 4f5492f..00d3b44 100644 (file)
 #include "notify_body.h"
 #include "presence_xml.h"
 
 #include "notify_body.h"
 #include "presence_xml.h"
 
-extern int force_dummy_presence;
-extern int presence_force_single_body;
-extern str presence_single_body_priorities;
-extern str presence_single_body_lookup_element;
+extern int pxml_force_dummy_presence;
+extern int pxml_force_single_body;
+extern str pxml_single_body_priorities;
+extern str pxml_single_body_lookup_element;
 
 str *offline_nbody(str *body);
 str *agregate_xmls(str *pres_user, str *pres_domain, str **body_array, int n);
 
 str *offline_nbody(str *body);
 str *agregate_xmls(str *pres_user, str *pres_domain, str **body_array, int n);
@@ -65,7 +65,7 @@ void free_xml_body(char *body)
 <presence xmlns=\"urn:ietf:params:xml:ns:pidf\"\
  xmlns:dm=\"urn:ietf:params:xml:ns:pidf:data-model\"\
  xmlns:rpid=\"urn:ietf:params:xml:ns:pidf:rpid\"\
 <presence xmlns=\"urn:ietf:params:xml:ns:pidf\"\
  xmlns:dm=\"urn:ietf:params:xml:ns:pidf:data-model\"\
  xmlns:rpid=\"urn:ietf:params:xml:ns:pidf:rpid\"\
- xmlns:c=\"urn:ietf:params:xml:ns:pidf:cipid\" entity=\"%.*s\"> \
+ xmlns:c=\"urn:ietf:params:xml:ns:pidf:cipid\" entity=\"%.*s\">\
 <tuple xmlns=\"urn:ietf:params:xml:ns:pidf\" id=\"615293b33c62dec073e05d9421e9f48b\">\
 <status>\
 <basic>open</basic>\
 <tuple xmlns=\"urn:ietf:params:xml:ns:pidf\" id=\"615293b33c62dec073e05d9421e9f48b\">\
 <status>\
 <basic>open</basic>\
@@ -139,7 +139,7 @@ str *pres_agg_nbody(str *pres_user, str *pres_domain, str **body_array, int n,
        str *n_body = NULL;
        str *body = NULL;
 
        str *n_body = NULL;
        str *body = NULL;
 
-       if(body_array == NULL && (!force_dummy_presence))
+       if(body_array == NULL && (!pxml_force_dummy_presence))
                return NULL;
 
        if(body_array == NULL)
                return NULL;
 
        if(body_array == NULL)
@@ -156,7 +156,7 @@ str *pres_agg_nbody(str *pres_user, str *pres_domain, str **body_array, int n,
        }
        LM_DBG("[user]=%.*s  [domain]= %.*s\n", pres_user->len, pres_user->s,
                        pres_domain->len, pres_domain->s);
        }
        LM_DBG("[user]=%.*s  [domain]= %.*s\n", pres_user->len, pres_user->s,
                        pres_domain->len, pres_domain->s);
-       if(presence_force_single_body == 0) {
+       if(pxml_force_single_body == 0) {
                n_body = agregate_xmls(pres_user, pres_domain, body_array, n);
        } else {
                n_body = agregate_xmls_priority(pres_user, pres_domain, body_array, n);
                n_body = agregate_xmls(pres_user, pres_domain, body_array, n);
        } else {
                n_body = agregate_xmls_priority(pres_user, pres_domain, body_array, n);
@@ -184,8 +184,9 @@ int pres_apply_auth(str *notify_body, subs_t *subs, str **final_nbody)
        str *n_body = NULL;
 
        *final_nbody = NULL;
        str *n_body = NULL;
 
        *final_nbody = NULL;
-       if(force_active)
+       if(pxml_force_active) {
                return 0;
                return 0;
+       }
 
        if(subs->auth_rules_doc == NULL) {
                LM_ERR("NULL rules doc\n");
 
        if(subs->auth_rules_doc == NULL) {
                LM_ERR("NULL rules doc\n");
@@ -682,15 +683,16 @@ str *agregate_xmls_priority(str *pres_user, str *pres_domain, str **body_array,
        }
 
        idx = --j;
        }
 
        idx = --j;
-       if(strlen(presence_single_body_priorities.s) > 0 && strlen(presence_single_body_lookup_element.s) > 0) {
+       if(strlen(pxml_single_body_priorities.s) > 0
+                               && strlen(pxml_single_body_lookup_element.s) > 0) {
                p_root = xmlDocGetNodeByName(xml_array[j], "presence", NULL);
                if(p_root == NULL) {
                        LM_ERR("while getting the xml_tree root\n");
                        goto error;
                }
                p_root = xmlDocGetNodeByName(xml_array[j], "presence", NULL);
                if(p_root == NULL) {
                        LM_ERR("while getting the xml_tree root\n");
                        goto error;
                }
-               cur = xmlNodeGetNodeContentByName(p_root, presence_single_body_lookup_element.s, NULL);
+               cur = xmlNodeGetNodeContentByName(p_root, pxml_single_body_lookup_element.s, NULL);
                if(cur) {
                if(cur) {
-                       priority = strstr(presence_single_body_priorities.s, cur);
+                       priority = strstr(pxml_single_body_priorities.s, cur);
                }
 
                for(i = j - 1; i >= 0; i--) {
                }
 
                for(i = j - 1; i >= 0; i--) {
@@ -700,9 +702,9 @@ str *agregate_xmls_priority(str *pres_user, str *pres_domain, str **body_array,
                                goto error;
                        }
 
                                goto error;
                        }
 
-                       cmp = xmlNodeGetNodeContentByName(new_p_root, presence_single_body_lookup_element.s, NULL);
+                       cmp = xmlNodeGetNodeContentByName(new_p_root, pxml_single_body_lookup_element.s, NULL);
                        if(cur != NULL && cmp != NULL && strcasecmp(cur,cmp)) {
                        if(cur != NULL && cmp != NULL && strcasecmp(cur,cmp)) {
-                               char *x1 = strstr(presence_single_body_priorities.s, cmp);
+                               char *x1 = strstr(pxml_single_body_priorities.s, cmp);
                                if(x1 > priority) {
                                        idx = i;
                                        cur = cmp;
                                if(x1 > priority) {
                                        idx = i;
                                        cur = cmp;
index 3da703e..cc9b814 100644 (file)
@@ -58,6 +58,7 @@
 #include "api.h"
 
 MODULE_VERSION
 #include "api.h"
 
 MODULE_VERSION
+
 #define S_TABLE_VERSION 4
 
 /** module functions */
 #define S_TABLE_VERSION 4
 
 /** module functions */
@@ -80,22 +81,22 @@ static int w_presxml_check_activities(
 presence_api_t psapi = {0};
 
 /* Module parameter variables */
 presence_api_t psapi = {0};
 
 /* Module parameter variables */
-str xcap_table = str_init("xcap");
-static str presxml_db_url = str_init(DEFAULT_DB_URL);
-int force_active = 0;
-int force_dummy_presence = 0;
-int integrated_xcap_server = 0;
+str pxml_xcap_table = str_init("xcap");
+static str pxml_db_url = str_init(DEFAULT_DB_URL);
+int pxml_force_active = 0;
+int pxml_force_dummy_presence = 0;
+int pxml_integrated_xcap_server = 0;
 xcap_serv_t *xs_list = NULL;
 xcap_serv_t *xs_list = NULL;
-int disable_presence = 0;
-int disable_winfo = 0;
-int disable_bla = 1;
-int passive_mode = 0;
-int disable_xcapdiff = 0;
+int pxml_disable_presence = 0;
+int pxml_disable_winfo = 0;
+int pxml_disable_bla = 1;
+int pxml_disable_xcapdiff = 0;
+static int pxml_passive_mode = 0;
 str xcapauth_userdel_reason = str_init("probation");
 
 str xcapauth_userdel_reason = str_init("probation");
 
-int presence_force_single_body = 0;
-str presence_single_body_priorities = str_init("Available|Ringing|On the Phone");
-str presence_single_body_lookup_element = str_init("note");
+int pxml_force_single_body = 0;
+str pxml_single_body_priorities = str_init("Available|Ringing|On the Phone");
+str pxml_single_body_lookup_element = str_init("note");
 
 /** SL API structure */
 sl_api_t slb;
 
 /** SL API structure */
 sl_api_t slb;
@@ -122,21 +123,21 @@ static cmd_export_t cmds[]={
 
 /* clang-format off */
 static param_export_t params[]={
 
 /* clang-format off */
 static param_export_t params[]={
-       { "db_url",             PARAM_STR, &presxml_db_url},
-       { "xcap_table",         PARAM_STR, &xcap_table},
-       { "force_active",       INT_PARAM, &force_active },
-       { "integrated_xcap_server", INT_PARAM, &integrated_xcap_server},
+       { "db_url",             PARAM_STR, &pxml_db_url},
+       { "xcap_table",         PARAM_STR, &pxml_xcap_table},
+       { "force_active",       INT_PARAM, &pxml_force_active },
+       { "integrated_xcap_server", INT_PARAM, &pxml_integrated_xcap_server},
        { "xcap_server",        PARAM_STRING|USE_FUNC_PARAM,(void*)pxml_add_xcap_server},
        { "xcap_server",        PARAM_STRING|USE_FUNC_PARAM,(void*)pxml_add_xcap_server},
-       { "disable_presence",   INT_PARAM, &disable_presence },
-       { "disable_winfo",              INT_PARAM, &disable_winfo },
-       { "disable_bla",                INT_PARAM, &disable_bla },
-       { "disable_xcapdiff",   INT_PARAM, &disable_xcapdiff },
-       { "passive_mode",               INT_PARAM, &passive_mode },
+       { "disable_presence",   INT_PARAM, &pxml_disable_presence },
+       { "disable_winfo",              INT_PARAM, &pxml_disable_winfo },
+       { "disable_bla",                INT_PARAM, &pxml_disable_bla },
+       { "disable_xcapdiff",   INT_PARAM, &pxml_disable_xcapdiff },
+       { "passive_mode",               INT_PARAM, &pxml_passive_mode },
        { "xcapauth_userdel_reason", PARAM_STR, &xcapauth_userdel_reason},
        { "xcapauth_userdel_reason", PARAM_STR, &xcapauth_userdel_reason},
-       { "force_dummy_presence",       INT_PARAM, &force_dummy_presence },
-       { "force_presence_single_body", INT_PARAM, &presence_force_single_body },
-       { "presence_single_body_priorities",  PARAM_STR, &presence_single_body_priorities },
-       { "presence_single_body_lookup_element", PARAM_STR, &presence_single_body_lookup_element },
+       { "force_dummy_presence",       INT_PARAM, &pxml_force_dummy_presence },
+       { "force_presence_single_body", INT_PARAM, &pxml_force_single_body },
+       { "presence_single_body_priorities",  PARAM_STR, &pxml_single_body_priorities },
+       { "presence_single_body_lookup_element", PARAM_STR, &pxml_single_body_lookup_element },
        { 0, 0, 0}
 };
 /* clang-format on */
        { 0, 0, 0}
 };
 /* clang-format on */
@@ -162,12 +163,12 @@ struct module_exports exports= {
  */
 static int mod_init(void)
 {
  */
 static int mod_init(void)
 {
-       if(passive_mode == 1) {
+       if(pxml_passive_mode == 1) {
                return 0;
        }
 
                return 0;
        }
 
-       LM_DBG("db_url=%s (len=%d addr=%p)\n", ZSW(presxml_db_url.s),
-                       presxml_db_url.len, presxml_db_url.s);
+       LM_DBG("db_url=%s (len=%d addr=%p)\n", ZSW(pxml_db_url.s),
+                       pxml_db_url.len, pxml_db_url.s);
 
        /* bind the SL API */
        if(sl_load_api(&slb) != 0) {
 
        /* bind the SL API */
        if(sl_load_api(&slb) != 0) {
@@ -189,9 +190,9 @@ static int mod_init(void)
                return -1;
        }
 
                return -1;
        }
 
-       if(force_active == 0) {
+       if(pxml_force_active == 0) {
                /* binding to mysql module  */
                /* binding to mysql module  */
-               if(db_bind_mod(&presxml_db_url, &pxml_dbf)) {
+               if(db_bind_mod(&pxml_db_url, &pxml_dbf)) {
                        LM_ERR("Database module not found\n");
                        return -1;
                }
                        LM_ERR("Database module not found\n");
                        return -1;
                }
@@ -202,19 +203,19 @@ static int mod_init(void)
                        return -1;
                }
 
                        return -1;
                }
 
-               pxml_db = pxml_dbf.init(&presxml_db_url);
+               pxml_db = pxml_dbf.init(&pxml_db_url);
                if(!pxml_db) {
                        LM_ERR("while connecting to database\n");
                        return -1;
                }
 
                if(db_check_table_version(
                if(!pxml_db) {
                        LM_ERR("while connecting to database\n");
                        return -1;
                }
 
                if(db_check_table_version(
-                                  &pxml_dbf, pxml_db, &xcap_table, S_TABLE_VERSION)
+                                  &pxml_dbf, pxml_db, &pxml_xcap_table, S_TABLE_VERSION)
                                < 0) {
                                < 0) {
-                       DB_TABLE_VERSION_ERROR(xcap_table);
+                       DB_TABLE_VERSION_ERROR(pxml_xcap_table);
                        goto dberror;
                }
                        goto dberror;
                }
-               if(!integrated_xcap_server) {
+               if(!pxml_integrated_xcap_server) {
                        xcap_api_t xcap_api;
                        bind_xcap_t bind_xcap;
 
                        xcap_api_t xcap_api;
                        bind_xcap_t bind_xcap;
 
@@ -263,21 +264,22 @@ static int child_init(int rank)
 {
        LM_DBG("[%d]  pid [%d]\n", rank, getpid());
 
 {
        LM_DBG("[%d]  pid [%d]\n", rank, getpid());
 
-       if(passive_mode == 1)
+       if(pxml_passive_mode == 1) {
                return 0;
                return 0;
+       }
 
        if(rank == PROC_INIT || rank == PROC_MAIN || rank == PROC_TCP_MAIN)
                return 0; /* do nothing for the main process */
 
 
        if(rank == PROC_INIT || rank == PROC_MAIN || rank == PROC_TCP_MAIN)
                return 0; /* do nothing for the main process */
 
-       if(force_active == 0) {
+       if(pxml_force_active == 0) {
                if(pxml_db)
                        return 0;
                if(pxml_db)
                        return 0;
-               pxml_db = pxml_dbf.init(&presxml_db_url);
+               pxml_db = pxml_dbf.init(&pxml_db_url);
                if(pxml_db == NULL) {
                        LM_ERR("while connecting database\n");
                        return -1;
                }
                if(pxml_db == NULL) {
                        LM_ERR("while connecting database\n");
                        return -1;
                }
-               if(pxml_dbf.use_table(pxml_db, &xcap_table) < 0) {
+               if(pxml_dbf.use_table(pxml_db, &pxml_xcap_table) < 0) {
                        LM_ERR("in use_table SQL operation\n");
                        return -1;
                }
                        LM_ERR("in use_table SQL operation\n");
                        return -1;
                }
@@ -365,7 +367,7 @@ static int shm_copy_xcap_list(void)
 
        xs = xs_list;
        if(xs == NULL) {
 
        xs = xs_list;
        if(xs == NULL) {
-               if(force_active == 0 && !integrated_xcap_server) {
+               if(pxml_force_active == 0 && !pxml_integrated_xcap_server) {
                        LM_ERR("no xcap_server parameter set\n");
                        return -1;
                }
                        LM_ERR("no xcap_server parameter set\n");
                        return -1;
                }
index 3d0bac3..e77891e 100644 (file)
@@ -44,12 +44,12 @@ typedef struct xcap_serv
 extern sl_api_t slb;
 extern presence_api_t psapi;
 
 extern sl_api_t slb;
 extern presence_api_t psapi;
 
-extern str xcap_table;
+extern str pxml_xcap_table;
 extern db1_con_t *pxml_db;
 extern db_func_t pxml_dbf;
 extern db1_con_t *pxml_db;
 extern db_func_t pxml_dbf;
-extern int force_active;
+extern int pxml_force_active;
 extern int pidf_manipulation;
 extern int pidf_manipulation;
-extern int integrated_xcap_server;
+extern int pxml_integrated_xcap_server;
 extern xcap_serv_t *xs_list;
 extern xcapGetNewDoc_t xcap_GetNewDoc;
 
 extern xcap_serv_t *xs_list;
 extern xcapGetNewDoc_t xcap_GetNewDoc;
 
index f55cbaa..0cf0669 100644 (file)
@@ -54,8 +54,8 @@ int pres_watcher_allowed(subs_t *subs)
        char *sub_handling = NULL;
        int ret = 0;
 
        char *sub_handling = NULL;
        int ret = 0;
 
-       /* if force_active set status to active*/
-       if(force_active) {
+       /* if pxml_force_active set status to active*/
+       if(pxml_force_active) {
                subs->status = ACTIVE_STATUS;
                subs->reason.s = NULL;
                subs->reason.len = 0;
                subs->status = ACTIVE_STATUS;
                subs->reason.s = NULL;
                subs->reason.len = 0;
@@ -400,7 +400,7 @@ int get_rules_doc(
        static str tmp4 = str_init("domain");
        static str tmp5 = str_init("doc");
 
        static str tmp4 = str_init("domain");
        static str tmp5 = str_init("doc");
 
-       if(force_active) {
+       if(pxml_force_active) {
                *rules_doc = NULL;
                return 0;
        }
                *rules_doc = NULL;
                return 0;
        }
@@ -439,8 +439,9 @@ int get_rules_doc(
 
        result_cols[xcap_doc_col = n_result_cols++] = &tmp5;
 
 
        result_cols[xcap_doc_col = n_result_cols++] = &tmp5;
 
-       if(pxml_dbf.use_table(pxml_db, &xcap_table) < 0) {
-               LM_ERR("in use_table-[table]= %.*s\n", xcap_table.len, xcap_table.s);
+       if(pxml_dbf.use_table(pxml_db, &pxml_xcap_table) < 0) {
+               LM_ERR("in use_table-[table]= %.*s\n", pxml_xcap_table.len,
+                               pxml_xcap_table.s);
                return -1;
        }
 
                return -1;
        }
 
@@ -461,10 +462,10 @@ int get_rules_doc(
                           "\t[domain]= %.*s\t[doc_type]= %d\n",
                                user->len, user->s, domain->len, domain->s, type);
 
                           "\t[domain]= %.*s\t[doc_type]= %d\n",
                                user->len, user->s, domain->len, domain->s, type);
 
-               if(!integrated_xcap_server && type != PRES_RULES) {
+               if(!pxml_integrated_xcap_server && type != PRES_RULES) {
                        LM_WARN("Cannot retrieve non pres-rules documents from"
                                        "external XCAP server\n");
                        LM_WARN("Cannot retrieve non pres-rules documents from"
                                        "external XCAP server\n");
-               } else if(!integrated_xcap_server) {
+               } else if(!pxml_integrated_xcap_server) {
                        if(http_get_rules_doc(*user, *domain, &body) < 0) {
                                LM_ERR("sending http GET request to xcap server\n");
                                goto error;
                        if(http_get_rules_doc(*user, *domain, &body) < 0) {
                                LM_ERR("sending http GET request to xcap server\n");
                                goto error;