当前位置: 首页>>代码示例>>C++>>正文


C++ parse_to函数代码示例

本文整理汇总了C++中parse_to函数的典型用法代码示例。如果您正苦于以下问题:C++ parse_to函数的具体用法?C++ parse_to怎么用?C++ parse_to使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了parse_to函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: parse_to

char *parse_arglist(dbref player, dbref cause, char *dstr, char delim,
					dbref eval, char *fargs[], dbref nfargs, char *cargs[],
					dbref ncargs)
{
	char *rstr, *tstr, *bp, *str;
	int arg, peval;

	for(arg = 0; arg < nfargs; arg++)
		fargs[arg] = NULL;
	if(dstr == NULL)
		return NULL;
	rstr = parse_to(&dstr, delim, 0);
	arg = 0;

	peval = (eval & ~EV_EVAL);

	while ((arg < nfargs) && rstr) {
		if(arg < (nfargs - 1))
			tstr = parse_to(&rstr, ',', peval);
		else
			tstr = parse_to(&rstr, '\0', peval);
		if(eval & EV_EVAL) {
			bp = fargs[arg] = alloc_lbuf("parse_arglist");
			str = tstr;
			exec(fargs[arg], &bp, 0, player, cause, eval | EV_FCHECK, &str,
				 cargs, ncargs);
			*bp = '\0';
		} else {
			fargs[arg] = alloc_lbuf("parse_arglist");
			StringCopy(fargs[arg], tstr);
		}
		arg++;
	}
	return dstr;
}
开发者ID:gtaylor,项目名称:btmux,代码行数:35,代码来源:eval.c

示例2: NAT_target_parse

static int NAT_target_parse(char c,char *to_address,struct ipt_natinfo **target)
{

    switch (c) {
    case 'S':
        *target = parse_to(to_address, *target);
        return 1;
    case 'Z':
        *target = parse_to(to_address, *target);
        return 1;
    default:
        return 0;
    }
}
开发者ID:sorindumitru,项目名称:lkl-net,代码行数:14,代码来源:nat_cmd.c

示例3: DNAT_parse

static void DNAT_parse(struct xt_option_call *cb)
{
	const struct ipt_entry *entry = cb->xt_entry;
	struct ipt_natinfo *info = (void *)(*cb->target);
	int portok;

	if (entry->ip.proto == IPPROTO_TCP
	    || entry->ip.proto == IPPROTO_UDP
	    || entry->ip.proto == IPPROTO_SCTP
	    || entry->ip.proto == IPPROTO_DCCP
	    || entry->ip.proto == IPPROTO_ICMP)
		portok = 1;
	else
		portok = 0;

	xtables_option_parse(cb);
	switch (cb->entry->id) {
	case O_TO_DEST:
		if (cb->xflags & F_X_TO_DEST) {
			if (!kernel_version)
				get_kernel_version();
			if (kernel_version > LINUX_VERSION(2, 6, 10))
				xtables_error(PARAMETER_PROBLEM,
					   "DNAT: Multiple --to-destination not supported");
		}
		*cb->target = parse_to(cb->arg, portok, info);
		cb->xflags |= F_X_TO_DEST;
		break;
	case O_PERSISTENT:
		info->mr.range[0].flags |= NF_NAT_RANGE_PERSISTENT;
		break;
	}
}
开发者ID:SnapRoute,项目名称:netfilter,代码行数:33,代码来源:libipt_DNAT.c

示例4: extract_mangled_fromuri

