]> code.citadel.org Git - citadel.git/commitdiff
generate_uuid() now generates more or less DCE-compliant uuid's
authorArt Cancro <ajc@uncensored.citadel.org>
Wed, 6 Apr 2011 19:38:27 +0000 (15:38 -0400)
committerArt Cancro <ajc@uncensored.citadel.org>
Wed, 6 Apr 2011 19:38:27 +0000 (15:38 -0400)
libcitadel/lib/tools.c

index 4a8eb6baaf108b426f256b5c6194599f2dce4754..db8fe3af8f2809f79c1b78808c86bd547a18d7fd 100644 (file)
@@ -860,10 +860,15 @@ char *strcpy(char *dest, const char *src) {
 void generate_uuid(char *buf) {
        static int seq = 0;
 
-       sprintf(buf, "%lx-%lx-%x",
-               time(NULL),
+       ++seq;
+       seq = (seq % 0x0FFF) ;
+
+       sprintf(buf, "%08lx-%04lx-4%03x-a%03x-%012lx",
+               (long)time(NULL),
                (long)getpid(),
-               (seq++)
+               seq,
+               seq,
+               (long)rand()
        );
 }