Add "long" date setting routine and more precise definitions there as well.
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
$Id: iso9660.h,v 1.22 2003/09/20 11:53:09 rocky Exp $
|
$Id: iso9660.h,v 1.23 2003/09/20 12:33:14 rocky Exp $
|
||||||
|
|
||||||
Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org>
|
Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org>
|
||||||
Copyright (C) 2003 Rocky Bernstein <rocky@panix.com>
|
Copyright (C) 2003 Rocky Bernstein <rocky@panix.com>
|
||||||
@@ -37,6 +37,8 @@
|
|||||||
|
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
|
#define _delta(from, to) ((to) - (from) + 1)
|
||||||
|
|
||||||
#define MIN_TRACK_SIZE 4*75
|
#define MIN_TRACK_SIZE 4*75
|
||||||
#define MIN_ISO_SIZE MIN_TRACK_SIZE
|
#define MIN_ISO_SIZE MIN_TRACK_SIZE
|
||||||
|
|
||||||
@@ -105,6 +107,19 @@ struct iso9660_dtime {
|
|||||||
|
|
||||||
typedef struct iso9660_dtime iso9660_dtime_t;
|
typedef struct iso9660_dtime iso9660_dtime_t;
|
||||||
|
|
||||||
|
struct iso9660_ltime {
|
||||||
|
char lt_year [_delta( 1, 4)]; /* Add 1900 for Julian year */
|
||||||
|
char lt_month [_delta( 5, 6)]; /* 1..12. Note starts at 1. */
|
||||||
|
char lt_day [_delta( 7, 8)];
|
||||||
|
char lt_hour [_delta( 9, 10)];
|
||||||
|
char lt_minute [_delta( 11, 12)];
|
||||||
|
char lt_second [_delta( 13, 14)];
|
||||||
|
char lt_hsecond [_delta( 15, 16)]; /* 1/100's of a second */
|
||||||
|
int8_t lt_gmtoff [_delta( 17, 17)];
|
||||||
|
} GNUC_PACKED;
|
||||||
|
|
||||||
|
typedef struct iso9660_ltime iso9660_ltime_t;
|
||||||
|
|
||||||
/* ISO-9660 Primary Volume Descriptor.
|
/* ISO-9660 Primary Volume Descriptor.
|
||||||
*/
|
*/
|
||||||
struct iso9660_pvd {
|
struct iso9660_pvd {
|
||||||
@@ -133,10 +148,10 @@ struct iso9660_pvd {
|
|||||||
char copyright_file_id[37]; /* 7.5 dchars */
|
char copyright_file_id[37]; /* 7.5 dchars */
|
||||||
char abstract_file_id[37]; /* 7.5 dchars */
|
char abstract_file_id[37]; /* 7.5 dchars */
|
||||||
char bibliographic_file_id[37]; /* 7.5 dchars */
|
char bibliographic_file_id[37]; /* 7.5 dchars */
|
||||||
char creation_date[17]; /* 8.4.26.1 */
|
iso9660_ltime_t creation_date; /* 8.4.26.1 */
|
||||||
char modification_date[17]; /* 8.4.26.1 */
|
iso9660_ltime_t modification_date; /* 8.4.26.1 */
|
||||||
char expiration_date[17]; /* 8.4.26.1 */
|
iso9660_ltime_t expiration_date; /* 8.4.26.1 */
|
||||||
char effective_date[17]; /* 8.4.26.1 */
|
iso9660_ltime_t effective_date; /* 8.4.26.1 */
|
||||||
uint8_t file_structure_version; /* 711 */
|
uint8_t file_structure_version; /* 711 */
|
||||||
char unused4[1];
|
char unused4[1];
|
||||||
char application_data[512];
|
char application_data[512];
|
||||||
@@ -231,10 +246,16 @@ char *iso9660_strncpy_pad(char dst[], const char src[], size_t len,
|
|||||||
/*!
|
/*!
|
||||||
Set time in format used in ISO 9660 directory index record
|
Set time in format used in ISO 9660 directory index record
|
||||||
from a Unix time structure. */
|
from a Unix time structure. */
|
||||||
void iso9660_set_time (const struct tm *tm,
|
void iso9660_set_dtime (const struct tm *tm,
|
||||||
/*out*/ iso9660_dtime_t *idr_date);
|
/*out*/ iso9660_dtime_t *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 *pvd_date);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Get time structure from structure in an ISO 9660 directory index
|
Get time structure from structure in an ISO 9660 directory index
|
||||||
record. Even though tm_wday and tm_yday fields are not explicitly in
|
record. Even though tm_wday and tm_yday fields are not explicitly in
|
||||||
|
|||||||
@@ -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) 2000 Herbert Valerio Riedel <hvr@gnu.org>
|
||||||
Copyright (C) 2003 Rocky Bernstein <rocky@panix.com>
|
Copyright (C) 2003 Rocky Bernstein <rocky@panix.com>
|
||||||
@@ -37,7 +37,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#endif
|
#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... */
|
/* some parameters... */
|
||||||
#define SYSTEM_ID "CD-RTOS CD-BRIDGE"
|
#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
|
Set time in format used in ISO 9660 directory index record
|
||||||
from a Unix time structure. */
|
from a Unix time structure. */
|
||||||
void
|
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);
|
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 */
|
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);
|
memset (pvd_date->lt_year, '0', sizeof(pvd_date->lt_year));
|
||||||
_pvd_date[16] = (int8_t) 0; /* tz */
|
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)
|
if (!_tm)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
snprintf(_pvd_date, 17,
|
snprintf(pvd_date->lt_year, sizeof(pvd_date->lt_year),
|
||||||
"%4.4d%2.2d%2.2d" "%2.2d%2.2d%2.2d" "%2.2d",
|
"%4.4d", _tm->tm_year + 1900);
|
||||||
_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_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.abstract_file_id , "", 37, ISO9660_DCHARS);
|
||||||
iso9660_strncpy_pad (ipd.bibliographic_file_id, "", 37, ISO9660_DCHARS);
|
iso9660_strncpy_pad (ipd.bibliographic_file_id, "", 37, ISO9660_DCHARS);
|
||||||
|
|
||||||
_pvd_set_time (ipd.creation_date, gmtime (pvd_time));
|
iso9660_set_ltime (gmtime (pvd_time), &(ipd.creation_date));
|
||||||
_pvd_set_time (ipd.modification_date, gmtime (pvd_time));
|
iso9660_set_ltime (gmtime (pvd_time), &(ipd.modification_date));
|
||||||
_pvd_set_time (ipd.expiration_date, NULL);
|
iso9660_set_ltime (NULL, &(ipd.expiration_date));
|
||||||
_pvd_set_time (ipd.effective_date, NULL);
|
iso9660_set_ltime (NULL, &(ipd.effective_date));
|
||||||
|
|
||||||
ipd.file_structure_version = to_711(1);
|
ipd.file_structure_version = to_711(1);
|
||||||
|
|
||||||
@@ -429,7 +451,7 @@ iso9660_dir_add_entry_su(void *dir,
|
|||||||
idr->extent = to_733(extent);
|
idr->extent = to_733(extent);
|
||||||
idr->size = to_733(size);
|
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);
|
idr->flags = to_711(flags);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user