summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--usr.sbin/sgsc/Makefile5
-rw-r--r--usr.sbin/sgsc/sgsc.191
-rw-r--r--usr.sbin/sgsc/sgsc.c193
3 files changed, 289 insertions, 0 deletions
diff --git a/usr.sbin/sgsc/Makefile b/usr.sbin/sgsc/Makefile
new file mode 100644
index 0000000..a25675d
--- /dev/null
+++ b/usr.sbin/sgsc/Makefile
@@ -0,0 +1,5 @@
+# $Id$
+
+PROG= sgsc
+
+.include <bsd.prog.mk>
diff --git a/usr.sbin/sgsc/sgsc.1 b/usr.sbin/sgsc/sgsc.1
new file mode 100644
index 0000000..164e72d
--- /dev/null
+++ b/usr.sbin/sgsc/sgsc.1
@@ -0,0 +1,91 @@
+.\" sgsc(1) - manual page for the `gsc' scanner device driver utility
+.\"
+.\"
+.\" Copyright (c) 1995 Gunther Schadow. All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\" 3. All advertising materials mentioning features or use of this software
+.\" must display the following acknowledgement:
+.\" This product includes software developed by Gunther Schadow.
+.\" 4. The name of the author may not be used to endorse or promote products
+.\" derived from this software without specific prior written permission.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+.\" 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.
+.TH SGSC 1 "January 6, 1995" FreeBSD "FreeBSD Reference Manual"
+.SH NAME
+\fBsgsc\fP - set the options of the gsc scanner device
+.SH SYNOPSIS
+.TP 5
+\fBsgsc\fP
+[\fB-sq\fP]
+[\fB-b\fP\ \fIlen\fP]
+[\fB-f\fP\ \fIfile\fP]
+[\fB-h\fP\ \fIheight\fP]
+[\fB-r\fP\ \fIresolution\fP]
+[\fB-t\fP\ \fItimeout\fP]
+[\fB-w\fP\ \fIwidth\fP]
+.SH DESCRIPTION
+The \fBsgsc\fP utility provides shell level access to the ioctl
+requests served by the handy scanner device driver gsc. Please see
+gsc(4) for the exact meaning of the requests. Generally they modify
+the output and behaviour of the gsc scanner device. When \fBsgsc\fP is
+called with no option only the current settings are reported.
+.SH OPTIONS
+.TP 3
+\fB-s\fP [GSC_SRESSW]
+Set the scanner with the values of the resolution selector switch.
+.TP
+\fB-q\fP
+Operate in quiet mode, i.e. do not report any of the current setings.
+Normally the parameters are shown after the modifications have been
+performed.
+.TP
+\fB-f\fP \fIfile\fP
+Operate on a different scanner device node given by filename. Note
+that even though there may exist more than one node of scanner device
+several of them will refer the same device unit. The modifications are
+performed od the unit regardless of the device node by which it is
+accessed.
+.TP
+\fB-r\fP \fIresolution\fP [GSC_SRES]
+Set the resolution in dpi.
+.TP
+\fB-w\fP \fIwidth\fP [GSC_SWIDHT]
+Set the width of the bitmap in pixels.
+.TP
+\fB-h\fP \fIheight\fP [GSC_SHEIGHT]
+Set the height of the bitmap in lines of pixels.
+.TP
+\fB-b\fP \fIlen\fP [GSC_SBLEN]
+Set the internal dma buffer to be \fIlen\fP lines in size.
+.TP
+\fB-t\fP \fItimeout\fP [GSC_SBTIME]
+Set the timeout time for reading one dma buffer.
+.SH FILES
+.TP 15
+.BI /dev/gsc0
+device node for \fIraw\fP output.
+.TP
+.BI /dev/gsc0p
+device node for output in \fIpbm\fP file format.
+.PB
+.SH SEE ALSO
+gsc(4)
+.SH AUTHOR
+Gunther Schadow <gusw@fub46.zedat.fu-berlin.de>
diff --git a/usr.sbin/sgsc/sgsc.c b/usr.sbin/sgsc/sgsc.c
new file mode 100644
index 0000000..056a1c1
--- /dev/null
+++ b/usr.sbin/sgsc/sgsc.c
@@ -0,0 +1,193 @@
+/* sgsc(1) - utility for the `gsc' scanner device driver
+ *
+ *
+ * Copyright (c) 1995 Gunther Schadow. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Gunther Schadow.
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * 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.
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <sys/file.h>
+#include <sys/ioctl.h>
+#include <machine/gsc.h>
+
+#ifndef DEFAULT_FILE
+#define DEFAULT_FILE "/dev/gsc0"
+#endif
+#ifdef FAIL
+#undef FAIL
+#endif
+#define FAIL -1
+
+usage(char *progn)
+{
+ fprintf(stderr, "usage: %s [-sq] [-f file] [-r dpi] "
+ "[-w width] [-h height] "
+ "[-b len] [-t time]\n", progn);
+ exit(1);
+}
+
+int
+main(int argc, char **argv)
+{
+ char c;
+ int fd;
+
+ char *file = DEFAULT_FILE;
+
+ int show_dpi = 0;
+ int show_width = 0;
+ int show_height = 0;
+ int show_blen = 0;
+ int show_btime = 0;
+ int show_all = 1;
+
+ int set_blen = 0;
+ int set_dpi = 0;
+ int set_width = 0;
+ int set_height = 0;
+ int set_btime = 0;
+ int set_switch = 0;
+
+ char *progn = *argv;
+
+ if (argc == 0) usage(progn);
+
+ while( (c = getopt(argc, argv, "sqf:b:r:w:h:t:")) != FAIL)
+ {
+ switch(c) {
+ case 'f': file = optarg; break;
+ case 'r': set_dpi = atoi(optarg); break;
+ case 'w': set_width = atoi(optarg); break;
+ case 'h': set_height = atoi(optarg); break;
+ case 'b': set_blen = atoi(optarg); break;
+ case 't': set_btime = atoi(optarg); break;
+ case 's': set_switch = 1; break;
+ case 'q': show_all = 0; break;
+ default: usage(progn);
+ }
+ }
+
+ fd = open(file, O_RDONLY);
+ if ( fd == FAIL )
+ {
+ perror(file);
+ exit(1);
+ }
+
+ if (set_switch != 0)
+ {
+ if(ioctl(fd, GSC_SRESSW) == FAIL)
+ {
+ perror("GSC_SRESSW");
+ exit(1);
+ }
+ }
+
+ if (set_dpi != 0)
+ {
+ if(ioctl(fd, GSC_SRES, &set_dpi) == FAIL)
+ {
+ perror("GSC_SRES");
+ exit(1);
+ }
+ }
+
+ if (set_width != 0)
+ {
+ if(ioctl(fd, GSC_SWIDTH, &set_width) == FAIL)
+ {
+ perror("GSC_SWIDTH");
+ exit(1);
+ }
+ }
+
+ if (set_height != 0)
+ {
+ if(ioctl(fd, GSC_SHEIGHT, &set_height) == FAIL)
+ {
+ perror("GSC_SHEIGHT");
+ exit(1);
+ }
+ }
+
+ if (set_blen != 0)
+ {
+ if(ioctl(fd, GSC_SBLEN, &set_blen) == FAIL)
+ {
+ perror("GSC_SBLEN");
+ exit(1);
+ }
+ }
+
+ if (set_btime != 0)
+ {
+ if(ioctl(fd, GSC_SBTIME, &set_btime) == FAIL)
+ {
+ perror("GSC_SBTIME");
+ exit(1);
+ }
+ }
+
+ if (show_all != 0)
+ {
+ if(ioctl(fd, GSC_GRES, &show_dpi) == FAIL)
+ {
+ perror("GSC_GRES");
+ exit(1);
+ }
+ if(ioctl(fd, GSC_GWIDTH, &show_width) == FAIL)
+ {
+ perror("GSC_GWIDTH");
+ exit(1);
+ }
+ if(ioctl(fd, GSC_GHEIGHT, &show_height) == FAIL)
+ {
+ perror("GSC_GHEIGHT");
+ exit(1);
+ }
+ if(ioctl(fd, GSC_GBLEN, &show_blen) == FAIL)
+ {
+ perror("GSC_GBLEN");
+ exit(1);
+ }
+ if(ioctl(fd, GSC_GBTIME, &show_btime) == FAIL)
+ {
+ perror("GSC_GBTIME");
+ exit(1);
+ }
+
+ printf("%s:\n", file);
+ printf("resolution\t %d dpi\n", show_dpi);
+ printf("width\t\t %d\n", show_width);
+ printf("height\t\t %d\n",show_height);
+ printf("buffer length\t %d\n", show_blen);
+ printf("buffer timeout\t %d\n", show_btime);
+ }
+
+ return 0;
+}
OpenPOWER on IntegriCloud