summaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorsinanmohd <sinan@firemail.cc>2023-05-22 15:25:25 +0530
committersinanmohd <sinan@firemail.cc>2023-06-26 12:59:10 +0530
commitd7ce046606ce05dd8a37e83fc48667bbe4c20093 (patch)
tree7e8d44431998e8c9d80f39165b6525866ddb5856 /main.c
initial commitHEADmaster
Diffstat (limited to 'main.c')
-rw-r--r--main.c89
1 files changed, 89 insertions, 0 deletions
diff --git a/main.c b/main.c
new file mode 100644
index 0000000..1a9d483
--- /dev/null
+++ b/main.c
@@ -0,0 +1,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;
+}