From 7d6eb2b59b880f710c8f2233b0f5abebff9da9f0 Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Mon, 8 Feb 2021 07:05:11 +0100 Subject: [PATCH] initctl: use same headings for ls as show From the start, the output from the 'list' command has been different from the output of the 'show' command. No longer. Also, drop the 'AVAILABLE', 'ENABLED', and 'STATIC' prefixes. They were a bit screamy and superfluous. 'STATIC' wasn't even a good name for the locally administered ones. Signed-off-by: Joachim Wiberg --- src/serv.c | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/src/serv.c b/src/serv.c index 2636f954..c57c3cf4 100644 --- a/src/serv.c +++ b/src/serv.c @@ -61,14 +61,12 @@ static int calc_width(char *arr[], size_t len) return width; } -static void do_list(const char *heading, const char *path) +static void do_list(const char *path) { - int num; - int prev; - int width; char buf[screen_cols]; - size_t i, len; + int width, num, prev; glob_t gl; + size_t i; pushd(path); if (glob("*.conf", 0, NULL, &gl)) { @@ -79,12 +77,8 @@ static void do_list(const char *heading, const char *path) if (gl.gl_pathc <= 0) goto done; - memset(buf, 0, sizeof(buf)); - snprintf(buf, sizeof(buf), "%s :: %s ", heading, path); - len = strlen(buf); - for (size_t i = len; i < (sizeof(buf) - 1); i++) - buf[i] = '-'; - printf("\e[1m%s\e[0m\n", buf); + snprintf(buf, sizeof(buf), "%s ", path); + printheader(NULL, buf, 0); width = calc_width(gl.gl_pathv, gl.gl_pathc); if (width <= 0) @@ -116,11 +110,11 @@ done: int serv_list(char *arg) { if (fisdir(available)) - do_list("AVAILABLE", available); + do_list(available); if (fisdir(enabled)) - do_list("ENABLED ", enabled); + do_list(enabled); if (fisdir(FINIT_RCSD)) - do_list("STATIC ", FINIT_RCSD); + do_list(FINIT_RCSD); return 0; }