static inline str* extract_mangled_fromuri(str *mangled_from_hdr)
{
	struct to_body from_b;
	struct hdr_field hdr;
	char *tmp,*end;

	if (mangled_from_hdr->len == 0 || mangled_from_hdr->s == NULL)
		return NULL;

	end = mangled_from_hdr->s+mangled_from_hdr->len;

	tmp=parse_hname2(mangled_from_hdr->s,end,&hdr);
	if (hdr.type==HDR_ERROR_T) {
		LM_ERR("bad from header\n");
		return NULL;
	}

	tmp=eat_lws_end(tmp, end);
	if (tmp >= end) {
		LM_ERR("empty header\n");
		return NULL;
	}

	parse_to(tmp,end,&from_b);
	if (from_b.error == PARSE_ERROR) {
		LM_ERR("bad from header [%.*s]\n",mangled_from_hdr->len,mangled_from_hdr->s);
		return NULL;
	}

	extracted_from_uri = from_b.uri;
	free_to_params(&from_b);

	LM_DBG("extracted from uri [%.*s]\n",extracted_from_uri.len,extracted_from_uri.s);
	return &extracted_from_uri;
}
开发者ID:MayamaTakeshi,项目名称:opensips,代码行数:35,代码来源:dlg_handlers.c

示例5: DNAT_parse

static void DNAT_parse(struct xt_option_call *cb)
{
	const struct ip6t_entry *entry = cb->xt_entry;
	struct nf_nat_range *range = cb->data;
	int portok;

	if (entry->ipv6.proto == IPPROTO_TCP ||
	    entry->ipv6.proto == IPPROTO_UDP ||
	    entry->ipv6.proto == IPPROTO_SCTP ||
	    entry->ipv6.proto == IPPROTO_DCCP ||
	    entry->ipv6.proto == IPPROTO_ICMP)
		portok = 1;
	else
		portok = 0;

	xtables_option_parse(cb);
	switch (cb->entry->id) {
	case O_TO_DEST:
		if (cb->xflags & F_X_TO_DEST) {
			if (!kernel_version)
				get_kernel_version();
			if (kernel_version > LINUX_VERSION(2, 6, 10))
				xtables_error(PARAMETER_PROBLEM,
					   "DNAT: Multiple --to-source not supported");
		}
		parse_to(cb->arg, portok, range);
		break;
	case O_PERSISTENT:
		range->flags |= NF_NAT_RANGE_PERSISTENT;
		break;
	}
}
开发者ID:jameshilliard,项目名称:bhr4_release_1.3.0.47.64,代码行数:32,代码来源:libip6t_DNAT.c

示例6: parse_diversion_header

/*! \brief
 * This method is used to parse DIVERSION header.
 *
 * params: msg : sip msg
 * returns 0 on success,
 *        -1 on failure.
 */
int parse_diversion_header(struct sip_msg *msg)
{
 	struct to_body* diversion_b;
	
 	if (!msg->diversion && (parse_headers(msg, HDR_DIVERSION_F, 0) == -1 ||
				!msg->diversion)) {
 		goto error;
 	}
 
 	/* maybe the header is already parsed! */
 	if (msg->diversion->parsed)
 		return 0;
 
 	/* bad luck! :-( - we have to parse it */
 	/* first, get some memory */
 	diversion_b = pkg_malloc(sizeof(struct to_body));
 	if (diversion_b == 0) {
 		LOG(L_ERR, "ERROR:parse_diversion_header: out of pkg_memory\n");
 		goto error;
 	}
 
 	/* now parse it!! */
 	memset(diversion_b, 0, sizeof(struct to_body));
 	parse_to(msg->diversion->body.s, msg->diversion->body.s + msg->diversion->body.len + 1, diversion_b);
 	if (diversion_b->error == PARSE_ERROR) {
 		LOG(L_ERR, "ERROR:parse_diversion_header: bad diversion header\n");
 		free_to(diversion_b);
 		goto error;
 	}
 	msg->diversion->parsed = diversion_b;
	
 	return 0;
 error:
 	return -1;
}
开发者ID:SibghatullahSheikh,项目名称:kamailio,代码行数:42,代码来源:parse_diversion.c

示例7: cscf_get_public_identity_from

/**
 * Returns the Public Identity extracted from the From header
 * @param msg - the SIP message
 * @returns the str containing the public id, no mem dup
 */
