Change message functions signature.

This commit is contained in:
Vreixo Formoso 2007-12-30 22:04:41 +01:00
parent d8cb56ecf3
commit e18f5d8898
7 changed files with 71 additions and 57 deletions

View File

@ -185,12 +185,13 @@ int ecma119_writer_compute_data_blocks(IsoImageWriter *writer)
target = writer->target;
/* compute position of directories */
iso_msg_debug(target->image, "Computing position of dir structure");
iso_msg_debug(target->image->messenger,
"Computing position of dir structure");
target->ndirs = 0;
calc_dir_pos(target, target->root);
/* compute length of pathlist */
iso_msg_debug(target->image, "Computing length of pathlist");
iso_msg_debug(target->image->messenger, "Computing length of pathlist");
path_table_size = calc_path_table_size(target->root);
/* compute location for path tables */
@ -295,7 +296,7 @@ int ecma119_writer_write_vol_desc(IsoImageWriter *writer)
t = writer->target;
image = t->image;
iso_msg_debug(image, "Write Primary Volume Descriptor");
iso_msg_debug(image->messenger, "Write Primary Volume Descriptor");
memset(&vol, 0, sizeof(struct ecma119_pri_vol_desc));
@ -546,7 +547,7 @@ int write_path_tables(Ecma119Image *t)
size_t i, j, cur;
Ecma119Node **pathlist;
iso_msg_debug(t->image, "Writing ISO Path tables");
iso_msg_debug(t->image->messenger, "Writing ISO Path tables");
/* allocate temporal pathlist */
pathlist = malloc(sizeof(void*) * t->ndirs);
@ -634,7 +635,8 @@ int ecma119_writer_create(Ecma119Image *target)
/* add this writer to image */
target->writers[target->nwriters++] = writer;
iso_msg_debug(target->image, "Creating low level ECMA-119 tree...");
iso_msg_debug(target->image->messenger,
"Creating low level ECMA-119 tree...");
ret = ecma119_tree_create(target);
if (ret < 0) {
return ret;
@ -654,7 +656,7 @@ void *write_function(void *arg)
IsoImageWriter *writer;
Ecma119Image *target = (Ecma119Image*)arg;
iso_msg_debug(target->image, "Starting image writing...");
iso_msg_debug(target->image->messenger, "Starting image writing...");
target->bytes_written = (off_t) 0;
target->percent_written = 0;
@ -669,7 +671,7 @@ void *write_function(void *arg)
}
/* write volume descriptors, one per writer */
iso_msg_debug(target->image, "Write volume descriptors");
iso_msg_debug(target->image->messenger, "Write volume descriptors");
for (i = 0; i < target->nwriters; ++i) {
writer = target->writers[i];
res = writer->write_vol_desc(writer);
@ -706,7 +708,7 @@ void *write_function(void *arg)
pthread_exit(NULL);
write_error: ;
iso_msg_fatal(target->image, LIBISO_WRITE_ERROR,
iso_msg_fatal(target->image->messenger, LIBISO_WRITE_ERROR,
"Image write error, code %d", res);
iso_ring_buffer_writer_close(target->buffer);
pthread_exit(NULL);
@ -843,7 +845,7 @@ int ecma119_image_new(IsoImage *src, Ecma119WriteOpts *opts, Ecma119Image **img)
ret = pthread_create(&(target->wthread), &(target->th_attr),
write_function, (void *) target);
if (ret != 0) {
iso_msg_fatal(target->image, LIBISO_THREAD_ERROR,
iso_msg_fatal(target->image->messenger, LIBISO_THREAD_ERROR,
"Cannot create writer thread");
ret = ISO_THREAD_ERROR;
goto target_cleanup;
@ -874,7 +876,8 @@ static int bs_read(struct burn_source *bs, unsigned char *buf, int size)
return size;
} else if (ret < 0) {
/* error */
iso_msg_fatal(t->image, LIBISO_READ_ERROR, "Error reading pipe");
iso_msg_fatal(t->image->messenger, LIBISO_READ_ERROR,
"Error reading buffer");
return -1;
} else {
/* EOF */
@ -898,9 +901,10 @@ static void bs_free_data(struct burn_source *bs)
/* wait until writer thread finishes */
pthread_join(target->wthread, NULL);
iso_msg_debug(target->image, "Writer thread joined");
iso_msg_debug(target->image, "Ring buffer was %d times full and %d times "
"empty", iso_ring_buffer_get_times_full(target->buffer),
iso_msg_debug(target->image->messenger, "Writer thread joined");
iso_msg_debug(target->image->messenger,
"Ring buffer was %d times full and %d times empty",
iso_ring_buffer_get_times_full(target->buffer),
iso_ring_buffer_get_times_empty(target->buffer));
/* now we can safety free target */
@ -975,8 +979,8 @@ int iso_write(Ecma119Image *target, void *buf, size_t count)
/* only report in 5% chunks */
if (percent >= target->percent_written + 5) {
iso_msg_debug(target->image, "Processed %u of %u KB (%d %%)",
kbw, kbt, percent);
iso_msg_debug(target->image->messenger,
"Processed %u of %u KB (%d %%)", kbw, kbt, percent);
target->percent_written = percent;
}
}

View File

@ -34,7 +34,7 @@ int get_iso_name(Ecma119Image *img, IsoNode *iso, char **name)
ret = str2ascii(img->input_charset, iso->name, &ascii_name);
if (ret < 0) {
iso_msg_debug(img->image, "Can't convert %s", iso->name);
iso_msg_debug(img->image->messenger, "Can't convert %s", iso->name);
return ret;
}
@ -135,7 +135,7 @@ int create_file(Ecma119Image *img, IsoFile *iso, Ecma119Node **node)
size = iso_stream_get_size(iso->stream);
if (size > (off_t)0xffffffff) {
iso_msg_note(img->image, LIBISO_FILE_IGNORED,
iso_msg_note(img->image->messenger, LIBISO_FILE_IGNORED,
"File \"%s\" can't be added to image because is "
"greater than 4GB", iso->node.name);
return 0;
@ -241,7 +241,7 @@ int create_tree(Ecma119Image *image, IsoNode *iso, Ecma119Node **tree,
max_path = pathlen + 1 + (iso_name ? strlen(iso_name) : 0);
if (!image->rockridge && !image->allow_deep_paths) {
if ((iso->type == LIBISO_DIR && depth > 8) || max_path > 255) {
iso_msg_note(image->image, LIBISO_FILE_IGNORED,
iso_msg_note(image->image->messenger, LIBISO_FILE_IGNORED,
"File \"%s\" can't be added, because depth > 8 "
"or path length over 255", iso->name);
free(iso_name);
@ -258,8 +258,9 @@ int create_tree(Ecma119Image *image, IsoNode *iso, Ecma119Node **tree,
ret = create_symlink(image, (IsoSymlink*)iso, &node);
} else {
/* symlinks are only supported when RR is enabled */
iso_msg_note(image->image, LIBISO_FILE_IGNORED, "File \"%s\" "
"ignored. Symlinks need RockRidge extensions.", iso->name);
iso_msg_note(image->image->messenger, LIBISO_FILE_IGNORED,
"File \"%s\" ignored. Symlinks need RockRidge extensions.",
iso->name);
ret = 0;
}
break;
@ -268,8 +269,9 @@ int create_tree(Ecma119Image *image, IsoNode *iso, Ecma119Node **tree,
ret = create_special(image, (IsoSpecial*)iso, &node);
} else {
/* symlinks are only supported when RR is enabled */
iso_msg_note(image->image, LIBISO_FILE_IGNORED, "File \"%s\" "
"ignored. Special files need RockRidge extensions.", iso->name);
iso_msg_note(image->image->messenger, LIBISO_FILE_IGNORED,
"File \"%s\" ignored. Special files need RockRidge extensions.",
iso->name);
ret = 0;
}
break;
@ -495,7 +497,8 @@ int mangle_single_dir(Ecma119Image *img, Ecma119Node *dir, int max_file_len,
if (new == NULL) {
return ISO_MEM_ERROR;
}
iso_msg_debug(img->image, "\"%s\" renamed to \"%s\"",
iso_msg_debug(img->image->messenger,
"\"%s\" renamed to \"%s\"",
children[k]->iso_name, new);
free(children[k]->iso_name);
children[k]->iso_name = new;
@ -735,10 +738,10 @@ int ecma119_tree_create(Ecma119Image *img)
}
img->root = root;
iso_msg_debug(img->image, "Sorting the low level tree...");
iso_msg_debug(img->image->messenger, "Sorting the low level tree...");
sort_tree(root);
iso_msg_debug(img->image, "Mangling names...");
iso_msg_debug(img->image->messenger, "Mangling names...");
ret = mangle_tree(img, 1);
if (ret < 0) {
return ret;

View File

@ -12,6 +12,7 @@
#include "util.h"
#include "writer.h"
#include "messages.h"
#include "image.h"
#include <stdlib.h>
#include <string.h>
@ -218,7 +219,7 @@ int filesrc_writer_write_data(IsoImageWriter *writer)
t = writer->target;
filelist = writer->data;
iso_msg_debug(t->image, "Writing Files...");
iso_msg_debug(t->image->messenger, "Writing Files...");
nfiles = iso_rbtree_get_size(t->files);
for (i = 0; i < nfiles; ++i) {
@ -238,8 +239,8 @@ int filesrc_writer_write_data(IsoImageWriter *writer)
* 0's to image
*/
char *name = iso_stream_get_name(file->stream);
iso_msg_sorry(t->image, LIBISO_FILE_CANT_WRITE, "File \"%s\" can't"
" be opened. Filling with 0s.", name);
iso_msg_sorry(t->image->messenger, LIBISO_FILE_CANT_WRITE,
"File \"%s\" can't be opened. Filling with 0s.", name);
free(name);
memset(buffer, 0, BLOCK_SIZE);
for (b = 0; b < nblocks; ++b) {
@ -268,17 +269,18 @@ int filesrc_writer_write_data(IsoImageWriter *writer)
char *name = iso_stream_get_name(file->stream);
if (res < 0) {
/* error */
iso_msg_sorry(t->image, LIBISO_FILE_CANT_WRITE,
iso_msg_sorry(t->image->messenger, LIBISO_FILE_CANT_WRITE,
"Read error in file %s.", name);
} else {
/* eof */
iso_msg_sorry(t->image, LIBISO_FILE_CANT_WRITE,
iso_msg_sorry(t->image->messenger, LIBISO_FILE_CANT_WRITE,
"Premature end of file %s.", name);
}
free(name);
/* fill with 0s */
iso_msg_sorry(t->image, LIBISO_FILE_CANT_WRITE, "Filling with 0");
iso_msg_sorry(t->image->messenger, LIBISO_FILE_CANT_WRITE,
"Filling with 0");
memset(buffer, 0, BLOCK_SIZE);
while (b++ < nblocks) {
res = iso_write(t, buffer, BLOCK_SIZE);

View File

@ -16,7 +16,7 @@
#define MAX_MSG_LEN 4096
void iso_msg_debug(IsoImage *img, const char *fmt, ...)
void iso_msg_debug(IsoMessenger *msgr, const char *fmt, ...)
{
char msg[MAX_MSG_LEN];
va_list ap;
@ -25,11 +25,11 @@ void iso_msg_debug(IsoImage *img, const char *fmt, ...)
vsnprintf(msg, MAX_MSG_LEN, fmt, ap);
va_end(ap);
libiso_msgs_submit(img->messenger, -1, 0x00000002, LIBISO_MSGS_SEV_DEBUG,
libiso_msgs_submit(msgr, -1, 0x00000002, LIBISO_MSGS_SEV_DEBUG,
LIBISO_MSGS_PRIO_ZERO, msg, 0, 0);
}
void iso_msg_note(IsoImage *img, int error_code, const char *fmt, ...)
void iso_msg_note(IsoMessenger *msgr, int error_code, const char *fmt, ...)
{
char msg[MAX_MSG_LEN];
va_list ap;
@ -38,11 +38,11 @@ void iso_msg_note(IsoImage *img, int error_code, const char *fmt, ...)
vsnprintf(msg, MAX_MSG_LEN, fmt, ap);
va_end(ap);
libiso_msgs_submit(img->messenger, -1, error_code, LIBISO_MSGS_SEV_NOTE,
libiso_msgs_submit(msgr, -1, error_code, LIBISO_MSGS_SEV_NOTE,
LIBISO_MSGS_PRIO_MEDIUM, msg, 0, 0);
}
void iso_msg_hint(IsoImage *img, int error_code, const char *fmt, ...)
void iso_msg_hint(IsoMessenger *msgr, int error_code, const char *fmt, ...)
{
char msg[MAX_MSG_LEN];
va_list ap;
@ -51,11 +51,11 @@ void iso_msg_hint(IsoImage *img, int error_code, const char *fmt, ...)
vsnprintf(msg, MAX_MSG_LEN, fmt, ap);
va_end(ap);
libiso_msgs_submit(img->messenger, -1, error_code, LIBISO_MSGS_SEV_HINT,
libiso_msgs_submit(msgr, -1, error_code, LIBISO_MSGS_SEV_HINT,
LIBISO_MSGS_PRIO_MEDIUM, msg, 0, 0);
}
void iso_msg_warn(IsoImage *img, int error_code, const char *fmt, ...)
void iso_msg_warn(IsoMessenger *msgr, int error_code, const char *fmt, ...)
{
char msg[MAX_MSG_LEN];
va_list ap;
@ -64,11 +64,11 @@ void iso_msg_warn(IsoImage *img, int error_code, const char *fmt, ...)
vsnprintf(msg, MAX_MSG_LEN, fmt, ap);
va_end(ap);
libiso_msgs_submit(img->messenger, -1, error_code, LIBISO_MSGS_SEV_WARNING,
libiso_msgs_submit(msgr, -1, error_code, LIBISO_MSGS_SEV_WARNING,
LIBISO_MSGS_PRIO_MEDIUM, msg, 0, 0);
}
void iso_msg_sorry(IsoImage *img, int error_code, const char *fmt, ...)
void iso_msg_sorry(IsoMessenger *msgr, int error_code, const char *fmt, ...)
{
char msg[MAX_MSG_LEN];
va_list ap;
@ -77,11 +77,11 @@ void iso_msg_sorry(IsoImage *img, int error_code, const char *fmt, ...)
vsnprintf(msg, MAX_MSG_LEN, fmt, ap);
va_end(ap);
libiso_msgs_submit(img->messenger, -1, error_code, LIBISO_MSGS_SEV_SORRY,
libiso_msgs_submit(msgr, -1, error_code, LIBISO_MSGS_SEV_SORRY,
LIBISO_MSGS_PRIO_HIGH, msg, 0, 0);
}
void iso_msg_fatal(IsoImage *img, int error_code, const char *fmt, ...)
void iso_msg_fatal(IsoMessenger *msgr, int error_code, const char *fmt, ...)
{
char msg[MAX_MSG_LEN];
va_list ap;
@ -90,7 +90,7 @@ void iso_msg_fatal(IsoImage *img, int error_code, const char *fmt, ...)
vsnprintf(msg, MAX_MSG_LEN, fmt, ap);
va_end(ap);
libiso_msgs_submit(img->messenger, -1, error_code, LIBISO_MSGS_SEV_FATAL,
libiso_msgs_submit(msgr, -1, error_code, LIBISO_MSGS_SEV_FATAL,
LIBISO_MSGS_PRIO_HIGH, msg, 0, 0);
}

View File

@ -74,16 +74,18 @@
/** Unsupported file type for Joliet tree */
#define LIBISO_JOLIET_WRONG_FILE_TYPE 0x00030301
void iso_msg_debug(IsoImage *img, const char *fmt, ...);
typedef struct libiso_msgs IsoMessenger;
void iso_msg_note(IsoImage *img, int error_code, const char *fmt, ...);
void iso_msg_debug(IsoMessenger *msgr, const char *fmt, ...);
void iso_msg_hint(IsoImage *img, int error_code, const char *fmt, ...);
void iso_msg_note(IsoMessenger *msgr, int error_code, const char *fmt, ...);
void iso_msg_warn(IsoImage *img, int error_code, const char *fmt, ...);
void iso_msg_hint(IsoMessenger *msgr, int error_code, const char *fmt, ...);
void iso_msg_sorry(IsoImage *img, int error_code, const char *fmt, ...);
void iso_msg_warn(IsoMessenger *msgr, int error_code, const char *fmt, ...);
void iso_msg_fatal(IsoImage *img, int error_code, const char *fmt, ...);
void iso_msg_sorry(IsoMessenger *msgr, int error_code, const char *fmt, ...);
void iso_msg_fatal(IsoMessenger *msgr, int error_code, const char *fmt, ...);
#endif /*MESSAGES_H_*/

View File

@ -13,6 +13,7 @@
#include "error.h"
#include "writer.h"
#include "messages.h"
#include "image.h"
#include <string.h>
@ -260,7 +261,7 @@ char *get_rr_name(Ecma119Image *t, Ecma119Node *n)
ret = strconv(n->node->name, t->input_charset, t->output_charset, &name);
if (ret < 0) {
iso_msg_sorry(t->image, LIBISO_CHARSET_ERROR,
iso_msg_sorry(t->image->messenger, LIBISO_CHARSET_ERROR,
"Charset conversion error. Can't convert %s from %s to %s",
n->node->name, t->input_charset, t->output_charset);

View File

@ -460,7 +460,7 @@ int iso_add_dir_aux(IsoImage *image, IsoDir *parent, IsoFileSource *dir)
result = iso_file_source_open(dir);
if (result < 0) {
iso_msg_debug(image, "Can't open dir %s",
iso_msg_debug(image->messenger, "Can't open dir %s",
iso_file_source_get_path(dir));
return result;
}
@ -475,15 +475,15 @@ int iso_add_dir_aux(IsoImage *image, IsoDir *parent, IsoFileSource *dir)
name = iso_file_source_get_name(file);
if (check_excludes(image, iso_file_source_get_path(file))) {
iso_msg_debug(image, "Skipping excluded file %s",
iso_msg_debug(image->messenger, "Skipping excluded file %s",
iso_file_source_get_path(file));
action = 2;
} else if (check_hidden(image, name)) {
iso_msg_debug(image, "Skipping hidden file %s",
iso_msg_debug(image->messenger, "Skipping hidden file %s",
iso_file_source_get_path(file));
action = 2;
} else {
iso_msg_debug(image, "Adding file %s",
iso_msg_debug(image->messenger, "Adding file %s",
iso_file_source_get_path(file));
action = 1;
}
@ -523,8 +523,9 @@ int iso_add_dir_aux(IsoImage *image, IsoDir *parent, IsoFileSource *dir)
result = builder->create_node(builder, image, file, &new);
if (result < 0) {
iso_msg_note(image, LIBISO_FILE_IGNORED, "Error %d when adding "
"file %s", result, iso_file_source_get_path(file));
iso_msg_note(image->messenger, LIBISO_FILE_IGNORED,
"Error %d when adding file %s", result,
iso_file_source_get_path(file));
if (image->recOpts.report) {
action = image->recOpts.report(file, result, flag);
@ -584,7 +585,8 @@ int iso_add_dir_aux(IsoImage *image, IsoDir *parent, IsoFileSource *dir)
if (result < 0) {
/* error reading dir, should never occur */
iso_msg_sorry(image, LIBISO_CANT_READ_FILE, "Error reading dir");
iso_msg_sorry(image->messenger, LIBISO_CANT_READ_FILE,
"Error reading dir");
action = result;
}