• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ parse_response函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: newsnntp_post

int newsnntp_post(newsnntp * f, const char * message, size_t size)
{
  char command[NNTP_STRING_SIZE];
  int r;
  char * response;

  snprintf(command, NNTP_STRING_SIZE, "POST\r\n");
  r = send_command(f, command);
  if (r == -1)
    return NEWSNNTP_ERROR_STREAM;

  response = read_line(f);
  if (response == NULL)
    return NEWSNNTP_ERROR_STREAM;

  r = parse_response(f, response);

  switch (r) {
  case 480:
    return NEWSNNTP_ERROR_REQUEST_AUTHORIZATION_USERNAME;
    
  case 381:
    return NEWSNNTP_WARNING_REQUEST_AUTHORIZATION_PASSWORD;

  case 340:
    break;
      
  case 440:
    return NEWSNNTP_ERROR_POSTING_NOT_ALLOWED;
    
  default:
    return NEWSNNTP_ERROR_UNEXPECTED_RESPONSE;
  }

  send_data(f, message, size); 

  response = read_line(f);
  if (response == NULL)
    return NEWSNNTP_ERROR_STREAM;

  r = parse_response(f, response);

  switch (r) {
  case 480:
    return NEWSNNTP_ERROR_REQUEST_AUTHORIZATION_USERNAME;
      
  case 381:
    return NEWSNNTP_WARNING_REQUEST_AUTHORIZATION_PASSWORD;
      
  case 240:
    return NEWSNNTP_NO_ERROR;
    return 1;

  case 441:
    return NEWSNNTP_ERROR_POSTING_FAILED;

  default:
    return NEWSNNTP_ERROR_UNEXPECTED_RESPONSE;
  }
}
开发者ID:AnckieLV,项目名称:libetpan,代码行数:60,代码来源:newsnntp.c


示例2: signup_signin

void signup_signin() {
    int i, authen = 0;
    char action[10], input[50], request[256];
    char **response;
    printf("signup/signin? ");
    scanf(" %s", action);

    while(!authen) {
        sprintf(request, "%s,", action);
        if (strcmp(action, "signup") == 0) {
            printf("[username] [nickname] [password]: ");
            for (i = 0; i < L_SIGNUP_REQ; i++) {
                scanf(" %s", input);
                strcat(request, input);
                strcat(request, ",");
            }
            getchar();

            if(send(sock, request, strlen(request) , 0) < 0)
                ERR_EXIT("Send failed");

            response = parse_response(L_SIGN_RES);
            if (strcmp(response[0], "success") == 0) {
                strcpy(user->username, response[1]);
                strcpy(user->nickname, response[2]);
                authen = 1;
            }
            else
                printf("%s\n", response[0]);
        } else if (strcmp(action, "signin") == 0) {
            printf("[username] [password]: ");
            for (i = 0; i < L_SIGNIN_REQ; i++) {
                scanf(" %s", input);
                strcat(request, input);
                strcat(request, ",");
            }
            getchar();

            if(send(sock, request, strlen(request) , 0) < 0)
                ERR_EXIT("Send failed");

            response = parse_response(L_SIGN_RES);
            if (strcmp(response[0], "success") == 0) {
                strcpy(user->username, response[1]);
                strcpy(user->nickname, response[2]);
                authen = 1;
            }
            else
                printf("%s\n", response[0]);
        }
    }
    free(response);
}
开发者ID:urchinfinity,项目名称:chatroom,代码行数:53,代码来源:client.c


示例3: phr_parse_response

int phr_parse_response(const char* buf_start, size_t len, int* minor_version,
		       int* status, const char** msg, size_t* msg_len,
		       struct phr_header* headers, size_t* num_headers,
		       size_t last_len)
{
  const char * buf = buf_start, * buf_end = buf + len;
  size_t max_headers = *num_headers;
  int r;
  
  *minor_version = -1;
  *status = 0;
  *msg = NULL;
  *msg_len = 0;
  *num_headers = 0;
  
  /* if last_len != 0, check if the response is complete (a fast countermeasure
     against slowloris */
  if (last_len != 0 && is_complete(buf, buf_end, last_len, &r) == NULL) {
    return r;
  }
  
  if ((buf = parse_response(buf, buf_end, minor_version, status, msg, msg_len,
			    headers, num_headers, max_headers, &r))
      == NULL) {
    return r;
  }
  
  return buf - buf_start;
}
开发者ID:miyagawa,项目名称:p5-http-parser-xs,代码行数:29,代码来源:picohttpparser.c


