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


C++ PT_WAIT_THREAD函数代码示例

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


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

示例1: PT_THREAD

/*---------------------------------------------------------------------------*/
static
PT_THREAD(handle_output(struct httpd_state *s))
{
  PT_BEGIN(&s->outputpt);
 
  char *ptr;

  if(!httpd_fs_open(s->filename, &s->file)) {
    httpd_fs_open(http_404_html, &s->file);
    strcpy_P(s->filename, http_404_html);
    PT_WAIT_THREAD(&s->outputpt, send_headers(s, http_header_404));
    PT_WAIT_THREAD(&s->outputpt, send_file(s));
  } else {
    snprintf(s->tmp_str, sizeof(s->tmp_str) -1, "%d", s->file.len);
    //snprintf(s->str_tmp, 8, "%d", s->len);
    PT_WAIT_THREAD(&s->outputpt, send_headers(s, http_header_200));
    ptr = strchr(s->filename, ISO_period);
    if(ptr != NULL && strncmp_P(ptr, http_shtml, 6) == 0) {
      PT_INIT(&s->scriptpt);
      PT_WAIT_THREAD(&s->outputpt, handle_script(s));
    } else {
      PT_WAIT_THREAD(&s->outputpt, send_file(s));
    }
  }

  PSOCK_CLOSE(&s->sout);
  PT_END(&s->outputpt);
}
开发者ID:jaseg,项目名称:avr-uip,代码行数:29,代码来源:httpd.c

示例2: PT_THREAD

static
PT_THREAD(handle_output(struct httpd_state *s))
{
  char *ptr;
  
  PT_BEGIN(&s->outputpt);
#if DEBUGLOGIC
   httpd_strcpy(s->filename,httpd_indexfn);
#endif
  if(!httpd_fs_open(s->filename, &s->file)) {
    httpd_strcpy(s->filename, httpd_404fn);
    httpd_fs_open(s->filename, &s->file);
    PT_WAIT_THREAD(&s->outputpt, send_headers(s, httpd_404notf));
    PT_WAIT_THREAD(&s->outputpt, send_file(s));
  } else {
    PT_WAIT_THREAD(&s->outputpt, send_headers(s, httpd_200ok));
    ptr = strchr(s->filename, ISO_period);
    if((ptr != NULL && httpd_strncmp(ptr, httpd_shtml, 6) == 0) || httpd_strcmp(s->filename,httpd_indexfn)==0) {
      PT_INIT(&s->scriptpt);
      PT_WAIT_THREAD(&s->outputpt, handle_script(s));
    } else {
      PT_WAIT_THREAD(&s->outputpt, send_file(s));
    }
  }
  PSOCK_CLOSE(&s->sout);
  PT_END(&s->outputpt);
}
开发者ID:Ammar-85,项目名称:contiki-arduino,代码行数:27,代码来源:httpd.c

示例3: PT_THREAD

/*---------------------------------------------------------------------------*/
static
PT_THREAD(handle_script(struct httpd_state *s))
{
  char *ptr;
  
  PT_BEGIN(&s->scriptpt);


  while(s->file.len > 0) {

    /* Check if we should start executing a script. */
    if(*s->file.data == ISO_percent &&
      *(s->file.data + 1) == ISO_bang) {
      s->scriptptr = s->file.data + 3;
      s->scriptlen = s->file.len - 3;
      if(*(s->scriptptr - 1) == ISO_colon) {
	httpd_fs_open(s->scriptptr + 1, &s->file);
	PT_WAIT_THREAD(&s->scriptpt, send_file(s));
      } else {
        // Httpd_cgi is called here
	PT_WAIT_THREAD(&s->scriptpt,
		       httpd_cgi(s->scriptptr)(s, s->scriptptr));
      }
      next_scriptstate(s);
      
      /* The script is over, so we reset the pointers and continue
	 sending the rest of the file. */
      s->file.data = s->scriptptr;
      s->file.len = s->scriptlen;
    } else {
      /* See if we find the start of script marker in the block of HTML
	 to be sent. */

      if(s->file.len > uip_mss()) {
	s->len = uip_mss();
      } else {
	s->len = s->file.len;
      }

      if(*s->file.data == ISO_percent) {
	ptr = strchr(s->file.data + 1, ISO_percent);
      } else {
	ptr = strchr(s->file.data, ISO_percent);
      }
      if(ptr != NULL &&
	 ptr != s->file.data) {
	s->len = (int)(ptr - s->file.data);
	if(s->len >= uip_mss()) {
	  s->len = uip_mss();
	}
      }
      PT_WAIT_THREAD(&s->scriptpt, send_part_of_file(s));
      s->file.data += s->len;
      s->file.len -= s->len;
      
    }
  }
  
  PT_END(&s->scriptpt);
}
开发者ID:dray92,项目名称:EE-472,代码行数:61,代码来源:httpd.c

