src/etpan_mime.c
changeset 90 42b5eb9d5af2
parent 89 aef5a4bc78f3
child 92 c9be62386ffb
     1.1 --- a/src/etpan_mime.c	Sat Mar 07 20:29:13 2015 +0100
     1.2 +++ b/src/etpan_mime.c	Sun Mar 08 00:35:18 2015 +0100
     1.3 @@ -23,14 +23,9 @@
     1.4      name[MAX_MESSAGE_ID - 1] = 0;
     1.5  
     1.6      now = time(NULL);
     1.7 -#ifndef WIN32
     1.8 +
     1.9      value = random();
    1.10 -    
    1.11      gethostname(name, MAX_MESSAGE_ID - 1);
    1.12 -#else
    1.13 -    value = now;
    1.14 -    strcpy(name, "WINDOWS");
    1.15 -#endif
    1.16      
    1.17      if (boundary_prefix == NULL)
    1.18          boundary_prefix = "";
    1.19 @@ -124,7 +119,7 @@
    1.20  			parameters = content->ct_parameters;
    1.21  
    1.22  		r = clist_append(parameters, param);
    1.23 -		if (r != 0) {
    1.24 +		if (r) {
    1.25  			clist_free(parameters);
    1.26  			mailmime_parameter_free(param);
    1.27  			goto free_list;
    1.28 @@ -294,9 +289,8 @@
    1.29      if (field == NULL)
    1.30          return -1;
    1.31  
    1.32 -
    1.33      r = clist_append(list, field);
    1.34 -    if (r == -1)
    1.35 +    if (r)
    1.36          _free_field(field);
    1.37  
    1.38      return r;
    1.39 @@ -343,3 +337,36 @@
    1.40      return result;
    1.41  }
    1.42  
    1.43 +struct mailimf_mailbox * mailbox_from_string(
    1.44 +        const char *name,
    1.45 +        const char *address
    1.46 +    )
    1.47 +{
    1.48 +    struct mailimf_mailbox *mb = NULL;
    1.49 +    char *_name = NULL;
    1.50 +    char *_address = NULL;
    1.51 +
    1.52 +    assert(address);
    1.53 +
    1.54 +    _name = name ? strdup(name) : strdup("");
    1.55 +    if (_name == NULL)
    1.56 +        goto enomem;
    1.57 +
    1.58 +    _address = strdup(address);
    1.59 +    if (_address == NULL)
    1.60 +        goto enomem;
    1.61 +
    1.62 +    mb = mailimf_mailbox_new(_name, _address);
    1.63 +    assert(mb);
    1.64 +    if (mb == NULL)
    1.65 +        goto enomem;
    1.66 +
    1.67 +    return mb;
    1.68 +
    1.69 +enomem:
    1.70 +    free(_name);
    1.71 +    free(_address);
    1.72 +
    1.73 +    return NULL;
    1.74 +}
    1.75 +