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

Function pv_add_extra

pvar.c:5845–5919  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5843}
5844
5845static int pv_add_extra(const pv_export_t *e)
5846{
5847 const char *p;
5848 const str_const *in;
5849 pv_extra_t *pvi = NULL;
5850 pv_extra_t *pvj = NULL;
5851 pv_extra_t *pvn = NULL;
5852 int found;
5853
5854 if(e==NULL || e->name.s==NULL || e->getf==NULL || e->type==PVT_NONE)
5855 {
5856 LM_ERR("invalid parameters\n");
5857 return -1;
5858 }
5859
5860 if(_pv_extra_list==0)
5861 {
5862 LM_DBG("extra items list is not initialized\n");
5863 if(pv_init_extra_list()!=0)
5864 {
5865 LM_ERR("cannot intit extra list\n");
5866 return -1;
5867 }
5868 }
5869 in = &(e->name);
5870 p = in->s;
5871 while(is_in_str(p,in) && is_pv_valid_char(*p))
5872 p++;
5873 if(is_in_str(p,in))
5874 {
5875 LM_ERR("invalid char [%c] in [%.*s]\n", *p, in->len, in->s);
5876 return -1;
5877 }
5878 found = 0;
5879 pvi = *_pv_extra_list;
5880 while(pvi)
5881 {
5882 if(pvi->pve.name.len > in->len)
5883 break;
5884 if(pvi->pve.name.len==in->len)
5885 {
5886 found = strncmp(pvi->pve.name.s, in->s, in->len);
5887 if(found>0)
5888 break;
5889 if(found==0)
5890 {
5891 LM_ERR("pvar [%.*s] already exists\n", in->len, in->s);
5892 return -1;
5893 }
5894 }
5895 pvj = pvi;
5896 pvi = pvi->next;
5897 }
5898
5899 pvn = (pv_extra_t*)pkg_malloc(sizeof(pv_extra_t));
5900 if(pvn==0)
5901 {
5902 LM_ERR("no more memory\n");

Callers 1

register_pvars_modFunction · 0.85

Calls 2

pv_init_extra_listFunction · 0.85
is_pv_valid_charFunction · 0.85

Tested by

no test coverage detected