示例4: PT_BEGIN

int DLGSM::PT_SMS_send(struct pt *pt, char *ret, char *nr, char *text, int len) {
	static struct pt child_pt;
        uint8_t c = 0, r = 0;

	PT_BEGIN(pt);
	c = 0;
	while (c == 0) {
                get_from_flash(&(sms_string_table[0]), _gsm_buff);
                PT_WAIT_THREAD(pt, PT_send_recv_confirm(&child_pt, ret, _gsm_buff, "OK", 1000));
        	c = *ret;
	}

        get_from_flash(&(sms_string_table[1]), _gsm_buff);
	PT_WAIT_THREAD(pt, PT_send_recv_confirm(&child_pt, ret, _gsm_buff, "OK", 3000));

	_gsm_wline = 1;
	c = 0;
	while (c != 1) {
                get_from_flash(&(sms_string_table[2]), _gsm_buff);
                strcat(_gsm_buff, nr);
		strcat(_gsm_buff, "\"\r\n");
		PT_WAIT_THREAD(pt, PT_send_recv_confirm(&child_pt, ret, _gsm_buff, ">", 3000));
        	c = *ret;
	}
	_gsm_wline = 0;
        GSM_send(text, len);
        
	PT_WAIT_THREAD(pt, PT_SMS_send_end(&child_pt));
	PT_END(pt);
}
开发者ID:atiti,项目名称:datalogger,代码行数:30,代码来源:DLGSM.cpp

示例5: PT_THREAD

/*---------------------------------------------------------------------------*/
static
PT_THREAD(handle_output(struct httpd_state *s))
{
  PT_BEGIN(&s->outputpt);

  petsciiconv_topetscii(s->filename, sizeof(s->filename));
  s->fd = cfs_open(s->filename, CFS_READ);
  petsciiconv_toascii(s->filename, sizeof(s->filename));
  if(s->fd < 0) {
    strcpy(s->filename, "notfound.html");
    s->fd = cfs_open(s->filename, CFS_READ);
    petsciiconv_toascii(s->filename, sizeof(s->filename));
    if(s->fd < 0) {
      PT_WAIT_THREAD(&s->outputpt,
                     send_headers(s, http_header_404));
      PT_WAIT_THREAD(&s->outputpt,
                     send_string(s, "not found"));
      uip_close();
      webserver_log_file(&uip_conn->ripaddr, "404 (no notfound.html)");
      PT_EXIT(&s->outputpt);
    }
    PT_WAIT_THREAD(&s->outputpt,
		   send_headers(s, http_header_404));
    webserver_log_file(&uip_conn->ripaddr, "404 - notfound.html");
  } else {
    PT_WAIT_THREAD(&s->outputpt,
		   send_headers(s, http_header_200));
  }
  PT_WAIT_THREAD(&s->outputpt, send_file(s));
  cfs_close(s->fd);
  s->fd = -1;
  PSOCK_CLOSE(&s->sout);
  PT_END(&s->outputpt);
}
开发者ID:arbraham,项目名称:hummingbird,代码行数:35,代码来源:httpd-cfs.c

示例6: PT_THREAD

/*---------------------------------------------------------------------------*/
static
PT_THREAD(handle_output(struct httpd_state *s))
{
  PT_BEGIN(&s->outputpt);

  s->fd = cfs_open(s->filename, CFS_READ);
  if(s->fd < 0) {
    s->fd = cfs_open("404.html", CFS_READ);
    if(s->fd < 0) {
      uip_abort();
      PT_EXIT(&s->outputpt);
    }
    PT_WAIT_THREAD(&s->outputpt,
		   send_headers(s, "HTTP/1.0 404 Not found\r\n"));
    PT_WAIT_THREAD(&s->outputpt,
		   send_file(s));
  } else {
    PT_WAIT_THREAD(&s->outputpt,
		   send_headers(s, "HTTP/1.0 200 OK\r\n"));
    PT_WAIT_THREAD(&s->outputpt,
		   send_file(s));
    cfs_close(s->fd);
  }
  PSOCK_CLOSE(&s->sout);
  PT_END(&s->outputpt);
}
开发者ID:EDAyele,项目名称:ptunes,代码行数:27,代码来源:httpd-cfs.c

示例7: PT_THREAD

