src/etpan_mime.c
branchENGINE-9
changeset 1872 23b14ab93b11
parent 1871 51337eb65533
child 1873 2da96adc534e
     1.1 --- a/src/etpan_mime.c	Mon Jun 19 09:01:06 2017 +0200
     1.2 +++ b/src/etpan_mime.c	Mon Jun 19 09:32:00 2017 +0200
     1.3 @@ -596,7 +596,25 @@
     1.4      return content;
     1.5  }
     1.6  
     1.7 -char * _get_filename(struct mailmime *mime)
     1.8 +char* _get_uri(char* uri_prefix, char* resource) {
     1.9 +    if (!uri_prefix || !resource)
    1.10 +        return NULL;
    1.11 +    const char* delim = "://";
    1.12 +    const int delim_len = 3;
    1.13 +    int prefix_len = strlen(uri_prefix);
    1.14 +    int resource_len = strlen(resource);
    1.15 +    int retval_len = prefix_len + delim_len + resource_len;
    1.16 +
    1.17 +    char* retval = calloc(1, retval_len + 1);
    1.18 +    strlcpy(retval, uri_prefix, retval_len);
    1.19 +    strlcat(retval, delim, retval_len);
    1.20 +    strlcat(retval, resource, retval_len);
    1.21 +    
    1.22 +    return retval;
    1.23 +}
    1.24 +
    1.25 +
    1.26 +char * _get_filename_or_cid(struct mailmime *mime)
    1.27  {
    1.28      clist * _fieldlist = NULL;
    1.29  
    1.30 @@ -621,10 +639,12 @@
    1.31                      struct mailmime_disposition_parm * param =
    1.32                              clist_content(cur2);
    1.33                      if (param->pa_type == MAILMIME_DISPOSITION_PARM_FILENAME)
    1.34 -                        return param->pa_data.pa_filename;
    1.35 +                        return _get_uri("file", param->pa_data.pa_filename);
    1.36                  }
    1.37              }
    1.38          }
    1.39 +        else if (_field && _field->fld_type == MAILMIME_FIELD_ID) 
    1.40 +            return _get_uri("cid", _field->fld_data.fld_id); 
    1.41      }
    1.42  
    1.43      return NULL;
    1.44 @@ -784,4 +804,3 @@
    1.45  
    1.46      return EINVAL;
    1.47  }
    1.48 -