diff options
author | Michael Shalayeff <mickey@cvs.openbsd.org> | 2003-07-09 01:10:31 +0000 |
---|---|---|
committer | Michael Shalayeff <mickey@cvs.openbsd.org> | 2003-07-09 01:10:31 +0000 |
commit | 73edd7a5323c995a98c6426ffbbd61ecf58a2e6d (patch) | |
tree | 4903c43e60f20c304b0149319a3eff28cfb9c56b /usr.bin/rwall | |
parent | 089089a1672ee8ebfd18aea28f2867e4784556f8 (diff) |
ans, knf, err and spaces
Diffstat (limited to 'usr.bin/rwall')
-rw-r--r-- | usr.bin/rwall/rwall.c | 47 |
1 files changed, 20 insertions, 27 deletions
diff --git a/usr.bin/rwall/rwall.c b/usr.bin/rwall/rwall.c index 89a1eb6a677..6d48854bec2 100644 --- a/usr.bin/rwall/rwall.c +++ b/usr.bin/rwall/rwall.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rwall.c,v 1.9 2003/07/02 00:21:16 avsm Exp $ */ +/* $OpenBSD: rwall.c,v 1.10 2003/07/09 01:10:30 mickey Exp $ */ /* * Copyright (c) 1993 Christopher G. Demetriou @@ -38,7 +38,7 @@ char copyright[] = #ifndef lint /*static char sccsid[] = "from: @(#)wall.c 5.14 (Berkeley) 3/2/91";*/ -static char rcsid[] = "$OpenBSD: rwall.c,v 1.9 2003/07/02 00:21:16 avsm Exp $"; +static char rcsid[] = "$OpenBSD: rwall.c,v 1.10 2003/07/09 01:10:30 mickey Exp $"; #endif /* not lint */ /* @@ -56,6 +56,7 @@ static char rcsid[] = "$OpenBSD: rwall.c,v 1.9 2003/07/02 00:21:16 avsm Exp $"; #include <pwd.h> #include <unistd.h> #include <paths.h> +#include <err.h> #include <rpc/rpc.h> #include <rpcsvc/rwall.h> @@ -64,16 +65,17 @@ struct timeval timeout = { 25, 0 }; int mbufsize; char *mbuf; -void makemsg (); +void makemsg(char *); int main(int argc, char *argv[]) { + extern char *__progname; char *wallhost, res; CLIENT *cl; if ((argc < 2) || (argc > 3)) { - fprintf(stderr, "usage: %s hostname [file]\n", argv[0]); + fprintf(stderr, "usage: %s hostname [file]\n", __progname); exit(1); } @@ -96,9 +98,10 @@ main(int argc, char *argv[]) exit(1); } - if (clnt_call(cl, WALLPROC_WALL, xdr_wrapstring, &mbuf, xdr_void, &res, timeout) != RPC_SUCCESS) { + if (clnt_call(cl, WALLPROC_WALL, xdr_wrapstring, &mbuf, xdr_void, + &res, timeout) != RPC_SUCCESS) { /* - * An error occurred while calling the server. + * An error occurred while calling the server. * Print error message and die. */ clnt_perror(cl, wallhost); @@ -119,11 +122,9 @@ makemsg(char *fname) int fd; char *whom, hostname[MAXHOSTNAMELEN], lbuf[100], tmpname[MAXPATHLEN]; - snprintf(tmpname, sizeof(tmpname), "%s/wall.XXXXXXXXXX", _PATH_TMP); - if ((fd = mkstemp(tmpname)) == -1 || !(fp = fdopen(fd, "r+"))) { - (void)fprintf(stderr, "wall: can't open temporary file.\n"); - exit(1); - } + snprintf(tmpname, sizeof(tmpname), "%s/wall.XXXXXXXXXX", _PATH_TMP); + if ((fd = mkstemp(tmpname)) == -1 || !(fp = fdopen(fd, "r+"))) + err(1, "can't open temporary file"); (void)unlink(tmpname); if (!(whom = getlogin())) @@ -146,26 +147,18 @@ makemsg(char *fname) putc('\n', fp); - if (fname && !(freopen(fname, "r", stdin))) { - (void)fprintf(stderr, "wall: can't read %s.\n", fname); - exit(1); - } + if (fname && !(freopen(fname, "r", stdin))) + err(1, "%s", fname); while (fgets(lbuf, sizeof(lbuf), stdin)) fputs(lbuf, fp); rewind(fp); - if (fstat(fd, &sbuf)) { - (void)fprintf(stderr, "wall: can't stat temporary file.\n"); - exit(1); - } + if (fstat(fd, &sbuf)) + err(1, "can't stat temporary file"); mbufsize = sbuf.st_size; - if (!(mbuf = malloc((u_int)mbufsize))) { - (void)fprintf(stderr, "wall: out of memory.\n"); - exit(1); - } - if (fread(mbuf, sizeof(*mbuf), mbufsize, fp) != mbufsize) { - (void)fprintf(stderr, "wall: can't read temporary file.\n"); - exit(1); - } + if (!(mbuf = malloc((u_int)mbufsize))) + err(1, "malloc"); + if (fread(mbuf, sizeof(*mbuf), mbufsize, fp) != mbufsize) + err(1, "can't read temporary file"); (void)close(fd); } |