diff options
Diffstat (limited to 'usr.sbin/lptcontrol')
-rw-r--r-- | usr.sbin/lptcontrol/lptcontrol.8 | 84 | ||||
-rw-r--r-- | usr.sbin/lptcontrol/lptcontrol.c | 54 |
2 files changed, 82 insertions, 56 deletions
diff --git a/usr.sbin/lptcontrol/lptcontrol.8 b/usr.sbin/lptcontrol/lptcontrol.8 index 52c34a6..4a02390 100644 --- a/usr.sbin/lptcontrol/lptcontrol.8 +++ b/usr.sbin/lptcontrol/lptcontrol.8 @@ -12,56 +12,62 @@ .\" .\" .\" $Id: lptcontrol.1,v 1.3 1994/05/22 12:31:54 csgr Exp $ -.TH lptcontrol 1 "March 12, 1994" "" "FreeBSD" - -.SH NAME -lptcontrol - a utility for manipulating the lpt printer driver. -.SH SYNOPSIS -.na -.B lptcontrol -.RB [options] -.SH DESCRIPTION +.Dd September 3, 1994 +.Dt LPTCONTROL 8 +.Os FreeBSD 2 +.Sh NAME +.Nm \&lptcontrol +.Nd a utility for manipulating the lpt printer driver. +.Sh SYNOPSIS +.Nm \&lptcontrol +.Cm -i +| +.Cm -p +.Op Fl u Ar unit no +.Sh DESCRIPTION The -.B lptcontrol +.Nm lptcontrol command is used to set either the interrupt-driven or polling mode -of individual lpt devices. When a printer is switched between +of individual +.Xr lpt 4 +devices. When a printer is switched between interrupt-driven and polled mode, this change will only take effect the next time the device is opened. -.SH OPTIONS +.Sh OPTIONS .TP -The following command line options are supported. -.TP -.B \-i +The following command line options are supported: +.Bl -tag -width indent +.It Fl i Turns on interrupt-driven mode. -.TP -.B \-p +.It Fl p Turns on polled mode. -.TP -.BI "\-f\ " file +.It Fl u Ar n Sets the mode of the printer device specified by -.I file. +.Em n . The default value for -.I file +.Em n is -.I /dev/lpt0 -.TP +.Em 0 (ie. /dev/lpt0) +.El +.Pp One of -.B \-i +.Fl i or -.B \-p +.Fl p must be specified. -.PP -.SH FILES -/dev/lpt? -.PP -.SH BUGS -If the port to be controlled does not have a printer connected and -on-line, then lptcontrol will not be able to open the port in question -for performing ioctl's and will fail. -.sp -Sure to be others. -.SH "SEE ALSO" -.BR lpt (4) , -.BR /sys/i386/conf/GENERICAH -.SH AUTHOR +.Pp +.Sh FILES +.Bl -tag -width indent -compact +.It Pa /dev/lpt? - printer devices +.It Pa /dev/lpctl? - printer control devices +.El +.Sh BUGS +Sure to be some. +.Sh "SEE ALSO" +.Xr lpt 4 +.Xr /sys/i386/conf/GENERICAH +.Sh AUTHOR Geoffrey M. Rehmet +.Sh HISTORY +.Nm lptcontrol +first appeared in FreeBSD 1.1.5 diff --git a/usr.sbin/lptcontrol/lptcontrol.c b/usr.sbin/lptcontrol/lptcontrol.c index bcb3ad3..cbe0410 100644 --- a/usr.sbin/lptcontrol/lptcontrol.c +++ b/usr.sbin/lptcontrol/lptcontrol.c @@ -27,30 +27,35 @@ * (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: lptcontrol.c,v 1.2 1994/04/08 22:23:39 csgr Exp $ + * $Id: lptcontrol.c,v 1.1.1.1 1994/09/03 13:10:09 csgr Exp $ */ -#include <sys/types.h> -#include <sys/file.h> -#include <sys/ioctl.h> -#include <machine/lpt.h> -#include <stdlib.h> -#include <unistd.h> +#include <ctype.h> +#include <limits.h> +#include <paths.h> #include <stdio.h> +#include <stdlib.h> #include <string.h> +#include <unistd.h> + +#include <machine/lpt.h> #include <sys/errno.h> +#include <sys/file.h> +#include <sys/ioctl.h> +#include <sys/types.h> -#define DEFAULT_LPT "/dev/lpt0" +#define PATH_LPCTL _PATH_DEV "lpctl" +#define DEFAULT_UNIT "0" #define IRQ_INVALID -1 #define DO_POLL 0 #define USE_IRQ 1 -static char default_printer[] = DEFAULT_LPT; - static void usage(const char * progname) { - fprintf(stderr, "usage: %s -i | -p [-f <file name>]\n", progname); + 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"); exit(1); } @@ -69,23 +74,38 @@ static void set_interrupt_status(int irq_status, const char * file) close(fd); } +static char * dev_file(char unit_no) +{ + static char devname[_POSIX_PATH_MAX+1]; + int len; + + strncpy(devname, PATH_LPCTL, _POSIX_PATH_MAX); + devname[len = strlen(devname)] = unit_no; + devname[++len] = '\0'; + + return(devname); +} int main (int argc, char * argv[]) { int opt; - int irq_status = -1; - char * file = default_printer; + int irq_status = IRQ_INVALID; + char * unit = DEFAULT_UNIT; - while((opt = getopt(argc, argv, "pif:")) != -1) + while((opt = getopt(argc, argv, "ipu:")) != -1) switch(opt) { case 'i': irq_status = USE_IRQ; break; case 'p': irq_status = DO_POLL; break; - case 'f': file = optarg; break; + case 'u': unit = optarg; + if(!isdigit(*unit)) + usage(argv[0]); + break; default : usage(argv[0]); } - if(irq_status == IRQ_INVALID) usage(argv[0]); + if(irq_status == IRQ_INVALID) + usage(argv[0]); - set_interrupt_status(irq_status, file); + set_interrupt_status(irq_status, dev_file(*unit)); exit(0); } |