diff --git a/ChangeLog b/ChangeLog index 29891b75..ff13471f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2014-06-22 Giuseppe Scrivano + + * configure.ac: Add check for uuid_create. + 2014-06-11 Giuseppe Scrivano * NEWS: Remove repeated word. diff --git a/configure.ac b/configure.ac index 029b2fed..abc92fb0 100644 --- a/configure.ac +++ b/configure.ac @@ -541,6 +541,12 @@ fi dnl dnl Check for UUID dnl +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, diff --git a/src/ChangeLog b/src/ChangeLog index f64ab766..a8fd4114 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,10 @@ +2014-06-22 Giuseppe Scrivano + + * warc.c [HAVE_UUID_CREATE]: Include + (warc_uuid_str) [HAVE_UUID_CREATE]: Use uuid_create and + uuid_to_string to generate the UUID. + Reported by: Alex Zimnitsky + 2014-06-22 Darshit Shah (tiny change) * progress.c (create_image): Align percentage download output better. diff --git a/src/warc.c b/src/warc.c index e3e76d0b..34613ec3 100644 --- a/src/warc.c +++ b/src/warc.c @@ -44,8 +44,11 @@ as that of the covered work. */ #ifdef HAVE_LIBZ #include #endif + #ifdef HAVE_LIBUUID #include +#elif HAVE_UUID_CREATE +#include #endif #ifndef WINDOWS @@ -594,7 +597,7 @@ warc_timestamp (char *timestamp) strftime (timestamp, 21, "%Y-%m-%dT%H:%M:%SZ", timeinfo); } -#ifdef HAVE_LIBUUID +#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. */ @@ -604,8 +607,13 @@ 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); }