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


C++ print_response函数代码示例

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


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

示例1: periodic_tasks_exec_100tks

 /**************************************************************
 *  Name                 : periodic_tasks_exec_100tks
 *	ID					 : TASK_100TKS
 *  Description          : Container for functionality that is 
                           executed periodically.
 *  Parameters           : none
 *  Return               : none
 *  Critical/explanation : no
 **************************************************************/
 void periodic_tasks_exec_100tks(void)
 { 
      str_ctrl();
	  print_str();
	  print_response();
      actionSelector();    
 }
开发者ID:Wolfprint,项目名称:CONTINENTAL,代码行数:16,代码来源:periodic_tasks_exec.c

示例2: dispatch_request

void dispatch_request(char* from, char* to, int accept_socket, int* keep_alive){
  char* req_str = (char*) malloc(sizeof(char) * (to - from + 1));
  char* char_i;
  int int_i;
  int _ = 0;
  for(char_i = from, int_i = 0; char_i < to; char_i++, int_i++){
    *(req_str + int_i) = *(char_i);
  }
  *(req_str + int_i) = '\0';
  struct request* req = malloc_request();
  parse_request(req, req_str);
  struct response* resp = malloc_response(req);
  //free(req_str);
  write_request(resp, accept_socket);
  if(resp->html == 0){
    read_file(req->resource_name, accept_socket);
  } else{
    _ = write(accept_socket, resp->html, strlen(resp->html));
    
  }
  if(_ == -1){
    printf("scream write %d\n", _);
  }
  *keep_alive = req->keep_alive;
  free(req_str);
  free_request(req);
  print_response(resp);
  free_response(resp); 
}
开发者ID:picrin,项目名称:webserver,代码行数:29,代码来源:simple_server.c

示例3: clientrequest

/*******************************************************************************
 * this function is called by the client
 * it takes care that the request is processed by the buffer
 *******************************************************************************/
int clientrequest(int server, const message_t *request, message_t **response_ptr) {
    int verbose = 0;

	if (verbose>0) fprintf(stderr, "clientrequest: server = %d\n", server);
	if (verbose>0) print_request(request->def);

	if (server<0) {
		fprintf(stderr, "clientrequest: invalid value for server (%d)\n", server);
		return -1;
	}

	else if (server==0) {
		/* use direct memory acces to the buffer */
		if (dmarequest(request, response_ptr)!=0)
			return -2;
	}

	else if (server>0) {
		/* use TCP connection to the buffer */
		if (tcprequest(server, request, response_ptr)!=0)
			return -3;
	}

	if (verbose>0) print_response((*response_ptr)->def);

	/* everything went fine */
	return 0;
}
开发者ID:Ascronia,项目名称:fieldtrip,代码行数:32,代码来源:clientrequest.c

示例4: cmd_touch

int cmd_touch(int argc, char** argv, yrmcds* s) {
    if( argc != 2 ) {
        fprintf(stderr, "Wrong number of arguments.\n");
        return 1;
    }
    const char* key = argv[0];
    uint32_t expire = (uint32_t)strtoull(argv[1], NULL, 0);

    yrmcds_response r[1];
    uint32_t serial;
    yrmcds_error e = yrmcds_touch(s, key, strlen(key), expire, quiet, &serial);
    CHECK_ERROR(e);
    if( quiet ) {
        e = yrmcds_noop(s, &serial);
        CHECK_ERROR(e);
    }
    if( debug )
        fprintf(stderr, "request serial = %u\n", serial);
    while( 1 ) {
        e = yrmcds_recv(s, r);
        CHECK_ERROR(e);
        if( debug )
            print_response(r);
        CHECK_RESPONSE(r);
        if( r->serial == serial )
            break;
    }
    return 0;
}
开发者ID:Birdflying1005,项目名称:h2o,代码行数:29,代码来源:yc.c

示例5: cmd_keys

