libansilove

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

commit 14523ee847f59cbb7f6495f2d406268307d64aa6
parent 2b52d536f1776644870c085827555188da762b4d
Author: Frederic Cambus <fred@statdns.com>
Date:   Sat, 30 Jun 2018 00:13:44 +0200

All loaders now return -1 in case of failure

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 @@ -422,7 +422,7 @@ int ansi(struct input *inputFile, struct output *outputFile) if (!canvas) { perror("Can't allocate ANSi buffer image memory"); - exit(6); + return -1; } int32_t colors[16]; diff --git a/src/loaders/artworx.c b/src/loaders/artworx.c @@ -22,7 +22,7 @@ int artworx(struct input *inputFile, struct output *outputFile) // error output if (!canvas) { perror("Can't allocate buffer image memory"); - exit(7); + return -1; } // ADF color palette array diff --git a/src/loaders/binary.c b/src/loaders/binary.c @@ -16,7 +16,7 @@ int binary(struct input *inputFile, struct output *outputFile) // binary files must have an even size if (inputFile->size % 2) { fprintf(stderr, "\nBinary file is not valid.\n"); - exit(1); + return -1; } // some type declarations @@ -34,7 +34,7 @@ int binary(struct input *inputFile, struct output *outputFile) if (!canvas) { perror("Error, can't allocate buffer image memory"); - exit(6); + return -1; } // allocate black color diff --git a/src/loaders/icedraw.c b/src/loaders/icedraw.c @@ -52,7 +52,7 @@ int icedraw(struct input *inputFile, struct output *outputFile) } else { perror("Error allocating IDF buffer memory"); - exit(7); + return -1; } idf_buffer[i] = inputFile->data[loop + 4]; @@ -69,7 +69,7 @@ int icedraw(struct input *inputFile, struct output *outputFile) } else { perror("Error allocating IDF buffer memory"); - exit(8); + return -1; } // normal character @@ -86,7 +86,7 @@ int icedraw(struct input *inputFile, struct output *outputFile) // error output if (!canvas) { perror("Can't allocate buffer image memory"); - exit(9); + return -1; } gdImageColorAllocate(canvas, 0, 0, 0); diff --git a/src/loaders/tundra.c b/src/loaders/tundra.c @@ -31,7 +31,7 @@ int tundra(struct input *inputFile, struct output *outputFile) // need to add check for "TUNDRA24" string in the header if (tundra_version != 24) { fputs("\nInput file is not a TUNDRA file.\n\n", stderr); - exit(4); + return -1; } // read tundra file a first time to find the image size @@ -93,7 +93,7 @@ int tundra(struct input *inputFile, struct output *outputFile) if (!canvas) { perror("Error, can't allocate buffer image memory"); - exit(6); + return -1; } // process tundra diff --git a/src/loaders/xbin.c b/src/loaders/xbin.c @@ -18,7 +18,7 @@ int xbin(struct input *inputFile, struct output *outputFile) if (strncmp((char *)inputFile->data, "XBIN\x1a", 5) != 0) { fputs("\nNot an XBin.\n\n", stderr); - exit(4); + return -1; } int32_t xbin_width = (inputFile->data[6] << 8) + inputFile->data[5]; @@ -32,7 +32,7 @@ int xbin(struct input *inputFile, struct output *outputFile) if (!canvas) { perror("Error, can't allocate buffer image memory"); - exit(6); + return -1; } // allocate black color @@ -73,7 +73,7 @@ int xbin(struct input *inputFile, struct output *outputFile) font_data_xbin = (unsigned char *)malloc(xbin_fontsize * numchars); if (font_data_xbin == NULL) { perror("Memory error"); - exit(5); + return -1; } memcpy(font_data_xbin, inputFile->data+offset, (xbin_fontsize * numchars));