Module: sip-router Branch: master Commit: 63be47a2d29d36408c42c7dc2d077865c2d19b98 URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=63be47a2...
Author: Daniel-Constantin Mierla miconda@gmail.com Committer: Daniel-Constantin Mierla miconda@gmail.com Date: Mon Apr 27 13:01:33 2009 +0200
added pv_isset() and pv_unset()
- functions to test and unset PV, aiming for K compatibility with null keyword
---
modules_k/pv/pv.c | 41 ++++++++++++++++++++++++++++++++++++++++- 1 files changed, 40 insertions(+), 1 deletions(-)
diff --git a/modules_k/pv/pv.c b/modules_k/pv/pv.c index b74fe12..9d7078a 100644 --- a/modules_k/pv/pv.c +++ b/modules_k/pv/pv.c @@ -26,6 +26,7 @@
#include "../../sr_module.h" #include "../../pvar.h" +#include "../../mod_fix.h" #include "../../lib/kmi/mi.h"
#include "pv_branch.h" @@ -372,12 +373,24 @@ static mi_export_t mi_cmds[] = {
static int mod_init(void); static void mod_destroy(void); +static int pv_isset(struct sip_msg* msg, char* pvid, char *foo); +static int pv_unset(struct sip_msg* msg, char* pvid, char *foo); + +static cmd_export_t cmds[]={ + {"pv_isset", (cmd_function)pv_isset, 1, fixup_pvar_null, 0, + ANY_ROUTE }, + {"pv_unset", (cmd_function)pv_unset, 1, fixup_pvar_null, 0, + ANY_ROUTE }, + {0,0,0,0,0,0} +}; + +
/** module exports */ struct module_exports exports= { "pv", DEFAULT_DLFLAGS, /* dlopen flags */ - 0, + cmds, params, 0, /* exported statistics */ mi_cmds, /* exported MI functions */ @@ -416,3 +429,29 @@ int mod_register(char *path, int *dlflags, void *p1, void *p2) return register_trans_mod(path, mod_trans); }
+static int pv_isset(struct sip_msg* msg, char* pvid, char *foo) +{ + pv_spec_t *sp; + pv_value_t value; + int ret; + + sp = (pv_spec_t*)pvid; + if(pv_get_spec_value(msg, sp, &value)!=0) + return -1; + ret =1; + if(value.flags & (PV_VAL_EMPTY|PV_VAL_NULL)) + ret = -1; + pv_value_destroy(&value); + return ret; +} + +static int pv_unset(struct sip_msg* msg, char* pvid, char *foo) +{ + pv_spec_t *sp; + + sp = (pv_spec_t*)pvid; + pv_set_spec_value(msg, sp, 0, NULL); + + return 1; +} +