示例#1
0
char * mailstream_read_line(mailstream * stream, MMAPString * line)
{
  if (mmap_string_assign(line, "") == NULL)
    return NULL;

  return mailstream_read_line_append(stream, line);
}
示例#2
0
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);
  }
}
示例#3
0
char * mailstream_read_multiline(mailstream * stream, size_t size,
				 MMAPString * stream_buffer,
				 MMAPString * line,
				 size_t progr_rate,
				 progress_function * progr_fun)
{
  if (stream == NULL)
    return NULL;

  mmap_string_assign(line, "");

  do {
    if (stream->read_buffer_len > 0) {
      size_t i;

      i = 0;
      while (i < stream->read_buffer_len) {
	if (end_of_multiline(stream->read_buffer, i + 1))
	  return mailstream_read_len_append(stream, line, i + 1);
	i++;
      }
      if (mailstream_read_len_append(stream, line,
				     stream->read_buffer_len) == NULL)
	return NULL;
      if (end_of_multiline(line->str, line->len))
	return line->str;
    }
    else
      if (mailstream_feed_read_buffer(stream) == -1)
	return NULL;
  }
  while (1);

  return line->str;
}
示例#4
0
static int parse_response(mailpop3 * f, char * response)
{
  char * msg;
  
  if (response == NULL) {
    f->pop3_response = NULL;
    return RESPONSE_ERR;
  }

  if (strncmp(response, RESP_OK_STR, strlen(RESP_OK_STR)) == 0) {

    if (response[strlen(RESP_OK_STR)] == ' ')
      msg = response + strlen(RESP_OK_STR) + 1;
    else
      msg = response + strlen(RESP_OK_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_OK;
  }
  else if (strncmp(response, RESP_ERR_STR, strlen(RESP_ERR_STR)) == 0) {

    if (response[strlen(RESP_ERR_STR)] == ' ')
      msg = response + strlen(RESP_ERR_STR) + 1;
    else
      msg = response + strlen(RESP_ERR_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_ERR;
  }

  f->pop3_response = NULL;
  return RESPONSE_ERR;
}
示例#5
0
char * mailstream_read_multiline(mailstream * s, size_t size,
				  MMAPString * stream_buffer,
				  MMAPString * multiline_buffer,
				  size_t progr_rate,
				  progress_function * progr_fun,
				  mailprogress_function * body_progr_fun, void * context)
{
  size_t count;
  char * line;
  size_t last;

  if (mmap_string_assign(multiline_buffer, "") == NULL)
    return NULL;

  count = 0;
  last = 0;

  while ((line = mailstream_read_line_remove_eol(s, stream_buffer)) != NULL) {
    if (mailstream_is_end_multiline(line))
      return multiline_buffer->str;

    if (line[0] == '.') {
      if (mmap_string_append(multiline_buffer, line + 1) == NULL)
	return NULL;
    }
    else {
      if (mmap_string_append(multiline_buffer, line) == NULL)
	return NULL;
    }
    if (mmap_string_append(multiline_buffer, "\r\n") == NULL)
      return NULL;

    count += strlen(line);
    if ((size != 0) && (progr_rate != 0) && (progr_fun != NULL))
      if (count - last >= progr_rate) {
	      if (progr_fun != NULL) {
          (* progr_fun)(count, size);
        }
	      if (body_progr_fun != NULL) {
					body_progr_fun(count, size, context);
		    }
        last = count;
      }
  }

  return NULL;
}
示例#6
0
static int parse_response(newsnntp * f, char * response)
{
  int code;

  code = strtol(response, &response, 10);

  if (response == NULL) {
    f->nntp_response = NULL;
    return code;
  }

  parse_space(&response);

  if (mmap_string_assign(f->nntp_response_buffer, response) != NULL)
    f->nntp_response = f->nntp_response_buffer->str;
  else
    f->nntp_response = NULL;
 
  return code;
}
示例#7
0
static int read_response(mailsmtp * session)
{
  char * line;
  int code;

  mmap_string_assign(session->response_buffer, "");

  do {
    line = read_line(session);

    if (line != NULL) {
	code = parse_response(session, line);
        mmap_string_append_c(session->response_buffer, '\n');
      }
    else
      code = 0;
  }
  while ((code & SMTP_STATUS_CONTINUE) != 0);

  session->response = session->response_buffer->str;

  return code;
}