remove typedef from struct recptypes
[citadel.git] / citadel / modules / blog / serv_blog.c
index fb95d613b4a1fc2a2df963a686a31f15d6bb15d0..98bc938d3c6113b53e2e13ff9035daee10e9ce74 100644 (file)
 #include <errno.h>
 #include <ctype.h>
 #include <sys/types.h>
-
-#if TIME_WITH_SYS_TIME
-# include <sys/time.h>
-# include <time.h>
-#else
-# if HAVE_SYS_TIME_H
-#  include <sys/time.h>
-# else
-#  include <time.h>
-# endif
-#endif
-
+#include <time.h>
 #include <sys/wait.h>
 #include <string.h>
 #include <limits.h>
@@ -62,7 +51,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, struct recptypes *recp) {
 
        /* Only run this hook for blog rooms */
        if (CC->room.QRdefaultview != VIEW_BLOG) {
@@ -72,20 +61,18 @@ int blog_upload_beforesave(struct CtdlMessage *msg) {
        /* 
         * If the message doesn't have an EUID, give it one.
         */
-       if (msg->cm_fields['E'] == NULL)
+       if (CM_IsEmpty(msg, eExclusiveID))
        {
-               char uuid[BLOG_EUIDBUF_SIZE];
+               char uuid[SIZ];
                generate_uuid(uuid);
-               msg->cm_fields['E'] = 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['E']) >= BLOG_EUIDBUF_SIZE) {
-               msg->cm_fields['E'][BLOG_EUIDBUF_SIZE-1] = 0;
-       }
-
+       CM_CutFieldAt(msg, eExclusiveID, BLOG_EUIDBUF_SIZE - 1);
+       
        /* Now allow the save to complete. */
        return(0);
 }