Draining and forwarding possibly enabled libjte message list.

Changed severity of error code ISO_LIBJTE_FILE_FAILED to MISHAP.
This commit is contained in:
Thomas Schmitt 2010-10-04 13:18:06 +02:00
parent 69a25c9734
commit 16dcf4a29c
5 changed files with 65 additions and 11 deletions

View File

@ -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;
}

View File

@ -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;

View File

@ -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:

View File

@ -17,6 +17,10 @@
#include <stdio.h>
#include <stdarg.h>
#ifdef Libisofs_with_libjtE
#include <libjte/libjte.h>
#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 */
}

View File

@ -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_*/