// *naka* - find a file within another file #include #include #include #include #include #include #include #include #include #include void prog_info(FILE* out) { fprintf(out, PROG_NAME " v%s - " PROG_DESCRIPTION #ifdef DEBUG " (debug build)" #endif "\n written by %s with <3 (compiled at %lu UTC (unix ts))\n license %s.\n", v_ctoss(v_rawtoc(PROG_VERSION)), PROG_AUTHOUR, PROG_COMPILED_TIMESTAMP, PROG_LICENSE); } void usage(FILE* out, int argc, char** argv) { IGNORE(argc); prog_info(out); fprintf(out, "\nUsage: %s \n", argv[0] ?: PROG_NAME); } // err: 0 for normal exit and print to stdout. // err: nonzero for abnormal exit and print to stderr. noreturn void usage_then_exit(int err, int argc, char** argv) { usage( err ? stderr : stdout, argc, argv); exit(err); } int main(int argc, char** argv) { TRACE("main start with %d (pn: %s, a1: %s)", argc, argv[0], argv[1] ?: ""); if(!argv[1] || !argv[2]) usage_then_exit(1, argc, argv); 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_free(needle))) return 3; TRACE("main end"); return 0; }