示例4: newsnntp_connect

int newsnntp_connect(newsnntp * f, mailstream * s)
{
  char * response;
  int r;

  if (f->nntp_stream != NULL)
    return NEWSNNTP_ERROR_BAD_STATE;

  f->nntp_stream = s;

  response = read_line(f);
  if (response == NULL)
    return NEWSNNTP_ERROR_STREAM;

  r = parse_response(f, response);

  switch (r) {
  case 200:
      f->nntp_readonly = FALSE;
      return NEWSNNTP_NO_ERROR;

  case 201:
      f->nntp_readonly = TRUE;
      return NEWSNNTP_NO_ERROR;

  default:
      f->nntp_stream = NULL;
      return NEWSNNTP_ERROR_UNEXPECTED_RESPONSE;
  }
}
开发者ID:AnckieLV,项目名称:libetpan,代码行数:30,代码来源:newsnntp.c


示例5: send_http_reply

//LCOV_EXCL_START - don't want to actually run the handlers in the UT
void RegistrationTimeoutTask::run()
{
  if (_req.method() != htp_method_POST)
  {
    send_http_reply(HTTP_BADMETHOD);
    delete this;
    return;
  }

  HTTPCode rc = parse_response(_req.get_rx_body());

  if (rc != HTTP_OK)
  {
    LOG_DEBUG("Unable to parse response from Chronos");
    send_http_reply(rc);
    delete this;
    return;
  }

  send_http_reply(HTTP_OK);

  SAS::Marker start_marker(trail(), MARKER_ID_START, 1u);
  SAS::report_marker(start_marker);

  handle_response();

  SAS::Marker end_marker(trail(), MARKER_ID_END, 1u);
  SAS::report_marker(end_marker);

  delete this;
}
开发者ID:matt-williams,项目名称:sprout,代码行数:32,代码来源:handlers.cpp


示例6: mailpop3_pass

int mailpop3_pass(mailpop3 * f, const char * password)
{
  char command[POP3_STRING_SIZE];
  int r;
  char * response;

  if (f->pop3_state != POP3_STATE_AUTHORIZATION)
    return MAILPOP3_ERROR_BAD_STATE;

  /* send password command */

  snprintf(command, POP3_STRING_SIZE, "PASS %s\r\n", password);
  r = send_command_private(f, command, 0);
  if (r == -1)
    return MAILPOP3_ERROR_STREAM;

  response = read_line(f);
  if (response == NULL)
    return MAILPOP3_ERROR_STREAM;
  r = parse_response(f, response);

  if (r != RESPONSE_OK)
    return MAILPOP3_ERROR_BAD_PASSWORD;

  f->pop3_state = POP3_STATE_TRANSACTION;

  return MAILPOP3_NO_ERROR;
}
开发者ID:CodaFi,项目名称:etPanKit,代码行数:28,代码来源:mailpop3.c


示例7: newsnntp_mode_reader

int newsnntp_mode_reader(newsnntp * f)
{
  char command[NNTP_STRING_SIZE];
  char * response;
  int r;

  snprintf(command, NNTP_STRING_SIZE, "MODE READER\r\n");
  
  r = send_command(f, command);
  if (r == -1)
    return NEWSNNTP_ERROR_STREAM;

  response = read_line(f);
  if (response == NULL)
    return NEWSNNTP_ERROR_STREAM;

  r = parse_response(f, response);
  switch (r) {
  case 480:
    return NEWSNNTP_ERROR_REQUEST_AUTHORIZATION_USERNAME;
      
  case 381:
    return NEWSNNTP_WARNING_REQUEST_AUTHORIZATION_PASSWORD;
      
  case 200:
  case 201:
    return NEWSNNTP_NO_ERROR;

  default:
    return NEWSNNTP_ERROR_UNEXPECTED_RESPONSE;
  }
}
开发者ID:AnckieLV,项目名称:libetpan,代码行数:32,代码来源:newsnntp.c


示例8: newsnntp_quit

int newsnntp_quit(newsnntp * f)
{
  char command[NNTP_STRING_SIZE];
  char * response;
  int r;
  int res;

  if (f->nntp_stream == NULL)
    return NEWSNNTP_ERROR_BAD_STATE;

  snprintf(command, NNTP_STRING_SIZE, "QUIT\r\n");
  r = send_command(f, command);
  if (r == -1) {
    res = NEWSNNTP_ERROR_STREAM;
    goto close;
  }
  
  response = read_line(f);
  if (response == NULL) {
    res = NEWSNNTP_ERROR_STREAM;
    goto close;
  }

  parse_response(f, response);

  res = NEWSNNTP_NO_ERROR;

 close:

  mailstream_close(f->nntp_stream);

  f->nntp_stream = NULL;
  
  return res;
}
开发者ID:AnckieLV,项目名称:libetpan,代码行数:35,代码来源:newsnntp.c


