diff --git a/src/include/66/ssexec.h b/src/include/66/ssexec.h index bac0f569a7adfeab78092abe938a180fa0ffaa2b..926971af533b4beaa2b4a60efec47174cb16f3cd 100644 --- a/src/include/66/ssexec.h +++ b/src/include/66/ssexec.h @@ -247,6 +247,8 @@ extern char const *help_halt ; #define OPTS_ENV_LEN (sizeof OPTS_ENV - 1) #define OPTS_STATE "h" #define OPTS_STATE_LEN (sizeof OPTS_STATE - 1) +#define OPTS_RESOLVE "h" +#define OPTS_RESOVLE_LEN (sizeof OPTS_RESOLVE - 1) #define OPTS_TREE_WRAPPER "h" #define OPTS_TREE_WRAPPER_LEN (sizeof OPTS_TREE_WRAPPER - 1) diff --git a/src/lib66/exec/ssexec_help.c b/src/lib66/exec/ssexec_help.c index c5f21446c42f1a56795fdc8d206fb96c11bd0622..cf5068b175296c02ff533448d1fb120c9a18ecdc 100644 --- a/src/lib66/exec/ssexec_help.c +++ b/src/lib66/exec/ssexec_help.c @@ -47,7 +47,7 @@ char const *help_66 = " disable: deactivate service for the next boot\n" " environ: manage service environment variable\n" " status: display services informations\n" -" resolve: display the resolve files contents of services\n" +" resolve: display the resolve file contents of services\n" " state: display state files contents of services\n" " remove: remove services and cleanup all files belong to it from the system\n" " signal: send signal to service\n" @@ -231,7 +231,7 @@ char const *help_status = char const *usage_resolve = "66 resolve [ -h ] service" ; char const *help_resolve = -"\ndisplay the resolve files contents of services\n" +"\ndisplay the resolve file contents of services\n" "\n" "options:\n" " -h: print this help\n" diff --git a/src/lib66/exec/ssexec_resolve.c b/src/lib66/exec/ssexec_resolve.c index f8df5af4946c8eec4b0dd7bf8a6d8d8a148df92f..7bae3840baf4fa1d568fc15c6eb40ab2035e1382 100644 --- a/src/lib66/exec/ssexec_resolve.c +++ b/src/lib66/exec/ssexec_resolve.c @@ -24,6 +24,7 @@ #include <skalibs/stralloc.h> #include <skalibs/lolstdio.h> #include <skalibs/buffer.h> +#include <skalibs/sgetopt.h> #include <66/resolve.h> #include <66/ssexec.h> @@ -167,14 +168,6 @@ int ssexec_resolve(int argc, char const *const *argv, ssexec_t *info) resolve_service_t res = RESOLVE_SERVICE_ZERO ; resolve_wrapper_t_ref wres = resolve_set_struct(DATA_SERVICE, &res) ; - argc-- ; - argv++ ; - - if (argc < 1) - log_usage(info->usage, "\n", info->help) ; - - svname = *argv ; - char service_buf[MAXOPTS][INFO_FIELD_MAXLEN] = { "name", "description" , @@ -258,6 +251,32 @@ int ssexec_resolve(int argc, char const *const *argv, ssexec_t *info) } ; + { + subgetopt l = SUBGETOPT_ZERO ; + + for (;;) + { + int opt = subgetopt_r(argc, argv, OPTS_RESOLVE, &l) ; + if (opt == -1) break ; + + switch (opt) { + + case 'h' : + + info_help(info->help, info->usage) ; + return 0 ; + + default : + log_usage(info->usage, "\n", info->help) ; + } + } + argc -= l.ind ; argv += l.ind ; + } + + if (argc < 1) + log_usage(info->usage, "\n", info->help) ; + + svname = *argv ; r = service_is_g(svname, STATE_FLAGS_ISPARSED) ; if (r == -1) diff --git a/src/lib66/exec/ssexec_state.c b/src/lib66/exec/ssexec_state.c index 539f9ea391c4a9723d4a34db8b8a5315bc96f9cb..dcf55c7c8dfe4d97838720daad224714e691ca22 100644 --- a/src/lib66/exec/ssexec_state.c +++ b/src/lib66/exec/ssexec_state.c @@ -87,7 +87,7 @@ int ssexec_state(int argc, char const *const *argv, ssexec_t *info) for (;;) { - int opt = subgetopt_r(argc, argv, OPTS_ENABLE, &l) ; + int opt = subgetopt_r(argc, argv, OPTS_STATE, &l) ; if (opt == -1) break ; switch (opt) {