ENGINE-9: moved build_uri to the resource_id files ENGINE-9
authorKrista Bennett <krista@pep-project.org>
Wed, 21 Jun 2017 13:43:55 +0200
branchENGINE-9
changeset 1881facb0b5b0bce
parent 1880 e2c2680bba23
child 1882 0b3814dbd6dd
ENGINE-9: moved build_uri to the resource_id files
src/etpan_mime.c
src/mime.c
src/resource_id.c
src/resource_id.h
     1.1 --- a/src/etpan_mime.c	Wed Jun 21 13:20:50 2017 +0200
     1.2 +++ b/src/etpan_mime.c	Wed Jun 21 13:43:55 2017 +0200
     1.3 @@ -620,22 +620,6 @@
     1.4      return content;
     1.5  }
     1.6  
     1.7 -char* _build_uri(char* uri_prefix, char* resource) {
     1.8 -    if (!uri_prefix || !resource)
     1.9 -        return NULL;
    1.10 -    const char* delim = "://";
    1.11 -    const int delim_len = 3;
    1.12 -    int prefix_len = strlen(uri_prefix);
    1.13 -    int resource_len = strlen(resource);
    1.14 -    int retval_len = prefix_len + delim_len + resource_len;
    1.15 -
    1.16 -    char* retval = calloc(1, retval_len + 1);
    1.17 -    strlcpy(retval, uri_prefix, retval_len);
    1.18 -    strlcat(retval, delim, retval_len);
    1.19 -    strlcat(retval, resource, retval_len);
    1.20 -    
    1.21 -    return retval;
    1.22 -}
    1.23  
    1.24  /* Return a list of identifier_type and resource id (filename, cid, etc) */
    1.25  pEp_rid_list_t* _get_resource_id_list(struct mailmime *mime)
    1.26 @@ -712,7 +696,7 @@
    1.27          if (_field && _field->fld_type == MAILMIME_FIELD_ID) {
    1.28              /* We prefer CIDs to filenames when both are present */
    1.29              free(_temp_filename_ptr); /* can be null, it's ok */
    1.30 -            return _build_uri("cid", _field->fld_data.fld_id); 
    1.31 +            return build_uri("cid", _field->fld_data.fld_id); 
    1.32          }
    1.33          else if (_field && _field->fld_type == MAILMIME_FIELD_DISPOSITION) {
    1.34              if (_field->fld_data.fld_disposition &&
    1.35 @@ -726,7 +710,7 @@
    1.36                      struct mailmime_disposition_parm * param =
    1.37                              clist_content(cur2);
    1.38                      if (param->pa_type == MAILMIME_DISPOSITION_PARM_FILENAME) {
    1.39 -                        _temp_filename_ptr = _build_uri("file", param->pa_data.pa_filename);
    1.40 +                        _temp_filename_ptr = build_uri("file", param->pa_data.pa_filename);
    1.41                          break;
    1.42                      }                
    1.43                  }
     2.1 --- a/src/mime.c	Wed Jun 21 13:20:50 2017 +0200
     2.2 +++ b/src/mime.c	Wed Jun 21 13:43:55 2017 +0200
     2.3 @@ -1433,7 +1433,7 @@
     2.4  
     2.5                      
     2.6                      if (file_prefix) {
     2.7 -                        filename = _build_uri(file_prefix, _filename);
     2.8 +                        filename = build_uri(file_prefix, _filename);
     2.9                          free(_filename);
    2.10                          _filename = filename;
    2.11                      }
     3.1 --- a/src/resource_id.c	Wed Jun 21 13:20:50 2017 +0200
     3.2 +++ b/src/resource_id.c	Wed Jun 21 13:43:55 2017 +0200
     3.3 @@ -51,3 +51,20 @@
     3.4      const char* resource = get_resource_ptr_noown(uri);
     3.5      return new_rid_node(type, resource);
     3.6  }
     3.7 +
     3.8 +char* build_uri(const char* uri_prefix, const char* resource) {
     3.9 +    if (!uri_prefix || !resource)
    3.10 +        return NULL;
    3.11 +    const char* delim = "://";
    3.12 +    const int delim_len = 3;
    3.13 +    int prefix_len = strlen(uri_prefix);
    3.14 +    int resource_len = strlen(resource);
    3.15 +    int retval_len = prefix_len + delim_len + resource_len;
    3.16 +
    3.17 +    char* retval = calloc(1, retval_len + 1);
    3.18 +    strlcpy(retval, uri_prefix, retval_len);
    3.19 +    strlcat(retval, delim, retval_len);
    3.20 +    strlcat(retval, resource, retval_len);
    3.21 +    
    3.22 +    return retval;
    3.23 +}
     4.1 --- a/src/resource_id.h	Wed Jun 21 13:20:50 2017 +0200
     4.2 +++ b/src/resource_id.h	Wed Jun 21 13:43:55 2017 +0200
     4.3 @@ -23,6 +23,8 @@
     4.4  
     4.5  pEp_rid_list_t* parse_uri(const char* uri);
     4.6  
     4.7 +char* build_uri(const char* uri_prefix, const char* resource);
     4.8 +
     4.9  const char* get_resource_ptr_noown(const char* uri);
    4.10  
    4.11  char* get_resource(char* uri);