X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=libcitadel%2Flib%2Ftools.c;h=0c012e7955e184d128b589ad547b1bf645ebb767;hb=d9666dbf7dd0623cdf4335ba3bae3776c592050b;hp=4a8eb6baaf108b426f256b5c6194599f2dce4754;hpb=1dd7c0f770f23bbc4f65de406deb75eb059b417f;p=citadel.git diff --git a/libcitadel/lib/tools.c b/libcitadel/lib/tools.c index 4a8eb6baa..0c012e795 100644 --- a/libcitadel/lib/tools.c +++ b/libcitadel/lib/tools.c @@ -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() ); }