aboutsummaryrefslogtreecommitdiff
path: root/initd
diff options
context:
space:
mode:
authorDavid Oberhollenzer <goliath@infraroot.at>2020-05-08 15:25:41 +0200
committerDavid Oberhollenzer <goliath@infraroot.at>2020-05-08 15:26:40 +0200
commit9430785779a178c2226b86e9ac46013123dea76a (patch)
tree567988e30e9c7e4cbe407b9d8f7a161b77fcf4c5 /initd
parentf6ef5b8dd3f1b8d6af104304a9988ff1f8edd182 (diff)
Cleanup: remove rest of status.c
Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
Diffstat (limited to 'initd')
-rw-r--r--initd/Makemodule.am2
-rw-r--r--initd/init.h20
-rw-r--r--initd/status.c31
-rw-r--r--initd/supervisor.c26
4 files changed, 27 insertions, 52 deletions
diff --git a/initd/Makemodule.am b/initd/Makemodule.am
index 9491fa9..294b2ee 100644
--- a/initd/Makemodule.am
+++ b/initd/Makemodule.am
@@ -1,5 +1,5 @@
init_SOURCES = initd/main.c initd/init.h initd/runsvc.c
-init_SOURCES += initd/status.c initd/supervisor.c
+init_SOURCES += initd/supervisor.c
init_CPPFLAGS = $(AM_CPPFLAGS)
init_CFLAGS = $(AM_CFLAGS)
init_LDFLAGS = $(AM_LDFLAGS)
diff --git a/initd/init.h b/initd/init.h
index b1287ee..6e5ad8f 100644
--- a/initd/init.h
+++ b/initd/init.h
@@ -26,13 +26,6 @@
#define ENVFILE ETCPATH "/initd.env"
#define PROCFDDIR "/proc/self/fd"
-enum {
- STATUS_OK = 0,
- STATUS_FAIL,
- STATUS_WAIT,
- STATUS_STARTED,
-};
-
/* service run time data */
enum {
@@ -64,19 +57,6 @@ void target_completed(int target);
*/
pid_t runsvc(service_t *svc);
-/********** status.c **********/
-
-/*
- Print a status message. Type is either STATUS_OK, STATUS_FAIL,
- STATUS_WAIT or STATUS_STARTED.
-
- A new-line is appended to the mssage, UNLESS type is STATUS_WAIT.
-
- If update is true, print a carriage return first to overwrite the
- current line (e.g. after a STATUS_WAIT message).
-*/
-void print_status(const char *msg, int type, bool update);
-
/********** supervisor.c **********/
void supervisor_handle_exited(pid_t pid, int status);
diff --git a/initd/status.c b/initd/status.c
deleted file mode 100644
index b62653c..0000000
--- a/initd/status.c
+++ /dev/null
@@ -1,31 +0,0 @@
-/* SPDX-License-Identifier: ISC */
-#include <stdio.h>
-
-#include "init.h"
-
-void print_status(const char *msg, int type, bool update)
-{
- const char *str;
-
- switch (type) {
- case STATUS_FAIL:
- str = "\033[22;31mFAIL\033[0m";
- break;
- case STATUS_WAIT:
- str = "\033[22;33m .. \033[0m";
- break;
- case STATUS_STARTED:
- str = "\033[22;32m UP \033[0m";
- break;
- default:
- str = "\033[22;32m OK \033[0m";
- break;
- }
-
- if (update)
- fputc('\r', stdout);
- printf("[%s] %s", str, msg);
- if (type != STATUS_WAIT)
- fputc('\n', stdout);
- fflush(stdout);
-}
diff --git a/initd/supervisor.c b/initd/supervisor.c
index 8de61c9..6fdaae1 100644
--- a/initd/supervisor.c
+++ b/initd/supervisor.c
@@ -21,6 +21,32 @@ static bool waiting = false;
/*****************************************************************************/
+enum {
+ STATUS_OK = 0,
+ STATUS_FAIL,
+ STATUS_WAIT,
+ STATUS_STARTED,
+};
+
+static const char *status_str[] = {
+ [STATUS_OK] = "\033[22;32m OK \033[0m",
+ [STATUS_FAIL] ="\033[22;31mFAIL\033[0m",
+ [STATUS_WAIT] = "\033[22;33m .. \033[0m",
+ [STATUS_STARTED] ="\033[22;32m UP \033[0m",
+};
+
+static void print_status(const char *msg, int type, bool update)
+{
+ if (update)
+ fputc('\r', stdout);
+
+ printf("[%s] %s", status_str[type], msg);
+
+ if (type != STATUS_WAIT)
+ fputc('\n', stdout);
+ fflush(stdout);
+}
+
static svc_run_data_t *run_time_data_from_pid(pid_t pid)
{
size_t i;