本文整理汇总了C++中parse_msg函数的典型用法代码示例。如果您正苦于以下问题:C++ parse_msg函数的具体用法?C++ parse_msg怎么用?C++ parse_msg使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了parse_msg函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PT_THREAD
/*---------------------------------------------------------------------------*/
static
PT_THREAD(handle_dhcp(void))
{
PT_BEGIN(&s.pt);
/* try_again:*/
s.state = STATE_SENDING;
s.ticks = CLOCK_SECOND;
do {
send_discover();
s.timer_init = platform_timer_op( ELUA_DHCP_TIMER_ID, PLATFORM_TIMER_OP_START, 0 );
PT_WAIT_UNTIL(&s.pt, uip_newdata() || platform_timer_get_diff_us( ELUA_DHCP_TIMER_ID, s.timer_init, platform_timer_op( ELUA_DHCP_TIMER_ID, PLATFORM_TIMER_OP_READ, 0 ) ) >= s.ticks );
if(uip_newdata() && parse_msg() == DHCPOFFER) {
uip_flags &= ~UIP_NEWDATA;
s.state = STATE_OFFER_RECEIVED;
break;
}
uip_flags &= ~UIP_NEWDATA;
if(s.ticks < CLOCK_SECOND * 60) {
s.ticks *= 2;
} else {
s.ipaddr[0] = 0;
goto dhcp_failed;
}
} while(s.state != STATE_OFFER_RECEIVED);
s.ticks = CLOCK_SECOND;
do {
send_request();
s.timer_init = platform_timer_op( ELUA_DHCP_TIMER_ID, PLATFORM_TIMER_OP_START, 0 );
PT_WAIT_UNTIL(&s.pt, uip_newdata() || platform_timer_get_diff_us( ELUA_DHCP_TIMER_ID, s.timer_init, platform_timer_op( ELUA_DHCP_TIMER_ID, PLATFORM_TIMER_OP_READ, 0 ) ) >= s.ticks );
if(uip_newdata() && parse_msg() == DHCPACK) {
uip_flags &= ~UIP_NEWDATA;
s.state = STATE_CONFIG_RECEIVED;
break;
}
uip_flags &= ~UIP_NEWDATA;
if(s.ticks <= CLOCK_SECOND * 10) {
s.ticks += CLOCK_SECOND;
} else {
PT_RESTART(&s.pt);
}
} while(s.state != STATE_CONFIG_RECEIVED);
dhcp_failed:
dhcpc_configured(&s);
/*
* PT_END restarts the thread so we do this instead. Eventually we
* should reacquire expired leases here.
*/
while(1) {
PT_YIELD(&s.pt);
}
PT_END(&s.pt);
}
示例2: do_irc
void do_irc(int fd) {
char recvbuf[MAX_MSG_LEN + 1];
char recvbuf2[MAX_MSG_LEN+1];
char sendbuf[MAX_MSG_LEN + 1];
char tokens[MAX_MSG_TOKENS][MAX_MSG_LEN+1];
int length;
bzero(&recvbuf, sizeof(recvbuf));
bzero(&sendbuf, sizeof(sendbuf));
read_msg(fd, recvbuf);
bzero(&recvbuf2, sizeof(recvbuf2));
trim(recvbuf, recvbuf2);
length = tokenize(recvbuf2, tokens);
parse_msg(tokens, length, sendbuf, fd);
}
示例3: dealnet
static void dealnet(aeEventLoop *loop, int fd, void *privdata, int mask)
{
struct sockaddr_in peer;
char buf[MAX_MSG_LEN];
struct ipcam_search_msg *msg_buf;
socklen_t len;
int ret;
len = sizeof(struct sockaddr_in);
ret = recvfrom(fd, buf, sizeof(buf), 0,
(struct sockaddr *)&peer, (socklen_t *)&len);
if (ret < 0) {
debug_print("recvfrom fail");
return;
}
msg_buf = malloc(sizeof(struct ipcam_search_msg)
+ ((struct ipcam_search_msg *)buf)->exten_len);
parse_msg(buf, ret, msg_buf);
deal_msg_func(msg_buf, &peer);
if (msg_buf) {
free(msg_buf);
msg_buf = NULL;
}
}
示例4: process_msg
static void process_msg(msg_t* msg, int localfd)
{
void* buffer = NULL;
unsigned short len;
int sys;
size_t room_id;
if (parse_msg(msg, &sys, &buffer, &len, &room_id))
{
if (sys) client_process_sys(msg, buffer, len);
else
{
ssize_t written = write_n(localfd, buffer, len);
SYSLOG(LOG_INFO, "write local length: %ld", written);
}
}
else
{
SYSLOG(LOG_WARNING, "Parse message error");
return;
}
if (buffer) pool_room_free(&this.pool, room_id);
this.client.status = (this.client.status & ~CLIENT_STATUS_WAITING_BODY) | CLIENT_STATUS_WAITING_HEADER;
this.client.want = sizeof(msg_t);
this.client.read = this.client.buffer;
}
示例5: faked_msg_init_with_dlg_info
int faked_msg_init_with_dlg_info(str *callid, str *from_tag, str *to_tag, struct sip_msg **msg)
{
memset(_faked_sip_msg_buf, 0, FAKED_SIP_MSG_BUF_LEN);
sprintf(_faked_sip_msg_buf, FAKED_SIP_MSG_FORMAT, from_tag->len, from_tag->s,
to_tag->len, to_tag->s,
callid->len, callid->s);
memset(&_faked_msg, 0, sizeof(struct sip_msg));
_faked_msg.buf = _faked_sip_msg_buf;
_faked_msg.len = strlen(_faked_sip_msg_buf);
_faked_msg.set_global_address = default_global_address;
_faked_msg.set_global_port = default_global_port;
if (parse_msg(_faked_msg.buf, _faked_msg.len, &_faked_msg) != 0)
{
LM_ERR("parse_msg failed\n");
return -1;
}
_faked_msg.rcv.proto = PROTO_UDP;
_faked_msg.rcv.src_port = 5060;
_faked_msg.rcv.src_ip.u.addr32[0] = 0x7f000001;
_faked_msg.rcv.src_ip.af = AF_INET;
_faked_msg.rcv.src_ip.len = 4;
_faked_msg.rcv.dst_port = 5060;
_faked_msg.rcv.dst_ip.u.addr32[0] = 0x7f000001;
_faked_msg.rcv.dst_ip.af = AF_INET;
_faked_msg.rcv.dst_ip.len = 4;
*msg = &_faked_msg;
return 0;
}
示例6: readResponse
static int readResponse(int type, int timeoutSecs)
{
int len;
JIF_t end;
int wait;
wait = timeoutSecs * HZ;
end = jiffies + wait;
do {
if ((len = netSockRead(s.conn, &dhcp_msg_buf, sizeof(dhcp_msg_buf), wait)) > 0) {
if(msg_for_me(len) == type) {
parse_msg(len);
return len;
}
}
wait = end - jiffies;
} while (wait > 0);
return -1;
}
示例7: skip_media_changes
int skip_media_changes(sip_msg_t *msg) {
if (parse_msg(msg->buf, msg->len, msg) == 0) {
if (msg->first_line.type == SIP_REQUEST) {
if (msg->REQ_METHOD == METHOD_INVITE) {
return 1;
}
} else if (msg->first_line.type == SIP_REPLY) {
if (parse_headers(msg, HDR_CSEQ_F, 0) != 0) {
return -1;
}
if (&msg->cseq == NULL || &msg->cseq->body.s == NULL) {
return -1;
}
unsigned int code = msg->REPLY_STATUS;
if (code >= 200 && code < 300 && get_cseq(msg)->method_id == METHOD_INVITE) {
return 1;
}
}
}
return -1;
}
示例8: faked_msg_init
int faked_msg_init(void)
{
if(_faked_msg_no>0)
return 0;
/* init faked sip msg */
memcpy(_faked_sip_buf, FAKED_SIP_MSG, FAKED_SIP_MSG_LEN);
_faked_sip_buf[FAKED_SIP_MSG_LEN] = '\0';
memset(&_faked_msg, 0, sizeof(struct sip_msg));
_faked_msg.buf=_faked_sip_buf;
_faked_msg.len=FAKED_SIP_MSG_LEN;
_faked_msg.set_global_address=default_global_address;
_faked_msg.set_global_port=default_global_port;
if (parse_msg(_faked_msg.buf, _faked_msg.len, &_faked_msg)!=0)
{
LM_ERR("parse_msg failed\n");
return -1;
}
_faked_msg.rcv.proto = PROTO_UDP;
_faked_msg.rcv.src_port = 5060;
_faked_msg.rcv.src_ip.u.addr32[0] = 0x7f000001;
_faked_msg.rcv.src_ip.af = AF_INET;
_faked_msg.rcv.src_ip.len = 4;
_faked_msg.rcv.dst_port = 5060;
_faked_msg.rcv.dst_ip.u.addr32[0] = 0x7f000001;
_faked_msg.rcv.dst_ip.af = AF_INET;
_faked_msg.rcv.dst_ip.len = 4;
return 0;
}
示例9: PT_THREAD
static PT_THREAD(handle_connection(void))
{
PT_BEGIN(&s.pt);
s.state = STATE_LISTENING;
do {
PT_WAIT_UNTIL(&s.pt, uip_newdata());
if(uip_newdata() && parse_msg()) {
s.state = STATE_HELLO_RECEIVED;
uip_flags &= (~UIP_NEWDATA);
break;
}
} while(s.state != STATE_HELLO_RECEIVED);
do {
send_request();
PT_WAIT_UNTIL(&s.pt, uip_newdata());
if(uip_newdata()) {
s.state = STATE_NAME_RECEIVED;
uip_flags &= (~UIP_NEWDATA);
break;
}
} while(s.state != STATE_NAME_RECEIVED);
send_response();
s.state = STATE_INIT;
PT_END(&s.pt);
}
示例10: th_prepare_msg
int th_prepare_msg(sip_msg_t *msg)
{
if (parse_msg(msg->buf, msg->len, msg)!=0)
{
LM_DBG("outbuf buffer parsing failed!");
return 1;
}
if(msg->first_line.type==SIP_REQUEST)
{
if(!IS_SIP(msg))
{
LM_DBG("non sip request message\n");
return 1;
}
} else if(msg->first_line.type!=SIP_REPLY) {
LM_DBG("non sip message\n");
return 1;
}
if (parse_headers(msg, HDR_EOH_F, 0)==-1)
{
LM_DBG("parsing headers failed [[%.*s]]\n",
msg->len, msg->buf);
return 2;
}
/* force 2nd via parsing here - it helps checking it later */
if (parse_headers(msg, HDR_VIA2_F, 0)==-1
|| (msg->via2==0) || (msg->via2->error!=PARSE_OK))
{
LM_DBG("no second via in this message \n");
}
if(parse_from_header(msg)<0)
{
LM_ERR("cannot parse FROM header\n");
return 3;
}
if(parse_to_header(msg)<0 || msg->to==NULL)
{
LM_ERR("cannot parse TO header\n");
return 3;
}
if(get_to(msg)==NULL)
{
LM_ERR("cannot get TO header\n");
return 3;
}
if(msg->via1==NULL || msg->callid==NULL) {
LM_ERR("mandatory headers missing - via1: %p callid: %p\n",
msg->via1, msg->callid);
return 4;
}
return 0;
}
示例11: pb2json
void pb2json(const Message* msg, std::string& str)
{
rapidjson::Value::AllocatorType allocator;
rapidjson::Value* json = parse_msg(msg, allocator);
json2string(json, str);
delete json;
}
示例12: gzc_prepare_msg
int gzc_prepare_msg(sip_msg_t *msg)
{
if (parse_msg(msg->buf, msg->len, msg)!=0)
{
LM_DBG("outbuf buffer parsing failed!");
return 1;
}
if(msg->first_line.type==SIP_REQUEST)
{
if(!IS_SIP(msg) && !IS_HTTP(msg))
{
LM_DBG("non sip or http request\n");
return 1;
}
} else if(msg->first_line.type==SIP_REPLY) {
if(!IS_SIP_REPLY(msg) && !IS_HTTP_REPLY(msg))
{
LM_DBG("non sip or http response\n");
return 1;
}
} else {
LM_DBG("non sip or http message\n");
return 1;
}
if (parse_headers(msg, HDR_EOH_F, 0)==-1)
{
LM_DBG("parsing headers failed");
return 2;
}
return 0;
}
示例13: START_TEST
END_TEST
#ifdef HAVE_PARSE_PRINTF_FORMAT
/**
* Test parsing additional format strings, that are only supported if
* we're under glibc.
*/
START_TEST (test_positional_params)
{
char *msg;
struct json_object *jo;
ul_openlog ("umberlog/test_positional_params", 0, LOG_LOCAL0);
#define COMPLEX_FORMAT \
"%3$*5$.*2$hhd , %1$Lf , %4$.3s , %4$s", 1.0L, 5, (char)100, "prefix", -8
#define COMPLEX_RESULT "00100 , 1.000000 , pre , prefix"
msg = ul_format (LOG_DEBUG, COMPLEX_FORMAT,
"simple1", "value1",
"complex", COMPLEX_FORMAT,
"simple2", "value2",
NULL);
jo = parse_msg (msg);
free (msg);
verify_value (jo, "msg", COMPLEX_RESULT);
verify_value (jo, "simple1", "value1");
verify_value (jo, "complex", COMPLEX_RESULT);
verify_value (jo, "simple2", "value2");
json_object_put (jo);
ul_closelog ();
}
示例14: LM_ERR
static inline struct sip_msg *parse_ac_msg(hdr_flags_t flags,char *start,int len)
{
struct sip_msg *my_msg;
my_msg=NULL;
if(!(my_msg=pkg_malloc(sizeof(struct sip_msg)))){
LM_ERR("ac_reply: out of memory!\n");
goto error;
}
memset(my_msg,0,sizeof(struct sip_msg));
my_msg->buf=start;
my_msg->len=len;
LM_DBG("Action Message:[%.*s]\n",len,start);
if(0>parse_msg(start,len,my_msg)){
LM_ERR("parse_ac_msg: parsing sip_msg");
goto error;
}
if(0>parse_headers(my_msg,flags,0)){
LM_ERR("parse_ac_msg: parsing headers\n");
goto error;
}
return my_msg;
error:
if(my_msg){
free_sip_msg_lite(my_msg);
pkg_free(my_msg);
}
return NULL;
}
示例15: stdin_cmd_poll
static void stdin_cmd_poll(rarch_cmd_t *handle)
{
if (!handle->stdin_enable)
return;
size_t ret = read_stdin(handle->stdin_buf + handle->stdin_buf_ptr, STDIN_BUF_SIZE - handle->stdin_buf_ptr - 1);
if (ret == 0)
return;
handle->stdin_buf_ptr += ret;
handle->stdin_buf[handle->stdin_buf_ptr] = '\0';
char *last_newline = strrchr(handle->stdin_buf, '\n');
if (!last_newline)
{
// We're receiving bogus data in pipe (no terminating newline),
// flush out the buffer.
if (handle->stdin_buf_ptr + 1 >= STDIN_BUF_SIZE)
{
handle->stdin_buf_ptr = 0;
handle->stdin_buf[0] = '\0';
}
return;
}
*last_newline++ = '\0';
ptrdiff_t msg_len = last_newline - handle->stdin_buf;
parse_msg(handle, handle->stdin_buf);
memmove(handle->stdin_buf, last_newline, handle->stdin_buf_ptr - msg_len);
handle->stdin_buf_ptr -= msg_len;
}