+ return ret;
+}
+
+int extract(struct lbx *lbx, int verbose, char **argv)
+{
+ unsigned int i;
+
+ if (verbose) {
+ printf("Files in archive: %u\n", lbx->nfiles);
+ }
+
+ for (i = 0; i < lbx->nfiles; i++) {
+ struct lbx_statbuf stat;
+ LBXfile *file;
+
+ lbx_file_stat(lbx, i, &stat);
+
+ switch (filematch(argv, stat.name)) {
+ case -1: continue;
+ case 0: break;
+ default: return EXIT_FAILURE;
+ }
+
+ file = lbx_file_open(lbx, i);
+ if (!file) {
+ tool_err(-1, "%s: %s", stat.name, lbx_errmsg());
+ continue;
+ }
+
+ if (extract_file(file, &stat) == -1)
+ return EXIT_FAILURE;
+ lbx_file_close(file);
+ }
+
+ return EXIT_SUCCESS;
+}
+
+int main(int argc, char **argv)
+{
+ int mode = MODE_NONE, verbose = 0, opt, rc = EXIT_FAILURE;
+ struct lbx_pipe_state stdin_handle = { .f = stdin };
+ const char *file = NULL;
+ struct lbx *lbx;
+
+ tool_init("lbxtool", argc, argv);