int cmd_keys(int argc, char** argv, yrmcds* s) {
    const char* prefix = NULL;
    size_t prefix_len = 0;
    if( argc == 1 ) {
        prefix = argv[0];
        prefix_len = strlen(prefix);
    }
    yrmcds_response r[1];
    uint32_t serial;
    yrmcds_error e = yrmcds_keys(s, prefix, prefix_len, &serial);
    CHECK_ERROR(e);
    if( debug )
        fprintf(stderr, "request serial = %u\n", serial);
    while( 1 ) {
        e = yrmcds_recv(s, r);
        CHECK_ERROR(e);
        if( debug )
            print_response(r);
        CHECK_RESPONSE(r);
        if( r->serial != serial )
            continue;
        if( r->key_len == 0 )
            break;
        printf("%.*s\n", (int)r->key_len, r->key);
    }
    return 0;
}
开发者ID:Birdflying1005,项目名称:h2o,代码行数:27,代码来源:yc.c

示例6: main

int
main(int argc, char **argv)
{
	mdata_proto_t *mdp;
	mdata_response_t mdr;
	string_t *data;
	const char *errmsg = NULL;

	if (argc < 2) {
		errx(MDEC_USAGE_ERROR, "Usage: %s <keyname>", argv[0]);
	}

	if (proto_init(&mdp, &errmsg) != 0) {
		fprintf(stderr, "ERROR: could not initialise protocol: %s\n",
		    errmsg);
		return (MDEC_ERROR);
	}

	if (proto_version(mdp) < 2) {
		fprintf(stderr, "ERROR: host does not support DELETE\n");
		return (MDEC_ERROR);
	}

	keyname = strdup(argv[1]);

	if (proto_execute(mdp, "DELETE", keyname, &mdr, &data) != 0) {
		fprintf(stderr, "ERROR: could not execute GET\n");
		return (MDEC_ERROR);
	}

	return (print_response(mdr, data));
}
开发者ID:jsonn,项目名称:mdata-client,代码行数:32,代码来源:mdata_delete.c

示例7: cmd_stat

int cmd_stat(int argc, char** argv, yrmcds* s) {
    yrmcds_response r[1];
    uint32_t serial;
    yrmcds_error e;
    if( argc > 0 ) {
        if( strcmp(argv[0], "settings") == 0 ) {
            e = yrmcds_stat_settings(s, &serial);
        } else if( strcmp(argv[0], "items") == 0 ) {
            e = yrmcds_stat_items(s, &serial);
        } else if( strcmp(argv[0], "sizes") == 0 ) {
            e = yrmcds_stat_sizes(s, &serial);
        } else {
            fprintf(stderr, "No such statistics.\n");
            return 1;
        }
    } else {
        e = yrmcds_stat_general(s, &serial);
    }
    CHECK_ERROR(e);
    while( 1 ) {
        e = yrmcds_recv(s, r);
        CHECK_ERROR(e);
        if( debug )
            print_response(r);
        CHECK_RESPONSE(r);
        if( r->key_len == 0 )
            break;
        if( r->data_len == 0 )
            continue;
        printf("%.*s: %.*s\n", (int)r->key_len, r->key,
               (int)r->data_len, r->data);
    }
    return 0;
}
开发者ID:Birdflying1005,项目名称:h2o,代码行数:34,代码来源:yc.c

示例8: cmd_flush

int cmd_flush(int argc, char** argv, yrmcds* s) {
    uint32_t delay = 0;
    if( argc == 1 )
        delay = (uint32_t)strtoull(argv[0], NULL, 0);

    yrmcds_response r[1];
    uint32_t serial;
    yrmcds_error e = yrmcds_flush(s, delay, quiet, &serial);
    CHECK_ERROR(e);
    if( quiet ) {
        e = yrmcds_noop(s, &serial);
        CHECK_ERROR(e);
    }
    if( debug )
        fprintf(stderr, "request serial = %u\n", serial);
    while( 1 ) {
        e = yrmcds_recv(s, r);
        CHECK_ERROR(e);
        if( debug )
            print_response(r);
        CHECK_RESPONSE(r);
        if( r->serial == serial )
            break;
    }
    return 0;
}
开发者ID:Birdflying1005,项目名称:h2o,代码行数:26,代码来源:yc.c

示例9: cmd_unlock

