Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.sbin/lpr/lpr - Replace fatal2() with the appropriate err...
details: https://anonhg.NetBSD.org/src/rev/7213ffa01840
branches: trunk
changeset: 761204:7213ffa01840
user: ginsbach <ginsbach%NetBSD.org@localhost>
date: Thu Jan 20 15:48:11 2011 +0000
description:
- Replace fatal2() with the appropriate err(3)/errx(3) calls.
diffstat:
usr.sbin/lpr/lpr/lpr.c | 40 +++++++++++++---------------------------
1 files changed, 13 insertions(+), 27 deletions(-)
diffs (115 lines):
diff -r ec94c8da9273 -r 7213ffa01840 usr.sbin/lpr/lpr/lpr.c
--- a/usr.sbin/lpr/lpr/lpr.c Thu Jan 20 15:44:56 2011 +0000
+++ b/usr.sbin/lpr/lpr/lpr.c Thu Jan 20 15:48:11 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lpr.c,v 1.43 2009/08/20 21:25:59 he Exp $ */
+/* $NetBSD: lpr.c,v 1.44 2011/01/20 15:48:11 ginsbach Exp $ */
/*
* Copyright (c) 1983, 1989, 1993
@@ -42,7 +42,7 @@
#if 0
static char sccsid[] = "@(#)lpr.c 8.4 (Berkeley) 4/28/95";
#else
-__RCSID("$NetBSD: lpr.c,v 1.43 2009/08/20 21:25:59 he Exp $");
+__RCSID("$NetBSD: lpr.c,v 1.44 2011/01/20 15:48:11 ginsbach Exp $");
#endif
#endif /* not lint */
@@ -106,8 +106,6 @@
static void chkprinter(const char *);
static void cleanup(int);
static void copy(int, const char *);
-static void fatal2(const char *, ...)
- __attribute__((__format__(__printf__, 1, 2),__noreturn__));
static char *itoa(int);
static const char *linked(const char *);
static char *lmktemp(const char *, int, int);
@@ -262,9 +260,9 @@
printer = DEFLP;
chkprinter(printer);
if (SC && ncopies > 1)
- fatal2("multiple copies are not allowed");
+ errx(EXIT_FAILURE, "multiple copies are not allowed");
if (MC > 0 && ncopies > MC)
- fatal2("only %ld copies are allowed", MC);
+ errx(EXIT_FAILURE, "only %ld copies are allowed", MC);
/*
* Get the identity of the person doing the lpr using the same
* algorithm as lprm.
@@ -272,7 +270,7 @@
userid = getuid();
if (userid != DU || person == 0) {
if ((pw = getpwuid(userid)) == NULL)
- fatal2("Who are you?");
+ errx(EXIT_FAILURE, "Who are you?");
person = pw->pw_name;
}
/*
@@ -280,7 +278,8 @@
*/
if (RG != NULL && userid != DU) {
if ((gptr = getgrnam(RG)) == NULL)
- fatal2("Restricted group specified incorrectly");
+ errx(EXIT_FAILURE,
+ "Restricted group specified incorrectly");
if (gptr->gr_gid != getgid()) {
while (*gptr->gr_mem != NULL) {
if ((strcmp(person, *gptr->gr_mem)) == 0)
@@ -288,7 +287,8 @@
gptr->gr_mem++;
}
if (*gptr->gr_mem == NULL)
- fatal2("Not a member of the restricted group");
+ errx(EXIT_FAILURE,
+ "Not a member of the restricted group");
}
}
/*
@@ -296,7 +296,7 @@
*/
(void)snprintf(buf, sizeof buf, "%s/%s", SD, LO);
if (userid && stat(buf, &stb) == 0 && (stb.st_mode & S_IXGRP))
- fatal2("Printer queue is disabled");
+ errx(EXIT_FAILURE, "Printer queue is disabled");
/*
* Initialize the control file.
*/
@@ -515,7 +515,8 @@
size_t len = 2;
if (strlen(p2) > BUFSIZ - 2)
- errx(1, "Internal error: String longer than %d", BUFSIZ);
+ errx(EXIT_FAILURE,
+ "Internal error: String longer than %d", BUFSIZ);
*p1++ = c;
while ((c = *p2++) != '\0') {
@@ -732,26 +733,11 @@
char *s;
if ((s = malloc(len)) == NULL)
- fatal2("out of memory");
+ err(EXIT_FAILURE, NULL);
(void)snprintf(s, len, "%s/%sA%03d%s", SD, id, num, host);
return(s);
}
-#include <stdarg.h>
-
-static void
-fatal2(const char *msg, ...)
-{
- va_list ap;
-
- va_start(ap, msg);
- printf("%s: ", getprogname());
- vprintf(msg, ap);
- putchar('\n');
- va_end(ap);
- exit(1);
-}
-
static void
usage(void)
{
Home |
Main Index |
Thread Index |
Old Index