aboutsummaryrefslogtreecommitdiffstats
path: root/src/s6/service.c
blob: 5ac453b2296cf1f860ea3b80c81967c0695c927c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/* ISC license. */

#include <skalibs/prog.h>
#include <skalibs/strerr.h>

#include "s6-internal.h"

#define USAGE "s6 service [ service options ] subcommand [ subcommand options ] services... Type \"s6 service help\" for details."
#define dieusage() strerr_dieusage(100, USAGE)

static struct command_s const service_commands[] =
{
  { .s = "help", .f = &service_help },
  { .s = "start", .f = &service_start },
  { .s = "status", .f = &service_status },
  { .s = "stop", .f = &service_stop },
} ;

int service (char const *const *argv)
{
  struct command_s *cmd ;

  PROG = "s6 service" ;
  if (!*argv) dieusage() ;
  cmd = BSEARCH(struct command_s, *argv, service_commands) ;
  if (!cmd) dieusage() ;
  return (*cmd->f)(++argv) ;
}