Exemplo n.º 1
0
static int
mailmime_filename_parm_parse(const char * message, size_t length,
                             size_t * indx, char ** result)
{
    char * value;
    int r;
    size_t cur_token;

    cur_token = * indx;

    r = mailimf_token_case_insensitive_parse(message, length,
            &cur_token, "filename");
    if (r != MAILIMF_NO_ERROR)
        return r;

    r = mailimf_unstrict_char_parse(message, length, &cur_token, '=');
    if (r != MAILIMF_NO_ERROR)
        return r;

    r = mailimf_cfws_parse(message, length, &cur_token);
    if ((r != MAILIMF_NO_ERROR) && (r != MAILIMF_ERROR_PARSE))
        return r;

    r = mailmime_value_parse(message, length, &cur_token, &value);
    if (r != MAILIMF_NO_ERROR)
        return r;

    * indx = cur_token;
    * result = value;

    return MAILIMF_NO_ERROR;
}
Exemplo n.º 2
0
LIBETPAN_EXPORT
int mailmime_parameter_parse(const char * message, size_t length,
			     size_t * indx,
			     struct mailmime_parameter ** result)
{
  char * attribute;
  char * value;
  struct mailmime_parameter * parameter;
  size_t cur_token;
  int r;
  int res;

  cur_token = * indx;

  r = mailmime_attribute_parse(message, length, &cur_token, &attribute);
  if (r != MAILIMF_NO_ERROR) {
    res = r;
    goto err;
  }

  r = mailimf_unstrict_char_parse(message, length, &cur_token, '=');
  if (r != MAILIMF_NO_ERROR) {
    res = r;
    goto free_attr;
  }

  r = mailimf_cfws_parse(message, length, &cur_token);
  if ((r != MAILIMF_NO_ERROR) && (r != MAILIMF_ERROR_PARSE)) {
    res = r;
    goto free_attr;
  }

  r = mailmime_value_parse(message, length, &cur_token, &value);
  if (r != MAILIMF_NO_ERROR) {
    res = r;
    goto free_attr;
  }

  parameter = mailmime_parameter_new(attribute, value);
  if (parameter == NULL) {
    res = MAILIMF_ERROR_MEMORY;
    goto free_value;
  }

  * result = parameter;
  * indx = cur_token;

  return MAILIMF_NO_ERROR;

 free_value:
  mailmime_value_free(value);
 free_attr:
  mailmime_attribute_free(attribute);
 err:
  return res;
}