summaryrefslogtreecommitdiffstats
path: root/bin/ps/print.c
diff options
context:
space:
mode:
authormarcel <marcel@FreeBSD.org>2015-05-22 23:07:55 +0000
committermarcel <marcel@FreeBSD.org>2015-05-22 23:07:55 +0000
commit25a1a3fe24b8137c4a7c6d224f5f21842bfa3a88 (patch)
treeaeb56f2a753a9c8bc84d07b9827b15c5db7222d6 /bin/ps/print.c
parentf378874c7a7796435f2dd07ecf5ff2b0342ea785 (diff)
downloadFreeBSD-src-25a1a3fe24b8137c4a7c6d224f5f21842bfa3a88.zip
FreeBSD-src-25a1a3fe24b8137c4a7c6d224f5f21842bfa3a88.tar.gz
Convert to use libxo. Document use of libxo as well.
Obtained from: Phil Shafer <phil@juniper.net> Sponsored by: Juniper Networks, Inc.
Diffstat (limited to 'bin/ps/print.c')
-rw-r--r--bin/ps/print.c27
1 files changed, 14 insertions, 13 deletions
diff --git a/bin/ps/print.c b/bin/ps/print.c
index 40ecd07..91daa44 100644
--- a/bin/ps/print.c
+++ b/bin/ps/print.c
@@ -61,6 +61,7 @@ __FBSDID("$FreeBSD$");
#include <string.h>
#include <unistd.h>
#include <vis.h>
+#include <libxo/xo.h>
#include "ps.h"
@@ -85,15 +86,15 @@ printheader(void)
v = vent->var;
if (v->flag & LJUST) {
if (STAILQ_NEXT(vent, next_ve) == NULL) /* last one */
- (void)printf("%s", vent->header);
+ xo_emit("{T:/%s}", vent->header);
else
- (void)printf("%-*s", v->width, vent->header);
+ xo_emit("{T:/%-*s}", v->width, vent->header);
} else
- (void)printf("%*s", v->width, vent->header);
+ xo_emit("{T:/%*s}", v->width, vent->header);
if (STAILQ_NEXT(vent, next_ve) != NULL)
- (void)putchar(' ');
+ xo_emit("{P: }");
}
- (void)putchar('\n');
+ xo_emit("\n");
}
char *
@@ -102,7 +103,7 @@ arguments(KINFO *k, VARENT *ve)
char *vis_args;
if ((vis_args = malloc(strlen(k->ki_args) * 4 + 1)) == NULL)
- errx(1, "malloc failed");
+ xo_errx(1, "malloc failed");
strvis(vis_args, k->ki_args, VIS_TAB | VIS_NL | VIS_NOSLASH);
if (STAILQ_NEXT(ve, next_ve) != NULL && strlen(vis_args) > ARGUMENTS_WIDTH)
@@ -130,7 +131,7 @@ command(KINFO *k, VARENT *ve)
return (str);
}
if ((vis_args = malloc(strlen(k->ki_args) * 4 + 1)) == NULL)
- errx(1, "malloc failed");
+ xo_errx(1, "malloc failed");
strvis(vis_args, k->ki_args, VIS_TAB | VIS_NL | VIS_NOSLASH);
if (STAILQ_NEXT(ve, next_ve) == NULL) {
@@ -139,7 +140,7 @@ command(KINFO *k, VARENT *ve)
if (k->ki_env) {
if ((vis_env = malloc(strlen(k->ki_env) * 4 + 1))
== NULL)
- errx(1, "malloc failed");
+ xo_errx(1, "malloc failed");
strvis(vis_env, k->ki_env,
VIS_TAB | VIS_NL | VIS_NOSLASH);
} else
@@ -215,7 +216,7 @@ state(KINFO *k, VARENT *ve __unused)
buf = malloc(16);
if (buf == NULL)
- errx(1, "malloc failed");
+ xo_errx(1, "malloc failed");
flag = k->ki_p->ki_flag;
tdflags = k->ki_p->ki_tdflags; /* XXXKSE */
@@ -391,7 +392,7 @@ started(KINFO *k, VARENT *ve __unused)
buf = malloc(buflen);
if (buf == NULL)
- errx(1, "malloc failed");
+ xo_errx(1, "malloc failed");
then = k->ki_p->ki_start.tv_sec;
tp = localtime(&then);
@@ -416,7 +417,7 @@ lstarted(KINFO *k, VARENT *ve __unused)
buf = malloc(buflen);
if (buf == NULL)
- errx(1, "malloc failed");
+ xo_errx(1, "malloc failed");
then = k->ki_p->ki_start.tv_sec;
(void)strftime(buf, buflen, "%c", localtime(&then));
@@ -762,7 +763,7 @@ printval(void *bp, VAR *v)
(void)asprintf(&str, ofmt, ps_pgtok(*(u_long *)bp));
break;
default:
- errx(1, "unknown type %d", v->type);
+ xo_errx(1, "unknown type %d", v->type);
}
return (str);
@@ -804,7 +805,7 @@ label(KINFO *k, VARENT *ve __unused)
string = NULL;
if (mac_prepare_process_label(&proclabel) == -1) {
- warn("mac_prepare_process_label");
+ xo_warn("mac_prepare_process_label");
goto out;
}
error = mac_get_pid(k->ki_p->ki_pid, proclabel);
OpenPOWER on IntegriCloud