str cscf_get_public_identity_from(struct sip_msg *msg)
{
	str pu={0,0};
	struct to_body *from;
	int i;

	if (parse_headers(msg,HDR_FROM_F,0)!=0) {
		return pu;
	}

	if ( get_from(msg) == NULL ) {
		from = (struct to_body*) pkg_malloc(sizeof(struct to_body));
		parse_to( msg->from->body.s, msg->from->body.s + msg->from->body.len, from );
		msg->from->parsed = from;
	}
	else from=(struct to_body *) msg->from->parsed;

	pu = from->uri;

	/* truncate to sip:[email protected] or tel:number */
	for(i=4;i<pu.len;i++)
		if (pu.s[i]==';' || pu.s[i]=='?' ||pu.s[i]==':'){
			pu.len = i;
		}

	return pu;
}
开发者ID:AndreiPlesa,项目名称:kamailio,代码行数:32,代码来源:ims_getters.c

示例8: parse_rpid_header

/*! \brief
 * This method is used to parse RPID header.
 *
 * params: msg : sip msg
 * returns 0 on success,
 *        -1 on failure.
 */
int parse_rpid_header( struct sip_msg *msg )
{
	struct to_body* rpid_b;
	
 	if ( !msg->rpid && (parse_headers(msg, HDR_RPID_F, 0)==-1 || !msg->rpid)) {
 		goto error;
 	}
 
 	/* maybe the header is already parsed! */
 	if (msg->rpid->parsed)
 		return 0;
 
 	/* bad luck! :-( - we have to parse it */
 	/* first, get some memory */
 	rpid_b = pkg_malloc(sizeof(struct to_body));
 	if (rpid_b == 0) {
 		LOG(L_ERR, "ERROR:parse_rpid_header: out of pkg_memory\n");
 		goto error;
 	}
 
 	/* now parse it!! */
 	memset(rpid_b, 0, sizeof(struct to_body));
 	parse_to(msg->rpid->body.s,msg->rpid->body.s+msg->rpid->body.len+1,rpid_b);
 	if (rpid_b->error == PARSE_ERROR) {
 		LOG(L_ERR, "ERROR:parse_rpid_header: bad rpid header\n");
 		free_to(rpid_b);
 		goto error;
 	}
 	msg->rpid->parsed = rpid_b;
 
 	return 0;
 error:
 	return -1;
}
开发者ID:4N7HR4X,项目名称:kamailio,代码行数:41,代码来源:parse_rpid.c

示例9: get_appearance_name_addr

struct to_body* get_appearance_name_addr(struct sip_msg* msg)
{
	int len = 0;

	if(appearance_name_addr_spec_param.s)
	{
		memset(&appearance_name_addr_tok, 0, sizeof(pv_value_t));
		if(pv_get_spec_value(msg, &appearance_name_addr_spec, &appearance_name_addr_tok) < 0)
		{
			LM_ERR("Failed to get appearance_name_addr value\n");
			return NULL;
		}
		//LM_DBG("got appearance_name_addr_spec_param flags [%d]\n", appearance_name_addr_tok.flags);
		if(!(appearance_name_addr_tok.flags&PV_VAL_INT) &&
			(appearance_name_addr_tok.flags&PV_VAL_STR))
		{
			//LM_DBG("got PV_SPEC appearance_name_addr [%.*s]\n",
			//	appearance_name_addr_tok.rs.len, appearance_name_addr_tok.rs.s);
			if(appearance_name_addr_tok.rs.len+CRLF_LEN > APPEARANCE_NAME_ADDR_BUF_LEN) {
				LM_ERR("Buffer overflow\n");
				return NULL;
			}
			trim(&appearance_name_addr_tok.rs);
			memcpy(appearance_name_addr_buf, appearance_name_addr_tok.rs.s,
				appearance_name_addr_tok.rs.len);
			len = appearance_name_addr_tok.rs.len;
			if(strncmp(appearance_name_addr_tok.rs.s + len - CRLF_LEN, CRLF, CRLF_LEN)) {
				memcpy(appearance_name_addr_buf + len, CRLF, CRLF_LEN);
				len+= CRLF_LEN;
			}

			parse_to(appearance_name_addr_buf, appearance_name_addr_buf+len,
				&appearance_name_addr);
			if (appearance_name_addr.error != PARSE_OK) {
				LM_ERR("Failed to parse PV_SPEC appearance_name_addr [%.*s]\n",
					len, appearance_name_addr_buf);
				return NULL;
			}
			if (parse_uri(appearance_name_addr.uri.s, appearance_name_addr.uri.len,
					&appearance_name_addr.parsed_uri)<0) {
				LM_ERR("failed to parse PV_SPEC appearance_name_addr uri [%.*s]\n",
					appearance_name_addr.uri.len, appearance_name_addr.uri.s);
				return NULL;
			}
			return &appearance_name_addr;
		}
	}

