summaryrefslogtreecommitdiffstats
path: root/usr.sbin/lptcontrol
diff options
context:
space:
mode:
authorcharnier <charnier@FreeBSD.org>1997-09-25 06:36:29 +0000
committercharnier <charnier@FreeBSD.org>1997-09-25 06:36:29 +0000
commit46349eda656a56e2cff10a8d8131b19abd6f97a4 (patch)
tree3383e33a82c0b1abf800e0fec1e3b9bbc49244dc /usr.sbin/lptcontrol
parentd84a9433e41f5f784b191848654fcad58b495f67 (diff)
downloadFreeBSD-src-46349eda656a56e2cff10a8d8131b19abd6f97a4.zip
FreeBSD-src-46349eda656a56e2cff10a8d8131b19abd6f97a4.tar.gz
Use err(3).
Diffstat (limited to 'usr.sbin/lptcontrol')
-rw-r--r--usr.sbin/lptcontrol/lptcontrol.834
-rw-r--r--usr.sbin/lptcontrol/lptcontrol.c35
2 files changed, 35 insertions, 34 deletions
diff --git a/usr.sbin/lptcontrol/lptcontrol.8 b/usr.sbin/lptcontrol/lptcontrol.8
index 51de5f7..d174fe6 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 d6110a6..73ea05c 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 <ctype.h>
+#include <err.h>
#include <limits.h>
#include <paths.h>
#include <stdio.h>
@@ -39,7 +43,6 @@
#include <unistd.h>
#include <machine/lpt.h>
-#include <sys/errno.h>
#include <sys/file.h>
#include <sys/ioctl.h>
#include <sys/types.h>
@@ -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 <unit no.>]\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 <unit no.>]\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);
}
-
-
OpenPOWER on IntegriCloud