forked from CapstoneStorage/TOMS
-
Notifications
You must be signed in to change notification settings - Fork 1
/
gasgen.c
66 lines (54 loc) · 855 Bytes
/
gasgen.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
#include "gasgen.h"
BOOL verbose;
static void
usage(void)
{
fprintf(stdout,
"Usage: gasgen <options> <config path>\n"
" <options>\n"
" -h: this message\n"
" -v: verbose mode\n"
);
}
void
errmsg(const char *fmt, ...)
{
va_list ap;
char *errmsg;
va_start(ap, fmt);
vasprintf(&errmsg, fmt, ap);
va_end(ap);
fprintf(stderr, "ERROR: %s\n", errmsg);
free(errmsg);
}
static void
parse_args(int argc, char *argv[])
{
int c;
while ((c = getopt(argc, argv, "s:h")) != -1) {
switch (c) {
case 'h':
usage();
exit(0);
default:
errmsg("invalid option");
usage();
exit(1);
}
}
if (argc - optind < 1) {
usage();
exit(1);
}
load_conf(argv[optind]);
}
int
main(int argc, char *argv[])
{
parse_args(argc, argv);
srand(getpid() + time(NULL));
gen_task();
gen_network();
gen_net_commander();
return 0;
}