	/* If the appearance_name_addr_spec_param is not set, use the From uri */
	/*
	if (msg->from->parsed == NULL) {
		if (parse_from_header(msg)<0) {
			LM_ERR("cannot parse From header\n");
			return NULL;
		}
	}
	*/

	return msg->from->parsed;
}
开发者ID:OpenSIPS,项目名称:opensips,代码行数:60,代码来源:b2b_sca.c

示例10: sca_get_msg_to_header

    int
sca_get_msg_to_header( sip_msg_t *msg, struct to_body **to )
{
    struct to_body	parsed_to;
    struct to_body	*t = NULL;

    assert( msg != NULL );
    assert( to != NULL );

    if ( SCA_HEADER_EMPTY( msg->to )) {
	LM_ERR( "Empty To header" );
	return( -1 );
    }
    t = get_to( msg );
    if ( t == NULL ) {
	parse_to( msg->to->body.s,
		  msg->to->body.s + msg->to->body.len + 1, /* end of buffer */
		  &parsed_to );
	if ( parsed_to.error != PARSE_OK ) {
	    LM_ERR( "Bad To header" );
	    return( -1 );
	}
	t = &parsed_to;
    }

    /* ensure the URI is parsed for future use */
    if ( parse_uri( t->uri.s, t->uri.len, GET_TO_PURI( msg )) < 0 ) {
	LM_ERR( "Failed to parse To URI %.*s", STR_FMT( &t->uri ));
	return( -1 );
    }

    *to = t;

    return( 0 );
}
开发者ID:AndreyRybkin,项目名称:kamailio,代码行数:35,代码来源:sca_util.c

示例11: get_b2bl_from

struct to_body* get_b2bl_from(struct sip_msg* msg)
{
	int len = 0;

	if(b2bl_from_spec_param.s)
	{
		memset(&b2bl_from_tok, 0, sizeof(pv_value_t));
		if(pv_get_spec_value(msg, &b2bl_from_spec, &b2bl_from_tok) < 0)
		{
			LM_ERR("Failed to get b2bl_from value\n");
			return NULL;
		}
		//LM_DBG("got b2bl_from_spec_param flags [%d]\n", b2bl_from_tok.flags);
		if(b2bl_from_tok.flags&PV_VAL_INT)
		{
			/* the PV might be empty */
			return NULL;
		}
		if(b2bl_from_tok.flags&PV_VAL_STR)
		{
			//LM_DBG("got PV_SPEC b2bl_from [%.*s]\n",
			//	b2bl_from_tok.rs.len, b2bl_from_tok.rs.s);
			if(b2bl_from_tok.rs.len+CRLF_LEN > B2BL_FROM_BUF_LEN) {
				LM_ERR("Buffer overflow\n");
				return NULL;
			}
			trim(&b2bl_from_tok.rs);
			memcpy(b2bl_from_buf, b2bl_from_tok.rs.s,
				b2bl_from_tok.rs.len);
			len = b2bl_from_tok.rs.len;
			if(strncmp(b2bl_from_tok.rs.s + len - CRLF_LEN, CRLF, CRLF_LEN)) {
				memcpy(b2bl_from_buf + len, CRLF, CRLF_LEN);
				len+= CRLF_LEN;
			}

			parse_to(b2bl_from_buf, b2bl_from_buf+len,
				&b2bl_from);
			if (b2bl_from.error != PARSE_OK) {
				LM_ERR("Failed to parse PV_SPEC b2bl_from [%.*s]\n",
					len, b2bl_from_buf);
				return NULL;
			}
			if (parse_uri(b2bl_from.uri.s, b2bl_from.uri.len,
					&b2bl_from.parsed_uri)<0) {
				LM_ERR("failed to parse PV_SPEC b2bl_from uri [%.*s]\n",
					b2bl_from.uri.len, b2bl_from.uri.s);
				return NULL;
			}

			/* side effect of parsing - nobody should need them later on,
			 * so free them right now */
			free_to_params(&b2bl_from);
			return &b2bl_from;
		}
	}

