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

Function register_pv_context

pvar.c:5991–6030  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5989}
5990
5991int register_pv_context(char* cname, pv_contextf_t get_context)
5992{
5993 pv_context_t* pvc = pv_context_lst;
5994 str name;
5995
5996 if(cname == NULL)
5997 {
5998 LM_DBG("NULL parameter\n");
5999 return -1;
6000 }
6001
6002 name.s = cname;
6003 name.len = strlen(cname);
6004
6005 LM_DBG("Registered new context: %.*s / %p\n", name.len, name.s, get_context);
6006 pvc = pv_get_context(&name);
6007 if(pvc == NULL)
6008 {
6009 LM_DBG("Context not found\n");
6010 if(add_pv_context(&name, get_context) == NULL)
6011 {
6012 LM_ERR("Failed to add context\n");
6013 return -1;
6014 }
6015 return 1;
6016 }
6017
6018 if(pvc->contextf!=NULL)
6019 {
6020 LM_ERR("Context already registered [%s]\n", cname);
6021 return -1;
6022 }
6023 if(get_context == NULL)
6024 {
6025 LM_ERR("NULL context getter function\n");
6026 return -1;
6027 }
6028 pvc->contextf= get_context;
6029 return 1;
6030}
6031
6032
6033/* function to register a pv context getter */

Callers 1

mod_loadFunction · 0.85

Calls 2

pv_get_contextFunction · 0.85
add_pv_contextFunction · 0.85

Tested by

no test coverage detected