int cmd_unlock(int argc, char** argv, yrmcds* s) {
    if( argc != 1 ) {
        fprintf(stderr, "Wrong number of arguments.\n");
        return 1;
    }
    yrmcds_response r[1];
    uint32_t serial;
    yrmcds_error e = yrmcds_unlock(s, argv[0], strlen(argv[0]), quiet, &serial);
    CHECK_ERROR(e);
    if( quiet ) {
        e = yrmcds_noop(s, &serial);
        CHECK_ERROR(e);
    }
    if( debug )
        fprintf(stderr, "request serial = %u\n", serial);
    while( 1 ) {
        e = yrmcds_recv(s, r);
        CHECK_ERROR(e);
        if( debug )
            print_response(r);
        CHECK_RESPONSE(r);
        if( r->serial == serial )
            break;
    }
    return 0;
}
开发者ID:Birdflying1005,项目名称:h2o,代码行数:26,代码来源:yc.c

示例10: main

int main(int argc, char const *argv[])
{	
	char *ip, *port;
	get_input(argc, argv, &ip, &port);
	printf("IP = %s\n", ip);
	printf("Port = %s\n", port);

	int sock;
	sock = create_socket(SOCK_DGRAM, ip);
	

/* PROTOTIPO de como ENVIA mensagens */
	char msg[BUF_SIZE];
	strcat(msg, "GET /index.html HTTP/1.1\r\nHost: ");
	strcat(msg, ip);
	strcat(msg, "\r\n\r\n");
	print_request(msg);

	send_all(sock, msg);

/* PROTOTIPO de como RECEBE mensagens */
	// int recv(int sockfd, void *buf, int len, int flags);
	char *buff;
	size_t by_recv;
	by_recv = recv_all(sock, &buff, BUF_SIZE);

	print_response(buff);
	return 0;
}
开发者ID:LuizPelegrini,项目名称:SocketProgramming,代码行数:29,代码来源:udp-client.c

示例11: main

int main(int argc, char *argv[]) {
	int server, offset;
	int n;
	messagedef_t request, response;
	event_t event;
	eventsel_t eventsel;
	void *buf = NULL;

	if (argc != 3) {
		fprintf(stderr, "USAGE: application <server_ip> <port>\n");
		exit(1);
	}

	/* open the TCP socket */
	if ((server = open_connection(argv[1], atoi(argv[2]))) < 0) {
		fprintf(stderr, "ERROR; failed to create socket\n");
		exit(1);
	}

	request.version = VERSION;
	request.command = GET_EVT;
	request.bufsize = 0; // sizeof(eventsel_t);

	// eventsel.begevent = 0;
	// eventsel.endevent = 2;

	fprintf(stderr, "------------------------------\n");
	print_request(&request);
	write(server, &request, sizeof(messagedef_t));
	// write(server, &eventsel, sizeof(eventsel_t));

	read(server, &response, sizeof(messagedef_t));
	fprintf(stderr, "------------------------------\n");
	print_response(&response);
	fprintf(stderr, "------------------------------\n");

	if (response.command==GET_OK) {
		buf = malloc(response.bufsize);
		if ((n = bufread(server, buf, response.bufsize)) < response.bufsize) {
			fprintf(stderr, "problem reading enough bytes (%d)\n", n);
		}
		else {
			n = 0;
			offset = 0;
			while (offset<response.bufsize) {
				event.def = buf+offset;
				event.buf = buf+offset+sizeof(eventdef_t);
				fprintf(stderr, "\n");
				print_eventdef(event.def);
				offset += sizeof(eventdef_t) + event.def->bufsize;
				n++;
			}
		}
		FREE(buf);
	}

	close(server);
	exit(0);
}
开发者ID:9877,项目名称:eeglab,代码行数:59,代码来源:test_getevt.c

示例12: buffer_gethdr

