本文整理汇总了C++中pv_parse_format函数的典型用法代码示例。如果您正苦于以下问题:C++ pv_parse_format函数的具体用法?C++ pv_parse_format怎么用?C++ pv_parse_format使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pv_parse_format函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: fixup_insert_avp
static int fixup_insert_avp(void** param, int param_no)
{
pv_elem_t* pv_elem;
str s;
if(param_no== 0)
return 0;
if(!param)
{
LM_ERR( "null format\n");
return E_UNSPEC;
}
s.s = (char*)(*param); s.len = strlen(s.s);
if(param_no == 3) /* the third argumet in an integer */
{
unsigned int* index;
index = (unsigned int*)pkg_malloc(sizeof(unsigned int*));
if(index == NULL)
{
LM_ERR("No more memory\n");
return E_OUT_OF_MEM;
}
if(str2int(&s, index) < 0)
{
LM_ERR("Bad format for the third argument - must be a positive integer\n");
return E_UNSPEC;
}
*param = (void*)index;
return 0;
}
if(pv_parse_format(&s, &pv_elem)<0)
{
LM_ERR( "wrong format[%s]\n",(char*)(*param));
return E_UNSPEC;
}
*param = (void*)pv_elem;
/* attr name is mandatory */
if (param_no == 1 && pv_elem->spec.type!=PVT_AVP)
{
LM_ERR("The first parameter must be an AVP name\n");
return E_UNSPEC;
}
*param = (void*)pv_elem;
return 0;
}
开发者ID:ryzhov,项目名称:ATS0,代码行数:54,代码来源:avpops.c
示例2: log_prefix_init
void log_prefix_init(void)
{
str s;
if(log_prefix_fmt==NULL)
return;
s.s = log_prefix_fmt; s.len = strlen(s.s);
if(pv_parse_format(&s, &log_prefix_pvs)<0)
{
LM_ERR("wrong format[%s]\n", s.s);
return;
}
}
开发者ID:spicyramen,项目名称:kamailio,代码行数:13,代码来源:dprint.c
示例3: acc_fixup
static int acc_fixup(void** param, int param_no)
{
struct acc_param *accp;
char *p;
p = (char*)*param;
if (p==0 || p[0]==0) {
LM_ERR("first parameter is empty\n");
return E_SCRIPT;
}
if (param_no == 1) {
accp = (struct acc_param*)pkg_malloc(sizeof(struct acc_param));
if (!accp) {
LM_ERR("no more pkg mem\n");
return E_OUT_OF_MEM;
}
memset( accp, 0, sizeof(struct acc_param));
accp->reason.s = p;
accp->reason.len = strlen(p);
if (strchr(p,PV_MARKER)!=NULL) { /* is a variable $xxxxx */
if (pv_parse_format(&accp->reason, &accp->elem)<0)
{
LM_ERR("bad param 1 - parse format error [%.*s]\n",
accp->reason.len, accp->reason.s);
pkg_free(accp);
return E_UNSPEC;
}
}
else {
if(acc_parse_code(p,accp)<0)
{
LM_ERR("bad param 1 - parse code error\n");
pkg_free(accp);
return E_UNSPEC;
}
}
*param = (void*)accp;
#ifdef SQL_ACC
} else if (param_no == 2) {
/* only for db acc - the table name */
if (db_url.s==0) {
pkg_free(p);
*param = 0;
} else {
return fixup_var_pve_str_12(param, 2);
}
#endif
}
return 0;
}
开发者ID:SipSeb,项目名称:kamailio,代码行数:51,代码来源:acc_mod.c
示例4: pv_parse_name
int pv_parse_name(pv_spec_p sp, str *in)
{
stat_var *stat;
pv_elem_t *format;
if(in==NULL || in->s==NULL || sp==NULL)
return -1;
LM_NOTICE("xXx name %p with name <%.*s>\n", &sp->pvp.pvn, in->len, in->s);
if (pv_parse_format( in, &format)!=0) {
LM_ERR("failed to parse statistic name format <%.*s> \n",
in->len,in->s);
return -1;
}
/* text only ? */
if (format->next==NULL && format->spec.type==PVT_NONE) {
/* search for the statistic */
stat = get_stat( &format->text );
if (stat==NULL) {
/* statistic does not exist (yet) -> fill in the string name */
sp->pvp.pvn.type = PV_NAME_INTSTR;
sp->pvp.pvn.u.isname.type = AVP_NAME_STR;
if (clone_pv_stat_name( in, &sp->pvp.pvn.u.isname.name.s )!=0) {
LM_ERR("failed to clone name of statistic \n");
return -1;
}
LM_NOTICE("xXx name %p, name cloned (in=%p, out=%p)\n",
&sp->pvp.pvn, in->s, sp->pvp.pvn.u.isname.name.s.s);
} else {
/* link the stat pointer directly as dynamic name */
sp->pvp.pvn.type = PV_NAME_PVAR;
sp->pvp.pvn.u.dname = (void*)stat;
LM_NOTICE("xXx name %p, stat found\n", &sp->pvp.pvn);
}
} else {
sp->pvp.pvn.type = PV_NAME_INTSTR;
sp->pvp.pvn.u.isname.type = 0; /* not string */
sp->pvp.pvn.u.isname.name.s.s = (char*)(void*)format;
sp->pvp.pvn.u.isname.name.s.len = 0;
LM_NOTICE("xXx name %p, stat name is FMT\n", &sp->pvp.pvn);
}
return 0;
}
开发者ID:Danfx,项目名称:opensips,代码行数:50,代码来源:statistics.c
示例5: fixup_db_query_avp
static int fixup_db_query_avp(void** param, int param_no)
{
pv_elem_t *model = NULL;
pvname_list_t *anlist = NULL;
str s;
if (db_url.s==0)
{
LM_ERR("you have to configure db_url for using avp_db_query function\n");
return E_UNSPEC;
}
s.s = (char*)(*param);
if (param_no==1)
{
if(s.s==NULL)
{
LM_ERR("null format in P%d\n",
param_no);
return E_UNSPEC;
}
s.len = strlen(s.s);
if(pv_parse_format(&s, &model)<0)
{
LM_ERR("wrong format[%s]\n", s.s);
return E_UNSPEC;
}
*param = (void*)model;
return 0;
} else if(param_no==2) {
if(s.s==NULL)
{
LM_ERR("null format in P%d\n", param_no);
return E_UNSPEC;
}
s.len = strlen(s.s);
anlist = parse_pvname_list(&s, PVT_AVP);
if(anlist==NULL)
{
LM_ERR("bad format in P%d [%s]\n", param_no, s.s);
return E_UNSPEC;
}
*param = (void*)anlist;
return 0;
}
return 0;
}
开发者ID:mehulsbhatt,项目名称:voip-foip,代码行数:50,代码来源:avpops.c
示例6: fixup_db_query_avp
static int fixup_db_query_avp(void** param, int param_no)
{
pv_elem_t *model = NULL;
pvname_list_t *anlist = NULL;
str s;
if (default_db_url==NULL) {
LM_ERR("no db url defined to be used by this function\n");
return E_CFG;
}
s.s = (char*)(*param);
if (param_no==1)
{
if(s.s==NULL)
{
LM_ERR("null format in P%d\n",
param_no);
return E_UNSPEC;
}
s.len = strlen(s.s);
if(pv_parse_format(&s, &model)<0)
{
LM_ERR("wrong format[%s]\n", s.s);
return E_UNSPEC;
}
*param = (void*)model;
return 0;
} else if(param_no==2) {
if(s.s==NULL || s.s[0]==0) {
*param = NULL;
return 0;
}
s.len = strlen(s.s);
anlist = parse_pvname_list(&s, PVT_AVP);
if(anlist==NULL)
{
LM_ERR("bad format in P%d [%s]\n", param_no, s.s);
return E_UNSPEC;
}
*param = (void*)anlist;
return 0;
} else if (param_no==3) {
return fixup_db_url(param);
}
return 0;
}
开发者ID:NoamRom89,项目名称:opensips,代码行数:50,代码来源:avpops.c
示例7: mp_fixup
/**
* fixes the module functions' parameters if it is a phone number.
* supports string, pseudo-variables and AVPs.
*
* @param param the parameter
*
* @return 0 on success, -1 on failure
*/
static int mp_fixup(void ** param) {
pv_spec_t avp_spec;
struct multiparam_t *mp;
str s;
mp = (struct multiparam_t *)pkg_malloc(sizeof(struct multiparam_t));
if (mp == NULL) {
LM_ERR("out of pkg memory\n");
return -1;
}
memset(mp, 0, sizeof(struct multiparam_t));
s.s = (char *)(*param);
s.len = strlen(s.s);
if (s.s[0]!='$') {
/* This is string */
mp->type=MP_STR;
mp->u.s=s;
}
else {
/* This is a pseudo-variable */
if (pv_parse_spec(&s, &avp_spec)==0) {
LM_ERR("pv_parse_spec failed for '%s'\n", (char *)(*param));
pkg_free(mp);
return -1;
}
if (avp_spec.type==PVT_AVP) {
/* This is an AVP - could be an id or name */
mp->type=MP_AVP;
if(pv_get_avp_name(0, &(avp_spec.pvp), &(mp->u.a.name), &(mp->u.a.flags))!=0) {
LM_ERR("Invalid AVP definition <%s>\n", (char *)(*param));
pkg_free(mp);
return -1;
}
} else {
mp->type=MP_PVE;
if(pv_parse_format(&s, &(mp->u.p))<0) {
LM_ERR("pv_parse_format failed for '%s'\n", (char *)(*param));
pkg_free(mp);
return -1;
}
}
}
*param = (void*)mp;
return 0;
}
开发者ID:kiryu,项目名称:kamailio,代码行数:56,代码来源:matrix.c
示例8: pv_fixup
/**
* fixes the module functions' parameters with generic pseudo variable support.
*
* @param param the parameter
*
* @return 0 on success, -1 on failure
*/
static int pv_fixup(void ** param) {
pv_elem_t *model;
str s;
s.s = (char *)(*param);
s.len = strlen(s.s);
if (s.len <= 0) return -1;
/* Check the format */
if(pv_parse_format(&s, &model)<0) {
LM_ERR("pv_parse_format failed for '%s'\n", (char *)(*param));
return -1;
}
*param = (void*)model;
return 0;
}
开发者ID:Distrotech,项目名称:opensips,代码行数:23,代码来源:carrierroute.c
示例9: it_list_fixup
static int it_list_fixup(void** param, int param_no)
{
pv_elem_t *model;
str s;
if(*param)
{
s.s = (char*)(*param); s.len = strlen(s.s);
if(pv_parse_format(&s, &model)<0)
{
LM_ERR("wrong format[%s]\n",(char*)(*param));
return E_UNSPEC;
}
*param = (void*)model;
}
return 0;
}
开发者ID:AndreiPlesa,项目名称:opensips,代码行数:16,代码来源:rr_mod.c
示例10: fixup_b2b_logic
static int fixup_b2b_logic(void** param, int param_no)
{
pv_elem_t *model;
str s;
if(param_no== 0)
return 0;
if(*param)
{
s.s = (char*)(*param);
s.len = strlen(s.s);
if(pv_parse_format(&s, &model)<0)
{
LM_ERR( "wrong format[%s]\n",(char*)(*param));
return E_UNSPEC;
}
/* the first parameter must be the scenario id and must be a string */
if(param_no == 1)
{
if(model->spec.type != PVT_NONE )
{
LM_ERR("The first parameter is not a string\n");
return -1;
}
if(s.len == B2B_TOP_HIDING_SCENARY_LEN &&
strncmp(s.s,B2B_TOP_HIDING_SCENARY,B2B_TOP_HIDING_SCENARY_LEN)==0)
{
*param = NULL;
return 0;
}
*param = get_scenario_id_list(&s, script_scenarios);
if(*param)
return 0;
LM_ERR("Wrong Scenary ID. No scenario with this ID [%.*s]\n", s.len, s.s);
return E_UNSPEC;
}
*param = (void*)model;
return 0;
}
LM_ERR( "null format\n");
return E_UNSPEC;
}
开发者ID:iamroger,项目名称:voip,代码行数:46,代码来源:b2b_logic.c
示例11: ldap_filter_url_encode_fixup
static int ldap_filter_url_encode_fixup(void** param, int param_no)
{
pv_elem_t *elem_p;
pv_spec_t *spec_p;
str s;
if (param_no == 1) {
s.s = (char*)*param;
if (s.s==0 || s.s[0]==0) {
elem_p = 0;
} else {
s.len = strlen(s.s);
if (pv_parse_format(&s, &elem_p) < 0) {
LM_ERR("pv_parse_format failed\n");
return E_OUT_OF_MEM;
}
}
*param = (void*)elem_p;
}
else if (param_no == 2)
{
spec_p = (pv_spec_t*)pkg_malloc(sizeof(pv_spec_t));
if (spec_p == NULL) {
LM_ERR("no memory\n");
return E_OUT_OF_MEM;
}
s.s = (char*)*param; s.len = strlen(s.s);
if (pv_parse_spec(&s, spec_p)
== 0)
{
pkg_free(spec_p);
LM_ERR("parse error for [%s]\n",
(char*)*param);
return E_UNSPEC;
}
if (spec_p->type != PVT_AVP) {
pkg_free(spec_p);
LM_ERR("bad attribute name"
" [%s]\n", (char*)*param);
return E_UNSPEC;
}
*param = (void*)spec_p;
}
return 0;
}
开发者ID:GeorgeShaw,项目名称:opensips,代码行数:46,代码来源:ldap_mod.c
示例12: fixup_sig_send_reply
/* *
* fixup_sig_send_reply
*/
static int fixup_sig_send_reply(void** param, int param_no)
{
pv_elem_t *model=NULL;
str s;
/* convert to str */
s.s = (char*)*param;
s.len = strlen(s.s);
model=NULL;
if (param_no==1 || param_no==2)
{
if(s.len==0)
{
LM_ERR("no param %d!\n", param_no);
return E_UNSPEC;
}
if(pv_parse_format(&s ,&model) || model==NULL)
{
LM_ERR("wrong format [%s] for param no %d!\n", s.s, param_no);
return E_UNSPEC;
}
if(model->spec.getf==NULL)
{
if(param_no==1)
{
if(str2int(&s,
(unsigned int*)&model->spec.pvp.pvn.u.isname.name.n)!=0
|| model->spec.pvp.pvn.u.isname.name.n<100
|| model->spec.pvp.pvn.u.isname.name.n>699)
{
LM_ERR("wrong value [%s] for param no %d!\n",
s.s, param_no);
LM_ERR("allowed values: 1xx - 6xx only!\n");
return E_UNSPEC;
}
}
}
*param = (void*)model;
}
return 0;
}
开发者ID:Distrotech,项目名称:opensips,代码行数:47,代码来源:signaling.c
示例13: auth_fixup
/*
* Convert char* parameter to pv_elem_t* parameter
*/
static int auth_fixup(void** param, int param_no)
{
pv_elem_t *model;
str s;
pv_spec_t *sp;
if (param_no == 1) { /* realm (string that may contain pvars) */
s.s = (char*)*param;
if (s.s==0 || s.s[0]==0) {
model = 0;
} else {
s.len = strlen(s.s);
if (pv_parse_format(&s,&model)<0) {
LM_ERR("pv_parse_format failed\n");
return E_OUT_OF_MEM;
}
}
*param = (void*)model;
}
if (param_no == 2) { /* URI user (a pvar) */
sp = (pv_spec_t*)pkg_malloc(sizeof(pv_spec_t));
if (sp == 0) {
LM_ERR("no pkg memory left\n");
return -1;
}
s.s = (char*)*param;
s.len = strlen(s.s);
if (pv_parse_spec(&s, sp) == 0) {
LM_ERR("parsing of pseudo variable %s failed!\n", (char*)*param);
pkg_free(sp);
return -1;
}
if (sp->type == PVT_NULL) {
LM_ERR("bad pseudo variable\n");
pkg_free(sp);
return -1;
}
*param = (void*)sp;
}
return 0;
}
开发者ID:GreenfieldTech,项目名称:kamailio,代码行数:46,代码来源:auth_radius.c
示例14: fixup_evaluate_exp
static int fixup_evaluate_exp(void **param, int param_no)
{
pv_elem_p ep;
pv_spec_p sp;
str s;
if (param_no != 1 && param_no != 2) {
LM_ERR("Invalid parameter number: %d\n", param_no);
return E_UNSPEC;
}
if (param_no == 1) {
s.s = (char*)(*param);
s.len = strlen(s.s);
if (pv_parse_format(&s, &ep) < 0) {
LM_ERR("wrong format[%.*s]\n", s.len, s.s);
return E_UNSPEC;
}
*param = (void *)ep;
return 0;
} else {
if (!(sp = pkg_malloc(sizeof(*sp)))) {
LM_ERR("No more pkg memory!\n");
return -1;
}
memset(sp, 0, sizeof(*sp));
s.s = (char *)*param;
s.len = strlen(s.s);
if (!pv_parse_spec(&s, sp)) {
LM_ERR("Parameter 2 only accepts pvars! Given: <%.*s>\n", s.len, s.s);
return -1;
}
*param = (void *)sp;
return 0;
}
}
开发者ID:vladpaiu,项目名称:opensips,代码行数:43,代码来源:mathops.c
示例15: check_user_blacklist_fixup
static int check_user_blacklist_fixup(void** param, int param_no)
{
pv_elem_t *model=NULL;
str s;
/* convert to str */
s.s = (char*)*param;
s.len = strlen(s.s);
if (param_no > 0 && param_no <= 4) {
if(s.len == 0 && param_no != 4) {
LM_ERR("no parameter %d\n", param_no);
return E_UNSPEC;
}
if(pv_parse_format(&s, &model) < 0 || !model) {
LM_ERR("wrong format [%.*s] for parameter %d\n", s.len, s.s, param_no);
return E_UNSPEC;
}
if(!model->spec.getf) {
if(param_no == 1) {
if(str2int(&s, (unsigned int*)&model->spec.pvp.pvn.u.isname.name.n) != 0) {
LM_ERR("wrong value [%.*s] for parameter %d\n", s.len, s.s, param_no);
return E_UNSPEC;
}
} else {
if(param_no == 2 || param_no == 3) {
LM_ERR("wrong value [%.*s] for parameter %d\n", s.len, s.s, param_no);
return E_UNSPEC;
} else {
// only a string
return 0;
}
}
}
*param = (void*)model;
} else {
LM_ERR("wrong number of parameters\n");
}
return 0;
}
开发者ID:zhangzheyuk,项目名称:opensips,代码行数:43,代码来源:userblacklist.c
示例16: pv_printf_fixup
int pv_printf_fixup(void** param, int param_no)
{
pv_spec_t *spec=NULL;
pv_elem_t *pvmodel=NULL;
str tstr;
if(param_no==1)
{
spec = (pv_spec_t*)pkg_malloc(sizeof(pv_spec_t));
if(spec==NULL)
{
LM_ERR("out of pkg\n");
return -1;
}
memset(spec, 0, sizeof(pv_spec_t));
tstr.s = (char*)(*param);
tstr.len = strlen(tstr.s);
if(pv_parse_spec(&tstr, spec)==NULL)
{
LM_ERR("unknown script variable in first parameter");
pkg_free(spec);
return -1;
}
if(!pv_is_w(spec))
{
LM_ERR("read-only script variable in first parameter");
pkg_free(spec);
return -1;
}
*param = spec;
} else if(param_no==2) {
pvmodel = 0;
tstr.s = (char*)(*param);
tstr.len = strlen(tstr.s);
if(pv_parse_format(&tstr, &pvmodel)<0)
{
LM_ERR("error in second parameter");
return -1;
}
*param = pvmodel;
}
return 0;
}
开发者ID:SipSeb,项目名称:kamailio,代码行数:43,代码来源:km_core.c
示例17: fixup_xcaps_put
static int fixup_xcaps_put(void** param, int param_no)
{
str s;
pv_elem_t *xm;
if (param_no == 1) {
return fixup_spve_null(param, 1);
} else if (param_no == 2) {
return fixup_spve_null(param, 1);
} else if (param_no == 3) {
s.s = (char*)(*param); s.len = strlen(s.s);
if(pv_parse_format(&s, &xm)<0)
{
LM_ERR("wrong format[%s]\n", (char*)(*param));
return E_UNSPEC;
}
*param = (void*)xm;
return 0;
}
return 0;
}
开发者ID:tripped,项目名称:kamailio,代码行数:20,代码来源:xcap_server.c
示例18: fixup_subscribe
int fixup_subscribe(void** param, int param_no) {
pv_elem_t *model;
str s;
if (param_no == 1) {
if(*param) {
s.s = (char*)(*param);
s.len = strlen(s.s);
if(pv_parse_format(&s, &model)<0) {
LM_ERR("wrong format[%s]\n",(char*)(*param));
return E_UNSPEC;
}
*param = (void*)model;
return 1;
}
LM_ERR("null format\n");
return E_UNSPEC;
} else if (param_no == 2) {
return fixup_igp_igp(param, param_no);
} else return 1;
}
开发者ID:4N7HR4X,项目名称:kamailio,代码行数:20,代码来源:subscribe.c
示例19: fixup_replace_disp_uri
static int fixup_replace_disp_uri(void** param, int param_no)
{
pv_elem_t *model;
char *p;
str s;
/* convert to str */
s.s = (char*)*param;
s.len = strlen(s.s);
model=NULL;
if (param_no==1 && s.len) {
/* check to see if it is already quoted */
if ((s.s[0] == '\"' && s.s[s.len - 1] == '\"') ||
str_check_token(&s))
goto unquoted;
/* put " around display name */
p = (char*)pkg_malloc(s.len+3);
if (p==0) {
LM_CRIT("no more pkg mem\n");
return E_OUT_OF_MEM;
}
p[0] = '\"';
memcpy(p+1, s.s, s.len);
p[s.len+1] = '\"';
p[s.len+2] = '\0';
pkg_free(s.s);
s.s = p;
s.len += 2;
}
unquoted:
if(pv_parse_format(&s ,&model)<0) {
LM_ERR("wrong format [%s] for param no %d!\n", s.s, param_no);
pkg_free(s.s);
return E_UNSPEC;
}
*param = (void*)model;
return 0;
}
开发者ID:alias-neo,项目名称:opensips,代码行数:41,代码来源:uac.c
示例20: one_str_pv_elem_fixup
static int one_str_pv_elem_fixup(void** param, int param_no)
{
pv_elem_t *model;
str s;
if (param_no == 1) {
s.s = (char*)*param;
if (s.s==0 || s.s[0]==0) {
model = 0;
} else {
s.len = strlen(s.s);
if (pv_parse_format(&s,&model)<0) {
LM_ERR("pv_parse_format failed\n");
return E_OUT_OF_MEM;
}
}
*param = (void*)model;
}
return 0;
}
开发者ID:Distrotech,项目名称:opensips,代码行数:21,代码来源:h350_mod.c
注:本文中的pv_parse_format函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论