mirror of
https://github.com/troglobit/finit.git
synced 2026-10-03 06:23:11 +07:00
Relocate runlevel_string() to initctl.c
Only used by this tool, no need to keep it in helpers.c Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
@@ -63,42 +63,6 @@ void runlevel_set(int pre, int now)
|
||||
utmp_set_runlevel(pre, now);
|
||||
}
|
||||
|
||||
/**
|
||||
* runlevel_string - Convert a bit encoded runlevel to .conf syntax
|
||||
* @levels: Bit encoded runlevels
|
||||
*
|
||||
* Returns:
|
||||
* Pointer to string on the form [2345]
|
||||
*/
|
||||
char *runlevel_string(int levels)
|
||||
{
|
||||
int i, pos = 1;
|
||||
static char lvl[20];
|
||||
|
||||
memset(lvl, 0, sizeof(lvl));
|
||||
lvl[0] = '[';
|
||||
|
||||
for (i = 0; i < 10; i++) {
|
||||
if (ISSET(levels, i)) {
|
||||
if (runlevel == i)
|
||||
pos = strlcat(lvl, "\e[1m", sizeof(lvl));
|
||||
|
||||
if (i == 0)
|
||||
lvl[pos++] = 'S';
|
||||
else
|
||||
lvl[pos++] = '0' + i;
|
||||
|
||||
if (runlevel == i)
|
||||
pos = strlcat(lvl, "\e[0m", sizeof(lvl));
|
||||
}
|
||||
}
|
||||
|
||||
lvl[pos++] = ']';
|
||||
lvl[pos] = 0;
|
||||
|
||||
return lvl;
|
||||
}
|
||||
|
||||
static int print_timestamp(void)
|
||||
{
|
||||
#if defined(CONFIG_PRINTK_TIME)
|
||||
|
||||
@@ -50,7 +50,6 @@ extern int _slup; /* INTERNAL: Is syslog up yet? */
|
||||
char *strip_line (char *line);
|
||||
|
||||
void runlevel_set (int pre, int now);
|
||||
char *runlevel_string (int levels);
|
||||
|
||||
int pid_alive (pid_t pid);
|
||||
char *pid_get_name (pid_t pid, char *name, size_t len);
|
||||
|
||||
+37
-1
@@ -379,6 +379,42 @@ static int show_version(char *UNUSED(arg))
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* runlevel_string - Convert a bit encoded runlevel to .conf syntax
|
||||
* @levels: Bit encoded runlevels
|
||||
*
|
||||
* Returns:
|
||||
* Pointer to string on the form [2345]
|
||||
*/
|
||||
char *runlevel_string(int runlevel, int levels)
|
||||
{
|
||||
int i, pos = 1;
|
||||
static char lvl[20];
|
||||
|
||||
memset(lvl, 0, sizeof(lvl));
|
||||
lvl[0] = '[';
|
||||
|
||||
for (i = 0; i < 10; i++) {
|
||||
if (ISSET(levels, i)) {
|
||||
if (runlevel == i)
|
||||
pos = strlcat(lvl, "\e[1m", sizeof(lvl));
|
||||
|
||||
if (i == 0)
|
||||
lvl[pos++] = 'S';
|
||||
else
|
||||
lvl[pos++] = '0' + i;
|
||||
|
||||
if (runlevel == i)
|
||||
pos = strlcat(lvl, "\e[0m", sizeof(lvl));
|
||||
}
|
||||
}
|
||||
|
||||
lvl[pos++] = ']';
|
||||
lvl[pos] = 0;
|
||||
|
||||
return lvl;
|
||||
}
|
||||
|
||||
/* In verbose mode we skip the header and each service description.
|
||||
* This in favor of having all info on one line so a machine can more
|
||||
* easily parse it. */
|
||||
@@ -433,7 +469,7 @@ static int show_status(char *arg)
|
||||
else
|
||||
printf("%-6d ", svc->pid);
|
||||
|
||||
lvls = runlevel_string(svc->runlevels);
|
||||
lvls = runlevel_string(runlevel, svc->runlevels);
|
||||
if (strchr(lvls, '\e'))
|
||||
printf("%-18.18s ", lvls);
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user