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


C++ parse_msg函数代码示例

本文整理汇总了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);
}
开发者ID:BackupTheBerlios,项目名称:elua-svn,代码行数:61,代码来源:dhcpc.c

示例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);



}
开发者ID:VikingMew,项目名称:network-lab,代码行数:25,代码来源:irc.c

示例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;
	}
}
开发者ID:119,项目名称:ipcam_search_protocol,代码行数:25,代码来源:ipcam_search_pc.c

示例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;
}
开发者ID:hermixy,项目名称:qtun,代码行数:26,代码来源:client.c

示例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;
}
开发者ID:gbour,项目名称:kamailio,代码行数:35,代码来源:cnxcc_sip_msg_faker.c

示例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;
}
开发者ID:AriZuu,项目名称:picoos-net,代码行数:26,代码来源:dhcpc.c

示例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;
}
开发者ID:ivanbarlog,项目名称:sip_single_port,代码行数:27,代码来源:ssp_replace.c

示例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;
}
开发者ID:MohammedYaseen,项目名称:kamailio,代码行数:34,代码来源:faked_msg.c

示例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);
}
开发者ID:SoundGuyAndy,项目名称:MissingLinkFirmware,代码行数:33,代码来源:udpapp.c

示例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;
}
开发者ID:adubovikov,项目名称:kamailio,代码行数:60,代码来源:topoh_mod.c

示例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;
 }
开发者ID:yinqiwen,项目名称:pbjson,代码行数:7,代码来源:pbjson.cpp

示例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;
}
开发者ID:GreenfieldTech,项目名称:kamailio,代码行数:34,代码来源:gzcompress_mod.c

示例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 ();
}
开发者ID:deirf,项目名称:libumberlog,代码行数:34,代码来源:test_umberlog.c

示例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;
}
开发者ID:4N7HR4X,项目名称:kamailio,代码行数:28,代码来源:seas_action.c

示例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;
}
开发者ID:ChowZenki,项目名称:RetroArch,代码行数:34,代码来源:command.c


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