From 5556dde4d3ad4e34267320b1411fc090b18a24b0 Mon Sep 17 00:00:00 2001 From: Byron Rakitzis Date: Mon, 7 Mar 1994 00:00:01 +0000 Subject: beta: rc-1.5betadev1 --- status.c | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) (limited to 'status.c') diff --git a/status.c b/status.c index 1b6325b..91252b0 100644 --- a/status.c +++ b/status.c @@ -80,27 +80,35 @@ extern void statprint(int pid, int i) { /* prepare a list to be passed back. Used whenever $status is dereferenced */ extern List *sgetstatus() { - List *r; + List *r = NULL; int i; - for (r = NULL, i = 0; i < pipelength; i++) { + + for (i = 0; i < pipelength; i++) { List *q = nnew(List); - int s = statuses[i]; - int t; + q->w = strstatus(statuses[i]); + q->m = NULL; q->n = r; r = q; - if ((t = s & 0x7f) != 0) { - const char *core = (s & 0x80) ? "+core" : ""; - if (t < NUMOFSIGNALS && *signals[t].name != '\0') - r->w = nprint("%s%s", signals[t].name, core); - else - r->w = nprint("-%d%s", t, core); /* unknown signals are negated */ - } else - r->w = nprint("%d", (s >> 8) & 0xff); - r->m = NULL; } + return r; } +/* return status as a string (used above and for bqstatus) */ + +extern char *strstatus(int s) { + int t = s & 0x7f; + + if (t != 0) { + const char *core = (s & 0x80) ? "+core" : ""; + if (t < NUMOFSIGNALS && *signals[t].name != '\0') + return nprint("%s%s", signals[t].name, core); + else + return nprint("-%d%s", t, core); /* unknown signals are negated */ + } else + return nprint("%d", (s >> 8) & 0xff); +} + extern void ssetstatus(char **av) { int i, j, k, l; bool found; -- cgit v1.2.3