summaryrefslogtreecommitdiff
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
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.
-rw-r--r--configure.ac15
-rw-r--r--src/sm_genid.c25
2 files changed, 32 insertions, 8 deletions
diff --git a/configure.ac b/configure.ac
index 9730b70..cf36193 100644
--- a/configure.ac
+++ b/configure.ac
@@ -42,12 +42,15 @@ XTRANS_CONNECTION_FLAGS
AC_ARG_WITH(libuuid, AC_HELP_STRING([--with-libuuid], [Build with libuuid support for client IDs]))
-if test x"$with_libuuid" != xno; then
- PKG_CHECK_MODULES(LIBUUID, uuid, [HAVE_LIBUUID=yes], [HAVE_LIBUUID=no])
-fi
-if test x"$with_libuuid" = xyes && test x"$HAVE_LIBUUID" = xno; then
- AC_MSG_ERROR([requested libuuid support but uuid.pc not found])
-fi
+AC_CHECK_FUNCS([uuid_create], [], [
+ if test x"$with_libuuid" != xno && test x"$have_system_uuid" != xyes; then
+ PKG_CHECK_MODULES(LIBUUID, uuid, [HAVE_LIBUUID=yes], [HAVE_LIBUUID=no])
+ fi
+ if test x"$with_libuuid" = xyes && test x"$HAVE_LIBUUID" = xno; then
+ AC_MSG_ERROR([requested libuuid support but uuid.pc not found])
+ fi
+])
+
AM_CONDITIONAL(WITH_LIBUUID, test x"$HAVE_LIBUUID" = xyes)
XORG_RELEASE_VERSION
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;