From 46349eda656a56e2cff10a8d8131b19abd6f97a4 Mon Sep 17 00:00:00 2001 From: charnier Date: Thu, 25 Sep 1997 06:36:29 +0000 Subject: [PATCH] Use err(3). --- usr.sbin/lptcontrol/lptcontrol.8 | 34 ++++++++++++++++++------------- usr.sbin/lptcontrol/lptcontrol.c | 35 ++++++++++++++------------------ 2 files changed, 35 insertions(+), 34 deletions(-) diff --git a/usr.sbin/lptcontrol/lptcontrol.8 b/usr.sbin/lptcontrol/lptcontrol.8 index 51de5f7841b..d174fe646d3 100644 --- a/usr.sbin/lptcontrol/lptcontrol.8 +++ b/usr.sbin/lptcontrol/lptcontrol.8 @@ -11,13 +11,13 @@ .\" documentation and/or other materials provided with the distribution. .\" .\" -.\" $Id$ +.\" $Id: lptcontrol.8,v 1.5 1997/02/22 16:06:24 peter Exp $ .Dd September 3, 1994 .Dt LPTCONTROL 8 .Os FreeBSD 2 .Sh NAME .Nm \&lptcontrol -.Nd a utility for manipulating the lpt printer driver. +.Nd a utility for manipulating the lpt printer driver .Sh SYNOPSIS .Nm \&lptcontrol .Cm -i @@ -26,7 +26,7 @@ .Op Fl u Ar unit no .Sh DESCRIPTION The -.Nm lptcontrol +.Nm command is used to set either the interrupt-driven or polling mode of individual .Xr lpt 4 @@ -38,16 +38,18 @@ the next time the device is opened. The following command line options are supported: .Bl -tag -width indent .It Fl i -Turns on interrupt-driven mode. +Turn on interrupt-driven mode. .It Fl p -Turns on polled mode. +Turn on polled mode. .It Fl u Ar n -Sets the mode of the printer device specified by +Set the mode of the printer device specified by .Em n . The default value for .Em n is -.Em 0 (ie. /dev/lpt0) +.Em 0 +(ie. +.Pa /dev/lpt0 ) .El .Pp One of @@ -57,17 +59,21 @@ or must be specified. .Pp .Sh FILES -.Bl -tag -width indent -compact -.It Pa /dev/lpt? - printer devices -.It Pa /dev/lpctl? - printer control devices -.It Pa /sys/i386/conf/GENERIC - kernel configuration file +.Bl -tag -width /sys/i386/conf/GENERIC -compact +.It Pa /dev/lpt? +Printer devices. +.It Pa /dev/lpctl? +Printer control devices. +.It Pa /sys/i386/conf/GENERIC +Kernel configuration file. .El .Sh BUGS Sure to be some. .Sh "SEE ALSO" .Xr lpt 4 .Sh AUTHOR -Geoffrey M. Rehmet +.An Geoffrey M. Rehmet .Sh HISTORY -.Nm lptcontrol -first appeared in FreeBSD 1.1.5 +.Nm Lptcontrol +first appeared in +.Fx 1.1.5 diff --git a/usr.sbin/lptcontrol/lptcontrol.c b/usr.sbin/lptcontrol/lptcontrol.c index d6110a66cab..73ea05cf459 100644 --- a/usr.sbin/lptcontrol/lptcontrol.c +++ b/usr.sbin/lptcontrol/lptcontrol.c @@ -26,11 +26,15 @@ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $Id$ */ +#ifndef lint +static const char rcsid[] = + "$Id$"; +#endif /* not lint */ + #include +#include #include #include #include @@ -39,7 +43,6 @@ #include #include -#include #include #include #include @@ -51,11 +54,9 @@ #define DO_POLL 0 #define USE_IRQ 1 -static void usage(const char * progname) +static void usage() { - fprintf(stderr, "usage: %s -i | -p [-u ]\n", progname); - fprintf(stderr, "\tUnit no. is a value in the range 0 to 3\n"); - fprintf(stderr, "\tThe default unit no is 0 (ie. /dev/lpt0)\n"); + fprintf(stderr, "usage: lptcontrol -i | -p [-u ]\n"); exit(1); } @@ -63,14 +64,10 @@ static void set_interrupt_status(int irq_status, const char * file) { int fd; - if((fd = open(file, O_WRONLY, 0660)) < 0) { - perror("open"); - exit(1); - } - if(ioctl(fd, LPT_IRQ, &irq_status) < 0) { - perror("ioctl"); - exit(1); - } + if((fd = open(file, O_WRONLY, 0660)) < 0) + err(1, "open"); + if(ioctl(fd, LPT_IRQ, &irq_status) < 0) + err(1, "ioctl"); close(fd); } @@ -98,16 +95,14 @@ int main (int argc, char * argv[]) case 'p': irq_status = DO_POLL; break; case 'u': unit = optarg; if(!isdigit(*unit)) - usage(argv[0]); + usage(); break; - default : usage(argv[0]); + default : usage(); } if(irq_status == IRQ_INVALID) - usage(argv[0]); + usage(); set_interrupt_status(irq_status, dev_file(*unit)); exit(0); } - - -- 2.45.2