Update of /cvsroot/monetdb/sql/src/backends/monet5/merovingian
In directory sfp-cvsdas-1.v30.ch3.sourceforge.com:/tmp/cvs-serv15369

Modified Files:
        utils.c utils.h 
Log Message:
Last commit from the Dacha.  Code will never be the same again...

Add generateUUID() function that has a fallback implementation in case
no system uuid functionality is available (or found).



Index: utils.c
===================================================================
RCS file: /cvsroot/monetdb/sql/src/backends/monet5/merovingian/utils.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- utils.c     6 Nov 2009 13:57:30 -0000       1.19
+++ utils.c     7 Dec 2009 13:53:41 -0000       1.20
@@ -314,4 +314,37 @@
        return(NULL);
 }
 
+generateUUID(void)
+{
+#ifdef HAVE_UUID_UUID_H
+# ifdef UUID_PRINTABLE_STRING_LENGTH
+       /* Solaris */
+       char out[UUID_PRINTABLE_STRING_LENGTH];
+# else
+       char out[37];
+# endif
+       uuid_t uuid;
+       uuid_generate(uuid);
+       uuid_unparse(uuid, out);
+#else
+       /* try to do some pseudo interesting stuff, and stash it in the
+        * format of an UUID to at least return some uniform answer */
+       char out[37];
+       char *p = out;
+       short seed;
+
+       /* generate something like this:
+        * cefa7a9c-1dd2-11b2-8350-880020adbeef ("%08x-%04x-%04x-%04x-%012x") */
+       p += snprintf(p, 5, "%04x", rand() % 65536);
+       p += snprintf(p, 6, "%04x-", rand() % 65536);
+       p += snprintf(p, 6, "%04x-", rand() % 65536);
+       p += snprintf(p, 6, "%04x-", rand() % 65536);
+       p += snprintf(p, 6, "%04x-", rand() % 65536);
+       p += snprintf(p, 5, "%04x", rand() % 65536);
+       p += snprintf(p, 5, "%04x", rand() % 65536);
+       p += snprintf(p, 5, "%04x", rand() % 65536);
+#endif
+       return(strdup(out));
+}
+
 /* vim:set ts=4 sw=4 noexpandtab: */

Index: utils.h
===================================================================
RCS file: /cvsroot/monetdb/sql/src/backends/monet5/merovingian/utils.h,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- utils.h     9 Oct 2009 15:42:53 -0000       1.11
+++ utils.h     7 Dec 2009 13:53:42 -0000       1.12
@@ -47,6 +47,7 @@
 void abbreviateString(char *ret, const char *in, size_t width);
 void generateSalt(char *buf[], unsigned int len);
 char *generatePassphraseFile(char *path);
+char *generateUUID(void);
 
 #endif
 


------------------------------------------------------------------------------
Join us December 9, 2009 for the Red Hat Virtual Experience,
a free event focused on virtualization and cloud computing. 
Attend in-depth sessions from your desk. Your couch. Anywhere.
http://p.sf.net/sfu/redhat-sfdev2dev
_______________________________________________
Monetdb-sql-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-sql-checkins

Reply via email to