diff options
author | sinanmohd <sinan@firemail.cc> | 2023-05-22 15:25:25 +0530 |
---|---|---|
committer | sinanmohd <sinan@firemail.cc> | 2023-06-26 12:59:10 +0530 |
commit | d7ce046606ce05dd8a37e83fc48667bbe4c20093 (patch) | |
tree | 7e8d44431998e8c9d80f39165b6525866ddb5856 /main.c |
Diffstat (limited to 'main.c')
-rw-r--r-- | main.c | 89 |
1 files changed, 89 insertions, 0 deletions
@@ -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; +} |