diff --git a/include/cdio/iso9660.h b/include/cdio/iso9660.h index a5311c8f..45ece74a 100644 --- a/include/cdio/iso9660.h +++ b/include/cdio/iso9660.h @@ -651,11 +651,11 @@ typedef struct _iso9660_s iso9660_t; bool iso9660_ifs_read_pvd (const iso9660_t *p_iso, /*out*/ iso9660_pvd_t *p_pvd); -/*! - Read the Super block of an ISO 9660 image. This is the - Primary Volume Descriptor (PVD) and perhaps a Supplemental Volume - Descriptor if (Joliet) extensions are acceptable. -*/ + /*! + Read the Super block of an ISO 9660 image. This is the + Primary Volume Descriptor (PVD) and perhaps a Supplemental Volume + Descriptor if (Joliet) extensions are acceptable. + */ bool iso9660_fs_read_superblock (CdIo_t *p_cdio, iso_extension_mask_t iso_extension_mask); @@ -671,19 +671,37 @@ typedef struct _iso9660_s iso9660_t; /*==================================================== Time conversion ====================================================*/ -/*! - Set time in format used in ISO 9660 directory index record - from a Unix time structure. */ + + /*! + Set time in format used in ISO 9660 directory index record + from a Unix time structure. + */ void iso9660_set_dtime (const struct tm *tm, /*out*/ iso9660_dtime_t *idr_date); - - + + + /*! + Set time in format used in ISO 9660 directory index record + from a Unix time structure. timezone is given as an offset + correction in minutes. + */ + void iso9660_set_dtime_with_timezone (const struct tm *p_tm, + int timezone, + /*out*/ iso9660_dtime_t *p_idr_date); + /*! Set "long" time in format used in ISO 9660 primary volume descriptor from a Unix time structure. */ void iso9660_set_ltime (const struct tm *_tm, /*out*/ iso9660_ltime_t *p_pvd_date); + /*! + Set "long" time in format used in ISO 9660 primary volume descriptor + from a Unix time structure. */ + void iso9660_set_ltime_with_timezone (const struct tm *_tm, + int timezone, + /*out*/ iso9660_ltime_t *p_pvd_date); + /*! Get Unix time structure from format use in an ISO 9660 directory index record. Even though tm_wday and tm_yday fields are not explicitly in diff --git a/lib/iso9660/iso9660.c b/lib/iso9660/iso9660.c index 0f58bfbc..6ad2e782 100644 --- a/lib/iso9660/iso9660.c +++ b/lib/iso9660/iso9660.c @@ -1,8 +1,8 @@ /* $Id: iso9660.c,v 1.41 2008/06/25 08:01:54 rocky Exp $ - Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 - Rocky Bernstein + Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 + Rocky Bernstein Copyright (C) 2000 Herbert Valerio Riedel This program is free software: you can redistribute it and/or modify @@ -296,12 +296,15 @@ iso9660_get_ltime (const iso9660_ltime_t *p_ldate, return true; } - /*! Set time in format used in ISO 9660 directory index record - from a Unix time structure. */ + from a Unix time structure. timezone is given as an offset + correction in minutes. +*/ void -iso9660_set_dtime (const struct tm *p_tm, /*out*/ iso9660_dtime_t *p_idr_date) +iso9660_set_dtime_with_timezone (const struct tm *p_tm, + int timezone, + /*out*/ iso9660_dtime_t *p_idr_date) { memset (p_idr_date, 0, 7); @@ -314,10 +317,9 @@ iso9660_set_dtime (const struct tm *p_tm, /*out*/ iso9660_dtime_t *p_idr_date) p_idr_date->dt_minute = p_tm->tm_min; p_idr_date->dt_second = p_tm->tm_sec; -#ifdef HAVE_TM_GMTOFF /* The ISO 9660 timezone is in the range -48..+52 and each unit represents a 15-minute interval. */ - p_idr_date->dt_gmtoff = p_tm->tm_gmtoff / (15 * 60); + p_idr_date->dt_gmtoff = timezone / 15; if (p_idr_date->dt_gmtoff < -48 ) { @@ -329,18 +331,33 @@ iso9660_set_dtime (const struct tm *p_tm, /*out*/ iso9660_dtime_t *p_idr_date) p_idr_date->dt_gmtoff); p_idr_date->dt_gmtoff = 52; } -#else - p_idr_date->dt_gmtoff = 0; +} - if (p_tm->tm_isdst > 0) p_idr_date->dt_gmtoff -= 4; +/*! + Set time in format used in ISO 9660 directory index record + from a Unix time structure. */ +void +iso9660_set_dtime (const struct tm *p_tm, /*out*/ iso9660_dtime_t *p_idr_date) +{ + int timezone; +#ifdef HAVE_TM_GMTOFF + /* Convert seconds to minutes */ + timezone = p_tm->tm_gmtoff / 60; +#else + timezone = (p_tm->tm_isdst > 0) ? 0 : -60; #endif + iso9660_set_dtime_with_timezone (p_tm, timezone, p_idr_date); } /*! Set "long" time in format used in ISO 9660 primary volume descriptor - from a Unix time structure. */ + from a Unix time structure. timezone is given as an offset + correction in minutes. +*/ void -iso9660_set_ltime (const struct tm *p_tm, /*out*/ iso9660_ltime_t *pvd_date) +iso9660_set_ltime_with_timezone (const struct tm *p_tm, + int timezone, + /*out*/ iso9660_ltime_t *pvd_date) { char *_pvd_date = (char *) pvd_date; @@ -355,13 +372,8 @@ iso9660_set_ltime (const struct tm *p_tm, /*out*/ iso9660_ltime_t *pvd_date) p_tm->tm_hour, p_tm->tm_min, p_tm->tm_sec, 0 /* 1/100 secs */ ); -#ifndef HAVE_TM_GMTOFF - /* Adjust for daylight savings time. */ - if (p_tm->tm_isdst > 0) _pvd_date[16] -= (iso712_t) 4; - -#else /* Set time zone in 15-minute interval encoding. */ - pvd_date->lt_gmtoff -= p_tm->tm_gmtoff / (15 * 60); + pvd_date->lt_gmtoff -= (timezone / 15); if (pvd_date->lt_gmtoff < -48 ) { cdio_warn ("Converted ISO 9660 timezone %d is less than -48. Adjusted", @@ -372,8 +384,22 @@ iso9660_set_ltime (const struct tm *p_tm, /*out*/ iso9660_ltime_t *pvd_date) (int) pvd_date->lt_gmtoff); pvd_date->lt_gmtoff = 52; } -#endif +} +/*! + Set "long" time in format used in ISO 9660 primary volume descriptor + from a Unix time structure. */ +void +iso9660_set_ltime (const struct tm *p_tm, /*out*/ iso9660_ltime_t *pvd_date) +{ + int timezone; +#ifdef HAVE_TM_GMTOFF + /* Set time zone in 15-minute interval encoding. */ + timezone = p_tm->tm_gmtoff / 60; +#else + timezone = (p_tm->tm_isdst > 0) ? 0 : -60; +#endif + iso9660_set_ltime_with_timezone (p_tm, timezone, pvd_date); } /*! diff --git a/lib/iso9660/libiso9660.sym b/lib/iso9660/libiso9660.sym index 7f9d3ad3..d2a55a88 100644 --- a/lib/iso9660/libiso9660.sym +++ b/lib/iso9660/libiso9660.sym @@ -73,8 +73,10 @@ iso9660_pathtable_init iso9660_pathtable_l_add_entry iso9660_pathtable_m_add_entry iso9660_set_dtime +iso9660_set_dtime_with_timezone iso9660_set_evd iso9660_set_ltime +iso9660_set_ltime_with_timezone iso9660_set_pvd iso9660_strncpy_pad iso9660_xa_init