Module: sip-router Branch: master Commit: df5b7ebf3f91ab4335fe3c390a521cbb7b15e2f7 URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=df5b7ebf...
Author: Daniel-Constantin Mierla miconda@gmail.com Committer: Daniel-Constantin Mierla miconda@gmail.com Date: Thu Jun 11 20:12:35 2009 +0300
presence_xml: new pv $xml(...)
- $xml(...) can be used to handle xml documents - xpath access and set of content - module can act in passive mode by settin 'passive_mode' parameter to 1 (no bind to presence module, no connection to database)
---
modules_k/presence_xml/presence_xml.c | 23 ++++++++++++++++++++--- 1 files changed, 20 insertions(+), 3 deletions(-)
diff --git a/modules_k/presence_xml/presence_xml.c b/modules_k/presence_xml/presence_xml.c index d54e76c..971449c 100644 --- a/modules_k/presence_xml/presence_xml.c +++ b/modules_k/presence_xml/presence_xml.c @@ -56,6 +56,7 @@ #include "pidf.h" #include "add_events.h" #include "presence_xml.h" +#include "pv_xml.h"
MODULE_VERSION #define S_TABLE_VERSION 3 @@ -88,6 +89,7 @@ xcap_serv_t* xs_list= NULL; int disable_presence = 0; int disable_winfo = 0; int disable_bla = 1; +int passive_mode = 0;
/* SL bind */ struct sl_binds slb; @@ -110,7 +112,7 @@ static param_export_t params[]={ { "disable_presence", INT_PARAM, &disable_presence }, { "disable_winfo", INT_PARAM, &disable_winfo }, { "disable_bla", INT_PARAM, &disable_bla }, - { 0, 0, 0} + { "passive_mode", INT_PARAM, &passive_mode }, { 0, 0, 0} };
static mi_export_t mi_cmds[] = { @@ -118,6 +120,12 @@ static mi_export_t mi_cmds[] = { { 0, 0, 0, 0, 0 } };
+static pv_export_t mod_pvs[] = { + { {"xml", sizeof("xml")-1}, PVT_OTHER, pv_get_xml, pv_set_xml, + pv_parse_xml_name, 0, 0, 0 }, + { {0, 0}, 0, 0, 0, 0, 0, 0, 0 } +}; + /** module exports */ struct module_exports exports= { "presence_xml", /* module name */ @@ -126,7 +134,7 @@ struct module_exports exports= { params, /* exported parameters */ 0, /* exported statistics */ mi_cmds, /* exported MI functions */ - 0, /* exported pseudo-variables */ + mod_pvs, /* exported pseudo-variables */ 0, /* extra processes */ mod_init, /* module initialization function */ 0, /* response handling function */ @@ -141,7 +149,10 @@ static int mod_init(void) { bind_presence_t bind_presence; presence_api_t pres; - + + if(passive_mode==1) + return 0; + if(register_mi_mod(exports.name, mi_cmds)!=0) { LM_ERR("failed to register MI commands\n"); @@ -256,6 +267,9 @@ static int mod_init(void)
static int mi_child_init(void) { + if(passive_mode==1) + return 0; + if (pxml_dbf.init==0) { LM_CRIT("database not bound\n"); @@ -283,6 +297,9 @@ static int child_init(int rank) { LM_DBG("[%d] pid [%d]\n", rank, getpid()); + if(passive_mode==1) + return 0; + if (rank==PROC_INIT || rank==PROC_MAIN || rank==PROC_TCP_MAIN) return 0; /* do nothing for the main process */