MCPcopy Create free account
hub / github.com/OpenSIPS/opensips / add_pv_context

Function add_pv_context

pvar.c:6034–6074  ·  view source on GitHub ↗

function to register a pv context getter */

Source from the content-addressed store, hash-verified

6032
6033/* function to register a pv context getter */
6034static pv_context_t* add_pv_context(const str* name, pv_contextf_t get_context)
6035{
6036 pv_context_t* pvc = pv_context_lst;
6037 pv_context_t* pvc_new, *pvc_prev;
6038
6039 if(pvc == NULL)
6040 {
6041 pvc_new = new_pv_context(name, get_context);
6042 if(pvc_new == NULL)
6043 {
6044 LM_ERR("Failed to allocate context\n");
6045 return 0;
6046 }
6047 pv_context_lst = pvc_new;
6048 return pvc_new;
6049 }
6050
6051 while(pvc)
6052 {
6053 if(pvc->name.len == name->len && strncmp(pvc->name.s, name->s, name->len)==0)
6054 {
6055 LM_ERR("PV Context already registered [%.*s]\n", name->len, name->s);
6056 return 0;
6057 }
6058 pvc_prev = pvc;
6059 pvc = pvc->next;
6060 }
6061
6062 pvc_new = new_pv_context(name, get_context);
6063 if(pvc_new == NULL)
6064 {
6065 LM_ERR("Failed to allocate context\n");
6066 return 0;
6067 }
6068
6069 LM_DBG("Registered new context: %.*s\n", name->len, name->s);
6070
6071 pvc_prev->next = pvc_new;
6072
6073 return pvc_new;
6074}
6075
6076static pv_context_t* pv_get_context(const str* name)
6077{

Callers 2

pv_parse_specFunction · 0.85
register_pv_contextFunction · 0.85

Calls 1

new_pv_contextFunction · 0.85

Tested by

no test coverage detected