Notes on Visual Studio
[metaproxy-moved-to-github.git] / doc / book.xml
1 <?xml version="1.0" standalone="no"?>
2 <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.1//EN"
3     "http://www.oasis-open.org/docbook/xml/4.1/docbookx.dtd" 
4 [
5      <!ENTITY % local SYSTEM "local.ent">
6      %local;
7      <!ENTITY manref SYSTEM "manref.xml">
8      <!ENTITY progref SYSTEM "progref.xml">
9      <!ENTITY % idcommon SYSTEM "common/common.ent">
10      %idcommon;
11      <!-- Next line allows imagedata/@format="PDF" and is taken from 
12          http://lists.oasis-open.org/archives/docbook/200303/msg00163.html
13      -->
14      <!ENTITY % local.notation.class "| PDF">
15      <!-- Next line is necessary for some XML parsers, for reasons I
16           don't understand.  I got this from
17          http://lists.oasis-open.org/archives/docbook/200303/msg00180.html
18      -->
19      <!NOTATION PDF SYSTEM "PDF">
20 ]>
21 <book id="metaproxy">
22  <bookinfo>
23   <title>Metaproxy - User's Guide and Reference</title>
24   <authorgroup>
25    <author>
26     <firstname>Adam</firstname><surname>Dickmeiss</surname>
27    </author>
28    <author>
29     <firstname>Marc</firstname><surname>Cromme</surname>
30    </author>
31    <author>
32     <firstname>Mike</firstname><surname>Taylor</surname>
33    </author>
34   </authorgroup>
35   <releaseinfo>&version;</releaseinfo>
36   <copyright>
37    <year>2005-2007</year>
38    <holder>Index Data ApS</holder>
39   </copyright>
40   <abstract>
41    <simpara>
42     This manual is part of Metaproxy version &version;.
43     </simpara>
44    <simpara>
45     Metaproxy is a universal router, proxy and encapsulated
46     metasearcher for information retrieval protocols.  It accepts,
47     processes, interprets and redirects requests from IR clients using
48     standard protocols such as the binary
49     <ulink url="&url.z39.50;">ANSI/NISO Z39.50</ulink>
50     and  the information search and retrieval 
51     web service <ulink url="&url.sru;">SRU</ulink>
52     as well as functioning as a limited
53     <ulink url="&url.http;">HTTP</ulink> server. 
54    </simpara>
55    <simpara>
56     Metaproxy is configured by an XML file which
57     specifies how the software should function in terms of routes that
58     the request packets can take through the proxy, each step on a
59     route being an instantiation of a filter.  Filters come in many
60     types, one for each operation: accepting Z39.50 packets, logging,
61     query transformation, multiplexing, etc.  Further filter-types can
62     be added as loadable modules to extend Metaproxy functionality,
63     using the filter API.
64    </simpara>
65    <simpara>
66     Metaproxy is covered by the GNU General Public License version 2.
67    </simpara>
68    <simpara>
69     <inlinemediaobject>
70      <imageobject>
71       <imagedata fileref="common/id.png" format="PNG"/>
72      </imageobject>
73      <imageobject>
74       <imagedata fileref="common/id.eps" format="EPS"/>
75      </imageobject>
76     </inlinemediaobject>
77    </simpara>
78   </abstract>
79  </bookinfo>
80
81  <chapter id="introduction">
82   <title>Introduction</title>
83   
84   <para>
85    <ulink url="&url.metaproxy;">Metaproxy</ulink>
86    is a stand alone program that acts as a universal router, proxy and
87    encapsulated metasearcher for information retrieval protocols such
88    as <ulink url="&url.z39.50;">Z39.50</ulink> and
89    <ulink url="&url.sru;">SRU</ulink>.
90    To clients, it acts as a server of these protocols: it can be searched,
91    records can be retrieved from it, etc. 
92    To servers, it acts as a client: it searches in them,
93    retrieves records from them, etc.  it satisfies its clients'
94    requests by transforming them, multiplexing them, forwarding them
95    on to zero or more servers, merging the results, transforming
96    them, and delivering them back to the client.  In addition, it
97    acts as a simple <ulink url="&url.http;">HTTP</ulink> server; support
98    for further protocols can be added in a modular fashion, through the
99    creation of new filters.
100   </para>
101   <screen>
102    Anything goes in!
103    Anything goes out!
104    Fish, bananas, cold pyjamas,
105    Mutton, beef and trout!
106         - attributed to Cole Porter.
107   </screen>
108   <para>
109    Metaproxy is a more capable alternative to
110    <ulink url="&url.yazproxy;">YAZ Proxy</ulink>,
111    being more powerful, flexible, configurable and extensible.  Among
112    its many advantages over the older, more pedestrian work are
113    support for multiplexing (encapsulated metasearching), routing by
114    database name, authentication and authorization and serving local
115    files via HTTP.  Equally significant, its modular architecture
116    facilitites the creation of pluggable modules implementing further
117    functionality.
118   </para>
119   <para>
120    This manual will describe how to install Metaproxy
121    before giving an overview of its architecture, then discussing the
122    key concept of a filter in some depth and giving an overview of
123    the various filter types, then discussing the configuration file
124    format.  After this come several optional chapters which may be
125    freely skipped: a detailed discussion of virtual databases and
126    multi-database searching, some notes on writing extensions
127    (additional filter types) and a high-level description of the
128    source code.  Finally comes the reference guide, which contains
129    instructions for invoking the <command>metaproxy</command>
130    program, and detailed information on each type of filter,
131    including examples.
132   </para>
133  </chapter>
134  
135  <chapter id="installation">
136   <title>Installation</title>
137   <para>
138    Metaproxy depends on the following tools/libraries:
139    <variablelist>
140     <varlistentry><term><ulink url="&url.yazplusplus;">YAZ++</ulink></term>
141      <listitem>
142       <para>
143        This is a C++ library based on <ulink url="&url.yaz;">YAZ</ulink>.
144       </para>
145      </listitem>
146     </varlistentry>
147     <varlistentry><term><ulink url="&url.libxslt;">Libxslt</ulink></term>
148      <listitem>
149       <para>This is an XSLT processor - based on 
150        <ulink url="&url.libxml2;">Libxml2</ulink>. Both Libxml2 and
151        Libxslt must be installed with the development components
152        (header files, etc.) as well as the run-time libraries.
153       </para>
154      </listitem>
155     </varlistentry>
156     <varlistentry><term><ulink url="&url.boost;">Boost</ulink></term>
157      <listitem>
158       <para>
159        The popular C++ library. Initial versions of Metaproxy
160        was built with 1.32 but this is no longer supported.
161        Metaproxy is known to work with Boost version 1.33 / 1.34 / 1.35.
162       </para>
163      </listitem>
164     </varlistentry>
165    </variablelist>
166   </para>
167   <para>
168    In order to compile Metaproxy a modern C++ compiler is
169    required. Boost, in particular, requires the C++ compiler
170    to facilitate the newest features. Refer to Boost
171    <ulink url="&url.boost.compilers.status;">Compiler Status</ulink>
172    for more information.
173   </para>
174   <para>
175    We have successfully built Metaproxy using the compilers
176    <ulink url="&url.gcc;">GCC</ulink> version 4.0 and
177    <ulink url="&url.vstudio;">Microsoft Visual Studio</ulink> 2003/2005.
178   </para>
179
180   <section id="installation.unix">
181    <title>Installation on Unix (from Source)</title>
182    <para>
183     Here is a quick step-by-step guide on how to compile all the
184     tools that Metaproxy uses. Only few systems have none of the required
185     tools binary packages. If, for example, Libxml2/libxslt are already
186     installed as development packages use those (and omit compilation).
187    </para>
188    
189    <para>
190     Libxml2/libxslt:
191    </para>
192    <screen>
193     gunzip -c libxml2-version.tar.gz|tar xf -
194     cd libxml2-version
195     ./configure
196     make
197     su
198     make install
199    </screen>
200    <screen>
201     gunzip -c libxslt-version.tar.gz|tar xf -
202     cd libxslt-version
203     ./configure
204     make
205     su
206     make install
207    </screen>
208    <para>
209     YAZ/YAZ++:
210    </para>
211    <screen>
212     gunzip -c yaz-version.tar.gz|tar xf -
213     cd yaz-version
214     ./configure
215     make
216     su
217     make install
218    </screen>
219    <screen>
220     gunzip -c yazpp-version.tar.gz|tar xf -
221     cd yazpp-version
222     ./configure
223     make
224     su
225     make install
226    </screen>
227    <para>
228     Boost:
229    </para>
230    <screen>
231     gunzip -c boost-version.tar.gz|tar xf -
232     cd boost-version
233     ./configure
234     make
235     su
236     make install
237    </screen>
238    <para>
239     Metaproxy:
240    </para>
241    <screen>
242     gunzip -c metaproxy-version.tar.gz|tar xf -
243     cd metaproxy-version
244     ./configure
245     make
246     su
247     make install
248    </screen>
249   </section>
250
251   <section id="installation.debian">
252    <title>Installation on Debian GNU/Linux</title>
253    <para>
254     All dependencies for Metaproxy are available as 
255     <ulink url="&url.debian;">Debian</ulink>
256     packages for the sarge (stable in 2005) and etch (testing in 2005)
257     distributions.
258    </para>
259    <para>
260     The procedures for Debian based systems, such as
261     <ulink url="&url.ubuntu;">Ubuntu</ulink> is probably similar
262    </para>
263    <para>
264     There is currently no official Debian package for YAZ++.
265     And the official Debian package for YAZ is probably too old.
266     But Index Data bulds "new" versions of those for Debian (i386 only).
267    </para>
268    <para>
269     Update the <filename>/etc/apt/sources.list</filename>
270     to include the Index Data repository.
271     See YAZ' <ulink url="&url.yaz.download.debian;">Download Debian</ulink>
272     for more information.
273    </para>
274    <screen>
275     apt-get install libxslt1-dev
276     apt-get install libyazpp2-dev
277     apt-get install libboost-dev
278     apt-get install libboost-thread-dev
279     apt-get install libboost-test-dev
280    </screen>
281    <para>
282     With these packages installed, the usual configure + make
283     procedure can be used for Metaproxy as outlined in
284     <xref linkend="installation.unix"/>.
285    </para>
286   </section>
287
288   <section id="installation.rpm">
289    <title>Installation on RPM based Linux Systems</title>
290    <para>
291     All external dependencies for Metaproxy are available as 
292     RPM packages, either from your distribution site, or from the 
293     <ulink url="http://fr.rpmfind.net/">RPMfind</ulink> site.
294    </para>
295    <para>
296     For example, an installation of the requires Boost C++ development 
297     libraries on RedHat Fedora C4 and C5 can be done like this:
298     <screen> 
299     wget ftp://fr.rpmfind.net/wlinux/fedora/core/updates/testing/4/SRPMS/boost-1.33.0-3.fc4.src.rpm
300     sudo rpmbuild --buildroot src/ --rebuild -p fc4/boost-1.33.0-3.fc4.src.rpm
301     sudo rpm -U /usr/src/redhat/RPMS/i386/boost-*rpm
302     </screen>
303    </para>
304    <para>
305     The  <ulink url="&url.yaz;">YAZ</ulink> library is needed to
306     compile &metaproxy;, see there
307     for more information on available RPM packages.
308    </para>
309    <para>
310     There is currently no official RPM package for YAZ++.
311     See the <ulink url="&url.yazplusplus;">YAZ++</ulink> pages 
312     for more information on a Unix tarball install.
313    </para>
314    <para>
315     With these packages installed, the usual configure + make
316     procedure can be used for Metaproxy as outlined in
317     <xref linkend="installation.unix"/>.
318    </para>
319   </section>
320
321   <section id="installation.windows">
322    <title>Installation on Windows</title>
323    <para>
324     Metaproxy can be compiled with Microsoft
325     <ulink url="&url.vstudio;">Visual Studio</ulink>.
326     Versions 2003 (C 7.1), 2005 (C 8.0) and 2008 (C 9.0) is known to work.
327    </para>
328    <section id="installation.windows.boost">
329     <title>Boost</title>
330     <para>
331      For Windows, it's easiest to get the precompiled Boost
332      package from <ulink url="&url.boost.windows.download;">here</ulink>.
333      Several versions of the Boost libraries may be selected when
334      installing Boost for windows. Please choose at least the
335      <emphasis>multithreaded</emphasis> (non-DLL) version because
336      the Metaproxy makefile uses that.
337     </para>
338     <para>
339      For more information about installing Boost refer to the
340      <ulink url="&url.boost.getting.started;">getting started</ulink>
341      pages.
342     </para>
343    </section>
344
345    <section id="installation.windows.libxslt">
346     <title>Libxslt</title>
347     <para>
348      <ulink url="&url.libxslt;">Libxslt</ulink> can be downloaded
349      for Windows from
350      <ulink url="&url.libxml2.download.win32;">here</ulink>.
351     </para>
352     <para>
353      Libxslt has other dependencies, but these can all be downloaded
354      from the same site. Get the following package:
355      iconv, zlib, libxml2, libxslt.
356     </para>
357    </section>
358
359    <section id="installation.windows.yaz">
360     <title>YAZ</title>
361     <para>
362      <ulink url="&url.yaz;">YAZ</ulink> can be downloaded
363      for Windows from
364      <ulink url="&url.yaz.download.win32;">here</ulink>.
365     </para>
366    </section>
367
368    <section id="installation.windows.yazplusplus">
369     <title>YAZ++</title>
370     <para>
371      Get <ulink url="&url.yazplusplus;">YAZ++</ulink> as well.
372      Version 1.1.0 or later is required.
373     </para>
374     <para>
375      YAZ++ includes NMAKE makefiles, similar to those found in the
376      YAZ package.
377     </para>
378    </section>
379
380    <section id="installation.windows.metaproxy">
381     <title>Metaproxy</title>
382     <para>
383      Metaproxy is shipped with NMAKE makefiles as well - similar
384      to those found in the YAZ++/YAZ packages. Adjust this Makefile
385      to point to the proper locations of Boost, Libxslt, Libxml2,
386      zlib, iconv, yaz and yazpp.
387     </para>
388
389     <variablelist>
390      <varlistentry><term><literal>DEBUG</literal></term>
391       <listitem><para>
392         If set to 1, the software is
393         compiled with debugging libraries (code generation is
394         multi-threaded debug DLL).
395         If set to 0, the software is compiled with release libraries
396         (code generation is multi-threaded DLL).
397        </para></listitem>
398      </varlistentry>
399
400      <varlistentry>
401       <term><literal>BOOST</literal></term>
402       <listitem>
403        <para>
404         Boost install location
405        </para>
406       </listitem>
407      </varlistentry>
408
409      <varlistentry>
410       <term><literal>BOOST_VERSION</literal></term>
411       <listitem>
412        <para>
413         Boost version (replace . with _).
414        </para>
415       </listitem>
416      </varlistentry>
417
418      <varlistentry>
419       <term><literal>BOOST_TOOLSET</literal></term>
420       <listitem>
421        <para>
422         Boost toolset.
423        </para>
424       </listitem>
425      </varlistentry>
426
427      <varlistentry>
428       <term><literal>LIBXSLT_DIR</literal>,
429        <literal>LIBXML2_DIR</literal> ..</term>
430       <listitem>
431        <para>
432         Specify the locations of Libxslt, libiconv, libxml2 and
433         libxslt.
434        </para>
435       </listitem>
436      </varlistentry>
437       
438     </variablelist>
439     
440     <para>
441      After successful compilation you'll find
442      <literal>metaproxy.exe</literal> in the
443      <literal>bin</literal> directory.
444     </para>
445    </section>
446
447
448   </section>
449  </chapter>
450  
451 <chapter id="yazproxy-comparison">
452  <title>YAZ Proxy Comparison</title>
453  <para>
454   The table below lists facilities either supported by either
455    <ulink url="&url.yazproxy;">YAZ Proxy</ulink> or Metaproxy.
456  </para>
457 <table id="yazproxy-comparison-table">
458  <title>Metaproxy / YAZ Proxy comparison</title>
459  <tgroup cols="3">
460   <thead>
461    <row>
462     <entry>Facility</entry>
463     <entry>Metaproxy</entry>
464     <entry>YAZ Proxy</entry>
465    </row>
466   </thead>
467   <tbody>
468    <row>
469     <entry>Z39.50 server</entry>
470     <entry>Using filter <literal>frontend_net</literal></entry>
471     <entry>Supported</entry>
472    </row>
473    <row>
474     <entry>SRU server</entry>
475     <entry>Supported with filter <literal>sru_z3950</literal></entry>
476     <entry>Supported</entry>
477    </row>
478    <row>
479     <entry>Z39.50 client</entry>
480     <entry>Supported with filter <literal>z3950_client</literal></entry>
481     <entry>Supported</entry>
482    </row>
483    <row>
484     <entry>SRU client</entry>
485     <entry>Unsupported</entry>
486     <entry>Unsupported</entry>
487    </row>
488    <row>
489     <entry>Connection reuse</entry>
490     <entry>Supported with filter <literal>session_shared</literal></entry>
491     <entry>Supported</entry>
492    </row>
493    <row>
494     <entry>Connection share</entry>
495     <entry>Supported with filter <literal>session_shared</literal></entry>
496     <entry>Unsupported</entry>
497    </row>
498    <row>
499     <entry>Result set reuse</entry>
500     <entry>Supported with filter <literal>session_shared</literal></entry>
501     <entry>Within one Z39.50 session / HTTP keep-alive</entry>
502    </row>
503    <row>
504     <entry>Record cache</entry>
505     <entry>Unsupported</entry>
506     <entry>Supported for last result set within one Z39.50/HTTP-keep alive session</entry>
507    </row>
508    <row>
509     <entry>Z39.50 Virtual database, i.e. select any Z39.50 target for database</entry>
510     <entry>Supported with filter <literal>virt_db</literal></entry>
511     <entry>Unsupported</entry>
512    </row>
513    <row>
514     <entry>SRU Virtual database, i.e. select any Z39.50 target for path</entry>
515     <entry>Supported with filter <literal>virt_db</literal>, 
516      <literal>sru_z3950</literal></entry>
517     <entry>Supported</entry>
518    </row>
519    <row>
520     <entry>Multi target search</entry>
521     <entry>Supported with filter <literal>multi</literal> (round-robin)</entry>
522     <entry>Unsupported</entry>
523    </row>
524    <row>
525     <entry>Retrieval and search limits</entry>
526     <entry>Unsupported</entry>
527     <entry>Supported</entry>
528    </row>
529    <row>
530     <entry>Bandwidth limits</entry>
531     <entry>Unsupported</entry>
532     <entry>Supported</entry>
533    </row>
534    <row>
535     <entry>Connect limits</entry>
536     <entry>Unsupported</entry>
537     <entry>Supported</entry>
538    </row>
539    <row>
540     <entry>Retrieval sanity check and conversions</entry>
541     <entry>Supported using filter <literal>record_transform</literal></entry>
542     <entry>Supported</entry>
543    </row>
544    <row>
545     <entry>Query check</entry>
546     <entry>
547      Supported in a limited way using <literal>query_rewrite</literal>
548     </entry>
549     <entry>Supported</entry>
550    </row>
551    <row>
552     <entry>Query rewrite</entry>
553     <entry>Supported with <literal>query_rewrite</literal></entry>
554     <entry>Unsupported</entry>
555    </row>
556    <row>
557     <entry>Session invalidate for -1 hits</entry>
558     <entry>Unsupported</entry>
559     <entry>Supported</entry>
560    </row>
561    <row>
562     <entry>Architecture</entry>
563     <entry>Multi-threaded + select for networked modules such as
564       <literal>frontend_net</literal>)</entry>
565     <entry>Single-threaded using select</entry>
566    </row>
567
568    <row>
569     <entry>Extensability</entry>
570     <entry>Most functionality implemented as loadable modules</entry>
571     <entry>Unsupported and experimental</entry>
572    </row>
573
574    <row>
575     <entry><ulink url="&url.usemarcon;">USEMARCON</ulink></entry>
576     <entry>Unsupported</entry>
577     <entry>Supported</entry>
578    </row>
579
580    <row>
581     <entry>Portability</entry>
582     <entry>
583      Requires YAZ, YAZ++ and modern C++ compiler supporting
584      <ulink url="&url.boost;">Boost</ulink>.
585     </entry>
586     <entry>
587      Requires YAZ and YAZ++.
588      STL is not required so pretty much any C++ compiler out there should work.
589     </entry>
590    </row>
591
592   </tbody>
593  </tgroup>
594 </table>
595 </chapter>
596
597  <chapter id="architecture">
598   <title>The Metaproxy Architecture</title>
599   <para>
600    The Metaproxy architecture is based on three concepts:
601    the <emphasis>package</emphasis>,
602    the <emphasis>route</emphasis>
603    and the <emphasis>filter</emphasis>.
604   </para>
605   <variablelist>
606    <varlistentry>
607     <term>Packages</term>
608     <listitem>
609      <para>
610       A package is request or response, encoded in some protocol,
611       issued by a client, making its way through Metaproxy, send to or
612       received from a server, or sent back to the client.
613      </para>
614      <para>
615       The core of a package is the protocol unit - for example, a
616       Z39.50 Init Request or Search Response, or an SRU searchRetrieve
617       URL or Explain Response.  In addition to this core, a package
618       also carries some extra information added and used by Metaproxy
619       itself.
620      </para>
621      <para>
622       In general, packages are doctored as they pass through
623       Metaproxy.  For example, when the proxy performs authentication
624       and authorization on a Z39.50 Init request, it removes the
625       authentication credentials from the package so that they are not
626       passed onto the back-end server; and when search-response
627       packages are obtained from multiple servers, they are merged
628       into a single unified package that makes its way back to the
629       client.
630      </para>
631     </listitem>
632    </varlistentry>
633    <varlistentry>
634     <term>Routes</term>
635     <listitem>
636      <para>
637       Packages make their way through routes, which can be thought of
638       as programs that operate on the package data-type.  Each
639       incoming package initially makes its way through a default
640       route, but may be switched to a different route based on various
641       considerations.  Routes are made up of sequences of filters (see
642       below).
643      </para>
644     </listitem>
645    </varlistentry>
646    <varlistentry>
647     <term>Filters</term>
648     <listitem>
649      <para>
650       Filters provide the individual instructions within a route, and
651       effect the necessary transformations on packages.  A particular
652       configuration of Metaproxy is essentially a set of filters,
653       described by configuration details and arranged in order in one
654       or more routes.  There are many kinds of filter - about a dozen
655       at the time of writing with more appearing all the time - each
656       performing a specific function and configured by different
657       information.
658      </para>
659      <para>
660       The word ``filter'' is sometimes used rather loosely, in two
661       different ways: it may be used to mean a particular
662       <emphasis>type</emphasis> of filter, as when we speak of ``the
663       auth_simple filter'' or ``the multi filter''; or it may be used
664       to be a specific <emphasis>instance</emphasis> of a filter
665       within a Metaproxy configuration.  For example, a single
666       configuration will often contain multiple instances of the
667       <literal>z3950_client</literal> filter.  In
668       operational terms, of these is a separate filter.  In practice,
669       context always make it clear which sense of the word ``filter''
670       is being used.
671      </para>
672      <para>
673       Extensibility of Metaproxy is primarily through the creation of
674       plugins that provide new filters.  The filter API is small and
675       conceptually simple, but there are many details to master.  See
676       the section below on
677       <link linkend="filters">Filters</link>.
678      </para>
679     </listitem>
680    </varlistentry>
681   </variablelist>
682   <para>
683    Since packages are created and handled by the system itself, and
684    routes are conceptually simple, most of the remainder of this
685    document concentrates on filters.  After a brief overview of the
686    filter types follows, along with some thoughts on possible future
687    directions.
688   </para>
689  </chapter>
690
691
692
693  <chapter id="filters">
694   <title>Filters</title>
695   
696   
697   <section id="filters-introductory-notes">
698    <title>Introductory notes</title>
699    <para>
700     It's useful to think of Metaproxy as an interpreter providing a small
701     number of primitives and operations, but operating on a very
702     complex data type, namely the ``package''.
703    </para>
704    <para>
705     A package represents a Z39.50 or SRU/W request (whether for Init,
706     Search, Scan, etc.)  together with information about where it came
707     from.  Packages are created by front-end filters such as
708     <literal>frontend_net</literal> (see below), which reads them from
709     the network; other front-end filters are possible.  They then pass
710     along a route consisting of a sequence of filters, each of which
711     transforms the package and may also have side-effects such as
712     generating logging.  Eventually, the route will yield a response,
713     which is sent back to the origin.
714    </para>
715    <para>
716     There are many kinds of filter: some that are defined statically
717     as part of Metaproxy, and others may be provided by third parties
718     and dynamically loaded.  They all conform to the same simple API
719     of essentially two methods: <function>configure()</function> is
720     called at startup time, and is passed an XML DOM tree representing that
721     part of the configuration file that pertains to this filter
722     instance: it is expected to walk that tree extracting relevant
723     information; and <function>process()</function> is called every
724     time the filter has to processes a package.
725    </para>
726    <para>
727     While all filters provide the same API, there are different modes
728     of functionality.  Some filters are sources: they create
729     packages
730     (<literal>frontend_net</literal>);
731     others are sinks: they consume packages and return a result
732     (<literal>backend_test</literal>,
733     <literal>bounce</literal>,
734     <literal>http_file</literal>, 
735     <literal>z3950_client</literal>);
736     the others are true filters, that read, process and pass on the
737     packages they are fed
738     (<literal>auth_simple</literal>,
739     <literal>log</literal>,
740     <literal>multi</literal>,
741     <literal>query_rewrite</literal>,
742     <literal>record_transform</literal>,
743     <literal>session_shared</literal>,
744     <literal>sru_z3950</literal>,
745     <literal>template</literal>,
746     <literal>virt_db</literal>).
747    </para>
748  </section>
749   
750   
751   <section id="overview.filter.types">
752    <title>Overview of filter types</title>
753    <para>
754     We now briefly consider each of the types of filter supported by
755     the core Metaproxy binary.  This overview is intended to give a
756     flavor of the available functionality; more detailed information
757     about each type of filter is included below in
758     <xref linkend="reference"/>.
759    </para>
760    <para>
761     The filters are here named by the string that is used as the
762     <literal>type</literal> attribute of a
763     <literal>&lt;filter&gt;</literal> element in the configuration
764     file to request them, with the name of the class that implements
765     them in parentheses.  (The classname is not needed for normal
766     configuration and use of Metaproxy; it is useful only to
767     developers.)
768    </para>
769    <para>
770     The filters are here listed in alphabetical order:
771    </para>
772    
773 <!--
774
775 ### New filters:
776
777 New virt_db-alike that does inteligent peer choice, explain merging,
778 adds FD&N to explain.  Keeps init responses (like "virt_db Classic"),
779 makes routing choices based on local explain knowledge.  Ref IDDI
780 paper.
781
782 Filter to convert Explain Classic to ZeeRex.
783
784 CQL2PQF (which needs augmented ZeeRex) - MARC for Talis.
785
786 SRU2Z39.50 (ditto).
787
788 Figure out what additional information we need in:
789         ZeeRex (check against D3.1)
790         Init request (e.g. loop detection)
791         Query package (e.g. number of hops)
792         Query response (e.g. record source)
793
794 -->
795
796    <section id="auth_simple">
797     <title><literal>auth_simple</literal>
798      (mp::filter::AuthSimple)</title>
799     <para>
800      Simple authentication and authorization.  The configuration
801      specifies the name of a file that is the user register, which
802      lists <varname>username</varname>:<varname>password</varname>
803      pairs, one per line, colon separated. When a session begins, it
804      is rejected unless username and passsword are supplied, and match
805      a pair in the register.  The configuration file may also specific
806      the name of another file that is the target register: this lists
807      lists <varname>username</varname>:<varname>dbname</varname>,<varname>dbname</varname>...
808      sets, one per line, with multiple database names separated by
809      commas.  When a search is processed, it is rejected unless the
810      database to be searched is one of those listed as available to
811      the user.
812     </para>
813    </section>
814    
815    <section id="backend_test">
816     <title><literal>backend_test</literal>
817     (mp::filter::Backend_test)</title>
818     <para>
819      A partial sink that provides dummy responses in the manner of the
820      <literal>yaz-ztest</literal> Z39.50 server.  This is useful only
821      for testing.  Seriously, you don't need this.  Pretend you didn't
822      even read this section.
823     </para>
824    </section>
825    
826    <section id="bounce">
827     <title><literal>bounce</literal>
828     (mp::filter::Bounce)</title>
829     <para>
830      A sink that swallows <emphasis>all packages</emphasis>, 
831      and returns them almost unprocessed.
832      It never sends any package of any type further down the row, but
833      sets Z39.50 packages to Z_Close, and HTTP_Request packages to
834      HTTP_Response err code 400 packages, and adds a suitable bounce
835      message. 
836      The bounce filter is usually added at end of each filter chain route
837      to prevent infinite hanging of for example HTTP
838      requests packages when only the Z39.50 client partial sink 
839      filter is found in the
840      route.  
841     </para>
842    </section>
843    
844    <section id="cql_rpn">
845     <title><literal>cql_rpn</literal>
846     (mp::filter::CQLtoRPN)</title>
847     <para>
848      A query language transforming filter which catches Z39.50 
849      <literal>searchRequest</literal>
850      packages containing <literal>CQL</literal> queries, transforms
851      those to <literal>RPN</literal> queries,
852      and sends the <literal>searchRequests</literal> on to the next
853      filters. It is among other things useful in a SRU context. 
854     </para>
855    </section>
856    
857    <section id="frontend_net">
858     <title><literal>frontend_net</literal>
859      (mp::filter::FrontendNet)</title>
860     <para>
861      A source that accepts Z39.50 connections from a port
862      specified in the configuration, reads protocol units, and
863      feeds them into the next filter in the route.  When the result is
864      received, it is returned to the original origin.
865     </para>
866    </section>
867
868    <section id="http_file">
869     <title><literal>http_file</literal>
870      (mp::filter::HttpFile)</title>
871     <para>
872      A partial sink which swallows only 
873      <literal>HTTP_Request</literal> packages, and 
874      returns the contents of files from the local
875      filesystem in response to HTTP requests.  
876      It lets Z39.50 packages and all other forthcoming package types
877      pass untouched. 
878      (Yes, Virginia, this
879      does mean that Metaproxy is also a Web-server in its spare time.  So
880      far it does not contain either an email-reader or a Lisp
881      interpreter, but that day is surely coming.)
882     </para>
883    </section>
884    
885    <section id="load_balance">
886     <title><literal>load_balance</literal>
887      (mp::filter::LoadBalance)</title>
888     <para>
889      Performs load balancing for incoming Z39.50 init requests.
890      It is used together with the <literal>virt_db</literal> filter,
891      but unlike the <literal>multi</literal> filter it does send an
892      entire session to only one of the virtual backends. The 
893      <literal>load_balance</literal> filter is assuming that
894      all backend targets have equal content, and chooses the backend
895      with least load cost for a new session.
896     <warning>
897      <para>
898       This filter is experimental and yet not mature for heavy load
899       production sites.
900      </para>
901     </warning>
902    </para>
903    </section>
904       
905    <section id="log">
906     <title><literal>log</literal>
907      (mp::filter::Log)</title>
908     <para>
909      Writes logging information to standard output, and passes on
910      the package unchanged. A log file name can be specified, as well
911      as multiple different logging formats.
912    </para>
913    </section>
914
915    <section id="multi">
916    <title><literal>multi</literal>
917      (mp::filter::Multi)</title>
918     <para>
919      Performs multi-database searching.
920      See
921      <link linkend="multidb">the extended discussion</link>
922      of virtual databases and multi-database searching below.
923     </para>
924    </section>
925    
926    <section id="query_rewrite">
927    <title><literal>query_rewrite</literal>
928      (mp::filter::QueryRewrite)</title>
929     <para>
930      Rewrites Z39.50 <literal>Type-1</literal> 
931      and <literal>Type-101</literal> (``<literal>RPN</literal>'') 
932      queries by a
933      three-step process: the query is transliterated from Z39.50
934      packet structures into an XML representation; that XML
935      representation is transformed by an XSLT stylesheet; and the
936      resulting XML is transliterated back into the Z39.50 packet
937      structure.
938     </para>
939    </section>
940    
941    
942    <section id="record_transform">
943     <title><literal>record_transform</literal>
944     (mp::filter::RecordTransform)</title>
945     <para>
946      This filter acts only on Z3950 present requests, and let all
947      other types of packages and requests pass untouched. It's use is
948      twofold: blocking Z3950  present requests, which the backend
949      server does not understand and can not honor, and transforming
950      the present syntax and elementset name according to the rules
951      specified, to fetch only existing record formats, and transform
952      them on the fly to requested record syntaxes.
953     </para>
954    </section>
955
956    <section id="session_shared">
957     <title><literal>session_shared</literal>
958      (mp::filter::SessionShared)</title>
959     <para>
960      This filter implements global sharing of
961      result sets (i.e. between threads and therefore between
962      clients), yielding performance improvements by clever resource
963      pooling. 
964     </para>
965    </section>
966
967    <section id="sru_z3950">
968     <title><literal>sru_z3950</literal>
969     (mp::filter::SRUtoZ3950)</title>
970     <para>
971      This filter transforms valid
972      SRU GET/POST/SOAP searchRetrieve requests to Z3950 init, search,
973      and present requests, and wraps the
974      received hit counts and XML records into suitable SRU response
975      messages.
976      The <literal>sru_z3950</literal> filter  processes also  SRU
977      GET/POST/SOAP explain requests, returning
978      either the absolute minimum required by the standard, or a  full 
979      pre-defined ZeeReX explain record.
980      See the 
981      <ulink url="&url.zeerex.explain;">ZeeReX Explain</ulink>
982      standard pages and the 
983      <ulink url="&url.sru.explain;">SRU Explain</ulink> pages
984      for more information on the correct explain syntax.
985      SRU scan requests are not supported yet.
986     </para>
987    </section>
988    
989    <section id="template">
990     <title><literal>template</literal>
991      (mp::filter::Template)</title>
992     <para>
993      Does nothing at all, merely passing the packet on.  (Maybe it
994      should be called <literal>nop</literal> or
995      <literal>passthrough</literal>?)  This exists not to be used, but
996      to be copied - to become the skeleton of new filters as they are
997      written.  As with <literal>backend_test</literal>, this is not
998      intended for civilians.
999     </para>
1000    </section>
1001    
1002    <section id="virt_db">
1003     <title><literal>virt_db</literal>
1004      (mp::filter::VirtualDB)</title>
1005     <para>
1006      Performs virtual database selection: based on the name of the
1007      database in the search request, a server is selected, and its
1008      address added to the request in a <literal>VAL_PROXY</literal>
1009      otherInfo packet.  It will subsequently be used by a
1010      <literal>z3950_client</literal> filter.
1011      See
1012      <link linkend="multidb">the extended discussion</link>
1013      of virtual databases and multi-database searching below.
1014     </para>
1015    </section>
1016    
1017    <section id="z3950_client">
1018     <title><literal>z3950_client</literal>
1019      (mp::filter::Z3950Client)</title>
1020     <para>
1021      A partial sink which swallows only Z39.50 packages.
1022      It performs Z39.50 searching and retrieval by proxying the
1023      packages that are passed to it.  Init requests are sent to the
1024      address specified in the <literal>VAL_PROXY</literal> otherInfo
1025      attached to the request: this may have been specified by client,
1026      or generated by a <literal>virt_db</literal> filter earlier in
1027      the route.  Subsequent requests are sent to the same address,
1028      which is remembered at Init time in a Session object.
1029      HTTP_Request packages and all other forthcoming package types
1030      are passed untouched. 
1031     </para>
1032   </section>
1033
1034
1035    <section id="zeerex_explain">
1036     <title><literal>zeerex_explain</literal>
1037      (mp::filter::ZeerexExplain)</title>
1038     <para>
1039      This filter acts as a sink for
1040      Z39.50 explain requests, returning a static ZeeReX
1041      Explain XML record from the config section. All other packages
1042      are passed through.
1043      See the 
1044      <ulink url="&url.zeerex.explain;">ZeeReX Explain</ulink>
1045      standard pages
1046      for more information on the correct explain syntax.
1047     </para>
1048     <warning>
1049      <para>
1050       This filter is not yet completed.
1051      </para>
1052     </warning>
1053    </section>
1054    
1055
1056   </section>
1057   
1058   
1059   <section id="future.directions">
1060    <title>Future directions</title>
1061   <para>
1062     Some other filters that do not yet exist, but which would be
1063     useful, are briefly described.  These may be added in future
1064     releases (or may be created by third parties, as loadable
1065     modules).
1066    </para>
1067
1068    <variablelist>
1069     <varlistentry>
1070      <term><literal>frontend_cli</literal> (source)</term>
1071     <listitem>
1072       <para>
1073        Command-line interface for generating requests.
1074       </para>
1075      </listitem>
1076     </varlistentry>
1077     <varlistentry>
1078      <term><literal>sru_client</literal> (sink)</term>
1079      <listitem>
1080       <para>
1081        SRU/GET and SRU/SOAP searching and retrieval.
1082       </para>
1083      </listitem>
1084     </varlistentry>
1085     <varlistentry>
1086      <term><literal>opensearch_client</literal> (sink)</term>
1087      <listitem>
1088       <para>
1089        A9 OpenSearch searching and retrieval.
1090       </para>
1091      </listitem>
1092     </varlistentry>
1093    </variablelist>
1094   </section>
1095  </chapter>
1096  
1097  
1098  
1099  <chapter id="configuration">
1100   <title>Configuration: the Metaproxy configuration file format</title>
1101   
1102   
1103   <section id="configuration-introductory-notes">
1104    <title>Introductory notes</title>
1105    <para>
1106     If Metaproxy is an interpreter providing operations on packages, then
1107     its configuration file can be thought of as a program for that
1108     interpreter.  Configuration is by means of a single XML file, the name
1109     of which is supplied as the sole command-line argument to the
1110     <command>metaproxy</command> program.  (See
1111     <xref linkend="reference"/> below for more information on invoking
1112     Metaproxy.)
1113    </para>
1114   </section>
1115   
1116   <section id="overview.xml.structure">
1117    <title>Overview of the config file XML structure</title>
1118    <para>
1119     All elements and attributes are in the namespace
1120     <ulink url="http://indexdata.com/metaproxy"/>.
1121      This is most easily achieved by setting the default namespace on
1122      the top-level element, as here:
1123    </para>
1124    <screen>
1125     &lt;metaproxy xmlns="http://indexdata.com/metaproxy" version="1.0"&gt;
1126    </screen>
1127    <para>
1128     The top-level element is &lt;metaproxy&gt;.  This contains a
1129     &lt;start&gt; element, a &lt;filters&gt; element and a
1130     &lt;routes&gt; element, in that order.  &lt;filters&gt; is
1131     optional; the other two are mandatory.  All three are
1132     non-repeatable.
1133    </para>
1134   <para>
1135     The &lt;start&gt; element is empty, but carries a
1136     <literal>route</literal> attribute, whose value is the name of
1137     route at which to start running - analogous to the name of the
1138     start production in a formal grammar.
1139    </para>
1140   <para>
1141     If present, &lt;filters&gt; contains zero or more &lt;filter&gt;
1142     elements.  Each filter carries a <literal>type</literal> attribute
1143     which specifies what kind of filter is being defined
1144     (<literal>frontend_net</literal>, <literal>log</literal>, etc.)
1145     and contain various elements that provide suitable configuration
1146     for a filter of its type.  The filter-specific elements are
1147     described in
1148     <xref linkend="reference"/>.
1149     Filters defined in this part of the file must carry an
1150     <literal>id</literal> attribute so that they can be referenced
1151     from elsewhere.
1152    </para>
1153    <para>
1154     &lt;routes&gt; contains one or more &lt;route&gt; elements, each
1155     of which must carry an <literal>id</literal> element.  One of the
1156     routes must have the ID value that was specified as the start
1157     route in the &lt;start&gt; element's <literal>route</literal>
1158     attribute.  Each route contains zero or more &lt;filter&gt;
1159     elements.  These are of two types.  They may be empty, but carry a
1160     <literal>refid</literal> attribute whose value is the same as the
1161     <literal>id</literal> of a filter previously defined in the
1162     &lt;filters&gt; section.  Alternatively, a route within a filter
1163     may omit the <literal>refid</literal> attribute, but contain
1164     configuration elements similar to those used for filters defined
1165     in the &lt;filters&gt; section.  (In other words, each filter in a
1166     route may be included either by reference or by physical
1167     inclusion.)
1168    </para>
1169   </section>
1170
1171
1172   <section id="example.configuration">
1173    <title>An example configuration</title>
1174    <para>
1175     The following is a small, but complete, Metaproxy configuration
1176     file (included in the distribution as
1177     <literal>metaproxy/etc/config1.xml</literal>).
1178     This file defines a very simple configuration that simply proxies
1179     to whatever back-end server the client requests, but logs each
1180     request and response.  This can be useful for debugging complex
1181     client-server dialogues.
1182    </para>
1183    <screen><![CDATA[<?xml version="1.0"?>
1184 <metaproxy xmlns="http://indexdata.com/metaproxy" version="1.0">
1185   <start route="start"/>
1186   <filters>
1187     <filter id="frontend" type="frontend_net">
1188       <port>@:9000</port>
1189     </filter>
1190     <filter id="backend" type="z3950_client">
1191     </filter>
1192   </filters>
1193   <routes>  
1194     <route id="start">
1195       <filter refid="frontend"/>
1196       <filter type="log"/>
1197       <filter refid="backend"/>
1198       <filter type="bounce"/>
1199     </route>
1200   </routes>
1201 </metaproxy>
1202 ]]></screen>
1203    <para>
1204     It works by defining a single route, called
1205     <literal>start</literal>, which consists of a sequence of four
1206     filters.  The first and last of these are included by reference:
1207     their <literal>&lt;filter&gt;</literal> elements have
1208     <literal>refid</literal> attributes that refer to filters defined
1209     within the prior <literal>&lt;filters&gt;</literal> section.  The
1210     middle filter is included inline in the route.
1211    </para>
1212    <para>
1213     The four filters in the route are as follows: first, a
1214     <literal>frontend_net</literal> filter accepts Z39.50 requests
1215     from any host on port 9000; then these requests are passed through
1216     a <literal>log</literal> filter that emits a message for each
1217     request; they are then fed into a <literal>z3950_client</literal>
1218     filter, which forwards all Z39.50 requests to the client-specified
1219     back-end Z39.509 server. Those Z39.50 packages are returned by the
1220     <literal>z3950_client</literal> filter, with the response data
1221     filled by the external Z39.50 server targeted.
1222     All non-Z39.50 packages are passed through to the
1223     <literal>bounce</literal> filter, which definitely bounces
1224     everything, including fish, bananas, cold pyjamas,
1225     mutton, beef and trout packages.
1226     When the response arrives, it is handed
1227     back to the <literal>log</literal> filter, which emits another
1228     message; and then to the <literal>frontend_net</literal> filter, 
1229     which returns the response to the client.
1230    </para>
1231   </section>
1232
1233   <section id="config-file-modularity">
1234    <title>Config file modularity</title>
1235    <para>
1236     Metaproxy XML configuration snippets can be reused by other
1237     filters using the <literal>XInclude</literal> standard, as seen in
1238     the <literal>/etc/config-sru-to-z3950.xml</literal> example SRU 
1239     configuration.
1240    <screen><![CDATA[
1241     <filter id="sru" type="sru_z3950">
1242       <database name="Default">
1243        <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
1244                     href="explain.xml"/>
1245       </database>
1246     </filter>
1247 ]]></screen>
1248     </para>
1249   </section>
1250
1251   <section id="config-file-syntax-check">
1252    <title>Config file syntax checking</title>
1253    <para>
1254     The distribution contains RelaxNG Compact and XML syntax checking
1255     files, as well as XML Schema files. These are found in the
1256     distribution paths 
1257    <screen>
1258     xml/schema/metaproxy.rnc
1259     xml/schema/metaproxy.rng
1260     xml/schema/metaproxy.xsd
1261    </screen>
1262     and can be used to verify or debug the XML structure of
1263     configuration files. For example, using the utility
1264     <filename>xmllint</filename>, syntax checking is done like this:
1265    <screen>
1266     xmllint --noout --schema xml/schema/metaproxy.xsd etc/config-local.xml 
1267     xmllint --noout --relaxng xml/schema/metaproxy.rng etc/config-local.xml 
1268    </screen>
1269     (A recent version of <literal>libxml2</literal> is required, as
1270     support for XML Schemas is a relatively recent addition.)
1271    </para>
1272    <para>
1273     You can of course use any other RelaxNG or XML Schema compliant tool
1274     you wish.
1275    </para>
1276    </section>
1277  </chapter>
1278
1279
1280
1281  <chapter id="multidb">
1282   <title>Virtual databases and multi-database searching</title>
1283
1284
1285   <section id="multidb-introductory-notes">
1286    <title>Introductory notes</title>
1287    <para>
1288     Two of Metaproxy's filters are concerned with multiple-database
1289     operations.  Of these, <literal>virt_db</literal> can work alone
1290     to control the routing of searches to one of a number of servers,
1291     while <literal>multi</literal> can work together with
1292     <literal>virt_db</literal> to perform multi-database searching, merging
1293     the results into a unified result-set - ``metasearch in a box''.
1294    </para>
1295    <para>
1296     The interaction between
1297     these two filters is necessarily complex: it reflects the real,
1298     irreducible complexity of multi-database searching in a protocol such
1299     as Z39.50 that separates initialization from searching, and in
1300     which the database to be searched is not known at initialization
1301     time.
1302    </para>
1303    <para>
1304     It's possible to use these filters without understanding the
1305     details of their functioning and the interaction between them; the
1306     next two sections of this chapter are ``HOW-TO'' guides for doing
1307     just that.  However, debugging complex configurations will require
1308     a deeper understanding, which the last two sections of this
1309     chapters attempt to provide.
1310    </para>
1311   </section>
1312
1313
1314   <section id="multidb.virt_db">
1315    <title>Virtual databases with the <literal>virt_db</literal> filter</title>
1316    <para>
1317     Working alone, the purpose of the
1318     <literal>virt_db</literal>
1319     filter is to route search requests to one of a selection of
1320     back-end databases.  In this way, a single Z39.50 endpoint
1321     (running Metaproxy) can provide access to several different
1322     underlying services, including those that would otherwise be
1323     inaccessible due to firewalls.  In many useful configurations, the
1324     back-end databases are local to the Metaproxy installation, but
1325     the software does not enforce this, and any valid Z39.50 servers
1326     may be used as back-ends.
1327    </para>
1328    <para>
1329     For example, a <literal>virt_db</literal>
1330     filter could be set up so that searches in the virtual database
1331     ``lc'' are forwarded to the Library of Congress bibliographic
1332     catalogue server, and searches in the virtual database ``marc''
1333     are forwarded to the toy database of MARC records that Index Data
1334     hosts for testing purposes.  A <literal>virt_db</literal>
1335     configuration to make this switch would look like this:
1336    </para>
1337    <screen><![CDATA[<filter type="virt_db">
1338   <virtual>
1339     <database>lc</database>
1340     <target>z3950.loc.gov:7090/voyager</target>
1341   </virtual>
1342   <virtual>
1343     <database>marc</database>
1344     <target>indexdata.com/marc</target>
1345   </virtual>
1346 </filter>]]></screen>
1347    <para>
1348     As well as being useful in it own right, this filter also provides
1349     the foundation for multi-database searching.
1350    </para>
1351   </section>
1352
1353
1354   <section id="multidb.multi">
1355    <title>Multi-database search with the <literal>multi</literal> filter</title>
1356    <para>
1357     To arrange for Metaproxy to broadcast searches to multiple back-end
1358     servers, the configuration needs to include two components: a
1359     <literal>virt_db</literal>
1360     filter that specifies multiple
1361     <literal>&lt;target&gt;</literal>
1362     elements, and a subsequent
1363     <literal>multi</literal>
1364     filter.  Here, for example, is a complete configuration that
1365     broadcasts searches to both the Library of Congress catalogue and
1366     Index Data's tiny testing database of MARC records:
1367    </para>
1368    <screen><![CDATA[<?xml version="1.0"?>
1369 <metaproxy xmlns="http://indexdata.com/metaproxy" version="1.0">
1370   <start route="start"/>
1371   <routes>
1372     <route id="start">
1373       <filter type="frontend_net">
1374         <threads>10</threads>
1375         <port>@:9000</port>
1376       </filter>
1377       <filter type="virt_db">
1378         <virtual>
1379           <database>lc</database>
1380           <target>z3950.loc.gov:7090/voyager</target>
1381         </virtual>
1382         <virtual>
1383           <database>marc</database>
1384           <target>indexdata.com/marc</target>
1385         </virtual>
1386         <virtual>
1387           <database>all</database>
1388           <target>z3950.loc.gov:7090/voyager</target>
1389           <target>indexdata.com/marc</target>
1390         </virtual>
1391       </filter>
1392       <filter type="multi"/>
1393       <filter type="z3950_client">
1394         <timeout>30</timeout>
1395       </filter>
1396       <filter type="bounce"/>
1397     </route>
1398   </routes>
1399 </metaproxy>]]></screen>
1400    <para>
1401     (Using a
1402     <literal>virt_db</literal>
1403     filter that specifies multiple
1404     <literal>&lt;target&gt;</literal>
1405     elements but without a subsequent
1406     <literal>multi</literal>
1407     filter yields surprising and undesirable results, as will be
1408     described below.  Don't do that.)
1409    </para>
1410    <para>
1411     Metaproxy can be invoked with this configuration as follows:
1412    </para>
1413    <screen>../src/metaproxy --config config-simple-multi.xml</screen>
1414    <para>
1415     And thereafter, Z39.50 clients can connect to the running server
1416     (on port 9000, as specified in the configuration) and search in
1417     any of the databases
1418     <literal>lc</literal> (the Library of Congress catalogue),
1419     <literal>marc</literal> (Index Data's test database of MARC records)
1420     or
1421     <literal>all</literal> (both of these).  As an example, a session
1422     using the YAZ command-line client <literal>yaz-client</literal> is
1423     here included (edited for brevity and clarity):
1424    </para>
1425    <screen><![CDATA[$ yaz-client @:9000
1426 Connecting...OK.
1427 Z> base lc
1428 Z> find computer
1429 Search was a success.
1430 Number of hits: 10000, setno 1
1431 Elapsed: 5.521070
1432 Z> base marc
1433 Z> find computer
1434 Search was a success.
1435 Number of hits: 10, setno 3
1436 Elapsed: 0.060187
1437 Z> base all
1438 Z> find computer
1439 Search was a success.
1440 Number of hits: 10010, setno 4
1441 Elapsed: 2.237648
1442 Z> show 1
1443 [marc]Record type: USmarc
1444 001    11224466
1445 003 DLC
1446 005 00000000000000.0
1447 008 910710c19910701nju           00010 eng
1448 010    $a 11224466
1449 040    $a DLC $c DLC
1450 050 00 $a 123-xyz
1451 100 10 $a Jack Collins
1452 245 10 $a How to program a computer
1453 260 1  $a Penguin
1454 263    $a 8710
1455 300    $a p. cm.
1456 Elapsed: 0.119612
1457 Z> show 2
1458 [VOYAGER]Record type: USmarc
1459 001 13339105
1460 005 20041229102447.0
1461 008 030910s2004    caua          000 0 eng
1462 035    $a (DLC)  2003112666
1463 906    $a 7 $b cbc $c orignew $d 4 $e epcn $f 20 $g y-gencatlg
1464 925 0  $a acquire $b 1 shelf copy $x policy default
1465 955    $a pc10 2003-09-10 $a pv12 2004-06-23 to SSCD; $h sj05 2004-11-30 $e sj05 2004-11-30 to Shelf.
1466 010    $a   2003112666
1467 020    $a 0761542892
1468 040    $a DLC $c DLC $d DLC
1469 050 00 $a MLCM 2004/03312 (G)
1470 245 10 $a 007, everything or nothing : $b Prima's official strategy guide / $c created by Kaizen Media Group.
1471 246 3  $a Double-O-seven, everything or nothing
1472 246 30 $a Prima's official strategy guide
1473 260    $a Roseville, CA : $b Prima Games, $c c2004.
1474 300    $a 161 p. : $b col. ill. ; $c 28 cm.
1475 500    $a "Platforms: Nintendo GameCube, Macintosh, PC, PlayStation 2 computer entertainment system, Xbox"--P. [4] of cover.
1476 650  0 $a Video games.
1477 710 2  $a Kaizen Media Group.
1478 856 42 $3 Publisher description $u http://www.loc.gov/catdir/description/random052/2003112666.html
1479 Elapsed: 0.150623
1480 Z>
1481 ]]></screen>
1482    <para>
1483     As can be seen, the first record in the result set is from the
1484     Index Data test database, and the second from the Library of
1485     Congress database.  The result-set continues alternating records
1486     round-robin style until the point where one of the databases'
1487     records are exhausted.
1488    </para>
1489    <para>
1490     This example uses only two back-end databases; more may be used.
1491     There is no limitation imposed on the number of databases that may
1492     be metasearched in this way: issues of resource usage and
1493     administrative complexity dictate the practical limits.
1494    </para>
1495    <para>
1496     What happens when one of the databases doesn't respond?  By default,
1497     the entire multi-database search fails, and the appropriate
1498     diagnostic is returned to the client.  This is usually appropriate
1499     during development, when technicians need maximum information, but
1500     can be inconvenient in deployment, when users typically don't want
1501     to be bothered with problems of this kind and prefer just to get
1502     the records from the databases that are available.  To obtain this
1503     latter behavior add an empty
1504     <literal>&lt;hideunavailable&gt;</literal>
1505     element inside the
1506     <literal>multi</literal> filter:
1507    </para>
1508    <screen><![CDATA[      <filter type="multi">
1509         <hideunavailable/>
1510       </filter>]]></screen>
1511    <para>
1512     Under this regime, an error is reported to the client only if
1513     <emphasis>all</emphasis> the databases in a multi-database search
1514     are unavailable.
1515    </para>
1516   </section>
1517
1518
1519   <section id="multidb.what">
1520    <title>What's going on?</title>
1521    <warning>
1522     <title>Lark's vomit</title>
1523     <para>
1524      This section goes into a level of technical detail that is
1525      probably not necessary in order to configure and use Metaproxy.
1526      It is provided only for those who like to know how things work.
1527      You should feel free to skip on to the next section if this one
1528      doesn't seem like fun.
1529     </para>
1530    </warning>
1531    <para>
1532     Hold on tight - this may get a little hairy.
1533    </para>
1534    <para>
1535     In the general course of things, a Z39.50 Init request may carry
1536     with it an otherInfo packet of type <literal>VAL_PROXY</literal>,
1537     whose value indicates the address of a Z39.50 server to which the
1538     ultimate connection is to be made.  (This otherInfo packet is
1539     supported by YAZ-based Z39.50 clients and servers, but has not yet
1540     been ratified by the Maintenance Agency and so is not widely used
1541     in non-Index Data software.  We're working on it.)
1542     The <literal>VAL_PROXY</literal> packet functions
1543     analogously to the absoluteURI-style Request-URI used with the GET
1544     method when a web browser asks a proxy to forward its request: see
1545     the
1546     <ulink url="http://www.w3.org/Protocols/rfc2616/rfc2616-sec5.html#sec5.1.2"
1547            >Request-URI</ulink>
1548     section of
1549     <ulink url="http://www.w3.org/Protocols/rfc2616/rfc2616.html"
1550            >the HTTP 1.1 specification</ulink>.
1551    </para>
1552    <para>
1553     Within Metaproxy, Search requests that are part of the same
1554     session as an Init request that carries a
1555     <literal>VAL_PROXY</literal> otherInfo are also annotated with the
1556     same information.  The role of the <literal>virt_db</literal>
1557     filter is to rewrite this otherInfo packet dependent on the
1558     virtual database that the client wants to search.
1559    </para>
1560    <para>
1561     When Metaproxy receives a Z39.50 Init request from a client, it
1562     doesn't immediately forward that request to the back-end server.
1563     Why not?  Because it doesn't know <emphasis>which</emphasis>
1564     back-end server to forward it to until the client sends a Search
1565     request that specifies the database that it wants to search in.
1566     Instead, it just treasures the Init request up in its heart; and,
1567     later, the first time the client does a search on one of the
1568     specified virtual databases, a connection is forged to the
1569     appropriate server and the Init request is forwarded to it.  If,
1570     later in the session, the same client searches in a different
1571     virtual database, then a connection is forged to the server that
1572     hosts it, and the same cached Init request is forwarded there,
1573     too.
1574    </para>
1575    <para>
1576     All of this clever Init-delaying is done by the
1577     <literal>frontend_net</literal> filter.  The
1578     <literal>virt_db</literal> filter knows nothing about it; in
1579     fact, because the Init request that is received from the client
1580     doesn't get forwarded until a Search request is received, the
1581     <literal>virt_db</literal> filter (and the
1582     <literal>z3950_client</literal> filter behind it) doesn't even get
1583     invoked at Init time.  The <emphasis>only</emphasis> thing that a
1584     <literal>virt_db</literal> filter ever does is rewrite the
1585     <literal>VAL_PROXY</literal> otherInfo in the requests that pass
1586     through it.
1587    </para>
1588    <para>
1589     It is possible for a <literal>virt_db</literal> filter to contain
1590     multiple
1591     <literal>&lt;target&gt;</literal>
1592     elements.  What does this mean?  Only that the filter will add
1593     multiple <literal>VAL_PROXY</literal> otherInfo packets to the
1594     Search requests that pass through it.  That's because the virtual
1595     DB filter is dumb, and does exactly what it's told - no more, no
1596     less.
1597     If a Search request with multiple <literal>VAL_PROXY</literal>
1598     otherInfo packets reaches a <literal>z3950_client</literal>
1599     filter, this is an error.  That filter doesn't know how to deal
1600     with multiple targets, so it will either just pick one and search
1601     in it, or (better) fail with an error message.
1602    </para>
1603    <para>
1604     The <literal>multi</literal> filter comes to the rescue!  This is
1605     the only filter that knows how to deal with multiple
1606     <literal>VAL_PROXY</literal> otherInfo packets, and it does so by
1607     making multiple copies of the entire Search request: one for each
1608     <literal>VAL_PROXY</literal>.  Each of these new copies is then
1609     passed down through the remaining filters in the route.  (The
1610     copies are handled in parallel though the
1611     spawning of new threads.)  Since the copies each have only one
1612     <literal>VAL_PROXY</literal> otherInfo, they can be handled by the
1613     <literal>z3950_client</literal> filter, which happily deals with
1614     each one individually.  When the results of the individual
1615     searches come back up to the <literal>multi</literal> filter, it
1616     merges them into a single Search response, which is what
1617     eventually makes it back to the client.
1618    </para>
1619   </section>
1620
1621
1622   <section id="multidb.picture">
1623    <title>A picture is worth a thousand words (but only five hundred on 64-bit architectures)</title>
1624    <simpara>
1625     <inlinemediaobject>
1626      <imageobject>
1627       <imagedata fileref="multi.pdf" format="PDF" scale="50"/>
1628      </imageobject>
1629      <imageobject>
1630       <imagedata fileref="multi.png" format="PNG"/>
1631      </imageobject>
1632      <textobject>
1633       <!-- Fall back if none of the images can be used -->
1634       <phrase>
1635        [Here there should be a diagram showing the progress of
1636        packages through the filters during a simple virtual-database
1637        search and a multi-database search, but is seems that your
1638        tool chain has not been able to include the diagram in this
1639        document.]
1640       </phrase>
1641      </textobject>
1642 <!-- ### This used to work with an older version of DocBook
1643      <caption>
1644       <para>Caption: progress of packages through filters.</para>
1645      </caption>
1646 -->
1647     </inlinemediaobject>
1648    </simpara>
1649   </section>
1650  </chapter>
1651
1652
1653  <chapter id="sru-server">
1654   <title>Combined SRU webservice and Z39.50 server configuration</title>
1655   <para>
1656    Metaproxy can act as 
1657    <ulink url="&url.sru;">SRU</ulink> and 
1658    web service server, which translates web service requests to 
1659    <ulink url="&url.z39.50;">ANSI/NISO Z39.50</ulink> packages and
1660    sends them off to common available targets.
1661   </para>
1662   <para>
1663   A typical setup for this operation needs a filter route including the
1664   following modules: 
1665   </para>
1666    
1667   <table id="sru-server-table-config" frame="top">
1668    <title>SRU/Z39.50 Server Filter Route Configuration</title>
1669    <tgroup cols="3">
1670     <thead>
1671      <row>
1672       <entry>Filter</entry>
1673       <entry>Importance</entry>
1674       <entry>Purpose</entry>
1675      </row>
1676     </thead>
1677     
1678     <tbody>
1679      <row>
1680       <entry><literal>frontend_net</literal></entry>
1681       <entry>required</entry>
1682       <entry>Accepting HTTP connections and passing them to following
1683       filters. Since this filter also accepts Z39.50 connections, the
1684       server works as SRU and Z39.50 server on the same port.</entry>
1685      </row>
1686      <row>
1687       <entry><literal>sru_z3950</literal></entry>
1688       <entry>required</entry>
1689       <entry>Accepting SRU GET/POST/SOAP explain and
1690        searchRetrieve requests for the the configured databases.
1691        Explain requests are directly served from the static XML configuration.
1692        SearchRetrieve requests are
1693        transformed  to Z39.50 search and present packages.
1694        All other HTTP and Z39.50 packages are passed unaltered.</entry>
1695      </row>
1696      <row>
1697       <entry><literal>http_file</literal></entry>
1698       <entry>optional</entry>
1699       <entry>Serving HTTP requests from the filesystem. This is only
1700       needed if the server should serve XSLT stylesheets, static HTML
1701       files or Java Script for thin browser based clients.
1702        Z39.50 packages are passed unaltered.</entry>
1703      </row>
1704      <row>
1705       <entry><literal>cql_rpn</literal></entry>
1706       <entry>required</entry>
1707       <entry>Usually, Z39.50 servers do not talk CQL, hence the
1708       translation of the CQL query language to RPN is mandatory in
1709       most cases. Affects only  Z39.50 search packages.</entry>
1710      </row>
1711      <row>
1712       <entry><literal>record_transform</literal></entry>
1713       <entry>optional</entry>
1714       <entry>Some Z39.50 backend targets can not present XML record
1715       syntaxes in common wanted element sets. using this filter, one
1716       can transform binary MARC records to MARCXML records, and
1717       further transform those to any needed XML schema/format by XSLT
1718       transformations. Changes only  Z39.50 present packages.</entry>
1719      </row>
1720      <row>
1721       <entry><literal>session_shared</literal></entry>
1722       <entry>optional</entry>
1723       <entry>The stateless nature of web services requires frequent
1724       re-searching of the same targets for display of paged result set
1725       records. This might be an unacceptable burden for the accessed
1726       backend Z39.50 targets, and this mosule can be added for
1727       efficient backend target resource pooling.</entry>
1728      </row>
1729      <row>
1730       <entry><literal>z3950_client</literal></entry>
1731       <entry>required</entry>
1732       <entry>Finally, a Z39.50 package sink is needed in the filter
1733       chain to provide the response packages. The Z39.50 client module
1734       is used to access external targets over the network, but any
1735       coming local Z39.50 package sink could be used instead of.</entry>
1736      </row>
1737      <row>
1738       <entry><literal>bounce</literal></entry>
1739       <entry>required</entry>
1740       <entry>Any Metaproxy package arriving here did not do so by
1741       purpose, and is bounced back with connection closure. this
1742       prevents inifinite package hanging inside the SRU server.</entry>
1743      </row>
1744     </tbody>
1745    </tgroup>
1746   </table>
1747   <para> 
1748    A typical minimal example <ulink url="&url.sru;">SRU</ulink>
1749    server configuration file is found in the tarball distribution at 
1750    <literal>etc/config-sru-to-z3950.xml</literal>.
1751   </para> 
1752   <para>
1753    Off course, any other metaproxy modules can be integrated into a
1754    SRU server solution, including, but not limited to, load balancing, 
1755    multiple target querying 
1756    (see  <xref linkend="multidb"/>), and complex RPN query rewrites. 
1757   </para>
1758
1759
1760  </chapter>
1761
1762  <!--
1763  <chapter id="extensions">
1764   <title>Writing extensions for Metaproxy</title>
1765   <para>### To be written</para>
1766  </chapter>
1767  -->
1768
1769
1770
1771  <chapter id="classes">
1772   <title>Classes in the Metaproxy source code</title>
1773
1774
1775   <section id="classes-introductory-notes">
1776    <title>Introductory notes</title>
1777    <para>
1778     <emphasis>Stop!  Do not read this!</emphasis>
1779     You won't enjoy it at all.  You should just skip ahead to
1780     <xref linkend="reference"/>,
1781     which tells
1782     <!-- The remainder of this paragraph is lifted verbatim from
1783     Douglas Adams' _Hitch Hiker's Guide to the Galaxy_, chapter 8 -->
1784     you things you really need to know, like the fact that the
1785     fabulously beautiful planet Bethselamin is now so worried about
1786     the cumulative erosion by ten billion visiting tourists a year
1787     that any net imbalance between the amount you eat and the amount
1788     you excrete whilst on the planet is surgically removed from your
1789     bodyweight when you leave: so every time you go to the lavatory it
1790     is vitally important to get a receipt.
1791    </para>
1792    <para>
1793     This chapter contains documentation of the Metaproxy source code, and is
1794     of interest only to maintainers and developers.  If you need to
1795     change Metaproxy's behavior or write a new filter, then you will most
1796     likely find this chapter helpful.  Otherwise it's a waste of your
1797     good time.  Seriously: go and watch a film or something.
1798     <citetitle>This is Spinal Tap</citetitle> is particularly good.
1799    </para>
1800    <para>
1801     Still here?  OK, let's continue.
1802    </para>
1803    <para>
1804     In general, classes seem to be named big-endianly, so that
1805     <literal>FactoryFilter</literal> is not a filter that filters
1806     factories, but a factory that produces filters; and
1807     <literal>FactoryStatic</literal> is a factory for the statically
1808     registered filters (as opposed to those that are dynamically
1809     loaded).
1810    </para>
1811   </section>
1812
1813   <section id="individual.classes">
1814    <title>Individual classes</title>
1815    <para>
1816     The classes making up the Metaproxy application are here listed by
1817     class-name, with the names of the source files that define them in
1818     parentheses.
1819    </para>
1820
1821    <section id="class-FactoryFilter">
1822     <title><literal>mp::FactoryFilter</literal>
1823      (<filename>factory_filter.cpp</filename>)</title>
1824     <para>
1825      A factory class that exists primarily to provide the
1826      <literal>create()</literal> method, which takes the name of a
1827      filter class as its argument and returns a new filter of that
1828      type.  To enable this, the factory must first be populated by
1829      calling <literal>add_creator()</literal> for static filters (this
1830      is done by the <literal>FactoryStatic</literal> class, see below)
1831      and <literal>add_creator_dyn()</literal> for filters loaded
1832      dynamically.
1833     </para>
1834    </section>
1835
1836    <section id="class-FactoryStatic">
1837     <title><literal>mp::FactoryStatic</literal>
1838      (<filename>factory_static.cpp</filename>)</title>
1839     <para>
1840      A subclass of <literal>FactoryFilter</literal> which is
1841      responsible for registering all the statically defined filter
1842      types.  It does this by knowing about all those filters'
1843      structures, which are listed in its constructor.  Merely
1844      instantiating this class registers all the static classes.  It is
1845      for the benefit of this class that <literal>struct
1846       metaproxy_1_filter_struct</literal> exists, and that all the filter
1847      classes provide a static object of that type.
1848     </para>
1849    </section>
1850
1851    <section id="class-filter-Base">
1852     <title><literal>mp::filter::Base</literal>
1853      (<filename>filter.cpp</filename>)</title>
1854     <para>
1855      The virtual base class of all filters.  The filter API is, on the
1856      surface at least, extremely simple: two methods.
1857      <literal>configure()</literal> is passed an XML DOM tree representing
1858      that part of the configuration file that pertains to this filter
1859      instance, and is expected to walk that tree extracting relevant
1860      information.  And <literal>process()</literal> processes a
1861      package (see below).  That surface simplicity is a bit
1862      misleading, as <literal>process()</literal> needs to know a lot
1863      about the <literal>Package</literal> class in order to do
1864      anything useful.
1865     </para>
1866    </section>
1867
1868    <section id="class-AuthSimple">
1869     <title><literal>mp::filter::AuthSimple</literal>,
1870      <literal>Backend_test</literal>, etc.
1871      (<filename>filter_auth_simple.cpp</filename>,
1872      <filename>filter_backend_test.cpp</filename>, etc.)</title>
1873     <para>
1874      Individual filters.  Each of these is implemented by a header and
1875      a source file, named <filename>filter_*.hpp</filename> and
1876      <filename>filter_*.cpp</filename> respectively.  All the header
1877      files should be pretty much identical, in that they declare the
1878      class, including a private <literal>Rep</literal> class and a
1879      member pointer to it, and the two public methods.
1880     </para>
1881     <para>
1882      The source file for each filter needs to supply:
1883     </para>
1884     <itemizedlist>
1885      <listitem>
1886       <para>
1887        A definition of the private <literal>Rep</literal> class.
1888       </para>
1889      </listitem>
1890      <listitem>
1891       <para>
1892        Some boilerplate constructors and destructors.
1893       </para>
1894      </listitem>
1895      <listitem>
1896       <para>
1897        A <literal>configure()</literal> method that uses the
1898        appropriate XML fragment.
1899       </para>
1900      </listitem>
1901      <listitem>
1902       <para>
1903        Most important, the <literal>process()</literal> method that
1904        does all the actual work.
1905       </para>
1906      </listitem>
1907     </itemizedlist>
1908    </section>
1909
1910    <section id="class-Package">
1911     <title><literal>mp::Package</literal>
1912      (<filename>package.cpp</filename>)</title>
1913     <para>
1914      Represents a package on its way through the series of filters
1915      that make up a route.  This is essentially a Z39.50 or SRU APDU
1916      together with information about where it came from, which is
1917      modified as it passes through the various filters.
1918     </para>
1919    </section>
1920
1921    <section id="class-Pipe">
1922     <title><literal>mp::Pipe</literal>
1923      (<filename>pipe.cpp</filename>)</title>
1924     <para>
1925      This class provides a compatibility layer so that we have an IPC
1926      mechanism that works the same under Unix and Windows.  It's not
1927      particularly exciting.
1928     </para>
1929    </section>
1930
1931    <section id="class-RouterChain">
1932     <title><literal>mp::RouterChain</literal>
1933      (<filename>router_chain.cpp</filename>)</title>
1934     <para>
1935      ### to be written
1936     </para>
1937    </section>
1938
1939    <section id="class-RouterFleXML">
1940     <title><literal>mp::RouterFleXML</literal>
1941      (<filename>router_flexml.cpp</filename>)</title>
1942     <para>
1943      ### to be written
1944     </para>
1945    </section>
1946
1947    <section id="class-Session">
1948     <title><literal>mp::Session</literal>
1949      (<filename>session.cpp</filename>)</title>
1950     <para>
1951      ### to be written
1952     </para>
1953    </section>
1954
1955    <section id="class-ThreadPoolSocketObserver">
1956     <title><literal>mp::ThreadPoolSocketObserver</literal>
1957      (<filename>thread_pool_observer.cpp</filename>)</title>
1958     <para>
1959      ### to be written
1960     </para>
1961    </section>
1962
1963    <section id="class-util">
1964     <title><literal>mp::util</literal>
1965      (<filename>util.cpp</filename>)</title>
1966     <para>
1967      A namespace of various small utility functions and classes,
1968      collected together for convenience.  Most importantly, includes
1969      the <literal>mp::util::odr</literal> class, a wrapper for YAZ's
1970      ODR facilities.
1971     </para>
1972    </section>
1973
1974    <section id="class-xml">
1975     <title><literal>mp::xml</literal>
1976      (<filename>xmlutil.cpp</filename>)</title>
1977     <para>
1978      A namespace of various XML utility functions and classes,
1979      collected together for convenience.
1980     </para>
1981    </section>
1982   </section>
1983
1984
1985   <section id="other.source.files">
1986    <title>Other Source Files</title>
1987    <para>
1988     In addition to the Metaproxy source files that define the classes
1989     described above, there are a few additional files which are
1990     briefly described here:
1991    </para>
1992    <variablelist>
1993     <varlistentry>
1994      <term><literal>metaproxy_prog.cpp</literal></term>
1995      <listitem>
1996       <para>
1997        The main function of the <command>metaproxy</command> program.
1998       </para>
1999      </listitem>
2000     </varlistentry>
2001     <varlistentry>
2002      <term><literal>ex_router_flexml.cpp</literal></term>
2003      <listitem>
2004       <para>
2005        Identical to <literal>metaproxy_prog.cpp</literal>: it's not clear why.
2006       </para>
2007      </listitem>
2008     </varlistentry>
2009     <varlistentry>
2010      <term><literal>test_*.cpp</literal></term>
2011      <listitem>
2012       <para>
2013        Unit-tests for various modules.
2014       </para>
2015      </listitem>
2016     </varlistentry>
2017    </variablelist>
2018    <para>
2019     ### Still to be described:
2020     <literal>ex_filter_frontend_net.cpp</literal>,
2021     <literal>filter_dl.cpp</literal>,
2022     <literal>plainfile.cpp</literal>,
2023     <literal>tstdl.cpp</literal>.
2024    </para>
2025   </section>
2026  </chapter>
2027  
2028  
2029  <reference id="reference">
2030   <title>Reference</title>
2031    <partintro id="reference-introduction">
2032     <para>
2033      The material in this chapter is drawn directly from the individual
2034      manual entries.  In particular, the Metaproxy invocation section is
2035      available using <command>man metaproxy</command>, and the section
2036      on each individual filter is available using the name of the filter
2037      as the argument to the <command>man</command> command.
2038     </para>
2039    </partintro>
2040    &manref;
2041  </reference>
2042
2043 <appendix id="license">
2044  <title>License</title>
2045
2046   <para>
2047    Metaproxy, Copyright &copy; 1995-2007 Index Data ApS.
2048  </para>
2049
2050   <para>
2051    Metaproxy is free software; you can redistribute it and/or modify it under
2052    the terms of the GNU General Public License as published by the Free
2053    Software Foundation; either version 2, or (at your option) any later
2054    version.
2055    </para>
2056
2057   <para>
2058    Metaproxy is distributed in the hope that it will be useful, but WITHOUT ANY
2059    WARRANTY; without even the implied warranty of MERCHANTABILITY or
2060    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
2061    for more details.
2062   </para>
2063   
2064   <para>
2065    You should have received a copy of the GNU General Public License
2066    along with Metaproxy; see the file LICENSE.  If not, write to the
2067    Free Software Foundation, 
2068    51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
2069    </para>
2070   
2071   <sect1 id="gpl">
2072    <title>GNU General Public License</title>
2073    <screen>
2074                     GNU GENERAL PUBLIC LICENSE
2075                        Version 2, June 1991
2076
2077  Copyright (C) 1989, 1991 Free Software Foundation, Inc.
2078                        51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
2079 w Everyone is permitted to copy and distribute verbatim copies
2080  of this license document, but changing it is not allowed.
2081
2082                             Preamble
2083
2084   The licenses for most software are designed to take away your
2085 freedom to share and change it.  By contrast, the GNU General Public
2086 License is intended to guarantee your freedom to share and change free
2087 software--to make sure the software is free for all its users.  This
2088 General Public License applies to most of the Free Software
2089 Foundation's software and to any other program whose authors commit to
2090 using it.  (Some other Free Software Foundation software is covered by
2091 the GNU Library General Public License instead.)  You can apply it to
2092 your programs, too.
2093
2094   When we speak of free software, we are referring to freedom, not
2095 price.  Our General Public Licenses are designed to make sure that you
2096 have the freedom to distribute copies of free software (and charge for
2097 this service if you wish), that you receive source code or can get it
2098 if you want it, that you can change the software or use pieces of it
2099 in new free programs; and that you know you can do these things.
2100
2101   To protect your rights, we need to make restrictions that forbid
2102 anyone to deny you these rights or to ask you to surrender the rights.
2103 These restrictions translate to certain responsibilities for you if you
2104 distribute copies of the software, or if you modify it.
2105
2106   For example, if you distribute copies of such a program, whether
2107 gratis or for a fee, you must give the recipients all the rights that
2108 you have.  You must make sure that they, too, receive or can get the
2109 source code.  And you must show them these terms so they know their
2110 rights.
2111
2112   We protect your rights with two steps: (1) copyright the software, and
2113 (2) offer you this license which gives you legal permission to copy,
2114 distribute and/or modify the software.
2115
2116   Also, for each author's protection and ours, we want to make certain
2117 that everyone understands that there is no warranty for this free
2118 software.  If the software is modified by someone else and passed on, we
2119 want its recipients to know that what they have is not the original, so
2120 that any problems introduced by others will not reflect on the original
2121 authors' reputations.
2122
2123   Finally, any free program is threatened constantly by software
2124 patents.  We wish to avoid the danger that redistributors of a free
2125 program will individually obtain patent licenses, in effect making the
2126 program proprietary.  To prevent this, we have made it clear that any
2127 patent must be licensed for everyone's free use or not licensed at all.
2128
2129   The precise terms and conditions for copying, distribution and
2130 modification follow.
2131
2132                     GNU GENERAL PUBLIC LICENSE
2133    TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
2134
2135   0. This License applies to any program or other work which contains
2136 a notice placed by the copyright holder saying it may be distributed
2137 under the terms of this General Public License.  The "Program", below,
2138 refers to any such program or work, and a "work based on the Program"
2139 means either the Program or any derivative work under copyright law:
2140 that is to say, a work containing the Program or a portion of it,
2141 either verbatim or with modifications and/or translated into another
2142 language.  (Hereinafter, translation is included without limitation in
2143 the term "modification".)  Each licensee is addressed as "you".
2144
2145 Activities other than copying, distribution and modification are not
2146 covered by this License; they are outside its scope.  The act of
2147 running the Program is not restricted, and the output from the Program
2148 is covered only if its contents constitute a work based on the
2149 Program (independent of having been made by running the Program).
2150 Whether that is true depends on what the Program does.
2151
2152   1. You may copy and distribute verbatim copies of the Program's
2153 source code as you receive it, in any medium, provided that you
2154 conspicuously and appropriately publish on each copy an appropriate
2155 copyright notice and disclaimer of warranty; keep intact all the
2156 notices that refer to this License and to the absence of any warranty;
2157 and give any other recipients of the Program a copy of this License
2158 along with the Program.
2159
2160 You may charge a fee for the physical act of transferring a copy, and
2161 you may at your option offer warranty protection in exchange for a fee.
2162
2163   2. You may modify your copy or copies of the Program or any portion
2164 of it, thus forming a work based on the Program, and copy and
2165 distribute such modifications or work under the terms of Section 1
2166 above, provided that you also meet all of these conditions:
2167
2168     a) You must cause the modified files to carry prominent notices
2169     stating that you changed the files and the date of any change.
2170
2171     b) You must cause any work that you distribute or publish, that in
2172     whole or in part contains or is derived from the Program or any
2173     part thereof, to be licensed as a whole at no charge to all third
2174     parties under the terms of this License.
2175
2176     c) If the modified program normally reads commands interactively
2177     when run, you must cause it, when started running for such
2178     interactive use in the most ordinary way, to print or display an
2179     announcement including an appropriate copyright notice and a
2180     notice that there is no warranty (or else, saying that you provide
2181     a warranty) and that users may redistribute the program under
2182     these conditions, and telling the user how to view a copy of this
2183     License.  (Exception: if the Program itself is interactive but
2184     does not normally print such an announcement, your work based on
2185     the Program is not required to print an announcement.)
2186
2187 These requirements apply to the modified work as a whole.  If
2188 identifiable sections of that work are not derived from the Program,
2189 and can be reasonably considered independent and separate works in
2190 themselves, then this License, and its terms, do not apply to those
2191 sections when you distribute them as separate works.  But when you
2192 distribute the same sections as part of a whole which is a work based
2193 on the Program, the distribution of the whole must be on the terms of
2194 this License, whose permissions for other licensees extend to the
2195 entire whole, and thus to each and every part regardless of who wrote it.
2196
2197 Thus, it is not the intent of this section to claim rights or contest
2198 your rights to work written entirely by you; rather, the intent is to
2199 exercise the right to control the distribution of derivative or
2200 collective works based on the Program.
2201
2202 In addition, mere aggregation of another work not based on the Program
2203 with the Program (or with a work based on the Program) on a volume of
2204 a storage or distribution medium does not bring the other work under
2205 the scope of this License.
2206
2207   3. You may copy and distribute the Program (or a work based on it,
2208 under Section 2) in object code or executable form under the terms of
2209 Sections 1 and 2 above provided that you also do one of the following:
2210
2211     a) Accompany it with the complete corresponding machine-readable
2212     source code, which must be distributed under the terms of Sections
2213     1 and 2 above on a medium customarily used for software interchange; or,
2214
2215     b) Accompany it with a written offer, valid for at least three
2216     years, to give any third party, for a charge no more than your
2217     cost of physically performing source distribution, a complete
2218     machine-readable copy of the corresponding source code, to be
2219     distributed under the terms of Sections 1 and 2 above on a medium
2220     customarily used for software interchange; or,
2221
2222     c) Accompany it with the information you received as to the offer
2223     to distribute corresponding source code.  (This alternative is
2224     allowed only for noncommercial distribution and only if you
2225     received the program in object code or executable form with such
2226     an offer, in accord with Subsection b above.)
2227
2228 The source code for a work means the preferred form of the work for
2229 making modifications to it.  For an executable work, complete source
2230 code means all the source code for all modules it contains, plus any
2231 associated interface definition files, plus the scripts used to
2232 control compilation and installation of the executable.  However, as a
2233 special exception, the source code distributed need not include
2234 anything that is normally distributed (in either source or binary
2235 form) with the major components (compiler, kernel, and so on) of the
2236 operating system on which the executable runs, unless that component
2237 itself accompanies the executable.
2238
2239 If distribution of executable or object code is made by offering
2240 access to copy from a designated place, then offering equivalent
2241 access to copy the source code from the same place counts as
2242 distribution of the source code, even though third parties are not
2243 compelled to copy the source along with the object code.
2244
2245   4. You may not copy, modify, sublicense, or distribute the Program
2246 except as expressly provided under this License.  Any attempt
2247 otherwise to copy, modify, sublicense or distribute the Program is
2248 void, and will automatically terminate your rights under this License.
2249 However, parties who have received copies, or rights, from you under
2250 this License will not have their licenses terminated so long as such
2251 parties remain in full compliance.
2252
2253   5. You are not required to accept this License, since you have not
2254 signed it.  However, nothing else grants you permission to modify or
2255 distribute the Program or its derivative works.  These actions are
2256 prohibited by law if you do not accept this License.  Therefore, by
2257 modifying or distributing the Program (or any work based on the
2258 Program), you indicate your acceptance of this License to do so, and
2259 all its terms and conditions for copying, distributing or modifying
2260 the Program or works based on it.
2261
2262   6. Each time you redistribute the Program (or any work based on the
2263 Program), the recipient automatically receives a license from the
2264 original licensor to copy, distribute or modify the Program subject to
2265 these terms and conditions.  You may not impose any further
2266 restrictions on the recipients' exercise of the rights granted herein.
2267 You are not responsible for enforcing compliance by third parties to
2268 this License.
2269
2270   7. If, as a consequence of a court judgment or allegation of patent
2271 infringement or for any other reason (not limited to patent issues),
2272 conditions are imposed on you (whether by court order, agreement or
2273 otherwise) that contradict the conditions of this License, they do not
2274 excuse you from the conditions of this License.  If you cannot
2275 distribute so as to satisfy simultaneously your obligations under this
2276 License and any other pertinent obligations, then as a consequence you
2277 may not distribute the Program at all.  For example, if a patent
2278 license would not permit royalty-free redistribution of the Program by
2279 all those who receive copies directly or indirectly through you, then
2280 the only way you could satisfy both it and this License would be to
2281 refrain entirely from distribution of the Program.
2282
2283 If any portion of this section is held invalid or unenforceable under
2284 any particular circumstance, the balance of the section is intended to
2285 apply and the section as a whole is intended to apply in other
2286 circumstances.
2287
2288 It is not the purpose of this section to induce you to infringe any
2289 patents or other property right claims or to contest validity of any
2290 such claims; this section has the sole purpose of protecting the
2291 integrity of the free software distribution system, which is
2292 implemented by public license practices.  Many people have made
2293 generous contributions to the wide range of software distributed
2294 through that system in reliance on consistent application of that
2295 system; it is up to the author/donor to decide if he or she is willing
2296 to distribute software through any other system and a licensee cannot
2297 impose that choice.
2298
2299 This section is intended to make thoroughly clear what is believed to
2300 be a consequence of the rest of this License.
2301
2302   8. If the distribution and/or use of the Program is restricted in
2303 certain countries either by patents or by copyrighted interfaces, the
2304 original copyright holder who places the Program under this License
2305 may add an explicit geographical distribution limitation excluding
2306 those countries, so that distribution is permitted only in or among
2307 countries not thus excluded.  In such case, this License incorporates
2308 the limitation as if written in the body of this License.
2309
2310   9. The Free Software Foundation may publish revised and/or new versions
2311 of the General Public License from time to time.  Such new versions will
2312 be similar in spirit to the present version, but may differ in detail to
2313 address new problems or concerns.
2314
2315 Each version is given a distinguishing version number.  If the Program
2316 specifies a version number of this License which applies to it and "any
2317 later version", you have the option of following the terms and conditions
2318 either of that version or of any later version published by the Free
2319 Software Foundation.  If the Program does not specify a version number of
2320 this License, you may choose any version ever published by the Free Software
2321 Foundation.
2322
2323   10. If you wish to incorporate parts of the Program into other free
2324 programs whose distribution conditions are different, write to the author
2325 to ask for permission.  For software which is copyrighted by the Free
2326 Software Foundation, write to the Free Software Foundation; we sometimes
2327 make exceptions for this.  Our decision will be guided by the two goals
2328 of preserving the free status of all derivatives of our free software and
2329 of promoting the sharing and reuse of software generally.
2330
2331                             NO WARRANTY
2332
2333   11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
2334 FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
2335 OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
2336 PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
2337 OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
2338 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
2339 TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
2340 PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
2341 REPAIR OR CORRECTION.
2342
2343   12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
2344 WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
2345 REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
2346 INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
2347 OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
2348 TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
2349 YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
2350 PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
2351 POSSIBILITY OF SUCH DAMAGES.
2352
2353                      END OF TERMS AND CONDITIONS
2354
2355    </screen> 
2356   </sect1>
2357  </appendix>
2358 </book>
2359
2360  <!-- Keep this comment at the end of the file
2361  Local variables:
2362  mode: sgml
2363  sgml-omittag:t
2364  sgml-shorttag:t
2365  sgml-minimize-attributes:nil
2366  sgml-always-quote-attributes:t
2367  sgml-indent-step:1
2368  sgml-indent-data:t
2369  sgml-parent-document: nil
2370  sgml-local-catalogs: nil
2371  sgml-namecase-general:t
2372  End:
2373  -->