示例9: send_http_reply

//LCOV_EXCL_START - don't want to actually run the handlers in the UT
void RegistrationTimeoutHandler::run()
{
  if (_req.method() != htp_method_POST)
  {
    send_http_reply(HTTP_BADMETHOD);
    delete this;
    return;
  }

  HTTPCode rc = parse_response(_req.body());

  if (rc != HTTP_OK)
  {
    LOG_DEBUG("Unable to parse response from Chronos");
    send_http_reply(rc);
    delete this;
    return;
  }

  send_http_reply(HTTP_OK);

  SAS::Marker start_marker(trail(), MARKER_ID_START, 1u);
  SAS::report_marker(start_marker);
  SAS::Marker calling_dn(trail(), MARKER_ID_CALLING_DN, 1u);
  calling_dn.add_var_param(_aor_id);
  SAS::report_marker(calling_dn);

  handle_response();

  SAS::Marker end_marker(trail(), MARKER_ID_END, 1u);
  SAS::report_marker(end_marker);

  delete this;
}
开发者ID:oldurecu,项目名称:sprout,代码行数:35,代码来源:handlers.cpp


示例10: mailpop3_dele

int mailpop3_dele(mailpop3 * f, unsigned int indx)
{
  char command[POP3_STRING_SIZE];
  struct mailpop3_msg_info * msginfo;
  char * response;
  int r;

  if (f->pop3_state != POP3_STATE_TRANSACTION)
    return MAILPOP3_ERROR_BAD_STATE;

  msginfo = find_msg(f, indx);

  if (msginfo == NULL) {
    f->pop3_response = NULL;
    return MAILPOP3_ERROR_NO_SUCH_MESSAGE;
  }

  snprintf(command, POP3_STRING_SIZE, "DELE %i\r\n", indx);
  r = send_command(f, command);
  if (r == -1)
    return MAILPOP3_ERROR_STREAM;

  response = read_line(f);
  if (response == NULL)
    return MAILPOP3_ERROR_STREAM;
  r = parse_response(f, response);
  if (r != RESPONSE_OK)
    return MAILPOP3_ERROR_NO_SUCH_MESSAGE;

  msginfo->msg_deleted = TRUE;
  f->pop3_deleted_count ++;
  
  return MAILPOP3_NO_ERROR;
}
开发者ID:CodaFi,项目名称:etPanKit,代码行数:34,代码来源:mailpop3.c


示例11: mailpop3_rset

int mailpop3_rset(mailpop3 * f)
{
  char command[POP3_STRING_SIZE];
  char * response;
  int r;

  if (f->pop3_state != POP3_STATE_TRANSACTION)
    return MAILPOP3_ERROR_BAD_STATE;

  snprintf(command, POP3_STRING_SIZE, "RSET\r\n");
  r = send_command(f, command);
  if (r == -1)
    return MAILPOP3_ERROR_STREAM;

  response = read_line(f);
  if (response == NULL)
    return MAILPOP3_ERROR_STREAM;
  parse_response(f, response);

  if (f->pop3_msg_tab != NULL) {
    mailpop3_msg_info_tab_reset(f->pop3_msg_tab);
    f->pop3_deleted_count = 0;
  }

  return MAILPOP3_NO_ERROR;
}
开发者ID:CodaFi,项目名称:etPanKit,代码行数:26,代码来源:mailpop3.c


示例12: handle_response

static void handle_response(GObex *obex, GError *err, GObexPacket *rsp)
{
	struct pending_pkt *p = obex->pending_req;
	gboolean disconn = err ? TRUE : FALSE, final_rsp = TRUE;

	if (rsp != NULL)
		final_rsp = parse_response(obex, rsp);

	if (p->cancelled)
		err = g_error_new(G_OBEX_ERROR, G_OBEX_ERROR_CANCELLED,
					"The operation was cancelled");

	if (err)
		g_obex_debug(G_OBEX_DEBUG_ERROR, "%s", err->message);

	if (p->rsp_func) {
		p->rsp_func(obex, err, rsp, p->rsp_data);

		/* Check if user callback removed the request */
		if (p != obex->pending_req)
			return;
	}

	if (p->cancelled)
		g_error_free(err);

	if (final_rsp) {
		pending_pkt_free(p);
		obex->pending_req = NULL;
	}

	if (!disconn && g_queue_get_length(obex->tx_queue) > 0)
		enable_tx(obex);
}
开发者ID:Fiend90,项目名称:obex,代码行数:34,代码来源:gobex.c


