blob: 1a9d483c68d35e9bf166813e683103f783d9d311 (
plain) (
blame)
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
83
84
85
86
87
88
89
|
#include <unistd.h>
#include "menu.h"
#include "ui.h"
#include "config.h"
#include "util.h"
int main(int argc, char *argv[])
{
int errflg, fd, rc;
char c;
State state = {
.headerr = headerr,
.headverf = headverf,
.statstr = statstr,
.statverf = statverf,
.statfail = statfail,
.cmds[PASS].name = headpromt
};
errflg = 0;
while ((c = getopt(argc, argv, "ip:e:v:s:r:l:c:u:d:w:")) != -1) {
switch(c) {
case 'i':
state.flag |= IGNORE_ISIG;
break;
case 'p':
state.cmds[PASS].name = optarg;
break;
case 'e':
state.headerr = optarg;
break;
case 'v':
state.headverf = optarg;
break;
case 's':
state.statstr = optarg;
break;
case 'r':
state.statverf = *optarg;
break;
case 'l':
state.statfail = *optarg;
break;
case 'c':
state.cmds[PASS].cmd = optarg;
break;
case 'u':
state.cmds[UP].name = optarg;
while (*optarg && *optarg != '=')
optarg++;
if (*optarg == '=')
state.cmds[UP].cmd = optarg + 1;
else
errflg++;
*optarg = '\0';
break;
case 'd':
state.cmds[DOWN].name = optarg;
while (*optarg && *optarg != '=')
optarg++;
if (*optarg == '=')
state.cmds[DOWN].cmd = optarg + 1;
else
errflg++;
*optarg = '\0';
break;
case 'w':
state.floc = optarg;
break;
case '?':
errflg++;
}
}
if (errflg || !state.cmds[PASS].cmd)
die("usage: tuil [-ipevsrl]");
fd = uiinit(&state);
rc = menuinit(&state, fd) - 1;
uicleanup();
return rc;
}
|