Module: sip-router Branch: master Commit: a21137507bea759d4945402dc47486ac324724db URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=a2113750...
Author: Victor Seva linuxmaniac@torreviejawireless.org Committer: Victor Seva linuxmaniac@torreviejawireless.org Date: Wed May 29 12:25:50 2013 +0200
core: added helper function pv_cache_get_name() in order to get the name of a pv_spec_t on pv_cache.
---
pvapi.c | 30 ++++++++++++++++++++++++++++++ pvar.h | 1 + 2 files changed, 31 insertions(+), 0 deletions(-)
diff --git a/pvapi.c b/pvapi.c index 6245ee9..98b3d90 100644 --- a/pvapi.c +++ b/pvapi.c @@ -357,6 +357,36 @@ pv_spec_t* pv_cache_get(str *name) return pv_cache_add(&tname); }
+str* pv_cache_get_name(pv_spec_t *spec) +{ + int i; + pv_cache_t *pvi; + if(spec==NULL) + { + LM_ERR("invalid parameters\n"); + return NULL; + } + + if(_pv_cache_set==0) + return NULL; + + for(i=0;i<PV_CACHE_SIZE;i++) + { + pvi = _pv_cache[i]; + while(pvi) + { + if(&pvi->spec == spec) + { + LM_DBG("pvar[%p]->name[%.*s] found in cache\n", spec, + pvi->pvname.len, pvi->pvname.s); + return &pvi->pvname; + } + pvi = pvi->next; + } + } + return NULL; +} + /** * */ diff --git a/pvar.h b/pvar.h index f6d6318..c3d7b44 100644 --- a/pvar.h +++ b/pvar.h @@ -207,6 +207,7 @@ int pv_free_extra_list(void);
int pv_locate_name(str *in); pv_spec_t* pv_cache_get(str *name); +str* pv_cache_get_name(pv_spec_t *spec);
/*! \brief PV helper functions */ int pv_get_null(struct sip_msg *msg, pv_param_t *param, pv_value_t *res);