mirror of
https://git.FreeBSD.org/src.git
synced 2024-10-18 02:19:39 +00:00
ps(1): Complete libxo transition
Reviewed by: des MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D41422
This commit is contained in:
parent
95968ea7ec
commit
e17a2944a6
@ -36,7 +36,6 @@
|
|||||||
#include <sys/sysctl.h>
|
#include <sys/sysctl.h>
|
||||||
#include <sys/user.h>
|
#include <sys/user.h>
|
||||||
|
|
||||||
#include <err.h>
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@ -250,7 +249,8 @@ showkey(void)
|
|||||||
}
|
}
|
||||||
xo_emit("\n");
|
xo_emit("\n");
|
||||||
xo_close_list("key");
|
xo_close_list("key");
|
||||||
xo_finish();
|
if (xo_finish() < 0)
|
||||||
|
xo_err(1, "stdout");
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -291,7 +291,7 @@ parsefmt(const char *p, int user)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if ((vent = malloc(sizeof(struct varent))) == NULL)
|
if ((vent = malloc(sizeof(struct varent))) == NULL)
|
||||||
errx(1, "malloc failed");
|
xo_errx(1, "malloc failed");
|
||||||
vent->header = v->header;
|
vent->header = v->header;
|
||||||
if (hp) {
|
if (hp) {
|
||||||
hp = strdup(hp);
|
hp = strdup(hp);
|
||||||
@ -300,13 +300,13 @@ parsefmt(const char *p, int user)
|
|||||||
}
|
}
|
||||||
vent->var = malloc(sizeof(*vent->var));
|
vent->var = malloc(sizeof(*vent->var));
|
||||||
if (vent->var == NULL)
|
if (vent->var == NULL)
|
||||||
errx(1, "malloc failed");
|
xo_errx(1, "malloc failed");
|
||||||
memcpy(vent->var, v, sizeof(*vent->var));
|
memcpy(vent->var, v, sizeof(*vent->var));
|
||||||
STAILQ_INSERT_TAIL(&varlist, vent, next_ve);
|
STAILQ_INSERT_TAIL(&varlist, vent, next_ve);
|
||||||
}
|
}
|
||||||
free(tempstr1);
|
free(tempstr1);
|
||||||
if (STAILQ_EMPTY(&varlist)) {
|
if (STAILQ_EMPTY(&varlist)) {
|
||||||
warnx("no valid keywords; valid keywords:");
|
xo_warnx("no valid keywords; valid keywords:");
|
||||||
showkey();
|
showkey();
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
@ -345,7 +345,7 @@ findvar(char *p, int user, char **header)
|
|||||||
rflen = strlen(v->alias) + strlen(hp) + 2;
|
rflen = strlen(v->alias) + strlen(hp) + 2;
|
||||||
realfmt = malloc(rflen);
|
realfmt = malloc(rflen);
|
||||||
if (realfmt == NULL)
|
if (realfmt == NULL)
|
||||||
errx(1, "malloc failed");
|
xo_errx(1, "malloc failed");
|
||||||
snprintf(realfmt, rflen, "%s=%s", v->alias, hp);
|
snprintf(realfmt, rflen, "%s=%s", v->alias, hp);
|
||||||
parsefmt(realfmt, user);
|
parsefmt(realfmt, user);
|
||||||
free(realfmt);
|
free(realfmt);
|
||||||
@ -353,7 +353,7 @@ findvar(char *p, int user, char **header)
|
|||||||
return ((VAR *)NULL);
|
return ((VAR *)NULL);
|
||||||
}
|
}
|
||||||
if (!v) {
|
if (!v) {
|
||||||
warnx("%s: keyword not found", p);
|
xo_warnx("%s: keyword not found", p);
|
||||||
eval = 1;
|
eval = 1;
|
||||||
}
|
}
|
||||||
if (header)
|
if (header)
|
||||||
|
@ -40,7 +40,6 @@
|
|||||||
#include <sys/sysctl.h>
|
#include <sys/sysctl.h>
|
||||||
#include <sys/vmmeter.h>
|
#include <sys/vmmeter.h>
|
||||||
|
|
||||||
#include <err.h>
|
|
||||||
#include <grp.h>
|
#include <grp.h>
|
||||||
#include <jail.h>
|
#include <jail.h>
|
||||||
#include <langinfo.h>
|
#include <langinfo.h>
|
||||||
|
13
bin/ps/ps.c
13
bin/ps/ps.c
@ -46,7 +46,6 @@
|
|||||||
#include <sys/mount.h>
|
#include <sys/mount.h>
|
||||||
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <err.h>
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <grp.h>
|
#include <grp.h>
|
||||||
@ -657,7 +656,8 @@ main(int argc, char *argv[])
|
|||||||
|
|
||||||
if (nkept == 0) {
|
if (nkept == 0) {
|
||||||
printheader();
|
printheader();
|
||||||
xo_finish();
|
if (xo_finish() < 0)
|
||||||
|
xo_err(1, "stdout");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -742,7 +742,8 @@ main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
xo_close_list("process");
|
xo_close_list("process");
|
||||||
xo_close_container("process-information");
|
xo_close_container("process-information");
|
||||||
xo_finish();
|
if (xo_finish() < 0)
|
||||||
|
xo_err(1, "stdout");
|
||||||
|
|
||||||
free_list(&gidlist);
|
free_list(&gidlist);
|
||||||
free_list(&jidlist);
|
free_list(&jidlist);
|
||||||
@ -812,14 +813,14 @@ addelem_jid(struct listinfo *inf, const char *elem)
|
|||||||
int tempid;
|
int tempid;
|
||||||
|
|
||||||
if (*elem == '\0') {
|
if (*elem == '\0') {
|
||||||
warnx("Invalid (zero-length) jail id");
|
xo_warnx("Invalid (zero-length) jail id");
|
||||||
optfatal = 1;
|
optfatal = 1;
|
||||||
return (0); /* Do not add this value. */
|
return (0); /* Do not add this value. */
|
||||||
}
|
}
|
||||||
|
|
||||||
tempid = jail_getid(elem);
|
tempid = jail_getid(elem);
|
||||||
if (tempid < 0) {
|
if (tempid < 0) {
|
||||||
warnx("Invalid %s: %s", inf->lname, elem);
|
xo_warnx("Invalid %s: %s", inf->lname, elem);
|
||||||
optfatal = 1;
|
optfatal = 1;
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
@ -1480,7 +1481,7 @@ usage(void)
|
|||||||
{
|
{
|
||||||
#define SINGLE_OPTS "[-aCcde" OPT_LAZY_f "HhjlmrSTuvwXxZ]"
|
#define SINGLE_OPTS "[-aCcde" OPT_LAZY_f "HhjlmrSTuvwXxZ]"
|
||||||
|
|
||||||
(void)xo_error("%s\n%s\n%s\n%s\n%s\n",
|
xo_error("%s\n%s\n%s\n%s\n%s\n",
|
||||||
"usage: ps [--libxo] " SINGLE_OPTS " [-O fmt | -o fmt]",
|
"usage: ps [--libxo] " SINGLE_OPTS " [-O fmt | -o fmt]",
|
||||||
" [-G gid[,gid...]] [-J jid[,jid...]] [-M core] [-N system]",
|
" [-G gid[,gid...]] [-J jid[,jid...]] [-M core] [-N system]",
|
||||||
" [-p pid[,pid...]] [-t tty[,tty...]] [-U user[,user...]]",
|
" [-p pid[,pid...]] [-t tty[,tty...]] [-U user[,user...]]",
|
||||||
|
Loading…
Reference in New Issue
Block a user