libansilove

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

commit 8e191219099db3551ef099dfac7afc13c239f1af
parent 07526f10ade95cee9c36420068c49d27b2e9f096
Author: Frederic Cambus <fred@statdns.com>
Date:   Fri, 26 Oct 2018 19:06:40 +0200

Fix some style issues

Diffstat:
Minclude/ansilove.h | 2+-
Msrc/error.c | 42+++++++++++++++++++++---------------------
Msrc/fonts.c | 262++++++++++++++++++++++++++++++++++++++++----------------------------------------
Msrc/loaders/ansi.c | 18+++++++++---------
Msrc/loaders/binary.c | 2+-
Msrc/loaders/tundra.c | 4++--
6 files changed, 165 insertions(+), 165 deletions(-)

diff --git a/include/ansilove.h b/include/ansilove.h @@ -84,7 +84,7 @@ struct ansilove_options { }; int ansilove_init(struct ansilove_ctx *, struct ansilove_options *); -char* ansilove_error(struct ansilove_ctx *); +char *ansilove_error(struct ansilove_ctx *); int ansilove_loadfile(struct ansilove_ctx *, char *); int ansilove_savefile(struct ansilove_ctx *, char *); int ansilove_clean(struct ansilove_ctx *); diff --git a/src/error.c b/src/error.c @@ -12,31 +12,31 @@ #include <stddef.h> #include "../include/ansilove.h" -char* +char * ansilove_error(struct ansilove_ctx *ctx) { if (ctx == NULL) return NULL; switch (ctx->error) { - case ANSILOVE_INVALID_PARAM: - return "Invalid parameter."; - break; - case ANSILOVE_FORMAT_ERROR: - return "File format error."; - break; - case ANSILOVE_MEMORY_ERROR: - return "Memory allocation error."; - break; - case ANSILOVE_FILE_READ_ERROR: - return "Error reading file."; - break; - case ANSILOVE_FILE_WRITE_ERROR: - return "Error writing file."; - break; - case ANSILOVE_GD_ERROR: - return "GD library error."; - break; - default: - return NULL; + case ANSILOVE_INVALID_PARAM: + return "Invalid parameter."; + break; + case ANSILOVE_FORMAT_ERROR: + return "File format error."; + break; + case ANSILOVE_MEMORY_ERROR: + return "Memory allocation error."; + break; + case ANSILOVE_FILE_READ_ERROR: + return "Error reading file."; + break; + case ANSILOVE_FILE_WRITE_ERROR: + return "Error writing file."; + break; + case ANSILOVE_GD_ERROR: + return "GD library error."; + break; + default: + return NULL; } } diff --git a/src/fonts.c b/src/fonts.c @@ -9,140 +9,140 @@ // See the LICENSE file for details. // -#include "fonts.h" #include "../include/ansilove.h" +#include "fonts.h" void alSelectFont(struct fontStruct *fontData, int font) { - switch(font) { - case ANSILOVE_FONT_CP437_80x50: - fontData->font_data = font_pc_80x50; - fontData->width = 9; - fontData->height = 8; - break; - case ANSILOVE_FONT_CP737: - fontData->font_data = font_pc_greek; - fontData->width = 9; - fontData->height = 16; - break; - case ANSILOVE_FONT_CP775: - fontData->font_data = font_pc_baltic; - fontData->width = 9; - fontData->height = 16; - break; - case ANSILOVE_FONT_CP850: - fontData->font_data = font_pc_latin1; - fontData->width = 9; - fontData->height = 16; - break; - case ANSILOVE_FONT_CP852: - fontData->font_data = font_pc_latin2; - fontData->width = 9; - fontData->height = 16; - break; - case ANSILOVE_FONT_CP855: - fontData->font_data = font_pc_cyrillic; - fontData->width = 9; - fontData->height = 16; - break; - case ANSILOVE_FONT_CP857: - fontData->font_data = font_pc_turkish; - fontData->width = 9; - fontData->height = 16; - break; - case ANSILOVE_FONT_CP860: - fontData->font_data = font_pc_portuguese; - fontData->width = 9; - fontData->height = 16; - break; - case ANSILOVE_FONT_CP861: - fontData->font_data = font_pc_icelandic; - fontData->width = 9; - fontData->height = 16; - break; - case ANSILOVE_FONT_CP862: - fontData->font_data = font_pc_hebrew; - fontData->width = 9; - fontData->height = 16; - break; - case ANSILOVE_FONT_CP863: - fontData->font_data = font_pc_french_canadian; - fontData->width = 9; - fontData->height = 16; - break; - case ANSILOVE_FONT_CP865: - fontData->font_data = font_pc_nordic; - fontData->width = 9; - fontData->height = 16; - break; - case ANSILOVE_FONT_CP866: - fontData->font_data = font_pc_russian; - fontData->width = 9; - fontData->height = 16; - break; - case ANSILOVE_FONT_CP869: - fontData->font_data = font_pc_greek_869; - fontData->width = 9; - fontData->height = 16; - break; - case ANSILOVE_FONT_TERMINUS: - fontData->font_data = font_pc_terminus; - fontData->width = 9; - fontData->height = 16; - break; - case ANSILOVE_FONT_MICROKNIGHT: - fontData->isAmigaFont = true; - fontData->font_data = font_amiga_microknight; - fontData->width = 8; - fontData->height = 16; - break; - case ANSILOVE_FONT_MICROKNIGHT_PLUS: - fontData->isAmigaFont = true; - fontData->font_data = font_amiga_microknight_plus; - fontData->width = 8; - fontData->height = 16; - break; - case ANSILOVE_FONT_MOSOUL: - fontData->isAmigaFont = true; - fontData->font_data = font_amiga_mosoul; - fontData->width = 8; - fontData->height = 16; - break; - case ANSILOVE_FONT_POT_NOODLE: - fontData->isAmigaFont = true; - fontData->font_data = font_amiga_pot_noodle; - fontData->width = 8; - fontData->height = 16; - break; - case ANSILOVE_FONT_TOPAZ: - fontData->isAmigaFont = true; - fontData->font_data = font_amiga_topaz_1200; - fontData->width = 8; - fontData->height = 16; - break; - case ANSILOVE_FONT_TOPAZ_PLUS: - fontData->isAmigaFont = true; - fontData->font_data = font_amiga_topaz_1200_plus; - fontData->width = 8; - fontData->height = 16; - break; - case ANSILOVE_FONT_TOPAZ500: - fontData->isAmigaFont = true; - fontData->font_data = font_amiga_topaz_500; - fontData->width = 8; - fontData->height = 16; - break; - case ANSILOVE_FONT_TOPAZ500_PLUS: - fontData->isAmigaFont = true; - fontData->font_data = font_amiga_topaz_500_plus; - fontData->width = 8; - fontData->height = 16; - break; - default: - // in all other cases use the standard DOS font - fontData->font_data = font_pc_80x25; - fontData->width = 9; - fontData->height = 16; - break; + switch (font) { + case ANSILOVE_FONT_CP437_80x50: + fontData->font_data = font_pc_80x50; + fontData->width = 9; + fontData->height = 8; + break; + case ANSILOVE_FONT_CP737: + fontData->font_data = font_pc_greek; + fontData->width = 9; + fontData->height = 16; + break; + case ANSILOVE_FONT_CP775: + fontData->font_data = font_pc_baltic; + fontData->width = 9; + fontData->height = 16; + break; + case ANSILOVE_FONT_CP850: + fontData->font_data = font_pc_latin1; + fontData->width = 9; + fontData->height = 16; + break; + case ANSILOVE_FONT_CP852: + fontData->font_data = font_pc_latin2; + fontData->width = 9; + fontData->height = 16; + break; + case ANSILOVE_FONT_CP855: + fontData->font_data = font_pc_cyrillic; + fontData->width = 9; + fontData->height = 16; + break; + case ANSILOVE_FONT_CP857: + fontData->font_data = font_pc_turkish; + fontData->width = 9; + fontData->height = 16; + break; + case ANSILOVE_FONT_CP860: + fontData->font_data = font_pc_portuguese; + fontData->width = 9; + fontData->height = 16; + break; + case ANSILOVE_FONT_CP861: + fontData->font_data = font_pc_icelandic; + fontData->width = 9; + fontData->height = 16; + break; + case ANSILOVE_FONT_CP862: + fontData->font_data = font_pc_hebrew; + fontData->width = 9; + fontData->height = 16; + break; + case ANSILOVE_FONT_CP863: + fontData->font_data = font_pc_french_canadian; + fontData->width = 9; + fontData->height = 16; + break; + case ANSILOVE_FONT_CP865: + fontData->font_data = font_pc_nordic; + fontData->width = 9; + fontData->height = 16; + break; + case ANSILOVE_FONT_CP866: + fontData->font_data = font_pc_russian; + fontData->width = 9; + fontData->height = 16; + break; + case ANSILOVE_FONT_CP869: + fontData->font_data = font_pc_greek_869; + fontData->width = 9; + fontData->height = 16; + break; + case ANSILOVE_FONT_TERMINUS: + fontData->font_data = font_pc_terminus; + fontData->width = 9; + fontData->height = 16; + break; + case ANSILOVE_FONT_MICROKNIGHT: + fontData->isAmigaFont = true; + fontData->font_data = font_amiga_microknight; + fontData->width = 8; + fontData->height = 16; + break; + case ANSILOVE_FONT_MICROKNIGHT_PLUS: + fontData->isAmigaFont = true; + fontData->font_data = font_amiga_microknight_plus; + fontData->width = 8; + fontData->height = 16; + break; + case ANSILOVE_FONT_MOSOUL: + fontData->isAmigaFont = true; + fontData->font_data = font_amiga_mosoul; + fontData->width = 8; + fontData->height = 16; + break; + case ANSILOVE_FONT_POT_NOODLE: + fontData->isAmigaFont = true; + fontData->font_data = font_amiga_pot_noodle; + fontData->width = 8; + fontData->height = 16; + break; + case ANSILOVE_FONT_TOPAZ: + fontData->isAmigaFont = true; + fontData->font_data = font_amiga_topaz_1200; + fontData->width = 8; + fontData->height = 16; + break; + case ANSILOVE_FONT_TOPAZ_PLUS: + fontData->isAmigaFont = true; + fontData->font_data = font_amiga_topaz_1200_plus; + fontData->width = 8; + fontData->height = 16; + break; + case ANSILOVE_FONT_TOPAZ500: + fontData->isAmigaFont = true; + fontData->font_data = font_amiga_topaz_500; + fontData->width = 8; + fontData->height = 16; + break; + case ANSILOVE_FONT_TOPAZ500_PLUS: + fontData->isAmigaFont = true; + fontData->font_data = font_amiga_topaz_500_plus; + fontData->width = 8; + fontData->height = 16; + break; + default: + // in all other cases use the standard DOS font + fontData->font_data = font_pc_80x25; + fontData->width = 9; + fontData->height = 16; + break; } } diff --git a/src/loaders/ansi.c b/src/loaders/ansi.c @@ -68,15 +68,15 @@ int ansilove_ansi(struct ansilove_ctx *ctx, struct ansilove_options *options) // to deal with the bits flag, we declared handy bool types switch (options->mode) { - case ANSILOVE_MODE_CED: - ced = true; - break; - case ANSILOVE_MODE_TRANSPARENT: - transparent = true; - break; - case ANSILOVE_MODE_WORKBENCH: - workbench = true; - break; + case ANSILOVE_MODE_CED: + ced = true; + break; + case ANSILOVE_MODE_TRANSPARENT: + transparent = true; + break; + case ANSILOVE_MODE_WORKBENCH: + workbench = true; + break; } // libgd image pointers diff --git a/src/loaders/binary.c b/src/loaders/binary.c @@ -72,7 +72,7 @@ int ansilove_binary(struct ansilove_ctx *ctx, struct ansilove_options *options) } character = ctx->buffer[loop]; - + if (ctx->length > loop) { attribute = ctx->buffer[loop+1]; diff --git a/src/loaders/tundra.c b/src/loaders/tundra.c @@ -75,7 +75,7 @@ int ansilove_tundra(struct ansilove_ctx *ctx, struct ansilove_options *options) cursor = ctx->buffer[loop]; - switch(cursor) { + switch (cursor) { case TUNDRA_POSITION: row = (ctx->buffer[loop + 1] << 24) + (ctx->buffer[loop + 2] << 16) + @@ -136,7 +136,7 @@ int ansilove_tundra(struct ansilove_ctx *ctx, struct ansilove_options *options) cursor = character = ctx->buffer[loop]; - switch(cursor) { + switch (cursor) { case TUNDRA_POSITION: row = (ctx->buffer[loop + 1] << 24) + (ctx->buffer[loop + 2] << 16) +