aboutsummaryrefslogtreecommitdiff
path: root/initd
diff options
context:
space:
mode:
authorDavid Oberhollenzer <goliath@infraroot.at>2020-05-14 01:15:58 +0200
committerDavid Oberhollenzer <goliath@infraroot.at>2020-05-14 01:26:14 +0200
commit32c3ad35b4985718e2b92c979292f6b0f6816587 (patch)
treeb7d179c3db2c98b2d6045dd1259b0059d4148c84 /initd
parent4d29cd616632034e359ca4518065aea7d3a8fa55 (diff)
Cleanup: split print_status back out again from initd/main.c
Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
Diffstat (limited to 'initd')
-rw-r--r--initd/Makemodule.am1
-rw-r--r--initd/init.h4
-rw-r--r--initd/main.c33
-rw-r--r--initd/print_status.c35
4 files changed, 40 insertions, 33 deletions
diff --git a/initd/Makemodule.am b/initd/Makemodule.am
index 6f6b523..afe802e 100644
--- a/initd/Makemodule.am
+++ b/initd/Makemodule.am
@@ -1,4 +1,5 @@
init_SOURCES = initd/main.c initd/init.h initd/runsvc.c initd/config.c
+init_SOURCES += initd/print_status.c
init_CPPFLAGS = $(AM_CPPFLAGS)
init_CFLAGS = $(AM_CFLAGS)
init_LDFLAGS = $(AM_LDFLAGS)
diff --git a/initd/init.h b/initd/init.h
index 813dedb..deb6da9 100644
--- a/initd/init.h
+++ b/initd/init.h
@@ -94,4 +94,8 @@ void config_singleshot_started(void);
/* notify the configuration manager that a single shot service terminated */
void config_singleshot_terminated(void);
+/********** print_status.c **********/
+
+void print_status(const svc_run_data_t *rt);
+
#endif /* INIT_H */
diff --git a/initd/main.c b/initd/main.c
index 26a04e2..9656daf 100644
--- a/initd/main.c
+++ b/initd/main.c
@@ -1,39 +1,6 @@
/* SPDX-License-Identifier: ISC */
#include "init.h"
-static void print_status(svc_run_data_t *rt)
-{
- const char *str;
- char pre = '\n';
-
- switch (rt->state) {
- case STATE_RUNNING:
- if (rt->svc->type == SVC_WAIT) {
- str = "\033[22;33m .. \033[0m";
- } else {
- str = "\033[22;32m UP \033[0m";
- }
- break;
- case STATE_COMPLETED:
- if (rt->svc->type == SVC_WAIT)
- pre = '\r';
-
- str = "\033[22;32mDONE\033[0m";
- break;
- case STATE_FAILED:
- if (rt->svc->type == SVC_WAIT)
- pre = '\r';
-
- str = "\033[22;31mFAIL\033[0m";
- break;
- default:
- return;
- }
-
- printf("%c[%s] %s", pre, str, rt->svc->desc);
- fflush(stdout);
-}
-
static void respawn(svc_run_data_t *rt)
{
if (rt->svc->rspwn_limit > 0) {
diff --git a/initd/print_status.c b/initd/print_status.c
new file mode 100644
index 0000000..9f0259a
--- /dev/null
+++ b/initd/print_status.c
@@ -0,0 +1,35 @@
+/* SPDX-License-Identifier: ISC */
+#include "init.h"
+
+void print_status(const svc_run_data_t *rt)
+{
+ const char *str;
+ char pre = '\n';
+
+ switch (rt->state) {
+ case STATE_RUNNING:
+ if (rt->svc->type == SVC_WAIT) {
+ str = "\033[22;33m .. \033[0m";
+ } else {
+ str = "\033[22;32m UP \033[0m";
+ }
+ break;
+ case STATE_COMPLETED:
+ if (rt->svc->type == SVC_WAIT)
+ pre = '\r';
+
+ str = "\033[22;32mDONE\033[0m";
+ break;
+ case STATE_FAILED:
+ if (rt->svc->type == SVC_WAIT)
+ pre = '\r';
+
+ str = "\033[22;31mFAIL\033[0m";
+ break;
+ default:
+ return;
+ }
+
+ printf("%c[%s] %s", pre, str, rt->svc->desc);
+ fflush(stdout);
+}