示例13: mailpop3_capa

int mailpop3_capa(mailpop3 * f, clist ** result)
{
  clist * capa_list;
  char command[POP3_STRING_SIZE];
  int r;
  char * response;

  snprintf(command, POP3_STRING_SIZE, "CAPA\r\n");
  r = send_command(f, command);
  if (r == -1)
    return MAILPOP3_ERROR_STREAM;

  response = read_line(f);
  if (response == NULL)
    return MAILPOP3_ERROR_STREAM;
  r = parse_response(f, response);

  if (r != RESPONSE_OK)
    return MAILPOP3_ERROR_CAPA_NOT_SUPPORTED;
  
  capa_list = NULL;
  r = read_capa_resp(f, &capa_list);
  if (r != MAILPOP3_NO_ERROR)
    return r;

  * result = capa_list;

  return MAILPOP3_NO_ERROR;
}
开发者ID:CodaFi,项目名称:etPanKit,代码行数:29,代码来源:mailpop3.c


示例14: suspend

static int suspend(const struct ether_addr *mac, struct message_buffer *buf)
{
    struct response *response = &buf->u.response;
    struct agent *agent = find_agent_by_mac(list, mac);
    int n;

    if (agent == NULL)
        return 404;
    if (agent->state == SUSPENDED)
        return 409;
    if (agent->fd2 < 0)  // no connection to the agent
        return 500;
    send_request(agent->fd2, SUSP, NULL, NULL, buf);
    n = read(agent->fd2, buf->chars, sizeof(buf->chars) - 1);
    if (n <= 0) {
        if (n < 0)
            WARNING("read() failed: %m");
        else
            WARNING("unexpected EOF while waiting for a response");
        return 500;
    }
    buf->chars[n] = 0;
    if (parse_response(buf->chars, response)) {
        WARNING("invalid response");
        return 500;
    }
    switch (response->status) {
    case 200:
        return 200;
    default:
        WARNING("got unexpected response status code: %d", response->status);
        return 500;
    }
}
开发者ID:clee704,项目名称:nightwatch,代码行数:34,代码来源:ui_handler.c


示例15: newsnntp_xover_resp

static int newsnntp_xover_resp(newsnntp * f, clist ** result)
{
  int r;
  char * response;

  response = read_line(f);
  if (response == NULL)
    return NEWSNNTP_ERROR_STREAM;

  r = parse_response(f, response);

  switch (r) {
  case 480:
    return NEWSNNTP_ERROR_REQUEST_AUTHORIZATION_USERNAME;
      
  case 381:
    return NEWSNNTP_WARNING_REQUEST_AUTHORIZATION_PASSWORD;
      
  case 224:
    * result = read_xover_resp_list(f);
    return NEWSNNTP_NO_ERROR;

  case 412:
    return NEWSNNTP_ERROR_NO_NEWSGROUP_SELECTED;

  case 420:
    return NEWSNNTP_ERROR_NO_ARTICLE_SELECTED;

  case 502:
    return NEWSNNTP_ERROR_NO_PERMISSION;

  default:
    return NEWSNNTP_ERROR_UNEXPECTED_RESPONSE;
  }
}
开发者ID:AnckieLV,项目名称:libetpan,代码行数:35,代码来源:newsnntp.c


示例16: mailpop3_user

int mailpop3_user(mailpop3 * f, const char * user)
{
  char command[POP3_STRING_SIZE];
  int r;
  char * response;

  if (f->pop3_state != POP3_STATE_AUTHORIZATION)
    return MAILPOP3_ERROR_BAD_STATE;
  
  /* send user command */
    
  snprintf(command, POP3_STRING_SIZE, "USER %s\r\n", user);
  r = send_command_private(f, command, 0);
  if (r == -1)
    return MAILPOP3_ERROR_STREAM;

  response = read_line(f);
  if (response == NULL)
    return MAILPOP3_ERROR_STREAM;
  r = parse_response(f, response);

  if (r != RESPONSE_OK)
    return MAILPOP3_ERROR_BAD_USER;

  return MAILPOP3_NO_ERROR;
}
开发者ID:CodaFi,项目名称:etPanKit,代码行数:26,代码来源:mailpop3.c


