initctl: minor refactor and set min column width
@@ -52,15 +52,17 @@ int heading = 1;
int numeric = 0;
int verbose = 0;
int runlevel = 0;
+int iw, pw;
/* figure ut width of IDENT and PID columns */
-static void col_widths(int *identw, int *pidw)
+static void col_widths(void)
{
char ident[MAX_IDENT_LEN];
char pid[10];
svc_t *svc;
- int iw = 0;
- int pw = 0;
+
+ iw = 0;
+ pw = 0;
for (svc = client_svc_iterator(1); svc; svc = client_svc_iterator(0)) {
int w, p;
@@ -79,8 +81,11 @@ static void col_widths(int *identw, int *pidw)
pw = p;
}
- *identw = iw;
- *pidw = pw;
+ /* adjust for min col width */
+ if (iw < 5)
+ iw = 5;
+ if (pw < 3)
+ pw = 3;
}
static int runlevel_get(int *prevlevel)
@@ -268,9 +273,8 @@ static int do_cond_show(char *arg)
char ident[MAX_IDENT_LEN];
enum cond_state cond;
svc_t *svc;
- int iw, pw;
- col_widths(&iw, &pw);
+ col_widths();
if (heading) {
char title[80];
@@ -437,7 +441,6 @@ static int show_status(char *arg)
{
char ident[MAX_IDENT_LEN];
svc_t *svc;
- int iw, pw;
/* Fetch UTMP runlevel, needed for svc_status() call below */
runlevel = runlevel_get(NULL);
@@ -463,7 +466,7 @@ static int show_status(char *arg)
return do_log(svc->cmd);
}
- col_widths(&iw, &pw);
+ col_widths();
if (heading) {
char title[80];