int buffer_gethdr(int server, mxArray *plhs[], const mxArray *prhs[])
{
	int verbose = 0;
	int result  = 0;

	message_t *request  = NULL;
	message_t *response = NULL;

	/* this is for the Matlab specific output */
	const char *field_names[NUMBER_OF_FIELDS] = {"nchans", "nsamples", "nevents", "fsample", "data_type", "bufsize"};

	/* allocate the elements that will be used in the communication */
	request      = malloc(sizeof(message_t));
	request->def = malloc(sizeof(messagedef_t));
	request->buf = NULL;
	request->def->version = VERSION;
	request->def->command = GET_HDR;
	request->def->bufsize = 0;
	
	if (verbose) print_request(request->def);
	result = clientrequest(server, request, &response);
	
	if (result == 0) {
		if (verbose) print_response(response->def);

		if (response->def->command==GET_OK) {
			headerdef_t *headerdef = (headerdef_t *) response->buf;
			
			if (verbose) print_headerdef(headerdef);

			plhs[0] = mxCreateStructMatrix(1, 1, NUMBER_OF_FIELDS, field_names);
			mxSetFieldByNumber(plhs[0], 0, 0, mxCreateDoubleScalar((double)(headerdef->nchans)));
			mxSetFieldByNumber(plhs[0], 0, 1, mxCreateDoubleScalar((double)(headerdef->nsamples)));
			mxSetFieldByNumber(plhs[0], 0, 2, mxCreateDoubleScalar((double)(headerdef->nevents)));
			mxSetFieldByNumber(plhs[0], 0, 3, mxCreateDoubleScalar((double)(headerdef->fsample)));
			mxSetFieldByNumber(plhs[0], 0, 4, mxCreateDoubleScalar((double)(headerdef->data_type)));
			mxSetFieldByNumber(plhs[0], 0, 5, mxCreateDoubleScalar((double)(headerdef->bufsize)));
			
			addChunksToMatrix(plhs[0], (const char *) response->buf + sizeof(headerdef_t), headerdef->bufsize, headerdef->nchans);
		}
		else {
			result = response->def->command;
		}
	}

	if (response) {
		FREE(response->def);
		FREE(response->buf);
		FREE(response);
	}

	if (request) {
		FREE(request->def);
		FREE(request->buf);
		FREE(request);
	}

	return result;
}
开发者ID:kabm1979,项目名称:open-realtime-fmri,代码行数:59,代码来源:buffer_gethdr.c

示例13: wifi_test_tcp

void wifi_test_tcp() {
  printf("[WIFI] Test...\n");

  softserial_printf("AT+CIPSTART=\"TCP\",\"%s\",%d\r\n", "173.254.30.60", 80);
  _delay_ms(1000);
  print_response();

  const char *http = "GET /Test.txt HTTP/1.0\r\n\r\nHost: thearduinoguy.org\r\n\r\n";

  softserial_printf("AT+CIPSEND=%d\r\n", strlen(http));
  print_response();

  while(serial_available()) fgetc(serial_input);
  softserial_printf(http);

  _delay_ms(1000);

  char line_buf[128];
  int content_length = -1;

  while(serial_available()) {
    softserial_readline(line_buf, ARRAYSIZE(line_buf));

    if(memcmp(line_buf, "Content-Length: ", 16) == 0) {
      content_length = atoi(&line_buf[16]);
    } else if(content_length >= 0 && line_buf[0] == '\r') {
      break;
    }
  }

  // TODO: Protect against overflow
  char content[128];
  for(int i = 0; i < content_length; ++i) {
    content[i] = softserial_getc();
  }
  content[content_length] = '\0';

  printf("CONTENT: %s\n", content);

  while(serial_available()) fgetc(serial_input);

  // Will error if remote closed connection already, that's fine
  softserial_printf("AT+CIPCLOSE\r\n");
  _delay_ms(100);
  print_response();
}
开发者ID:anibali,项目名称:rat_trace_avr,代码行数:46,代码来源:wifi.c

示例14: eventManager

void TechBot::welcome()
{
    eventManager("welcome**");
    chooseOutput();
    Savelog();
    Savelog("TechTron");
    //speak(TB_Response);
    print_response();
}
开发者ID:raj61,项目名称:chatBot,代码行数:9,代码来源:bot.cpp

示例15: print_packet

void print_packet(corefs_packet pkt){
   dprintf(stderr, "--------------------------------------------------------\n");
  dprintf(stderr,"<header>\n");
  dprintf(stderr, "\t| magic[0x%x] | type[0x%x] | sequence[0x%x] | payload_size[0d%u] |\n",pkt.header.magic, pkt.header.type, pkt.header.sequence, pkt.header.payload_size);
  dprintf(stderr,"<\\header>\n");
  dprintf(stderr, "--------------------------------------------------------\n");
  if(pkt.header.type == COREFS_REQUEST) print_request(pkt);
  if(pkt.header.type == COREFS_RESPONSE) print_response(pkt);
}
开发者ID:Greeshma,项目名称:DFS,代码行数:9,代码来源:common.c


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