diff --git a/configure.ac b/configure.ac index 7b4e2adc..ff016ce9 100644 --- a/configure.ac +++ b/configure.ac @@ -652,13 +652,6 @@ AS_IF([test "X$with_libuuid" != "Xno"],[ CFLAGS="$UUID_CFLAGS $CFLAGS" AC_DEFINE([HAVE_LIBUUID], [1], [Define if using libuuid.]) ], [ - AC_CHECK_HEADER(uuid.h, - AC_CHECK_FUNC(uuid, uuid_create, - [AC_DEFINE([HAVE_UUID_CREATE], 1, - [Define if uuid_create is available.]) - ]) - ) - AC_CHECK_HEADER(uuid/uuid.h, AC_CHECK_LIB(uuid, uuid_generate, [LIBS="${LIBS} -luuid" @@ -669,6 +662,12 @@ AS_IF([test "X$with_libuuid" != "Xno"],[ ]) ]) +AC_CHECK_HEADER(uuid.h, + AC_CHECK_FUNC(uuid_create, + [AC_DEFINE([HAVE_UUID_CREATE], 1, [Define if uuid_create is available.])] + ) +) + dnl dnl Check for PCRE dnl diff --git a/src/warc.c b/src/warc.c index 5bdda1b5..49598369 100644 --- a/src/warc.c +++ b/src/warc.c @@ -600,26 +600,34 @@ warc_timestamp (char *timestamp, size_t timestamp_size) return timestamp; } -#if HAVE_LIBUUID || HAVE_UUID_CREATE /* Fills urn_str with a UUID in the format required for the WARC-Record-Id header. The string will be 47 characters long. */ +#if HAVE_LIBUUID void warc_uuid_str (char *urn_str) { char uuid_str[37]; - uuid_t record_id; -#if HAVE_UUID_CREATE - uuid_create (&record_id, NULL); - uuid_to_string (&record_id, &uuid_str, NULL); -#else + uuid_generate (record_id); uuid_unparse (record_id, uuid_str); -#endif sprintf (urn_str, "", uuid_str); } +#elif HAVE_UUID_CREATE +void +warc_uuid_str (char *urn_str) +{ + char *uuid_str; + uuid_t record_id; + + uuid_create (&record_id, NULL); + uuid_to_string (&record_id, &uuid_str, NULL); + + sprintf (urn_str, "", uuid_str); + xfree (uuid_str); +} #else /* Fills urn_str with a UUID based on random numbers in the format required for the WARC-Record-Id header.