Merge commit 'origin/daniel/pv'
authorAndrei Pelinescu-Onciul <andrei@iptel.org>
Fri, 19 Dec 2008 13:57:57 +0000 (14:57 +0100)
committerAndrei Pelinescu-Onciul <andrei@iptel.org>
Fri, 19 Dec 2008 13:57:57 +0000 (14:57 +0100)
* commit 'origin/daniel/pv':
  fix add/lookup pv name
  fix pv&t lookup due to signness
  pv api updates
  - list of PVs types syncronized with Kamailio

Conflicts:
pvapi.c

1  2 
pvapi.c
pvar.h
ut.h

diff --cc pvapi.c
+++ b/pvapi.c
@@@ -352,7 -349,72 +349,72 @@@ pv_export_t* pv_lookup_spec_name(str *p
        return NULL;
  }
  
 -char* pv_parse_spec(str *in, pv_spec_p e)
+ int pv_parse_index(pv_spec_p sp, str *in)
+ {
+       char *p;
+       char *s;
+       int sign;
+       pv_spec_p nsp = 0;
+       if(in==NULL || in->s==NULL || sp==NULL)
+               return -1;
+       p = in->s;
+       if(*p==PV_MARKER)
+       {
+               nsp = (pv_spec_p)pkg_malloc(sizeof(pv_spec_t));
+               if(nsp==NULL)
+               {
+                       LM_ERR("no more memory\n");
+                       return -1;
+               }
+               s = pv_parse_spec(in, nsp);
+               if(s==NULL)
+               {
+                       LM_ERR("invalid index [%.*s]\n", in->len, in->s);
+                       pv_spec_free(nsp);
+                       return -1;
+               }
+               sp->pvp.pvi.type = PV_IDX_PVAR;
+               sp->pvp.pvi.u.dval = (void*)nsp;
+               return 0;
+       }
+       if(*p=='*' && in->len==1)
+       {
+               sp->pvp.pvi.type = PV_IDX_ALL;
+               return 0;
+       }
+       sign = 1;
+       if(*p=='-')
+       {
+               sign = -1;
+               p++;
+       }
+       sp->pvp.pvi.u.ival = 0;
+       while(p<in->s+in->len && *p>='0' && *p<='9')
+       {
+               sp->pvp.pvi.u.ival = sp->pvp.pvi.u.ival * 10 + *p - '0';
+               p++;
+       }
+       if(p!=in->s+in->len)
+       {
+               LM_ERR("invalid index [%.*s]\n", in->len, in->s);
+               return -1;
+       }
+       sp->pvp.pvi.u.ival *= sign;
+       sp->pvp.pvi.type = PV_IDX_INT;
+       return 0;
+ }
+ int pv_init_iname(pv_spec_p sp, int param)
+ {
+       if(sp==NULL)
+               return -1;
+       sp->pvp.pvn.type = PV_NAME_INTSTR;
+       sp->pvp.pvn.u.isname.name.n = param;
+       return 0;
+ }
 +char* pv_parse_spec2(str *in, pv_spec_p e, int silent)
  {
        char *p;
        str s;
diff --cc pvar.h
--- 1/pvar.h
--- 2/pvar.h
+++ b/pvar.h
@@@ -158,10 -163,8 +163,9 @@@ typedef struct _pv_ele
        struct _pv_elem *next;
  } pv_elem_t, *pv_elem_p;
  
 -char* pv_parse_spec(str *in, pv_spec_p sp);
 +char* pv_parse_spec2(str *in, pv_spec_p sp, int silent);
 +#define pv_parse_spec(in, sp) pv_parse_spec2((in), (sp), 0)
  int pv_get_spec_value(struct sip_msg* msg, pv_spec_p sp, pv_value_t *value);
- int pv_print_spec(struct sip_msg* msg, pv_spec_p sp, char *buf, int *len);
  int pv_printf(struct sip_msg* msg, pv_elem_p list, char *buf, int *len);
  int pv_elem_free_all(pv_elem_p log);
  void pv_value_destroy(pv_value_t *val);
diff --cc ut.h
Simple merge