aboutsummaryrefslogtreecommitdiffstats
path: root/src/s6/s6.c
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2025-10-24 16:46:58 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2025-10-24 16:46:58 +0000
commit5f46f6f2d649b2bb8664f9c749e15acd8f529b6c (patch)
tree3eb2a3f71488b932afd24a03b1dad909fa6e9c50 /src/s6/s6.c
parentad3cffc4b2c3e43053aa914e19cd5649868a7d74 (diff)
downloads6-frontend-5f46f6f2d649b2bb8664f9c749e15acd8f529b6c.tar.gz
Separate s6 from s6-frontend, fix configure for no-nsss build
Diffstat (limited to 'src/s6/s6.c')
-rw-r--r--src/s6/s6.c133
1 files changed, 0 insertions, 133 deletions
diff --git a/src/s6/s6.c b/src/s6/s6.c
deleted file mode 100644
index e7ecd6f..0000000
--- a/src/s6/s6.c
+++ /dev/null
@@ -1,133 +0,0 @@
-/* ISC license. */
-
-#include <string.h>
-#include <unistd.h>
-
-#include <skalibs/uint64.h>
-#include <skalibs/types.h>
-#include <skalibs/buffer.h>
-#include <skalibs/prog.h>
-#include <skalibs/strerr.h>
-#include <skalibs/gol.h>
-
-#include <s6/config.h>
-#include <s6-rc/config.h>
-
-#include <s6-frontend/config.h>
-#include "s6-internal.h"
-
-#define USAGE "s6 [ generic options ] command [ command options ] command_arguments... Type \"s6 help\" for details."
-#define dieusage() strerr_dieusage(100, USAGE)
-
-
-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,
- GOLB_VERSION,
- GOLB_USER,
- GOLB_N
-} ;
-
-enum gola_e
-{
- GOLA_SCANDIR,
- GOLA_LIVEDIR,
- GOLA_REPODIR,
- GOLA_BOOTDIR,
- GOLA_STMPDIR,
- GOLA_VERBOSITY,
- GOLA_COLOR,
- GOLA_N
-} ;
-
-static gol_bool const rgolb[GOLB_N] =
-{
- { .so = 'h', .lo = "help", .clear = 0, .set = 1 << GOLB_HELP },
- { .so = 'V', .lo = "version", .clear = 0, .set = 1 << GOLB_VERSION },
- { .so = 0, .lo = "user", .clear = 0, .set = 1 << GOLB_USER }
-} ;
-
-static gol_arg const rgola[GOLA_N] =
-{
- { .so = 's', .lo = "scandir", .i = GOLA_SCANDIR },
- { .so = 'l', .lo = "livedir", .i = GOLA_LIVEDIR },
- { .so = 'r', .lo = "repodir", .i = GOLA_REPODIR },
- { .so = 'b', .lo = "bootdir", .i = GOLA_BOOTDIR },
- { .so = 0, .lo = "stmpdir", .i = GOLA_STMPDIR },
- { .so = 'v', .lo = "verbosity", .i = GOLA_VERBOSITY },
- { .so = 0, .lo = "color", .i = GOLA_COLOR }
-} ;
-
-struct global_s *g ;
-
-static struct command_s const commands[] =
-{
- { .s = "help", .f = &help },
- { .s = "process", .f = &process },
- { .s = "service", .f = &service },
- { .s = "version", .f = &version },
-} ;
-
-int main (int argc, char const *const *argv, char const *const *envp)
-{
- struct global_s globals_in_the_stack = GLOBAL_ZERO ;
- char const *wgola[GOLA_N] = { 0 } ;
- uint64_t wgolb = 0 ;
- unsigned int golc ;
- struct command_s *cmd ;
- PROG = "s6" ;
- g = &globals_in_the_stack ;
-
- golc = gol_main(argc, argv, rgolb, GOLB_N, rgola, GOLA_N, &wgolb, wgola) ;
- argc -= golc ; argv += golc ;
-
- if (wgola[GOLA_VERBOSITY] && !uint0_scan(wgola[GOLA_VERBOSITY], &g->verbosity))
- strerr_dief1x(100, "verbosity must be an unsigned integer") ;
-
- if (wgolb & 1 << GOLB_VERSION) version(argv) ;
- if (wgolb & 1 << GOLB_HELP) help(argv) ;
- if (wgolb & (1 << GOLB_VERSION | 1 << GOLB_HELP)) return 0 ;
-
- if (wgola[GOLA_SCANDIR]) g->dirs.scan = wgola[GOLA_SCANDIR] ;
- if (wgola[GOLA_LIVEDIR]) g->dirs.live = wgola[GOLA_LIVEDIR] ;
- if (wgola[GOLA_REPODIR]) g->dirs.repo = wgola[GOLA_REPODIR] ;
- if (wgola[GOLA_BOOTDIR]) g->dirs.boot = wgola[GOLA_BOOTDIR] ;
- if (wgola[GOLA_STMPDIR]) g->dirs.stmp = wgola[GOLA_STMPDIR] ;
-
- {
- int force_color = 0 ;
- g->istty = isatty(1) ;
- if (wgola[GOLA_COLOR])
- {
- if (!strcmp(wgola[GOLA_COLOR], "yes"))
- {
- force_color = 1 ;
- g->color = 1 ;
- }
- else if (!strcmp(wgola[GOLA_COLOR], "no"))
- {
- force_color = 1 ;
- g->color = 0 ;
- }
- else if (strcmp(wgola[GOLA_COLOR], "auto"))
- strerr_dief1x(100, "--color value must be yes, no, or auto") ;
- }
- if (!force_color) g->color = g->istty ;
- }
-
- g->isuser = !!(wgolb & 1 << GOLB_USER) ;
- if (g->isuser) s6f_user_get_confdirs(&g->dirs, &g->userstorage) ;
-
- if (!*argv) dieusage() ;
- cmd = BSEARCH(struct command_s, *argv, commands) ;
- if (!cmd) dieusage() ;
- return (*cmd->f)(++argv) ;
-}