sane-project-website/old-archive/2000-01/0130.html

324 wiersze
8.9 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
"http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
<TITLE>sane-devel: Re: forwarded message from Karl Heinz Kremer</TITLE>
<META NAME="Author" CONTENT="Petter Reinholdtsen (pere@hungry.com)">
<META NAME="Subject" CONTENT="Re: forwarded message from Karl Heinz Kremer">
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000">
<H1>Re: forwarded message from Karl Heinz Kremer</H1>
<!-- received="Mon Jan 17 16:47:53 2000" -->
<!-- isoreceived="20000118004753" -->
<!-- sent="Tue, 18 Jan 2000 08:51:14 +0800" -->
<!-- isosent="20000118005114" -->
<!-- name="Petter Reinholdtsen" -->
<!-- email="pere@hungry.com" -->
<!-- subject="Re: forwarded message from Karl Heinz Kremer" -->
<!-- id="200001180051.IAA29038@minerva.cc.uit.no" -->
<!-- inreplyto="forwarded message from Karl Heinz Kremer" -->
<STRONG>From:</STRONG> Petter Reinholdtsen (<A HREF="mailto:pere@hungry.com?Subject=Re:%20forwarded%20message%20from%20Karl%20Heinz%20Kremer&In-Reply-To=&lt;200001180051.IAA29038@minerva.cc.uit.no&gt;"><EM>pere@hungry.com</EM></A>)<BR>
<STRONG>Date:</STRONG> Mon Jan 17 2000 - 16:51:14 PST
<P>
<!-- next="start" -->
<LI><STRONG>Next message:</STRONG> <A HREF="0131.html">Petter Reinholdtsen: "Libtool ltdl patch"</A>
<UL>
<LI><STRONG>Previous message:</STRONG> <A HREF="0129.html">Petter Reinholdtsen: "Re: A bug in the backend? (microtek2)"</A>
<LI><STRONG>Maybe in reply to:</STRONG> <A HREF="0026.html">David Mosberger-Tang: "forwarded message from Karl Heinz Kremer"</A>
<!-- nextthread="start" -->
<LI><STRONG>Next in thread:</STRONG> <A HREF="0238.html">abel deuring: "Re: forwarded message from Karl Heinz Kremer"</A>
<LI><STRONG>Reply:</STRONG> <A HREF="0238.html">abel deuring: "Re: forwarded message from Karl Heinz Kremer"</A>
<!-- reply="end" -->
<LI><STRONG>Messages sorted by:</STRONG>
<A HREF="date.html#130">[ date ]</A>
<A HREF="index.html#130">[ thread ]</A>
<A HREF="subject.html#130">[ subject ]</A>
<A HREF="author.html#130">[ author ]</A>
</UL>
<HR NOSHADE><P>
<!-- body="start" -->
<P>
[David Mosberger-Tang]
<BR>
<EM>&gt; Could someone consider this for inclusion in the CVS tree?
</EM><BR>
<P>I had a look at it, reformatted it to be consistent with current style
<BR>
and rewrote the for loop to make sure non-batch mode still works.
<BR>
Could someone please verify that the new patch work? I don't have a
<BR>
scanner to test with. :-(
<BR>
<P>I guess the batch mode should have a way to limit the number of scans.
<BR>
If it is used on the video4linux backend, the flow of images will
<BR>
never stop... :-)
<BR>
<P>Index: frontend/scanimage.c
<BR>
===================================================================
<BR>
RCS file: /cvsroot/external/sane/frontend/scanimage.c,v
<BR>
retrieving revision 1.1.1.1
<BR>
diff -u -r1.1.1.1 scanimage.c
<BR>
--- scanimage.c 1999/08/09 18:05:40 1.1.1.1
<BR>
+++ scanimage.c 2000/01/18 00:48:07
<BR>
@@ -61,7 +61,8 @@
<BR>
&nbsp;&nbsp;&nbsp;{&quot;verbose&quot;, no_argument, NULL, 'v'},
<BR>
&nbsp;&nbsp;&nbsp;{&quot;test&quot;, no_argument, NULL, 'T'},
<BR>
&nbsp;&nbsp;&nbsp;{&quot;version&quot;, no_argument, NULL, 'V'},
<BR>
- {0, }
<BR>
+ {&quot;batch&quot;, optional_argument, NULL, 'b'},
<BR>
+ {0, 0, NULL, 0}
<BR>
&nbsp;};
<BR>
&nbsp;
<BR>
&nbsp;#define BASE_OPTSTRING &quot;d:hLvVT&quot;
<BR>
@@ -749,7 +750,7 @@
<BR>
&nbsp;&nbsp;&nbsp;return image-&gt;data;
<BR>
&nbsp;}
<BR>
&nbsp;
<BR>
-static void
<BR>
+static SANE_Status
<BR>
&nbsp;scan_it (void)
<BR>
&nbsp;{
<BR>
&nbsp;&nbsp;&nbsp;int i, len, first_frame = 1, offset = 0, must_buffer = 0;
<BR>
@@ -870,7 +871,7 @@
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;fprintf (stderr, &quot;%s: sane_read: %s\n&quot;,
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;prog_name, sane_strstatus (status));
<BR>
- return;
<BR>
+ return status;
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break;
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
<BR>
@@ -938,6 +939,8 @@
<BR>
&nbsp;&nbsp;&nbsp;sane_cancel (device);
<BR>
&nbsp;&nbsp;&nbsp;if (image.data)
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;free (image.data);
<BR>
+
<BR>
+ return status;
<BR>
&nbsp;}
<BR>
&nbsp;
<BR>
&nbsp;#define clean_buffer(buf,size) memset ((buf), 0x23, size)
<BR>
@@ -1049,6 +1052,8 @@
<BR>
&nbsp;&nbsp;&nbsp;const SANE_Device ** device_list;
<BR>
&nbsp;&nbsp;&nbsp;SANE_Int num_dev_options = 0;
<BR>
&nbsp;&nbsp;&nbsp;const char * devname = 0;
<BR>
+ const char * format = 0;
<BR>
+ int batch = 0;
<BR>
&nbsp;&nbsp;&nbsp;SANE_Status status;
<BR>
&nbsp;&nbsp;&nbsp;char *full_optstring;
<BR>
&nbsp;
<BR>
@@ -1076,6 +1081,7 @@
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break; /* may be an option that we'll parse later on */
<BR>
&nbsp;
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;case 'd': devname = optarg; break;
<BR>
+ case 'b': batch = 1; format = optarg; break;
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;case 'h': help = 1; break;
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;case 'v': ++verbose; break;
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;case 'T': test= 1; break;
<BR>
@@ -1115,6 +1121,7 @@
<BR>
&nbsp;Start image acquisition on a scanner device and write PNM image data to\n\
<BR>
&nbsp;standard output.\n\
<BR>
&nbsp;\n\
<BR>
+-b, --batch=FORMAT working in batch mode\n\
<BR>
&nbsp;-d, --device-name=DEVICE use a given scanner device\n\
<BR>
&nbsp;-h, --help display this help message and exit\n\
<BR>
&nbsp;-L, --list-devices show available scanner devices\n\
<BR>
@@ -1337,11 +1344,43 @@
<BR>
&nbsp;&nbsp;&nbsp;signal (SIGTERM, sighandler);
<BR>
&nbsp;
<BR>
&nbsp;&nbsp;&nbsp;if (test == 0)
<BR>
- scan_it ();
<BR>
+ {
<BR>
+ int n = 1;
<BR>
+
<BR>
+ if (batch &amp;&amp; NULL == format)
<BR>
+ format = &quot;out%d.pnm&quot;;
<BR>
+
<BR>
+ do
<BR>
+ {
<BR>
+ char path [ 1024];
<BR>
+ sprintf (path, format, n); /* love --(C++) */
<BR>
+
<BR>
+ if (batch &amp;&amp; NULL == freopen (path, &quot;w&quot;, stdout) )
<BR>
+ {
<BR>
+ fprintf (stderr, &quot;cannot open %s\n&quot;, path);
<BR>
+ return SANE_STATUS_ACCESS_DENIED;
<BR>
+ }
<BR>
+
<BR>
+ status = scan_it ();
<BR>
+ if (batch)
<BR>
+ fprintf( stderr, &quot;status = %d\n&quot;, status);
<BR>
+
<BR>
+ switch (status)
<BR>
+ {
<BR>
+ case SANE_STATUS_EOF:
<BR>
+ status = SANE_STATUS_GOOD;
<BR>
+ break;
<BR>
+ default:
<BR>
+ break;
<BR>
+ } /* switch */
<BR>
+ n++;
<BR>
+ }
<BR>
+ while (batch &amp;&amp; SANE_STATUS_GOOD == status);
<BR>
+ }
<BR>
&nbsp;&nbsp;&nbsp;else
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;test_it ();
<BR>
&nbsp;
<BR>
&nbsp;&nbsp;&nbsp;sane_close (device);
<BR>
&nbsp;
<BR>
- return 0;
<BR>
+ return status;
<BR>
&nbsp;}
<BR>
<PRE>
--
##&gt; Petter Reinholdtsen &lt;## | <A HREF="mailto:pere@td.org.uit.no?Subject=Re:%20forwarded%20message%20from%20Karl%20Heinz%20Kremer&In-Reply-To=&lt;200001180051.IAA29038@minerva.cc.uit.no&gt;">pere@td.org.uit.no</A>
<P>--
Source code, list archive, and docs: <A HREF="http://www.mostang.com/sane/">http://www.mostang.com/sane/</A>
To unsubscribe: echo unsubscribe sane-devel | mail <A HREF="mailto:majordomo@mostang.com?Subject=Re:%20forwarded%20message%20from%20Karl%20Heinz%20Kremer&In-Reply-To=&lt;200001180051.IAA29038@minerva.cc.uit.no&gt;">majordomo@mostang.com</A>
</PRE>
<P><!-- body="end" -->
<HR NOSHADE>
<UL>
<!-- next="start" -->
<LI><STRONG>Next message:</STRONG> <A HREF="0131.html">Petter Reinholdtsen: "Libtool ltdl patch"</A>
<LI><STRONG>Previous message:</STRONG> <A HREF="0129.html">Petter Reinholdtsen: "Re: A bug in the backend? (microtek2)"</A>
<LI><STRONG>Maybe in reply to:</STRONG> <A HREF="0026.html">David Mosberger-Tang: "forwarded message from Karl Heinz Kremer"</A>
<!-- nextthread="start" -->
<LI><STRONG>Next in thread:</STRONG> <A HREF="0238.html">abel deuring: "Re: forwarded message from Karl Heinz Kremer"</A>
<LI><STRONG>Reply:</STRONG> <A HREF="0238.html">abel deuring: "Re: forwarded message from Karl Heinz Kremer"</A>
<!-- reply="end" -->
<LI><STRONG>Messages sorted by:</STRONG>
<A HREF="date.html#130">[ date ]</A>
<A HREF="index.html#130">[ thread ]</A>
<A HREF="subject.html#130">[ subject ]</A>
<A HREF="author.html#130">[ author ]</A>
</UL>
<!-- trailer="footer" -->
<HR NOSHADE>
<P>
<SMALL>
<EM>
This archive was generated by <A HREF="http://www.hypermail.org/">hypermail 2b29</A>
: <EM>Mon Jan 17 2000 - 16:55:15 PST</EM>
</EM>
</SMALL>
</BODY>
</HTML>