/*
* Support for blog rooms
*
- * Copyright (c) 1999-2010 by the citadel.org team
+ * Copyright (c) 1999-2011 by the citadel.org team
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
+ * This program is open source software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as published
+ * by the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "sysdep.h"
#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>
#include "ctdl_module.h"
/*
- * sd sdhfksdjhkjsdfhk jsdhfkjsdfhkjsd hkfjhsdkjfhsdkjfhksdjfhsd
+ * 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) {
- char buf[SIZ];
+int blog_upload_beforesave(struct CtdlMessage *msg, recptypes *recp) {
/* Only run this hook for blog rooms */
if (CC->room.QRdefaultview != VIEW_BLOG) {
/*
* If the message doesn't have an EUID, give it one.
*/
- if (msg->cm_fields['E'] != NULL)
+ if (CM_IsEmpty(msg, eExclusiveID))
{
- generate_uuid(buf);
- msg->cm_fields['E'] = strdup(buf);
+ char uuid[SIZ];
+ generate_uuid(uuid);
+ CM_SetField(msg, eExclusiveID, uuid, strlen(uuid));
}
+ /*
+ * We also want to define a maximum length, whether we generated it or not.
+ */
+ CM_CutFieldAt(msg, eExclusiveID, BLOG_EUIDBUF_SIZE - 1);
+
/* Now allow the save to complete. */
return(0);
}