libansilove

Library for converting ANSI, ASCII, and other formats to PNG
Log | Files | Refs | README | LICENSE

commit 9e3a4cde11f0f895eab33e3915df490d26349de9
parent 8a58b60d9eef5f68a4c977f75c719e45371aec0d
Author: Frederic Cambus <fred@statdns.com>
Date:   Wed,  4 Jul 2018 10:51:53 +0200

Save error codes in the ansilove_ctx context

Diffstat:
Msrc/loaders/ansi.c | 2+-
Msrc/loaders/artworx.c | 2+-
Msrc/loaders/binary.c | 4++--
Msrc/loaders/icedraw.c | 6+++---
Msrc/loaders/tundra.c | 4++--
Msrc/loaders/xbin.c | 6+++---
6 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/src/loaders/ansi.c b/src/loaders/ansi.c @@ -386,7 +386,7 @@ int ansilove_ansi(struct ansilove_ctx *ctx, struct output *outputFile) canvas = gdImageCreate(columns * outputFile->bits, (rowMax)*fontData.height); if (!canvas) { - perror("Can't allocate ANSi buffer image memory"); + ctx->error = GD_ERROR; return -1; } diff --git a/src/loaders/artworx.c b/src/loaders/artworx.c @@ -21,7 +21,7 @@ int ansilove_artworx(struct ansilove_ctx *ctx, struct output *outputFile) // error output if (!canvas) { - perror("Can't allocate buffer image memory"); + ctx->error = GD_ERROR; return -1; } diff --git a/src/loaders/binary.c b/src/loaders/binary.c @@ -15,7 +15,7 @@ int ansilove_binary(struct ansilove_ctx *ctx, struct output *outputFile) { // binary files must have an even size if (ctx->length % 2) { - fprintf(stderr, "\nBinary file is not valid.\n"); + ctx->error = FORMAT_ERROR; return -1; } @@ -33,7 +33,7 @@ int ansilove_binary(struct ansilove_ctx *ctx, struct output *outputFile) ((ctx->length / 2) / outputFile->columns * fontData.height)); if (!canvas) { - perror("Error, can't allocate buffer image memory"); + ctx->error = GD_ERROR; return -1; } diff --git a/src/loaders/icedraw.c b/src/loaders/icedraw.c @@ -48,7 +48,7 @@ int ansilove_icedraw(struct ansilove_ctx *ctx, struct output *outputFile) if (idf_buffer != NULL) { idf_buffer = temp; } else { - perror("Error allocating IDF buffer memory"); + ctx->error = MEMORY_ERROR; return -1; } @@ -63,7 +63,7 @@ int ansilove_icedraw(struct ansilove_ctx *ctx, struct output *outputFile) if (idf_buffer != NULL) { idf_buffer = temp; } else { - perror("Error allocating IDF buffer memory"); + ctx->error = MEMORY_ERROR; return -1; } @@ -80,7 +80,7 @@ int ansilove_icedraw(struct ansilove_ctx *ctx, struct output *outputFile) // error output if (!canvas) { - perror("Can't allocate buffer image memory"); + ctx->error = GD_ERROR; return -1; } gdImageColorAllocate(canvas, 0, 0, 0); diff --git a/src/loaders/tundra.c b/src/loaders/tundra.c @@ -35,7 +35,7 @@ int ansilove_tundra(struct ansilove_ctx *ctx, struct output *outputFile) // need to add check for "TUNDRA24" string in the header if (tundra_version != TUNDRA_VERSION) { - fputs("\nInput file is not a TUNDRA file.\n\n", stderr); + ctx->error = FORMAT_ERROR; return -1; } @@ -87,7 +87,7 @@ int ansilove_tundra(struct ansilove_ctx *ctx, struct output *outputFile) canvas = gdImageCreateTrueColor(80 * outputFile->bits, (row) * fontData.height); if (!canvas) { - perror("Error, can't allocate buffer image memory"); + ctx->error = GD_ERROR; return -1; } diff --git a/src/loaders/xbin.c b/src/loaders/xbin.c @@ -17,7 +17,7 @@ int ansilove_xbin(struct ansilove_ctx *ctx, struct output *outputFile) unsigned char *font_data_xbin = NULL; if (strncmp((char *)ctx->buffer, "XBIN\x1a", 5) != 0) { - fputs("\nNot an XBin.\n\n", stderr); + ctx->error = FORMAT_ERROR; return -1; } @@ -31,7 +31,7 @@ int ansilove_xbin(struct ansilove_ctx *ctx, struct output *outputFile) canvas = gdImageCreate(8 * xbin_width, xbin_fontsize * xbin_height); if (!canvas) { - perror("Error, can't allocate buffer image memory"); + ctx->error = GD_ERROR; return -1; } @@ -70,7 +70,7 @@ int ansilove_xbin(struct ansilove_ctx *ctx, struct output *outputFile) // allocate memory to contain the XBin font font_data_xbin = (unsigned char *)malloc(xbin_fontsize * numchars); if (font_data_xbin == NULL) { - perror("Memory error"); + ctx->error = MEMORY_ERROR; return -1; } memcpy(font_data_xbin, ctx->buffer+offset, (xbin_fontsize * numchars));