本文整理汇总了C++中PSOCK_GENERATOR_SEND函数的典型用法代码示例。如果您正苦于以下问题:C++ PSOCK_GENERATOR_SEND函数的具体用法?C++ PSOCK_GENERATOR_SEND怎么用?C++ PSOCK_GENERATOR_SEND使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PSOCK_GENERATOR_SEND函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PT_THREAD
static PT_THREAD(send_file(struct httpd_state *s)) {
PSOCK_BEGIN(&s->sout);
do {
PSOCK_GENERATOR_SEND(&s->sout, generate_part_of_file, s);
s->file.len -= s->len;
s->file.data += s->len;
} while(s->file.len > 0);
PSOCK_END(&s->sout);
}
示例2: PT_THREAD
static PT_THREAD(sensors_list(struct httpd_state *s, char *))
{
PSOCK_BEGIN(&s->sout);
for(s->count = 0; sensors[s->count].is_valid_P(); ++s->count) {
PSOCK_GENERATOR_SEND(&s->sout, generate_sensors_list, s);
}
PSOCK_END(&s->sout);
}
示例3: PT_THREAD
/*---------------------------------------------------------------------------*/
static
PT_THREAD(file_stats(struct httpd_state *s, char *ptr))
{
PSOCK_BEGIN(&s->sout);
//while (pgm_read_byte(ptr++)!=' ') {}; //skip to "/filename" after the script invokation
PSOCK_GENERATOR_SEND(&s->sout, generate_file_stats, (void *) (strchr_P(ptr, ' ') + 1));
PSOCK_END(&s->sout);
}
示例4: PT_THREAD
/*---------------------------------------------------------------------------*/
static PT_THREAD( tcp_stats ( struct httpd_state *s, char *ptr ) )
{
PSOCK_BEGIN( &s->sout );
for( s->count = 0; s->count < UIP_CONNS; ++s->count ) {
if( (uip_conns[s->count].tcpstateflags & UIP_TS_MASK) != UIP_CLOSED ) {
PSOCK_GENERATOR_SEND( &s->sout, generate_tcp_stats, s );
}
}
PSOCK_END( &s->sout );
}
示例5: PT_THREAD
/*---------------------------------------------------------------------------*/
static
PT_THREAD(file_stats(struct httpd_state *s, char *ptr))
{
PSOCK_BEGIN(&s->sout);
/* Pass string after cgi invocation to the generator */
s->u.ptr = ptr;
PSOCK_GENERATOR_SEND(&s->sout, generate_file_stats, s);
PSOCK_END(&s->sout);
}
示例6: PT_THREAD
/*---------------------------------------------------------------------------*/
static
PT_THREAD(file_stats(struct httpd_state *s, char *ptr))
{
PSOCK_BEGIN(&s->sout);
thisfilename=&s->filename[0]; //temporary way to pass filename to generate_file_stats
PSOCK_GENERATOR_SEND(&s->sout, generate_file_stats, (void *) ptr);
PSOCK_END(&s->sout);
}
示例7: PT_THREAD
/*---------------------------------------------------------------------------*/
static
PT_THREAD(addrmap(struct httpd_state *s, char *ptr))
{
PSOCK_BEGIN(&s->sout);
for(s->u.ptr = ip64_addrmap_list();
s->u.ptr != NULL;
s->u.ptr = list_item_next(s->u.ptr)) {
PSOCK_GENERATOR_SEND(&s->sout, make_addrmap, s);
}
PSOCK_END(&s->sout);
}
示例8: handle_connection
static int handle_connection(struct webserver_state *s)
{
PSOCK_BEGIN(&s->p);
// the incoming GET request will have the following format:
// GET / HTTP/1.1 ....
// we have to parse this string to determine the resource being requested
// if the requested resource is not the root webpage ('/') then,
// GET /<resource name> HTTP/1.1 ....
// we should parse the specific resource and react appropriately
// read incoming data until we read a space character
PSOCK_READTO(&s->p, ISO_space);
// parse the data to determine if it was a GET request
if(strncmp(s->inputbuf, http_get, 4) != 0) {
PSOCK_CLOSE_EXIT(&s->p);
}
// continue reading until the next space character
PSOCK_READTO(&s->p, ISO_space);
// determine the requested resource
// in this case, we check if the request was for the '/' root page
// AKA index.html
if(s->inputbuf[0] != ISO_slash) {
// request for unknown webpage, close and exit
PSOCK_CLOSE_EXIT(&s->p);
}
if(s->inputbuf[1] != ISO_space) {
// request for unavailable resource
// not supported, modify to add support for additional resources
PSOCK_CLOSE_EXIT(&s->p);
}
lockstate = lockstate+1;
PSOCK_SEND_STR(&s->p, "HTTP/1.1 200 OK\r\n");
PSOCK_SEND_STR(&s->p, "Content-Type: text/html\r\n");
PSOCK_SEND_STR(&s->p, "\r\n");
PSOCK_SEND_STR(&s->p, "Hello World, I am WiShield");
PSOCK_SEND_STR(&s->p, "<center><h1>Hello World!! I am Matt's WiShield. Find me in webserver.c under PSOCK_SEND_STR.</h1></center>");
PSOCK_GENERATOR_SEND(&s->p, fill_buf, 0);
PSOCK_CLOSE(&s->p);
PSOCK_END(&s->p);
}
示例9: PT_THREAD
/*---------------------------------------------------------------------------*/
static
PT_THREAD(neighborscall(struct httpd_state *s, char *ptr))
{
PSOCK_BEGIN(&s->sout);
announcement_listen(1);
/* printf("neighbor_num %d\n", collect_neighbor_list_num(&neighbor_list)); */
for(s->u.count = 0; s->u.count < collect_neighbor_list_num(&neighbor_list); s->u.count++) {
/* printf("count %d\n", s->u.count); */
if(collect_neighbor_list_get(&neighbor_list, s->u.count) != NULL) {
/* printf("!= NULL\n"); */
PSOCK_GENERATOR_SEND(&s->sout, make_neighbor, s);
}
}
PSOCK_END(&s->sout);
}
示例10: handle_connection
static uint16_t handle_connection(struct simple_httpd_state *s)
{
PSOCK_BEGIN(&s->p);
int comp;
// the incoming GET request will have the following format:
// GET / HTTP/1.1 ....
// we have to parse this string to determine the resource being requested
// if the requested resource is not the root webpage ('/') then,
// GET /<resource name> HTTP/1.1 ....
// we should parse the specific resource and react appropriately
// read incoming data until we read a space character
PSOCK_READTO(&s->p, ISO_space);
// parse the data to determine if it was a GET request
if((comp = strncmp_P((const char *)(s->inputbuf), (const char *)http_get, 4)) != 0)
{
PSOCK_CLOSE_EXIT(&s->p);
}
// continue reading until the next space character
PSOCK_READTO(&s->p, ISO_space);
// determine the requested resource
// in this case, we check if the request was for the '/' root page
// AKA index.html
if(s->inputbuf[0] != ISO_slash){
PSOCK_CLOSE_EXIT(&s->p); // request for unknown webpage, close and exit
}
// not supported, modify to add support for additional resources
if(s->inputbuf[1] != ISO_space){
PSOCK_CLOSE_EXIT(&s->p); // request for unavailable resource, close and exit
}
PSOCK_GENERATOR_SEND(&s->p, fill_buf, 0); // generate the web page response with fill_buf from PSTR variable
PSOCK_CLOSE(&s->p);
PSOCK_END(&s->p);
}
示例11: PT_THREAD
/***** VOLTAGE *****/
static
PT_THREAD(volt_stats(struct httpd_state *s, char *ptr))
{
char *f = strchr(ptr, ' ') + 1; // pointer to "second" argument from xml file
/* Character matching of "2nd argument" from XML file */
#define REQ_ARGUMENT_LENGTH 4 // 4 is size of sample referencing specified in XML files!
char sampleIndexStr[REQ_ARGUMENT_LENGTH + 1] = ""; //Remember +1 for NULL byte!
strncat(sampleIndexStr, f+0, REQ_ARGUMENT_LENGTH);
s->requestedNoOfSamples = atoi(sampleIndexStr); // This is relative so that "now" is zero and needs to be translated to circular buffer index.
s->circularBufferLastWriteAtCallTime = voltageShortHistLastWriteIndex; //Save it in a httpd_state as this function will be interrupted and local variables can change
PSOCK_BEGIN(&s->sout);
/** generate functions gets called ONCE PER value at the moment **/
for(s->count = 0; s->count < s->requestedNoOfSamples; ){// ++s->count) { //expression3 is omitted and done put generate function!!!!
PSOCK_GENERATOR_SEND(&s->sout, generate_volt_stats, s);
}//for
PSOCK_END(&s->sout);
}
示例12: PT_THREAD
/*---------------------------------------------------------------------------*/
static
PT_THREAD(send_file(struct httpd_state *s))
{
PSOCK_BEGIN(&s->sout);
do {
PSOCK_GENERATOR_SEND(&s->sout, generate_part_of_file, s);
s->file.len -= s->len;
s->file.data += s->len;
} while(s->file.len > 0);
#ifdef PAKAI_FILE_SIMPAN
if ( s->file.flag == 27 )
{
//printf(" Close file\r\n");
f_close( s->file.fd );
}
#endif
PSOCK_END(&s->sout);
}
示例13: PT_THREAD
static PT_THREAD(led_io(struct httpd_state *s, char *ptr))
{
PSOCK_BEGIN(&s->sout);
PSOCK_GENERATOR_SEND(&s->sout, generate_io_state, NULL);
PSOCK_END(&s->sout);
}
示例14: PT_THREAD
/*---------------------------------------------------------------------------*/
static
PT_THREAD(send_headers(struct httpd_state *s, const char *statushdr))
{
char *ptr;
PSOCK_BEGIN(&s->sout);
PSOCK_GENERATOR_SEND(&s->sout, generate_status, (char *) statushdr);
ptr = strrchr(s->filename, ISO_period);
if (httpd_strncmp("4", statushdr, 1) == 0) { //404
PSOCK_GENERATOR_SEND(&s->sout, generate_header, &httpd_mime_htm);
} else if (ptr == NULL) {
#if WEBSERVER_CONF_BIN
PSOCK_GENERATOR_SEND(&s->sout, generate_header, &httpd_mime_bin);
#else
PSOCK_GENERATOR_SEND(&s->sout, generate_header, &httpd_mime_htm);
#endif
} else {
ptr++;
#if WEBSERVER_CONF_INCLUDE || WEBSERVER_CONF_CGI
if (httpd_strncmp(ptr, &httpd_mime_htm[5], 3) == 0 || httpd_strncmp(ptr, &httpd_str_shtml[1], 4) == 0) {
#else
if (httpd_strncmp(ptr, &httpd_mime_htm[5], 3) == 0) {
#endif
PSOCK_GENERATOR_SEND(&s->sout, generate_header, &httpd_mime_htm);
#if WEBSEVER_CONF_CSS
} else if (httpd_strcmp(ptr, &httpd_mime_css[5]) == 0) {
PSOCK_GENERATOR_SEND(&s->sout, generate_header, &httpd_mime_css);
#endif
#if WEBSERVER_CONF_PNG
} else if (httpd_strcmp(ptr, &httpd_mime_png[6]) == 0) {
PSOCK_GENERATOR_SEND(&s->sout, generate_header, &httpd_mime_png);
#endif
#if WEBSERVER_CONF_GIF
} else if (httpd_strcmp(ptr, &httpd_mime_gif[6]) == 0) {
PSOCK_GENERATOR_SEND(&s->sout, generate_header, &httpd_mime_gif);
#endif
#if WEBSERVER_CONF_JPG
} else if (httpd_strcmp(ptr, httpd_mime_jpg) == 0) {
PSOCK_GENERATOR_SEND(&s->sout, generate_header, &httpd_mime_jpg);
#endif
#if WEBSERVER_CONF_TXT
} else {
PSOCK_GENERATOR_SEND(&s->sout, generate_header, &httpd_mime_txt);
#endif
}
}
PSOCK_END(&s->sout);
}
/*---------------------------------------------------------------------------*/
static
PT_THREAD(handle_output(struct httpd_state *s))
{
char *ptr;
PT_BEGIN(&s->outputpt);
#if DEBUGLOGIC
httpd_strcpy(s->filename, httpd_str_indexfn);
#endif
s->fd = httpd_fs_open(s->filename, HTTPD_FS_READ);
if (s->fd == -1) { // Opening file failed.
/* TODO: try index.htm ? */
#if WEBSERVER_CONF_INCLUDE || WEBSERVER_CONF_CGI
/* If index.html not found try index.htm */
if (httpd_strcmp(s->filename, httpd_str_indexfn) == 0) {
httpd_strcpy(s->filename, httpd_str_indexfn3);
}
s->fd = httpd_fs_open(s->filename, HTTPD_FS_READ);
if (s->fd != -1) {
goto sendfile;
}
/* If index.html not found try index.shtml */
if (httpd_strcmp(s->filename, httpd_str_indexfn) == 0) {
httpd_strcpy(s->filename, httpd_str_indexsfn);
}
s->fd = httpd_fs_open(s->filename, HTTPD_FS_READ);
if (s->fd == -1) {
PRINTD("Opening %s failed\n", s->filename);
goto psock_close;
} else {
goto sendfile;
}
#endif
/* If nothing was found, send 404 page */
httpd_strcpy(s->filename, httpd_str_404fn);
s->fd = httpd_fs_open(s->filename, HTTPD_FS_READ);
PT_WAIT_THREAD(&s->outputpt, send_headers(s, httpd_str_404notf));
PT_WAIT_THREAD(&s->outputpt, send_file(s));
} else { // Opening file succeeded.
sendfile:
PT_WAIT_THREAD(&s->outputpt, send_headers(s, httpd_str_200ok));
#if WEBSERVER_CONF_INCLUDE || WEBSERVER_CONF_CGI
/* If filename ends with .shtml, scan file for script includes or cgi */
ptr = strchr(s->filename, ISO_period);
//.........这里部分代码省略.........
示例15: PT_THREAD
static
PT_THREAD(generate_routes(struct httpd_state *s))
{
uint8_t i=0;
PSOCK_BEGIN(&s->sout);
PSOCK_GENERATOR_SEND(&s->sout, generate_string_P, (char *) TOP1);
PSOCK_GENERATOR_SEND(&s->sout, generate_string_P, (char *) TOP2);
#if UIP_CONF_IPV6 //allow ip4 builds
blen = 0;
ADD("<h2>Neighbors [%u max]</h2>",UIP_DS6_NBR_NB);
PSOCK_GENERATOR_SEND(&s->sout, generate_string, buf);
blen = 0;
for(i = 0; i < UIP_DS6_NBR_NB; i++) {
if(uip_ds6_nbr_cache[i].isused) {
ipaddr_add(&uip_ds6_nbr_cache[i].ipaddr);
ADD("<br>");
// if(blen > sizeof(buf) - 45) {
PSOCK_GENERATOR_SEND(&s->sout, generate_string, buf);
blen = 0;
// }
}
}
ADD("<h2>Routes [%u max]</h2>",UIP_DS6_ROUTE_NB);
PSOCK_GENERATOR_SEND(&s->sout, generate_string, buf);
blen = 0;
for(i = 0; i < UIP_DS6_ROUTE_NB; i++) {
if(uip_ds6_routing_table[i].isused) {
ipaddr_add(&uip_ds6_routing_table[i].ipaddr);
ADD("/%u (via ", uip_ds6_routing_table[i].length);
PSOCK_GENERATOR_SEND(&s->sout, generate_string, buf);
blen=0;
ipaddr_add(&uip_ds6_routing_table[i].nexthop);
if(uip_ds6_routing_table[i].state.lifetime < 600) {
PSOCK_GENERATOR_SEND(&s->sout, generate_string, buf);
blen=0;
ADD(") %lus<br>", uip_ds6_routing_table[i].state.lifetime);
} else {
ADD(")<br>");
}
PSOCK_GENERATOR_SEND(&s->sout, generate_string, buf);
blen = 0;
}
}
if(blen > 0) {
PSOCK_GENERATOR_SEND(&s->sout, generate_string, buf);
blen = 0;
}
#else /* UIP_CONF_IPV6 */
blen = 0;i++;
ADD("<h2>Hey, you got ip4 working!</h2>");
PSOCK_GENERATOR_SEND(&s->sout, generate_string, buf);
#endif /* UIP_CONF_IPV6 */
PSOCK_GENERATOR_SEND(&s->sout, generate_string_P, (char *) BOTTOM);
PSOCK_END(&s->sout);
}