/*---------------------------------------------------------------------------*/
static
PT_THREAD(handle_output(struct httpd_state *s))
{
  char *ptr;
  
  PT_BEGIN(&s->outputpt);
 
   if(!httpd_fs_open(s->filename, &s->file)) {
    httpd_fs_open(http_404_html, &s->file);
    strcpy(s->filename, http_404_html);
    PT_WAIT_THREAD(&s->outputpt,
		   send_headers(s,
		   http_header_404));
    PT_WAIT_THREAD(&s->outputpt,
		   send_file(s));
  }
   else {
     PT_WAIT_THREAD(&s->outputpt,
		   send_headers(s,
                                http_header_200));
     ptr = strchr(s->filename, ISO_period);
     if(ptr != NULL && strncmp(ptr, http_shtml, 6) == 0) {
       PT_INIT(&s->scriptpt);
       PT_WAIT_THREAD(&s->outputpt, handle_script(s));
     } else {
       PT_WAIT_THREAD(&s->outputpt,
                      send_file(s));
     }
   }
  PSOCK_CLOSE(&s->sout);
  PT_END(&s->outputpt);
}
开发者ID:topiaruss,项目名称:xmostcptests,代码行数:33,代码来源:httpd.c

示例8: PT_THREAD

static
PT_THREAD(handle_output(struct httpd_state *s))
{
  PT_BEGIN(&s->outputpt);

  s->script = NULL;
  s->script = httpd_simple_get_script(&s->filename[1]);
  if(s->script == NULL) {
    strncpy(s->filename, "/notfound.html", sizeof(s->filename));
    PT_WAIT_THREAD(&s->outputpt,
                   send_headers(s, http_header_404));
    PT_WAIT_THREAD(&s->outputpt,
                   send_string(s, NOT_FOUND));
    uip_close();
    webserver_log_file(&uip_conn->ripaddr, "404 - not found");
    PT_EXIT(&s->outputpt);
  } else {
    PT_WAIT_THREAD(&s->outputpt,
                   send_headers(s, http_header_200));
    PT_WAIT_THREAD(&s->outputpt, s->script(s));
  }
  s->script = NULL;
  PSOCK_CLOSE(&s->sout);
  PT_END(&s->outputpt);
}
开发者ID:AWRyder,项目名称:contiki,代码行数:25,代码来源:httpd-simple.c

示例9: PT_THREAD

static
PT_THREAD(handle_output(struct httpd_state *s))
{
  PT_BEGIN(&s->outputpt);
  s->script = httpd_cgi(&s->filename[1]);
  if(!s->script) {
    httpd_cgi_command_t *cmd = httpd_cgi_command(&s->filename[1]);
    if(cmd) {
      s->script = cmd->function(s);
    }
  }
  if(s->script) {
    if((s->script->flags & HTTPD_CUSTOM_HEADER) == 0) {
      PT_WAIT_THREAD(&s->outputpt, send_headers(s, http_header_200));
    }
    if((s->script->flags & HTTPD_CUSTOM_TOP) == 0) {
      PT_WAIT_THREAD(&s->outputpt, generate_top(s));
    }
    PT_WAIT_THREAD(&s->outputpt, s->script->function(s));
    if((s->script->flags & HTTPD_CUSTOM_BOTTOM) == 0) {
      PT_WAIT_THREAD(&s->outputpt, generate_bottom(s));
    }
#if CONTIKI_TARGET_NATIVE
  } else if (httpd_is_file(s->filename)){
    PT_WAIT_THREAD(&s->outputpt, send_headers(s, http_header_200));
    PT_WAIT_THREAD(&s->outputpt, send_file(s));
#endif
  } else {
    LOG6LBR_6ADDR(WARN, &uip_conn->ripaddr, "File '%s' not found, from ", s->filename);
    PT_WAIT_THREAD(&s->outputpt, send_headers(s, http_header_404));
    PT_WAIT_THREAD(&s->outputpt, generate_404(s));
  }
  PSOCK_CLOSE(&s->sout);
  PT_END(&s->outputpt);
}
开发者ID:Ayesha-N,项目名称:6lbr,代码行数:35,代码来源:httpd.c

示例10: PT_THREAD

