New API call iso_write_opts_set_pvd_times().

This commit is contained in:
Thomas Schmitt 2010-04-07 21:03:00 +02:00
parent f13167335a
commit c3d5ab7bc7
3 changed files with 112 additions and 4 deletions

View File

@ -383,7 +383,7 @@ int ecma119_writer_write_vol_desc(IsoImageWriter *writer)
IsoImage *image; IsoImage *image;
Ecma119Image *t; Ecma119Image *t;
struct ecma119_pri_vol_desc vol; struct ecma119_pri_vol_desc vol;
int i;
char *vol_id, *pub_id, *data_id, *volset_id; char *vol_id, *pub_id, *data_id, *volset_id;
char *system_id, *application_id, *copyright_file_id; char *system_id, *application_id, *copyright_file_id;
char *abstract_file_id, *biblio_file_id; char *abstract_file_id, *biblio_file_id;
@ -438,9 +438,35 @@ int ecma119_writer_write_vol_desc(IsoImageWriter *writer)
strncpy_pad((char*)vol.abstract_file_id, abstract_file_id, 37); strncpy_pad((char*)vol.abstract_file_id, abstract_file_id, 37);
strncpy_pad((char*)vol.bibliographic_file_id, biblio_file_id, 37); strncpy_pad((char*)vol.bibliographic_file_id, biblio_file_id, 37);
iso_datetime_17(vol.vol_creation_time, t->now, t->always_gmt); if (t->vol_creation_time > 0)
iso_datetime_17(vol.vol_modification_time, t->now, t->always_gmt); iso_datetime_17(vol.vol_creation_time, t->vol_creation_time,
iso_datetime_17(vol.vol_effective_time, t->now, t->always_gmt); t->always_gmt);
else
iso_datetime_17(vol.vol_creation_time, t->now, t->always_gmt);
if (t->vol_uuid[0]) {
for(i = 0; i < 16; i++)
if(t->vol_uuid[i] < '0' || t->vol_uuid[i] > '9')
break;
else
vol.vol_modification_time[i] = t->vol_uuid[i];
for(; i < 16; i++)
vol.vol_modification_time[i] = '1';
vol.vol_modification_time[16] = 0;
} else if (t->vol_modification_time > 0)
iso_datetime_17(vol.vol_modification_time, t->vol_modification_time,
t->always_gmt);
else
iso_datetime_17(vol.vol_modification_time, t->now, t->always_gmt);
if (t->vol_expiration_time > 0)
iso_datetime_17(vol.vol_expiration_time, t->vol_expiration_time,
t->always_gmt);
if (t->vol_effective_time > 0)
iso_datetime_17(vol.vol_effective_time, t->vol_effective_time,
t->always_gmt);
vol.file_structure_version[0] = 1; vol.file_structure_version[0] = 1;
free(vol_id); free(vol_id);
@ -1141,6 +1167,12 @@ int ecma119_image_new(IsoImage *src, IsoWriteOpts *opts, Ecma119Image **img)
} }
target->system_area_options = opts->system_area_options; target->system_area_options = opts->system_area_options;
target->vol_creation_time = opts->vol_creation_time;
target->vol_modification_time = opts->vol_modification_time;
target->vol_expiration_time = opts->vol_expiration_time;
target->vol_effective_time = opts->vol_effective_time;
strcpy(target->vol_uuid, opts->vol_uuid);
target->input_charset = strdup(iso_get_local_charset(0)); target->input_charset = strdup(iso_get_local_charset(0));
if (target->input_charset == NULL) { if (target->input_charset == NULL) {
ret = ISO_OUT_OF_MEM; ret = ISO_OUT_OF_MEM;
@ -1703,6 +1735,14 @@ int iso_write_opts_new(IsoWriteOpts **opts, int profile)
wopts->fifo_size = 1024; /* 2 MB buffer */ wopts->fifo_size = 1024; /* 2 MB buffer */
wopts->sort_files = 1; /* file sorting is always good */ wopts->sort_files = 1; /* file sorting is always good */
wopts->system_area_data = NULL;
wopts->system_area_options = 0;
wopts->vol_creation_time = 0;
wopts->vol_modification_time = 0;
wopts->vol_expiration_time = 0;
wopts->vol_effective_time = 0;
wopts->vol_uuid[0]= 0;
*opts = wopts; *opts = wopts;
return ISO_SUCCESS; return ISO_SUCCESS;
} }
@ -2126,3 +2166,17 @@ int iso_write_opts_set_system_area(IsoWriteOpts *opts, char data[32768],
return ISO_SUCCESS; return ISO_SUCCESS;
} }
int iso_write_opts_set_pvd_times(IsoWriteOpts *opts,
time_t vol_creation_time, time_t vol_modification_time,
time_t vol_expiration_time, time_t vol_effective_time,
char *vol_uuid)
{
opts->vol_creation_time = vol_creation_time;
opts->vol_modification_time = vol_modification_time;
opts->vol_expiration_time = vol_expiration_time;
opts->vol_effective_time = vol_effective_time;
strncpy(opts->vol_uuid, vol_uuid, 16);
opts->vol_uuid[16] = 0;
return ISO_SUCCESS;
}

