1 /* sgsc(1) - utility for the `gsc' 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.sbin/sgsc/sgsc.c,v 1.5 1999/08/28 01:19:57 peter Exp $
32 * $DragonFly: src/usr.sbin/sgsc/sgsc.c,v 1.3 2005/12/05 02:40:28 swildner Exp $
40 #include <sys/ioctl.h>
41 #include <machine/gsc.h>
44 #define DEFAULT_FILE "/dev/gsc0"
54 fprintf(stderr
, "%s\n%s\n",
55 "usage: sgsc [-sq] [-f file] [-r dpi] [-w width] [-h height]",
56 " [-b len] [-t time]");
61 main(int argc
, char **argv
)
66 char *file
= DEFAULT_FILE
;
82 if (argc
== 0) usage();
84 while( (c
= getopt(argc
, argv
, "sqf:b:r:w:h:t:")) != FAIL
)
87 case 'f': file
= optarg
; break;
88 case 'r': set_dpi
= atoi(optarg
); break;
89 case 'w': set_width
= atoi(optarg
); break;
90 case 'h': set_height
= atoi(optarg
); break;
91 case 'b': set_blen
= atoi(optarg
); break;
92 case 't': set_btime
= atoi(optarg
); break;
93 case 's': set_switch
= 1; break;
94 case 'q': show_all
= 0; break;
99 fd
= open(file
, O_RDONLY
);
105 if(ioctl(fd
, GSC_SRESSW
) == FAIL
)
106 err(1, "GSC_SRESSW");
111 if(ioctl(fd
, GSC_SRES
, &set_dpi
) == FAIL
)
117 if(ioctl(fd
, GSC_SWIDTH
, &set_width
) == FAIL
)
118 err(1, "GSC_SWIDTH");
123 if(ioctl(fd
, GSC_SHEIGHT
, &set_height
) == FAIL
)
124 err(1, "GSC_SHEIGHT");
129 if(ioctl(fd
, GSC_SBLEN
, &set_blen
) == FAIL
)
135 if(ioctl(fd
, GSC_SBTIME
, &set_btime
) == FAIL
)
136 err(1, "GSC_SBTIME");
141 if(ioctl(fd
, GSC_GRES
, &show_dpi
) == FAIL
)
143 if(ioctl(fd
, GSC_GWIDTH
, &show_width
) == FAIL
)
144 err(1, "GSC_GWIDTH");
145 if(ioctl(fd
, GSC_GHEIGHT
, &show_height
) == FAIL
)
146 err(1, "GSC_GHEIGHT");
147 if(ioctl(fd
, GSC_GBLEN
, &show_blen
) == FAIL
)
149 if(ioctl(fd
, GSC_GBTIME
, &show_btime
) == FAIL
)
150 err(1, "GSC_GBTIME");
152 printf("%s:\n", file
);
153 printf("resolution\t %d dpi\n", show_dpi
);
154 printf("width\t\t %d\n", show_width
);
155 printf("height\t\t %d\n",show_height
);
156 printf("buffer length\t %d\n", show_blen
);
157 printf("buffer timeout\t %d\n", show_btime
);