diff options
Diffstat (limited to 'initd/print_status.c')
-rw-r--r-- | initd/print_status.c | 35 |
1 files changed, 35 insertions, 0 deletions
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); +} |