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

Add size of buffer to warc_timestamp()

This commit is contained in:
Tim Rühsen 2014-11-24 10:41:08 +01:00
parent 9217b864d8
commit 0c18773308
4 changed files with 21 additions and 16 deletions

View File

@ -1,3 +1,7 @@
2014-11-24 Tim Ruehsen <tim.ruehsen@gmx.de>
* warc.c, warc.h, http.c: Add size of buffer to warc_timestamp()
2014-11-24 Tim Ruehsen <tim.ruehsen@gmx.de>
* wget.h, test.c, main.c: Make program_name and program_argstring const

View File

@ -2191,8 +2191,9 @@ gethttp (struct url *u, struct http_stat *hs, int *dt, struct url *proxy,
if (warc_enabled)
{
bool warc_result;
/* Generate a timestamp and uuid for this request. */
warc_timestamp (warc_timestamp_str);
warc_timestamp (warc_timestamp_str, sizeof(warc_timestamp_str));
warc_uuid_str (warc_request_uuid);
/* Create a request record and store it in the WARC file. */

View File

@ -391,12 +391,9 @@ static bool
warc_write_date_header (const char *timestamp)
{
char current_timestamp[21];
if (timestamp == NULL)
{
warc_timestamp (current_timestamp);
timestamp = current_timestamp;
}
return warc_write_header ("WARC-Date", timestamp);
return warc_write_header ("WARC-Date", timestamp ? timestamp :
warc_timestamp (current_timestamp, sizeof(current_timestamp)));
}
/* Writes the WARC-IP-Address header for the given IP to
@ -591,14 +588,16 @@ warc_write_digest_headers (FILE *file, long payload_offset)
The UTC time is formatted following ISO 8601, as required
for use in the WARC-Date header.
The timestamp will be 21 characters long. */
void
warc_timestamp (char *timestamp)
char *
warc_timestamp (char *timestamp, size_t timestamp_size)
{
time_t rawtime;
struct tm * timeinfo;
time ( &rawtime );
timeinfo = gmtime (&rawtime);
strftime (timestamp, 21, "%Y-%m-%dT%H:%M:%SZ", timeinfo);
time_t rawtime = time (NULL);
struct tm * timeinfo = gmtime (&rawtime);
if (strftime (timestamp, timestamp_size, "%Y-%m-%dT%H:%M:%SZ", timeinfo) == 0 && timestamp_size > 0)
*timestamp = 0;
return timestamp;
}
#if HAVE_LIBUUID || HAVE_UUID_CREATE
@ -672,7 +671,7 @@ warc_write_warcinfo_record (char *filename)
warc_current_warcinfo_uuid_str = (char *) malloc (48);
warc_uuid_str (warc_current_warcinfo_uuid_str);
warc_timestamp (timestamp);
warc_timestamp (timestamp, sizeof(timestamp));
filename_copy = strdup (filename);
filename_basename = strdup (basename (filename_copy));

View File

@ -6,9 +6,10 @@
void warc_init (void);
void warc_close (void);
void warc_timestamp (char *timestamp);
void warc_uuid_str (char *id_str);
char * warc_timestamp (char *timestamp, size_t timestamp_size);
FILE * warc_tempfile (void);
bool warc_write_request_record (char *url, char *timestamp_str,