summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDiego Elio 'Flameeyes' Pettenò <flameeyes@gmail.com>2009-05-16 01:01:39 +0200
committerAlan Coopersmith <alan.coopersmith@sun.com>2009-08-03 20:34:02 -0700
commit45720a2e266748ac15bc0544b56e035383695588 (patch)
tree002e8ce7f96a3170748297a02ecda978e6bb1ee0 /src
parent0389dbec3b738fa7e1dbef2b5317124b95bdfb20 (diff)
Use FreeBSD uuid functions when available.
If the system provide the uuid_create function assume building on FreeBSD or another OS with a compatible uuid interface. If that's the case, ignore libuuid and just use the system functions without extra deps.
Diffstat (limited to 'src')
-rw-r--r--src/sm_genid.c25
1 files changed, 23 insertions, 2 deletions
diff --git a/src/sm_genid.c b/src/sm_genid.c
index 391a10e..f6adda3 100644
--- a/src/sm_genid.c
+++ b/src/sm_genid.c
@@ -76,7 +76,9 @@ in this Software without prior written authorization from The Open Group.
#define TCPCONN
#endif
-#if defined(HAVE_LIBUUID)
+#if defined(HAVE_UUID_CREATE)
+#include <uuid.h>
+#elif defined(HAVE_LIBUUID)
#include <uuid/uuid.h>
#endif
@@ -84,7 +86,26 @@ in this Software without prior written authorization from The Open Group.
char *
SmsGenerateClientID(SmsConn smsConn)
{
-#if defined(HAVE_LIBUUID)
+#if defined(HAVE_UUID_CREATE)
+ char *id;
+ char **temp;
+ uuid_t uuid;
+ uint32_t status;
+
+ uuid_create(&uuid, &status);
+
+ uuid_to_string(&uuid, &temp, &status);
+
+ if ((id = malloc (strlen (temp) + 2)) != NULL)
+ {
+ id[1] = '2';
+ strcpy (id+1, temp);
+ }
+
+ free(temp);
+
+ return id;
+#elif defined(HAVE_LIBUUID)
char *id;
char temp[256];
uuid_t uuid;