# HG changeset patch # User Volker Birk # Date 1427630078 -7200 # Node ID 63eb5372f2ef81806d69a0a4599caa37b81024b4 # Parent 0d9aec90828f4d7742323ab2c435c41ade8208c2 why not errno diff -r 0d9aec90828f -r 63eb5372f2ef src/etpan_mime.c --- a/src/etpan_mime.c Sun Mar 29 12:03:09 2015 +0200 +++ b/src/etpan_mime.c Sun Mar 29 13:54:38 2015 +0200 @@ -8,9 +8,7 @@ #include #include #include - - -time_t mail_mkgmtime(struct tm * tmp); +#include #define MAX_MESSAGE_ID 512 @@ -630,7 +628,7 @@ return NULL; } -bool parameter_has_value( +static bool parameter_has_value( struct mailmime_content *content, const char *name, const char *value @@ -712,8 +710,10 @@ assert(content); - if (content->ct_subtype == NULL) + if (content->ct_subtype == NULL) { + errno = EINVAL; return NULL; + } if (content->ct_type && content->ct_type->tp_data.tp_discrete_type) { size_t len; @@ -739,23 +739,27 @@ _type = "extension"; break; default: + errno = EINVAL; return NULL; } len = strlen(_type) + 1 + strlen(content->ct_subtype) + 1; type = calloc(1, len); assert(type); - // BUG: out of memory cannot be signaled - if (type == NULL) + if (type == NULL) { + errno = ENOMEM; return NULL; + } strcpy(type, _type); strcat(type, "/"); strcat(type, content->ct_subtype); + errno = 0; return type; } + errno = EINVAL; return NULL; } diff -r 0d9aec90828f -r 63eb5372f2ef src/etpan_mime.h --- a/src/etpan_mime.h Sun Mar 29 12:03:09 2015 +0200 +++ b/src/etpan_mime.h Sun Mar 29 13:54:38 2015 +0200 @@ -68,13 +68,6 @@ clist * _get_fields(struct mailmime * mime); struct mailmime_content * _get_content(struct mailmime * mime); char * _get_filename(struct mailmime *mime); - -bool parameter_has_value( - struct mailmime_content *content, - const char *name, - const char *value - ); - bool _is_multipart(struct mailmime_content *content, const char *subtype); bool _is_PGP_MIME(struct mailmime_content *content); bool _is_text_part(struct mailmime_content *content, const char *subtype); diff -r 0d9aec90828f -r 63eb5372f2ef src/mime.c --- a/src/mime.c Sun Mar 29 12:03:09 2015 +0200 +++ b/src/mime.c Sun Mar 29 13:54:38 2015 +0200 @@ -1300,13 +1300,21 @@ } else { char *data = NULL; - size_t size; - char * mime_type = NULL; - char * filename = NULL; + size_t size = 0; + char * mime_type; + char * filename; mime_type = _get_content_type(content); - if (mime_type == NULL) - return PEP_ILLEGAL_VALUE; + if (mime_type == NULL) { + switch (errno) { + case EINVAL: + return PEP_ILLEGAL_VALUE; + case ENOMEM: + return PEP_OUT_OF_MEMORY; + default: + return PEP_UNKNOWN_ERROR; + } + } status = interpret_body(mime, &data, &size); if (status)