diff options
| author | Laurent Bercot <ska-skaware@skarnet.org> | 2025-11-05 04:40:36 +0000 |
|---|---|---|
| committer | Laurent Bercot <ska-skaware@skarnet.org> | 2025-11-05 04:40:36 +0000 |
| commit | 6a5a4baf2454530cd7c53cada4176c3ef90afa40 (patch) | |
| tree | 7bb266ab96765ce584f5a79225a12b28e4cd9a15 | |
| parent | 3b56d41ef579c18feafbf47d170a6ea4375beb6f (diff) | |
| download | s6-frontend-6a5a4baf2454530cd7c53cada4176c3ef90afa40.tar.gz | |
Now it builds again
| -rw-r--r-- | package/deps.mak | 21 | ||||
| -rw-r--r-- | src/helpers/s6-frontend-helper-kill.c | 20 | ||||
| -rw-r--r-- | src/include-local/s6f.h | 4 | ||||
| -rw-r--r-- | src/libs6f/s6f_equote.c | 14 | ||||
| -rw-r--r-- | src/s6-frontend/deps-exe/s6-frontend | 3 | ||||
| -rw-r--r-- | src/s6-frontend/help.c | 26 | ||||
| -rw-r--r-- | src/s6-frontend/process.c | 12 | ||||
| -rw-r--r-- | src/s6-frontend/process_help.c | 16 | ||||
| -rw-r--r-- | src/s6-frontend/process_kill.c | 47 | ||||
| -rw-r--r-- | src/s6-frontend/process_startstop.c | 17 | ||||
| -rw-r--r-- | src/s6-frontend/process_status.c | 18 | ||||
| -rw-r--r-- | src/s6-frontend/s6-frontend-internal.h | 33 | ||||
| -rw-r--r-- | src/s6-frontend/s6-frontend.c | 13 | ||||
| -rw-r--r-- | src/s6-frontend/service_help.c | 16 | ||||
| -rw-r--r-- | src/s6-frontend/util.c | 15 |
15 files changed, 149 insertions, 126 deletions
diff --git a/package/deps.mak b/package/deps.mak index c5f3895..ed00001 100644 --- a/package/deps.mak +++ b/package/deps.mak @@ -9,18 +9,19 @@ src/libs6f/s6f_equote.o src/libs6f/s6f_equote.lo: src/libs6f/s6f_equote.c src/in src/libs6f/s6f_lock.o src/libs6f/s6f_lock.lo: src/libs6f/s6f_lock.c src/include-local/s6f.h src/libs6f/s6f_report_state_change.o src/libs6f/s6f_report_state_change.lo: src/libs6f/s6f_report_state_change.c src/include-local/s6f.h src/libs6f/s6f_user_get_confdirs.o src/libs6f/s6f_user_get_confdirs.lo: src/libs6f/s6f_user_get_confdirs.c src/include-local/s6f.h -src/s6-frontend/help.o src/s6-frontend/help.lo: src/s6-frontend/help.c src/include-local/s6-internal.h -src/s6-frontend/process.o src/s6-frontend/process.lo: src/s6-frontend/process.c src/include-local/s6-internal.h +src/s6-frontend/help.o src/s6-frontend/help.lo: src/s6-frontend/help.c src/s6-frontend/s6-frontend-internal.h src/include/s6-frontend/config.h +src/s6-frontend/process.o src/s6-frontend/process.lo: src/s6-frontend/process.c src/s6-frontend/s6-frontend-internal.h +src/s6-frontend/process_help.o src/s6-frontend/process_help.lo: src/s6-frontend/process_help.c src/s6-frontend/s6-frontend-internal.h src/s6-frontend/process_kill.o src/s6-frontend/process_kill.lo: src/s6-frontend/process_kill.c src/s6-frontend/s6-frontend-internal.h src/include-local/s6f.h -src/s6-frontend/process_restart.o src/s6-frontend/process_restart.lo: src/s6-frontend/process_restart.c src/include-local/s6-internal.h +src/s6-frontend/process_restart.o src/s6-frontend/process_restart.lo: src/s6-frontend/process_restart.c src/s6-frontend/s6-frontend-internal.h src/s6-frontend/process_startstop.o src/s6-frontend/process_startstop.lo: src/s6-frontend/process_startstop.c src/s6-frontend/s6-frontend-internal.h -src/s6-frontend/process_status.o src/s6-frontend/process_status.lo: src/s6-frontend/process_status.c src/include-local/s6-internal.h -src/s6-frontend/s6-frontend.o src/s6-frontend/s6-frontend.lo: src/s6-frontend/s6-frontend.c src/s6-frontend/s6-frontend-internal.h src/include/s6-frontend/config.h +src/s6-frontend/process_status.o src/s6-frontend/process_status.lo: src/s6-frontend/process_status.c src/s6-frontend/s6-frontend-internal.h +src/s6-frontend/s6-frontend.o src/s6-frontend/s6-frontend.lo: src/s6-frontend/s6-frontend.c src/s6-frontend/s6-frontend-internal.h src/s6-frontend/s6.o src/s6-frontend/s6.lo: src/s6-frontend/s6.c src/include/s6-frontend/config.h -src/s6-frontend/service.o src/s6-frontend/service.lo: src/s6-frontend/service.c src/include-local/s6-internal.h -src/s6-frontend/service_startstop.o src/s6-frontend/service_startstop.lo: src/s6-frontend/service_startstop.c src/include-local/s6-internal.h -src/s6-frontend/service_status.o src/s6-frontend/service_status.lo: src/s6-frontend/service_status.c src/include-local/s6-internal.h -src/s6-frontend/util.o src/s6-frontend/util.lo: src/s6-frontend/util.c src/include-local/s6-internal.h +src/s6-frontend/service.o src/s6-frontend/service.lo: src/s6-frontend/service.c src/s6-frontend/s6-frontend-internal.h +src/s6-frontend/service_help.o src/s6-frontend/service_help.lo: src/s6-frontend/service_help.c src/s6-frontend/s6-frontend-internal.h +src/s6-frontend/service_startstop.o src/s6-frontend/service_startstop.lo: src/s6-frontend/service_startstop.c src/s6-frontend/s6-frontend-internal.h +src/s6-frontend/service_status.o src/s6-frontend/service_status.lo: src/s6-frontend/service_status.c src/s6-frontend/s6-frontend-internal.h s6-frontend-helper-kill: EXTRA_LIBS := s6-frontend-helper-kill: src/helpers/s6-frontend-helper-kill.o -lskarnet @@ -32,5 +33,5 @@ endif s6: EXTRA_LIBS := s6: src/s6-frontend/s6.o -lskarnet s6-frontend: EXTRA_LIBS := ${MAYBEPTHREAD_LIB} -s6-frontend: src/s6-frontend/s6-frontend.o src/s6-frontend/help.o src/s6-frontend/util.o src/s6-frontend/process.o src/s6-frontend/process_kill.o src/s6-frontend/process_restart.o src/s6-frontend/process_startstop.o src/s6-frontend/process_status.o src/s6-frontend/service.o src/s6-frontend/service_startstop.o src/s6-frontend/service_status.o libs6f.a.xyzzy ${LIBNSSS} -ls6rc -ls6 -lskarnet +s6-frontend: src/s6-frontend/s6-frontend.o src/s6-frontend/help.o src/s6-frontend/process.o src/s6-frontend/process_help.o src/s6-frontend/process_kill.o src/s6-frontend/process_restart.o src/s6-frontend/process_startstop.o src/s6-frontend/process_status.o src/s6-frontend/service.o src/s6-frontend/service_help.o src/s6-frontend/service_startstop.o src/s6-frontend/service_status.o libs6f.a.xyzzy ${LIBNSSS} -ls6rc -ls6 -lskarnet INTERNAL_LIBS := libs6f.a.xyzzy diff --git a/src/helpers/s6-frontend-helper-kill.c b/src/helpers/s6-frontend-helper-kill.c index c217373..87d9f61 100644 --- a/src/helpers/s6-frontend-helper-kill.c +++ b/src/helpers/s6-frontend-helper-kill.c @@ -14,18 +14,18 @@ int main (int argc, char const *const *argv) { unsigned int sig ; PROG = "s6-frontend-helper-kill" ; - if (argc-- < 3) dieusage() ; + if (argc-- < 2) dieusage() ; argv++ ; if (!uint0_scan(*argv++, &sig)) dieusage() ; - argc-- ; + if (--argc) + { + pid_t pids[argc] ; + for (unsigned int i = 0 ; i < argc ; i++) + if (!pid0_scan(argv[i], pids + i)) + strerr_dief1x(100, "pids must be numerical") ; - pid_t pids[argc] ; - for (unsigned int i = 0 ; i < argc ; i++) - if (!pid0_scan(argv[i], pids + i)) - strerr_dief1x(100, "pids must be numerical") ; - - for (unsigned int i = 0 ; i < argc ; i++) - kill(sig, pids[i]) ; - + for (unsigned int i = 0 ; i < argc ; i++) + kill(sig, pids[i]) ; + } _exit(0) ; } diff --git a/src/include-local/s6f.h b/src/include-local/s6f.h index a775eef..fbeab7e 100644 --- a/src/include-local/s6f.h +++ b/src/include-local/s6f.h @@ -24,7 +24,7 @@ extern void s6f_report_state_change (uint32_t, unsigned char const *, unsigned c extern void s6f_user_get_confdirs (s6f_confdirs *, stralloc *) ; -extern size_t s6f_equote_space (char const *const *, unsigned int) ; -extern unsigned int s6f_equote (char const **, char const *const *, unsigned int, char *) ; +extern size_t s6f_equote_space (char const *const *, unsigned int, char const *) ; +extern unsigned int s6f_equote (char const **, char const *const *, unsigned int, char const *, char *) ; #endif diff --git a/src/libs6f/s6f_equote.c b/src/libs6f/s6f_equote.c index 41cef42..a4c41bb 100644 --- a/src/libs6f/s6f_equote.c +++ b/src/libs6f/s6f_equote.c @@ -4,19 +4,25 @@ #include "s6f.h" -size_t s6f_equote_space (char const *const *argv, unsigned int argc) +size_t s6f_equote_space (char const *const *argv, unsigned int argc, char const *prefix) { - size_t l = 0 ; - for (unsigned int i = 0 ; i < argc ; i++) l += i + 2 + strlen(argv[i]) ; + size_t l = (prefix ? strlen(prefix) + 3 : 2) * argc ; + for (unsigned int i = 0 ; i < argc ; i++) l += strlen(argv[i]) ; return l ; } -unsigned int s6f_equote (char const **newargv, char const *const *argv, unsigned int argc, char *s) +unsigned int s6f_equote (char const **newargv, char const *const *argv, unsigned int argc, char const *prefix, char *s) { + size_t prefixlen = prefix ? strlen(prefix) : 0 ; for (unsigned int i = 0 ; i < argc ; i++) { newargv[i] = s ; *s++ = ' ' ; + if (prefix) + { + memcpy(s, prefix, prefixlen) ; + *s++ = '/' ; + } s = stpcpy(s, argv[i]) + 1 ; } newargv[argc] = "" ; diff --git a/src/s6-frontend/deps-exe/s6-frontend b/src/s6-frontend/deps-exe/s6-frontend index e87e35a..8bb5b58 100644 --- a/src/s6-frontend/deps-exe/s6-frontend +++ b/src/s6-frontend/deps-exe/s6-frontend @@ -1,11 +1,12 @@ help.o -util.o process.o +process_help.o process_kill.o process_restart.o process_startstop.o process_status.o service.o +service_help.o service_startstop.o service_status.o libs6f.a.xyzzy diff --git a/src/s6-frontend/help.c b/src/s6-frontend/help.c index f2832c6..0e119d1 100644 --- a/src/s6-frontend/help.c +++ b/src/s6-frontend/help.c @@ -3,35 +3,23 @@ #include <skalibs/buffer.h> #include <skalibs/strerr.h> +#include <s6-frontend/config.h> #include "s6-frontend-internal.h" #define MAIN_HELP_MESSAGE "This is the main help message.\n" -#define PROCESS_HELP_MESSAGE "This is the process help message.\n" - -#define SERVICE_HELP_MESSAGE "This is the service help message.\n" - -static int print_help (char const *msg) +int version (char const *const *argv) { - if (!buffer_putsflush(buffer_1, msg)) + (void)argv ; + if (!buffer_putsflush(buffer_1, "s6-frontend v" S6_FRONTEND_VERSION "\n")) strerr_diefu1sys(111, "write to stdout") ; return 0 ; } -int process_help (char const* const *argv) -{ - (void)argv ; - return print_help(PROCESS_HELP_MESSAGE) ; -} - -int service_help (char const* const *argv) -{ - (void)argv ; - return print_help(SERVICE_HELP_MESSAGE) ; -} - int help (char const *const *argv) { (void)argv ; - return print_help(MAIN_HELP_MESSAGE) ; + if (!buffer_putsflush(buffer_1, MAIN_HELP_MESSAGE)) + strerr_diefu1sys(111, "write to stdout") ; + return 0 ; } diff --git a/src/s6-frontend/process.c b/src/s6-frontend/process.c index bce29c6..f6b3f12 100644 --- a/src/s6-frontend/process.c +++ b/src/s6-frontend/process.c @@ -42,7 +42,7 @@ void process_check_services (char const *const *argv, size_t argc) } } -void process_send_svc (char const *svcopt, char const *const *argv, size_t argc, unsigned int timeout) +void process_send_svc (char const *svcopt, char const *const *argv, unsigned int argc, unsigned int timeout) { size_t const scandirlen = strlen(g->dirs.scan) ; size_t len = 0 ; @@ -89,7 +89,7 @@ enum gola_e int process (char const *const *argv) { - static struct command_s const process_commands[] = + static struct process_command_s const process_commands[] = { { .s = "help", .f = &process_help }, { .s = "kill", .f = &process_kill }, @@ -108,16 +108,16 @@ int process (char const *const *argv) { .so = 't', .lo = "timeout", .i = GOLA_TIMEOUT }, } ; - struct command_s *cmd ; + struct process_command_s *cmd ; process_options options = PROCESS_OPTIONS_ZERO ; char const *wgola[GOLA_N] = { 0 } ; - PROG = "s6-frontend: process" ; argv += GOL_argv(argv, rgolb, rgola, &options.flags, wgola) ; if (!*argv) dieusage() ; if (wgola[GOLA_TIMEOUT] && !uint0_scan(wgola[GOLA_TIMEOUT], &options.timeout)) strerr_dief1x(100, "timeout must be a numerical argument (milliseconds)") ; - cmd = BSEARCH(struct command_s, *argv, process_commands) ; + cmd = BSEARCH(struct process_command_s, *argv, process_commands) ; if (!cmd) dieusage() ; - return (*cmd->f)(++argv, &options) ; + (*cmd->f)(++argv, &options) ; + return 0 ; } diff --git a/src/s6-frontend/process_help.c b/src/s6-frontend/process_help.c new file mode 100644 index 0000000..295d5c6 --- /dev/null +++ b/src/s6-frontend/process_help.c @@ -0,0 +1,16 @@ +/* ISC license. */ + +#include <skalibs/buffer.h> +#include <skalibs/strerr.h> + +#include "s6-frontend-internal.h" + +#define PROCESS_HELP_MESSAGE "This is the process help message.\n" + +void process_help (char const *const *argv, process_options const *options) +{ + if (!buffer_putsflush(buffer_1, PROCESS_HELP_MESSAGE)) + strerr_diefu1sys(111, "write to stdout") ; + (void)argv ; + (void)options ; +} diff --git a/src/s6-frontend/process_kill.c b/src/s6-frontend/process_kill.c index 2a28d8f..ce16a91 100644 --- a/src/s6-frontend/process_kill.c +++ b/src/s6-frontend/process_kill.c @@ -8,11 +8,10 @@ #include <skalibs/uint64.h> #include <skalibs/posixplz.h> #include <skalibs/types.h> -#include <skalibs/strerr.h> -#include <skalibs/gol.h> -#include <skalibs/env.h> +#include <skalibs/envexec.h> #include <skalibs/sig.h> +#include <s6/config.h> #include <s6/supervise.h> #include "s6f.h" @@ -21,24 +20,23 @@ #define USAGE "s6 process kill [ --signal=sig ] services..." #define dieusage() strerr_dieusage(100, USAGE) -static void process_kill_hack_kill (int sig, char const *const *argv, size_t argc) gccattr_noreturn ; -static void process_kill_hack_kill (int sig, char const *const *argv, size_t argc, int dowait, unsigned int timeout) +static void process_kill_hack_kill (int sig, char const *const *argv, unsigned int argc, int dowait, unsigned int timeout) gccattr_noreturn ; +static void process_kill_hack_kill (int sig, char const *const *argv, unsigned int argc, int dowait, unsigned int timeout) { size_t scandirlen = strlen(g->dirs.scan) ; + size_t l = 0 ; + size_t equotelen = dowait ? s6f_equote_space(argv, argc, g->dirs.scan) : 1 ; unsigned int m = 0 ; - char fmt[UINT_FMT] ; + char const *newargv[3 + argc + (dowait ? 4 + argc + (timeout ? 2 : 0) : 0)] ; + char equotestorage[equotelen] ; + char fmt[UINT_FMT + PID_FMT * argc] ; + l = uint_fmt(fmt, (unsigned int)sig) ; fmt[l++] = 0 ; if (g->verbosity) - { - fmt[uint_fmt(fmt, (unsigned int)sig)] = 0 ; strerr_warnw3x("signal ", fmt, " is not natively supported by s6-svc, cannot ensure reliability") ; - } - pid_t pids[argc] ; - char const *newargv[5 + argc + (dowait ? 4 + argc + (timeout ? 2 : 0) : 0)] ; - char equotestorage[dowait ? s6f_equote_space(argv, argc) : 1] ; if (dowait) { newargv[m++] = S6_EXTBINPREFIX "s6-svlisten" ; - newargv[m++] = "-dwD" ; + newargv[m++] = "-D" ; if (timeout) { fmt[uint_fmt(fmt, timeout)] = 0 ; @@ -46,23 +44,30 @@ static void process_kill_hack_kill (int sig, char const *const *argv, size_t arg newargv[m++] = fmt ; } newargv[m++] = "--" ; - m += s6f_equote(newargv + m, argv, argc, equotestorage) ; + m += s6f_equote(newargv + m, argv, argc, g->dirs.scan, equotestorage) ; } - - for (; *argv ; argv++) + + newargv[m++] = S6_FRONTEND_LIBEXECPREFIX "s6-frontend-helper-kill" ; + newargv[m++] = fmt ; + for (unsigned int i = 0 ; i < argc ; i++) { s6_svstatus_t status ; - size_t arglen = strlen(*argv) ; + size_t arglen = strlen(argv[i]) ; char path[scandirlen + arglen + 2] ; memcpy(path, g->dirs.scan, scandirlen) ; path[scandirlen] = '/' ; - memcpy(path + scandirlen + 1, *argv, arglen) ; + memcpy(path + scandirlen + 1, argv[i], arglen) ; path[scandirlen + 1 + arglen] = 0 ; if (!s6_svstatus_read(path, &status)) strerr_diefu2sys(111, "read status file for service ", path) ; - if (status.pid && !status.flagfinishing) kill(status.pid, sig) ; + if (status.pid && !status.flagfinishing) + { + newargv[m++] = fmt + l ; + l += pid_fmt(fmt + l, status.pid) ; fmt[l++] = 0 ; + } } - _exit(0) ; + newargv[m++] = 0 ; + xmexec_n(newargv, cleanup_modif.s, cleanup_modif.len, cleanup_modif.n) ; } @@ -111,5 +116,5 @@ void process_kill (char const *const *argv, process_options const *options) } if (options->flags & 1) { svcopt[2] = 'w' ; svcopt[3] = 'D' ; } if (svcopt[1] != '!') process_send_svc(svcopt, argv, argc, options->timeout) ; - else process_kill_hack_kill(sig, argv, argc, options->flags & 1, unsigned int timeout) ; + else process_kill_hack_kill(sig, argv, argc, options->flags & 1, options->timeout) ; } diff --git a/src/s6-frontend/process_startstop.c b/src/s6-frontend/process_startstop.c index 9e23680..a80c579 100644 --- a/src/s6-frontend/process_startstop.c +++ b/src/s6-frontend/process_startstop.c @@ -13,17 +13,28 @@ static void process_startstop (char const *const *argv, process_options const *options, int h) gccattr_noreturn ; static void process_startstop (char const *const *argv, process_options const *options, int h) { + static gol_bool const rgolb[] = + { + { .so = 'P', .lo = "no-permanent", .clear = 0x01, .set = 0 }, + { .so = 'p', .lo = "permanent", .clear = 0, .set = 0x01 } + } ; + static char const *svcopts[2][2][2] = { { { "-d", "-u" }, { "-D", "-U" } }, { { "-dwD", "-uwU" }, { "-DwD", "-UwU" } } } ; size_t argc = env_len(argv) ; + uint64_t wgolb = 0 ; + unsigned int golc = gol_argv(argv, rgolb, 2, 0, 0, &wgolb, 0) ; + argc -= golc ; argv += golc ; + if (!argc) strerr_dief3x(100, "usage: s6 process ", h ? "start" : "stop", " [ -P | -p ] services...") ; + process_check_services(argv, argc) ; - process_send_svc(options->flags & 1 ? h ? "-uwU" : "-dwD" : h ? "-u" : "-d", argv, argc, options->timeout) ; + process_send_svc(svcopts[options->flags & 1][wgolb & 1][h], argv, argc, options->timeout) ; } void process_start (char const *const *argv, process_options const *options) { - return process_startstop(argv, options, 1) ; + process_startstop(argv, options, 1) ; } void process_stop (char const *const *argv, process_options const *options) { - return process_startstop(argv, options, 0) ; + process_startstop(argv, options, 0) ; } diff --git a/src/s6-frontend/process_status.c b/src/s6-frontend/process_status.c index 96cee95..ea76d9f 100644 --- a/src/s6-frontend/process_status.c +++ b/src/s6-frontend/process_status.c @@ -1,6 +1,7 @@ /* ISC license. */ #include <string.h> +#include <unistd.h> #include <sys/wait.h> #include <errno.h> @@ -73,24 +74,16 @@ static int do_status (char const *dir, int withlog) } -enum golb_e -{ - GOLB_WITHLOGS, - GOLB_N -} ; - static gol_bool const rgolb[1] = { - { .so = 'l', .lo = "with-logs", .clear = 0, .set = 1 << GOLB_WITHLOGS } + { .so = 'l', .lo = "with-logs", .clear = 0, .set = 0x01 } } ; - -int process_status (char const *const *argv) +void process_status (char const *const *argv, process_options const *options) { size_t scandirlen = strlen(g->dirs.scan) ; uint64_t wgolb = 0 ; int e = 0 ; - PROG = "s6 process status" ; argv += gol_argv(argv, rgolb, 1, 0, 0, &wgolb, 0) ; if (!argv) dieusage() ; @@ -102,7 +95,8 @@ int process_status (char const *const *argv) memcpy(path, g->dirs.scan, scandirlen) ; path[scandirlen] = '/' ; memcpy(path + scandirlen + 1, *argv, len+1) ; - if (do_status(path, !!(wgolb & 1 << GOLB_WITHLOGS))) e = 1 ; + if (do_status(path, wgolb & 1)) e = 1 ; } - return e ; + (void)options ; + _exit(e) ; } diff --git a/src/s6-frontend/s6-frontend-internal.h b/src/s6-frontend/s6-frontend-internal.h index b935fe2..b4bfe98 100644 --- a/src/s6-frontend/s6-frontend-internal.h +++ b/src/s6-frontend/s6-frontend-internal.h @@ -16,17 +16,13 @@ #include <s6-frontend/config.h> #include "s6f.h" - /* util */ - -#define BSEARCH(type, key, array) bsearch(key, (array), sizeof(array)/sizeof(type), sizeof(type), &str_cmp) +#define BSEARCH(type, key, array) bsearch(key, (array), sizeof(array)/sizeof(type), sizeof(type), &stringkey_bcmp) /* help */ -extern int process_help (char const *const *) ; -extern int service_help (char const *const *) ; - extern int help (char const *const *) ; +extern int version (char const *const *) ; /* process */ @@ -39,20 +35,32 @@ struct process_options_s } ; #define PROCESS_OPTIONS_ZERO { .flags = 0, .timeout = 0 } +typedef void process_command_func (char const *const *, process_options const *) ; +typedef process_command_func *process_command_func_ref ; + +struct process_command_s +{ + char const *s ; + process_command_func_ref f ; +} ; +#define PROCESS_COMMAND_ZERO { .s = 0, .f = 0 } + extern void process_check_services (char const *const *, size_t) ; -extern int process_send_svc (char const *, char const *const *, size_t, unsigned int) gccattr_noreturn ; +extern void process_send_svc (char const *, char const *const *, unsigned int, unsigned int) gccattr_noreturn ; -extern int process_kill (char const *const *, process_options const *) ; +extern void process_help (char const *const *, process_options const *) ; +extern void process_kill (char const *const *, process_options const *) gccattr_noreturn ; extern void process_restart (char const *const *, process_options const *) gccattr_noreturn ; extern void process_start (char const *const *, process_options const *) gccattr_noreturn ; extern void process_stop (char const *const *, process_options const *) gccattr_noreturn ; -extern int process_status (char const *const *, process_options const *) ; +extern void process_status (char const *const *, process_options const *) ; extern int process (char const *const *) ; /* service */ +extern int service_help (char const *const *) ; extern int service_start (char const *const *) ; extern int service_status (char const *const *) ; extern int service_stop (char const *const *) ; @@ -97,15 +105,16 @@ struct modif_s extern struct modif_s const cleanup_modif ; +typedef int command_func (char const *const *) ; +typedef command_func *command_func_ref ; + struct command_s { char const *s ; - main_func_ref f ; + command_func_ref f ; } ; #define COMMAND_ZERO { .s = 0, .f = 0 } extern struct global_s *g ; -extern int version (char const *const *) ; - #endif diff --git a/src/s6-frontend/s6-frontend.c b/src/s6-frontend/s6-frontend.c index 3148062..ab4b045 100644 --- a/src/s6-frontend/s6-frontend.c +++ b/src/s6-frontend/s6-frontend.c @@ -13,28 +13,19 @@ #include <s6/config.h> #include <s6-rc/config.h> -#include <s6-frontend/config.h> #include "s6-frontend-internal.h" #define USAGE "s6 [ generic options ] command [ command options ] command_arguments... Type \"s6 help\" for details." #define dieusage() strerr_dieusage(100, USAGE) -#define CLEANUP_MODIF "EXECLINE_STRICT\0scandir\0livedir\0repodir\0bootdb\0stmpdir\0verbosity" +#define CLEANUP_MODIF "scandir\0livedir\0repodir\0bootdb\0stmpdir\0verbosity" struct modif_s const cleanup_modif = { .s = CLEANUP_MODIF, .len = sizeof(CLEANUP_MODIF), - .n = 7 + .n = 6 } ; -int version (char const *const *argv) -{ - (void)argv ; - if (!buffer_putsflush(buffer_1, "s6-frontend v" S6_FRONTEND_VERSION "\n")) - strerr_diefu1sys(111, "write to stdout") ; - return 0 ; -} - enum golb_e { GOLB_HELP = 0x01, diff --git a/src/s6-frontend/service_help.c b/src/s6-frontend/service_help.c new file mode 100644 index 0000000..304901a --- /dev/null +++ b/src/s6-frontend/service_help.c @@ -0,0 +1,16 @@ +/* ISC license. */ + +#include <skalibs/buffer.h> +#include <skalibs/strerr.h> + +#include "s6-frontend-internal.h" + +#define SERVICE_HELP_MESSAGE "This is the service help message.\n" + +int service_help (char const *const *argv) +{ + (void)argv ; + if (!buffer_putsflush(buffer_1, SERVICE_HELP_MESSAGE)) + strerr_diefu1sys(111, "write to stdout") ; + return 0 ; +} diff --git a/src/s6-frontend/util.c b/src/s6-frontend/util.c deleted file mode 100644 index 699f976..0000000 --- a/src/s6-frontend/util.c +++ /dev/null @@ -1,15 +0,0 @@ -/* ISC license. */ - -#include <string.h> - -#include "s6-internal.h" - -struct starts_with_a_string_key_s -{ - char const *s ; -} ; - -int keycmp (void const *a, void const *b) -{ - return strcmp((char const *)a, ((struct starts_with_a_string_key_s const *)b)->s) ; -} |