示例17: mailpop3_do_uidl

static int mailpop3_do_uidl(mailpop3 * f, carray * msg_tab)
{
  char command[POP3_STRING_SIZE];
  int r;
  char * response;

  if (f->pop3_state != POP3_STATE_TRANSACTION)
    return MAILPOP3_ERROR_BAD_STATE;

  /* send list command */
  
  snprintf(command, POP3_STRING_SIZE, "UIDL\r\n");
  r = send_command(f, command);
  if (r == -1)
    return MAILPOP3_ERROR_STREAM;

  response = read_line(f);
  if (response == NULL)
    return MAILPOP3_ERROR_STREAM;
  r = parse_response(f, response);

  if (r != RESPONSE_OK)
    return MAILPOP3_ERROR_CANT_LIST;
  
  r = read_uidl(f, msg_tab);
  if (r != MAILPOP3_NO_ERROR)
    return r;

  return MAILPOP3_NO_ERROR;
}
开发者ID:CodaFi,项目名称:etPanKit,代码行数:30,代码来源:mailpop3.c


示例18: newsnntp_list_active

int newsnntp_list_active(newsnntp * f, const char * wildcard, clist ** result)
{
  char command[NNTP_STRING_SIZE];
  int r;
  char * response;

  if (wildcard != NULL)
    snprintf(command, NNTP_STRING_SIZE, "LIST ACTIVE %s\r\n", wildcard);
  else
    snprintf(command, NNTP_STRING_SIZE, "LIST ACTIVE\r\n");
  r = send_command(f, command);
  if (r == -1)
    return NEWSNNTP_ERROR_STREAM;

  response = read_line(f);
  if (response == NULL)
    return NEWSNNTP_ERROR_STREAM;

  r = parse_response(f, response);

  switch (r) {
  case 480:
    return NEWSNNTP_ERROR_REQUEST_AUTHORIZATION_USERNAME;
      
  case 381:
    return NEWSNNTP_WARNING_REQUEST_AUTHORIZATION_PASSWORD;

  case 215:
    * result = read_groups_list(f);
    return NEWSNNTP_NO_ERROR;

  default:
    return NEWSNNTP_ERROR_UNEXPECTED_RESPONSE;
  }
}
开发者ID:AnckieLV,项目名称:libetpan,代码行数:35,代码来源:newsnntp.c


示例19: mailpop3_connect

int mailpop3_connect(mailpop3 * f, mailstream * s)
{
  char * response;
  int r;
  char * timestamp;

  if (f->pop3_state != POP3_STATE_DISCONNECTED)
    return MAILPOP3_ERROR_BAD_STATE;

  f->pop3_stream = s;

  response = read_line(f);

  r = parse_response(f, response);
  if (r != RESPONSE_OK)
    return MAILPOP3_ERROR_UNAUTHORIZED;

  f->pop3_state = POP3_STATE_AUTHORIZATION;

  timestamp = mailpop3_get_timestamp(f->pop3_response);
  if (timestamp != NULL)
    f->pop3_timestamp = timestamp;

  return MAILPOP3_NO_ERROR;
}
开发者ID:CodaFi,项目名称:etPanKit,代码行数:25,代码来源:mailpop3.c


示例20: parse_auth

static int parse_auth(mailpop3 * f, char * response)
{
  char * msg;
  
  if (response == NULL) {
    f->pop3_response = NULL;
    return RESPONSE_ERR;
  }

  if ((strncmp(response, RESP_AUTH_CONT_STR, strlen(RESP_AUTH_CONT_STR)) == 0) &&
      (strncmp(response, RESP_OK_STR, strlen(RESP_OK_STR)) != 0)) {
    
    if (response[strlen(RESP_AUTH_CONT_STR)] == ' ')
      msg = response + strlen(RESP_AUTH_CONT_STR) + 1;
    else
      msg = response + strlen(RESP_AUTH_CONT_STR);
    
    if (mmap_string_assign(f->pop3_response_buffer, msg))
      f->pop3_response = f->pop3_response_buffer->str;
    else
      f->pop3_response = NULL;

    return RESPONSE_AUTH_CONT;
  }
  else {
    return parse_response(f, response);
  }
}
开发者ID:CodaFi,项目名称:etPanKit,代码行数:28,代码来源:mailpop3.c



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ parse_rr函数代码示例发布时间:2022-05-30
下一篇:
C++ parse_request函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap