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:
parent
425368c602
commit
b8c567a3ef
13
configure.ac
13
configure.ac
@ -652,13 +652,6 @@ AS_IF([test "X$with_libuuid" != "Xno"],[
|
|||||||
CFLAGS="$UUID_CFLAGS $CFLAGS"
|
CFLAGS="$UUID_CFLAGS $CFLAGS"
|
||||||
AC_DEFINE([HAVE_LIBUUID], [1], [Define if using libuuid.])
|
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_HEADER(uuid/uuid.h,
|
||||||
AC_CHECK_LIB(uuid, uuid_generate,
|
AC_CHECK_LIB(uuid, uuid_generate,
|
||||||
[LIBS="${LIBS} -luuid"
|
[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
|
||||||
dnl Check for PCRE
|
dnl Check for PCRE
|
||||||
dnl
|
dnl
|
||||||
|
22
src/warc.c
22
src/warc.c
@ -600,26 +600,34 @@ warc_timestamp (char *timestamp, size_t timestamp_size)
|
|||||||
return timestamp;
|
return timestamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if HAVE_LIBUUID || HAVE_UUID_CREATE
|
|
||||||
/* Fills urn_str with a UUID in the format required
|
/* Fills urn_str with a UUID in the format required
|
||||||
for the WARC-Record-Id header.
|
for the WARC-Record-Id header.
|
||||||
The string will be 47 characters long. */
|
The string will be 47 characters long. */
|
||||||
|
#if HAVE_LIBUUID
|
||||||
void
|
void
|
||||||
warc_uuid_str (char *urn_str)
|
warc_uuid_str (char *urn_str)
|
||||||
{
|
{
|
||||||
char uuid_str[37];
|
char uuid_str[37];
|
||||||
|
|
||||||
uuid_t record_id;
|
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_generate (record_id);
|
||||||
uuid_unparse (record_id, uuid_str);
|
uuid_unparse (record_id, uuid_str);
|
||||||
#endif
|
|
||||||
|
|
||||||
sprintf (urn_str, "<urn:uuid:%s>", uuid_str);
|
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
|
#else
|
||||||
/* Fills urn_str with a UUID based on random numbers in the format
|
/* Fills urn_str with a UUID based on random numbers in the format
|
||||||
required for the WARC-Record-Id header.
|
required for the WARC-Record-Id header.
|
||||||
|
Loading…
Reference in New Issue
Block a user