本文整理汇总了C++中pv_get_strval函数的典型用法代码示例。如果您正苦于以下问题:C++ pv_get_strval函数的具体用法?C++ pv_get_strval怎么用?C++ pv_get_strval使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pv_get_strval函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: pv_get_nh
int pv_get_nh(struct sip_msg *msg, pv_param_t *param,
pv_value_t *res)
{
struct sip_uri parsed_uri;
str uri;
if(msg==NULL || res==NULL)
return -1;
if(msg->first_line.type == SIP_REPLY) /* REPLY doesnt have r/d-uri */
return pv_get_null(msg, param, res);
if (msg->dst_uri.s != NULL && msg->dst_uri.len>0)
{
uri = msg->dst_uri;
} else {
if (msg->new_uri.s!=NULL && msg->new_uri.len>0)
{
uri = msg->new_uri;
} else {
uri = msg->first_line.u.request.uri;
}
}
if(param->pvn.u.isname.name.n==0) /* uri */
{
return pv_get_strval(msg, param, res, &uri);
}
if(parse_uri(uri.s, uri.len, &parsed_uri)!=0)
{
LM_ERR("failed to parse nh uri [%.*s]\n", uri.len, uri.s);
return pv_get_null(msg, param, res);
}
if(param->pvn.u.isname.name.n==1) /* username */
{
if(parsed_uri.user.s==NULL || parsed_uri.user.len<=0)
return pv_get_null(msg, param, res);
return pv_get_strval(msg, param, res, &parsed_uri.user);
} else if(param->pvn.u.isname.name.n==2) /* domain */ {
if(parsed_uri.host.s==NULL || parsed_uri.host.len<=0)
return pv_get_null(msg, param, res);
return pv_get_strval(msg, param, res, &parsed_uri.host);
} else if(param->pvn.u.isname.name.n==3) /* port */ {
if(parsed_uri.port.s==NULL)
return pv_get_5060(msg, param, res);
return pv_get_strintval(msg, param, res, &parsed_uri.port,
(int)parsed_uri.port_no);
} else if(param->pvn.u.isname.name.n==4) /* protocol */ {
if(parsed_uri.transport_val.s==NULL)
return pv_get_udp(msg, param, res);
return pv_get_strintval(msg, param, res, &parsed_uri.transport_val,
(int)parsed_uri.proto);
}
LM_ERR("unknown specifier\n");
return pv_get_null(msg, param, res);
}
示例2: pv_get_dbr
int pv_get_dbr(struct sip_msg *msg, pv_param_t *param,
pv_value_t *res)
{
sql_pv_t *spv;
int row;
int col;
spv = (sql_pv_t*)param->pvn.u.dname;
if(spv->res==NULL)
{
spv->res = sql_get_result(&spv->resname);
if(spv->res==NULL)
return pv_get_null(msg, param, res);
}
switch(spv->type)
{
case 1:
return pv_get_sintval(msg, param, res, spv->res->nrows);
break;
case 2:
return pv_get_sintval(msg, param, res, spv->res->ncols);
break;
case 3:
if(fixup_get_ivalue(msg, &spv->row, &row)!=0)
return pv_get_null(msg, param, res);
if(fixup_get_ivalue(msg, &spv->col, &col)!=0)
return pv_get_null(msg, param, res);
if(row>=spv->res->nrows)
return pv_get_null(msg, param, res);
if(col>=spv->res->ncols)
return pv_get_null(msg, param, res);
if(spv->res->vals[row][col].flags&PV_VAL_NULL)
return pv_get_null(msg, param, res);
if(spv->res->vals[row][col].flags&PV_VAL_INT)
return pv_get_sintval(msg, param, res,
spv->res->vals[row][col].value.n);
return pv_get_strval(msg, param, res,
&spv->res->vals[row][col].value.s);
break;
case 4:
if(fixup_get_ivalue(msg, &spv->col, &col)!=0)
return pv_get_null(msg, param, res);
if(col>=spv->res->ncols)
return pv_get_null(msg, param, res);
return pv_get_strval(msg, param, res,
&spv->res->cols[col].name);
break;
}
return 0;
}
示例3: pv_get_color
static int pv_get_color(struct sip_msg *msg, pv_param_t *param,
pv_value_t *res)
{
str s = {"", 0};
if(log_stderr==0 && force_color==0)
{
LM_DBG("ignoring colors\n");
return pv_get_strval(msg, param, res, &s);
}
dprint_term_color(param->pvn.u.isname.name.s.s[0],
param->pvn.u.isname.name.s.s[1], &s);
return pv_get_strval(msg, param, res, &s);
}
示例4: pv_get_mongodb
static int pv_get_mongodb(struct sip_msg *msg, pv_param_t *param,
pv_value_t *res)
{
mongodbc_pv_t *rpv;
rpv = (mongodbc_pv_t*)param->pvn.u.dname;
if(rpv->reply==NULL)
{
rpv->reply = mongodbc_get_reply(&rpv->rname);
if(rpv->reply==NULL)
return pv_get_null(msg, param, res);
}
switch(rpv->rkeyid) {
case 1:
/* value */
if(rpv->reply->jsonrpl.s==NULL)
return pv_get_null(msg, param, res);
return pv_get_strval(msg, param, res, &rpv->reply->jsonrpl);
case 2:
/* info */
return pv_get_null(msg, param, res);
case 3:
/* size */
return pv_get_null(msg, param, res);
case 0:
/* type */
return pv_get_sintval(msg, param, res, 0);
default:
/* We do nothing. */
return pv_get_null(msg, param, res);
}
}
示例5: pv_get_ht_expired_cell
int pv_get_ht_expired_cell(struct sip_msg *msg, pv_param_t *param,
pv_value_t *res)
{
if (res == NULL || ht_expired_cell == NULL)
{
return -1;
}
if (param->pvn.u.isname.name.s.len == 3 &&
strncmp(param->pvn.u.isname.name.s.s, "key", 3) == 0)
{
res->rs = ht_expired_cell->name;
}
else if (param->pvn.u.isname.name.s.len == 5 &&
strncmp(param->pvn.u.isname.name.s.s, "value", 5) == 0)
{
if(ht_expired_cell->flags&AVP_VAL_STR) {
return pv_get_strval(msg, param, res, &ht_expired_cell->value.s);
} else {
return pv_get_sintval(msg, param, res, ht_expired_cell->value.n);
}
}
if (res->rs.s == NULL)
res->flags = PV_VAL_NULL;
else
res->flags = PV_VAL_STR;
return 0;
}
示例6: pv_get_sdp
static int pv_get_sdp(sip_msg_t *msg, pv_param_t *param,
pv_value_t *res)
{
sdp_info_t *sdp = NULL;
if(msg==NULL || param==NULL)
return -1;
if(parse_sdp(msg) < 0) {
LM_INFO("Unable to parse sdp\n");
return pv_get_null(msg, param, res);
}
sdp = (sdp_info_t*)msg->body;
if (sdp==NULL) {
LM_DBG("No SDP\n");
return pv_get_null(msg, param, res);
}
switch(param->pvn.u.isname.name.n)
{
case 0:
return pv_get_strval(msg, param, res, &sdp->raw_sdp);
default:
return pv_get_null(msg, param, res);
}
}
示例7: pv_get_strftime
/**
* return strftime() formatted time
*/
int pv_get_strftime(struct sip_msg *msg, pv_param_t *param,
pv_value_t *res)
{
str s;
#define PV_STRFTIME_BUF_SIZE 64
static char _pv_strftime_buf[PV_STRFTIME_BUF_SIZE];
if(msg==NULL || param==NULL)
return -1;
if(msg_ctx_id_match(msg, &_cfgutils_msgid)!=1)
{
msg_set_time(msg);
msg_ctx_id_set(msg, &_cfgutils_msgid);
if(localtime_r(&msg->tval.tv_sec, &_cfgutils_ts) == NULL)
{
LM_ERR("unable to break time to attributes\n");
return -1;
}
}
s.len = strftime(_pv_strftime_buf, PV_STRFTIME_BUF_SIZE,
param->pvn.u.isname.name.s.s, &_cfgutils_ts);
if(s.len<=0)
return pv_get_null(msg, param, res);
s.s = _pv_strftime_buf;
return pv_get_strval(msg, param, res, &s);
}
示例8: pv_get_from_tag_initial
static int pv_get_from_tag_initial(sip_msg_t *msg, pv_param_t *param,
pv_value_t *res)
{
struct to_body *xto;
if(msg==NULL)
return -1;
if(parse_from_header(msg)<0) {
LM_ERR("cannot parse From header\n");
return pv_get_null(msg, param, res);
}
if(msg->from==NULL || get_from(msg)==NULL) {
LM_DBG("no From header\n");
return pv_get_null(msg, param, res);
}
xto = get_from(msg);
if(is_direction(msg, RR_FLOW_UPSTREAM)==0) {
if(msg->to==NULL && parse_headers(msg, HDR_TO_F, 0)==-1) {
LM_ERR("cannot parse To header\n");
return pv_get_null(msg, param, res);
}
if(msg->to==NULL || get_to(msg)==NULL) {
LM_DBG("no To header\n");
return pv_get_null(msg, param, res);
}
xto = get_to(msg);
}
if (xto->tag_value.s==NULL || xto->tag_value.len<=0) {
LM_DBG("no Tag parameter\n");
return pv_get_null(msg, param, res);
}
return pv_get_strval(msg, param, res, &xto->tag_value);
}
示例9: pv_get_huri
static int pv_get_huri(struct sip_msg *msg, pv_param_t *param,
pv_value_t *res)
{
if(msg==NULL || res==NULL)
return -1;
return pv_get_strval(msg, param, res, &msg->first_line.u.request.uri);
}
示例10: pv_get_registration_contact_f
/*
* Get the asserted Identity for the current user
*/
static int
pv_get_registration_contact_f(struct sip_msg *msg, pv_param_t *param,
pv_value_t *res)
{
str * ret_val = get_registration_contact(msg);
if (ret_val != NULL) return pv_get_strval(msg, param, res, ret_val);
else return -1;
}
示例11: pv_get_rdir
static int pv_get_rdir(sip_msg_t *msg, pv_param_t *param, pv_value_t *res)
{
if(msg==NULL || param==NULL)
return -1;
switch(param->pvn.u.isname.name.n)
{
case 1:
if(is_direction(msg, RR_FLOW_UPSTREAM)==0)
return pv_get_strval(msg, param, res, &pv_rr_flow_list[1]);
return pv_get_strval(msg, param, res, &pv_rr_flow_list[0]);
default:
if(is_direction(msg, RR_FLOW_UPSTREAM)==0)
return pv_get_uintval(msg, param, res, RR_FLOW_UPSTREAM);
return pv_get_uintval(msg, param, res, RR_FLOW_DOWNSTREAM);
}
}
示例12: pv_get_asserted_identity_f
/*
* Get the asserted Identity for the current user
*/
static int
pv_get_asserted_identity_f(struct sip_msg *msg, pv_param_t *param,
pv_value_t *res)
{
str * ret_val = get_asserted_identity(msg);
if (ret_val != NULL) return pv_get_strval(msg, param, res, ret_val);
else return -1;
}
示例13: pv_get_tm_reply_ruid
int pv_get_tm_reply_ruid(struct sip_msg *msg, pv_param_t *param,
pv_value_t *res)
{
struct cell *t;
tm_ctx_t *tcx = 0;
int branch;
if(msg==NULL || res==NULL)
return -1;
/* first get the transaction */
if (_tmx_tmb.t_check( msg , 0 )==-1) return -1;
if ( (t=_tmx_tmb.t_gett())==0) {
/* no T */
return pv_get_strempty(msg, param, res);
} else {
switch (get_route_type()) {
case FAILURE_ROUTE:
case BRANCH_FAILURE_ROUTE:
/* use the reason of the winning reply */
if ( (branch=_tmx_tmb.t_get_picked_branch())<0 ) {
LM_CRIT("no picked branch (%d) for a final response"
" in MODE_ONFAILURE\n", branch);
return pv_get_strempty(msg, param, res);
}
LM_DBG("reply ruid is [%.*s]\n", t->uac[branch].ruid.len, t->uac[branch].ruid.s);
return pv_get_strval(msg, param, res, &t->uac[branch].ruid);
break;
case TM_ONREPLY_ROUTE:
tcx = _tmx_tmb.tm_ctx_get();
if(tcx == NULL) {
return pv_get_strempty(msg, param, res);
}
branch = tcx->branch_index;
if(branch<0 || branch>=t->nr_of_outgoings) {
return pv_get_strempty(msg, param, res);
}
LM_DBG("reply ruid is [%.*s]\n", t->uac[branch].ruid.len, t->uac[branch].ruid.s);
return pv_get_strval(msg, param, res, &t->uac[branch].ruid);
default:
LM_ERR("unsupported route_type %d\n", get_route_type());
return pv_get_strempty(msg, param, res);
}
}
}
示例14: pv_get_sruid_val
static int pv_get_sruid_val(struct sip_msg *msg, pv_param_t *param,
pv_value_t *res)
{
if(res==NULL)
return -1;
if(sruid_next(&_kex_sruid)<0)
return pv_get_null(msg, param, res);
return pv_get_strval(msg, param, res, &_kex_sruid.uid);
}
示例15: pv_get_sndto
int pv_get_sndto(struct sip_msg *msg, pv_param_t *param,
pv_value_t *res)
{
struct onsend_info* snd_inf;
struct ip_addr ip;
str s;
snd_inf=get_onsend_info();
if (! likely(snd_inf && snd_inf->send_sock))
return pv_get_null(msg, param, res);
switch(param->pvn.u.isname.name.n)
{
case 1: /* af */
return pv_get_uintval(msg, param, res,
(int)snd_inf->send_sock->address.af);
case 2: /* port */
return pv_get_uintval(msg, param, res,
(int)su_getport(snd_inf->to));
case 3: /* proto */
return pv_get_uintval(msg, param, res,
(int)snd_inf->send_sock->proto);
case 4: /* buf */
s.s = snd_inf->buf;
s.len = snd_inf->len;
return pv_get_strval(msg, param, res, &s);
case 5: /* len */
return pv_get_uintval(msg, param, res,
(int)snd_inf->len);
case 6: /* sproto */
if(get_valid_proto_string((int)snd_inf->send_sock->proto,
0, 0, &s)<0)
return pv_get_null(msg, param, res);
return pv_get_strval(msg, param, res, &s);
default:
/* 0 - ip */
su2ip_addr(&ip, snd_inf->to);
s.s = ip_addr2a(&ip);
s.len = strlen(s.s);
return pv_get_strval(msg, param, res, &s);
}
return 0;
}