sane-project-website/html/doc007.html

105 wiersze
5.0 KiB
HTML

<html><body>
<a href="doc008.html"><img src=../icons/next.gif alt="Next"></a>
<a href="doc000.html"><img src=../icons/up.gif alt="Up"></a>
<a href="doc006.html"><img src=../icons/previous.gif alt="Previous"></a>
<a href="doc000.html"><img src=../icons/contents.gif alt="Contents"></a>
<a href="doc019.html"><img src=../icons/index.gif alt="Index"></a>
<hr>
<title>Attaching to a SANE backend</title>
<h2><a name="s3.1">3.1 Attaching to a SANE backend</a></h2>
<p>The process through which a SANE frontend connects to a backend is
platform dependent. Several possibilities exist:
<ul>
<p><li><b>Static linking:</b> A SANE backend may be linked directly into
a frontend. While the simplest method of attaching to a backend, it
is somewhat limited in functionality since the available devices is
limited to the ones for which support has been linked in when the
frontend was built. But even so static linking can be quite useful,
particularly when combined with a backend that can access scanners
via a network. Also, it is possible to support multiple backends
simultaneously by implementing a meta backend that manages several
backends that have been compiled in such a manner that they export
unique function names. For example, a backend called <tt>be</tt>
would normally export a function called <tt>sane_read()</tt>. If
each backend would provide such a function, static linking would
fail due to multiple conflicting definitions of the same symbol.
This can be resolved by having backend <tt>be</tt> include a
header file that has lines of the form:
<blockquote>
<pre>
#define sane_read be_sane_read
</pre>
</blockquote>
With definitions of this kind, backend <tt>be</tt> will export
function name <tt>be_sane_read()</tt>. Thus, all backends will
export unique names. As long as a meta backend knows about these
names, it is possible to combine several backends at link time and
select and use them dynamically at runtime.
<p><li><b>Dynamic linking:</b> A simpler yet more powerful way to
support multiple backends is to exploit dynamic linking on platforms
that support it. In this case, a frontend is linked against a
shared library that implements any SANE backend. Since each
dynamically linked backend exports the same set of global symbols
(all starting with the prefix <tt>sane_</tt>), the dynamic library
that gets loaded at runtime does not necessarily have to be the same
one as one the frontend got linked against. In other words, it is
possible to switch the backend by installing the appropriate backend
dynamic library.
<p> More importantly, dynamic linking makes it easy to implement a meta
backend that loads other backends <em>on demand</em>. This is a
powerful mechanism since it allows adding new backends merely by
installing a shared library and updating a configuration file.
<p><li><b>Network connection:</b> Arguably the ultimate way to attach to
a scanner is by using the network to connect to a backend on a
remote machine. This makes it possible to scan images from any host
in the universe, as long as there is a network connection to that
host and provided the user is permitted to access that scanner.
<p></ul>
<p><p><a name="f1"></a>
<center>
<img width=780 height=384 src="img000.gif">
<p><center>Figure 1: Example SANE Hiearchy</center>
</center>
<p>
<p>The above discussion lists just a few ways for frontends to attach to
a backend. It is of course possible to combine these solutions to
provide an entire hierarchy of SANE backends. Such a hierarchy is
depicted in Figure <a href="doc007.html#f1">1</a>. The figure shows that machine
A uses a dynamic-linking based meta backend called <tt>dll</tt> to
access the backends called <tt>pnm</tt>, <tt>mustek</tt>, and <tt>net</tt>.
The first two are real backends, whereas the last one is a meta
backend that provides network transparent access to remote scanners.
In the figure, machine B provides non-local access to its scanners
through the SANE frontend called <tt>saned</tt>. The <tt>saned</tt> in
turn has access to the <tt>hp</tt> and <tt>autolum</tt> backends through
another instance of the <tt>dll</tt> backend. The <tt>autolum</tt> meta
backend is used to automatically adjust the luminance (brightness) of
the image data acquired by the camera backend called <tt>qcam</tt>.
<p>Note that a meta backend really is both a frontend and a backend at
the same time. It is a frontend from the viewpoint of the backends
that it manages and a backend from the viewpoint of the frontends that
access it. The name ``meta backend'' was chosen primarily because the
SANE standard describes the interface from the viewpoint of a (real)
frontend.
<p><p><hr>
<a href="doc008.html"><img src=../icons/next.gif alt="Next"></a>
<a href="doc000.html"><img src=../icons/up.gif alt="Up"></a>
<a href="doc006.html"><img src=../icons/previous.gif alt="Previous"></a>
<a href="doc000.html"><img src=../icons/contents.gif alt="Contents"></a>
<a href="doc019.html"><img src=../icons/index.gif alt="Index"></a>
<hr>
</body></html>