src/message.c
branchENGINE-423
changeset 2615 5cd3625e0d91
parent 1517 f29830f1c407
child 3884 49d25cfc873c
     1.1 --- a/src/message.c	Thu Apr 19 09:38:52 2018 +0200
     1.2 +++ b/src/message.c	Thu Apr 19 16:03:44 2018 +0200
     1.3 @@ -201,6 +201,81 @@
     1.4      return NULL;
     1.5  }
     1.6  
     1.7 +DYNAMIC_API void message_transfer(message* dst, message *src)
     1.8 +{
     1.9 +    assert(dst);
    1.10 +    assert(src);
    1.11 +
    1.12 +    dst->dir = src->dir;
    1.13 +    dst->rawmsg_ref = src->rawmsg_ref;
    1.14 +    dst->rawmsg_size = src->rawmsg_size;
    1.15 +    dst->refering_msg_ref = src->refering_msg_ref;
    1.16 +    dst->enc_format = src->enc_format;
    1.17 +
    1.18 +    /* Strings */
    1.19 +    free(dst->id);
    1.20 +    free(dst->shortmsg);
    1.21 +    free(dst->longmsg);
    1.22 +    free(dst->longmsg_formatted);
    1.23 +    free(dst->comments);
    1.24 +    dst->id = src->id;
    1.25 +    dst->shortmsg = src->shortmsg;
    1.26 +    dst->longmsg = src->longmsg;
    1.27 +    dst->longmsg_formatted = src->longmsg_formatted;
    1.28 +    dst->comments = src->comments;    
    1.29 +    src->id = src->shortmsg = src->longmsg = src->longmsg_formatted = NULL;
    1.30 +    src->comments = NULL;
    1.31 +    
    1.32 +    /* bloblists */
    1.33 +    free_bloblist(dst->attachments);
    1.34 +    dst->attachments = src->attachments;
    1.35 +    src->attachments = NULL;
    1.36 +    
    1.37 +    /* timestamps */
    1.38 +    free_timestamp(dst->sent);
    1.39 +    free_timestamp(dst->recv);
    1.40 +    dst->sent = src->sent;
    1.41 +    dst->recv = src->recv;
    1.42 +    src->sent = src->recv = NULL;
    1.43 +    
    1.44 +    /* identities */
    1.45 +    free_identity(dst->from);
    1.46 +    free_identity(dst->recv_by);
    1.47 +    dst->from = src->from;
    1.48 +    dst->recv_by = src->recv_by;
    1.49 +    src->from = src->recv_by = NULL;
    1.50 +    
    1.51 +    /* identity lists */
    1.52 +    free_identity_list(dst->to);
    1.53 +    free_identity_list(dst->cc);
    1.54 +    free_identity_list(dst->bcc);
    1.55 +    free_identity_list(dst->reply_to);
    1.56 +    dst->to = src->to;
    1.57 +    dst->cc = src->cc;
    1.58 +    dst->bcc = src->bcc;
    1.59 +    dst->reply_to = src->reply_to;
    1.60 +    src->to = src->cc = src->bcc = src->reply_to = NULL;
    1.61 +
    1.62 +    /* stringlists */
    1.63 +    free_stringlist(dst->references);
    1.64 +    free_stringlist(dst->keywords);
    1.65 +    free_stringlist(dst->in_reply_to);
    1.66 +    dst->references = src->references;
    1.67 +    dst->keywords = src->keywords;
    1.68 +    dst->in_reply_to = src->in_reply_to;
    1.69 +    src->references = src->keywords = src->in_reply_to = NULL;
    1.70 +
    1.71 +    /* message ref list */
    1.72 +    free_message_ref_list(dst->refered_by);
    1.73 +    dst->refered_by = src->refered_by;
    1.74 +    src->refered_by = NULL;
    1.75 +    
    1.76 +    /* stringpair lists */
    1.77 +    free_stringpair_list(dst->opt_fields);
    1.78 +    dst->opt_fields = src->opt_fields;
    1.79 +    src->opt_fields = NULL;
    1.80 +}
    1.81 +
    1.82  DYNAMIC_API message_ref_list *new_message_ref_list(message *msg)
    1.83  {
    1.84      message_ref_list *msg_list = calloc(1, sizeof(message_ref_list));
    1.85 @@ -266,4 +341,3 @@
    1.86          return message_ref_list_add(msg_list->next, msg);
    1.87      }
    1.88  }
    1.89 -