1 /* sasc(1) - utility for the `asc' scanner device driver
4 * Copyright (c) 1995 Gunther Schadow. All rights reserved.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. All advertising materials mentioning features or use of this software
15 * must display the following acknowledgement:
16 * This product includes software developed by Gunther Schadow.
17 * 4. The name of the author may not be used to endorse or promote products
18 * derived from this software without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
22 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
23 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
24 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
25 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
29 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 * $FreeBSD: src/usr.bin/sasc/sasc.c,v 1.7.2.1 2000/06/30 09:47:52 ps Exp $
32 * $DragonFly: src/usr.bin/sasc/sasc.c,v 1.3 2003/10/04 20:36:50 hmp Exp $
40 #include <sys/ioctl.h>
41 #include <machine/asc_ioctl.h>
44 #define DEFAULT_FILE "/dev/asc0"
51 static void usage(void);
57 "usage: sasc [-sq] [-f file] [-r dpi] [-w width] [-h height] \
58 [-b len] [-t time]\n");
63 main(int argc, char **argv)
68 char *file = DEFAULT_FILE;
84 if (argc == 0) usage();
86 while( (c = getopt(argc, argv, "sqf:b:r:w:h:t:")) != -1)
89 case 'f': file = optarg; break;
90 case 'r': set_dpi = atoi(optarg); break;
91 case 'w': set_width = atoi(optarg); break;
92 case 'h': set_height = atoi(optarg); break;
93 case 'b': set_blen = atoi(optarg); break;
94 case 't': set_btime = atoi(optarg); break;
95 case 's': set_switch = 1; break;
96 case 'q': show_all = 0; break;
101 fd = open(file, O_RDONLY);
107 if(ioctl(fd, ASC_SRESSW) == FAIL)
108 err(1, "ASC_SRESSW");
113 if(ioctl(fd, ASC_SRES, &set_dpi) == FAIL)
119 if(ioctl(fd, ASC_SWIDTH, &set_width) == FAIL)
120 err(1, "ASC_SWIDTH");
125 if(ioctl(fd, ASC_SHEIGHT, &set_height) == FAIL)
126 err(1, "ASC_SHEIGHT");
131 if(ioctl(fd, ASC_SBLEN, &set_blen) == FAIL)
137 if(ioctl(fd, ASC_SBTIME, &set_btime) == FAIL)
138 err(1, "ASC_SBTIME");
143 if(ioctl(fd, ASC_GRES, &show_dpi) == FAIL)
145 if(ioctl(fd, ASC_GWIDTH, &show_width) == FAIL)
146 err(1, "ASC_GWIDTH");
147 if(ioctl(fd, ASC_GHEIGHT, &show_height) == FAIL)
148 err(1, "ASC_GHEIGHT");
149 if(ioctl(fd, ASC_GBLEN, &show_blen) == FAIL)
151 if(ioctl(fd, ASC_GBTIME, &show_btime) == FAIL)
152 err(1, "ASC_GBTIME");
154 printf("%s:\n", file);
155 printf("resolution\t %d dpi\n", show_dpi);
156 printf("width\t\t %d\n", show_width);
157 printf("height\t\t %d\n",show_height);
158 printf("buffer length\t %d\n", show_blen);
159 printf("buffer timeout\t %d\n", show_btime);