Add support for uuid_generate/uuid_unparse

This commit is contained in:
Kurt Zeilenga 2007-03-02 07:36:23 +00:00
parent 2d54d689f9
commit 0a1301bc6b
2 changed files with 20 additions and 2 deletions

View file

@ -1000,6 +1000,15 @@ if test $ac_cv_header_sys_uuid_h = yes ; then
fi fi
fi fi
dnl Look for uuid_generate
if test $have_uuid = no ; then
AC_CHECK_HEADERS(uuid/uuid.h)
if test $ac_cv_header_uuid_uuid_h = yes ; then
AC_CHECK_FUNCS( uuid_generate )
have_uuid=$ac_cv_func_uuid_generate
fi
fi
dnl For windows, check for the need of RPCRT for UUID function support dnl For windows, check for the need of RPCRT for UUID function support
if test $have_uuid = no ; then if test $have_uuid = no ; then
AC_MSG_CHECKING(to see if -lrpcrt4 is needed for win32 UUID support) AC_MSG_CHECKING(to see if -lrpcrt4 is needed for win32 UUID support)

View file

@ -41,6 +41,8 @@
#ifdef HAVE_UUID_TO_STR #ifdef HAVE_UUID_TO_STR
# include <sys/uuid.h> # include <sys/uuid.h>
#elif defined( HAVE_UUID_GENERATE )
# include <uuid/uuid.h>
#elif defined( _WIN32 ) #elif defined( _WIN32 )
# include <rpc.h> # include <rpc.h>
#else #else
@ -56,7 +58,7 @@
#include <lutil.h> #include <lutil.h>
/* not needed for Windows */ /* not needed for Windows */
#if !defined(HAVE_UUID_TO_STR) && !defined(_WIN32) #if !defined(HAVE_UUID_TO_STR) && !defined(HAVE_UUID_GENERATE) && !defined(_WIN32)
static unsigned char * static unsigned char *
lutil_eaddr( void ) lutil_eaddr( void )
{ {
@ -251,7 +253,7 @@ mul64ll(unsigned long i1, unsigned long i2)
#endif /* ULONG_MAX >= 64 bits || HAVE_LONG_LONG */ #endif /* ULONG_MAX >= 64 bits || HAVE_LONG_LONG */
#endif /* !HAVE_UUID_TO_STR && !_WIN32 */ #endif /* !HAVE_UUID_TO_STR && !HAVE_UUID_GENERATE && !_WIN32 */
/* /*
** All we really care about is an ISO UUID string. The format of a UUID is: ** All we really care about is an ISO UUID string. The format of a UUID is:
@ -298,6 +300,13 @@ lutil_uuidstr( char *buf, size_t len )
return l; return l;
#elif defined( HAVE_UUID_GENERATE )
uuid_t uu;
uuid_generate( uu );
uuid_unparse_lower( uu, buf );
return strlen( buf );
#elif defined( _WIN32 ) #elif defined( _WIN32 )
UUID uuid; UUID uuid;
unsigned char *uuidstr; unsigned char *uuidstr;