本文整理汇总了C++中pv_printf_s函数的典型用法代码示例。如果您正苦于以下问题:C++ pv_printf_s函数的具体用法?C++ pv_printf_s怎么用?C++ pv_printf_s使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pv_printf_s函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: w_drop_acc_2
int w_drop_acc_2(struct sip_msg* msg, char* type_p, char* flags_p)
{
unsigned long long type=0;
/* if not set, we reset all flags for the type of accounting requested */
unsigned long long flags=ALL_ACC_FLAGS;
unsigned long long flag_mask;
acc_type_param_t* acc_param;
acc_ctx_t* acc_ctx=try_fetch_ctx();
str in;
if (acc_ctx == NULL) {
LM_ERR("do_accounting() not used! This function resets flags in "
"do_accounting()!\n");
return -1;
}
if (type_p != NULL) {
acc_param = (acc_type_param_t *)type_p;
if (acc_param->t == DO_ACC_PARAM_TYPE_VALUE) {
type = acc_param->u.ival;
} else {
if (pv_printf_s(msg, acc_param->u.pval, &in) < 0) {
LM_ERR("failed to fetch type value!\n");
return -1;
}
if ((type=do_acc_parse(&in, do_acc_type_parser)) == DO_ACC_ERR) {
LM_ERR("Invalid expression <%.*s> for acc type!\n", in.len, in.s);
return -1;
}
}
}
if (flags_p != NULL) {
flags= *(unsigned long long*)flags_p;
}
flag_mask = type * flags;
/* reset all flags */
if (flag_mask == 0) {
/*
* we use this flag in order make the difference between
* 0 value (do_accounting never called, callbacks never registered) and
* ACC_FLAGS_RESET (do_accounting called, callbacks registered, flag value
* changing during script execution)
*/
acc_ctx->flags = ACC_FLAGS_RESET;
} else {
reset_flags(acc_ctx->flags, flag_mask);
}
return 1;
}
开发者ID:andrey-vorobiev,项目名称:opensips,代码行数:57,代码来源:acc_logic.c
示例2: sql_query_async
static int sql_query_async(struct sip_msg *msg, char *dbl, char *query)
{
str sq;
if(pv_printf_s(msg, (pv_elem_t*)query, &sq)!=0)
{
LM_ERR("cannot print the sql query\n");
return -1;
}
return sql_do_query_async((sql_con_t*)dbl, &sq);
}
开发者ID:AlessioCasco,项目名称:kamailio,代码行数:10,代码来源:sqlops.c
示例3: w_add_rr_param
static int w_add_rr_param(struct sip_msg *msg, char *key, char *foo)
{
str s;
if (pv_printf_s(msg, (pv_elem_t*)key, &s)<0) {
LM_ERR("failed to print the format\n");
return -1;
}
return ((add_rr_param( msg, &s)==0)?1:-1);
}
开发者ID:AndreiPlesa,项目名称:opensips,代码行数:10,代码来源:rr_mod.c
示例4: w_load_balance
static int w_load_balance(struct sip_msg *req, char *grp, char *rl, char *al)
{
int ret;
int grp_no;
struct lb_grp_param *lbgp = (struct lb_grp_param *)grp;
pv_value_t val;
struct lb_res_str_list *lb_rl;
struct lb_res_parse *lbp;
pv_elem_t *model;
str dest;
if (lbgp->grp_pv) {
if (pv_get_spec_value( req, (pv_spec_p)lbgp->grp_pv, &val)!=0) {
LM_ERR("failed to get PV value\n");
return -1;
}
if ( (val.flags&PV_VAL_INT)==0 ) {
LM_ERR("PV vals is not integer\n");
return -1;
}
grp_no = val.ri;
} else {
grp_no = lbgp->grp_no;
}
lbp = (struct lb_res_parse *)rl;
if (lbp->type & RES_ELEM) {
model = (pv_elem_p)lbp->param;
if (pv_printf_s(req, model, &dest) || dest.len <= 0) {
LM_ERR("cannot create resource string\n");
return -1;
}
lb_rl = parse_resources_list(dest.s, 0);
if (!lb_rl) {
LM_ERR("cannot create resource list\n");
return -1;
}
} else
lb_rl = (struct lb_res_str_list *)lbp->param;
lock_start_read( ref_lock );
/* do lb */
ret = do_load_balance(req, grp_no, lb_rl,
(unsigned int)(long)al, *curr_data);
lock_stop_read( ref_lock );
if (lbp->type & RES_ELEM)
pkg_free(lb_rl);
if (ret<0)
return ret;
return 1;
}
开发者ID:NoamRom89,项目名称:opensips,代码行数:55,代码来源:load_balancer.c
示例5: pv_set_ht_cell
int pv_set_ht_cell(struct sip_msg* msg, pv_param_t *param,
int op, pv_value_t *val)
{
str htname;
int_str isval;
ht_pv_t *hpv;
hpv = (ht_pv_t*)param->pvn.u.dname;
if(hpv->ht==NULL)
hpv->ht = ht_get_table(&hpv->htname);
if(hpv->ht==NULL)
return -1;
if(pv_printf_s(msg, hpv->pve, &htname)!=0)
{
LM_ERR("cannot get $ht name\n");
return -1;
}
LM_DBG("set value for $ht(%.*s=>%.*s)\n", hpv->htname.len, hpv->htname.s,
htname.len, htname.s);
if((val==NULL) || (val->flags&PV_VAL_NULL))
{
/* delete it */
if (hpv->ht->dmqreplicate>0 && ht_dmq_replicate_action(HT_DMQ_DEL_CELL, &hpv->htname, &htname, 0, NULL, 0)!=0) {
LM_ERR("dmq relication failed\n");
}
ht_del_cell(hpv->ht, &htname);
return 0;
}
if(val->flags&PV_TYPE_INT)
{
isval.n = val->ri;
if (hpv->ht->dmqreplicate>0 && ht_dmq_replicate_action(HT_DMQ_SET_CELL, &hpv->htname, &htname, 0, &isval, 1)!=0) {
LM_ERR("dmq relication failed\n");
}
if(ht_set_cell(hpv->ht, &htname, 0, &isval, 1)!=0)
{
LM_ERR("cannot set $ht(%.*s)\n", htname.len, htname.s);
return -1;
}
} else {
isval.s = val->rs;
if (hpv->ht->dmqreplicate>0 && ht_dmq_replicate_action(HT_DMQ_SET_CELL, &hpv->htname, &htname, AVP_VAL_STR, &isval, 1)!=0) {
LM_ERR("dmq relication failed\n");
}
if(ht_set_cell(hpv->ht, &htname, AVP_VAL_STR, &isval, 1)!=0)
{
LM_ERR("cannot set $ht(%.*s)\n", htname.len, htname.s);
return -1;
}
}
return 0;
}
开发者ID:AndreyRybkin,项目名称:kamailio,代码行数:55,代码来源:ht_var.c
示例6: ldap_filter_url_encode
int ldap_filter_url_encode(
struct sip_msg* _msg,
pv_elem_t* _filter_component,
pv_spec_t* _dst_avp_spec)
{
str filter_component_str, esc_str;
int dst_avp_name;
unsigned short dst_avp_type;
/*
* variable substitution for _filter_component
*/
if (_filter_component) {
if (pv_printf_s(_msg, _filter_component, &filter_component_str) != 0) {
LM_ERR("pv_printf_s failed\n");
return -1;
}
} else {
LM_ERR("empty first argument\n");
return -1;
}
/*
* get dst AVP name (dst_avp_name)
*/
if (pv_get_avp_name(_msg, &(_dst_avp_spec->pvp), &dst_avp_name,
&dst_avp_type) != 0)
{
LM_ERR("error getting dst AVP name\n");
return -1;
}
/*
* apply LDAP filter escaping rules
*/
esc_str.s = esc_buf;
esc_str.len = ESC_BUF_SIZE;
if (ldap_rfc4515_escape(&filter_component_str, &esc_str, 1) != 0)
{
LM_ERR("ldap_rfc4515_escape() failed\n");
return -1;
}
/*
* add dst AVP
*/
if (add_avp(dst_avp_type|AVP_VAL_STR, dst_avp_name, (int_str)esc_str) != 0)
{
LM_ERR("failed to add new AVP\n");
return -1;
}
return 1;
}
开发者ID:KISSMonX,项目名称:opensips,代码行数:54,代码来源:ldap_exp_fn.c
示例7: w_update_stat
static int w_update_stat(struct sip_msg *msg, char *stat_p, char *n)
{
struct stat_param *sp = (struct stat_param *)stat_p;
pv_value_t pv_val;
stat_var *stat;
if (sp->type==STAT_PARAM_TYPE_STAT) {
/* we have the statistic */
update_stat( sp->u.stat, (long)n);
return 1;
}
if (sp->type==STAT_PARAM_TYPE_PVAR) {
/* take name from PVAR */
if (pv_get_spec_value(msg, sp->u.pvar, &pv_val)!=0 ||
(pv_val.flags & PV_VAL_STR)==0 ) {
LM_ERR("failed to get pv string value\n");
return -1;
}
} else if (sp->type==STAT_PARAM_TYPE_FMT) {
/* take name from FMT */
if (pv_printf_s( msg, sp->u.format, &(pv_val.rs) )!=0 ) {
LM_ERR("failed to get format string value\n");
return -1;
}
} else if (sp->type==STAT_PARAM_TYPE_NAME) {
/* take name from STRING */
pv_val.rs = *sp->u.name;
}
LM_DBG("needed statistic is <%.*s>\n", pv_val.rs.len, pv_val.rs.s);
/* name is in pv_val.rs -> look for it */
stat = get_stat( &(pv_val.rs) );
if ( stat==NULL ) {
/* stats not found -> create it */
LM_DBG("creating dynamic statistic <%.*s>\n",
pv_val.rs.len, pv_val.rs.s);
if (register_dynamic_stat( &(pv_val.rs), &stat )!=0) {
LM_ERR("failed to create dynamic statistic <%.*s>\n",
pv_val.rs.len, pv_val.rs.s);
return -1;
}
if (sp->type==STAT_PARAM_TYPE_NAME) {
sp->u.stat = stat;
sp->type=STAT_PARAM_TYPE_STAT;
}
}
/* statistic exists ! */
update_stat( stat, (long)n);
return 1;
}
开发者ID:Danfx,项目名称:opensips,代码行数:53,代码来源:statistics.c
示例8: w_t_replicate
inline static int w_t_replicate(struct sip_msg *p_msg, char *dst, char *flags)
{
str dest;
if(((pv_elem_p)dst)->spec.getf!=NULL) {
if(pv_printf_s(p_msg, (pv_elem_p)dst, &dest)!=0 || dest.len <=0)
return -1;
} else {
dest = ((pv_elem_p)dst)->text;
}
return t_replicate( p_msg, &dest, (int)(long)flags);
}
开发者ID:Deni90,项目名称:opensips,代码行数:13,代码来源:tm.c
示例9: sql_do_xquery
int sql_do_xquery(struct sip_msg *msg, sql_con_t *con, pv_elem_t *query,
pv_elem_t *res)
{
str sv, xavp;
if(msg==NULL || query==NULL || res==NULL)
{
LM_ERR("bad parameters\n");
return -1;
}
if(pv_printf_s(msg, query, &sv)!=0)
{
LM_ERR("cannot print the sql query\n");
return -1;
}
if(pv_printf_s(msg, res, &xavp)!=0)
{
LM_ERR("cannot print the result parameter\n");
return -1;
}
return sql_exec_xquery(msg, con, &sv, &xavp);
}
开发者ID:SipCoSystems,项目名称:hush,代码行数:22,代码来源:sql_api.c
示例10: w_drop_acc_2
int w_drop_acc_2(struct sip_msg* msg, char* type_p, char* flags_p)
{
unsigned long long type=0;
/* if not set, we reset all flags for the type of accounting requested */
unsigned long long flags=ALL_ACC_FLAGS;
unsigned long long flag_mask;
unsigned long long *context_flags_p=try_fetch_flags();
acc_type_param_t* acc_param;
str in;
if (context_flags_p == NULL) {
LM_ERR("do_accounting() not used! This function resets flags in "
"do_accounting()!\n");
return -1;
}
if (type_p != NULL) {
acc_param = (acc_type_param_t *)type_p;
if (acc_param->t == DO_ACC_PARAM_TYPE_VALUE) {
type = acc_param->u.ival;
} else {
if (pv_printf_s(msg, acc_param->u.pval, &in) < 0) {
LM_ERR("failed to fetch type value!\n");
return -1;
}
if ((type=do_acc_parse(&in, do_acc_type_parser)) < 0) {
LM_ERR("Invalid expression <%.*s> for acc type!\n", in.len, in.s);
return -1;
}
}
}
if (flags_p != NULL) {
flags= *(unsigned long long*)flags_p;
}
flag_mask = type * flags;
/* reset all flags */
if (flag_mask == 0) {
*context_flags_p = 0;
} else {
reset_flags(*context_flags_p, flag_mask);
}
return 1;
}
开发者ID:ph4r05,项目名称:opensips,代码行数:51,代码来源:acc_logic.c
示例11: w_pv_t_reply
inline static int w_pv_t_reply(struct sip_msg *msg, char* code, char* text)
{
str code_s;
unsigned int code_i;
if(((pv_elem_p)code)->spec.getf!=NULL) {
if(pv_printf_s(msg, (pv_elem_p)code, &code_s)!=0)
return -1;
if(str2int(&code_s, &code_i)!=0 || code_i<100 || code_i>699)
return -1;
} else {
code_i = ((pv_elem_p)code)->spec.pvp.pvn.u.isname.name.n;
}
if(((pv_elem_p)text)->spec.getf!=NULL) {
if(pv_printf_s(msg, (pv_elem_p)text, &code_s)!=0 || code_s.len <=0)
return -1;
} else {
code_s = ((pv_elem_p)text)->text;
}
return w_t_reply(msg, (char*)(unsigned long)code_i, (char*)&code_s);
}
开发者ID:Deni90,项目名称:opensips,代码行数:23,代码来源:tm.c
示例12: tree_route_uri
/**
* rewrites the request URI of msg by calculating a rule, using
* crc32 for hashing. The request URI is used to determine tree node
* the given _tree is the used routing tree
*
* @param msg the current SIP message
* @param _tree the routing tree to be used (string or pseudo-variable
* @param _domain the requested routing domain
*
* @return 1 on success, -1 on failure
*/
int tree_route_uri(struct sip_msg * msg, char * _tree, char * _domain) {
struct rewrite_data * rd = NULL;
pv_elem_t *model;
str carrier_name;
int index;
str ruser;
str ruri;
if (!_tree) {
LM_ERR("bad parameters\n");
return -1;
}
if (parse_sip_msg_uri(msg) < 0) {
return -1;
}
/* Retrieve carrier name from parameter */
model = (pv_elem_t*)_tree;
if (pv_printf_s(msg, model, &carrier_name)<0) {
LM_ERR("cannot print the format\n");
return -1;
}
if ((index = find_tree(carrier_name)) < 0)
LM_WARN("could not find carrier %.*s\n",
carrier_name.len, carrier_name.s);
else
LM_DBG("tree %.*s has id %i\n", carrier_name.len, carrier_name.s, index);
ruser.s = msg->parsed_uri.user.s;
ruser.len = msg->parsed_uri.user.len;
ruri.s = msg->parsed_uri.user.s;
ruri.len = msg->parsed_uri.user.len;
do {
rd = get_data();
} while (rd == NULL);
if (index < 0) {
if (fallback_default) {
LM_NOTICE("invalid tree id %i specified, use default tree\n", index);
index = rd->default_carrier_index;
} else {
LM_ERR("invalid tree id %i specified and fallback deactivated\n", index);
release_data(rd);
return -1;
}
}
release_data(rd);
return carrier_rewrite_msg(index, (int)(long)_domain, &ruri, msg, &ruser,
shs_call_id, alg_crc32);
}
开发者ID:Drooids,项目名称:openser-xmlrpc,代码行数:61,代码来源:route_func.c
示例13: w_evaluate_rpn
static int w_evaluate_rpn(struct sip_msg *msg, char *exp, char *result)
{
pv_elem_p exp_fmt = (pv_elem_p)exp;
str s;
if (pv_printf_s(msg, exp_fmt, &s) != 0) {
LM_ERR("Failed to print the pv format string!\n");
return -1;
}
LM_DBG("Evaluating expression: %.*s\n", s.len, s.s);
return evaluate_exp(msg, &s, (pv_spec_p)result, 1);
}
开发者ID:Distrotech,项目名称:opensips,代码行数:14,代码来源:mathops.c
示例14: w_replace_to
static int w_replace_to(struct sip_msg* msg, char* p1, char* p2)
{
str uri_s;
str dsp_s;
str *uri = NULL;
str *dsp = NULL;
if (p2==NULL) {
p2 = p1;
p1 = NULL;
dsp = NULL;
}
/* p1 display , p2 uri */
if( p1!=NULL ) {
if(pv_printf_s( msg, (pv_elem_p)p1, &dsp_s)!=0)
return -1;
dsp = &dsp_s;
}
/* compute the URI string; if empty string -> make it NULL */
if (pv_printf_s( msg, (pv_elem_p)p2, &uri_s)!=0)
return -1;
uri = uri_s.len?&uri_s:NULL;
/* parse TO hdr */
if ( msg->to==0 && (parse_headers(msg,HDR_TO_F,0)!=0 || msg->to==0) ) {
LM_ERR("failed to parse TO hdr\n");
return -1;
}
LM_DBG("dsp=%p (len=%d) , uri=%p (len=%d)\n",dsp,dsp?dsp->len:0,uri,uri?uri->len:0);
return (replace_uri(msg, dsp, uri, msg->to, &rr_to_param, &restore_to_avp, 0)==0)?1:-1;
}
开发者ID:AlessioCasco,项目名称:kamailio,代码行数:37,代码来源:uac.c
示例15: h350_sipuri_lookup
int h350_sipuri_lookup(struct sip_msg* _msg, pv_elem_t* _sip_uri)
{
str sip_uri, sip_uri_escaped;
int ld_result_count;
static char sip_uri_escaped_buf[SIP_URI_ESCAPED_MAX_LEN];
/*
* get sip_uri
*/
if (pv_printf_s(_msg, _sip_uri, &sip_uri) != 0)
{
LM_ERR("pv_printf_s failed\n");
return E_H350_INTERNAL;
}
/*
* ldap filter escape sip_uri
*/
sip_uri_escaped.s = sip_uri_escaped_buf;
sip_uri_escaped.len = SIP_URI_ESCAPED_MAX_LEN - 1;
if (ldap_api.ldap_rfc4515_escape(&sip_uri, &sip_uri_escaped, 0))
{
LM_ERR("ldap_rfc4515_escape failed\n");
return E_H350_INTERNAL;
}
/*
* do ldap search
*/
if (ldap_api.ldap_params_search(&ld_result_count,
h350_ldap_session.s,
h350_base_dn.s,
h350_search_scope_int,
NULL,
H350_SIPURI_LOOKUP_LDAP_FILTER,
sip_uri_escaped.s)
!= 0)
{
LM_ERR("ldap search failed\n");
return E_H350_INTERNAL;
}
if (ld_result_count < 1)
{
return E_H350_NO_SUCCESS;
}
return ld_result_count;
}
开发者ID:GeorgeShaw,项目名称:opensips,代码行数:49,代码来源:h350_exp_fn.c
示例16: acc_get_param_value
int acc_get_param_value(struct sip_msg *rq, struct acc_param *param)
{
if(param->elem!=NULL) {
if(pv_printf_s(rq, param->elem, ¶m->reason)==-1) {
LM_ERR("Can't get value for %.*s\n", param->reason.len, param->reason.s);
return -1;
}
if(acc_parse_code(param->reason.s, param)<0)
{
LM_ERR("Can't parse code\n");
return -1;
}
}
return 0;
}
开发者ID:krys1976,项目名称:kamailio,代码行数:15,代码来源:acc_logic.c
示例17: w_replace_from
int w_replace_from(struct sip_msg* msg, char* p1, char* p2)
{
str uri_s;
str dsp_s;
str *uri = NULL;
str *dsp = NULL;
if (p2==NULL) {
p2 = p1;
p1 = NULL;
dsp = NULL;
}
/* p1 display , p2 uri */
if ( p1!=NULL ) {
if(pv_printf_s( msg, (pv_elem_p)p1, &dsp_s)!=0)
return -1;
dsp = &dsp_s;
}
/* compute the URI string; if empty string -> make it NULL */
if (pv_printf_s( msg, (pv_elem_p)p2, &uri_s)!=0)
return -1;
uri = uri_s.len?&uri_s:NULL;
if (parse_from_header(msg)<0 ) {
LM_ERR("failed to find/parse FROM hdr\n");
return -1;
}
LM_DBG("dsp=%p (len=%d) , uri=%p (len=%d)\n",dsp,dsp?dsp->len:0,uri,uri?uri->len:0);
return (replace_uri(msg, dsp, uri, msg->from, &rr_from_param, &restore_from_avp, 1)==0)?1:-1;
}
开发者ID:AlessioCasco,项目名称:kamailio,代码行数:36,代码来源:uac.c
示例18: w_store_dlg_value
int w_store_dlg_value(struct sip_msg *msg, char *name, char *val)
{
struct dlg_cell *dlg;
pv_elem_t *pve = (pv_elem_t *)val;
str val_s;
if ( (dlg=get_current_dialog())==NULL )
return -1;
if ( pve==NULL || pv_printf_s(msg, pve, &val_s)!=0 ||
val_s.len == 0 || val_s.s == NULL) {
LM_WARN("cannot get string for value\n");
return -1;
}
return (store_dlg_value( dlg, (str*)name, &val_s)==0)?1:-1;
}
开发者ID:MayamaTakeshi,项目名称:opensips,代码行数:17,代码来源:dialog.c
示例19: mp2carrier_id
/**
* Get the carrier id from multiparam_t structure.
*
* @param mp carrier id as integer, pseudo-variable or AVP name of carrier
* @param _msg SIP message
* @return carrier id on success, -1 otherwise
*
*/
int mp2carrier_id(struct sip_msg * _msg, struct multiparam_t *mp) {
int carrier_id;
struct usr_avp *avp;
int_str avp_val;
str tmp;
/* TODO combine the redundant parts of the logic */
switch (mp->type) {
case MP_INT:
return mp->u.n;
break;
case MP_AVP:
avp = search_first_avp(mp->u.a.flags, mp->u.a.name, &avp_val, 0);
if (!avp) {
LM_ERR("cannot find AVP '%d'\n", mp->u.a.name);
return -1;
}
if ((avp->flags&AVP_VAL_STR)==0) {
return avp_val.n;
}
else {
carrier_id = find_tree(avp_val.s);
if (carrier_id < 0) {
LM_WARN("could not find carrier tree '%.*s'\n", avp_val.s.len, avp_val.s.s);
/* might be using fallback later... */
}
return carrier_id;
}
break;
case MP_PVE:
/* retrieve carrier name from parameter */
if (pv_printf_s(_msg, mp->u.p, &tmp)<0) {
LM_ERR("cannot print the carrier\n");
return -1;
}
carrier_id = find_tree(tmp);
if (carrier_id < 0) {
LM_WARN("could not find carrier tree '%.*s'\n", tmp.len, tmp.s);
/* might be using fallback later... */
}
return carrier_id;
default:
LM_ERR("invalid carrier type\n");
return -1;
}
}
开发者ID:UIKit0,项目名称:OpenSIPS,代码行数:54,代码来源:route_func.c
示例20: w_assert_identity
static int w_assert_identity(struct sip_msg* _m, char* _d, char* _preferred_uri) {
pv_elem_t *model;
str identity;
if(_preferred_uri == NULL) {
LM_ERR("error - bad parameters\n");
return -1;
}
model = (pv_elem_t*)_preferred_uri;
if (pv_printf_s(_m, model, &identity)<0) {
LM_ERR("error - cannot print the format\n");
return -1;
}
return assert_identity( _m, (udomain_t*)_d, identity);
}
开发者ID:alezzandro,项目名称:kamailio,代码行数:17,代码来源:reg_mod.c
注:本文中的pv_printf_s函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论