	return NULL;
}
开发者ID:GeorgeShaw,项目名称:opensips,代码行数:58,代码来源:b2b_logic.c

示例12: ospGetPChargeInfoUserpart

/*
 * Get user part from P-Charge-Info header
 * param msg SIP message
 * param user User part of P-Charge-Info header
 * param bufsize Size of fromuser buffer
 * return 0 success, 1 without P-Charge-Info, -1 failure
 */
int ospGetPChargeInfoUserpart(
    struct sip_msg* msg,
    char* pciuser,
    int bufsize)
{
    static const char* header = "P-Charge-Info";
    struct to_body body;
    struct to_body* pci=NULL;
    struct hdr_field *hf;
    struct sip_uri uri;
    int result = -1;

    if ((pciuser != NULL) && (bufsize > 0)) {
        pciuser[0] = '\0';
        if (parse_headers(msg, HDR_EOH_F, 0) < 0) {
            LM_ERR("failed to parse message\n");
            return -1;
        }
        for (hf = msg->headers; hf; hf = hf->next) {
            if ((hf->type == HDR_OTHER_T) &&
                (hf->name.len == strlen(header)) &&
                (strncasecmp(hf->name.s, header, hf->name.len) == 0))
            {
                if (!(pci = hf->parsed)) {
                    pci = &body;
                    parse_to(hf->body.s, hf->body.s + hf->body.len + 1, pci);
                }
                if (pci->error != PARSE_ERROR) {
                    if (parse_uri(pci->uri.s, pci->uri.len, &uri) == 0) {
                        ospCopyStrToBuffer(&uri.user, pciuser, bufsize);
                        ospSkipUserParam(pciuser);
                        result = 0;
                    } else {
                        LM_ERR("failed to parse P-Charge-Info uri\n");
                    }
                    if (pci == &body) {
                        free_to_params(pci);
                    }
                } else {
                    LM_ERR("bad P-Charge-Info header\n");
                }
                break;
            }
        }
        if (!hf) {
            LM_DBG("without P-Charge-Info header\n");
            result = 1;
        }
    } else {
        LM_ERR("bad parameters to parse user part from PAI\n");
    }

    return result;
}
开发者ID:dynamicpacket,项目名称:opensips-testing,代码行数:61,代码来源:sipheader.c

示例13: SNAT_parse

static int SNAT_parse(int c, char **argv, int invert, unsigned int *flags,
                      const void *e, struct xt_entry_target **target)
{
	const struct ipt_entry *entry = e;
	struct ipt_natinfo *info = (void *)*target;
	int portok;

	if (entry->ip.proto == IPPROTO_TCP
	    || entry->ip.proto == IPPROTO_UDP
	    || entry->ip.proto == IPPROTO_SCTP
	    || entry->ip.proto == IPPROTO_DCCP
	    || entry->ip.proto == IPPROTO_ICMP)
		portok = 1;
	else
		portok = 0;

	switch (c) {
	case '1':
		if (xtables_check_inverse(optarg, &invert, NULL, 0, argv))
			xtables_error(PARAMETER_PROBLEM,
				   "Unexpected `!' after --to-source");

		if (*flags & IPT_SNAT_OPT_SOURCE) {
			if (!kernel_version)
				get_kernel_version();
			if (kernel_version > LINUX_VERSION(2, 6, 10))
				xtables_error(PARAMETER_PROBLEM,
					   "Multiple --to-source not supported");
		}
		*target = parse_to(optarg, portok, info);
		/* WTF do we need this for?? */
		if (*flags & IPT_SNAT_OPT_RANDOM)
			info->mr.range[0].flags |= IP_NAT_RANGE_PROTO_RANDOM;
		*flags |= IPT_SNAT_OPT_SOURCE;
		return 1;

	case '2':
		if (*flags & IPT_SNAT_OPT_SOURCE) {
			info->mr.range[0].flags |= IP_NAT_RANGE_PROTO_RANDOM;
			*flags |= IPT_SNAT_OPT_RANDOM;
		} else
			*flags |= IPT_SNAT_OPT_RANDOM;
		return 1;

	case '3':
		info->mr.range[0].flags |= IP_NAT_RANGE_PERSISTENT;
		return 1;

	default:
		return 0;
	}
}
开发者ID:inibir,项目名称:daemongroup,代码行数:52,代码来源:libipt_SNAT.c

