]> code.citadel.org Git - citadel.git/blobdiff - citadel/modules/blog/serv_blog.c
Convert CtdlMessages to respect cm_lengths[]
[citadel.git] / citadel / modules / blog / serv_blog.c
index 4424d46b89d255f5f07a8eae9b9ae51a1eff1b9f..0402e0190e650c6b4e01a79f3e6d38978a188a9b 100644 (file)
@@ -62,7 +62,7 @@
  * Pre-save hook for saving a message in a blog room.
  * (Do we want to only do this for top-level messages?)
  */
-int blog_upload_beforesave(struct CtdlMessage *msg) {
+int blog_upload_beforesave(struct CtdlMessage *msg, recptypes *recp) {
 
        /* Only run this hook for blog rooms */
        if (CC->room.QRdefaultview != VIEW_BLOG) {
@@ -72,20 +72,18 @@ int blog_upload_beforesave(struct CtdlMessage *msg) {
        /* 
         * If the message doesn't have an EUID, give it one.
         */
-       if (msg->cm_fields[eExclusiveID] == NULL)
+       if (CM_IsEmpty(msg, eExclusiveID))
        {
-               char uuid[BLOG_EUIDBUF_SIZE];
+               char uuid[SIZ];
                generate_uuid(uuid);
-               msg->cm_fields[eExclusiveID] = strdup(uuid);
+               CM_SetField(msg, eExclusiveID, uuid, strlen(uuid));
        }
 
        /*
         * We also want to define a maximum length, whether we generated it or not.
         */
-       else if (strlen(msg->cm_fields[eExclusiveID]) >= BLOG_EUIDBUF_SIZE) {
-               msg->cm_fields[eExclusiveID][BLOG_EUIDBUF_SIZE-1] = 0;
-       }
-
+       CM_CutFieldAt(msg, eExclusiveID, BLOG_EUIDBUF_SIZE - 1);
+       
        /* Now allow the save to complete. */
        return(0);
 }