diff --git a/include/cdio/iso9660.h b/include/cdio/iso9660.h index b5234dce..38b11b1d 100644 --- a/include/cdio/iso9660.h +++ b/include/cdio/iso9660.h @@ -1,5 +1,5 @@ /* - $Id: iso9660.h,v 1.21 2003/09/10 08:39:00 rocky Exp $ + $Id: iso9660.h,v 1.22 2003/09/20 11:53:09 rocky Exp $ Copyright (C) 2000 Herbert Valerio Riedel Copyright (C) 2003 Rocky Bernstein @@ -93,6 +93,18 @@ enum strncpy_pad_check { PRAGMA_BEGIN_PACKED +struct iso9660_dtime { + uint8_t dt_year; + uint8_t dt_month; /* 1..12. Note 1 origin not 0, like a tm struct. */ + uint8_t dt_day; + uint8_t dt_hour; + uint8_t dt_minute; + uint8_t dt_second; + int8_t dt_gmtoff; /* GMT values -48 .. + 52 in 15 min intervals */ +} GNUC_PACKED; + +typedef struct iso9660_dtime iso9660_dtime_t; + /* ISO-9660 Primary Volume Descriptor. */ struct iso9660_pvd { @@ -150,17 +162,17 @@ typedef struct iso9660_stat iso9660_stat_t; /* Format of an ISO-9660 directory record */ struct iso9660_dir { - uint8_t length; /* 711 */ - uint8_t ext_attr_length; /* 711 */ - uint64_t extent; /* 733 */ - uint64_t size; /* 733 */ - uint8_t date[7]; /* 7 by 711 */ - uint8_t flags; - uint8_t file_unit_size; /* 711 */ - uint8_t interleave; /* 711 */ + uint8_t length; /* 711 */ + uint8_t ext_attr_length; /* 711 */ + uint64_t extent; /* 733 */ + uint64_t size; /* 733 */ + iso9660_dtime_t date; /* 7 by 711 */ + uint8_t flags; + uint8_t file_unit_size; /* 711 */ + uint8_t interleave; /* 711 */ uint32_t volume_sequence_number; /* 723 */ - uint8_t name_len; /* 711 */ - char name[EMPTY_ARRAY_SIZE]; + uint8_t name_len; /* 711 */ + char name[EMPTY_ARRAY_SIZE]; } GNUC_PACKED; struct iso9660_stat { /* big endian!! */ @@ -219,7 +231,8 @@ char *iso9660_strncpy_pad(char dst[], const char src[], size_t len, /*! Set time in format used in ISO 9660 directory index record from a Unix time structure. */ -void iso9660_set_time (const struct tm *tm, /*out*/ uint8_t idr_date[]); + void iso9660_set_time (const struct tm *tm, + /*out*/ iso9660_dtime_t *idr_date); /*! @@ -227,7 +240,8 @@ void iso9660_set_time (const struct tm *tm, /*out*/ uint8_t idr_date[]); record. Even though tm_wday and tm_yday fields are not explicitly in idr_date, the are calculated from the other fields. */ -void iso9660_get_time (const uint8_t idr_date[], /*out*/ struct tm *tm); +void iso9660_get_time (const iso9660_dtime_t *idr_date, + /*out*/ struct tm *tm); /*===================================================================== diff --git a/lib/iso9660.c b/lib/iso9660.c index fcae6afd..d7cdb848 100644 --- a/lib/iso9660.c +++ b/lib/iso9660.c @@ -1,5 +1,5 @@ /* - $Id: iso9660.c,v 1.10 2003/09/10 08:39:00 rocky Exp $ + $Id: iso9660.c,v 1.11 2003/09/20 11:53:09 rocky Exp $ Copyright (C) 2000 Herbert Valerio Riedel Copyright (C) 2003 Rocky Bernstein @@ -37,7 +37,7 @@ #include #endif -static const char _rcsid[] = "$Id: iso9660.c,v 1.10 2003/09/10 08:39:00 rocky Exp $"; +static const char _rcsid[] = "$Id: iso9660.c,v 1.11 2003/09/20 11:53:09 rocky Exp $"; /* some parameters... */ #define SYSTEM_ID "CD-RTOS CD-BRIDGE" @@ -53,16 +53,18 @@ pathtable_get_size_and_entries(const void *pt, unsigned int *size, idr_date, the are calculated from the other fields. */ void -iso9660_get_time (const uint8_t idr_date[], /*out*/ struct tm *tm) +iso9660_get_time (const iso9660_dtime_t *idr_date, /*out*/ struct tm *tm) { if (!idr_date) return; - tm->tm_year = idr_date[0]; - tm->tm_mon = idr_date[1] - 1; - tm->tm_mday = idr_date[2]; - tm->tm_hour = idr_date[3]; - tm->tm_min = idr_date[4]; - tm->tm_sec = idr_date[5]; + tm->tm_year = idr_date->dt_year; + tm->tm_mon = idr_date->dt_month - 1; + tm->tm_mday = idr_date->dt_day; + tm->tm_hour = idr_date->dt_hour; + tm->tm_min = idr_date->dt_minute; + tm->tm_sec = idr_date->dt_second; + tm->tm_gmtoff = 0; + /* Recompute tm_wday and tm_yday */ mktime(tm); } @@ -71,19 +73,19 @@ iso9660_get_time (const uint8_t idr_date[], /*out*/ struct tm *tm) Set time in format used in ISO 9660 directory index record from a Unix time structure. */ void -iso9660_set_time (const struct tm *tm, /*out*/ uint8_t idr_date[]) +iso9660_set_time (const struct tm *tm, /*out*/ iso9660_dtime_t *idr_date) { memset (idr_date, 0, 7); if (!tm) return; - idr_date[0] = tm->tm_year; - idr_date[1] = tm->tm_mon + 1; - idr_date[2] = tm->tm_mday; - idr_date[3] = tm->tm_hour; - idr_date[4] = tm->tm_min; - idr_date[5] = tm->tm_sec; - idr_date[6] = 0x00; /* tz, GMT -48 +52 in 15min intervals */ + idr_date->dt_year = tm->tm_year; + idr_date->dt_month = tm->tm_mon + 1; + idr_date->dt_day = tm->tm_mday; + idr_date->dt_hour = tm->tm_hour; + idr_date->dt_minute = tm->tm_min; + idr_date->dt_second = tm->tm_sec; + idr_date->dt_gmtoff = 0x00; /* tz, GMT -48 +52 in 15min intervals */ } static void @@ -427,7 +429,7 @@ iso9660_dir_add_entry_su(void *dir, idr->extent = to_733(extent); idr->size = to_733(size); - iso9660_set_time (gmtime(entry_time), idr->date); + iso9660_set_time (gmtime(entry_time), &(idr->date)); idr->flags = to_711(flags); diff --git a/lib/iso9660_fs.c b/lib/iso9660_fs.c index e5e6e510..933a55e5 100644 --- a/lib/iso9660_fs.c +++ b/lib/iso9660_fs.c @@ -1,5 +1,5 @@ /* - $Id: iso9660_fs.c,v 1.9 2003/09/14 06:35:59 rocky Exp $ + $Id: iso9660_fs.c,v 1.10 2003/09/20 11:53:09 rocky Exp $ Copyright (C) 2001 Herbert Valerio Riedel Copyright (C) 2003 Rocky Bernstein @@ -38,7 +38,7 @@ #include -static const char _rcsid[] = "$Id: iso9660_fs.c,v 1.9 2003/09/14 06:35:59 rocky Exp $"; +static const char _rcsid[] = "$Id: iso9660_fs.c,v 1.10 2003/09/20 11:53:09 rocky Exp $"; static void _idr2statbuf (const iso9660_dir_t *idr, iso9660_stat_t *stat, bool is_mode2) @@ -55,7 +55,7 @@ _idr2statbuf (const iso9660_dir_t *idr, iso9660_stat_t *stat, bool is_mode2) stat->size = from_733 (idr->size); stat->secsize = _cdio_len2blocks (stat->size, ISO_BLOCKSIZE); - iso9660_get_time(idr->date, &(stat->tm)); + iso9660_get_time(&(idr->date), &(stat->tm)); cdio_assert (dir_len >= sizeof (iso9660_dir_t));