diff options
author | kstailey <kstailey@cvs.openbsd.org> | 1997-03-11 03:23:19 +0000 |
---|---|---|
committer | kstailey <kstailey@cvs.openbsd.org> | 1997-03-11 03:23:19 +0000 |
commit | 2c9f7b546f76c7a75234d7755f9d96688406046f (patch) | |
tree | a4f918205b154167d6bf5bf25278f5655f1ecf87 /usr.sbin/ssio | |
parent | 1b301f2ae51a4ebfc354000cc614c51c00687892 (diff) |
the PINT scanner utilities for now
Diffstat (limited to 'usr.sbin/ssio')
-rw-r--r-- | usr.sbin/ssio/INSTALL | 9 | ||||
-rw-r--r-- | usr.sbin/ssio/Makefile | 51 | ||||
-rw-r--r-- | usr.sbin/ssio/fixup_fujitsu_grayscale.c | 70 | ||||
-rw-r--r-- | usr.sbin/ssio/fs1toppm.1 | 65 | ||||
-rw-r--r-- | usr.sbin/ssio/fs1toppm.c | 112 | ||||
-rw-r--r-- | usr.sbin/ssio/fujitsu_m3096g_grabscan.sh | 69 | ||||
-rw-r--r-- | usr.sbin/ssio/get_scanner.1 | 56 | ||||
-rw-r--r-- | usr.sbin/ssio/get_scanner.c | 203 | ||||
-rw-r--r-- | usr.sbin/ssio/grabscan.1 | 46 | ||||
-rw-r--r-- | usr.sbin/ssio/grabscan.sh | 97 | ||||
-rw-r--r-- | usr.sbin/ssio/hp_scanjet_IIc_grabscan.sh | 80 | ||||
-rw-r--r-- | usr.sbin/ssio/reset_scanner.1 | 33 | ||||
-rw-r--r-- | usr.sbin/ssio/reset_scanner.c | 91 | ||||
-rw-r--r-- | usr.sbin/ssio/ricoh_fs1_grabscan.sh | 63 | ||||
-rw-r--r-- | usr.sbin/ssio/ricoh_is410_grabscan.sh | 70 | ||||
-rw-r--r-- | usr.sbin/ssio/ricoh_is50_grabscan.sh | 70 | ||||
-rw-r--r-- | usr.sbin/ssio/set_scanner.1 | 130 | ||||
-rw-r--r-- | usr.sbin/ssio/set_scanner.c | 339 | ||||
-rw-r--r-- | usr.sbin/ssio/sharp_jx600_grabscan.sh | 80 | ||||
-rw-r--r-- | usr.sbin/ssio/umax_uc630_grabscan.sh | 117 | ||||
-rw-r--r-- | usr.sbin/ssio/use_adf.1 | 49 | ||||
-rw-r--r-- | usr.sbin/ssio/use_adf.c | 108 |
22 files changed, 2008 insertions, 0 deletions
diff --git a/usr.sbin/ssio/INSTALL b/usr.sbin/ssio/INSTALL new file mode 100644 index 00000000000..a8a71182922 --- /dev/null +++ b/usr.sbin/ssio/INSTALL @@ -0,0 +1,9 @@ +1) Make sure that the pint driver is in your kernel, see ../INSTALL + +2) Make sure that /usr/include/sys/scanio.h is the one for your OS. + +3) Fiddle with Makefile if you want to. + +4) Type "make install". + +5) cd into scripts, type "make install" diff --git a/usr.sbin/ssio/Makefile b/usr.sbin/ssio/Makefile new file mode 100644 index 00000000000..92843434544 --- /dev/null +++ b/usr.sbin/ssio/Makefile @@ -0,0 +1,51 @@ +# PINT Makefile for utilities +# $Id: Makefile,v 1.1 1997/03/11 03:23:11 kstailey Exp $ +# +# Copyright (c) 1996 Kenneth Stailey +# 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 for the NetBSD Project +# by Kenneth Stailey +# 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. +# +# + +CC = gcc +CFLAGS = -O -g -DTRUE=1 -DFALSE=0 + +PROGS = get_scanner set_scanner use_adf reset_scanner fs1toppm + +BIN_DIR = /usr/local/bin +MAN_DIR = /usr/local/man/man1 + +all: $(PROGS) + +install: all + cp $(PROGS) $(BIN_DIR) + cp *.1 $(MAN_DIR) + +clean: + rm -f $(PROGS) *.o core a.out diff --git a/usr.sbin/ssio/fixup_fujitsu_grayscale.c b/usr.sbin/ssio/fixup_fujitsu_grayscale.c new file mode 100644 index 00000000000..21afacc04a6 --- /dev/null +++ b/usr.sbin/ssio/fixup_fujitsu_grayscale.c @@ -0,0 +1,70 @@ +static char *rcs_id = "$Id: fixup_fujitsu_grayscale.c,v 1.1 1997/03/11 03:23:11 kstailey Exp $"; +/* + * Copyright (c) 1995 Kenneth Stailey + * 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 for the NetBSD Project + * by Kenneth Stailey + * 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. + */ + +/* + * fixup_fujitsu_grayscale.c: convert scanner output to PGM + * + * This is faster than using "pgminvert | pnmgamma" but does the same + * thing basically. + */ + +#include <stdio.h> +#include <math.h> + +static int gamma_table[256]; + +void buildgamma(double gamma) +{ + int i, v; + double one_over_gamma, index; + + one_over_gamma = 1.0 / gamma; + + for (i = 0; i <= 255; ++i) { + index = (double)i / 255.0; + v = (255.0 * pow(index, one_over_gamma)) + 0.5; + if (v > 255) + v = 255; + gamma_table[i] = 255 - v; + } +} + +main() +{ + int ch; + + buildgamma(0.75); + + while ((ch = getchar()) != EOF) + putchar((char)(gamma_table[ch])); +} diff --git a/usr.sbin/ssio/fs1toppm.1 b/usr.sbin/ssio/fs1toppm.1 new file mode 100644 index 00000000000..26c3eba8c5f --- /dev/null +++ b/usr.sbin/ssio/fs1toppm.1 @@ -0,0 +1,65 @@ +.\" $Id: fs1toppm.1,v 1.1 1997/03/11 03:23:11 kstailey Exp $ +.\" +.\" Copyright (c) 1996 Kenneth Stailey +.\" 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 for the NetBSD Project +.\" by Kenneth Stailey +.\" 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 fs1toppm 1 "21 February 1994" +.SH NAME +fs1toppm - convert the output from the Ricoh FS1 scanner to PPM format +.SH SYNOPSIS +.B fs1toppm +.I <width in pixels> <height in pixels> +.I <FS1 file> +.SH DESCRIPTION +.I fs1toppm +reads the width and height in pixels of the scanner image +data as a decimal integer from the command line and the scanner image +data from the file specified on the command line. +It writes the data out in a format compatible with Portable Pix Map +(PPM) "rawbits". +.PP +This program was written because the color data format used by +the Ricoh FS1 scanner and Portable Pix Map (PPM) are incompatible. +In PPM the red, green and blue samples are interleaved at the pixel level; +the Ricoh FS1 interleaves them at the row level. +.PP +The +.I grabscan +script uses +.I fs1toppm +internally. +.SH EXAMPLES +fs1toppm 100 200 picture.fs1 >picture.ppm +.SH SEE ALSO +ppm(5) +.SH AUTHOR +.nf +Kenneth Stailey (kstailey@gnu.ai.mit.edu) (kstailey@leidecker.gsfc.nasa.gov) +.fi diff --git a/usr.sbin/ssio/fs1toppm.c b/usr.sbin/ssio/fs1toppm.c new file mode 100644 index 00000000000..9b7e6fde3bb --- /dev/null +++ b/usr.sbin/ssio/fs1toppm.c @@ -0,0 +1,112 @@ +static char *rcs_id = "$Id: fs1toppm.c,v 1.1 1997/03/11 03:23:12 kstailey Exp $"; +/* + * Copyright (c) 1995 Kenneth Stailey + * 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 for the NetBSD Project + * by Kenneth Stailey + * 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. + */ + + +/* + * fs1toppm.c: convert output from Ricoh FS1 into PPM format + */ + +#include <stdio.h> +#include <fcntl.h> +#include <unistd.h> + +char fp_buf[262144]; +char out_buf[262144]; + +void usage(); +int read_rgb(FILE *, char *, int); + +main(int argc, char *argv[]) +{ + int width; + FILE *fp; + char rgb[3]; + + if (argc != 4) { + usage(); + exit(1); + } + + width = atoi(argv[1]); + + if ((fp = fopen(argv[3], "r")) == NULL) { + perror("open"); + exit(-1); + } + setbuffer(fp, fp_buf, 262144); + setbuffer(stdout, out_buf, 262144); + + printf("P6\n%d %d 255\n", width, atoi(argv[2])); + + while(read_rgb(fp, rgb, width) != EOF) { + fwrite(rgb, 3, 1, stdout); + } + + fclose(fp); +} + +int read_rgb(FILE *fp, char *rgb, int width) +{ + static int cur_pos = 0; + + if (fseek(fp, cur_pos, SEEK_SET) != 0) { + perror("fseek red"); + exit(-1); + } + if (fread(&rgb[0], 1, 1, fp) != 1) + return EOF; + + if (fseek(fp, cur_pos + width, SEEK_SET) != 0) { + perror("fseek green"); + exit(-1); + } + if (fread(&rgb[1], 1, 1, fp) != 1) + return EOF; + + if (fseek(fp, cur_pos + width * 2, SEEK_SET) != 0) { + perror("fseek blue"); + exit(-1); + } + if (fread(&rgb[2], 1, 1, fp) != 1) + return EOF; + + if (++cur_pos % width == 0) + cur_pos += width * 2; + + return 0; +} + +void usage() +{ + fprintf(stderr, "usage: fs1toppm width height fs1_file\n"); +} diff --git a/usr.sbin/ssio/fujitsu_m3096g_grabscan.sh b/usr.sbin/ssio/fujitsu_m3096g_grabscan.sh new file mode 100644 index 00000000000..acf3d5aabd2 --- /dev/null +++ b/usr.sbin/ssio/fujitsu_m3096g_grabscan.sh @@ -0,0 +1,69 @@ +#!/bin/sh + +# $Id: fujitsu_m3096g_grabscan.sh,v 1.1 1997/03/11 03:23:12 kstailey Exp $ +# +# Copyright (c) 1996 Kenneth Stailey +# 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 for the NetBSD Project +# by Kenneth Stailey +# 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. +# + +# +# a wrapper for making PNM rawbits files from the Fujitsu scanner data +# + +if [ $# -gt 1 ] +then + echo usage: $0 [\<logical name of scanner\>] 1>&2 + exit -1 +fi + +if [ $# = 0 ] +then + scan_lname=scan0 +else + scan_lname=$1 +fi + +image_mode=`get_scanner -l $scan_lname | awk '/image_mode/ { print $3 }'` + +set `get_scanner -p -l $scan_lname` +width=$1 +height=$2 + +if [ $image_mode = grayscale ] +then + echo P5 + echo $width $height + echo 255 + dd if=/dev/$scan_lname bs=256k | fixup_fujitsu_grayscale +else # monochrome + echo P4 + echo $width $height + dd if=/dev/$scan_lname bs=256k +fi diff --git a/usr.sbin/ssio/get_scanner.1 b/usr.sbin/ssio/get_scanner.1 new file mode 100644 index 00000000000..2ca0798f12f --- /dev/null +++ b/usr.sbin/ssio/get_scanner.1 @@ -0,0 +1,56 @@ +.\" $Id: get_scanner.1,v 1.1 1997/03/11 03:23:13 kstailey Exp $ +.\" +.\" Copyright (c) 1996 Kenneth Stailey +.\" 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 for the NetBSD Project +.\" by Kenneth Stailey +.\" 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 get_scanner 1 "25 October 1994" +.SH NAME +get_scanner - view the current parameter settings for the scanner +.SH SYNOPSIS +.B get_scanner +.RI [ -p ][ -q ][ -l <logical-name-of-scanner-to-use>] +.SH DESCRIPTION +Produces a list of scanner attributes and their values. The -p flag +makes get_scanner print only the pixel size of the image. The +optional -q flag formats the list to match the command line for the +set_scanner program. This is useful for saving and restoring settings +inside of scripts. The -l flag is used if you have two or more +scanners. The default logical name is "scan0". +.SH EXAMPLES +get_scanner -l scan1 + +old_values=`get_scanner -q` +.SH "SEE ALSO" +set_scanner(1) +.SH AUTHOR +.nf +Kenneth Stailey (kstailey@leidecker.gsfc.nasa.gov, + kstailey@gnu.ai.mit.edu) +.fi diff --git a/usr.sbin/ssio/get_scanner.c b/usr.sbin/ssio/get_scanner.c new file mode 100644 index 00000000000..9c6458ef8ad --- /dev/null +++ b/usr.sbin/ssio/get_scanner.c @@ -0,0 +1,203 @@ +static char *rcs_id = "$Id: get_scanner.c,v 1.1 1997/03/11 03:23:13 kstailey Exp $"; +/* + * Copyright (c) 1995 Kenneth Stailey + * 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 for the NetBSD Project + * by Kenneth Stailey + * 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. + */ + +/* + * get_scanner.c: retrieve the a scanner's parameters + */ +#include <stdlib.h> +#include <stdio.h> +#include <string.h> +#include <fcntl.h> +#ifdef __NetBSD__ +#include <sys/ioctl.h> +#endif +#include <sys/scanio.h> + +int print_type(int type) { + static char *scanners[] = { + "kibo", + "ricoh_is410", + "fujitsu_m3069g", + "hp_scanjet_IIc", + "ricoh_fs1", + "sharp_jx600", + "ricoh_is50", + "ibm_2456", + "umax_uc630", + "umax_ug630", + "mustek_06000cx", + "mustek_12000cx", + }; + + if (type < 0 || type > MUSTEK_12000CX) + return 1; + + puts(scanners[type]); + return 0; +} + +void +usage(char *prog_name) +{ + fprintf(stderr, "usage: %s [-p][-q][-l <logical name>]\n", prog_name); + exit(-1); +} + + +main(int argc, char *argv[]) +{ + int s_fd; + struct scan_io s_io; + + int quiet = FALSE; + int do_pixels = FALSE; + int do_type = FALSE; + + char *logical_name = "scan0"; + char device_special[255]; + + int c; + extern int optind; + extern char *optarg; + + while ((c = getopt(argc, argv, "tpql:")) != EOF) { + switch (c) { + case 'q': + quiet = TRUE; + break; + + case 'l': + logical_name = optarg; + break; + + case 'p': + do_pixels = TRUE; + break; + + case 't': + do_type = TRUE; + break; + + case '?': + usage(argv[0]); + break; + } + } + + sprintf(device_special, "/dev/%s", logical_name); + if ((s_fd = open(device_special, O_RDONLY)) < 0) { + perror("open of scanner"); + exit(-1); + } + + if (ioctl(s_fd, SCIOCGET, &s_io) < 0) { + perror("ioctl on scanner"); + exit(-1); + } + + if (do_pixels) { + printf("%d %d\n", s_io.scan_pixels_per_line, s_io.scan_lines); + exit(0); + } + + if (do_type) + return (print_type(s_io.scan_scanner_type)); + + if (quiet) { + printf("-w %g -h %g -x %g -y %g -b %d -c %d -r %d", + (double)s_io.scan_width / 1200.0, + (double)s_io.scan_height / 1200.0, + (double)s_io.scan_x_origin / 1200.0, + (double)s_io.scan_y_origin / 1200.0, + s_io.scan_brightness, + s_io.scan_contrast, + s_io.scan_x_resolution); + switch (s_io.scan_image_mode) { + case SIM_BINARY_MONOCHROME: + printf(" -i m\n"); + break; + case SIM_DITHERED_MONOCHROME: + printf(" -i d\n"); + break; + case SIM_GRAYSCALE: + printf(" -i g\n"); + break; + case SIM_COLOR: + printf(" -i c\n"); + break; + case SIM_RED: + printf(" -i R\n"); + break; + case SIM_GREEN: + printf(" -i G\n"); + break; + case SIM_BLUE: + printf(" -i B\n"); + break; + } + } else { + printf("width = %g inches\n", (double)s_io.scan_width / 1200.0); + printf("height = %g inches\n", (double)s_io.scan_height / 1200.0); + printf("x_origin = %g inches\n", (double)s_io.scan_x_origin / 1200.0); + printf("y_origin = %g inches\n", (double)s_io.scan_y_origin / 1200.0); + printf("brightness = %d\n", s_io.scan_brightness); + printf("contrast = %d\n", s_io.scan_contrast); + printf("resolution = %d dpi\n", s_io.scan_x_resolution); + printf("image_mode = "); + switch (s_io.scan_image_mode) { + case SIM_BINARY_MONOCHROME: + printf("binary_monochrome\n"); + break; + case SIM_DITHERED_MONOCHROME: + printf("dithered_monochrome\n"); + break; + case SIM_GRAYSCALE: + printf("grayscale\n"); + break; + case SIM_COLOR: + printf("color\n"); + break; + case SIM_RED: + printf("red\n"); + break; + case SIM_GREEN: + printf("green\n"); + break; + case SIM_BLUE: + printf("blue\n"); + break; + } + } + + close(s_fd); +} diff --git a/usr.sbin/ssio/grabscan.1 b/usr.sbin/ssio/grabscan.1 new file mode 100644 index 00000000000..cfee3b04c4f --- /dev/null +++ b/usr.sbin/ssio/grabscan.1 @@ -0,0 +1,46 @@ +.\" $Id: grabscan.1,v 1.1 1997/03/11 03:23:13 kstailey Exp $ +.\" +.\" Copyright (c) 1996 Kenneth Stailey +.\" 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 for the NetBSD Project +.\" by Kenneth Stailey +.\" 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 grabscan 1 "22 November 1994" +.SH NAME +grabscan - read scanner data into a Portable Any Map (PNM) file +.SH SYNOPSIS +.B grabscan +.RI [ -l <logical-name-of-scanner-to-use>] +.SH DESCRIPTION +Grabscan analyzes the scanner parameters and uses them to construct a +PNM file header. It then writes the header and scanner data to standard +output. +.SH AUTHOR +.nf +Kenneth Stailey (kstailey@leidecker.gsfc.nasa.gov) +.fi diff --git a/usr.sbin/ssio/grabscan.sh b/usr.sbin/ssio/grabscan.sh new file mode 100644 index 00000000000..56649016459 --- /dev/null +++ b/usr.sbin/ssio/grabscan.sh @@ -0,0 +1,97 @@ +#!/bin/sh + +# $Id: grabscan.sh,v 1.1 1997/03/11 03:23:14 kstailey Exp $ +# +# Copyright (c) 1996 Kenneth Stailey +# 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 for the NetBSD Project +# by Kenneth Stailey +# 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. +# + +# top-level script to kick off scanning. + +LANG=En_US +export LANG + +if [ $# -ne 0 -a $# -ne 2 ] +then + echo usage: grabscan '[ -l \<logical name of scanner\> ]' >&2 + exit 1 +fi + +if [ $# -eq 2 ] +then + scan_lname=$2 +else + scan_lname=scan0 +fi + +scan_type=`get_scanner -t` + +if [ -z "$scan_type" ] +then + echo grabscan: no scanner found. >&2 + echo grabscan: terminating execution. >&2 + exit 1 +fi + +case $scan_type in + ricoh_is410 | ibm_2456) + exec ricoh_is410_grabscan $scan_lname + ;; + + fujitsu_m3069g) + exec fujitsu_m3096g_grabscan $scan_lname + ;; + + ricoh_fs1) + exec ricoh_fs1_grabscan $scan_lname + ;; + + sharp_jx600) + exec sharp_jx600_grabscan $scan_lname + ;; + + ricoh_is50) + exec ricoh_is50_grabscan $scan_lname + ;; + + umax_uc630 | umax_ug630) + exec umax_uc630_grabscan $scan_lname + ;; + + hp_scanjet_IIc) + exec hp_scanjet_IIc_grabscan $scan_lname + ;; + + *) + echo grabscan: an unsupported scanner type was specified. >&2 + echo grabscan: terminating execution. >&2 + exit 1 + ;; +esac diff --git a/usr.sbin/ssio/hp_scanjet_IIc_grabscan.sh b/usr.sbin/ssio/hp_scanjet_IIc_grabscan.sh new file mode 100644 index 00000000000..30f56c54012 --- /dev/null +++ b/usr.sbin/ssio/hp_scanjet_IIc_grabscan.sh @@ -0,0 +1,80 @@ +#!/bin/sh +# + +# $Id: hp_scanjet_IIc_grabscan.sh,v 1.1 1997/03/11 03:23:14 kstailey Exp $ +# +# Copyright (c) 1996 Kenneth Stailey +# 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 for the NetBSD Project +# by Kenneth Stailey +# 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. +# + +# hp_scanjet_IIc_grabscan: +# a wrapper for making PNM rawbits files from the HP ScanJet IIc data +# + +if [ $# -gt 1 ] +then + echo usage: $0 [\<logical name of scanner\>] 1>&2 + exit -1 +fi + +if [ $# = 0 ] +then + scan_lname=scan0 +else + scan_lname=$1 +fi + +image_mode=`get_scanner -l $scan_lname | awk '/image_mode/ { print $3 }'` + +set `get_scanner -p -l $scan_lname` +width=$1 +height=$2 + +case $image_mode in + color) + echo P6 + echo $width $height + echo 255 + dd if=/dev/$scan_lname bs=256k + ;; + + grayscale) + echo P5 + echo $width $height + echo 255 + dd if=/dev/$scan_lname bs=256k + ;; + + binary_monochrome) + echo P4 + echo $width $height + dd if=/dev/$scan_lname bs=256k + ;; +esac diff --git a/usr.sbin/ssio/reset_scanner.1 b/usr.sbin/ssio/reset_scanner.1 new file mode 100644 index 00000000000..afa873b7f05 --- /dev/null +++ b/usr.sbin/ssio/reset_scanner.1 @@ -0,0 +1,33 @@ +.\" $Id: reset_scanner.1,v 1.1 1997/03/11 03:23:14 kstailey Exp $ +.\" PINT Pint Is Not TWAIN - common scanner driver interface for UN*X +.\" Copyright (C) 1994 Kenneth Stailey kstailey@leidecker.gsfc.nasa.gov +.\" +.\" This program is free software; you can redistribute it and/or modify +.\" it under the terms of the GNU General Public License as published by +.\" the Free Software Foundation; either version 2 of the License, or +.\" (at your option) any later version. +.\" +.\" This program is distributed in the hope that it will be useful, +.\" but WITHOUT ANY WARRANTY; without even the implied warranty of +.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +.\" GNU General Public License for more details. +.\" +.\" You should have received a copy of the GNU General Public License +.\" along with this program; if not, write to the Free Software +.\" Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +.\" +.TH reset-scanner 1 "25 October 1994" +.SH NAME +reset-scanner - clear error conditions on the scanner +.SH SYNOPSIS +.B reset-scanner +.RI [ -l <logical-name-of-scanner-to-use>] +.SH DESCRIPTION +If the scanner gets stuck and the error lights go on and you wish that +you could push the reset button on it but there isn't one, run this (as +the super-user) instead and it will send a Bus Device Reset (BDR) to the +scanner. +.SH AUTHOR +.nf +Kenneth Stailey (kstailey@gnu.ai.mit.edu, kstailey@leidecker.gsfc.nasa.gov) +.fi diff --git a/usr.sbin/ssio/reset_scanner.c b/usr.sbin/ssio/reset_scanner.c new file mode 100644 index 00000000000..4f814126873 --- /dev/null +++ b/usr.sbin/ssio/reset_scanner.c @@ -0,0 +1,91 @@ +static char *rcs_id = "$Id: reset_scanner.c,v 1.1 1997/03/11 03:23:15 kstailey Exp $"; +#ifdef _IBMR2 +/* + * PINT Pint Is Not TWAIN - common scanner driver interface for UN*X + * Copyright (C) 1994 Kenneth Stailey kstailey@leidecker.gsfc.nasa.gov + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +/* + * reset_scanner.c: clear scanner of error conditions + * Ricoh IS-50's and IS-410's don't have reset buttons, but could use them. + */ + +#include <stdio.h> +#include <fcntl.h> +#include <sys/scsi.h> + +void +usage(char *prog_name) +{ + fprintf(stderr, "usage: %s [-l <logical name>]\n", prog_name); + exit(-1); +} + +main(int argc, char *argv[]) +{ + int sfd; + char *logical_name = "scan0"; + char device[255]; + char cmd[255]; + + int fast = FALSE; + + int c; + extern int optind; + extern char *optarg; + + while ((c = getopt(argc, argv, "fl:")) != EOF) { + switch (c) { + case 'l': + logical_name = optarg; + break; + + case 'f': + fast = TRUE; + break; + + case '?': + usage(argv[0]); + break; + } + } + + strcpy(device, "/dev/"); + strcat(device, logical_name); + + if ((sfd = openx(device, O_RDONLY, 0, SC_FORCED_OPEN)) < 0) { + fprintf(stderr, "openx of %s failed: ", device); + perror(""); + exit(-1); + } + + close(sfd); + + if (fast) + exit(0); + + sprintf(cmd, "rmdev -l %s", logical_name); + system(cmd); + sprintf(cmd, "mkdev -l %s", logical_name); + system(cmd); +} +#else +main() +{ + printf("this only works for AIX 3.2\n"); +} +#endif diff --git a/usr.sbin/ssio/ricoh_fs1_grabscan.sh b/usr.sbin/ssio/ricoh_fs1_grabscan.sh new file mode 100644 index 00000000000..b590cb1a484 --- /dev/null +++ b/usr.sbin/ssio/ricoh_fs1_grabscan.sh @@ -0,0 +1,63 @@ +#!/bin/sh + +# $Id: ricoh_fs1_grabscan.sh,v 1.1 1997/03/11 03:23:15 kstailey Exp $ +# +# Copyright (c) 1996 Kenneth Stailey +# 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 for the NetBSD Project +# by Kenneth Stailey +# 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. +# + +# ricoh_fs1_grabscan: +# a wrapper for making PPM rawbits files from the Ricoh FS1 scanner data +# + +if [ $# -gt 1 ] +then + echo usage: $0 [\<logical name of scanner\>] 1>&2 + exit -1 +fi + +if [ $# = 0 ] +then + scan_lname=scan0 +else + scan_lname=$1 +fi + +image_mode=`get_scanner -l $scan_lname | awk '/image_mode/ { print $3 }'` + +set `get_scanner -p -l $scan_lname` +width=$1 +height=$2 + +dd if=/dev/$scan_lname of=/tmp/fs1_grabscan.$$ bs=256k + +fs1toppm $width $height /tmp/fs1_grabscan.$$ + +rm /tmp/fs1_grabscan.$$ diff --git a/usr.sbin/ssio/ricoh_is410_grabscan.sh b/usr.sbin/ssio/ricoh_is410_grabscan.sh new file mode 100644 index 00000000000..b47ab9a9bef --- /dev/null +++ b/usr.sbin/ssio/ricoh_is410_grabscan.sh @@ -0,0 +1,70 @@ +#!/bin/sh + +# $Id: ricoh_is410_grabscan.sh,v 1.1 1997/03/11 03:23:16 kstailey Exp $ +# +# Copyright (c) 1996 Kenneth Stailey +# 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 for the NetBSD Project +# by Kenneth Stailey +# 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. +# + +# +# ricoh_is410_grabscan: +# a wrapper for making PNM rawbits files from the Ricoh IS410 scanner data +# + +if [ $# -gt 1 ] +then + echo usage: $0 [\<logical name of scanner\>] 1>&2 + exit -1 +fi + +if [ $# = 0 ] +then + scan_lname=scan0 +else + scan_lname=$1 +fi + +image_mode=`get_scanner -l $scan_lname | awk '/image_mode/ { print $3 }'` + +set `get_scanner -p -l $scan_lname` +width=$1 +height=$2 + +if [ $image_mode = grayscale ] +then + echo P5 + echo $width $height + echo 255 + dd if=/dev/$scan_lname bs=256k +else # monochrome + echo P4 + echo $width $height + dd if=/dev/$scan_lname bs=256k +fi diff --git a/usr.sbin/ssio/ricoh_is50_grabscan.sh b/usr.sbin/ssio/ricoh_is50_grabscan.sh new file mode 100644 index 00000000000..7e9c4ac45fa --- /dev/null +++ b/usr.sbin/ssio/ricoh_is50_grabscan.sh @@ -0,0 +1,70 @@ +#!/bin/sh + +# $Id: ricoh_is50_grabscan.sh,v 1.1 1997/03/11 03:23:16 kstailey Exp $ +# +# Copyright (c) 1996 Kenneth Stailey +# 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 for the NetBSD Project +# by Kenneth Stailey +# 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. +# + +# +# ricoh_is50_grabscan: +# a wrapper for making PNM rawbits files from the Ricoh IS50 scanner data +# + +if [ $# -gt 1 ] +then + echo usage: $0 [\<logical name of scanner\>] 1>&2 + exit -1 +fi + +if [ $# = 0 ] +then + scan_lname=scan0 +else + scan_lname=$1 +fi + +image_mode=`get_scanner -l $scan_lname | awk '/image_mode/ { print $3 }'` + +set `get_scanner -p -l $scan_lname` +width=$1 +height=$2 + +if [ $image_mode = grayscale ] +then + echo P5 + echo $width $height + echo 255 + dd if=/dev/$scan_lname bs=256k +else # monochrome + echo P4 + echo $width $height + dd if=/dev/$scan_lname bs=256k +fi diff --git a/usr.sbin/ssio/set_scanner.1 b/usr.sbin/ssio/set_scanner.1 new file mode 100644 index 00000000000..5d50b71b8b0 --- /dev/null +++ b/usr.sbin/ssio/set_scanner.1 @@ -0,0 +1,130 @@ +.\" $Id: set_scanner.1,v 1.1 1997/03/11 03:23:16 kstailey Exp $ +.\" +.\" Copyright (c) 1996 Kenneth Stailey +.\" 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 for the NetBSD Project +.\" by Kenneth Stailey +.\" 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 set_scanner 1 "25 October 1994" +.SH NAME +set_scanner - change the parameter settings for the scanner +.SH SYNOPSIS +.B set_scanner +.RI [ -w width ] +.RI [ -h height] +.RI [ -x x_origin ] +.RI [ -y y_origin ] +.RI [ -r resolution ] +.RI [ -l logical_name ] +.RI [ -i image_mode ] +.RI [ \-b brightness ] +.RI [ -c contrast ] +.RI [ -d ] +.SH DESCRIPTION +Changes one or more of the scanner's attributes. Changes are stored +in the ODM if you use the -d flag (for setting default values), but +leaving off the -d is faster. +.SH FLAGS +.B \-w +.I width. +Sets the width of the scanner active area to the given value in inches. +Decimal fractions of inches are acceptable for this and all other size +values. +.PP +.B \-h +.I height. +Sets the height of the scanner active area to the given value in inches. +.PP +.B \-x +.I x_origin. +Sets the upper left hand corner x coordinate of the scanner active area to +the given value in inches. +.PP +.B \-y +.I y_origin. +Sets the upper left hand corner y coordinate of the scanner active area to +the given value in inches. +.PP +.B \-r +.I resolution. +Sets the resolution to the given value in dots-per-inch. To see +acceptable values for +.I resolution +use "lsattr -R -l scan0 -a x_resolution" +.PP +.B \-l +.I logical name of scanner. +Specifies what scanner to use. The default is "scan0" +.PP +.B \-i +.I image mode. +Change the type of image data sent by the scanner. The flag is followed +by a one-letter code representing the image mode. Use "m" for binary +monochrome (solid black or white), "d" for dithered monochrome (halftoned), +"g" for grayscale, "c" for color, "R" for red only, "G" for green only or +"B" for blue only. Not all scanners support all formats. +.PP +.B \-b +.I brightness +Set the hardware brightness control inside the scanner, if any. This flag +is followed by a decimal integer that specifies how bright the image is to be. +To see acceptable values for +.I brightness +use the command "lsattr -R -l scan0 -a brightness". +.PP +.B \-c +.I contrast +Set the hardware contrast control inside the scanner, if any. This flag +is followed by a decimal integer that specifies the level of contrast used. +To see acceptable values for +.I contrast +use the command "lsattr -R -l scan0 -a contrast". +.I +.PP +.B \-d +Set the defaults. Scanner settings will be remembered even after the system +reboots. +.B set_scanner +will use "chdev" to alter the ODM instead of the ioctl(2) system call on the +device special file. +.SH EXAMPLES +.PP +the command: +.PP +set_scanner -w 5.5 -h 3.75 -r 300 +.PP +will set the active area of the scanner to 5 1/2" x 3 3/4" at 300 dots-per-inch +resolution +.SH "SEE ALSO" +get_scanner(1) +.SH BUGS +Probably should support Metric measurement units too. +.SH AUTHOR +.nf +Kenneth Stailey (kstailey@gnu.ai.mit.edu, kstailey@leidecker.gsfc.nasa.gov) +.fi diff --git a/usr.sbin/ssio/set_scanner.c b/usr.sbin/ssio/set_scanner.c new file mode 100644 index 00000000000..48f419cf3cf --- /dev/null +++ b/usr.sbin/ssio/set_scanner.c @@ -0,0 +1,339 @@ +static char *rcs_id = "$Id: set_scanner.c,v 1.1 1997/03/11 03:23:17 kstailey Exp $"; +/* + * Copyright (c) 1995 Kenneth Stailey + * 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 for the NetBSD Project + * by Kenneth Stailey + * 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. + */ + +/* + * set-scanner.c: + * + * Set the scan area in decimal fractions of inches. + * If the defaults are to be changed use system("chdev...") + * otherwise use ioctl() + */ + +#include <stdlib.h> +#include <stdio.h> +#include <string.h> +#include <fcntl.h> +#ifdef __NetBSD__ +#include <sys/ioctl.h> +#endif +#include <sys/scanio.h> + +#define UNINITIALIZED -10 + +int inches_to_1200th(char *numeral); +void usage(char *prog_name); +int xlate_image_code(char *); +int ipow10(int); +int scanner_type(char *); + +main(int argc, char *argv[]) +{ + int width, height; + int x_origin, y_origin; + int brightness, contrast; + int resolution, image_mode; + + int defaults = FALSE; + + char *logical_name = "scan0"; + char device_special[255]; + + int c; /* for command line parsing */ + extern int optind; /* for getopt() */ + extern char *optarg; /* for getopt() */ + + char command[256]; + struct scan_io s_io; + + int s_fd; + + brightness = contrast = resolution = + width = height = x_origin = y_origin = + image_mode = + UNINITIALIZED; + + while ((c = getopt(argc, argv, "w:h:x:y:l:b:c:r:i:d")) != EOF) { + switch (c) { + case 'w': + width = inches_to_1200th(optarg); + break; + case 'h': + height = inches_to_1200th(optarg); + break; + case 'x': + x_origin = inches_to_1200th(optarg); + break; + case 'y': + y_origin = inches_to_1200th(optarg); + break; + case 'l': + logical_name = optarg; + break; + case 'd': + defaults = TRUE; /* use chdev to set defaults */ + break; + case 'b': + brightness = atol(optarg); + break; + case 'c': + contrast = atol(optarg); + break; + case 'r': + resolution = atol(optarg); + break; + case 'i': + image_mode = xlate_image_code(optarg); + if (image_mode == -1) { + usage(argv[0]); + } + break; + case '?': + usage(argv[0]); + } + } + +#ifdef __IBMR2 + if (defaults) { + sprintf(command, "chdev -l %s", logical_name); + + if (width != UNINITIALIZED) + sprintf(command, "%s -a window_width=%d", command, width); + + if (height != UNINITIALIZED) + sprintf(command, "%s -a window_length=%d", command, height); + + if (x_origin != UNINITIALIZED) + sprintf(command, "%s -a x_origin=%d", command, x_origin); + + if (y_origin != UNINITIALIZED) + sprintf(command, "%s -a y_origin=%d", command, y_origin); + + if (brightness != UNINITIALIZED) + sprintf(command, "%s -a brightness=%d", command, brightness); + + /* note that the FUJITSU doesn't support contrast via the ODM */ + if (contrast != UNINITIALIZED && scanner_type(logical_name) != FUJITSU) + sprintf(command, "%s -a contrast=%d", command, contrast); + + if (resolution != UNINITIALIZED) { + sprintf(command, "%s -a x_resolution=%d", command, resolution); + sprintf(command, "%s -a y_resolution=%d", command, resolution); + } + + if (image_mode != UNINITIALIZED) { + sprintf(command, "%s -a image_mode=", command); + switch (image_mode) { + case SIM_BINARY_MONOCHROME: + sprintf(command, "%smonochrome ", command); + break; + case SIM_DITHERED_MONOCHROME: + sprintf(command, "%sdithered ", command); + break; + case SIM_GRAYSCALE: + sprintf(command, "%sgrayscale ", command); + break; + case SIM_COLOR: + sprintf(command, "%scolor ", command); + break; + case SIM_RED: + sprintf(command, "%sred ", command); + break; + case SIM_GREEN: + sprintf(command, "%sgreen ", command); + break; + case SIM_BLUE: + sprintf(command, "%sblue ", command); + break; + } + } + + system(command); + + } else { /* use ioctl() instead of chdev */ +#endif + sprintf(device_special, "/dev/%s", logical_name); + if ((s_fd = open(device_special, O_RDONLY)) < 0) { + fprintf(stderr, "open of %s failed: ", device_special); + perror(""); + exit(-1); + } + + if (ioctl(s_fd, SCIOCGET, &s_io) < 0) { + perror("ioctl SCIOCGET"); + exit(-1); + } + + if (width != UNINITIALIZED) + s_io.scan_width = width; + + if (height != UNINITIALIZED) + s_io.scan_height = height; + + if (x_origin != UNINITIALIZED) + s_io.scan_x_origin = x_origin; + + if (y_origin != UNINITIALIZED) + s_io.scan_y_origin = y_origin; + + if (brightness != UNINITIALIZED) + s_io.scan_brightness = brightness; + + if (contrast != UNINITIALIZED) + s_io.scan_contrast = contrast; + + if (resolution != UNINITIALIZED) { + s_io.scan_x_resolution = resolution; + s_io.scan_y_resolution = resolution; + } + + if (image_mode != UNINITIALIZED) + s_io.scan_image_mode = image_mode; + + if (ioctl(s_fd, SCIOCSET, &s_io) < 0) { + perror("ioctl SCIOCSET"); + exit(-1); + } +#ifdef __IBMR2 + } +#endif + + exit(0); +} + +/* + * Convert a numeral representing inches into a number representing + * 1/1200ths of an inch. If multipling the input by 1200 still leaves + * a fractional part then abort with an error message. + * + * Note that "numeral" here means string of digits with optional decimal point + */ +int +inches_to_1200th(char *numeral) +{ + FILE *bc; + char result[50]; + char *p; + + /* test to see if "numeral" really is a numeral */ + p = numeral; + while (*p) { + if (!isdigit(*p) && *p != '.') + usage("set_scanner"); + ++p; + } + + /* test to see if it is a multiple of 1/1200 */ + + if ((bc = fopen("/tmp/set_scanner.bc_work", "w")) == NULL) { + perror("creating temp file '/tmp/set_scanner.bc_work'"); + exit(-1); + } + fprintf(bc, "%s * 1200\nquit\n", numeral); + fclose(bc); + + if ((bc = popen("bc -l /tmp/set_scanner.bc_work", "r")) == NULL) { + perror("running bc"); + exit(-1); + } + fgets(result, 50, bc); + result[strlen(result) - 1] = '\0'; /* eat newline from fgets */ + pclose(bc); + unlink("/tmp/set_scanner.bc_work"); + + if ((p = strchr(result, '.')) != NULL) { + ++p; + while (*p) + if (*p++ != '0') { + fprintf(stderr, "set_scanner: please do not use fractions with a "); + fprintf(stderr, "granularity less than\nset_scanner: one "); + fprintf(stderr, "twelve-thousandths of an inch\n"); + exit(-1); + } + } + + return (atoi(result)); +} + +void +usage(char *prog_name) +{ + fprintf(stderr, + "usage: %s [-w width] [-h height] [-x x_origin] [-y y_origin]\n[-r resolution] [-l logical name] [-i image mode] [-d (for setting defaults)]\n", + prog_name); + exit(-1); +} + +int xlate_image_code(char *image_code) +{ + switch (image_code[0]) { + case 'm': + return (SIM_BINARY_MONOCHROME); + case 'd': + return (SIM_DITHERED_MONOCHROME); + case 'g': + return (SIM_GRAYSCALE); + case 'c': + return (SIM_COLOR); + case 'R': + return (SIM_RED); + case 'G': + return (SIM_GREEN); + case 'B': + return (SIM_BLUE); + default: + return (-1); + } +} + +int scanner_type(char *lname) +{ + char special_file[256]; + int scan_fd; + struct scan_io sp; + + sprintf(special_file, "/dev/%s", lname); + + if ((scan_fd = open(special_file, O_RDONLY)) < 0) { + perror("set_scanner: can't open scanner--"); + exit(1); + } + + if (ioctl(scan_fd, SCIOCGET, &sp) < 0) { + perror("set_scanner: can't get parameters from scanner--"); + exit(1); + } + + close(scan_fd); + + return ((int)sp.scan_scanner_type); +} diff --git a/usr.sbin/ssio/sharp_jx600_grabscan.sh b/usr.sbin/ssio/sharp_jx600_grabscan.sh new file mode 100644 index 00000000000..b0c7a847311 --- /dev/null +++ b/usr.sbin/ssio/sharp_jx600_grabscan.sh @@ -0,0 +1,80 @@ +#!/bin/sh + +# $Id: sharp_jx600_grabscan.sh,v 1.1 1997/03/11 03:23:17 kstailey Exp $ +# +# Copyright (c) 1996 Kenneth Stailey +# 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 for the NetBSD Project +# by Kenneth Stailey +# 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. +# + +# +# sharp_jx600_grabscan: +# a wrapper for making PNM rawbits files from the Sharp JX600 data +# + +if [ $# -gt 1 ] +then + echo usage: $0 [\<logical name of scanner\>] 1>&2 + exit -1 +fi + +if [ $# = 0 ] +then + scan_lname=scan0 +else + scan_lname=$1 +fi + +image_mode=`get_scanner -l $scan_lname | awk '/image_mode/ { print $3 }'` + +set `get_scanner -p -l $scan_lname` +width=$1 +height=$2 + +case $image_mode in + color) + echo P6 + echo $width $height + echo 255 + dd if=/dev/$scan_lname bs=32k + ;; + + grayscale) + echo P5 + echo $width $height + echo 255 + dd if=/dev/$scan_lname bs=32k + ;; + + binary_monochrome) + (echo P4 + echo $width $height + dd if=/dev/$scan_lname bs=32k) | pnminvert + ;; +esac diff --git a/usr.sbin/ssio/umax_uc630_grabscan.sh b/usr.sbin/ssio/umax_uc630_grabscan.sh new file mode 100644 index 00000000000..a3d99a16dd6 --- /dev/null +++ b/usr.sbin/ssio/umax_uc630_grabscan.sh @@ -0,0 +1,117 @@ +#!/bin/sh + +# $Id: umax_uc630_grabscan.sh,v 1.1 1997/03/11 03:23:18 kstailey Exp $ +# +# Copyright (c) 1996 Kenneth Stailey +# 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 for the NetBSD Project +# by Kenneth Stailey +# 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. +# + +# +# umax_uc630_grabscan: +# a wrapper for making PNM rawbits files from the UMAX UC630 scanner data +# + +if [ $# -gt 1 ] +then + echo usage: $0 [\<logical name of scanner\>] 1>&2 + exit -1 +fi + +if [ $# = 0 ] +then + scan_lname=scan0 +else + scan_lname=$1 +fi + +image_mode=`get_scanner -l $scan_lname | awk '/image_mode/ { print $3 }'` + +set `get_scanner -p -l $scan_lname` +width=$1 +height=$2 + +case $image_mode in + +grayscale) + echo P5 + echo $width $height + echo 255 + dd if=/dev/$scan_lname bs=256k +;; + +binary_monochrome|dithered_monochrome) + echo P4 + echo $width $height + dd if=/dev/$scan_lname bs=256k +;; + +red|green|blue) + + save_modes=`get_scanner -q` + + echo grabbing colors: >&2 + +# red pass... + echo red... >&2 + set_scanner -i R >/dev/null + (echo P5 + echo $width $height + echo 255 + dd if=/dev/scan0 bs=256k) > /tmp/grabscan.$$.red + +# green pass... + echo green... >&2 + set_scanner -i G >/dev/null + (echo P5 + echo $width $height + echo 255 + dd if=/dev/scan0 bs=256k) > /tmp/grabscan.$$.green + +# blue pass... + echo blue... >&2 + set_scanner -i B >/dev/null + (echo P5 + echo $width $height + echo 255 + dd if=/dev/scan0 bs=256k) > /tmp/grabscan.$$.blue + + echo mixing colors together... >&2 + rgb3toppm /tmp/grabscan.$$.red /tmp/grabscan.$$.green /tmp/grabscan.$$.blue + + rm /tmp/grabscan.$$.red /tmp/grabscan.$$.green /tmp/grabscan.$$.blue + +# restore scanner + set_scanner $save_modes >/dev/null + +;; + +esac + +echo done >&2 diff --git a/usr.sbin/ssio/use_adf.1 b/usr.sbin/ssio/use_adf.1 new file mode 100644 index 00000000000..ee1d091d23e --- /dev/null +++ b/usr.sbin/ssio/use_adf.1 @@ -0,0 +1,49 @@ +.\" $Id: use_adf.1,v 1.1 1997/03/11 03:23:18 kstailey Exp $ +.\" +.\" Copyright (c) 1996 Kenneth Stailey +.\" 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 for the NetBSD Project +.\" by Kenneth Stailey +.\" 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 use_adf 1 "25 October 1994" +.SH NAME +use_adf - set up the scanner for reading a page from the ADF +.SH SYNOPSIS +.B use_adf +.RI [ -l <logical-name-of-scanner-to-use>] +.SH DESCRIPTION +When you run this program on a scanner with paper in the Automatic +Document Feeder (ADF), the next time you do a read the ADF will be the +paper source. This program will also eject paper sitting in the ADF. +.SH NOTE +The Ricoh scanner must have the "use_adf" attribute set to "yes" in +order to work the ADF. This is not true for the Fujitsu. +.SH AUTHOR +.nf +Kenneth Stailey (kstailey@gnu.ai.mit.edu, kstailey@leidecker.gsfc.nasa.gov) +.fi diff --git a/usr.sbin/ssio/use_adf.c b/usr.sbin/ssio/use_adf.c new file mode 100644 index 00000000000..fca15923eb9 --- /dev/null +++ b/usr.sbin/ssio/use_adf.c @@ -0,0 +1,108 @@ +static char *rcs_id = "$Id: use_adf.c,v 1.1 1997/03/11 03:23:18 kstailey Exp $"; +/* + * Copyright (c) 1995 Kenneth Stailey + * 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 for the NetBSD Project + * by Kenneth Stailey + * 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. + */ + +/* + * use_adf.c: make the scanner use the ADF as the next paper source + */ + +#include <sys/types.h> +#ifdef __NetBSD__ +# include <sys/ioctl.h> +#endif +#include <sys/scanio.h> + +#include <errno.h> +#include <stdio.h> +#include <stdlib.h> +#include <fcntl.h> + + +void +usage(char *prog_name) +{ + fprintf(stderr, "usage: %s [-l <logical name>]\n", prog_name); + exit(-1); +} + +main(int argc, char *argv[]) +{ + int sfd; + char *logical_name = "scan0"; + char device[255]; + + int c; + extern int optind; + extern char *optarg; + + extern int errno; + + while ((c = getopt(argc, argv, "l:")) != EOF) { + switch (c) { + case 'l': + logical_name = optarg; + break; + + case '?': + usage(argv[0]); + break; + } + } + + strcpy(device, "/dev/"); + strcat(device, logical_name); + + if ((sfd = open(device, O_RDONLY)) < 0) { + fprintf(stderr, "open of %s failed: ", device); + perror(""); + exit(errno); + } + + if (ioctl(sfd, SCIOC_USE_ADF, NULL) < 0) { + int sv_errno = errno; + + switch (errno) { + case ENOTTY: + fprintf(stderr, "use_adf: scanner does not support ADF\n"); + break; + case EIO: + fprintf(stderr, "use_adf: ADF probably empty or jammed\n"); + break; + default: + perror("use_adf: ioctl SCAN_USE_ADF failed"); + } + exit(sv_errno); + } + + close(sfd); + exit(0); +} |