summaryrefslogtreecommitdiff
path: root/misc
diff options
context:
space:
mode:
authorpquerna <pquerna@13f79535-47bb-0310-9956-ffa450edef68>2004-11-22 20:14:25 +0000
committerpquerna <pquerna@13f79535-47bb-0310-9956-ffa450edef68>2004-11-22 20:14:25 +0000
commit2ec247566ac0709aada90b7841641c6c555fab3c (patch)
treefd83b96066fedff0d7455778a074aed8d08169e9 /misc
parentd44e9b2a7bd06e690bdddedc766a63d085cd288d (diff)
downloadlibapr-2ec247566ac0709aada90b7841641c6c555fab3c.tar.gz
Use uuid_generate() and uuid_create() for the apr_os_uuid_get() interface
on platforms that support them. Tested On: Linux 2.6 (libuuid) and FreeBSD 5.2.1 (libc has uuid_create) git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@106214 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'misc')
-rw-r--r--misc/unix/rand.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/misc/unix/rand.c b/misc/unix/rand.c
index 894022f6d..0bdd3722f 100644
--- a/misc/unix/rand.c
+++ b/misc/unix/rand.c
@@ -39,6 +39,37 @@
#define SHUT_RDWR 2
#endif
+#if HAVE_UUID_CREATE
+
+#include <uuid.h>
+
+APR_DECLARE(apr_status_t) apr_os_uuid_get(unsigned char *uuid_data)
+{
+ uuid_t g;
+
+ uuid_create(&g, NULL);
+
+ memcpy( (void*)uuid_data, (const void *)&g, sizeof( uuid_t ) );
+
+ return APR_SUCCESS;
+}
+
+#elif HAVE_LIBUUID
+
+#include <uuid/uuid.h>
+
+APR_DECLARE(apr_status_t) apr_os_uuid_get(unsigned char *uuid_data)
+{
+ uuid_t g;
+
+ uuid_generate(g);
+
+ memcpy((void*)uuid_data, (const void *)g, sizeof( uuid_t ) );
+
+ return APR_SUCCESS;
+}
+#endif
+
#if APR_HAS_RANDOM
APR_DECLARE(apr_status_t) apr_generate_random_bytes(unsigned char *buf,