...
authorvb
Tue, 03 Mar 2015 11:02:26 +0100
changeset 83c5d82f11689a
parent 82 d0ad5655688a
child 84 2009f3090d32
...
src/message_api.c
src/message_api.h
     1.1 --- a/src/message_api.c	Sun Mar 01 21:51:53 2015 +0100
     1.2 +++ b/src/message_api.c	Tue Mar 03 11:02:26 2015 +0100
     1.3 @@ -8,25 +8,22 @@
     1.4  
     1.5  #define NOT_IMPLEMENTED assert(0); return PEP_UNKNOWN_ERROR;
     1.6  
     1.7 -static char * combine_short_and_long(const message * src)
     1.8 +static char * combine_short_and_long(const char *shortmsg, const char *longmsg)
     1.9  {
    1.10      char * ptext;
    1.11 -    char * longmsg;
    1.12  
    1.13 -    assert(src);
    1.14 -    assert(src->shortmsg && strcmp(src->shortmsg, "pEp") != 0);
    1.15 +    assert(shortmsg);
    1.16 +    assert(strcmp(shortmsg, "pEp") != 0);
    1.17  
    1.18 -    if (src->longmsg)
    1.19 -        longmsg = src->longmsg;
    1.20 -    else
    1.21 +    if (longmsg == NULL)
    1.22          longmsg = "";
    1.23  
    1.24 -    ptext = calloc(1, strlen(src->shortmsg) + strlen(longmsg) + 12);
    1.25 +    ptext = calloc(1, strlen(shortmsg) + strlen(longmsg) + 12);
    1.26      if (ptext == NULL)
    1.27          return NULL;
    1.28  
    1.29      strcpy(ptext, "subject: ");
    1.30 -    strcat(ptext, src->shortmsg);
    1.31 +    strcat(ptext, shortmsg);
    1.32      strcat(ptext, "\n\n");
    1.33      strcat(ptext, longmsg);
    1.34  
    1.35 @@ -234,7 +231,7 @@
    1.36              msg->enc_format = PEP_enc_MIME_multipart;
    1.37  
    1.38              if (src->shortmsg && strcmp(src->shortmsg, "pEp") != 0) {
    1.39 -                ptext = combine_short_and_long(src);
    1.40 +                ptext = combine_short_and_long(src->shortmsg, src->longmsg);
    1.41                  if (ptext == NULL)
    1.42                      goto enomem;
    1.43                  free_ptext = true;
    1.44 @@ -288,7 +285,7 @@
    1.45              }
    1.46  
    1.47              if (src->shortmsg && strcmp(src->shortmsg, "pEp") != 0) {
    1.48 -                ptext = combine_short_and_long(src);
    1.49 +                ptext = combine_short_and_long(src->shortmsg, src->longmsg);
    1.50                  if (ptext == NULL)
    1.51                      goto enomem;
    1.52  
     2.1 --- a/src/message_api.h	Sun Mar 01 21:51:53 2015 +0100
     2.2 +++ b/src/message_api.h	Tue Mar 03 11:02:26 2015 +0100
     2.3 @@ -13,8 +13,8 @@
     2.4  //      session (in)        session handle
     2.5  //      src (in)            message to encrypt
     2.6  //      extra (in)          extra keys for encryption
     2.7 -//      dst (out)           pointer to encrypted message or NULL on failure
     2.8 -//      format (in)         unencrypted format
     2.9 +//      dst (out)           pointer to new encrypted message or NULL on failure
    2.10 +//      format (in)         encrypted format
    2.11  //
    2.12  //  return value:
    2.13  //      PEP_STATUS_OK                   on success
    2.14 @@ -23,6 +23,9 @@
    2.15  //		PEP_KEY_HAS_AMBIG_NAME          at least one of the receipient keys has
    2.16  //		                                an ambiguous name
    2.17  //		PEP_GET_KEY_FAILED		        cannot retrieve key
    2.18 +//
    2.19 +//	caveat:
    2.20 +//	    the ownership of the new message goes to the caller
    2.21  
    2.22  DYNAMIC_API PEP_STATUS encrypt_message(
    2.23          PEP_SESSION session,
    2.24 @@ -38,10 +41,14 @@
    2.25  //  parameters:
    2.26  //      session (in)        session handle
    2.27  //      src (in)            message to decrypt
    2.28 -//      dst (out)           pointer to decrypted message or NULL on failure
    2.29 +//      dst (out)           pointer to new decrypted message or NULL on failure
    2.30 +//      format (in)         unencrypted format
    2.31  //
    2.32  //  return value:
    2.33  //      error status or PEP_STATUS_OK on success
    2.34 +//
    2.35 +//	caveat:
    2.36 +//	    the ownership of the new message goes to the caller
    2.37  
    2.38  DYNAMIC_API PEP_STATUS decrypt_message(
    2.39          PEP_SESSION session,