mirror of
https://github.com/troglobit/finit.git
synced 2026-11-10 16:31:21 +00:00
1 parent
0e93dfd640
commit
0e84ecf143
1 file changed
+9
-10
+9
-10
@@ -390,7 +390,9 @@ static int do_cond_dump(char *arg)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int do_cond_act(char *arg, int op)
|
typedef enum { COND_CLR, COND_SET, COND_GET } condop_t;
|
||||||
|
|
||||||
|
static int do_cond_act(char *arg, condop_t op)
|
||||||
{
|
{
|
||||||
char oneshot[256];
|
char oneshot[256];
|
||||||
size_t off;
|
size_t off;
|
||||||
@@ -409,30 +411,27 @@ static int do_cond_act(char *arg, int op)
|
|||||||
off = strlen(_PATH_COND);
|
off = strlen(_PATH_COND);
|
||||||
|
|
||||||
switch (op) {
|
switch (op) {
|
||||||
case 2:
|
case COND_GET:
|
||||||
off = !fexist(oneshot);
|
off = !fexist(oneshot);
|
||||||
if (verbose)
|
if (verbose)
|
||||||
puts(off ? "off" : "on");
|
puts(off ? "off" : "on");
|
||||||
return off;
|
return off;
|
||||||
case 1:
|
case COND_SET:
|
||||||
if (symlink(_PATH_RECONF, oneshot) && errno != EEXIST)
|
if (symlink(_PATH_RECONF, oneshot) && errno != EEXIST)
|
||||||
ERR(73, "Failed asserting condition <%s>", &oneshot[off]);
|
ERR(73, "Failed asserting condition <%s>", &oneshot[off]);
|
||||||
break;
|
break;
|
||||||
case 0:
|
case COND_CLR:
|
||||||
if (erase(oneshot) && errno != ENOENT)
|
if (erase(oneshot) && errno != ENOENT)
|
||||||
ERR(73, "Failed deasserting condition <%s>", &oneshot[off]);
|
ERR(73, "Failed deasserting condition <%s>", &oneshot[off]);
|
||||||
break;
|
break;
|
||||||
default:
|
|
||||||
ERRX(3, "Unsupported operation (%d)", op);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int do_cond_get(char *arg) { return do_cond_act(arg, 2); }
|
static int do_cond_get(char *arg) { return do_cond_act(arg, COND_GET); }
|
||||||
static int do_cond_set(char *arg) { return do_cond_act(arg, 1); }
|
static int do_cond_set(char *arg) { return do_cond_act(arg, COND_SET); }
|
||||||
static int do_cond_clr(char *arg) { return do_cond_act(arg, 0); }
|
static int do_cond_clr(char *arg) { return do_cond_act(arg, COND_CLR); }
|
||||||
|
|
||||||
static char *svc_cond(svc_t *svc, char *buf, size_t len)
|
static char *svc_cond(svc_t *svc, char *buf, size_t len)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in new issue
Block a user