From 16dcf4a29c2d8cb9b0ff0926d0446bd0f1edbd76 Mon Sep 17 00:00:00 2001 From: Thomas Schmitt Date: Mon, 4 Oct 2010 13:18:06 +0200 Subject: [PATCH] Draining and forwarding possibly enabled libjte message list. Changed severity of error code ISO_LIBJTE_FILE_FAILED to MISHAP. --- libisofs/ecma119.c | 15 ++++++++++----- libisofs/filesrc.c | 17 +++++++++++++---- libisofs/libisofs.h | 4 ++-- libisofs/messages.c | 34 ++++++++++++++++++++++++++++++++++ libisofs/messages.h | 6 ++++++ 5 files changed, 65 insertions(+), 11 deletions(-) diff --git a/libisofs/ecma119.c b/libisofs/ecma119.c index b0c9423..20668ba 100644 --- a/libisofs/ecma119.c +++ b/libisofs/ecma119.c @@ -104,13 +104,13 @@ static int show_chunk_to_jte(Ecma119Image *target, char *buf, int count) if (target->libjte_handle == NULL) return ISO_SUCCESS; - - /* >>> What is the meaning of libjte_show_data_chunk(islast) ? */ - ret = libjte_show_data_chunk(target->libjte_handle, buf, count, 1, 0, target->bytes_written + (off_t) count == target->total_size); - if (ret <= 0) + if (ret <= 0) { + iso_libjte_forward_msgs(target->libjte_handle, + target->image->id, ISO_LIBJTE_FILE_FAILED, 0); return ISO_LIBJTE_FILE_FAILED; + } #endif /* Libisofs_with_libjtE */ @@ -1267,8 +1267,11 @@ static int finish_libjte(Ecma119Image *target) if (target->libjte_handle != NULL) { ret = libjte_write_footer(target->libjte_handle); - if (ret <= 0) + if (ret <= 0) { + iso_libjte_forward_msgs(target->libjte_handle, + target->image->id, ISO_LIBJTE_END_FAILED, 0); return ISO_LIBJTE_END_FAILED; + } } #endif /* Libisofs_with_libjtE */ @@ -1601,6 +1604,8 @@ int ecma119_image_new(IsoImage *src, IsoWriteOpts *opts, Ecma119Image **img) target->libjte_handle = opts->libjte_handle; ret = libjte_write_header(target->libjte_handle); if (ret <= 0) { + iso_libjte_forward_msgs(target->libjte_handle, + target->image->id, ISO_LIBJTE_START_FAILED, 0); ret = ISO_LIBJTE_START_FAILED; goto target_cleanup; } diff --git a/libisofs/filesrc.c b/libisofs/filesrc.c index d03a22f..36ac0d3 100644 --- a/libisofs/filesrc.c +++ b/libisofs/filesrc.c @@ -393,9 +393,13 @@ int filesrc_writer_write_data(IsoImageWriter *writer) res = libjte_begin_data_file(t->libjte_handle, name, BLOCK_SIZE, file_size); if (res <= 0) { - filesrc_close(file); - ret = ISO_LIBJTE_FILE_FAILED; - goto ex; + res = iso_libjte_forward_msgs(t->libjte_handle, t->image->id, + ISO_LIBJTE_FILE_FAILED, 0); + if (res < 0) { + filesrc_close(file); + ret = ISO_LIBJTE_FILE_FAILED; + goto ex; + } } jte_begun = 1; } @@ -507,6 +511,8 @@ int filesrc_writer_write_data(IsoImageWriter *writer) if (t->libjte_handle != NULL) { res = libjte_end_data_file(t->libjte_handle); if (res <= 0) { + iso_libjte_forward_msgs(t->libjte_handle, t->image->id, + ISO_LIBJTE_FILE_FAILED, 0); ret = ISO_LIBJTE_FILE_FAILED; goto ex; } @@ -522,8 +528,11 @@ ex:; iso_md5_end(&ctx, md5); #ifdef Libisofs_with_libjtE - if (jte_begun) + if (jte_begun) { libjte_end_data_file(t->libjte_handle); + iso_libjte_forward_msgs(t->libjte_handle, t->image->id, + ISO_LIBJTE_END_FAILED, 0); + } #endif /* Libisofs_with_libjtE */ return ret; diff --git a/libisofs/libisofs.h b/libisofs/libisofs.h index a994ab5..dc75e39 100644 --- a/libisofs/libisofs.h +++ b/libisofs/libisofs.h @@ -6221,8 +6221,8 @@ int iso_md5_match(char first_md5[16], char second_md5[16]); #define ISO_LIBJTE_END_FAILED 0xE830FE93 /** Failed to process file for Jigdo Template Extraction - (FAILURE, HIGH, -366) */ -#define ISO_LIBJTE_FILE_FAILED 0xE830FE92 + (MISHAP, HIGH, -366) */ +#define ISO_LIBJTE_FILE_FAILED 0xE430FE92 /* Internal developer note: diff --git a/libisofs/messages.c b/libisofs/messages.c index 9df3290..e5b3d19 100644 --- a/libisofs/messages.c +++ b/libisofs/messages.c @@ -17,6 +17,10 @@ #include #include +#ifdef Libisofs_with_libjtE +#include +#endif + #include "libiso_msgs.h" #include "libisofs.h" #include "messages.h" @@ -523,3 +527,33 @@ int iso_report_errfile(char *path, int error_code, int os_errno, int flag) path, os_errno, 0); return(1); } + + +int iso_libjte_forward_msgs(void *libjte_handle, + int imgid, int errcode, int flag) +{ + +#ifdef Libisofs_with_libjtE + + char *msg = NULL; + int res; + struct libjte_env *handle = (struct libjte_env *) libjte_handle; + + res = ISO_SUCCESS; + while(1) { + msg= libjte_get_next_message(handle); + if(msg == NULL) + break; + res = iso_msg_submit(imgid, errcode, 0, msg); + free(msg); + } + return res; + +#else /* Libisofs_with_libjtE */ + + return ISO_SUCCESS; + +#endif /* ! Libisofs_with_libjtE */ + +} + diff --git a/libisofs/messages.h b/libisofs/messages.h index 788742e..693457b 100644 --- a/libisofs/messages.h +++ b/libisofs/messages.h @@ -54,4 +54,10 @@ int iso_msg_submit(int imgid, int errcode, int causedby, const char *fmt, ...); int iso_report_errfile(char *path, int error_code, int os_errno, int flag); +/* Drains the libjte message list and puts out the messages via + iso_msg_submit() +*/ +int iso_libjte_forward_msgs(void *libjte_handle, + int imgid, int errcode, int flag); + #endif /*MESSAGES_H_*/