merge in euid generation from master
authorWilfried Goesgens <dothebart@citadel.org>
Sun, 3 Jul 2011 22:34:03 +0000 (22:34 +0000)
committerWilfried Goesgens <dothebart@citadel.org>
Sun, 3 Jul 2011 22:34:03 +0000 (22:34 +0000)
libcitadel/lib/libcitadel.h
libcitadel/lib/tools.c

index 88ab8d72b4940253bc17179b5184fcc97bc40006..89fb4cee634561579cb50feb2a21a606ee2acbcf 100644 (file)
@@ -109,6 +109,7 @@ typedef enum _room_views {
        VIEW_MAX
 } ROOM_VIEWS;
 
+#define BLOG_EUIDBUF_SIZE      40
 
 #ifndef IsEmptyStr
 #define IsEmptyStr(a) ((a)[0] == '\0')
index 4a8eb6baaf108b426f256b5c6194599f2dce4754..0c012e7955e184d128b589ad547b1bf645ebb767 100644 (file)
@@ -858,12 +858,20 @@ 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);
 
-       sprintf(buf, "%lx-%lx-%x",
-               time(NULL),
+       if (seq == (-1)) {
+               seq = (int)rand();
+       }
+       ++seq;
+       seq = (seq % 0x0FFF) ;
+
+       sprintf(buf, "%08lx-%04lx-4%03x-a%03x-%012lx",
+               (long)time(NULL),
                (long)getpid(),
-               (seq++)
+               seq,
+               seq,
+               (long)rand()
        );
 }