Reinstated the use of EUID/UUID in blog posts; however this time they are not being...
authorArt Cancro <ajc@uncensored.citadel.org>
Wed, 25 May 2011 22:13:34 +0000 (18:13 -0400)
committerWilfried Goesgens <dothebart@citadel.org>
Sun, 4 Sep 2011 20:53:41 +0000 (20:53 +0000)
We really just need them so we can do uuid tags in the feed.

citadel/euidindex.c
citadel/modules/blog/serv_blog.c
libcitadel/lib/libcitadel.h
libcitadel/lib/tools.c

index 8bad12925557f072c6b713397337121624e0e7f5..dbc89adaa6c8153cade0153a8cfbf74780b88632 100644 (file)
@@ -74,6 +74,7 @@ int DoesThisRoomNeedEuidIndexing(struct ctdlroom *qrbuf) {
                case VIEW_TASKS:        return(1);
                case VIEW_NOTES:        return(1);
                case VIEW_WIKI:         return(1);
+               case VIEW_BLOG:         return(1);
        }
        
        return(0);
index 6997a057e48548fd2597b7691900ce616318d4dd..fb95d613b4a1fc2a2df963a686a31f15d6bb15d0 100644 (file)
@@ -1,11 +1,11 @@
 /*
  * 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,
@@ -15,7 +15,7 @@
  *
  * 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 "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];
 
        /* Only run this hook for blog rooms */
        if (CC->room.QRdefaultview != VIEW_BLOG) {
@@ -72,10 +72,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 (msg->cm_fields['E'] == NULL)
        {
-               generate_uuid(buf);
-               msg->cm_fields['E'] = strdup(buf);
+               char uuid[BLOG_EUIDBUF_SIZE];
+               generate_uuid(uuid);
+               msg->cm_fields['E'] = strdup(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;
        }
 
        /* Now allow the save to complete. */
index f47c4a24106f9c6b998563a9355be1c5a5aeee95..13737c39c797b6c2547f8d0cc402558a133a2f90 100644 (file)
@@ -89,6 +89,7 @@ typedef enum _room_views {
        VIEW_MAX
 } ROOM_VIEWS;
 
+#define BLOG_EUIDBUF_SIZE      40
 
 #ifndef IsEmptyStr
 #define IsEmptyStr(a) ((a)[0] == '\0')
index db8fe3af8f2809f79c1b78808c86bd547a18d7fd..0c012e7955e184d128b589ad547b1bf645ebb767 100644 (file)
@@ -858,8 +858,11 @@ char *strcpy(char *dest, const char *src) {
  * Generate a new, globally unique UID parameter for a calendar etc. object
  */
 void generate_uuid(char *buf) {
-       static int seq = 0;
+       static int seq = (-1);
 
+       if (seq == (-1)) {
+               seq = (int)rand();
+       }
        ++seq;
        seq = (seq % 0x0FFF) ;