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]"
unsigned char *framebits;
struct lbx_colour palette[256];
struct lbx_imginfo info;
+ int ret = EXIT_SUCCESS;
int extracted = 0;
unsigned int i;
if (usepalette) {
if (loadpalette(img, &info, palf, override, palette) == -1) {
+ ret = EXIT_FAILURE;
goto err;
}
}
data = lbx_img_getframe(img, i);
if (!data) {
tool_err(-1, "error in frame %u: %s", i, lbx_errmsg());
+ ret = EXIT_FAILURE;
continue;
}
if (!extracted) {
tool_err(-1, "no frames extracted.");
- goto err;
+ ret = EXIT_FAILURE;
}
-
- free(framebits);
- return EXIT_SUCCESS;
err:
free(framebits);
- return EXIT_FAILURE;
+ return ret;
}
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 }
};
return EXIT_FAILURE;
}
break;
+ case OPT_PREFIX:
+ outname = optarg;
+ break;
case 'V':
tool_version();
return EXIT_SUCCESS;