lptcontrol.c (fe577fe9397456e120a89d6352edc578298ff29c) | lptcontrol.c (bc35c17446fab005a7e11b67b9004736f1c8498b) |
---|---|
1/* 2 * Copyright (c) 1994 Geoffrey M. Rehmet 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 16 unchanged lines hidden (view full) --- 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 */ 30 31#ifndef lint 32static const char rcsid[] = | 1/* 2 * Copyright (c) 1994 Geoffrey M. Rehmet 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 16 unchanged lines hidden (view full) --- 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 */ 30 31#ifndef lint 32static const char rcsid[] = |
33 "$Id$"; | 33 "$Id: lptcontrol.c,v 1.6 1997/09/25 06:36:29 charnier Exp $"; |
34#endif /* not lint */ 35 36#include <ctype.h> 37#include <err.h> 38#include <limits.h> 39#include <paths.h> 40#include <stdio.h> 41#include <stdlib.h> --- 6 unchanged lines hidden (view full) --- 48#include <sys/types.h> 49 50 51#define PATH_LPCTL _PATH_DEV "lpctl" 52#define DEFAULT_UNIT "0" 53#define IRQ_INVALID -1 54#define DO_POLL 0 55#define USE_IRQ 1 | 34#endif /* not lint */ 35 36#include <ctype.h> 37#include <err.h> 38#include <limits.h> 39#include <paths.h> 40#include <stdio.h> 41#include <stdlib.h> --- 6 unchanged lines hidden (view full) --- 48#include <sys/types.h> 49 50 51#define PATH_LPCTL _PATH_DEV "lpctl" 52#define DEFAULT_UNIT "0" 53#define IRQ_INVALID -1 54#define DO_POLL 0 55#define USE_IRQ 1 |
56#define USE_EXT_MODE 2 57#define USE_STD_MODE 3 |
|
56 57static void usage() 58{ | 58 59static void usage() 60{ |
59 fprintf(stderr, "usage: lptcontrol -i | -p [-u <unit no.>]\n"); | 61 fprintf(stderr, "usage: lptcontrol -i | -p | -s | -e [-u <unit no.>]\n"); |
60 exit(1); 61} 62 63static void set_interrupt_status(int irq_status, const char * file) 64{ 65 int fd; 66 67 if((fd = open(file, O_WRONLY, 0660)) < 0) --- 16 unchanged lines hidden (view full) --- 84} 85 86int main (int argc, char * argv[]) 87{ 88 int opt; 89 int irq_status = IRQ_INVALID; 90 char * unit = DEFAULT_UNIT; 91 | 62 exit(1); 63} 64 65static void set_interrupt_status(int irq_status, const char * file) 66{ 67 int fd; 68 69 if((fd = open(file, O_WRONLY, 0660)) < 0) --- 16 unchanged lines hidden (view full) --- 86} 87 88int main (int argc, char * argv[]) 89{ 90 int opt; 91 int irq_status = IRQ_INVALID; 92 char * unit = DEFAULT_UNIT; 93 |
92 while((opt = getopt(argc, argv, "ipu:")) != -1) | 94 while((opt = getopt(argc, argv, "ipesu:")) != -1) |
93 switch(opt) { 94 case 'i': irq_status = USE_IRQ; break; 95 case 'p': irq_status = DO_POLL; break; | 95 switch(opt) { 96 case 'i': irq_status = USE_IRQ; break; 97 case 'p': irq_status = DO_POLL; break; |
98 case 'e': irq_status = USE_EXT_MODE; break; 99 case 's': irq_status = USE_STD_MODE; break; |
|
96 case 'u': unit = optarg; 97 if(!isdigit(*unit)) 98 usage(); 99 break; 100 default : usage(); 101 } 102 if(irq_status == IRQ_INVALID) 103 usage(); 104 105 set_interrupt_status(irq_status, dev_file(*unit)); 106 107 exit(0); 108} | 100 case 'u': unit = optarg; 101 if(!isdigit(*unit)) 102 usage(); 103 break; 104 default : usage(); 105 } 106 if(irq_status == IRQ_INVALID) 107 usage(); 108 109 set_interrupt_status(irq_status, dev_file(*unit)); 110 111 exit(0); 112} |