示例14: notify_quiet

// ---------------------------------------------------------------------------
// do_query: Command interface to sql_que
//
void do_query
(
    dbref executor,
    dbref caller,
    dbref enactor,
    int   eval,
    int   key,
    char *dbref_attr,
    char *dbname_query,
    char *cargs[],
    int   ncargs
)
{
    if (key & QUERY_SQL)
    {
        // SQL Query.
        //
        dbref thing;
        ATTR *pattr;

        if (!( parse_attrib(executor, dbref_attr, &thing, &pattr)
            && pattr))
        {
            notify_quiet(executor, "No match.");
            return;
        }

        if (!Controls(executor, thing))
        {
            notify_quiet(executor, NOPERM_MESSAGE);
            return;
        }

        char *pQuery = dbname_query;
        char *pDBName = parse_to(&pQuery, '/', 0);

        if (NULL == pQuery)
        {
            notify(executor, "QUERY: No Query.");
            return;
        }

        STARTLOG(LOG_ALWAYS, "CMD", "QUERY");
        Log.tinyprintf("Thing=#%d, Attr=%s, dbname=%s, query=%s", thing, pattr->name, pDBName, pQuery);
        ENDLOG;
    }
    else
    {
        notify_quiet(executor, "At least one query option is required.");
    }
}
开发者ID:Yargling,项目名称:MuxDevelopment,代码行数:54,代码来源:cque.cpp

示例15: SAME_parse

/* Function which parses command options; returns true if it
   ate an option */
static int SAME_parse(int c, char **argv, int invert, unsigned int *flags,
                      const void *entry, struct xt_entry_target **target)
{
	struct ipt_same_info *mr
		= (struct ipt_same_info *)(*target)->data;
	unsigned int count;

	switch (c) {
	case '1':
		if (mr->rangesize == IPT_SAME_MAX_RANGE)
			exit_error(PARAMETER_PROBLEM,
				   "Too many ranges specified, maximum "
				   "is %i ranges.\n",
				   IPT_SAME_MAX_RANGE);
		if (check_inverse(optarg, &invert, NULL, 0))
			exit_error(PARAMETER_PROBLEM,
				   "Unexpected `!' after --to");

		parse_to(optarg, &mr->range[mr->rangesize]);
		/* WTF do we need this for? */
		if (*flags & IPT_SAME_OPT_RANDOM)
			mr->range[mr->rangesize].flags 
				|= IP_NAT_RANGE_PROTO_RANDOM;
		mr->rangesize++;
		*flags |= IPT_SAME_OPT_TO;
		break;
		
	case '2':
		if (*flags & IPT_SAME_OPT_NODST)
			exit_error(PARAMETER_PROBLEM,
				   "Can't specify --nodst twice");
		
		mr->info |= IPT_SAME_NODST;
		*flags |= IPT_SAME_OPT_NODST;
		break;

	case '3':	
		*flags |= IPT_SAME_OPT_RANDOM;
		for (count=0; count < mr->rangesize; count++)
			mr->range[count].flags |= IP_NAT_RANGE_PROTO_RANDOM;
		break;

	default:
		return 0;
	}
	
	return 1;
}
开发者ID:inibir,项目名称:daemongroup,代码行数:50,代码来源:libipt_SAME.c


注:本文中的parse_to函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。