iso9660.h: parameter name change to match implementation.
iso9660.c: use reentrant version of localtime and gettime (most of the time) Patch from Nicolas Boullis. testiso9660.c: Change a memcmp for a test_compare which gives more detailed information on failure.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
$Id: iso9660.h,v 1.98 2008/03/25 15:59:09 karl Exp $
|
||||
$Id: iso9660.h,v 1.99 2008/05/28 01:48:37 rocky Exp $
|
||||
|
||||
Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008
|
||||
Rocky Bernstein <rocky@gnu.org>
|
||||
@@ -684,10 +684,10 @@ typedef struct _iso9660_s iso9660_t;
|
||||
record. Even though tm_wday and tm_yday fields are not explicitly in
|
||||
idr_date, they are calculated from the other fields.
|
||||
|
||||
If tm is to reflect the localtime, set "use_localtime" true, otherwise
|
||||
If tm is to reflect the localtime, set "b_localtime" true, otherwise
|
||||
tm will reported in GMT.
|
||||
*/
|
||||
bool iso9660_get_dtime (const iso9660_dtime_t *idr_date, bool use_localtime,
|
||||
bool iso9660_get_dtime (const iso9660_dtime_t *idr_date, bool b_localtime,
|
||||
/*out*/ struct tm *tm);
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
$Id: iso9660.c,v 1.35 2008/04/18 16:02:09 karl Exp $
|
||||
$Id: iso9660.c,v 1.36 2008/05/28 01:48:37 rocky Exp $
|
||||
|
||||
Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008
|
||||
Rocky Bernstein <rocky@gnu.org>
|
||||
@@ -57,7 +57,7 @@ const char ISO_STANDARD_ID[] = {'C', 'D', '0', '0', '1'};
|
||||
#include <errno.h>
|
||||
#endif
|
||||
|
||||
static const char _rcsid[] = "$Id: iso9660.c,v 1.35 2008/04/18 16:02:09 karl Exp $";
|
||||
static const char _rcsid[] = "$Id: iso9660.c,v 1.36 2008/05/28 01:48:37 rocky Exp $";
|
||||
|
||||
/* Variables to hold debugger-helping enumerations */
|
||||
enum iso_enum1_s iso_enums1;
|
||||
@@ -128,10 +128,10 @@ iso9660_get_dtime (const iso9660_dtime_t *idr_date, bool b_localtime,
|
||||
0 == idr_date->dt_day && 0 == idr_date->dt_hour &&
|
||||
0 == idr_date->dt_minute && 0 == idr_date->dt_second ) {
|
||||
time_t t = 0;
|
||||
struct tm *p_temp_tm;
|
||||
p_temp_tm = localtime(&t);
|
||||
struct tm temp_tm;
|
||||
localtime_r(&t, &temp_tm);
|
||||
|
||||
memcpy(p_tm, p_temp_tm, sizeof(struct tm));
|
||||
memcpy(p_tm, &temp_tm, sizeof(struct tm));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -217,21 +217,21 @@ iso9660_get_ltime (const iso9660_ltime_t *p_ldate,
|
||||
date values to account for the timezone offset. */
|
||||
{
|
||||
time_t t;
|
||||
struct tm *p_temp_tm;
|
||||
struct tm temp_tm;
|
||||
const char *old_tzname=getenv("TZ");
|
||||
char psz_gmt_tzset[]="TZ=GMT";
|
||||
|
||||
putenv(psz_gmt_tzset);
|
||||
tzset();
|
||||
t = mktime(p_tm);
|
||||
p_temp_tm = gmtime(&t);
|
||||
gmtime_r(&t, &temp_tm);
|
||||
if (old_tzname) {
|
||||
char psz_tzset[10];
|
||||
snprintf(psz_tzset, sizeof(psz_tzset), "TZ=%s", old_tzname);
|
||||
}
|
||||
|
||||
p_tm->tm_wday = p_temp_tm->tm_wday;
|
||||
p_tm->tm_yday = p_temp_tm->tm_yday;
|
||||
p_tm->tm_wday = temp_tm.tm_wday;
|
||||
p_tm->tm_yday = temp_tm.tm_yday;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -619,6 +619,7 @@ iso9660_dir_add_entry_su(void *dir,
|
||||
unsigned int offset = 0;
|
||||
uint32_t dsize = from_733(idr->size);
|
||||
int length, su_offset;
|
||||
struct tm temp_tm;
|
||||
cdio_assert (sizeof(iso9660_dir_t) == 33);
|
||||
|
||||
if (!dsize && !idr->length)
|
||||
@@ -675,7 +676,8 @@ iso9660_dir_add_entry_su(void *dir,
|
||||
idr->extent = to_733(extent);
|
||||
idr->size = to_733(size);
|
||||
|
||||
iso9660_set_dtime (gmtime(entry_time), &(idr->recording_time));
|
||||
gmtime_r(entry_time, &temp_tm);
|
||||
iso9660_set_dtime (&temp_tm, &(idr->recording_time));
|
||||
|
||||
idr->file_flags = to_711(file_flags);
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
$Id: testiso9660.c,v 1.21 2008/03/22 18:08:25 karl Exp $
|
||||
$Id: testiso9660.c,v 1.22 2008/05/28 01:48:38 rocky Exp $
|
||||
|
||||
Copyright (C) 2003, 2006, 2007, 2008 Rocky Bernstein <rocky@gnu.org>
|
||||
|
||||
@@ -245,9 +245,7 @@ main (int argc, const char *argv[])
|
||||
p_tm = localtime(&now);
|
||||
iso9660_set_dtime(p_tm, &dtime);
|
||||
iso9660_get_dtime(&dtime, true, &tm);
|
||||
if ( memcmp(p_tm, &tm, sizeof(tm)) != 0 ) {
|
||||
printf("Local time retrieved with iso9660_get_dtime not same as\n");
|
||||
printf("that set with iso9660_set_dtime().\n");
|
||||
if ( !time_compare(p_tm, &tm) ) {
|
||||
return 41;
|
||||
}
|
||||
p_tm = gmtime(&now);
|
||||
@@ -257,7 +255,7 @@ main (int argc, const char *argv[])
|
||||
return 42;
|
||||
}
|
||||
|
||||
if ( memcmp(p_tm, &tm, sizeof(tm)) != 0 ) {
|
||||
if ( !time_compare(p_tm, &tm) ) {
|
||||
printf("GMT time retrieved with iso9660_get_dtime() not same as that\n");
|
||||
printf("set with iso9660_set_dtime().\n");
|
||||
return 43;
|
||||
|
||||
Reference in New Issue
Block a user