some redesign and bugfixing
authorvb
Sun, 22 Feb 2015 13:40:25 +0100
changeset 63f5b2641f4ae7
parent 62 ad5e484720e1
child 64 d393c205d201
some redesign and bugfixing
src/message_api.c
src/mime.c
src/pgp_gpg.c
src/transport.c
test/message_api_test.cc
     1.1 --- a/src/message_api.c	Sat Feb 21 16:55:43 2015 +0100
     1.2 +++ b/src/message_api.c	Sun Feb 22 13:40:25 2015 +0100
     1.3 @@ -11,18 +11,23 @@
     1.4  static char * combine_short_and_long(const message * src)
     1.5  {
     1.6      char * ptext;
     1.7 +    char * longmsg;
     1.8      assert(src);
     1.9 -    assert(src->shortmsg && src->longmsg && strcmp(src->shortmsg, "pEp") != 0);
    1.10 +    assert(src->shortmsg && strcmp(src->shortmsg, "pEp") != 0);
    1.11  
    1.12 -    ptext = calloc(1, strlen(src->shortmsg) + strlen(src->longmsg)
    1.13 -            + 12);
    1.14 +    if (src->longmsg)
    1.15 +        longmsg = src->longmsg;
    1.16 +    else
    1.17 +        longmsg = "";
    1.18 +
    1.19 +    ptext = calloc(1, strlen(src->shortmsg) + strlen(longmsg) + 12);
    1.20      if (ptext == NULL)
    1.21          return NULL;
    1.22  
    1.23      strcpy(ptext, "subject: ");
    1.24      strcat(ptext, src->shortmsg);
    1.25      strcat(ptext, "\n\n");
    1.26 -    strcat(ptext, src->longmsg);
    1.27 +    strcat(ptext, longmsg);
    1.28  
    1.29      return ptext;
    1.30  }
    1.31 @@ -36,6 +41,8 @@
    1.32      )
    1.33  {
    1.34      PEP_STATUS status = PEP_STATUS_OK;
    1.35 +    message * msg = NULL;
    1.36 +    stringlist_t * keys = NULL;
    1.37  
    1.38      assert(session);
    1.39      assert(src);
    1.40 @@ -45,64 +52,51 @@
    1.41  
    1.42      pEp_identity *from = identity_dup(src->from);
    1.43      if (from == NULL)
    1.44 -        return PEP_OUT_OF_MEMORY;
    1.45 +        goto enomem;
    1.46 +    from->me = true;
    1.47  
    1.48      identity_list *to = identity_list_dup(src->to);
    1.49      if (to == NULL) {
    1.50          free_identity(from);
    1.51 -        return PEP_OUT_OF_MEMORY;
    1.52 +        goto enomem;
    1.53      }
    1.54  
    1.55 -    message *msg = new_message(src->dir, from, to, NULL);
    1.56 +    msg = new_message(src->dir, from, to, NULL);
    1.57      if (msg == NULL) {
    1.58          free_identity(from);
    1.59          free_identity_list(to);
    1.60 -        return PEP_OUT_OF_MEMORY;
    1.61 +        goto enomem;
    1.62      }
    1.63      msg->enc_format = PEP_enc_pieces;
    1.64  
    1.65 -    from->me = true;
    1.66 +    status = myself(session, from);
    1.67 +    if (status != PEP_STATUS_OK)
    1.68 +        goto pep_error;
    1.69  
    1.70 -    status = myself(session, from);
    1.71 -    if (status != PEP_STATUS_OK) {
    1.72 -        free_message(msg);
    1.73 -        return status;
    1.74 -    }
    1.75 -
    1.76 -    stringlist_t * keys = new_stringlist(from->fpr);
    1.77 -    if (keys == NULL) {
    1.78 -        free_message(msg);
    1.79 -        return PEP_OUT_OF_MEMORY;
    1.80 -    }
    1.81 +    keys = new_stringlist(from->fpr);
    1.82 +    if (keys == NULL)
    1.83 +        goto enomem;
    1.84  
    1.85      stringlist_t *_k = keys;
    1.86  
    1.87      if (extra) {
    1.88          _k = stringlist_append(_k, extra);
    1.89 -        if (_k == NULL) {
    1.90 -            free_stringlist(keys);
    1.91 -            free_message(msg);
    1.92 -            return PEP_OUT_OF_MEMORY;
    1.93 -        }
    1.94 +        if (_k == NULL)
    1.95 +            goto enomem;
    1.96      }
    1.97  
    1.98      bool dest_keys_found = false;
    1.99      identity_list * _il;
   1.100      for (_il = to; _il && _il->ident; _il = _il->next) {
   1.101 -        PEP_STATUS _status = update_identity(session, _il->ident);
   1.102 -        if (_status != PEP_STATUS_OK) {
   1.103 -            free_message(msg);
   1.104 -            free_stringlist(keys);
   1.105 -            return _status;
   1.106 -        }
   1.107 +        PEP_STATUS status = update_identity(session, _il->ident);
   1.108 +        if (status != PEP_STATUS_OK)
   1.109 +            goto pep_error;
   1.110 +
   1.111          if (_il->ident->fpr) {
   1.112              dest_keys_found = true;
   1.113              _k = stringlist_add(_k, _il->ident->fpr);
   1.114 -            if (_k == NULL) {
   1.115 -                free_message(msg);
   1.116 -                free_stringlist(keys);
   1.117 -                return PEP_OUT_OF_MEMORY;
   1.118 -            }
   1.119 +            if (_k == NULL)
   1.120 +                goto enomem;
   1.121          }
   1.122          else
   1.123              status = PEP_KEY_NOT_FOUND;
   1.124 @@ -116,107 +110,66 @@
   1.125  
   1.126          switch (format) {
   1.127          case PEP_enc_MIME_multipart: {
   1.128 -            char *resulttext;
   1.129 +            char *resulttext = NULL;
   1.130              bool free_ptext = false;
   1.131              msg->enc_format = PEP_enc_MIME_multipart;
   1.132  
   1.133 -            if (src->shortmsg && src->longmsg && strcmp(src->shortmsg, "pEp") != 0) {
   1.134 +            if (src->shortmsg && strcmp(src->shortmsg, "pEp") != 0) {
   1.135                  ptext = combine_short_and_long(src);
   1.136 -                if (ptext == NULL) {
   1.137 -                    free_message(msg);
   1.138 -                    free_stringlist(keys);
   1.139 -                    return PEP_OUT_OF_MEMORY;
   1.140 -                }
   1.141 +                if (ptext == NULL)
   1.142 +                    goto enomem;
   1.143                  free_ptext = true;
   1.144              }
   1.145              else if (src->longmsg) {
   1.146                  ptext = src->longmsg;
   1.147              }
   1.148              else {
   1.149 -                ptext = NULL;
   1.150 +                assert(0);
   1.151 +                status = PEP_ILLEGAL_VALUE;
   1.152 +                goto pep_error;
   1.153              }
   1.154  
   1.155 -            // TO EXTEND: we only support HTML yet
   1.156 -            assert(src->format == PEP_format_plain
   1.157 -                    || src->format == PEP_format_html);
   1.158 -
   1.159              status = mime_encode_text(ptext, src->longmsg_formatted,
   1.160                      src->attachments, &resulttext);
   1.161              assert(status == PEP_STATUS_OK);
   1.162              if (free_ptext)
   1.163                  free(ptext);
   1.164              assert(resulttext);
   1.165 -            if (resulttext == NULL) {
   1.166 -                free_message(msg);
   1.167 -                free_stringlist(keys);
   1.168 -                return status;
   1.169 -            }
   1.170 +            if (resulttext == NULL)
   1.171 +                goto pep_error;
   1.172              
   1.173              status = encrypt_and_sign(session, keys, resulttext, strlen(resulttext),
   1.174                      &ctext, &csize);
   1.175              free(resulttext);
   1.176 -            free_stringlist(keys);
   1.177              if (ctext) {
   1.178                  msg->longmsg = strdup(ctext);
   1.179                  msg->shortmsg = strdup("pEp");
   1.180 -                if (!(msg->longmsg && msg->shortmsg)) {
   1.181 -                    free_message(msg);
   1.182 -                    return PEP_OUT_OF_MEMORY;
   1.183 -                }
   1.184 +                if (!(msg->longmsg && msg->shortmsg))
   1.185 +                    goto enomem;
   1.186 +            }
   1.187 +            else {
   1.188 +                goto pep_error;
   1.189              }
   1.190          }
   1.191 +        break;
   1.192  
   1.193          case PEP_enc_pieces:
   1.194 -            if (src->shortmsg && src->longmsg && strcmp(src->shortmsg, "pEp") != 0) {
   1.195 +            if (src->shortmsg && strcmp(src->shortmsg, "pEp") != 0) {
   1.196                  ptext = combine_short_and_long(src);
   1.197 -                if (ptext == NULL) {
   1.198 -                    free_message(msg);
   1.199 -                    free_stringlist(keys);
   1.200 -                    return PEP_OUT_OF_MEMORY;
   1.201 -                }
   1.202 +                if (ptext == NULL)
   1.203 +                    goto enomem;
   1.204 +
   1.205                  status = encrypt_and_sign(session, keys, ptext, strlen(ptext),
   1.206                          &ctext, &csize);
   1.207                  free(ptext);
   1.208                  if (ctext) {
   1.209                      msg->longmsg = strdup(ctext);
   1.210                      msg->shortmsg = strdup("pEp");
   1.211 -                    if (!(msg->longmsg && msg->shortmsg)) {
   1.212 -                        free_stringlist(keys);
   1.213 -                        free_message(msg);
   1.214 -                        return PEP_OUT_OF_MEMORY;
   1.215 -                    }
   1.216 +                    if (!(msg->longmsg && msg->shortmsg))
   1.217 +                        goto enomem;
   1.218                  }
   1.219                  else {
   1.220 -                    free_message(msg);
   1.221 -                    free_stringlist(keys);
   1.222 -                    msg = NULL;
   1.223 -                }
   1.224 -            }
   1.225 -            else if (src->shortmsg && strcmp(src->shortmsg, "pEp") != 0) {
   1.226 -                ptext = calloc(1, strlen(src->shortmsg) + 12);
   1.227 -                if (ptext == NULL) {
   1.228 -                    free_message(msg);
   1.229 -                    free_stringlist(keys);
   1.230 -                    return PEP_OUT_OF_MEMORY;
   1.231 -                }
   1.232 -                strcpy(ptext, "subject: ");
   1.233 -                strcat(ptext, src->shortmsg);
   1.234 -                strcat(ptext, "\n\n");
   1.235 -                status = encrypt_and_sign(session, keys, ptext, strlen(ptext),
   1.236 -                        &ctext, &csize);
   1.237 -                free(ptext);
   1.238 -                if (ctext) {
   1.239 -                    msg->longmsg = strdup(ctext);
   1.240 -                    msg->shortmsg = strdup("pEp");
   1.241 -                    if (!(msg->longmsg && msg->shortmsg)) {
   1.242 -                        free_message(msg);
   1.243 -                        free_stringlist(keys);
   1.244 -                        return PEP_OUT_OF_MEMORY;
   1.245 -                    }
   1.246 -                }
   1.247 -                else {
   1.248 -                    free_message(msg);
   1.249 -                    msg = NULL;
   1.250 +                    goto pep_error;
   1.251                  }
   1.252              }
   1.253              else if (src->longmsg) {
   1.254 @@ -226,81 +179,76 @@
   1.255                  if (ctext) {
   1.256                      msg->longmsg = strdup(ctext);
   1.257                      msg->shortmsg = strdup("pEp");
   1.258 -                    if (!(msg->longmsg && msg->shortmsg)) {
   1.259 -                        free_message(msg);
   1.260 -                        return PEP_OUT_OF_MEMORY;
   1.261 -                    }
   1.262 +                    if (!(msg->longmsg && msg->shortmsg))
   1.263 +                        goto enomem;
   1.264                  }
   1.265                  else {
   1.266 -                    free_message(msg);
   1.267 -                    msg = NULL;
   1.268 +                    goto pep_error;
   1.269                  }
   1.270              }
   1.271 -            if (msg && msg->longmsg_formatted) {
   1.272 +
   1.273 +            if (msg->longmsg_formatted) {
   1.274                  ptext = src->longmsg_formatted;
   1.275                  status = encrypt_and_sign(session, keys, ptext, strlen(ptext),
   1.276                          &ctext, &csize);
   1.277                  if (ctext) {
   1.278                      msg->longmsg_formatted = strdup(ctext);
   1.279 -                    if (msg->longmsg_formatted == NULL) {
   1.280 -                        free_message(msg);
   1.281 -                        return PEP_OUT_OF_MEMORY;
   1.282 +                    if (msg->longmsg_formatted == NULL)
   1.283 +                        goto enomem;
   1.284 +                }
   1.285 +                else {
   1.286 +                    goto pep_error;
   1.287 +                }
   1.288 +            }
   1.289 +
   1.290 +            if (src->attachments) {
   1.291 +                bloblist_t *_s;
   1.292 +                bloblist_t *_d = new_bloblist(NULL, 0, NULL, NULL);
   1.293 +                if (_d == NULL)
   1.294 +                    goto enomem;
   1.295 +
   1.296 +                msg->attachments = _d;
   1.297 +                for (_s = src->attachments; _s && _s->data; _s = _s->next) {
   1.298 +                    int psize = _s->size;
   1.299 +                    ptext = _s->data;
   1.300 +                    status = encrypt_and_sign(session, keys, ptext, psize,
   1.301 +                            &ctext, &csize);
   1.302 +                    if (ctext) {
   1.303 +                        char * _c = strdup(ctext);
   1.304 +                        if (_c == NULL)
   1.305 +                            goto enomem;
   1.306 +
   1.307 +                        _d = bloblist_add(_d, _c, csize, _s->mime_type,
   1.308 +                                _s->file_name);
   1.309 +                        if (_d == NULL)
   1.310 +                            goto enomem;
   1.311 +                    }
   1.312 +                    else {
   1.313 +                        goto pep_error;
   1.314                      }
   1.315                  }
   1.316 -                else {
   1.317 -                    free_message(msg);
   1.318 -                    msg = NULL;
   1.319 -                }
   1.320 -            }
   1.321 -            if (msg) {
   1.322 -                if (src->attachments) {
   1.323 -                    bloblist_t *_s;
   1.324 -                    bloblist_t *_d = new_bloblist(NULL, 0, NULL, NULL);
   1.325 -                    if (_d == NULL) {
   1.326 -                        free_message(msg);
   1.327 -                        free_stringlist(keys);
   1.328 -                        return PEP_OUT_OF_MEMORY;
   1.329 -                    }
   1.330 -                    msg->attachments = _d;
   1.331 -                    for (_s = src->attachments; _s && _s->data; _s = _s->next) {
   1.332 -                        int psize = _s->size;
   1.333 -                        ptext = _s->data;
   1.334 -                        status = encrypt_and_sign(session, keys, ptext, psize,
   1.335 -                                &ctext, &csize);
   1.336 -                        if (ctext) {
   1.337 -                            char * _c = strdup(ctext);
   1.338 -                            if (_c == NULL) {
   1.339 -                                free_message(msg);
   1.340 -                                free_stringlist(keys);
   1.341 -                                return PEP_OUT_OF_MEMORY;
   1.342 -                            }
   1.343 -                            _d = bloblist_add(_d, _c, csize, _s->mime_type,
   1.344 -                                    _s->file_name);
   1.345 -                            if (_d == NULL) {
   1.346 -                                free_message(msg);
   1.347 -                                free_stringlist(keys);
   1.348 -                                return PEP_OUT_OF_MEMORY;
   1.349 -                            }
   1.350 -                        }
   1.351 -                        else {
   1.352 -                            free_message(msg);
   1.353 -                            msg = NULL;
   1.354 -                            break;
   1.355 -                        }
   1.356 -                    }
   1.357 -                }
   1.358 -                *dst = msg;
   1.359              }
   1.360              break;
   1.361  
   1.362          default:
   1.363              assert(0);
   1.364 +            status = PEP_ILLEGAL_VALUE;
   1.365 +            goto pep_error;
   1.366          }
   1.367      }
   1.368 -    else
   1.369 -        free_message(msg);
   1.370  
   1.371      free_stringlist(keys);
   1.372 +
   1.373 +    *dst = msg;
   1.374 +    return PEP_STATUS_OK;
   1.375 +
   1.376 +enomem:
   1.377 +    status = PEP_OUT_OF_MEMORY;
   1.378 +
   1.379 +pep_error:
   1.380 +    free_stringlist(keys);
   1.381 +    free_message(msg);
   1.382 +
   1.383      return status;
   1.384  }
   1.385  
     2.1 --- a/src/mime.c	Sat Feb 21 16:55:43 2015 +0100
     2.2 +++ b/src/mime.c	Sun Feb 22 13:40:25 2015 +0100
     2.3 @@ -8,6 +8,7 @@
     2.4  #include <unistd.h>
     2.5  
     2.6  #include "etpan_mime.h"
     2.7 +#include "wrappers.h"
     2.8  
     2.9  DYNAMIC_API PEP_STATUS mime_encode_text(
    2.10          const char *plaintext,
    2.11 @@ -127,10 +128,7 @@
    2.12      if (template == NULL)
    2.13          goto enomem;
    2.14  
    2.15 -    do {
    2.16 -        fd = mkstemp(template);
    2.17 -    } while (fd == -1 && errno == EINTR);
    2.18 -
    2.19 +    fd = Mkstemp(template);
    2.20      assert(fd != -1);
    2.21      if (fd == -1)
    2.22          goto err_file;
    2.23 @@ -143,10 +141,7 @@
    2.24      free(template);
    2.25      template = NULL;
    2.26  
    2.27 -    do {
    2.28 -        file = fdopen(fd, "w+");
    2.29 -    } while (file == NULL && errno == EINTR);
    2.30 -
    2.31 +    file = Fdopen(fd, "w+");
    2.32      assert(file);
    2.33      if (file == NULL) {
    2.34          switch (errno) {
    2.35 @@ -179,38 +174,28 @@
    2.36  
    2.37      errno = 0;
    2.38      rewind(file);
    2.39 -
    2.40      assert(errno == 0);
    2.41 +#ifdef NDEBUG
    2.42      switch (errno) {
    2.43 +        case 0:
    2.44 +            break;
    2.45          case ENOMEM:
    2.46              goto enomem;
    2.47          default:
    2.48              goto err_file;
    2.49      }
    2.50 +#endif
    2.51  
    2.52      buf = calloc(1, size + 1);
    2.53      assert(buf);
    2.54      if (buf == NULL)
    2.55          goto enomem;
    2.56 -    
    2.57 -    char *_buf = buf;
    2.58 -    size_t rest = size;
    2.59 -    for (size_t bytes_read = 0; rest > 0; rest -= bytes_read, _buf += rest) {
    2.60 -        clearerr(file);
    2.61 -        bytes_read = rest * fread(_buf, rest, 1, file);
    2.62 + 
    2.63 +    size_t _read;
    2.64 +    _read = Fread1(buf, size, file);
    2.65 +    assert(_read == size);
    2.66  
    2.67 -        assert(ferror(file) == 0 || ferror(file) == EINTR);
    2.68 -        if (ferror(file) != 0 && ferror(file) != EINTR)
    2.69 -            goto err_file;
    2.70 -
    2.71 -        assert(!feof(file));
    2.72 -        if (feof(file))
    2.73 -            goto err_file;
    2.74 -    }
    2.75 -
    2.76 -    do {
    2.77 -        r = fclose(file);
    2.78 -    } while (r == -1 && errno == EINTR);
    2.79 +    r = Fclose(file);
    2.80      assert(r == 0);
    2.81  
    2.82      mailmime_free(mime);
    2.83 @@ -233,15 +218,11 @@
    2.84      free(template);
    2.85  
    2.86      if (file) {
    2.87 -        do {
    2.88 -            r = fclose(file);
    2.89 -        } while (r == -1 && errno == EINTR);
    2.90 +        r = Fclose(file);
    2.91          assert(r == 0);
    2.92      }
    2.93      else if (fd != -1) {
    2.94 -        do {
    2.95 -            r = close(fd);
    2.96 -        } while (r == -1 && errno == EINTR);
    2.97 +        r = Close(fd);
    2.98          assert(r == 0);
    2.99      }
   2.100  
     3.1 --- a/src/pgp_gpg.c	Sat Feb 21 16:55:43 2015 +0100
     3.2 +++ b/src/pgp_gpg.c	Sun Feb 22 13:40:25 2015 +0100
     3.3 @@ -1,5 +1,3 @@
     3.4 -#include <errno.h>
     3.5 -
     3.6  #include "pgp_gpg.h"
     3.7  #include "pEp_internal.h"
     3.8  
     3.9 @@ -15,17 +13,15 @@
    3.10      int r;
    3.11  
    3.12      f = Fopen(gpg_conf(), "r");
    3.13 -    if (errno == ENOMEM)
    3.14 +    assert(f);
    3.15 +    if (f == NULL && errno == ENOMEM)
    3.16          return false;
    3.17  
    3.18      if (f != NULL) {
    3.19          do {
    3.20              char * s;
    3.21  
    3.22 -            do {
    3.23 -                s = fgets(buf, MAX_LINELENGTH, f);
    3.24 -            } while (s == NULL && !feof(f) && errno == EINTR);
    3.25 -
    3.26 +            s = Fgets(buf, MAX_LINELENGTH, f);
    3.27              assert(s);
    3.28              if (s == NULL)
    3.29                  return false;
    3.30 @@ -33,36 +29,26 @@
    3.31              if (s && !feof(f)) {
    3.32                  char * t = strtok(s, " ");
    3.33                  if (t && strcmp(t, "keyserver") == 0) {
    3.34 -                    do {
    3.35 -                        r = fclose(f);
    3.36 -                    } while (r == -1 && errno == EINTR);
    3.37 +                    r = Fclose(f);
    3.38                      assert(r == 0);
    3.39                      return true;
    3.40                  }
    3.41              }
    3.42          } while (!feof(f));
    3.43 -        do {
    3.44 -            f = freopen(gpg_conf(), "a", f);
    3.45 -        } while (f == NULL && errno == EINTR);
    3.46 +        f = Freopen(gpg_conf(), "a", f);
    3.47      }
    3.48      else {
    3.49 -        do {
    3.50 -            f = fopen(gpg_conf(), "w");
    3.51 -        } while (f == NULL && errno == EINTR);
    3.52 +        f = Fopen(gpg_conf(), "w");
    3.53      }
    3.54  
    3.55      assert(f);
    3.56      if (f == NULL)
    3.57          return false;
    3.58  
    3.59 -    do {
    3.60 -        n = fprintf(f, "keyserver %s\n", DEFAULT_KEYSERVER);
    3.61 -    } while (n < 0 && errno == EINTR);
    3.62 +    n = Fprintf(f, "keyserver %s\n", DEFAULT_KEYSERVER);
    3.63      assert(n >= 0);
    3.64  
    3.65 -    do {
    3.66 -        r = fclose(f);
    3.67 -    } while (r == -1 && errno == EINTR);
    3.68 +    r = Fclose(f);
    3.69      assert(r == 0);
    3.70  
    3.71      return true;
     4.1 --- a/src/transport.c	Sat Feb 21 16:55:43 2015 +0100
     4.2 +++ b/src/transport.c	Sun Feb 22 13:40:25 2015 +0100
     4.3 @@ -197,19 +197,21 @@
     4.4  
     4.5  DYNAMIC_API void free_message(message *msg)
     4.6  {
     4.7 -    free(msg->id);
     4.8 -    free(msg->shortmsg);
     4.9 -    free(msg->longmsg);
    4.10 -    free(msg->longmsg_formatted);
    4.11 -    free_bloblist(msg->attachments);
    4.12 -    free_identity(msg->from);
    4.13 -    free_identity_list(msg->to);
    4.14 -    free_identity(msg->recv_by);
    4.15 -    free_identity_list(msg->cc);
    4.16 -    free_identity_list(msg->bcc);
    4.17 -    free(msg->refering_id);
    4.18 -    free_message_ref_list(msg->refered_by);
    4.19 -    free(msg);
    4.20 +    if (msg) {
    4.21 +        free(msg->id);
    4.22 +        free(msg->shortmsg);
    4.23 +        free(msg->longmsg);
    4.24 +        free(msg->longmsg_formatted);
    4.25 +        free_bloblist(msg->attachments);
    4.26 +        free_identity(msg->from);
    4.27 +        free_identity_list(msg->to);
    4.28 +        free_identity(msg->recv_by);
    4.29 +        free_identity_list(msg->cc);
    4.30 +        free_identity_list(msg->bcc);
    4.31 +        free(msg->refering_id);
    4.32 +        free_message_ref_list(msg->refered_by);
    4.33 +        free(msg);
    4.34 +    }
    4.35  }
    4.36  
    4.37  DYNAMIC_API message_ref_list *new_message_ref_list(message *msg)
     5.1 --- a/test/message_api_test.cc	Sat Feb 21 16:55:43 2015 +0100
     5.2 +++ b/test/message_api_test.cc	Sun Feb 22 13:40:25 2015 +0100
     5.3 @@ -25,26 +25,17 @@
     5.4      assert(msg);
     5.5      cout << "message created.\n";
     5.6  
     5.7 -//     cout << "encrypting message in pieces…\n";
     5.8 -//     message *enc_msg;
     5.9 -//     cout << "calling encrypt_message()\n";
    5.10 -//     PEP_STATUS status2 = encrypt_message(session, msg, NULL, &enc_msg, PEP_enc_pieces);
    5.11 -//     assert(status2 == PEP_STATUS_OK);
    5.12 -//     assert(enc_msg);
    5.13 -//     cout << "message encrypted.\n";
    5.14 -
    5.15      cout << "encrypting message as MIME multipart…\n";
    5.16 -    message *enc_msg2;
    5.17 +    message *enc_msg3;
    5.18      cout << "calling encrypt_message()\n";
    5.19 -    PEP_STATUS status3 = encrypt_message(session, msg, NULL, &enc_msg2, PEP_enc_MIME_multipart);
    5.20 +    PEP_STATUS status3 = encrypt_message(session, msg, NULL, &enc_msg3, PEP_enc_MIME_multipart);
    5.21      assert(status3 == PEP_STATUS_OK);
    5.22 -    assert(enc_msg2);
    5.23 +    assert(enc_msg3);
    5.24      cout << "message encrypted.\n";
    5.25 +    free_message(enc_msg3);
    5.26      
    5.27      cout << "freeing messages…\n";
    5.28      free_message(msg);
    5.29 -//    free_message(enc_msg);
    5.30 -    free_message(enc_msg2);
    5.31      cout << "done.\n";
    5.32  
    5.33      cout << "calling release()\n";