static
PT_THREAD(handle_output(struct httpd_state *s))
{
  PT_BEGIN(&s->outputpt);

#if DEBUGLOGIC
   strcpy_P(s->filename,PSTR("/x"));
#endif
#if FIND_THE_SCRIPT
  s->script = httpd_simple_get_script(&s->filename[1]);
  if(s->script == NULL) {
    printf_P(PSTR("not found!"));
    strcpy_P(s->filename, PSTR("/notfound.html"));

    PT_WAIT_THREAD(&s->outputpt,
                   send_headers(s, http_header_404));
    PT_WAIT_THREAD(&s->outputpt,
                   send_string_P(s, NOT_FOUND));
    uip_close();

    PT_EXIT(&s->outputpt);
  } else {
#else
  s->script = generate_routes;
  if (1) {
#endif

    PT_WAIT_THREAD(&s->outputpt,
                   send_headers(s, http_header_200));
    PT_WAIT_THREAD(&s->outputpt, s->script(s));
  }
  s->script = NULL;
  PSOCK_CLOSE(&s->sout);
  PT_END(&s->outputpt);
}
/*---------------------------------------------------------------------------*/
static void
handle_connection(struct httpd_state *s)
{
#if DEBUGLOGIC
  handle_output(s);
#else
  handle_input(s);
  if(s->state == STATE_OUTPUT) {
    handle_output(s);
  }
#endif
}
开发者ID:Cancan79,项目名称:mist,代码行数:48,代码来源:httpd-simple-avr.c

示例11: PT_THREAD

/*---------------------------------------------------------------------------*/
static
PT_THREAD(handle_output(void))
{
  ctk_arch_key_t c;
  char *ptr;
  
  PT_BEGIN(&s.outpt);
  
  while(1) {
    PT_WAIT_UNTIL(&s.outpt, (ctk_mode_get() == CTK_MODE_EXTERNAL) &&
		  kbhit());


    ptr = s.outputbuf;
    s.len = 0;    
    while(kbhit() && s.len < sizeof(s.outputbuf)) {
      c = cgetc();
      *ptr = c;
      ++ptr;
      ++s.len;   
    }

    PT_WAIT_THREAD(&s.outpt, send());
  }
  PT_END(&s.outpt);      
}
开发者ID:kincki,项目名称:contiki,代码行数:27,代码来源:cgterm.c

示例12: PROCESS_THREAD

PROCESS_THREAD(test_pub_bind, ev, data) {
    // printf("> test_pub_bind %d, %d, %p\n", process_pt->lc, ev, data);
    // print_event_name(ev);
    // printf("\r\n");
    PROCESS_BEGIN();

    zmq_init();
    zmq_socket_init(&my_sock, ZMQ_PUB);
    // zmq_bind("tcp://*:9999");
    zmq_bind(&my_sock, 9999);

    while(1) {
        if(etimer_expired(&et))
            etimer_set(&et, CLOCK_SECOND);

        PROCESS_WAIT_EVENT();

        if(ev == PROCESS_EVENT_TIMER) {
            printf("Publishing 'Hi there!'\r\n");
            static zmq_msg_t *msg = NULL;
            msg = zmq_msg_from_const_data(0, "Hi there!", 9);
            PT_WAIT_THREAD(process_pt, my_sock.send(&my_sock, msg));
            zmq_msg_destroy(&msg);
        }
    }

    PROCESS_END();
}
开发者ID:Alidron,项目名称:contiki-zeromq,代码行数:28,代码来源:my-zmq-pub.c

示例13: PT_THREAD

/*---------------------------------------------------------------------------*/
static
PT_THREAD(handle_output(struct httpd_state *s))
{
  char *ptr;
  
  PT_BEGIN(&s->outputpt);
 
  if(!httpd_fs_open(s->filename, &s->file)) {
    httpd_fs_open(http_404_html, &s->file);
    strcpy(s->filename, http_404_html);
    PT_WAIT_THREAD(&s->outputpt,
		   send_headers(s,
		   http_header_404));
    PT_WAIT_THREAD(&s->outputpt,
		   send_file(s));
  } else {
    PT_WAIT_THREAD(&s->outputpt,
		   send_headers(s,
		   http_header_200));
    ptr = strchr(s->filename, ISO_period);
    if(ptr != NULL && (strncmp(ptr, http_shtml, 6) == 0 || strncmp(ptr, ".bin", 4) == 0)) {
      PT_INIT(&s->scriptpt);
      PT_WAIT_THREAD(&s->outputpt, handle_script(s));
    } else {
      PT_WAIT_THREAD(&s->outputpt,
		     send_file(s));
    }
  }
  if (s->emumode) {
	// Just switched to emulator mode! Fix the state
	s->state = STATE_WAITING;
  } else {
	PSOCK_CLOSE(&s->sout);
  }
  PT_END(&s->outputpt);
}
开发者ID:Carrotman42,项目名称:cs4534,代码行数:37,代码来源:httpd.c

示例14: PT_THREAD

static 
PT_THREAD(driver_thread(struct pt *pt))
{
	static struct pt writePt, readPt, lpPt;

	PT_BEGIN(pt);

	PT_INIT(&writePt);
	PT_INIT(&readPt);
	PT_INIT(&lpPt);

	PT_WAIT_THREAD(pt,	data_write_thread(&writePt) &
			 			data_read_thread(&readPt) &
						data_long_polling_thread(&lpPt));

	PT_END(pt);
}
开发者ID:cgm7487,项目名称:exosite_device,代码行数:17,代码来源:exosite_http.c


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