4 * Copyright (C) 2001-2003 FhG Fokus
6 * This file is part of SIP-Router, a free SIP server.
8 * SIP-Router is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version
13 * SIP-Router is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 * \brief SIP-router core :: PV API specification
33 #include <sys/types.h>
37 #include "mem/shm_mem.h"
42 #include "pvapi_init.h"
45 #define is_in_str(p, in) (p<in->s+in->len && *p)
47 #define PV_TABLE_SIZE 16
48 #define TR_TABLE_SIZE 4
51 void tr_destroy(trans_t *t);
52 void tr_free(trans_t *t);
54 typedef struct _pv_item
58 struct _pv_item *next;
59 } pv_item_t, *pv_item_p;
61 static pv_item_t* _pv_table[PV_TABLE_SIZE];
62 static int _pv_table_set = 0;
68 void pv_init_table(void)
70 memset(_pv_table, 0, sizeof(pv_item_t*)*PV_TABLE_SIZE);
77 static int is_pv_valid_char(char c)
79 if((c>='0' && c<='9') || (c>='a' && c<='z') || (c>='A' && c<='Z')
80 || (c=='_') || (c=='.') || (c=='?') /* ser $? */)
88 int pv_table_add(pv_export_t *e)
92 pv_item_t *pvi = NULL;
93 pv_item_t *pvj = NULL;
94 pv_item_t *pvn = NULL;
98 if(e==NULL || e->name.s==NULL || e->getf==NULL || e->type==PVT_NONE)
100 LM_ERR("invalid parameters\n");
106 LM_DBG("PV table not initialized, doing it now\n");
111 while(is_in_str(p,in) && is_pv_valid_char(*p))
115 LM_ERR("invalid char [%c] in [%.*s]\n", *p, in->len, in->s);
119 //pvid = get_hash1_raw(in->s, in->len);
120 pvid = get_hash1_raw(in->s, in->len);
122 pvi = _pv_table[pvid%PV_TABLE_SIZE];
127 if(pvi->pve.name.len==in->len)
129 found = strncmp(pvi->pve.name.s, in->s, in->len);
133 LM_ERR("pvar [%.*s] already exists\n", in->len, in->s);
141 pvn = (pv_item_t*)pkg_malloc(sizeof(pv_item_t));
144 LM_ERR("no more memory\n");
147 memset(pvn, 0, sizeof(pv_item_t));
148 memcpy(&(pvn->pve), e, sizeof(pv_export_t));
153 pvn->next = _pv_table[pvid%PV_TABLE_SIZE];
154 _pv_table[pvid%PV_TABLE_SIZE] = pvn;
157 pvn->next = pvj->next;
167 int register_pvars_mod(char *mod_name, pv_export_t *items)
175 for ( i=0 ; items[i].name.s ; i++ ) {
176 ret = pv_table_add(&items[i]);
178 LM_ERR("failed to register pseudo-variable <%.*s> for module %s\n",
179 items[i].name.len, items[i].name.s, mod_name);
188 int pv_table_free(void)
194 for(i=0; i<PV_TABLE_SIZE; i++)
204 memset(_pv_table, 0, sizeof(pv_item_t*)*PV_TABLE_SIZE);
210 /********** helper functions ********/
212 * convert unsigned int to pv_value_t
214 int pv_get_uintval(struct sip_msg *msg, pv_param_t *param,
215 pv_value_t *res, unsigned int uival)
223 ch = int2str(uival, &l);
227 res->ri = (int)uival;
228 res->flags = PV_VAL_STR|PV_VAL_INT|PV_TYPE_INT;
233 * convert signed int to pv_value_t
235 int pv_get_sintval(struct sip_msg *msg, pv_param_t *param,
236 pv_value_t *res, int sival)
244 ch = sint2str(sival, &l);
249 res->flags = PV_VAL_STR|PV_VAL_INT|PV_TYPE_INT;
254 * convert str to pv_value_t
256 int pv_get_strval(struct sip_msg *msg, pv_param_t *param,
257 pv_value_t *res, str *sval)
263 res->flags = PV_VAL_STR;
268 * convert str-int to pv_value_t (type is str)
270 int pv_get_strintval(struct sip_msg *msg, pv_param_t *param,
271 pv_value_t *res, str *sval, int ival)
278 res->flags = PV_VAL_STR|PV_VAL_INT;
283 * convert int-str to pv_value_t (type is int)
285 int pv_get_intstrval(struct sip_msg *msg, pv_param_t *param,
286 pv_value_t *res, int ival, str *sval)
293 res->flags = PV_VAL_STR|PV_VAL_INT|PV_TYPE_INT;
297 /*** ============================= ***/
298 static str pv_str_marker = { PV_MARKER_STR, 1 };
299 static int pv_get_marker(struct sip_msg *msg, pv_param_t *param,
302 return pv_get_strintval(msg, param, res, &pv_str_marker,
303 (int)pv_str_marker.s[0]);
306 static str pv_str_empty = { "", 0 };
307 static str pv_str_null = { "<null>", 6 };
308 int pv_get_null(struct sip_msg *msg, pv_param_t *param, pv_value_t *res)
313 res->rs = pv_str_empty;
315 res->flags = PV_VAL_NULL;
319 pv_export_t* pv_lookup_spec_name(str *pvname, pv_spec_p e)
324 if(pvname==0 || e==0)
326 LM_ERR("bad parameters\n");
330 /* search in PV table */
331 // pvid = get_hash1_raw(pvname->s, pvname->len);
332 pvid = get_hash1_raw(pvname->s, pvname->len);
333 pvi = _pv_table[pvid%PV_TABLE_SIZE];
339 if(pvi->pvid==pvid && pvi->pve.name.len==pvname->len
340 && memcmp(pvi->pve.name.s, pvname->s, pvname->len)==0)
342 /*LM_DBG("found [%.*s] [%d]\n", pvname->len, pvname->s,
343 _pv_names_table[i].type);*/
344 /* copy data from table to spec */
345 e->type = pvi->pve.type;
346 e->getf = pvi->pve.getf;
347 e->setf = pvi->pve.setf;
356 int pv_parse_index(pv_spec_p sp, str *in)
363 if(in==NULL || in->s==NULL || sp==NULL)
368 nsp = (pv_spec_p)pkg_malloc(sizeof(pv_spec_t));
371 LM_ERR("no more memory\n");
374 s = pv_parse_spec(in, nsp);
377 LM_ERR("invalid index [%.*s]\n", in->len, in->s);
381 sp->pvp.pvi.type = PV_IDX_PVAR;
382 sp->pvp.pvi.u.dval = (void*)nsp;
385 if(*p=='*' && in->len==1)
387 sp->pvp.pvi.type = PV_IDX_ALL;
396 sp->pvp.pvi.u.ival = 0;
397 while(p<in->s+in->len && *p>='0' && *p<='9')
399 sp->pvp.pvi.u.ival = sp->pvp.pvi.u.ival * 10 + *p - '0';
404 LM_ERR("invalid index [%.*s]\n", in->len, in->s);
407 sp->pvp.pvi.u.ival *= sign;
408 sp->pvp.pvi.type = PV_IDX_INT;
412 int pv_init_iname(pv_spec_p sp, int param)
416 sp->pvp.pvn.type = PV_NAME_INTSTR;
417 sp->pvp.pvn.u.isname.name.n = param;
421 char* pv_parse_spec2(str *in, pv_spec_p e, int silent)
428 pv_export_t *pte = NULL;
431 if(in==NULL || in->s==NULL || e==NULL || *in->s!=PV_MARKER)
433 if (!silent) LM_ERR("bad parameters\n");
437 /* LM_DBG("***** input [%.*s] (%d)\n", in->len, in->s, in->len); */
440 memset(e, 0, sizeof(pv_spec_t));
449 if(*p == PV_MARKER) {
457 e->getf = pv_get_marker;
458 e->type = PVT_MARKER;
462 while(is_in_str(p,in) && is_pv_valid_char(*p))
464 pvname.len = p - pvname.s;
468 { /* full pv name ended here*/
470 } else if(*p==PV_LNBRACKET) {
473 } else if(*p==PV_LIBRACKET) {
476 } else if(*p==TR_LBRACKET) {
481 LM_ERR("invalid char '%c' in [%.*s] (%d)\n",
482 *p, in->len, in->s, pvstate);
486 if(!is_in_str(p, in)) {
489 } else if(*p==PV_LNBRACKET) {
493 /* still in input str, but end of PV */
494 /* p is increased at the end, so decrement here */
501 if((pte = pv_lookup_spec_name(&pvname, e))==NULL)
504 LM_ERR("error searching pvar \"%.*s\"\n", pvname.len, pvname.s);
507 if(pte->parse_name!=NULL && pvstate!=2 && pvstate!=5)
510 LM_ERR("pvar \"%.*s\" expects an inner name\n",
511 pvname.len, pvname.s);
514 if(pvstate==2 || pvstate==5)
516 if(pte->parse_name==NULL)
519 LM_ERR("pvar \"%.*s\" does not get name param\n",
520 pvname.len, pvname.s);
525 while(is_in_str(p, in))
533 if(*p == PV_LNBRACKET)
538 if(!is_in_str(p, in))
544 LM_ERR("pvar \"%.*s\" does not get empty name param\n",
545 pvname.len, pvname.s);
549 if(pte->parse_name(e, &s)!=0)
552 LM_ERR("pvar \"%.*s\" has an invalid name param [%.*s]\n",
553 pvname.len, pvname.s, s.len, s.s);
560 { /* full pv name ended here*/
562 } else if(*p==PV_LIBRACKET) {
565 } else if(*p==TR_LBRACKET) {
570 LM_ERR("invalid char '%c' in [%.*s] (%d)\n",
571 *p, in->len, in->s, pvstate);
576 { /* full pv name ended here*/
581 LM_ERR("invalid char '%c' in [%.*s] (%d)\n",
582 *p, in->len, in->s, pvstate);
590 if(pte->parse_index==NULL)
593 LM_ERR("pvar \"%.*s\" does not get index param\n",
594 pvname.len, pvname.s);
599 while(is_in_str(p, in))
607 if(*p == PV_LIBRACKET)
611 if(!is_in_str(p, in))
617 LM_ERR("pvar \"%.*s\" does not get empty index param\n",
618 pvname.len, pvname.s);
622 if(pte->parse_index(e, &s)!=0)
625 LM_ERR("pvar \"%.*s\" has an invalid index param [%.*s]\n",
626 pvname.len, pvname.s, s.len, s.s);
631 { /* full pv name ended here*/
633 } else if(*p==TR_LBRACKET) {
638 LM_ERR("invalid char '%c' in [%.*s] (%d)\n",
639 *p, in->len, in->s, pvstate);
648 while(is_in_str(p, in))
654 /* yet another transformation */
656 while(is_in_str(p, in) && (*p==' ' || *p=='\t')) p++;
658 if(!is_in_str(p, in) || *p != TR_LBRACKET)
666 if(*p == TR_LBRACKET)
670 if(!is_in_str(p, in))
676 LM_ERR("pvar \"%.*s\" does not get empty index param\n",
677 pvname.len, pvname.s);
682 p = tr_lookup(&s, &tr);
686 LM_ERR("bad tr in pvar name \"%.*s\"\n", pvname.len, pvname.s);
692 LM_ERR("bad pvar name \"%.*s\" (%c)!\n", in->len, in->s, *p);
695 e->trans = (void*)tr;
700 if(pte!=NULL && pte->init_param)
701 pte->init_param(e, pte->iparam);
707 LM_ERR("wrong char [%c/%d] in [%.*s] at [%d (%d)]\n", *p, (int)*p,
708 in->len, in->s, (int)(p-in->s), pvstate);
711 LM_ERR("invalid parsing in [%.*s] at (%d)\n",
712 in->len, in->s, pvstate);
716 } /* end: pv_parse_spec */
721 int pv_parse_format(str *in, pv_elem_p *el)
728 if(in==NULL || in->s==NULL || el==NULL)
731 /*LM_DBG("parsing [%.*s]\n", in->len, in->s);*/
735 *el = pkg_malloc(sizeof(pv_elem_t));
738 memset(*el, 0, sizeof(pv_elem_t));
747 while(is_in_str(p,in))
750 e = pkg_malloc(sizeof(pv_elem_t));
753 memset(e, 0, sizeof(pv_elem_t));
761 while(is_in_str(p,in) && *p!=PV_MARKER)
763 e->text.len = p - e->text.s;
765 if(*p == '\0' || !is_in_str(p,in))
768 s.len = in->s+in->len-p;
769 p0 = pv_parse_spec(&s, &e->spec);
777 /*LM_DBG("format parsed OK: [%d] items\n", n);*/
785 pv_elem_free_all(*el);
790 int pv_get_spec_name(struct sip_msg* msg, pv_param_p ip, pv_value_t *name)
792 if(msg==NULL || ip==NULL || name==NULL)
794 memset(name, 0, sizeof(pv_value_t));
796 if(ip->pvn.type==PV_NAME_INTSTR)
798 if(ip->pvn.u.isname.type&AVP_NAME_STR)
800 name->rs = ip->pvn.u.isname.name.s;
801 name->flags = PV_VAL_STR;
803 name->ri = ip->pvn.u.isname.name.n;
804 name->flags = PV_VAL_INT|PV_TYPE_INT;
807 } else if(ip->pvn.type==PV_NAME_PVAR) {
809 if(pv_get_spec_value(msg, (pv_spec_p)(ip->pvn.u.dname), name)!=0)
811 LM_ERR("cannot get name value\n");
814 if(name->flags&PV_VAL_NULL || name->flags&PV_VAL_EMPTY)
816 LM_ERR("null or empty name\n");
821 LM_ERR("name type is PV_NAME_OTHER - cannot resolve\n");
825 int pv_get_avp_name(struct sip_msg* msg, pv_param_p ip, int_str *avp_name,
826 unsigned short *name_type)
829 if(ip==NULL || avp_name==NULL || name_type==NULL)
831 memset(avp_name, 0, sizeof(int_str));
834 if(ip->pvn.type==PV_NAME_INTSTR)
836 *name_type = ip->pvn.u.isname.type;
837 if(ip->pvn.u.isname.type&AVP_NAME_STR)
839 avp_name->s = ip->pvn.u.isname.name.s;
840 *name_type |= AVP_NAME_STR;
842 avp_name->n = ip->pvn.u.isname.name.n;
843 /* *name_type &= AVP_SCRIPT_MASK; */
849 if(pv_get_spec_value(msg, (pv_spec_p)(ip->pvn.u.dname), &tv)!=0)
851 LM_ERR("cannot get avp value\n");
854 if(tv.flags&PV_VAL_NULL || tv.flags&PV_VAL_EMPTY)
856 LM_ERR("null or empty name\n");
860 if((tv.flags&PV_TYPE_INT) && (tv.flags&PV_VAL_INT))
865 *name_type = AVP_NAME_STR;
871 int pv_get_spec_index(struct sip_msg* msg, pv_param_p ip, int *idx, int *flags)
874 if(ip==NULL || idx==NULL || flags==NULL)
880 if(ip->pvi.type == PV_IDX_ALL) {
885 if(ip->pvi.type == PV_IDX_INT)
887 *idx = ip->pvi.u.ival;
892 if(pv_get_spec_value(msg, (pv_spec_p)ip->pvi.u.dval, &tv)!=0)
894 LM_ERR("cannot get index value\n");
897 if(!(tv.flags&PV_VAL_INT))
899 LM_ERR("invalid index value\n");
906 int pv_get_spec_value(struct sip_msg* msg, pv_spec_p sp, pv_value_t *value)
910 if(msg==NULL || sp==NULL || sp->getf==NULL || value==NULL
911 || sp->type==PVT_NONE)
913 LM_ERR("bad parameters\n");
917 memset(value, 0, sizeof(pv_value_t));
919 ret = (*sp->getf)(msg, &(sp->pvp), value);
924 return tr_exec(msg, (trans_t*)sp->trans, value);
928 int pv_set_spec_value(struct sip_msg* msg, pv_spec_p sp, int op,
931 if(sp==NULL || !pv_is_w(sp))
932 return 0; /* no op */
933 if(pv_alter_context(sp) && is_route_type(LOCAL_ROUTE))
934 return 0; /* no op */
935 return sp->setf(msg, &sp->pvp, op, value);
941 int pv_printf(struct sip_msg* msg, pv_elem_p list, char *buf, int *len)
948 if(msg==NULL || list==NULL || buf==NULL || len==NULL)
959 for (it=list; it; it=it->next)
962 if(it->text.s && it->text.len>0)
964 if(n+it->text.len < *len)
966 memcpy(cur, it->text.s, it->text.len);
970 LM_ERR("no more space for text [%d]\n", it->text.len);
974 /* put the value of the specifier */
975 if(it->spec.type!=PVT_NONE
976 && pv_get_spec_value(msg, &(it->spec), &tok)==0)
978 if(tok.flags&PV_VAL_NULL)
979 tok.rs = pv_str_null;
980 if(n+tok.rs.len < *len)
984 memcpy(cur, tok.rs.s, tok.rs.len);
989 LM_ERR("no more space for spec value\n");
998 LM_ERR("buffer overflow -- increase the buffer size...\n");
1003 LM_DBG("final buffer length %d\n", n);
1013 pvname_list_t* parse_pvname_list(str *in, unsigned int type)
1015 pvname_list_t* head = NULL;
1016 pvname_list_t* al = NULL;
1017 pvname_list_t* last = NULL;
1022 if(in==NULL || in->s==NULL)
1024 LM_ERR("bad parameters\n");
1029 while(is_in_str(p, in))
1031 while(is_in_str(p, in) && (*p==' '||*p=='\t'||*p==','||*p==';'))
1033 if(!is_in_str(p, in))
1036 LM_ERR("wrong item name list [%.*s]\n", in->len, in->s);
1040 s.len = in->s+in->len-p;
1041 p = pv_parse_spec(&s, &spec);
1042 if(p==NULL || (type && spec.type!=type))
1044 LM_ERR("wrong item name list [%.*s]!\n", in->len, in->s);
1047 al = (pvname_list_t*)pkg_malloc(sizeof(pvname_list_t));
1050 LM_ERR("no more memory!\n");
1053 memset(al, 0, sizeof(pvname_list_t));
1054 memcpy(&al->sname, &spec, sizeof(pv_spec_t));
1081 void pv_spec_free(pv_spec_t *spec)
1084 /* TODO: free name if it is PV */
1086 tr_free((trans_t*)spec->trans);
1093 int pv_elem_free_all(pv_elem_p log)
1108 void pv_value_destroy(pv_value_t *val)
1111 if(val->flags&PV_VAL_PKG) pkg_free(val->rs.s);
1112 if(val->flags&PV_VAL_SHM) shm_free(val->rs.s);
1113 memset(val, 0, sizeof(pv_value_t));
1116 #define PV_PRINT_BUF_SIZE 1024
1117 #define PV_PRINT_BUF_NO 3
1118 int pv_printf_s(struct sip_msg* msg, pv_elem_p list, str *s)
1120 static int buf_itr = 0;
1121 static char buf[PV_PRINT_BUF_NO][PV_PRINT_BUF_SIZE];
1123 s->s = buf[buf_itr];
1124 s->len = PV_PRINT_BUF_SIZE;
1125 buf_itr = (buf_itr+1)%PV_PRINT_BUF_NO;
1126 return pv_printf( msg, list, s->s, &s->len);
1129 /********************************************************
1130 * Transformations API
1131 ********************************************************/
1136 static inline char* tr_get_class(str *in, char *p, str *tclass)
1139 while(is_in_str(p, in) && *p!=TR_CLASS_MARKER) p++;
1140 if(*p!=TR_CLASS_MARKER || tclass->s == p)
1142 LM_ERR("invalid transformation: %.*s (%c)!\n", in->len, in->s, *p);
1145 tclass->len = p - tclass->s;
1154 static inline trans_t* tr_new(void)
1158 t = (trans_t*)pkg_malloc(sizeof(trans_t));
1161 LM_ERR("no more private memory\n");
1164 memset(t, 0, sizeof(trans_t));
1168 char* tr_lookup(str *in, trans_t **tr)
1173 tr_export_t *te = NULL;
1178 if(in==NULL || in->s==NULL || tr==NULL)
1183 while(is_in_str(p, in) && (*p==' ' || *p=='\t' || *p=='\n')) p++;
1184 if(*p != TR_LBRACKET)
1188 if((t = tr_new())==NULL) return NULL;
1190 if(t0==NULL) *tr = t;
1194 /* find transformation class */
1195 p = tr_get_class(in, p, &tclass);
1196 if(p==NULL) goto error;
1198 /* locate transformation */
1199 te = tr_lookup_class(&tclass);
1202 LM_ERR("unknown transformation: [%.*s] in [%.*s]\n",
1203 tclass.len, tclass.s, in->len, in->s);
1207 s.s = p; s.len = in->s + in->len - p;
1208 p0 = te->tparse(&s, t);
1213 if(*p != TR_RBRACKET)
1215 LM_ERR("invalid transformation: %.*s | %c !!\n", in->len,
1221 if(!is_in_str(p, in))
1227 LM_ERR("error parsing [%.*s]\n", in->len, in->s);
1240 * \brief Destroy transformation including eventual parameter
1241 * \param t transformation
1243 void tr_destroy(trans_t *t)
1256 memset(t, 0, sizeof(trans_t));
1260 * \brief Exec transformation on a pseudo-variable value
1261 * \param msg SIP message
1262 * \param tr one or more transformations
1263 * \param val pseudo-variable value
1264 * \return 0 on success, -1 on error
1267 int tr_exec(struct sip_msg *msg, trans_t *t, pv_value_t *v)
1272 if(t==NULL || v==NULL)
1274 LM_DBG("invalid parameters\n");
1278 for(i = t; i!=NULL; i=i->next)
1280 r = (*i->trf)(msg, i->params, i->subtype, v);
1288 * \brief Free allocated memory of transformation list
1289 * \param t transformation list
1291 void tr_free(trans_t *t)
1306 * \brief Free transformation parameter list
1307 * \param tp transformation list
1309 void tr_param_free(tr_param_t *tp)
1313 if(tp==NULL) return;
1318 if(tp0->type==TR_PARAM_SPEC)
1319 pv_spec_free((pv_spec_t*)tp0->v.data);
1324 typedef struct _tr_item
1328 struct _tr_item *next;
1329 } tr_item_t, *tr_item_p;
1331 static tr_item_t* _tr_table[TR_TABLE_SIZE];
1332 static int _tr_table_set = 0;
1338 void tr_init_table(void)
1340 memset(_tr_table, 0, sizeof(tr_item_t*)*TR_TABLE_SIZE);
1347 int tr_table_add(tr_export_t *e)
1349 tr_item_t *tri = NULL;
1350 tr_item_t *trj = NULL;
1351 tr_item_t *trn = NULL;
1355 if(e==NULL || e->tclass.s==NULL)
1357 LM_ERR("invalid parameters\n");
1361 if(_tr_table_set==0)
1363 LM_DBG("TR table not initialized, doing it now\n");
1368 // trid = get_hash1_raw(e->tclass.s, e->tclass.len);
1369 trid = get_hash1_raw(e->tclass.s, e->tclass.len);
1371 tri = _tr_table[trid%TR_TABLE_SIZE];
1374 if(tri->tre.tclass.len==e->tclass.len)
1376 found = strncmp(tri->tre.tclass.s, e->tclass.s, e->tclass.len);
1379 LM_ERR("TR class [%.*s] already exists\n", e->tclass.len,
1388 trn = (tr_item_t*)pkg_malloc(sizeof(tr_item_t));
1391 LM_ERR("no more memory\n");
1394 memset(trn, 0, sizeof(tr_item_t));
1395 memcpy(&(trn->tre), e, sizeof(tr_export_t));
1398 //LM_DBG("TR class [%.*s] added to entry [%d]\n", e->tclass.len,
1399 // e->tclass.s, trid%TR_TABLE_SIZE);
1402 trn->next = _tr_table[trid%TR_TABLE_SIZE];
1403 _tr_table[trid%TR_TABLE_SIZE] = trn;
1406 trn->next = trj->next;
1416 int register_trans_mod(char *mod_name, tr_export_t *items)
1424 for ( i=0 ; items[i].tclass.s ; i++ ) {
1425 ret = tr_table_add(&items[i]);
1427 LM_ERR("failed to register pseudo-variable <%.*s> for module %s\n",
1428 items[i].tclass.len, items[i].tclass.s, mod_name);
1437 int tr_table_free(void)
1443 for(i=0; i<TR_TABLE_SIZE; i++)
1453 memset(_tr_table, 0, sizeof(tr_item_t*)*TR_TABLE_SIZE);
1459 tr_export_t* tr_lookup_class(str *tclass)
1464 if(tclass==0 || tclass->s==0)
1466 LM_ERR("bad parameters\n");
1470 /* search in TR table */
1471 // trid = get_hash1_raw(tclass->s, tclass->len);
1472 trid = get_hash1_raw(tclass->s, tclass->len);
1473 tri = _tr_table[trid%TR_TABLE_SIZE];
1476 if(tri->trid==trid && tri->tre.tclass.len==tclass->len
1477 && memcmp(tri->tre.tclass.s, tclass->s, tclass->len)==0)
1486 /** init pv api (optional).
1487 * @return 0 on success, -1 on error
1489 int init_pv_api(void)
1497 /** destroy pv api. */
1498 void destroy_pv_api(void)
1500 /* free PV and TR hash tables */