ansilove

ANSI and ASCII art to PNG converter in C
Log | Files | Refs | README | LICENSE

commit cb7f9635c266091e5790456c53862b92f0ec8be9
parent b6f16b4ca05f8afac020847ec58a36ef61fc4c52
Author: Frederic Cambus <fred@statdns.com>
Date:   Fri, 14 Feb 2020 18:17:20 +0100

Also use the loaders function prototype arrays when falling back to file extension.

Diffstat:
Msrc/ansilove.c | 29++++++++++-------------------
1 file changed, 10 insertions(+), 19 deletions(-)

diff --git a/src/ansilove.c b/src/ansilove.c @@ -248,29 +248,20 @@ main(int argc, char *argv[]) } } - /* fall back on extension if no loader was found */ + /* fall back on file extension if no loader was found */ if (!loader) { - if (!strcmp(fext, "pcb")) { - loader = ansilove_pcboard; - fileIsPCBoard = true; - } else if (!strcmp(fext, "bin")) { - loader = ansilove_binary; - fileIsBinary = true; - } else if (!strcmp(fext, "adf")) { - loader = ansilove_artworx; - } else if (!strcmp(fext, "idf")) { - loader = ansilove_icedraw; - } else if (!strcmp(fext, "tnd")) { - loader = ansilove_tundra; - fileIsTundra = true; - } else if (!strcmp(fext, "xb")) { - loader = ansilove_xbin; - } else { - loader = ansilove_ansi; - fileIsANSi = true; + for (size_t loop = 0; loop < 7; loop++) { + if (!strcmp(types[loop], fext)) { + loader = loaders[loop]; + break; + } } } + if (!loader) { + loader = ansilove_ansi; + } + if (loader(&ctx, &options) == -1) errx(EXIT_FAILURE, "%s", ansilove_error(&ctx));