sane-project-website/old-archive/2000-03/0286.html

279 wiersze
7.8 KiB
HTML
Czysty Zwykły widok Historia

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
"http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
<TITLE>sane-devel: SANE_DEFAULT_DEVICE for scanimage (patch)</TITLE>
<META NAME="Author" CONTENT="Ingo Wilken (Ingo.Wilken@Informatik.Uni-Oldenburg.DE)">
<META NAME="Subject" CONTENT="SANE_DEFAULT_DEVICE for scanimage (patch)">
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000">
<H1>SANE_DEFAULT_DEVICE for scanimage (patch)</H1>
<!-- received="Mon Mar 27 14:12:05 2000" -->
<!-- isoreceived="20000327221205" -->
<!-- sent="Tue, 28 Mar 2000 00:26:57 +0200 (MET DST)" -->
<!-- isosent="20000327222657" -->
<!-- name="Ingo Wilken" -->
<!-- email="Ingo.Wilken@Informatik.Uni-Oldenburg.DE" -->
<!-- subject="SANE_DEFAULT_DEVICE for scanimage (patch)" -->
<!-- id="E12ZhyL-0001ED-00@petersfehn.Informatik.Uni-Oldenburg.DE" -->
<STRONG>From:</STRONG> Ingo Wilken (<A HREF="mailto:Ingo.Wilken@Informatik.Uni-Oldenburg.DE?Subject=Re:%20SANE_DEFAULT_DEVICE%20for%20scanimage%20(patch)&In-Reply-To=&lt;E12ZhyL-0001ED-00@petersfehn.Informatik.Uni-Oldenburg.DE&gt;"><EM>Ingo.Wilken@Informatik.Uni-Oldenburg.DE</EM></A>)<BR>
<STRONG>Date:</STRONG> Mon Mar 27 2000 - 14:26:57 PST
<P>
<!-- next="start" -->
<LI><STRONG>Next message:</STRONG> <A HREF="0287.html">pixel fairy: "noisy umax astra 2200"</A>
<UL>
<LI><STRONG>Previous message:</STRONG> <A HREF="0285.html">Oliver Rauch: "Re: sane 1.0.2 - strangeness"</A>
<!-- nextthread="start" -->
<!-- reply="end" -->
<LI><STRONG>Messages sorted by:</STRONG>
<A HREF="date.html#286">[ date ]</A>
<A HREF="index.html#286">[ thread ]</A>
<A HREF="subject.html#286">[ subject ]</A>
<A HREF="author.html#286">[ author ]</A>
</UL>
<HR NOSHADE><P>
<!-- body="start" -->
<P>
This patch adds support for an environment variable SANE_DEFAULT_DEVICE
<BR>
to scanimage. Useful if the first device on the list is not your
<BR>
preferred device, and you don't want to use the --device option in
<BR>
every command.
<BR>
<P>I think I sent a similar patch for SANE-1.0.1 to this list some time
<BR>
ago. Anyway, it's not in 1.0.2, so I reimplemented it (with a minor
<BR>
improvement: if the variable is set, show its contents with -L).
<BR>
<P>Regards,
<BR>
Ingo
<BR>
<P><P>*** doc/scanimage.man.orig Thu Mar 16 05:25:19 2000
<BR>
--- doc/scanimage.man Thu Mar 16 05:38:45 2000
<BR>
***************
<BR>
*** 38,43 ****
<BR>
--- 38,47 ----
<BR>
&nbsp;&nbsp;.B --list-devices
<BR>
&nbsp;&nbsp;option (see below). If no device-name is specified explicitly,
<BR>
&nbsp;&nbsp;.B scanimage
<BR>
+ reads a device-name from the environment variable
<BR>
+ .BR SANE_DEFAULT_DEVICE .
<BR>
+ If this variable is not set,
<BR>
+ .B scanimage
<BR>
&nbsp;&nbsp;will attempt to open the first available device.
<BR>
&nbsp;&nbsp;.PP
<BR>
&nbsp;&nbsp;The
<BR>
***************
<BR>
*** 228,233 ****
<BR>
--- 232,241 ----
<BR>
&nbsp;&nbsp;.BR /tmp/input.ppm .
<BR>
&nbsp;&nbsp;.RE
<BR>
&nbsp;&nbsp;
<BR>
+ .SH ENVIRONMENT
<BR>
+ .TP
<BR>
+ .B SANE_DEFAULT_DEVICE
<BR>
+ The default device-name.
<BR>
&nbsp;&nbsp;.SH FILES
<BR>
&nbsp;&nbsp;.TP
<BR>
&nbsp;&nbsp;.I @CONFIGDIR@
<BR>
*** frontend/scanimage.c.orig Wed Mar 15 17:30:38 2000
<BR>
--- frontend/scanimage.c Wed Mar 15 18:05:17 2000
<BR>
***************
<BR>
*** 1062,1067 ****
<BR>
--- 1062,1068 ----
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;const SANE_Device ** device_list;
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;SANE_Int num_dev_options = 0;
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;const char * devname = 0;
<BR>
+ const char * defdevname = 0;
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;const char * format = 0;
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;int batch = 0;
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;SANE_Status status;
<BR>
***************
<BR>
*** 1075,1080 ****
<BR>
--- 1076,1083 ----
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;else
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;prog_name = argv[0];
<BR>
&nbsp;&nbsp;
<BR>
+ defdevname = getenv(&quot;SANE_DEFAULT_DEVICE&quot;);
<BR>
+
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;sane_init (0, 0);
<BR>
&nbsp;&nbsp;
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;/* make a first pass through the options with error printing and argument
<BR>
***************
<BR>
*** 1113,1118 ****
<BR>
--- 1116,1124 ----
<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;device_list[i]-&gt;name, device_list[i]-&gt;vendor,
<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;device_list[i]-&gt;model, device_list[i]-&gt;type);
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
<BR>
+ if (defdevname)
<BR>
+ printf (&quot;default device is `%s'\n&quot;, defdevname);
<BR>
+
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;exit (0);
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
<BR>
&nbsp;&nbsp;
<BR>
***************
<BR>
*** 1142,1150 ****
<BR>
&nbsp;&nbsp;
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;if (!devname)
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{
<BR>
! /* If no device name was specified explicitly, we open the first
<BR>
! device we find (if any): */
<BR>
!
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;status = sane_get_devices (&amp;device_list, SANE_FALSE);
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (status != SANE_STATUS_GOOD)
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{
<BR>
--- 1148,1159 ----
<BR>
&nbsp;&nbsp;
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;if (!devname)
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{
<BR>
! /* If no device name was specified explicitly, we look at the
<BR>
! environment variable SANE_DEFAULT_DEVICE. If this variable
<BR>
! is not set, we open the first device we find (if any): */
<BR>
! devname = defdevname;
<BR>
! if (!devname )
<BR>
! {
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;status = sane_get_devices (&amp;device_list, SANE_FALSE);
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (status != SANE_STATUS_GOOD)
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{
<BR>
***************
<BR>
*** 1158,1163 ****
<BR>
--- 1167,1173 ----
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;exit (1);
<BR>
&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;devname = device_list[0]-&gt;name;
<BR>
+ }
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
<BR>
&nbsp;&nbsp;
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;status = sane_open (devname, &amp;device);
<BR>
<P><PRE>
--
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:%20SANE_DEFAULT_DEVICE%20for%20scanimage%20(patch)&In-Reply-To=&lt;E12ZhyL-0001ED-00@petersfehn.Informatik.Uni-Oldenburg.DE&gt;">majordomo@mostang.com</A>
</PRE>
<P><!-- body="end" -->
<HR NOSHADE>
<UL>
<!-- next="start" -->
<LI><STRONG>Next message:</STRONG> <A HREF="0287.html">pixel fairy: "noisy umax astra 2200"</A>
<LI><STRONG>Previous message:</STRONG> <A HREF="0285.html">Oliver Rauch: "Re: sane 1.0.2 - strangeness"</A>
<!-- nextthread="start" -->
<!-- reply="end" -->
<LI><STRONG>Messages sorted by:</STRONG>
<A HREF="date.html#286">[ date ]</A>
<A HREF="index.html#286">[ thread ]</A>
<A HREF="subject.html#286">[ subject ]</A>
<A HREF="author.html#286">[ 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 Mar 27 2000 - 14:12:52 PST</EM>
</EM>
</SMALL>
</BODY>
</HTML>