-
Notifications
You must be signed in to change notification settings - Fork 0
/
rigg.c
82 lines (71 loc) · 2.01 KB
/
rigg.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/*
* Copyright (c) 2023-2024 Thomas Frohwein
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include <sys/cdefs.h>
#include <err.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "rigg.h"
unveilmode umode = STRICT;
int verbose = 0;
__dead static void usage(void) {
fprintf(stderr,
"usage:\trigg [-v] [-u strict|permissive|none] mono|hl file [arguments]\n\trigg [-hl]\n"
);
exit(1);
}
int main(int argc, char** argv) {
int ch;
while ((ch = getopt(argc, argv, "hlu:v")) != -1) {
switch (ch) {
case 'l':
for (size_t i = 0; i < sizeof(runtimes) / sizeof(runtimes[0]); i++) {
printf("%s\n", runtimes[i]);
}
exit(0);
case 'u':
if (strncmp(optarg, "none", 4) == 0)
umode = NONE;
else if (strncmp(optarg, "permissive", 10) == 0)
umode = PERMISSIVE;
else if (strncmp(optarg, "strict", 6) == 0)
umode = STRICT;
else
(void)usage();
break;
case 'v':
verbose = 1;
break;
case 'h':
default:
usage();
}
}
argc -= optind;
argv += optind;
if (argc < 1)
usage();
if (strncmp(argv[0], "mono", MAX_INPUT) == 0) {
return mono(argc - 1, argv + 1);
}
else if (strncmp(argv[0], "hl", MAX_INPUT) == 0) {
return hl(argc - 1, argv + 1);
}
fprintf(stderr, "not a valid engine argument: %s\n", argv[0]);
(void)usage();
}