add utility function to set / replace cm_flield entries.
authorWilfried Goesgens <dothebart@citadel.org>
Sun, 17 Feb 2013 16:22:05 +0000 (17:22 +0100)
committerWilfried Goesgens <dothebart@citadel.org>
Sun, 17 Feb 2013 16:22:05 +0000 (17:22 +0100)
citadel/msgbase.c
citadel/msgbase.h

index 0b8e8ba9194912f4f63c707949b1f8d6f00e3dbf..a125d01e36d9bed841a1732550c5c529c2a037b3 100644 (file)
@@ -116,6 +116,15 @@ char *msgkeys[] = {
        NULL    /* Z */
 };
 
+void CtdlMsgSetCM_Fields(struct CtdlMessage *Msg, const char which, const char *buf, long length)
+{
+       if (Msg->cm_fields[which] != NULL)
+               free (Msg->cm_fields[which]);
+       Msg->cm_fields[which] = malloc(length + 1);
+       memcpy(Msg->cm_fields[which], buf, length);
+       Msg->cm_fields[which][length] = '\0';
+}
+
 /*
  * This function is self explanatory.
  * (What can I say, I'm in a weird mood today...)
index 45a7f765cac64776a0122c4cb1ba1e8c4754439d..c051f490e31f63ef53494853962a32a2fe7cc84c 100644 (file)
@@ -161,6 +161,7 @@ void CtdlWriteObject(char *req_room,                        /* Room to stuff it in */
 );
 struct CtdlMessage *CtdlFetchMessage(long msgnum, int with_body);
 struct CtdlMessage * CtdlDuplicateMessage(struct CtdlMessage *OrgMsg);
+void CtdlMsgSetCM_Fields(struct CtdlMessage *Msg, const char which, const char *buf, long length);
 void CtdlFreeMessage(struct CtdlMessage *msg);
 void CtdlFreeMessageContents(struct CtdlMessage *msg);
 void serialize_message(struct ser_ret *, struct CtdlMessage *);