8 static const char *progname;
9 #define errmsg(fmt, ...) (\
10 fprintf(stderr, "%s: " fmt, progname, __VA_ARGS__)\
19 int list(FILE *f, int verbose) {
20 LBX *lbx = lbx_fopen(f);
22 errmsg("failed to open archive: %s.\n", lbx_strerror());
27 printf("Files in archive: %zd\n", lbx_numfiles(lbx));
33 int main(int argc, char **argv)
35 int mode = MODE_NONE, verbose = 0;
39 static const char *sopts = "lxf:v";
40 static const struct option lopts[] = {
41 { "list", 0, NULL, 'l' },
42 { "extract", 0, NULL, 'x' },
44 { "file", 1, NULL, 'f' },
46 { "verbose", 0, NULL, 'v' },
51 progname = "lbxtool"; /* argv[0]; */
52 while ((opt = getopt_long(argc, argv, sopts, lopts, NULL)) != -1) {
61 f = fopen(optarg, "rb");
63 errmsg("failed to open file %s: %m\n", optarg);
77 return list(f, verbose);
82 fprintf(stderr, "%s: you must specify a mode.\n", progname);