本文整理汇总了C++中print_response函数的典型用法代码示例。如果您正苦于以下问题:C++ print_response函数的具体用法?C++ print_response怎么用?C++ print_response使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了print_response函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: SavePrevresponse
void TechBot::answer()
{
SavePrevresponse();
setEvent("BOT UNDERSTAND**");
if(null_input())
{
eventManager("NULL INPUT**");
}
else if(null_input_repetition())
{
eventManager("NULL INPUT REPETITION**");
}
else if(isUserRepeat())
{
manageUserRepeat();
}
else if(isaskedusername())
{
std::cout<<"I THINK IT IS "<<user_name<<std::endl;
return;
}
else
{
selectMatch();
}
if(user_want_to_quit())
{
TB_bQuitProgram = 1;
eventManager("USER WANTS TO QUIT**");
}
else if(TB_Input.find("BYE")!=std::string::npos)
return;
else if(!isAIunderstand())
{
eventManager("BOT DON'T UNDERSTAND**");
// update_unkown_input_list();
}
if(RespLISTonse.size() > 0)
{
chooseOutput();
SaveAI_response();
initPre_response();
if(isAIRepeat())
{
manageRepeat();
}
Savelog("TechTron");
print_response();
//speak(TB_Response);
}
}
开发者ID:raj61,项目名称:chatBot,代码行数:56,代码来源:bot.cpp
示例17: main
int main(int argc, char *argv[])
{
int sockfd, ret;
char *host;
uint16_t port = DEFAULT_PORT;
struct addrinfo *p_addrlist = NULL;
struct addrinfo hint;
struct sockaddr_in sa_in;
if(argc == 1)
{
host = get_defaulthost();
}
if(argc >= 2)
{
host = argv[1];
}
if(argc >= 3)
{
port = (uint16_t)atoi(argv[2]);
}
/*
* get remote addr from input host or default host
*/
init_addrinfo(&hint, SOCK_STREAM);
if((ret = getaddrinfo(host, NULL, &hint, &p_addrlist)) != 0)
err_quit("getaddrinfo error: %s", gai_strerror(ret));
if(p_addrlist != NULL)
memcpy((void *)&sa_in, (void *)p_addrlist->ai_addr, sizeof(sa_in));
else
{
sa_in.sin_family = AF_INET;
sa_in.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
}
sa_in.sin_port = htons(port);
if((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0)
err_sys("socket error: %s", strerror(errno));
/*
* !!!
* pay attention to the alen, it is not correct by input sizeof(struct sockaddr)
* because the struct size depends on the machine archtect
*/
if(connect_retry(sockfd, (struct sockaddr *)&sa_in, INET_ADDRSTRLEN) < 0)
err_quit("connect fail: %s", strerror(errno));
print_response(sockfd);
return 0;
}
开发者ID:leonshao,项目名称:apue,代码行数:54,代码来源:client.c
示例18: main
int
main()
{
struct sockaddr_in from;
socklen_t from_size = (socklen_t)sizeof (from);
int cc;
int name_length = sizeof (hostname);
fd_set rfds;
struct timeval tv;
(void) sysinfo(SI_HOSTNAME, hostname, name_length);
for (;;) {
tv.tv_sec = MAX_LIFE;
tv.tv_usec = 0;
FD_ZERO(&rfds);
FD_SET(0, &rfds);
if (select(1, &rfds, 0, 0, &tv) <= 0)
return (0);
cc = recvfrom(0, (char *)&request, sizeof (request), 0,
(struct sockaddr *)&from, &from_size);
if (cc != sizeof (request)) {
if (cc < 0 && errno != EINTR) {
print_error("receive");
}
} else {
if (debug) {
(void) printf("Request received : \n");
(void) print_request(&request);
}
request = swapmsg(request);
process_request(&request, &response);
if (debug) {
(void) printf("Response sent : \n");
print_response(&response);
}
/*
* Can block here, is this what I want?
*/
cc = sendto(0, (char *)&response, sizeof (response), 0,
(struct sockaddr *)&request.ctl_addr,
(socklen_t)sizeof (request.ctl_addr));
if (cc != sizeof (response)) {
print_error("Send");
}
}
}
}
开发者ID:AlainODea,项目名称:illumos-gate,代码行数:54,代码来源:in.talkd.c
示例19: time
void Eliza::start() {
time_t ltime;
time(<ime);
logfile.open("log.txt", std::ios::out | std::ios::app);
if(logfile.fail()) {
throw std::string("can't save conversation log");
}
logfile << "\n\nConversation log - " << ctime(<ime) << std::endl;
response_list = signOn;
select_response();
print_response();
save_log("ELIZA");
}
开发者ID:ASAP-Project,项目名称:ASAP,代码行数:13,代码来源:Eliza_1.cpp
示例20: got_body
static void
got_body (SoupMessage *msg, gpointer user_data)
{
SoupLogger *logger = user_data;
SoupLoggerPrivate *priv = SOUP_LOGGER_GET_PRIVATE (logger);
g_mutex_lock (&priv->lock);
print_response (logger, msg);
soup_logger_print (logger, SOUP_LOGGER_LOG_MINIMAL, ' ', "");
g_mutex_unlock (&priv->lock);
}
开发者ID:Kharif,项目名称:libsoup,代码行数:13,代码来源:soup-logger.c
注:本文中的print_response函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论