mirror of
https://github.com/troglobit/finit.git
synced 2026-10-31 13:00:32 +00: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:
1 parent
9974d65756
commit
958cab8cc7
3 files changed
+37
-38
No files matched your search
@@ -63,42 +63,6 @@ void runlevel_set(int pre, int now)
|
|||||||
utmp_set_runlevel(pre, 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)
|
static int print_timestamp(void)
|
||||||
{
|
{
|
||||||
#if defined(CONFIG_PRINTK_TIME)
|
#if defined(CONFIG_PRINTK_TIME)
|
||||||
|
|||||||
@@ -50,7 +50,6 @@ extern int _slup; /* INTERNAL: Is syslog up yet? */
|
|||||||
char *strip_line (char *line);
|
char *strip_line (char *line);
|
||||||
|
|
||||||
void runlevel_set (int pre, int now);
|
void runlevel_set (int pre, int now);
|
||||||
char *runlevel_string (int levels);
|
|
||||||
|
|
||||||
int pid_alive (pid_t pid);
|
int pid_alive (pid_t pid);
|
||||||
char *pid_get_name (pid_t pid, char *name, size_t len);
|
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;
|
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.
|
/* 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
|
* This in favor of having all info on one line so a machine can more
|
||||||
* easily parse it. */
|
* easily parse it. */
|
||||||
@@ -433,7 +469,7 @@ static int show_status(char *arg)
|
|||||||
else
|
else
|
||||||
printf("%-6d ", svc->pid);
|
printf("%-6d ", svc->pid);
|
||||||
|
|
||||||
lvls = runlevel_string(svc->runlevels);
|
lvls = runlevel_string(runlevel, svc->runlevels);
|
||||||
if (strchr(lvls, '\e'))
|
if (strchr(lvls, '\e'))
|
||||||
printf("%-18.18s ", lvls);
|
printf("%-18.18s ", lvls);
|
||||||
else
|
else
|
||||||
|
|||||||
Reference in new issue
Block a user