1
0
mirror of https://github.com/moparisthebest/wget synced 2024-07-03 16:38:41 -04:00

Fix use of uuid libc functions (tiny change)

* Always attempt to detect uuid.h and uuid_create().
* Split libuuid and uuid.h implementations of warc_uuid_str(), since
  those APIs vary significantly.
* Correctly use the uuid.h functions
This commit is contained in:
Jérémie Courrèges-Anglas 2014-12-16 00:01:48 +01:00 committed by Tim Rühsen
parent 425368c602
commit b8c567a3ef
2 changed files with 21 additions and 14 deletions

View File

@ -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

View File

@ -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, "<urn:uuid:%s>", 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, "<urn:uuid:%s>", 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.