Add "long" date setting routine and more precise definitions there as well.

This commit is contained in:
rocky
2003-09-20 12:33:14 +00:00
parent 524522106d
commit 6568624fb3
2 changed files with 98 additions and 55 deletions

View File

@@ -1,5 +1,5 @@
/*
$Id: iso9660.c,v 1.11 2003/09/20 11:53:09 rocky Exp $
$Id: iso9660.c,v 1.12 2003/09/20 12:33:14 rocky Exp $
Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org>
Copyright (C) 2003 Rocky Bernstein <rocky@panix.com>
@@ -37,7 +37,7 @@
#include <stdio.h>
#endif
static const char _rcsid[] = "$Id: iso9660.c,v 1.11 2003/09/20 11:53:09 rocky Exp $";
static const char _rcsid[] = "$Id: iso9660.c,v 1.12 2003/09/20 12:33:14 rocky Exp $";
/* some parameters... */
#define SYSTEM_ID "CD-RTOS CD-BRIDGE"
@@ -73,7 +73,7 @@ iso9660_get_time (const iso9660_dtime_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*/ iso9660_dtime_t *idr_date)
iso9660_set_dtime (const struct tm *tm, /*out*/ iso9660_dtime_t *idr_date)
{
memset (idr_date, 0, 7);
@@ -88,22 +88,44 @@ iso9660_set_time (const struct tm *tm, /*out*/ iso9660_dtime_t *idr_date)
idr_date->dt_gmtoff = 0x00; /* tz, GMT -48 +52 in 15min intervals */
}
static void
_pvd_set_time (char _pvd_date[], const struct tm *_tm)
/*!
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 *pvd_date)
{
memset (_pvd_date, '0', 16);
_pvd_date[16] = (int8_t) 0; /* tz */
memset (pvd_date->lt_year, '0', sizeof(pvd_date->lt_year));
memset (pvd_date->lt_month, '0', sizeof(pvd_date->lt_month));
memset (pvd_date->lt_day, '0', sizeof(pvd_date->lt_day));
memset (pvd_date->lt_hour, '0', sizeof(pvd_date->lt_hour));
memset (pvd_date->lt_minute, '0', sizeof(pvd_date->lt_minute));
memset (pvd_date->lt_second, '0', sizeof(pvd_date->lt_second));
memset (pvd_date->lt_hsecond, '0', sizeof(pvd_date->lt_hsecond));
memset (pvd_date->lt_gmtoff, 0, sizeof(pvd_date->lt_gmtoff));
if (!_tm)
return;
snprintf(_pvd_date, 17,
"%4.4d%2.2d%2.2d" "%2.2d%2.2d%2.2d" "%2.2d",
_tm->tm_year + 1900, _tm->tm_mon + 1, _tm->tm_mday,
_tm->tm_hour, _tm->tm_min, _tm->tm_sec,
0 /* 1/100 secs */ );
_pvd_date[16] = (int8_t) 0; /* tz */
snprintf(pvd_date->lt_year, sizeof(pvd_date->lt_year),
"%4.4d", _tm->tm_year + 1900);
snprintf(pvd_date->lt_month, sizeof(pvd_date->lt_month),
"%2.2d", _tm->tm_mon + 1);
snprintf(pvd_date->lt_day, sizeof(pvd_date->lt_day),
"%2.2d", _tm->tm_mday);
snprintf(pvd_date->lt_hour, sizeof(pvd_date->lt_hour),
"%2.2d", _tm->tm_hour);
snprintf(pvd_date->lt_minute, sizeof(pvd_date->lt_minute),
"%2.2d", _tm->tm_min);
snprintf(pvd_date->lt_second, sizeof(pvd_date->lt_second),
"%2.2d", _tm->tm_sec);
snprintf(pvd_date->lt_hsecond, sizeof(pvd_date->lt_hsecond),
"%2.2d", 0);
}
/*!
@@ -330,10 +352,10 @@ iso9660_set_pvd(void *pd,
iso9660_strncpy_pad (ipd.abstract_file_id , "", 37, ISO9660_DCHARS);
iso9660_strncpy_pad (ipd.bibliographic_file_id, "", 37, ISO9660_DCHARS);
_pvd_set_time (ipd.creation_date, gmtime (pvd_time));
_pvd_set_time (ipd.modification_date, gmtime (pvd_time));
_pvd_set_time (ipd.expiration_date, NULL);
_pvd_set_time (ipd.effective_date, NULL);
iso9660_set_ltime (gmtime (pvd_time), &(ipd.creation_date));
iso9660_set_ltime (gmtime (pvd_time), &(ipd.modification_date));
iso9660_set_ltime (NULL, &(ipd.expiration_date));
iso9660_set_ltime (NULL, &(ipd.effective_date));
ipd.file_structure_version = to_711(1);
@@ -429,7 +451,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_dtime (gmtime(entry_time), &(idr->date));
idr->flags = to_711(flags);