merged in default ENGINE-215
authorKrista Bennett <krista@pep-project.org>
Wed, 14 Jun 2017 18:58:09 +0200
branchENGINE-215
changeset 185752e46f43ac67
parent 1856 99348d336639
parent 1854 b76315c0117d
child 1864 9ce429048fd7
merged in default
src/message_api.c
     1.1 --- a/src/keymanagement.c	Wed Jun 14 18:52:55 2017 +0200
     1.2 +++ b/src/keymanagement.c	Wed Jun 14 18:58:09 2017 +0200
     1.3 @@ -91,7 +91,7 @@
     1.4      assert(!EMPTYSTR(identity->address));
     1.5  
     1.6      if (!(session && identity && !EMPTYSTR(identity->address)))
     1.7 -        return ERROR(PEP_ILLEGAL_VALUE);
     1.8 +        return ADD_TO_LOG(PEP_ILLEGAL_VALUE);
     1.9  
    1.10      if (identity->me || (identity->user_id && strcmp(identity->user_id, PEP_OWN_USERID) == 0)) {
    1.11          identity->me = true;
    1.12 @@ -326,7 +326,7 @@
    1.13      free_identity(stored_identity);
    1.14      free_identity(temp_id);
    1.15      
    1.16 -    return ERROR(status);
    1.17 +    return ADD_TO_LOG(status);
    1.18  }
    1.19  
    1.20  PEP_STATUS elect_ownkey(
    1.21 @@ -416,7 +416,7 @@
    1.22      
    1.23      *is_usable = !dont_use_fpr;
    1.24      
    1.25 -    return ERROR(status);
    1.26 +    return ADD_TO_LOG(status);
    1.27  }
    1.28  
    1.29  PEP_STATUS _myself(PEP_SESSION session, pEp_identity * identity, bool do_keygen, bool ignore_flags)
    1.30 @@ -434,7 +434,7 @@
    1.31      if (!(session && identity && !EMPTYSTR(identity->address) &&
    1.32              (EMPTYSTR(identity->user_id) ||
    1.33              strcmp(identity->user_id, PEP_OWN_USERID) == 0)))
    1.34 -        return ERROR(PEP_ILLEGAL_VALUE);
    1.35 +        return ADD_TO_LOG(PEP_ILLEGAL_VALUE);
    1.36  
    1.37      identity->comm_type = PEP_ct_pEp;
    1.38      identity->me = true;
    1.39 @@ -522,7 +522,7 @@
    1.40          status = elect_ownkey(session, identity);
    1.41          assert(status == PEP_STATUS_OK);
    1.42          if (status != PEP_STATUS_OK) {
    1.43 -            return ERROR(status);
    1.44 +            return ADD_TO_LOG(status);
    1.45          }
    1.46  
    1.47          bool has_private = false;
    1.48 @@ -554,7 +554,7 @@
    1.49  
    1.50          if (status != PEP_STATUS_OK) 
    1.51          {
    1.52 -            return ERROR(status);
    1.53 +            return ADD_TO_LOG(status);
    1.54          }
    1.55      }
    1.56     
    1.57 @@ -563,7 +563,7 @@
    1.58      if (EMPTYSTR(identity->fpr) || revoked)
    1.59      {
    1.60          if(!do_keygen){
    1.61 -            return ERROR(PEP_GET_KEY_FAILED);
    1.62 +            return ADD_TO_LOG(PEP_GET_KEY_FAILED);
    1.63          }
    1.64  
    1.65          if(revoked)
    1.66 @@ -581,7 +581,7 @@
    1.67              DEBUG_LOG("generating key pair failed", "debug", buf);
    1.68              if(revoked && r_fpr)
    1.69                  free(r_fpr);
    1.70 -            return ERROR(status);
    1.71 +            return ADD_TO_LOG(status);
    1.72          }
    1.73  
    1.74          new_key_generated = true;
    1.75 @@ -592,7 +592,7 @@
    1.76                                   identity->fpr, time(NULL));
    1.77              free(r_fpr);
    1.78              if (status != PEP_STATUS_OK) {
    1.79 -                return ERROR(status);
    1.80 +                return ADD_TO_LOG(status);
    1.81              }
    1.82          }
    1.83      }
    1.84 @@ -605,7 +605,7 @@
    1.85  
    1.86          assert(status == PEP_STATUS_OK);
    1.87          if (status != PEP_STATUS_OK) {
    1.88 -            return ERROR(status);
    1.89 +            return ADD_TO_LOG(status);
    1.90          }
    1.91  
    1.92          if (status == PEP_STATUS_OK && expired) {
    1.93 @@ -633,12 +633,12 @@
    1.94          }
    1.95      }
    1.96  
    1.97 -    return ERROR(PEP_STATUS_OK);
    1.98 +    return ADD_TO_LOG(PEP_STATUS_OK);
    1.99  }
   1.100  
   1.101  DYNAMIC_API PEP_STATUS myself(PEP_SESSION session, pEp_identity * identity)
   1.102  {
   1.103 -    return ERROR(_myself(session, identity, true, false));
   1.104 +    return ADD_TO_LOG(_myself(session, identity, true, false));
   1.105  }
   1.106  
   1.107  DYNAMIC_API PEP_STATUS register_examine_function(
     2.1 --- a/src/message_api.c	Wed Jun 14 18:52:55 2017 +0200
     2.2 +++ b/src/message_api.c	Wed Jun 14 18:58:09 2017 +0200
     2.3 @@ -1104,14 +1104,14 @@
     2.4      assert(enc_format != PEP_enc_none);
     2.5  
     2.6      if (!(session && src && dst && enc_format != PEP_enc_none))
     2.7 -        return ERROR(PEP_ILLEGAL_VALUE);
     2.8 +        return ADD_TO_LOG(PEP_ILLEGAL_VALUE);
     2.9  
    2.10      if (src->dir == PEP_dir_incoming)
    2.11 -        return ERROR(PEP_ILLEGAL_VALUE);
    2.12 +        return ADD_TO_LOG(PEP_ILLEGAL_VALUE);
    2.13  
    2.14      determine_encryption_format(src);
    2.15      if (src->enc_format != PEP_enc_none)
    2.16 -        return ERROR(PEP_ILLEGAL_VALUE);
    2.17 +        return ADD_TO_LOG(PEP_ILLEGAL_VALUE);
    2.18  
    2.19      *dst = NULL;
    2.20  
    2.21 @@ -1218,7 +1218,7 @@
    2.22          free_stringlist(keys);
    2.23          if (!session->passive_mode && !(flags & PEP_encrypt_flag_force_no_attached_key))
    2.24              attach_own_key(session, src);
    2.25 -        return ERROR(PEP_UNENCRYPTED);
    2.26 +        return ADD_TO_LOG(PEP_UNENCRYPTED);
    2.27      }
    2.28      else {
    2.29          msg = clone_to_empty_message(src);
    2.30 @@ -1275,7 +1275,7 @@
    2.31      }
    2.32  
    2.33      *dst = msg;
    2.34 -    return ERROR(status);
    2.35 +    return ADD_TO_LOG(status);
    2.36  
    2.37  enomem:
    2.38      status = PEP_OUT_OF_MEMORY;
    2.39 @@ -1284,7 +1284,7 @@
    2.40      free_stringlist(keys);
    2.41      free_message(msg);
    2.42  
    2.43 -    return ERROR(status);
    2.44 +    return ADD_TO_LOG(status);
    2.45  }
    2.46  
    2.47  DYNAMIC_API PEP_STATUS encrypt_message_for_self(
    2.48 @@ -1306,14 +1306,14 @@
    2.49      assert(enc_format != PEP_enc_none);
    2.50  
    2.51      if (!(session && src && dst && enc_format != PEP_enc_none))
    2.52 -        return ERROR(PEP_ILLEGAL_VALUE);
    2.53 +        return ADD_TO_LOG(PEP_ILLEGAL_VALUE);
    2.54  
    2.55      if (src->dir == PEP_dir_incoming)
    2.56 -        return ERROR(PEP_ILLEGAL_VALUE);
    2.57 +        return ADD_TO_LOG(PEP_ILLEGAL_VALUE);
    2.58  
    2.59      determine_encryption_format(src);
    2.60      if (src->enc_format != PEP_enc_none)
    2.61 -        return ERROR(PEP_ILLEGAL_VALUE);
    2.62 +        return ADD_TO_LOG(PEP_ILLEGAL_VALUE);
    2.63  
    2.64      status = myself(session, target_id);
    2.65      if (status != PEP_STATUS_OK)
    2.66 @@ -1394,7 +1394,7 @@
    2.67      free_stringlist(keys);
    2.68      free_message(msg);
    2.69  
    2.70 -    return ERROR(status);
    2.71 +    return ADD_TO_LOG(status);
    2.72  }
    2.73  
    2.74  static bool is_a_pEpmessage(const message *msg)
    2.75 @@ -1669,7 +1669,7 @@
    2.76      assert(flags);
    2.77  
    2.78      if (!(session && src && dst && keylist && rating && flags))
    2.79 -        return ERROR(PEP_ILLEGAL_VALUE);
    2.80 +        return ADD_TO_LOG(PEP_ILLEGAL_VALUE);
    2.81  
    2.82      *flags = 0;
    2.83  
    2.84 @@ -1680,7 +1680,7 @@
    2.85      // we would need to check signature
    2.86      status = _update_identity_for_incoming_message(session, src);
    2.87      if(status != PEP_STATUS_OK)
    2.88 -        return ERROR(status);
    2.89 +        return ADD_TO_LOG(status);
    2.90  
    2.91      // Get detached signature, if any
    2.92      bloblist_t* detached_sig = NULL;
    2.93 @@ -1714,7 +1714,7 @@
    2.94                                  PEP_decrypt_flag_consume;
    2.95                  }
    2.96                  else if (status != PEP_STATUS_OK) {
    2.97 -                    return ERROR(status);
    2.98 +                    return ADD_TO_LOG(status);
    2.99                  }
   2.100              }
   2.101              
   2.102 @@ -1746,7 +1746,7 @@
   2.103                  }
   2.104              }
   2.105              
   2.106 -            return ERROR(PEP_UNENCRYPTED);
   2.107 +            return ADD_TO_LOG(PEP_UNENCRYPTED);
   2.108  
   2.109          case PEP_enc_PGP_MIME:
   2.110              ctext = src->attachments->next->value;
   2.111 @@ -2117,7 +2117,7 @@
   2.112      free_message(msg);
   2.113      free_stringlist(_keylist);
   2.114  
   2.115 -    return ERROR(status);
   2.116 +    return ADD_TO_LOG(status);
   2.117  }
   2.118  
   2.119  DYNAMIC_API PEP_STATUS decrypt_message(
   2.120 @@ -2166,7 +2166,7 @@
   2.121  
   2.122      free_identity_list(private_il);
   2.123  
   2.124 -    return ERROR(status);
   2.125 +    return ADD_TO_LOG(status);
   2.126  }
   2.127  
   2.128  static void _max_comm_type_from_identity_list(
   2.129 @@ -2207,10 +2207,10 @@
   2.130      assert(rating);
   2.131  
   2.132      if (!(session && msg && rating))
   2.133 -        return ERROR(PEP_ILLEGAL_VALUE);
   2.134 +        return ADD_TO_LOG(PEP_ILLEGAL_VALUE);
   2.135  
   2.136      if (msg->dir != PEP_dir_outgoing)
   2.137 -        return ERROR(PEP_ILLEGAL_VALUE);
   2.138 +        return ADD_TO_LOG(PEP_ILLEGAL_VALUE);
   2.139  
   2.140      *rating = PEP_rating_undefined;
   2.141  
   2.142 @@ -2401,7 +2401,7 @@
   2.143          free (XORed_fpr);
   2.144          
   2.145      the_end:
   2.146 -    return ERROR(status);
   2.147 +    return ADD_TO_LOG(status);
   2.148  }
   2.149  
   2.150  DYNAMIC_API PEP_STATUS get_message_trustwords(
   2.151 @@ -2487,7 +2487,7 @@
   2.152  
   2.153      if (status != PEP_STATUS_OK) {
   2.154          free_identity(partner);
   2.155 -        return ERROR(status);
   2.156 +        return ADD_TO_LOG(status);
   2.157      }
   2.158     
   2.159      // Find own identity corresponding to given account address.
   2.160 @@ -2500,7 +2500,7 @@
   2.161  
   2.162      if (status != PEP_STATUS_OK) {
   2.163          free_identity(stored_identity);
   2.164 -        return ERROR(status);
   2.165 +        return ADD_TO_LOG(status);
   2.166      }
   2.167  
   2.168      // get the trustwords
   2.169 @@ -2509,7 +2509,7 @@
   2.170                              partner, received_by, 
   2.171                              lang, words, &wsize, full);
   2.172  
   2.173 -    return ERROR(status);
   2.174 +    return ADD_TO_LOG(status);
   2.175  }
   2.176  
   2.177  DYNAMIC_API PEP_STATUS MIME_decrypt_message(
   2.178 @@ -2560,14 +2560,14 @@
   2.179      {
   2.180          free(tmp_msg);
   2.181          free(dec_msg);
   2.182 -        return ERROR(decrypt_status);
   2.183 +        return ADD_TO_LOG(decrypt_status);
   2.184      }
   2.185      
   2.186  pep_error:
   2.187      free_message(tmp_msg);
   2.188      free_message(dec_msg);
   2.189  
   2.190 -    return ERROR(status);
   2.191 +    return ADD_TO_LOG(status);
   2.192  }
   2.193  
   2.194  
   2.195 @@ -2612,7 +2612,7 @@
   2.196      free_message(tmp_msg);
   2.197      free_message(enc_msg);
   2.198  
   2.199 -    return ERROR(status);
   2.200 +    return ADD_TO_LOG(status);
   2.201  
   2.202  }
   2.203  
   2.204 @@ -2656,7 +2656,7 @@
   2.205      free_message(tmp_msg);
   2.206      free_message(enc_msg);
   2.207  
   2.208 -    return ERROR(status);
   2.209 +    return ADD_TO_LOG(status);
   2.210  }
   2.211  
   2.212  static PEP_rating string_to_rating(const char * rating)
   2.213 @@ -2749,7 +2749,7 @@
   2.214      assert(rating);
   2.215  
   2.216      if (!(session && msg && rating))
   2.217 -        return ERROR(PEP_ILLEGAL_VALUE);
   2.218 +        return ADD_TO_LOG(PEP_ILLEGAL_VALUE);
   2.219  
   2.220      *rating = PEP_rating_undefined;
   2.221  
   2.222 @@ -2760,7 +2760,7 @@
   2.223                  goto got_rating;
   2.224              }
   2.225          }
   2.226 -        return ERROR(PEP_ILLEGAL_VALUE);
   2.227 +        return ADD_TO_LOG(PEP_ILLEGAL_VALUE);
   2.228      }
   2.229  
   2.230  got_rating:
   2.231 @@ -2777,7 +2777,7 @@
   2.232                  goto got_keylist;
   2.233              }
   2.234          }
   2.235 -        return ERROR(PEP_ILLEGAL_VALUE);
   2.236 +        return ADD_TO_LOG(PEP_ILLEGAL_VALUE);
   2.237      }
   2.238  got_keylist:
   2.239  
   2.240 @@ -2796,5 +2796,5 @@
   2.241      if (must_free_keylist)
   2.242          free_stringlist(_keylist);
   2.243  
   2.244 -    return ERROR(status);
   2.245 +    return ADD_TO_LOG(status);
   2.246  }
     3.1 --- a/src/message_api.h	Wed Jun 14 18:52:55 2017 +0200
     3.2 +++ b/src/message_api.h	Wed Jun 14 18:58:09 2017 +0200
     3.3 @@ -47,11 +47,14 @@
     3.4  //
     3.5  //  return value:
     3.6  //      PEP_STATUS_OK                   on success
     3.7 -//		PEP_KEY_NOT_FOUND	            at least one of the receipient keys
     3.8 -//		                                could not be found
     3.9 -//		PEP_KEY_HAS_AMBIG_NAME          at least one of the receipient keys has
    3.10 -//		                                an ambiguous name
    3.11 -//		PEP_GET_KEY_FAILED		        cannot retrieve key
    3.12 +//      PEP_KEY_NOT_FOUND	            at least one of the receipient keys
    3.13 +//                                      could not be found
    3.14 +//      PEP_KEY_HAS_AMBIG_NAME          at least one of the receipient keys has
    3.15 +//                                      an ambiguous name
    3.16 +//      PEP_GET_KEY_FAILED		        cannot retrieve key
    3.17 +//      PEP_UNENCRYPTED                 no recipients with usable key, 
    3.18 +//                                      message is left unencrypted,
    3.19 +//                                      and key is attached to it
    3.20  //
    3.21  //	caveat:
    3.22  //	    the ownershop of src remains with the caller
     4.1 --- a/src/pEpEngine.c	Wed Jun 14 18:52:55 2017 +0200
     4.2 +++ b/src/pEpEngine.c	Wed Jun 14 18:58:09 2017 +0200
     4.3 @@ -886,7 +886,7 @@
     4.4      } while (result == SQLITE_BUSY);
     4.5      sqlite3_reset(session->log);
     4.6  
     4.7 -    return ERROR(status);
     4.8 +    return ADD_TO_LOG(status);
     4.9  }
    4.10  
    4.11  DYNAMIC_API PEP_STATUS log_service(
    4.12 @@ -1988,7 +1988,7 @@
    4.13      status = PEP_OUT_OF_MEMORY;
    4.14  
    4.15  the_end:
    4.16 -    return ERROR(status);
    4.17 +    return ADD_TO_LOG(status);
    4.18  }
    4.19  
    4.20  DYNAMIC_API PEP_STATUS get_languagelist(
     5.1 --- a/src/pEp_internal.h	Wed Jun 14 18:52:55 2017 +0200
     5.2 +++ b/src/pEp_internal.h	Wed Jun 14 18:58:09 2017 +0200
     5.3 @@ -316,9 +316,9 @@
     5.4  
     5.5  #ifdef DEBUG_ERRORSTACK
     5.6      PEP_STATUS session_add_error(PEP_SESSION session, const char* file, unsigned line, PEP_STATUS status);
     5.7 -    #define ERROR(status)   session_add_error(session, __FILE__, __LINE__, (status))
     5.8 -    #define GOTO(label)     do{ (void)session_add_error(session, __FILE__, __LINE__, status); goto label; }while(0)
     5.9 +    #define ADD_TO_LOG(status)   session_add_error(session, __FILE__, __LINE__, (status))
    5.10 +    #define GOTO(label)          do{ (void)session_add_error(session, __FILE__, __LINE__, status); goto label; }while(0)
    5.11  #else
    5.12 -    #define ERROR(status)   (status)
    5.13 -    #define GOTO(label)     goto label
    5.14 +    #define ADD_TO_LOG(status)   (status)
    5.15 +    #define GOTO(label)          goto label
    5.16  #endif