sane-project-website/lj98/doc005.html

81 wiersze
4.1 KiB
HTML

<html><body>
<a href="doc006.html"><img src=../icons/next.gif alt="Next"></a>
<a href="doc000.html"><img src=../icons/up.gif alt="Up"></a>
<a href="doc004.html"><img src=../icons/previous.gif alt="Previous"></a>
<a href="doc000.html"><img src=../icons/contents.gif alt="Contents"></a>
<hr>
<title>How Does It Work?</title>
<h2><a name="s4">4 How Does It Work?</a></h2>
<p>When building a SANE application, it must be linked against the shared
library called libsane.so. In reality, libsane.so is just a symlink to
one of the SANE drivers. Since every SANE driver exports the exact
same interface, you can change the libsane.so symlink at any time and
effectively change which driver the application is using. While this
is useful in the sense that it allows upgrading to a different driver
without having to relink all the applications, it would not be very
convenient if you had to change a symlink whenever you wished to
switch the scanning device. For this reason, SANE supports two
pseudo-drivers called <tt>dll</tt> and <tt>net</tt>. They are
pseudo-drivers because rather than talking to physical devices, they
talk to other SANE drivers, as illustrated in
Figure <a href="doc005.html#f6">6</a>.
<p>For machine A, the libsane.so symlink points to the dll pseudo-driver
(called libsane-dll.so). That pseudo-driver uses dynamically linked
libraries (dll) to access other SANE drivers. In the example, dll is
configured to use the pnm, mustek and net drivers. The net driver is
again a pseudo-driver; it provides access to remote scanners by
connecting to the SANE daemon (saned) running on machine B. Machine B
in turn uses dll again to provide access to a variety of other
drivers. As you might imagine, the exact configuration is entirely up
to the system administrator(s) of machines A and B. It is fairly
typical to have libsane.so be a symlink to the dll pseudo-driver, but
there is no reason it couldn't point to the net pseudo-driver or just
the mustek driver. Of course, in the latter case the implication would
be that applications could access the mustek driver only---but that's
perfectly reasonable for certain environments.
<p><p><a name="f6"></a>
<center>
<img width=780 height=384 src="img004.gif">
<p><center>Figure 6: Possible SANE Hierarchy</center>
</center>
<p>
<p>This approach is very flexible, but it raises an interesting question:
how do we name devices in such an environment? The answer is that
every real driver has its own device name space. For example, the
Mustek and HP drivers use the path for the Unix special device that
controls the device, such as <tt>/dev/scanner</tt>. With pseudo-drivers,
things get a bit more interesting. Since dll must guarantee that each
device name is unique, it simply prefixes the name of each subordinate
device with the name of the subordinate driver, separated by a colon.
Thus, on machine A, the mustek scanner would be called
<tt>mustek:/dev/scanner</tt>. The net pseudo-driver does something
similar: it prefixes the remote device name with the remote host name
(again using a colon as a separator). For example, HP scanner 1 on
machine B would appear on machine A under the name
<tt>net:B.domain.com:hp:/dev/scanner1</tt>. While this doesn't make for
the world's prettiest names, the information contained in the names is
actually quite useful. In essence, much like a Unix path name, the
device names convey the path through the SANE hierarchy that leads to
a particular device. For example, if you know that machine B is down,
it's pretty obvious that <tt>net:B.domain.com:hp:/dev/scanner1</tt> will
be down as well. If someone feels strongly about these names, it is
possible for an application to let a user or system administrator
define aliases that are more concise. For example, an application
could let a user rename the above device to ``HP Scanner 1'', which
may be easier for beginners.
<p><p><hr>
<a href="doc006.html"><img src=../icons/next.gif alt="Next"></a>
<a href="doc000.html"><img src=../icons/up.gif alt="Up"></a>
<a href="doc004.html"><img src=../icons/previous.gif alt="Previous"></a>
<a href="doc000.html"><img src=../icons/contents.gif alt="Contents"></a>
<hr>
</body></html>