View File

@ -303,6 +303,17 @@ struct iso_write_opts {
*/ */
char *system_area_data; char *system_area_data;
int system_area_options; int system_area_options;
/* User settable PVD time stamps */
time_t vol_creation_time;
time_t vol_modification_time;
time_t vol_expiration_time;
time_t vol_effective_time;
/* To eventually override vol_modification_time by unconverted string
* and timezone 0
*/
char vol_uuid[17];
}; };
typedef struct ecma119_image Ecma119Image; typedef struct ecma119_image Ecma119Image;
@ -513,6 +524,16 @@ struct ecma119_image
/* writer thread descriptor */ /* writer thread descriptor */
pthread_t wthread; pthread_t wthread;
pthread_attr_t th_attr; pthread_attr_t th_attr;
/* User settable PVD time stamps */
time_t vol_creation_time;
time_t vol_modification_time;
time_t vol_expiration_time;
time_t vol_effective_time;
/* To eventually override vol_modification_time by unconverted string
* and timezone 0
*/
char vol_uuid[17];
}; };
#define BP(a,b) [(b) - (a) + 1] #define BP(a,b) [(b) - (a) + 1]

View File

@ -1706,6 +1706,39 @@ int iso_write_opts_set_fifo_size(IsoWriteOpts *opts, size_t fifo_size);
int iso_write_opts_set_system_area(IsoWriteOpts *opts, char data[32768], int iso_write_opts_set_system_area(IsoWriteOpts *opts, char data[32768],
int options, int flag); int options, int flag);
/**
* Explicitely set the four timestamps of the emerging Primary Volume
* Descriptor. Default with all parameters is 0.
* ECMA-119 defines them as:
* @param vol_creation_time
* When "the information in the volume was created."
* A value of 0 means that the timepoint of write start is to be used.
* @param vol_modification_time
* When "the information in the volume was last modified."
* A value of 0 means that the timepoint of write start is to be used.
* @param vol_expiration_time
* When "the information in the volume may be regarded as obsolete."
* A value of 0 means that the information never shall expire.
* @param vol_effective_time
* When "the information in the volume may be used."
* A value of 0 means that not such retention is intended.
* @param uuid
* If this text is not empty, then it overrides vol_modification_time
* by copying the first 16 decimal digits from uuid, eventually
* padding up with decimal '1', and writing a NUL-byte as timezone.
* Other than with vol_modification_time the resulting string in the ISO
* image is fully predictable and free of timezone pitfalls.
* It should express a reasonable time in form YYYYMMDDhhmmsscc
* E.g.: "2010040711405800" = 7 Apr 2010 11:40:58 (+0 centiseconds)
*
* @since 0.6.30
*/
int iso_write_opts_set_pvd_times(IsoWriteOpts *opts,
time_t vol_creation_time, time_t vol_modification_time,
time_t vol_expiration_time, time_t vol_effective_time,
char *vol_uuid);
/** /**
* Inquire the start address of the file data blocks after having used * Inquire the start address of the file data blocks after having used
* IsoWriteOpts with iso_image_create_burn_source(). * IsoWriteOpts with iso_image_create_burn_source().