10 static const char *progname;
11 #define errmsg(fmt, ...) (\
12 fprintf(stderr, "%s: " fmt, progname, __VA_ARGS__)\
21 int main(int argc, char **argv)
23 int mode = MODE_NONE, verbose = 0;
24 FILE *inf = stdin, *palf = NULL;
25 const char *name = "stdin";
29 static const char *sopts = "idvf:p:";
30 static const struct option lopts[] = {
31 { "info", 0, NULL, 'i' },
32 { "decode", 0, NULL, 'd' },
33 { "verbose", 0, NULL, 'v' },
34 { "file", 1, NULL, 'f' },
35 { "palette", 1, NULL, 'p' },
40 progname = "lbximg"; /* argv[0]; */
41 while ((opt = getopt_long(argc, argv, sopts, lopts, NULL)) != -1) {
53 if (strcmp(optarg, "-") == 0)
56 name = strrchr(optarg, '/');
57 name = name ? name+1 : optarg;
59 inf = fopen(optarg, "rb");
61 errmsg("failed to open %s: %m\n", optarg);
66 palf = fopen(optarg, "rb");
68 errmsg("failed to open %s: %m\n", optarg);
78 if (mode == MODE_NONE) {
79 errmsg("you must specify a mode.\n", 0);
83 img = lbximg_fopen(inf);
85 errmsg("failed to open image: %s.\n", lbx_strerror());
89 if (verbose || mode == MODE_IDENT) {
90 struct lbx_imginfo info;
91 lbximg_getinfo(img, &info);
93 printf("%s is %ux%u LBX image, %u frames\n",
94 name, info.width, info.height, info.nframes);
99 errmsg("decode function not yet implemented.\n", 0);