From a4f07eb3b3c944286c1592d7a68a6dbf91675156 Mon Sep 17 00:00:00 2001 From: Thomas Schmitt Date: Tue, 12 Mar 2013 17:42:13 +0100 Subject: [PATCH] New API call iso_image_get_pvd_times(). --- libisofs/fs_image.c | 20 +++++++++++++++++++- libisofs/image.c | 35 +++++++++++++++++++++++++++++++++++ libisofs/image.h | 8 ++++++++ libisofs/libisofs.h | 30 ++++++++++++++++++++++++++++++ libisofs/libisofs.ver | 1 + 5 files changed, 93 insertions(+), 1 deletion(-) diff --git a/libisofs/fs_image.c b/libisofs/fs_image.c index f64e77a..1539ee1 100644 --- a/libisofs/fs_image.c +++ b/libisofs/fs_image.c @@ -241,6 +241,10 @@ typedef struct char *copyright_file_id; char *abstract_file_id; char *biblio_file_id; + char *creation_time; + char *modification_time; + char *expiration_time; + char *effective_time; /* extension information */ @@ -2089,6 +2093,10 @@ void ifs_fs_free(IsoFilesystem *fs) free(data->copyright_file_id); free(data->abstract_file_id); free(data->biblio_file_id); + free(data->creation_time); + free(data->modification_time); + free(data->expiration_time); + free(data->effective_time); free(data->input_charset); free(data->local_charset); @@ -2317,7 +2325,15 @@ int read_pvm(_ImageFsData *data, uint32_t block) data->copyright_file_id[0] = 0; data->abstract_file_id[0] = 0; data->biblio_file_id[0] = 0; - } + } + data->creation_time = + iso_util_strcopy_untail((char*) pvm->vol_creation_time, 17); + data->modification_time = + iso_util_strcopy_untail((char*) pvm->vol_modification_time, 17); + data->expiration_time = + iso_util_strcopy_untail((char*) pvm->vol_expiration_time, 17); + data->effective_time = + iso_util_strcopy_untail((char*) pvm->vol_effective_time, 17); data->nblocks = iso_read_bb(pvm->vol_space_size, 4, NULL); @@ -3553,6 +3569,8 @@ int iso_image_import(IsoImage *image, IsoDataSource *src, iso_image_set_copyright_file_id(image, data->copyright_file_id); iso_image_set_abstract_file_id(image, data->abstract_file_id); iso_image_set_biblio_file_id(image, data->biblio_file_id); + iso_image_set_pvd_times(image, data->creation_time, + data->modification_time, data->expiration_time, data->effective_time); if (features != NULL) { *features = malloc(sizeof(IsoReadImageFeatures)); diff --git a/libisofs/image.c b/libisofs/image.c index 3442622..b8a6e84 100644 --- a/libisofs/image.c +++ b/libisofs/image.c @@ -145,6 +145,10 @@ void iso_image_unref(IsoImage *image) free(image->copyright_file_id); free(image->abstract_file_id); free(image->biblio_file_id); + free(image->creation_time); + free(image->modification_time); + free(image->expiration_time); + free(image->effective_time); if (image->used_inodes != NULL) free(image->used_inodes); if (image->system_area_data != NULL) @@ -335,6 +339,37 @@ const char *iso_image_get_biblio_file_id(const IsoImage *image) return image->biblio_file_id; } +int iso_image_set_pvd_times(IsoImage *image, + char *creation_time, char *modification_time, + char *expiration_time, char *effective_time) +{ + if (creation_time == NULL || modification_time == NULL || + expiration_time == NULL || effective_time == NULL) + return ISO_NULL_POINTER; + image->creation_time = strdup(creation_time); + image->modification_time = strdup(modification_time); + image->expiration_time = strdup(expiration_time); + image->effective_time = strdup(effective_time); + if (image->creation_time == NULL || image->modification_time == NULL || + image->expiration_time == NULL || image->effective_time == NULL) + return ISO_OUT_OF_MEM; + return ISO_SUCCESS; +} + +int iso_image_get_pvd_times(IsoImage *image, + char **creation_time, char **modification_time, + char **expiration_time, char **effective_time) +{ + if (image->creation_time == NULL || image->modification_time == NULL || + image->expiration_time == NULL || image->effective_time == NULL) + return ISO_NULL_POINTER; + *creation_time = image->creation_time; + *modification_time = image->modification_time; + *expiration_time = image->expiration_time; + *effective_time = image->effective_time; + return ISO_SUCCESS; +} + int iso_image_get_msg_id(IsoImage *image) { return image->id; diff --git a/libisofs/image.h b/libisofs/image.h index 0645430..d741abd 100644 --- a/libisofs/image.h +++ b/libisofs/image.h @@ -49,6 +49,10 @@ struct Iso_Image char *copyright_file_id; char *abstract_file_id; char *biblio_file_id; + char *creation_time; + char *modification_time; + char *expiration_time; + char *effective_time; /* el-torito boot catalog */ struct el_torito_boot_catalog *bootcat; @@ -234,4 +238,8 @@ int iso_image_set_checksums(IsoImage *image, char *checksum_array, uint32_t idx_count, int flag); +int iso_image_set_pvd_times(IsoImage *image, + char *creation_time, char *modification_time, + char *expiration_time, char *effective_time); + #endif /*LIBISO_IMAGE_H_*/ diff --git a/libisofs/libisofs.h b/libisofs/libisofs.h index 7da0129..e26afd2 100644 --- a/libisofs/libisofs.h +++ b/libisofs/libisofs.h @@ -3027,6 +3027,36 @@ void iso_image_set_biblio_file_id(IsoImage *image, const char *biblio_file_id); */ const char *iso_image_get_biblio_file_id(const IsoImage *image); +/** + * Get the four timestamps from the Primary Volume Descriptor of the imported + * ISO image. The timestamps are strings which are either empty or consist + * of 17 digits of the form YYYYMMDDhhmmsscc. + * None of the returned string pointers shall be used for altering or freeing + * data. They are just for reading. + * + * @param image + * The image to be inquired. + * @param vol_creation_time + * Returns a pointer to the Volume Creation time: + * When "the information in the volume was created." + * @param vol_modification_time + * Returns a pointer to Volume Modification time: + * When "the information in the volume was last modified." + * @param vol_expiration_time + * Returns a pointer to Volume Expiration time: + * When "the information in the volume may be regarded as obsolete." + * @param vol_effective_time + * Returns a pointer to Volume Expiration time: + * When "the information in the volume may be used." + * @return + * ISO_SUCCESS or error + * + * @since 1.2.8 + */ +int iso_image_get_pvd_times(IsoImage *image, + char **creation_time, char **modification_time, + char **expiration_time, char **effective_time); + /** * Create a new set of El-Torito bootable images by adding a boot catalog * and the default boot image. diff --git a/libisofs/libisofs.ver b/libisofs/libisofs.ver index b9df3eb..0adf65a 100644 --- a/libisofs/libisofs.ver +++ b/libisofs/libisofs.ver @@ -98,6 +98,7 @@ iso_image_get_data_preparer_id; iso_image_get_mips_boot_files; iso_image_get_msg_id; iso_image_get_publisher_id; +iso_image_get_pvd_times; iso_image_get_root; iso_image_get_session_md5; iso_image_get_system_area;