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

Function pv_lookup_spec_name

pvar.c:4912–4969  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4910};
4911
4912static const pv_export_t* pv_lookup_spec_name(str *pvname, pv_spec_p e, int has_name)
4913{
4914 int i;
4915 pv_extra_p pvi;
4916 int found;
4917
4918 if(pvname==0 || e==0)
4919 {
4920 LM_ERR("bad parameters\n");
4921 return NULL;
4922 }
4923 /* search in main table */
4924 for(i=0; _pv_names_table[i].name.s!=0; i++)
4925 {
4926 if(_pv_names_table[i].name.len==pvname->len
4927 && !((has_name?1:0) ^ (_pv_names_table[i].parse_name?1:0))
4928 && memcmp(_pv_names_table[i].name.s, pvname->s, pvname->len)==0)
4929 {
4930 /*LM_DBG("found [%.*s] [%d]\n", pvname->len, pvname->s,
4931 _pv_names_table[i].type);*/
4932 /* copy data from table to spec */
4933 e->type = _pv_names_table[i].type;
4934 e->getf = _pv_names_table[i].getf;
4935 e->setf = _pv_names_table[i].setf;
4936 return &_pv_names_table[i];
4937 }
4938 }
4939 /* search in extra list */
4940 if(_pv_extra_list==0)
4941 {
4942 LM_DBG("extra items list is empty\n");
4943 return NULL;
4944 }
4945 pvi = *_pv_extra_list;
4946 while(pvi)
4947 {
4948 if(pvi->pve.name.len>pvname->len)
4949 break;
4950 if(pvi->pve.name.len==pvname->len)
4951 {
4952 found = strncmp(pvi->pve.name.s, pvname->s, pvname->len);
4953 if(found>0)
4954 break;
4955 if(found==0)
4956 {
4957 LM_DBG("found in extra list [%.*s]\n", pvname->len, pvname->s);
4958 /* copy data from export to spec */
4959 e->type = pvi->pve.type;
4960 e->getf = pvi->pve.getf;
4961 e->setf = pvi->pve.setf;
4962 return &(pvi->pve);
4963 }
4964 }
4965 pvi = pvi->next;
4966 }
4967
4968 return NULL;
4969}

Callers 1

pv_parse_specFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected