From: Nick Bowler Date: Wed, 19 Jun 2013 01:07:51 +0000 (-0400) Subject: lbximg: Add an option to control the output filenames. X-Git-Url: http://git.draconx.ca/gitweb/liblbx.git/commitdiff_plain/2f0e47fcf78aeae3bcd0e8126f2f33b98bd285e8 lbximg: Add an option to control the output filenames. This will be needed for postmortem analysis of test cases that extract multiple images, since otherwise there is no easy way to prevent the tool from overwriting the earlier outputs. This was clearly intended to be a user setting from the start but for some reason it was never wired up to a command-line option. --- diff --git a/doc/man/lbximg.1 b/doc/man/lbximg.1 index f3ecece..5f0c6ee 100644 --- a/doc/man/lbximg.1 +++ b/doc/man/lbximg.1 @@ -64,6 +64,11 @@ inefficient and provided mainly for testing. Read from the specified .Ar path instead of standard input. +.It Fl -output-prefix Ar string +Prefix each output filename with the given string. Filenames are produced by +adding a frame number and file extension to the given prefix. The default +prefix is +.Li out . .It Fl n , -no-palette Instead of looking up colour indices in the palette, emit a grayscale image where the intensity value of a pixel is equal to the palette index itself. diff --git a/src/lbximg.c b/src/lbximg.c index 0a0057a..c88fc4e 100644 --- a/src/lbximg.c +++ b/src/lbximg.c @@ -38,6 +38,10 @@ static int verbose = 0; static char *outname = "out"; static int usepalette = 1; +enum { + OPT_PREFIX = UCHAR_MAX+1, +}; + static void printusage(void) { puts("usage: lbximg [-i|-d] [-v] [-p palette_file] [-O override_file]" @@ -332,19 +336,20 @@ int main(int argc, char **argv) static const char sopts[] = "idnvF:f:p:O:VH"; static const struct option lopts[] = { - { "identify", 0, NULL, 'i' }, - { "decode", 0, NULL, 'd' }, - { "verbose", 0, NULL, 'v' }, - { "file", 1, NULL, 'f' }, - { "format", 1, NULL, 'F' }, - { "palette", 1, NULL, 'p' }, - { "override", 1, NULL, 'O' }, + { "identify", 0, NULL, 'i' }, + { "decode", 0, NULL, 'd' }, + { "verbose", 0, NULL, 'v' }, + { "file", 1, NULL, 'f' }, + { "format", 1, NULL, 'F' }, + { "palette", 1, NULL, 'p' }, + { "override", 1, NULL, 'O' }, + { "no-palette", 0, NULL, 'n' }, - { "version", 0, NULL, 'V' }, - { "usage", 0, NULL, 'U' }, - { "help", 0, NULL, 'H' }, + { "output-prefix", 1, NULL, OPT_PREFIX }, - { "no-palette", 0, NULL, 'n' }, + { "version", 0, NULL, 'V' }, + { "usage", 0, NULL, 'U' }, + { "help", 0, NULL, 'H' }, { 0 } }; @@ -385,6 +390,9 @@ int main(int argc, char **argv) return EXIT_FAILURE; } break; + case OPT_PREFIX: + outname = optarg; + break; case 'V': tool_version(); return EXIT_SUCCESS;