|
|
|
@ -33,6 +33,7 @@ void usage(FILE* out, int argc, char** argv)
|
|
|
|
|
|
|
|
|
|
prog_info(out);
|
|
|
|
|
fprintf(out, "\nUsage: %s <needle> <haystack(s)...>\n", argv[0] ?: PROG_NAME);
|
|
|
|
|
fprintf(out, "\nUsage: %s --help\n", argv[0] ?: PROG_NAME);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// err: 0 for normal exit and print to stdout.
|
|
|
|
@ -43,20 +44,27 @@ noreturn void usage_then_exit(int err, int argc, char** argv)
|
|
|
|
|
exit(err);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int main(int argc, char** argv)
|
|
|
|
|
{
|
|
|
|
|
TRACE("main start with %d (pn: %s, a1: %s)", argc, argv[0], argv[1] ?: "<null>");
|
|
|
|
|
|
|
|
|
|
if(!argv[1] || !argv[2]) usage_then_exit(1, argc, argv);
|
|
|
|
|
if(!argv[1])
|
|
|
|
|
inv_args:
|
|
|
|
|
usage_then_exit(PROG_RET_ARGS, argc, argv);
|
|
|
|
|
else if(strcmp(argv[1], "--help")==0)
|
|
|
|
|
usage_then_exit(0, argc, argv);
|
|
|
|
|
else if(!argv[2])
|
|
|
|
|
goto inv_args;
|
|
|
|
|
|
|
|
|
|
map_t needle;
|
|
|
|
|
INFO("Mapping needle file `%s'", argv[1]);
|
|
|
|
|
if(!map_handle_err(map_file(argv[1], false, 0, 0, &needle))) return 2;
|
|
|
|
|
if(!map_handle_err(map_file(argv[1], false, 0, 0, &needle))) return PROG_RET_MAP_NEEDLE_FAILED;
|
|
|
|
|
|
|
|
|
|
if(!map_handle_err(map_free(needle))) return 3;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(!map_handle_err(map_free(needle))) return PROG_RET_UNMAP_NEEDLE_FAILED;
|
|
|
|
|
TRACE("main end");
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|