mirror of
https://github.com/moparisthebest/wget
synced 2024-07-03 16:38:41 -04:00
warc: make warc_uuid_str implementation depend on HAVE_LIBUUID
This commit is contained in:
parent
2ffc383654
commit
2541e0b579
@ -1,4 +1,8 @@
|
|||||||
2012-03-29 From: Tim Ruehsen <tim.ruehsen@gmx.de> (tiny change)
|
2012-03-30 Tim Ruehsen <tim.ruehsen@gmx.de> (tiny change)
|
||||||
|
|
||||||
|
* warc.c: make warc_uuid_str() implementation depend on HAVE_LIBUUID.
|
||||||
|
|
||||||
|
2012-03-29 Tim Ruehsen <tim.ruehsen@gmx.de> (tiny change)
|
||||||
|
|
||||||
* utils.c (library): Include <sys/time.h>.
|
* utils.c (library): Include <sys/time.h>.
|
||||||
|
|
||||||
|
49
src/warc.c
49
src/warc.c
@ -580,15 +580,32 @@ warc_timestamp (char *timestamp)
|
|||||||
strftime (timestamp, 21, "%Y-%m-%dT%H:%M:%SZ", timeinfo);
|
strftime (timestamp, 21, "%Y-%m-%dT%H:%M:%SZ", timeinfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Fills uuid_str with a UUID based on random numbers.
|
#ifdef HAVE_LIBUUID
|
||||||
|
/* Fills urn_str with a UUID in the format required
|
||||||
|
for the WARC-Record-Id header.
|
||||||
|
The string will be 47 characters long. */
|
||||||
|
void
|
||||||
|
warc_uuid_str (char *urn_str)
|
||||||
|
{
|
||||||
|
char uuid_str[37];
|
||||||
|
|
||||||
|
uuid_t record_id;
|
||||||
|
uuid_generate (record_id);
|
||||||
|
uuid_unparse (record_id, uuid_str);
|
||||||
|
|
||||||
|
sprintf (urn_str, "<urn:uuid:%s>", uuid_str);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
/* Fills urn_str with a UUID based on random numbers in the format
|
||||||
|
required for the WARC-Record-Id header.
|
||||||
(See RFC 4122, UUID version 4.)
|
(See RFC 4122, UUID version 4.)
|
||||||
|
|
||||||
Note: this is a fallback method, it is much better to use the
|
Note: this is a fallback method, it is much better to use the
|
||||||
methods provided by libuuid.
|
methods provided by libuuid.
|
||||||
|
|
||||||
The uuid_str will be 36 characters long. */
|
The string will be 47 characters long. */
|
||||||
static void
|
void
|
||||||
warc_uuid_random (char *uuid_str)
|
warc_uuid_str (char *urn_str)
|
||||||
{
|
{
|
||||||
// RFC 4122, a version 4 UUID with only random numbers
|
// RFC 4122, a version 4 UUID with only random numbers
|
||||||
|
|
||||||
@ -605,32 +622,14 @@ warc_uuid_random (char *uuid_str)
|
|||||||
// clock_seq_hi_and_reserved to zero and one, respectively.
|
// clock_seq_hi_and_reserved to zero and one, respectively.
|
||||||
uuid_data[8] = (uuid_data[8] & 0xBF) | 0x80;
|
uuid_data[8] = (uuid_data[8] & 0xBF) | 0x80;
|
||||||
|
|
||||||
sprintf (uuid_str,
|
sprintf (urn_str,
|
||||||
"%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x",
|
"<urn:uuid:%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x>",
|
||||||
uuid_data[0], uuid_data[1], uuid_data[2], uuid_data[3], uuid_data[4],
|
uuid_data[0], uuid_data[1], uuid_data[2], uuid_data[3], uuid_data[4],
|
||||||
uuid_data[5], uuid_data[6], uuid_data[7], uuid_data[8], uuid_data[9],
|
uuid_data[5], uuid_data[6], uuid_data[7], uuid_data[8], uuid_data[9],
|
||||||
uuid_data[10], uuid_data[11], uuid_data[12], uuid_data[13], uuid_data[14],
|
uuid_data[10], uuid_data[11], uuid_data[12], uuid_data[13], uuid_data[14],
|
||||||
uuid_data[15]);
|
uuid_data[15]);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
/* Fills urn_str with a UUID in the format required
|
|
||||||
for the WARC-Record-Id header.
|
|
||||||
The string will be 47 characters long. */
|
|
||||||
void
|
|
||||||
warc_uuid_str (char *urn_str)
|
|
||||||
{
|
|
||||||
char uuid_str[37];
|
|
||||||
|
|
||||||
# ifdef HAVE_LIBUUID
|
|
||||||
uuid_t record_id;
|
|
||||||
uuid_generate (record_id);
|
|
||||||
uuid_unparse (record_id, uuid_str);
|
|
||||||
# else
|
|
||||||
warc_uuid_random (uuid_str);
|
|
||||||
# endif
|
|
||||||
|
|
||||||
sprintf (urn_str, "<urn:uuid:%s>", uuid_str);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Write a warcinfo record to the current file.
|
/* Write a warcinfo record to the current file.
|
||||||
Updates warc_current_warcinfo_uuid_str. */
|
Updates warc_current_warcinfo_uuid_str. */
|
||||||
|
Loading…
Reference in New Issue
Block a user