* 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()
);
}