You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
55 lines
1.0 KiB
55 lines
1.0 KiB
// *naka* - find a file within another file
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <sys/mman.h>
|
|
|
|
#include <ints.h>
|
|
#include <macros.h>
|
|
#include <version.h>
|
|
|
|
#include <project.h>
|
|
|
|
#include <tests.h>
|
|
|
|
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 <needle> <haystack(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");
|
|
|
|
usage_then_exit(0, argc, argv);
|
|
|
|
TRACE("main end");
|
|
|
|
return 0;
|
|
}
|
|
|