Blob


1 /*
2 * Copyright (c) 2022 Omar Polo <op@omarpolo.com>
3 *
4 * Permission to use, copy, modify, and distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
17 #include <err.h>
18 #include <stdio.h>
19 #include <stdlib.h>
20 #include <unistd.h>
22 int parse(const char *);
24 int nodebug;
26 static void __dead
27 usage(void)
28 {
29 fprintf(stderr, "usage: %s [file...]\n",
30 getprogname());
31 exit(1);
32 }
34 int
35 main(int argc, char **argv)
36 {
37 int ch, i;
39 if (pledge("stdio rpath", NULL) == -1)
40 err(1, "pledge");
42 while ((ch = getopt(argc, argv, "G")) != -1) {
43 switch (ch) {
44 case 'G':
45 nodebug = 1;
46 break;
47 default:
48 usage();
49 }
50 }
51 argc -= optind;
52 argv += optind;
54 /* preamble */
55 puts("#include \"tmpl.h\"");
57 if (argc == 0) {
58 parse("/dev/stdin");
59 exit(0);
60 }
62 for (i = 0; i < argc; ++i)
63 if (parse(argv[i]) == -1)
64 return (1);
66 return (0);
67 }