From e8f8876ee6570cbd9d005fb26e1a5fae89f8469a Mon Sep 17 00:00:00 2001 From: Thomas Schmitt Date: Mon, 6 Apr 2009 14:19:49 +0200 Subject: [PATCH] New API function iso_stream_get_source_path() tries to obtain a source path depending on the stream class. --- libisofs/libisofs.h | 36 +++++++++++++++++++++++++++--------- libisofs/stream.c | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+), 9 deletions(-) diff --git a/libisofs/libisofs.h b/libisofs/libisofs.h index 2d4f4f8..7b7747b 100644 --- a/libisofs/libisofs.h +++ b/libisofs/libisofs.h @@ -4067,20 +4067,22 @@ int iso_stream_update_size(IsoStream *stream); void iso_stream_get_id(IsoStream *stream, unsigned int *fs_id, dev_t *dev_id, ino_t *ino_id); -/* ts A90328 */ +/* ts A90406 */ /** - * Obtain the eventual input stream of a filter stream. + * Try to get eventual source path string of a stream. Meaning and availability + * of this string depends on the stream.class . Expect valid results with + * types "fsrc" and "cout". * @param stream - * The eventual filter stream to be inquired. + * The stream to be inquired. * @param flag - * Bitfield for control purposes. Submit 0 for now. + * Bitfield for control purposes, unused yet, submit 0 * @return - * The input stream, if one exists. Elsewise NULL. - * No extra reference to the stream is taken by this call. - * + * A copy of the path string. Apply free() when no longer needed. + * NULL if no path string is available. + * * @since 0.6.18 - */ -IsoStream *iso_stream_get_input_stream(IsoStream *stream, int flag); + */ +char *iso_stream_get_source_path(IsoStream *stream, int flag); /************ Error codes and return values for libisofs ********************/ @@ -4811,6 +4813,22 @@ int iso_file_add_external_filter(IsoFile *file, IsoExternalFilterCommand *cmd, int iso_file_remove_filter(IsoFile *file, int flag); +/* ts A90328 */ +/** + * Obtain the eventual input stream of a filter stream. + * @param stream + * The eventual filter stream to be inquired. + * @param flag + * Bitfield for control purposes. Submit 0 for now. + * @return + * The input stream, if one exists. Elsewise NULL. + * No extra reference to the stream is taken by this call. + * + * @since 0.6.18 + */ +IsoStream *iso_stream_get_input_stream(IsoStream *stream, int flag); + + /* ts A90402 */ /** * Obtain the IsoExternalFilterCommand which is eventually associated with the diff --git a/libisofs/stream.c b/libisofs/stream.c index 8ecc56b..3ae17c1 100644 --- a/libisofs/stream.c +++ b/libisofs/stream.c @@ -14,6 +14,7 @@ #include #include #include +#include ino_t serial_id = (ino_t)1; ino_t mem_serial_id = (ino_t)1; @@ -638,6 +639,8 @@ void iso_stream_get_file_name(IsoStream *stream, char *name) strcpy(name, "BOOT CATALOG"); } else if (!strncmp(type, "mem ", 4)) { strcpy(name, "MEM SOURCE"); + } else if (!strncmp(type, "extf", 4)) { + strcpy(name, "EXTERNAL FILTER"); } else { strcpy(name, "UNKNOWN SOURCE"); } @@ -653,3 +656,34 @@ IsoStream *iso_stream_get_input_stream(IsoStream *stream, int flag) return class->get_input_stream(stream, 0); } +/* ts A90406 API */ +char *iso_stream_get_source_path(IsoStream *stream, int flag) +{ + char *path = NULL, ivd[80], *raw_path = NULL; + + if (stream == NULL) { + return NULL; + } + if (stream->class == &fsrc_stream_class) { + FSrcStreamData *fsrc_data = stream->data; + + path = iso_file_source_get_path(fsrc_data->src); + } else if (stream->class == &cut_out_stream_class) { + struct cut_out_stream *cout_data = stream->data; + + raw_path = iso_file_source_get_path(cout_data->src); + sprintf(ivd, " %.f %.f", + (double) cout_data->offset, (double) cout_data->size); + path= calloc(strlen(raw_path) + strlen(ivd) + 1, 1); + if (path == NULL) { + goto ex; + } + strcpy(path, raw_path); + strcat(path, ivd); + } +ex:; + if (raw_path != NULL) + free(raw_path); + return path; +} +