Trying to use Solr name consistently
[yaz-moved-to-github.git] / doc / zoom.xml
1 <!--
2 ### Still to document:
3 ZOOM_connection_errcode(c)
4 ZOOM_connection_errmsg(c)
5 ZOOM_connection_addinfo(c)
6 ZOOM_connection_addinfo(c)
7 ZOOM_connection_diagset(c);
8 ZOOM_connection_save_apdu_wrbuf
9 ZOOM_diag_str(error)
10 ZOOM_resultset_record_immediate(s, pos)
11 ZOOM_resultset_cache_reset(r)
12 ZOOM_options_set_callback(opt, function, handle)
13 ZOOM_options_create_with_parent2(parent1, parent2)
14 ZOOM_options_getl(opt, name, len)
15 ZOOM_options_setl(opt, name, value, len)
16 ZOOM_options_get_bool(opt, name, defa)
17 ZOOM_options_get_int(opt, name, defa)
18 ZOOM_options_set_int(opt, name, value)
19 ZOOM_query_cql2rpn(ZOOM_query s, const char *str, ZOOM_connection conn)
20 -->
21  <chapter id="zoom"><title>ZOOM</title>
22   <para>
23     &zoom; is an acronym for 'Z39.50 Object-Orientation Model' and is
24    an initiative started by Mike Taylor (Mike is from the UK, which
25    explains the peculiar name of the model). The goal of &zoom; is to
26    provide a common Z39.50 client API not bound to a particular
27    programming language or toolkit.
28   </para>
29
30   <para>
31     From YAZ version 2.1.12, <ulink url="&url.sru;">SRU</ulink> is supported.
32     You can make SRU ZOOM connections by specifying scheme
33     <literal>http://</literal> for the hostname for a connection.
34     The dialect of SRU used is specified by the value of the
35     connection's <literal>sru</literal> option, which may be SRU over
36     HTTP GET (<literal>get</literal>),
37     SRU over HTTP POST (<literal>post</literal>), (SRU over
38     SOAP) (<literal>soap</literal>) or <literal>solr</literal>
39     (<ulink url="&url.solr;">Solr</ulink> Web Service).
40     Using the facility for embedding options in target strings, a
41     connection can be forced to use SRU rather the SRW (the default) by
42     prefixing the target string with <literal>sru=get,</literal>, like this:
43     <literal>sru=get,http://sru.miketaylor.org.uk:80/sru.pl</literal>
44   </para>
45   <para>
46    <ulink url="&url.solr;">Solr</ulink>  protocol support was added to
47    YAZ in version 4.1.0, as a dialect of a SRU protocol, since both are
48    HTTP based protocols.
49   </para>
50   <para>
51    The lack of a simple Z39.50 client API for &yaz; has become more
52    and more apparent over time. So when the first &zoom; specification
53    became available,
54    an implementation for &yaz; was quickly developed. For the first time, it is
55    now as easy (or easier!) to develop clients than servers with &yaz;. This
56    chapter describes the &zoom; C binding. Before going further, please
57    reconsider whether C is the right programming language for the job.
58    There are other language bindings available for &yaz;, and still
59    more
60    are in active development. See the
61    <ulink url="&url.zoom;">ZOOM web-site</ulink> for
62    more information.
63   </para>
64
65   <para>
66    In order to fully understand this chapter you should read and
67    try the example programs <literal>zoomtst1.c</literal>,
68    <literal>zoomtst2.c</literal>, .. in the <literal>zoom</literal>
69    directory.
70   </para>
71
72   <para>
73    The C language misses features found in object oriented languages
74    such as C++, Java, etc. For example, you'll have to manually,
75    destroy all objects you create, even though you may think of them as
76    temporary. Most objects has a <literal>_create</literal> - and a
77    <literal>_destroy</literal> variant.
78    All objects are in fact pointers to internal stuff, but you don't see
79    that because of typedefs. All destroy methods should gracefully ignore a
80    <literal>NULL</literal> pointer.
81   </para>
82   <para>
83    In each of the sections below you'll find a sub section called
84    protocol behavior, that describes how the API maps to the Z39.50
85    protocol.
86   </para>
87   <sect1 id="zoom-connections"><title>Connections</title>
88
89    <para>The Connection object is a session with a target.
90    </para>
91    <synopsis>
92     #include &lt;yaz/zoom.h>
93
94     ZOOM_connection ZOOM_connection_new(const char *host, int portnum);
95
96     ZOOM_connection ZOOM_connection_create(ZOOM_options options);
97
98     void ZOOM_connection_connect(ZOOM_connection c, const char *host,
99                                  int portnum);
100     void ZOOM_connection_destroy(ZOOM_connection c);
101    </synopsis>
102    <para>
103     Connection objects are created with either function
104     <function>ZOOM_connection_new</function> or
105     <function>ZOOM_connection_create</function>.
106     The former creates and automatically attempts to establish a network
107     connection with the target. The latter doesn't establish
108     a connection immediately, thus allowing you to specify options
109     before establishing network connection using the function
110     <function>ZOOM_connection_connect</function>.
111     If the port number, <literal>portnum</literal>, is zero, the
112     <literal>host</literal> is consulted for a port specification.
113     If no port is given, 210 is used. A colon denotes the beginning of
114     a port number in the host string. If the host string includes a
115     slash, the following part specifies a database for the connection.
116    </para>
117    <para>
118     You can prefix the host with a scheme followed by colon. The
119     default scheme is <literal>tcp</literal> (Z39.50 protocol).
120     The scheme <literal>http</literal> selects SRU/get over HTTP by default,
121     but can overridded to use SRU/post, SRW and the Solr protocol.
122    </para>
123    <para>
124     You can prefix the scheme-qualified host-string with one or more
125     comma-separated
126     <literal><parameter>key</parameter>=<parameter>value</parameter></literal>
127     sequences, each of which represents an option to be set into the
128     connection structure <emphasis>before</emphasis> the
129     protocol-level connection is forged and the initialization
130     handshake takes place.  This facility can be used to provide
131     authentication credentials, as in host-strings such as:
132     <literal>user=admin,password=halfAm4n,tcp:localhost:8017/db</literal>
133    </para>
134    <para>
135     Connection objects should be destroyed using the function
136     <function>ZOOM_connection_destroy</function>.
137    </para>
138    <synopsis>
139     void ZOOM_connection_option_set(ZOOM_connection c,
140                                     const char *key, const char *val);
141
142     void ZOOM_connection_option_setl(ZOOM_connection c,
143                                      const char *key,
144                                      const char *val, int len);
145
146     const char *ZOOM_connection_option_get(ZOOM_connection c,
147                                            const char *key);
148     const char *ZOOM_connection_option_getl(ZOOM_connection c,
149                                             const char *key,
150                                             int *lenp);
151    </synopsis>
152    <para>
153     The functions <function>ZOOM_connection_option_set</function> and
154     <function>ZOOM_connection_option_setl</function> allows you to
155     set an option given by <parameter>key</parameter> to the value
156     <parameter>value</parameter> for the connection.
157     For <function>ZOOM_connection_option_set</function>, the
158     value is assumed to be a 0-terminated string. Function
159     <function>ZOOM_connection_option_setl</function> specifies a
160     value of a certain size (len).
161    </para>
162    <para>
163     Functions <function>ZOOM_connection_option_get</function> and
164     <function>ZOOM_connection_option_getl</function> returns
165     the value for an option given by <parameter>key</parameter>.
166    </para>
167    <table id="zoom-connection-options" frame="top">
168     <title>ZOOM Connection Options</title>
169     <tgroup cols="3">
170      <colspec colwidth="4*" colname="name"></colspec>
171      <colspec colwidth="7*" colname="description"></colspec>
172      <colspec colwidth="3*" colname="default"></colspec>
173      <thead>
174       <row>
175        <entry>Option</entry>
176        <entry>Description</entry>
177        <entry>Default</entry>
178       </row>
179      </thead>
180      <tbody>
181       <row><entry>
182         implementationName</entry><entry>Name of Your client
183        </entry><entry>none</entry></row>
184       <row><entry>
185         user</entry><entry>Authentication user name
186        </entry><entry>none</entry></row>
187       <row><entry>
188         group</entry><entry>Authentication group name
189        </entry><entry>none</entry></row>
190       <row><entry>
191         password</entry><entry>Authentication password.
192        </entry><entry>none</entry></row>
193       <row><entry>
194         host</entry><entry>Target host. This setting is "read-only".
195         It's automatically set internally when connecting to a target.
196        </entry><entry>none</entry></row>
197       <row><entry>
198         proxy</entry><entry>Proxy host. If set, the logical host
199         is encoded in the otherInfo area of the Z39.50 Init PDU
200         with OID 1.2.840.10003.10.1000.81.1.
201        </entry><entry>none</entry></row>
202       <row><entry>
203         clientIP</entry><entry>Client IP. If set, is
204         encoded in the otherInfo area of a Z39.50 PDU with OID
205         1.2.840.10003.10.1000.81.3. Holds the original IP addreses
206         of a client. Is used of ZOOM is used in a gateway of some sort.
207        </entry><entry>none</entry></row>
208       <row><entry>
209         async</entry><entry>If true (1) the connection operates in
210         asynchronous operation which means that all calls are non-blocking
211         except
212         <link linkend="zoom.events"><function>ZOOM_event</function></link>.
213        </entry><entry>0</entry></row>
214       <row><entry>
215         maximumRecordSize</entry><entry> Maximum size of single record.
216        </entry><entry>1 MB</entry></row>
217       <row><entry>
218         preferredMessageSize</entry><entry> Maximum size of multiple records.
219        </entry><entry>1 MB</entry></row>
220       <row><entry>
221         lang</entry><entry> Language for negotiation.
222        </entry><entry>none</entry></row>
223       <row><entry>
224         charset</entry><entry> Character set for negotiation.
225        </entry><entry>none</entry></row>
226       <row><entry>
227         serverImplementationId</entry><entry>
228         Implementation ID of server.  (The old targetImplementationId
229         option is also supported for the benefit of old applications.)
230        </entry><entry>none</entry></row>
231       <row><entry>
232         targetImplementationName</entry><entry>
233         Implementation Name of server.  (The old
234         targetImplementationName option is also supported for the
235         benefit of old applications.)
236        </entry><entry>none</entry></row>
237       <row><entry>
238         serverImplementationVersion</entry><entry>
239         Implementation Version of server.  (the old
240         targetImplementationVersion option is also supported for the
241         benefit of old applications.)
242        </entry><entry>none</entry></row>
243       <row><entry>
244         databaseName</entry><entry>One or more database names
245         separated by character plus (<literal>+</literal>), which to
246         be used by subsequent search requests on this Connection.
247        </entry><entry>Default</entry></row>
248       <row><entry>
249         piggyback</entry><entry>True (1) if piggyback should be
250         used in searches; false (0) if not.
251        </entry><entry>1</entry></row>
252       <row><entry>
253         smallSetUpperBound</entry><entry>If hits is less than or equal to this
254         value, then target will return all records using small element set name
255        </entry><entry>0</entry></row>
256       <row><entry>
257         largeSetLowerBound</entry><entry>If hits is greater than this
258         value, the target will return no records.
259        </entry><entry>1</entry></row>
260       <row><entry>
261         mediumSetPresentNumber</entry><entry>This value represents
262         the number of records to be returned as part of a search when when
263         hits is less than or equal to large set lower bound and if hits
264         is greater than small set upper bound.
265        </entry><entry>0</entry></row>
266       <row><entry>
267         smallSetElementSetName</entry><entry>
268         The element set name to be used for small result sets.
269        </entry><entry>none</entry></row>
270       <row><entry>
271         mediumSetElementSetName</entry><entry>
272         The element set name to be for medium-sized result sets.
273        </entry><entry>none</entry></row>
274       <row><entry>
275         init_opt_search, init_opt_present, init_opt_delSet, etc.</entry><entry>
276         After a successful Init, these options may be interrogated to
277         discover whether the server claims to support the specified
278         operations.
279        </entry><entry>none</entry></row>
280       <row>
281         <entry>sru</entry><entry>
282         SRU/Solr transport type. Must be either <literal>soap</literal>,
283         <literal>get</literal>, <literal>post</literal>, or
284         <literal>solr</literal>.
285         </entry><entry>soap</entry></row>
286       <row><entry>
287         sru_version</entry><entry>
288         SRU/SRW version. Should be <literal>1.1</literal>, or
289         <literal>1.2</literal>. This is , prior to connect, the version
290         to offer (highest version). And following connect (in fact
291         first operation), holds the negotiated version with the server
292         (same or lower version).
293        </entry><entry>1.2</entry></row>
294       <row><entry>
295         facets</entry><entry>
296         A FacetList is comma-separated list of facet, which is defined
297         as <literal>AttributeList</literal>  and a optional FacetTerm
298         (a Term and a frequency). On request the terms is missing.
299         On response the the list contains the terms that the target
300         could collect.
301        </entry><entry>none</entry></row>
302       <row><entry>
303         apdulog</entry><entry>
304         If set to a true value such as "1", a log of low-level
305         protocol packets is emitted on standard error stream.  This
306         can be very useful for debugging.
307        </entry><entry>0</entry></row>
308       <row><entry>
309         saveAPDU</entry><entry>
310         If set to a true value such as "1", a log of low-level
311         protocol packets is saved. The log can be retrieved by reading
312         option APDU. Setting saveAPDU always has the side effect of
313         resetting the currently saved log. This setting is
314         <emphasis>write-only</emphasis>. If read, NULL will be returned.
315         It is only recognized in
316         <function>ZOOM_connection_option_set</function>.
317        </entry><entry>0</entry></row>
318       <row><entry>
319         APDU</entry><entry>
320         Returns the log of protocol packets. Will be empty if logging
321         is not enabled (see saveAPDU above). This setting is
322         <emphasis>read-only</emphasis>. It is only recognized if used
323         in call to <function>ZOOM_connection_option_get</function> or
324         <function>ZOOM_connection_option_getl</function>.
325        </entry><entry></entry></row>
326      </tbody>
327     </tgroup>
328    </table>
329    <para>
330     If either option <literal>lang</literal> or <literal>charset</literal>
331     is set, then
332     <ulink url="&url.z39.50.charneg;">
333      Character Set and Language Negotiation</ulink> is in effect.
334    </para>
335    <synopsis>
336      int ZOOM_connection_error(ZOOM_connection c, const char **cp,
337                                const char **addinfo);
338      int ZOOM_connection_error_x(ZOOM_connection c, const char **cp,
339                                  const char **addinfo, const char **dset);
340    </synopsis>
341    <para>
342     Function <function>ZOOM_connection_error</function> checks for
343     errors for the last operation(s) performed. The function returns
344     zero if no errors occurred; non-zero otherwise indicating the error.
345     Pointers <parameter>cp</parameter> and <parameter>addinfo</parameter>
346     holds messages for the error and additional-info if passed as
347     non-<literal>NULL</literal>. Function
348     <function>ZOOM_connection_error_x</function> is an extended version
349     of <function>ZOOM_connection_error</function> that is capable of
350     returning name of diagnostic set in <parameter>dset</parameter>.
351    </para>
352    <sect2 id="zoom-connection-z39.50">
353     <title>Z39.50 Protocol behavior</title>
354     <para>
355      The calls <function>ZOOM_connection_new</function> and
356      <function>ZOOM_connection_connect</function> establishes a TCP/IP
357       connection and sends an Initialize Request to the target if
358       possible. In addition, the calls waits for an Initialize Response
359       from the target and the result is inspected (OK or rejected).
360     </para>
361     <para>
362      If <literal>proxy</literal> is set then the client will establish
363      a TCP/IP connection with the peer as specified by the
364      <literal>proxy</literal> host and the hostname as part of the
365      connect calls will be set as part of the Initialize Request.
366      The proxy server will then "forward" the PDU's transparently
367      to the target behind the proxy.
368     </para>
369     <para>
370      For the authentication parameters, if option <literal>user</literal>
371      is set and both options <literal>group</literal> and
372      <literal>pass</literal> are unset, then Open style
373      authentication is used (Version 2/3) in which case the username
374      is usually followed by a slash, then by a password.
375      If either <literal>group</literal>
376      or <literal>pass</literal> is set then idPass authentication
377      (Version 3 only) is used. If none of the options are set, no
378      authentication parameters are set as part of the Initialize Request
379      (obviously).
380     </para>
381     <para>
382      When option <literal>async</literal> is 1, it really means that
383      all network operations are postponed (and queued) until the
384      function <literal>ZOOM_event</literal> is invoked. When doing so
385      it doesn't make sense to check for errors after
386      <literal>ZOOM_connection_new</literal> is called since that
387      operation "connecting - and init" is still incomplete and the
388      API cannot tell the outcome (yet).
389     </para>
390     </sect2>
391    <sect2 id="zoom.sru.init.behavior">
392     <title>SRU/Solr Protocol behavior</title>
393     <para>
394      The HTTP based protocols (SRU, SRW, Solr) doesn't feature an Inititialize Request, so
395      the connection phase merely establishes a TCP/IP connection
396      with the SOAP service.
397     </para>
398     <para>Most of the ZOOM connection options do not
399      affect SRU/Solr and they are ignored. However, future versions
400      of &yaz; might honor <literal>implementationName</literal> and
401      put that as part of User-Agent header for HTTP requests.
402      </para>
403     <para>
404      The <literal>charset</literal> is used in the Content-Type header
405      of HTTP requests.
406     </para>
407    </sect2>
408   </sect1>
409   <sect1 id="zoom.query"><title>Queries</title>
410    <para>
411     Query objects represents queries.
412    </para>
413    <synopsis>
414      ZOOM_query ZOOM_query_create(void);
415
416      void ZOOM_query_destroy(ZOOM_query q);
417
418      int ZOOM_query_prefix(ZOOM_query q, const char *str);
419
420      int ZOOM_query_cql(ZOOM_query s, const char *str);
421
422      int ZOOM_query_sortby(ZOOM_query q, const char *criteria);
423
424      int ZOOM_query_sortby2(ZOOM_query q, const char *strategy,
425                             const char *criteria);
426    </synopsis>
427    <para>
428     Create query objects using <function>ZOOM_query_create</function>
429     and destroy them by calling <function>ZOOM_query_destroy</function>.
430     RPN-queries can be specified in <link linkend="PQF">PQF</link>
431     notation by using the
432     function <function>ZOOM_query_prefix</function>.
433     The <function>ZOOM_query_cql</function> specifies a CQL
434     query to be sent to the server/target.
435     More query types will be added in future versions of &yaz;, such as
436     <link linkend="CCL">CCL</link> to RPN-mapping, native CCL query,
437     etc. In addition to a search, a sort criteria may be set. Function
438     <function>ZOOM_query_sortby</function> enables Z39.50 sorting and
439     it takes sort criteria using the same string notation as
440     yaz-client's <link linkend="sortspec">sort command</link>.
441    </para>
442    <para id="zoom.query.sortby2">
443     <function>ZOOM_query_sortby2</function> is similar to
444     <function>ZOOM_query_sortby</function> but allows a strategy for
445     sorting. The reason for the strategy parameter is that some
446     protocols offers multiple ways of performing sorting.
447     For example, Z39.50 has the standard sort, which is performed after
448     search on an existing result set.
449     It's also possible to use CQL in Z39.50 as the query type and use
450     CQL's SORTBY keyword. Finally, Index Data's
451     Zebra server also allows sorting to be specified as part of RPN (Type 7).
452    </para>
453    <table id="zoom-sort-strategy" frame="top">
454     <title>ZOOM sort strategy</title>
455     <tgroup cols="2">
456      <colspec colwidth="2*" colname="name"/>
457      <colspec colwidth="5*" colname="description"/>
458      <thead>
459       <row>
460        <entry>Name</entry>
461        <entry>Description</entry>
462       </row>
463      </thead>
464      <tbody>
465       <row>
466        <entry>z39.50</entry><entry>Z39.50 resultset sort</entry>
467       </row>
468       <row>
469        <entry>type7</entry><entry>Sorting embedded in RPN(Type-7)</entry>
470       </row>
471       <row>
472        <entry>cql</entry><entry>CQL SORTBY</entry>
473       </row>
474       <row>
475        <entry>sru11</entry><entry>SRU sortKeys parameter</entry>
476       </row>
477       <row>
478        <entry>solr</entry><entry>Solr sort</entry>
479       </row>
480       <row>
481        <entry>embed</entry><entry>type7 for Z39.50, cql for SRU,
482         solr for Solr protocol</entry>
483       </row>
484      </tbody>
485     </tgroup>
486    </table>
487   </sect1>
488   <sect1 id="zoom.resultsets"><title>Result sets</title>
489    <para>
490     The result set object is a container for records returned from
491     a target.
492    </para>
493    <synopsis>
494      ZOOM_resultset ZOOM_connection_search(ZOOM_connection, ZOOM_query q);
495
496      ZOOM_resultset ZOOM_connection_search_pqf(ZOOM_connection c,
497                                                const char *q);
498      void ZOOM_resultset_destroy(ZOOM_resultset r);
499    </synopsis>
500    <para>
501     Function <function>ZOOM_connection_search</function> creates
502     a result set given a connection and query.
503     Destroy a result set by calling
504     <function>ZOOM_resultset_destroy</function>.
505     Simple clients may using PQF only may use function
506     <function>ZOOM_connection_search_pqf</function> in which case
507     creating query objects is not necessary.
508    </para>
509    <synopsis>
510      void ZOOM_resultset_option_set(ZOOM_resultset r,
511                                     const char *key, const char *val);
512
513      const char *ZOOM_resultset_option_get(ZOOM_resultset r, const char *key);
514
515      size_t ZOOM_resultset_size(ZOOM_resultset r);
516    </synopsis>
517    <para>
518     Functions <function>ZOOM_resultset_options_set</function> and
519     <function>ZOOM_resultset_get</function> sets and gets an option
520     for a result set similar to <function>ZOOM_connection_option_get</function>
521     and <function>ZOOM_connection_option_set</function>.
522    </para>
523    <para>
524     The number of hits also called result-count is returned by
525     function <function>ZOOM_resultset_size</function>.
526    </para>
527    <table id="zoom.resultset.options"
528     frame="top"><title>ZOOM Result set Options</title>
529     <tgroup cols="3">
530      <colspec colwidth="4*" colname="name"></colspec>
531      <colspec colwidth="7*" colname="description"></colspec>
532      <colspec colwidth="2*" colname="default"></colspec>
533      <thead>
534       <row>
535        <entry>Option</entry>
536        <entry>Description</entry>
537        <entry>Default</entry>
538       </row>
539      </thead>
540      <tbody>
541       <row><entry>
542         start</entry><entry>Offset of first record to be
543         retrieved from target. First record has offset 0 unlike the
544         protocol specifications where first record has position 1.
545         This option affects ZOOM_resultset_search and
546         ZOOM_resultset_search_pqf and must be set before any of
547         these functions are invoked. If a range of
548         records must be fetched manually after search,
549         function ZOOM_resultset_records should be used.
550        </entry><entry>0</entry></row>
551       <row><entry>
552         count</entry><entry>Number of records to be retrieved.
553         This option affects ZOOM_resultset_search and
554         ZOOM_resultset_search_pqf and must be set before any of
555         these functions are invoked.
556        </entry><entry>0</entry></row>
557       <row><entry>
558         presentChunk</entry><entry>The number of records to be
559         requested from the server in each chunk (present request). The
560         value 0 means to request all the records in a single chunk.
561         (The old <literal>step</literal>
562         option is also supported for the benefit of old applications.)
563        </entry><entry>0</entry></row>
564       <row><entry>
565         elementSetName</entry><entry>Element-Set name of records.
566         Most targets should honor element set name <literal>B</literal>
567         and <literal>F</literal> for brief and full respectively.
568        </entry><entry>none</entry></row>
569       <row><entry>
570         preferredRecordSyntax</entry><entry>Preferred Syntax, such as
571         <literal>USMARC</literal>, <literal>SUTRS</literal>, etc.
572        </entry><entry>none</entry></row>
573       <row><entry>
574         schema</entry><entry>Schema for retrieval, such as
575         <literal>Gils-schema</literal>, <literal>Geo-schema</literal>, etc.
576        </entry><entry>none</entry></row>
577       <row><entry>
578         setname</entry><entry>Name of Result Set (Result Set ID).
579         If this option isn't set, the ZOOM module will automatically
580         allocate a result set name.
581        </entry><entry>default</entry></row>
582       <row><entry>
583         rpnCharset</entry><entry>Character set for RPN terms.
584         If this is set, ZOOM C will assume that the ZOOM application is
585         running UTF-8. Terms in RPN queries are then converted to the
586         rpnCharset. If this is unset, ZOOM C will not assume any encoding
587         of RPN terms and no conversion is performed.
588        </entry><entry>none</entry></row>
589      </tbody>
590     </tgroup>
591    </table>
592    <para>
593     For servers that support Search Info report, the following
594     options may be read using <function>ZOOM_resultset_get</function>.
595     This detailed information is read after a successful search has
596     completed.
597    </para>
598    <para>
599     This information is a list of of items, where each item is
600     information about a term or subquery. All items in the list
601     are prefixed by
602     <literal>SearchResult.</literal><replaceable>no</replaceable>
603     where no presents the item number (0=first, 1=second).
604     Read <literal>searchresult.size</literal> to determine the
605     number of items.
606    </para>
607    <table id="zoom.search.info.report.options"
608     frame="top"><title>Search Info Report Options</title>
609     <tgroup cols="2">
610      <colspec colwidth="4*" colname="name"></colspec>
611      <colspec colwidth="7*" colname="description"></colspec>
612      <thead>
613       <row>
614        <entry>Option</entry>
615        <entry>Description</entry>
616       </row>
617      </thead>
618      <tbody>
619       <row>
620        <entry>searchresult.size</entry>
621        <entry>
622         number of search result entries. This option is-nonexistant
623         if no entries are returned by the server.
624        </entry>
625       </row>
626       <row>
627        <entry>searchresult.<replaceable>no</replaceable>.id</entry>
628        <entry>sub query ID</entry>
629       </row>
630       <row>
631        <entry>searchresult.<replaceable>no</replaceable>.count</entry>
632        <entry>result count for item (number of hits)</entry>
633       </row>
634       <row>
635        <entry>searchresult.<replaceable>no</replaceable>.subquery.term</entry>
636        <entry>subquery term</entry>
637       </row>
638       <row>
639        <entry>
640         searchresult.<replaceable>no</replaceable>.interpretation.term
641        </entry>
642        <entry>interpretation term</entry>
643       </row>
644       <row>
645        <entry>
646         searchresult.<replaceable>no</replaceable>.recommendation.term
647        </entry>
648        <entry>recommendation term</entry>
649       </row>
650      </tbody>
651     </tgroup>
652    </table>
653
654    <sect2 id="zoom.z3950.resultset.sort">
655     <title>Z39.50 Result-set Sort</title>
656     <synopsis>
657      void ZOOM_resultset_sort(ZOOM_resultset r,
658                               const char *sort_type, const char *sort_spec);
659
660      int ZOOM_resultset_sort1(ZOOM_resultset r,
661                               const char *sort_type, const char *sort_spec);
662     </synopsis>
663     <para>
664      <function>ZOOM_resultset_sort</function> and
665      <function>ZOOM_resultset_sort1</function> both sort an existing
666      result-set. The sort_type parameter is not use. Set it to "yaz".
667      The sort_spec is same notation as ZOOM_query_sortby and identical
668      to that offered by yaz-client's
669      <link linkend="sortspec">sort command</link>.
670     </para>
671     <para>
672      These functions only work for Z39.50. Use the more generic utility
673      <link linkend="zoom.query.sortby2">
674       <function>ZOOM_query_sortby2</function></link>
675      for other protocols (and even Z39.50).
676     </para>
677    </sect2>
678    <sect2 id="zoom.z3950.resultset.behavior">
679     <title>Z39.50 Protocol behavior</title>
680     <para>
681      The creation of a result set involves at least a SearchRequest
682      - SearchResponse protocol handshake. Following that, if a sort
683      criteria was specified as part of the query, a SortRequest -
684      SortResponse handshake takes place. Note that it is necessary to
685      perform sorting before any retrieval takes place, so no records will
686      be returned from the target as part of the SearchResponse because these
687      would be unsorted. Hence, piggyback is disabled when sort criteria
688      are set. Following Search - and a possible sort - Retrieval takes
689      place - as one or more Present Requests/Response pairs being
690      transferred.
691      </para>
692     <para>
693      The API allows for two different modes for retrieval. A high level
694      mode which is somewhat more powerful and a low level one.
695      The low level is enabled when searching on a Connection object
696      for which the settings
697      <literal>smallSetUpperBound</literal>,
698      <literal>mediumSetPresentNumber</literal> and
699      <literal>largeSetLowerBound</literal> are set. The low level mode
700      thus allows you to precisely set how records are returned as part
701      of a search response as offered by the Z39.50 protocol.
702      Since the client may be retrieving records as part of the
703      search response, this mode doesn't work well if sorting is used.
704      </para>
705     <para>
706      The high-level mode allows you to fetch a range of records from
707      the result set with a given start offset. When you use this mode
708      the client will automatically use piggyback if that is possible
709      with the target and perform one or more present requests as needed.
710      Even if the target returns fewer records as part of a present response
711      because of a record size limit, etc. the client will repeat sending
712      present requests. As an example, if option <literal>start</literal>
713      is 0 (default) and <literal>count</literal> is 4, and
714      <literal>piggyback</literal> is 1 (default) and no sorting criteria
715      is specified, then the client will attempt to retrieve the 4
716      records as part the search response (using piggyback). On the other
717      hand, if either <literal>start</literal> is positive or if
718      a sorting criteria is set, or if <literal>piggyback</literal>
719      is 0, then the client will not perform piggyback but send Present
720      Requests instead.
721     </para>
722     <para>
723      If either of the options <literal>mediumSetElementSetName</literal> and
724      <literal>smallSetElementSetName</literal> are unset, the value
725      of option <literal>elementSetName</literal> is used for piggyback
726      searches. This means that for the high-level mode you only have
727      to specify one elementSetName option rather than three.
728      </para>
729    </sect2>
730    <sect2 id="zoom.sru.resultset.behavior">
731     <title>SRU Protocol behavior</title>
732     <para>
733      Current version of &yaz; does not take advantage of a result set id
734      returned by the SRU server. Future versions might do, however.
735      Since, the ZOOM driver does not save result set IDs any
736      present (retrieval) is transformed to a SRU SearchRetrieveRequest
737      with same query but, possibly, different offsets.
738     </para>
739     <para>
740      Option <literal>schema</literal> specifies SRU schema
741      for retrieval. However, options <literal>elementSetName</literal> and
742      <literal>preferredRecordSyntax</literal> are ignored.
743     </para>
744     <para>
745      Options <literal>start</literal> and <literal>count</literal>
746      are supported by SRU.
747      The remaining options
748      <literal>piggyback</literal>,
749      <literal>smallSetUpperBound</literal>,
750      <literal>largeSetLowerBound</literal>,
751      <literal>mediumSetPresentNumber</literal>,
752      <literal>mediumSetElementSetName</literal>,
753       <literal>smallSetElementSetName</literal> are
754      unsupported.
755     </para>
756     <para>
757      SRU supports CQL queries, <emphasis>not</emphasis> PQF.
758      If PQF is used, however, the PQF query is transferred anyway
759      using non-standard element <literal>pQuery</literal> in
760      SRU SearchRetrieveRequest.
761     </para>
762     <para>
763      Solr queries has to be done in Solr query format.
764     </para>
765     <para>
766      Unfortunately, SRU or Solr does not define a database setting. Hence,
767      <literal>databaseName</literal> is unsupported and ignored.
768      However, the path part in host parameter for functions
769      <function>ZOOM_connecton_new</function> and
770      <function>ZOOM_connection_connect</function> acts as a
771      database (at least for the &yaz; SRU server).
772     </para>
773    </sect2>
774   </sect1>
775   <sect1 id="zoom.records"><title>Records</title>
776    <para>
777     A record object is a retrieval record on the client side -
778     created from result sets.
779    </para>
780    <synopsis>
781      void ZOOM_resultset_records(ZOOM_resultset r,
782                                  ZOOM_record *recs,
783                                  size_t start, size_t count);
784      ZOOM_record ZOOM_resultset_record(ZOOM_resultset s, size_t pos);
785
786      const char *ZOOM_record_get(ZOOM_record rec, const char *type,
787                                  size_t *len);
788
789      int ZOOM_record_error(ZOOM_record rec, const char **msg,
790                            const char **addinfo, const char **diagset);
791
792      ZOOM_record ZOOM_record_clone(ZOOM_record rec);
793
794      void ZOOM_record_destroy(ZOOM_record rec);
795    </synopsis>
796    <para>
797     References to temporary records are returned by functions
798     <function>ZOOM_resultset_records</function> or
799     <function>ZOOM_resultset_record</function>.
800     </para>
801    <para>
802     If a persistent reference to a record is desired
803     <function>ZOOM_record_clone</function> should be used.
804     It returns a record reference that should be destroyed
805     by a call to <function>ZOOM_record_destroy</function>.
806    </para>
807    <para>
808     A single record is returned by function
809     <function>ZOOM_resultset_record</function> that takes a
810     position as argument. First record has position zero.
811     If no record could be obtained <literal>NULL</literal> is returned.
812    </para>
813    <para>
814     Error information for a record can be checked with
815     <function>ZOOM_record_error</function> which returns non-zero
816     (error code) if record is in error, called <emphasis>Surrogate
817      Diagnostics</emphasis> in Z39.50.
818    </para>
819    <para>
820     Function <function>ZOOM_resultset_records</function> retrieves
821     a number of records from a result set. Parameter <literal>start</literal>
822     and <literal>count</literal> specifies the range of records to
823     be returned. Upon completion array
824     <literal>recs[0], ..recs[count-1]</literal>
825     holds record objects for the records. The array of records
826      <literal>recs</literal> should be allocated prior the call
827     <function>ZOOM_resultset_records</function>. Note that for those
828     records that couldn't be retrieved from the target
829     <literal>recs[ ..]</literal> is set to <literal>NULL</literal>.
830    </para>
831    <para id="zoom.record.get">
832     In order to extract information about a single record,
833     <function>ZOOM_record_get</function> is provided. The
834     function returns a pointer to certain record information. The
835     nature (type) of the pointer depends on the parameter,
836     <parameter>type</parameter>.
837    </para>
838    <para>
839     The <parameter>type</parameter> is a string of the format:
840    </para>
841    <para>
842     <replaceable>format</replaceable>[;charset=<replaceable>from</replaceable>[/<replaceable>opacfrom</replaceable>][,<replaceable>to</replaceable>]][;format=<replaceable>v</replaceable>]
843    </para>
844    <para>
845     where <replaceable>format</replaceable> specifies the format of the
846     returned record, <replaceable>from</replaceable>
847     specifies the character set of the record in its original form
848     (as returned by the server), <replaceable>to</replaceable> specifies
849     the output (returned)
850     character set encoding.
851     If <replaceable>to</replaceable> is omitted UTF-8 is assumed.
852     If charset is not given, then no character set conversion takes place.
853    </para>
854
855    <para>OPAC records may be returned in a different
856      set from the bibliographic MARC record. If this is this the case,
857     <replaceable>opacfrom</replaceable> should be set to the character set
858     of the OPAC record part.
859    </para>
860    <note>
861      <para>
862        Specifying the OPAC record character set requires YAZ 4.1.5 or later.
863      </para>
864    </note>
865    <para>
866     The format argument controls whether record data should be XML
867     pretty-printed (post process operation).
868     It is enabled only if format value <replaceable>v</replaceable> is
869     <literal>1</literal> and the record content is XML well-formed.
870    </para>
871    <para>
872     In addition, for certain types, the length
873     <literal>len</literal> passed will be set to the size in bytes of
874     the returned information.
875     </para>
876    <para>
877     The following are the supported values for <replaceable>form</replaceable>.
878     <variablelist>
879      <varlistentry><term><literal>database</literal></term>
880       <listitem><para>Database of record is returned
881         as a C null-terminated string. Return type
882         <literal>const char *</literal>.
883        </para></listitem>
884      </varlistentry>
885      <varlistentry><term><literal>syntax</literal></term>
886       <listitem><para>The transfer syntax of the record is returned
887         as a C null-terminated string containing the symbolic name of
888         the record syntax, e.g. <literal>Usmarc</literal>. Return type
889         is
890         <literal>const char *</literal>.
891        </para></listitem>
892      </varlistentry>
893      <varlistentry><term><literal>schema</literal></term>
894       <listitem><para>The schema of the record is returned
895         as a C null-terminated string. Return type is
896         <literal>const char *</literal>.
897        </para></listitem>
898      </varlistentry>
899      <varlistentry><term><literal>render</literal></term>
900       <listitem><para>The record is returned in a display friendly
901         format. Upon completion buffer is returned
902         (type <literal>const char *</literal>) and length is stored in
903         <literal>*len</literal>.
904        </para></listitem>
905      </varlistentry>
906      <varlistentry><term><literal>raw</literal></term>
907       <listitem><para>The record is returned in the internal
908         YAZ specific format. For GRS-1, Explain, and others, the
909         raw data is returned as type
910         <literal>Z_External *</literal> which is just the type for
911         the member <literal>retrievalRecord</literal> in
912         type <literal>NamePlusRecord</literal>.
913         For SUTRS and octet aligned record (including all MARCs) the
914         octet buffer is returned and the length of the buffer.
915        </para></listitem>
916      </varlistentry>
917      <varlistentry><term><literal>xml</literal></term>
918       <listitem><para>The record is returned in XML if possible.
919         SRU, Solr and Z39.50 records with transfer syntax XML are
920         returned verbatim. MARC records are returned in
921         <ulink url="&url.marcxml;">
922          MARCXML
923          </ulink>
924         (converted from ISO2709 to MARCXML by YAZ).
925         OPAC records are also converted to XML and the
926         bibliographic record is converted to MARCXML (when possible).
927         GRS-1 records are not supported for this form.
928         Upon completion, the XML buffer is returned
929         (type <literal>const char *</literal>) and length is stored in
930         <literal>*len</literal>.
931        </para></listitem>
932      </varlistentry>
933      <varlistentry><term><literal>opac</literal></term>
934       <listitem><para>OPAC information for record is returned in XML
935         if an OPAC record is present at the position given. If no
936         OPAC record is present, a NULL pointer is returned.
937        </para></listitem>
938      </varlistentry>
939      <varlistentry><term><literal>txml</literal></term>
940       <listitem><para>The record is returned in TurboMARC if possible.
941         SRU and Z39.50 records with transfer syntax XML are
942         returned verbatim. MARC records are returned in
943         <link linkend="tools.turbomarc">
944          TurboMARC
945         </link>
946         (converted from ISO2709 to TurboMARC by YAZ).
947         Upon completion, the XML buffer is returned
948         (type <literal>const char *</literal>) and length is stored in
949         <literal>*len</literal>.
950        </para></listitem>
951      </varlistentry>
952     </variablelist>
953    </para>
954    <para>
955     Most
956     <ulink url="&url.marc21;">MARC21</ulink>
957     records uses the
958     <ulink url="&url.marc8;">MARC-8</ulink>
959     character set encoding.
960     An application that wishes to display in Latin-1 would use
961     <screen>
962      render; charset=marc8,iso-8859-1
963     </screen>
964    </para>
965    <sect2 id="zoom.z3950.record.behavior">
966     <title>Z39.50 Protocol behavior</title>
967     <para>
968      The functions <function>ZOOM_resultset_record</function> and
969      <function>ZOOM_resultset_records</function> inspects the client-side
970      record cache. Records not found in cache are fetched using
971      Present.
972      The functions may block (and perform network I/O)  - even though option
973      <literal>async</literal> is 1, because they return records objects.
974      (and there's no way to return records objects without retrieving them!).
975      </para>
976     <para>
977      There is a trick, however, in the usage of function
978      <function>ZOOM_resultset_records</function> that allows for
979      delayed retrieval (and makes it non-blocking). By using
980      a null pointer for <parameter>recs</parameter> you're indicating
981      you're not interested in getting records objects
982      <emphasis>now</emphasis>.
983     </para>
984    </sect2>
985    <sect2 id="zoom.sru.record.behavior">
986     <title>SRU/Solr Protocol behavior</title>
987     <para>
988      The ZOOM driver for SRU/Solr treats records returned by a SRU/Solr server
989      as if they where Z39.50 records with transfer syntax XML and
990      no element set name or database name.
991     </para>
992    </sect2>
993   </sect1>
994   <sect1 id="zoom.facets"><title>Facets</title>
995    <para>
996     Facets operations is not part of the official ZOOM specification, but
997     is an Index Data extension for YAZ-based Z39.50 targets or
998     <ulink url="&url.solr;">Solr</ulink> targets.
999     In case the target can and is requested to return facets, using a
1000     result set the ZOOM client can request one or all facet fields.
1001     Using a facet field the client can request the term count and then
1002     interate over the terms.
1003    </para>
1004    <synopsis>
1005     ZOOM_facet_field *ZOOM_resultset_facets(ZOOM_resultset r);
1006
1007     const char ** ZOOM_resultset_facets_names(ZOOM_resultset r);
1008
1009     ZOOM_facet_field ZOOM_resultset_get_facet_field(ZOOM_resultset r,
1010                                                     const char *facet_name);
1011
1012     ZOOM_facet_field ZOOM_resultset_get_facet_field_by_index(ZOOM_resultset r,
1013                                                              int pos);
1014
1015     size_t ZOOM_resultset_facets_size(ZOOM_resultset r);
1016
1017     const char *ZOOM_facet_field_name(ZOOM_facet_field facet_field);
1018
1019     size_t ZOOM_facet_field_term_count(ZOOM_facet_field facet_field);
1020
1021     const char *ZOOM_facet_field_get_term(ZOOM_facet_field facet_field,
1022                                           size_t idx, int *freq);
1023    </synopsis>
1024    <para>
1025     References to temporary structures are returned by all functions.
1026     They are only valid as long the Result set is valid.
1027     <function>ZOOM_resultset_get_facet_field</function> or
1028     <function>ZOOM_resultset_get_facet_field_by_index</function>.
1029     <function>ZOOM_resultset_facets</function>.
1030     <function>ZOOM_resultset_facets_names</function>.
1031     <function>ZOOM_facet_field_name</function>.
1032     <function>ZOOM_facet_field_get_term</function>.
1033     </para>
1034    <para id="zoom.resultset.get_facet_field">
1035     A single Facet field  is returned by function
1036     <function>ZOOM_resultset_get_facet_field</function> or
1037     <function>ZOOM_resultset_get_facet_field_by_index</function> that takes
1038     a  result set and facet name or positive index respectively. First
1039     facet has position zero. If no facet could be obtained (invalid name
1040     or index out of bounds) <literal>NULL</literal> is returned.
1041    </para>
1042    <para id="zoom.resultset.facets">
1043     An array of facets field can be returned by
1044     <function>ZOOM_resultset_facets</function>. The length of the array is
1045     given by <function>ZOOM_resultset_facets_size</function>. The array is
1046     zero-based and last entry will be at
1047     <function>ZOOM_resultset_facets_size(result_set)</function>-1.
1048    </para>
1049    <para id="zoom.resultset.facets_names">
1050     It is possible to interate over facets by name, by calling
1051     <function>ZOOM_resultset_facets_names</function>.
1052     This will return an const array of char * where each string can be used
1053     as parameter for <function>ZOOM_resultset_get_facet_field</function>.
1054    </para>
1055    <para>
1056    Function <function>ZOOM_facet_field_name</function> gets the request
1057     facet name from a returned facet field.
1058    </para>
1059    <para>
1060     Function <function>ZOOM_facet_field_get_term</function> returns the
1061     idx'th term and term count for a facet field.
1062     Idx must between 0 and
1063     <function>ZOOM_facet_field_term_count</function>-1, otherwise the
1064     returned reference will be <literal>NULL</literal>. On a valid idx, the
1065     value of the freq reference will be the term count.
1066     The <literal>freq</literal> parameter must be valid pointer to integer.
1067    </para>
1068    </sect1>
1069   <sect1 id="zoom.scan"><title>Scan</title>
1070    <para>
1071     This section describes an interface for Scan. Scan is not an
1072     official part of the ZOOM model yet. The result of a scan operation
1073     is the <literal>ZOOM_scanset</literal> which is a set of terms
1074     returned by a target.
1075    </para>
1076
1077    <para>
1078     The Scan interface is supported for both Z39.50, SRU and Solr.
1079    </para>
1080
1081    <synopsis>
1082     ZOOM_scanset ZOOM_connection_scan(ZOOM_connection c,
1083                                       const char *startpqf);
1084
1085     ZOOM_scanset ZOOM_connection_scan1(ZOOM_connection c,
1086                                        ZOOM_query q);
1087
1088     size_t ZOOM_scanset_size(ZOOM_scanset scan);
1089
1090     const char *ZOOM_scanset_term(ZOOM_scanset scan, size_t pos,
1091                                   size_t *occ, size_t *len);
1092
1093     const char *ZOOM_scanset_display_term(ZOOM_scanset scan, size_t pos,
1094                                           size_t *occ, size_t *len);
1095
1096     void ZOOM_scanset_destroy(ZOOM_scanset scan);
1097
1098     const char *ZOOM_scanset_option_get(ZOOM_scanset scan,
1099                                         const char *key);
1100
1101     void ZOOM_scanset_option_set(ZOOM_scanset scan, const char *key,
1102                                  const char *val);
1103     </synopsis>
1104    <para>
1105     The scan set is created by function
1106     <function>ZOOM_connection_scan</function> which performs a scan
1107     operation on the connection using the specified
1108     <parameter>startpqf</parameter>.
1109     If the operation was successful, the size of the scan set can be
1110     retrieved by a call to <function>ZOOM_scanset_size</function>.
1111     Like result sets, the items are numbered 0,..size-1.
1112     To obtain information about a particular scan term, call function
1113     <function>ZOOM_scanset_term</function>. This function takes
1114     a scan set offset <literal>pos</literal> and returns a pointer
1115     to a <emphasis>raw term</emphasis> or <literal>NULL</literal> if
1116     non-present.
1117     If present, the <literal>occ</literal> and <literal>len</literal>
1118     are set to the number of occurrences and the length
1119     of the actual term respectively.
1120     <function>ZOOM_scanset_display_term</function> is similar to
1121     <function>ZOOM_scanset_term</function> except that it returns
1122     the <emphasis>display term</emphasis> rather than the raw term.
1123     In a few cases, the term is different from display term. Always
1124     use the display term for display and the raw term for subsequent
1125     scan operations (to get more terms, next scan result, etc).
1126    </para>
1127    <para>
1128     A scan set may be freed by a call to function
1129     <function>ZOOM_scanset_destroy</function>.
1130     Functions <function>ZOOM_scanset_option_get</function> and
1131     <function>ZOOM_scanset_option_set</function> retrieves and sets
1132     an option respectively.
1133    </para>
1134
1135    <para>
1136     The <parameter>startpqf</parameter> is a subset of PQF, namely
1137     the Attributes+Term part. Multiple <literal>@attr</literal> can
1138     be used. For example to scan in title (complete) phrases:
1139     <literallayout>
1140      @attr 1=4 @attr 6=2 "science o"
1141     </literallayout>
1142    </para>
1143
1144    <para>
1145     The <function>ZOOM_connecton_scan1</function> is a newer and
1146     more generic alternative to <function>ZOOM_connection_scan</function>
1147     which allows to use both CQL and PQF for Scan.
1148    </para>
1149
1150    <table frame="top" id="zoom.scanset.options">
1151     <title>ZOOM Scan Set Options</title>
1152     <tgroup cols="3">
1153      <colspec colwidth="4*" colname="name"></colspec>
1154      <colspec colwidth="7*" colname="description"></colspec>
1155      <colspec colwidth="2*" colname="default"></colspec>
1156      <thead>
1157       <row>
1158        <entry>Option</entry>
1159        <entry>Description</entry>
1160        <entry>Default</entry>
1161       </row>
1162      </thead>
1163      <tbody>
1164       <row><entry>
1165         number</entry><entry>Number of Scan Terms requested in next scan.
1166         After scan it holds the actual number of terms returned.
1167        </entry><entry>20</entry></row>
1168       <row><entry>
1169         position</entry><entry>Preferred Position of term in response
1170         in next scan; actual position after completion of scan.
1171        </entry><entry>1</entry></row>
1172       <row><entry>
1173         stepSize</entry><entry>Step Size
1174        </entry><entry>0</entry></row>
1175       <row><entry>
1176         scanStatus</entry><entry>An integer indicating the Scan Status
1177         of last scan.
1178        </entry><entry>0</entry></row>
1179       <row><entry>
1180         rpnCharset</entry><entry>Character set for RPN terms.
1181         If this is set, ZOOM C will assume that the ZOOM application is
1182         running UTF-8. Terms in RPN queries are then converted to the
1183         rpnCharset. If this is unset, ZOOM C will not assume any encoding
1184         of RPN terms and no conversion is performed.
1185        </entry><entry>none</entry></row>
1186      </tbody>
1187     </tgroup>
1188    </table>
1189   </sect1>
1190
1191   <sect1 id="zoom.extendedservices"><title>Extended Services</title>
1192    <para>
1193     ZOOM offers an interface to a subset of the Z39.50 extended services
1194     as well as a few privately defined ones:
1195    </para>
1196    <itemizedlist>
1197     <listitem>
1198      <para>
1199       Z39.50 Item Order (ILL).
1200       See <xref linkend="zoom.item.order"/>.
1201      </para>
1202     </listitem>
1203     <listitem>
1204      <para>
1205       Record Update. This allows a client to insert, modify or delete
1206       records.
1207       See <xref linkend="zoom.record.update"/>.
1208      </para>
1209     </listitem>
1210     <listitem>
1211      <para>
1212       Database Create. This a non-standard feature. Allows a client
1213       to create a database.
1214       See <xref linkend="zoom.database.create"/>.
1215      </para>
1216     </listitem>
1217     <listitem>
1218      <para>
1219       Database Drop. This a non-standard feature. Allows a client
1220       to delete/drop a database.
1221       See <xref linkend="zoom.database.drop"/>.
1222      </para>
1223      </listitem>
1224     <listitem>
1225      <para>
1226       Commit operation. This a non-standard feature. Allows a client
1227       to commit operations.
1228       See <xref linkend="zoom.commit"/>.
1229      </para>
1230     </listitem>
1231     <!-- all the ILL PDU options should go here too -->
1232    </itemizedlist>
1233    <para>
1234     To create an extended service operation a <literal>ZOOM_package</literal>
1235     must be created. The operation is a five step operation. The
1236     package is created, package is configured by means of options,
1237     the package is send, result is inspected (by means of options),
1238     the package is destroyed.
1239    </para>
1240    <synopsis>
1241     ZOOM_package ZOOM_connection_package(ZOOM_connection c,
1242                                          ZOOM_options options);
1243
1244     const char *ZOOM_package_option_get(ZOOM_package p,
1245                                         const char *key);
1246     void ZOOM_package_option_set(ZOOM_package p, const char *key,
1247                                  const char *val);
1248     void ZOOM_package_send(ZOOM_package p, const char *type);
1249
1250     void ZOOM_package_destroy(ZOOM_package p);
1251    </synopsis>
1252    <para>
1253     The <function>ZOOM_connection_package</function> creates a
1254     package for the connection given using the options specified.
1255    </para>
1256    <para>
1257     Functions <function>ZOOM_package_option_get</function> and
1258     <function>ZOOM_package_option_set</function> gets and sets
1259     options.
1260    </para>
1261    <para>
1262     <function>ZOOM_package_send</function> sends
1263     the package the via connection specified in
1264     <function>ZOOM_connection_package</function>.
1265     The <parameter>type</parameter> specifies the actual extended service
1266     package type to be sent.
1267    </para>
1268
1269    <table frame="top" id="zoom.extendedservices.options">
1270     <title>Extended Service Common Options</title>
1271     <tgroup cols="3">
1272      <colspec colwidth="4*" colname="name"></colspec>
1273      <colspec colwidth="7*" colname="description"></colspec>
1274      <colspec colwidth="3*" colname="default"></colspec>
1275      <thead>
1276       <row>
1277        <entry>Option</entry>
1278        <entry>Description</entry>
1279        <entry>Default</entry>
1280       </row>
1281      </thead>
1282      <tbody>
1283       <row>
1284        <entry>package-name</entry>
1285        <entry>Extended Service Request package name. Must be specified
1286        as part of a request</entry>
1287        <entry>none</entry>
1288       </row>
1289       <row>
1290        <entry>user-id</entry>
1291        <entry>User ID of Extended Service Package. Is a request option</entry>
1292        <entry>none</entry>
1293       </row>
1294       <row>
1295        <entry>function</entry>
1296        <entry>
1297         Function of package - one of <literal>create</literal>,
1298         <literal>delete</literal>, <literal>modify</literal>. Is
1299         a request option.
1300        </entry>
1301        <entry><literal>create</literal></entry>
1302       </row>
1303       <row>
1304        <entry>waitAction</entry>
1305        <entry>
1306         Wait action for package. Possible values:
1307         <literal>wait</literal>, <literal>waitIfPossible</literal>,
1308         <literal>dontWait</literal> or <literal>dontReturnPackage</literal>.
1309        </entry>
1310        <entry><literal>waitIfPossible</literal></entry>
1311       </row>
1312       <row>
1313        <entry>targetReference</entry>
1314        <entry>
1315         Target Reference. This is part of the response as returned
1316         by the server. Read it after a successful operation.
1317        </entry>
1318        <entry><literal>none</literal></entry>
1319       </row>
1320      </tbody>
1321     </tgroup>
1322    </table>
1323
1324    <sect2 id="zoom.item.order"><title>Item Order</title>
1325     <para>
1326      For Item Order, type must be set to <literal>itemorder</literal> in
1327      <function>ZOOM_package_send</function>.
1328     </para>
1329
1330     <table frame="top" id="zoom.item.order.options">
1331      <title>Item Order Options</title>
1332      <tgroup cols="3">
1333       <colspec colwidth="4*" colname="name"></colspec>
1334       <colspec colwidth="7*" colname="description"></colspec>
1335       <colspec colwidth="3*" colname="default"></colspec>
1336       <thead>
1337        <row>
1338         <entry>Option</entry>
1339         <entry>Description</entry>
1340         <entry>Default</entry>
1341        </row>
1342       </thead>
1343       <tbody>
1344        <row>
1345         <entry>contact-name</entry>
1346         <entry>ILL contact name</entry>
1347         <entry>none</entry>
1348        </row>
1349        <row>
1350         <entry>contact-phone</entry>
1351         <entry>ILL contact phone</entry>
1352         <entry>none</entry>
1353        </row>
1354        <row>
1355         <entry>contact-email</entry>
1356         <entry>ILL contact email</entry>
1357         <entry>none</entry>
1358        </row>
1359        <row>
1360         <entry>itemorder-item</entry>
1361         <entry>Position for item (record) requested. An integer</entry>
1362         <entry>1</entry>
1363        </row>
1364       </tbody>
1365      </tgroup>
1366     </table>
1367
1368    </sect2>
1369
1370    <sect2 id="zoom.record.update"><title>Record Update</title>
1371     <para>
1372      For Record Update, type must be set to <literal>update</literal> in
1373      <function>ZOOM_package_send</function>.
1374     </para>
1375
1376     <table frame="top" id="zoom.record.update.options">
1377      <title>Record Update Options</title>
1378      <tgroup cols="3">
1379       <colspec colwidth="4*" colname="name"></colspec>
1380       <colspec colwidth="7*" colname="description"></colspec>
1381       <colspec colwidth="3*" colname="default"></colspec>
1382       <thead>
1383        <row>
1384         <entry>Option</entry>
1385         <entry>Description</entry>
1386         <entry>Default</entry>
1387        </row>
1388       </thead>
1389       <tbody>
1390        <row>
1391         <entry>action</entry>
1392         <entry>
1393          The update action. One of
1394          <literal>specialUpdate</literal>,
1395          <literal>recordInsert</literal>,
1396          <literal>recordReplace</literal>,
1397          <literal>recordDelete</literal>,
1398          <literal>elementUpdate</literal>.
1399         </entry>
1400         <entry><literal>specialUpdate (recordInsert for updateVersion=1 which does not support specialUpdate)</literal></entry>
1401        </row>
1402        <row>
1403         <entry>recordIdOpaque</entry>
1404         <entry>Opaque Record ID</entry>
1405         <entry>none</entry>
1406        </row>
1407        <row>
1408         <entry>recordIdNumber</entry>
1409         <entry>Record ID number</entry>
1410         <entry>none</entry>
1411        </row>
1412        <row>
1413         <entry>record</entry>
1414         <entry>The record itself</entry>
1415         <entry>none</entry>
1416        </row>
1417        <row>
1418         <entry>recordOpaque</entry>
1419         <entry>Specifies an opaque record which is
1420           encoded as an ASN.1 ANY type with the OID as tiven by option
1421           <literal>syntax</literal> (see below).
1422           Option <literal>recordOpaque</literal> is an alternative
1423           to record - and <literal>record</literal> option (above) is
1424           ignored if recordOpaque is set. This option is only available in
1425           YAZ 3.0.35 and later and is meant to facilitate Updates with
1426           servers from OCLC.
1427         </entry>
1428         <entry>none</entry>
1429        </row>
1430        <row>
1431         <entry>syntax</entry>
1432         <entry>The record syntax (transfer syntax). Is a string that
1433          is a known record syntax.
1434         </entry>
1435         <entry>no syntax</entry>
1436        </row>
1437        <row>
1438         <entry>databaseName</entry>
1439         <entry>Database from connection object</entry>
1440         <entry>Default</entry>
1441        </row>
1442        <row>
1443         <entry>correlationInfo.note</entry>
1444         <entry>Correlation Info Note (string)</entry>
1445         <entry>none</entry>
1446        </row>
1447        <row>
1448         <entry>correlationInfo.id</entry>
1449         <entry>Correlation Info ID (integer)</entry>
1450         <entry>none</entry>
1451        </row>
1452        <row>
1453         <entry>elementSetName</entry>
1454         <entry>Element Set for Record</entry>
1455         <entry>none</entry>
1456        </row>
1457        <row>
1458         <entry>updateVersion</entry>
1459         <entry>Record Update version which holds one of the values
1460          1, 2 or 3. Each version has a distinct OID:
1461          1.2.840.10003.9.5
1462          (<ulink url="&url.z39.50.extupdate1;">first version</ulink>) ,
1463          1.2.840.10003.9.5.1
1464          (second version) and
1465          1.2.840.10003.9.5.1.1
1466          (<ulink url="&url.z39.50.extupdate3;">third and
1467           newest version</ulink>).
1468         </entry>
1469         <entry>3</entry>
1470        </row>
1471       </tbody>
1472      </tgroup>
1473     </table>
1474
1475    </sect2>
1476
1477    <sect2 id="zoom.database.create"><title>Database Create</title>
1478     <para>
1479      For Database Create, type must be set to <literal>create</literal> in
1480      <function>ZOOM_package_send</function>.
1481     </para>
1482
1483     <table frame="top" id="zoom.database.create.options">
1484      <title>Database Create Options</title>
1485      <tgroup cols="3">
1486       <colspec colwidth="4*" colname="name"></colspec>
1487       <colspec colwidth="7*" colname="description"></colspec>
1488       <colspec colwidth="3*" colname="default"></colspec>
1489       <thead>
1490        <row>
1491         <entry>Option</entry>
1492         <entry>Description</entry>
1493         <entry>Default</entry>
1494        </row>
1495       </thead>
1496       <tbody>
1497        <row>
1498         <entry>databaseName</entry>
1499         <entry>Database from connection object</entry>
1500         <entry>Default</entry>
1501        </row>
1502       </tbody>
1503      </tgroup>
1504     </table>
1505    </sect2>
1506
1507    <sect2 id="zoom.database.drop"><title>Database Drop</title>
1508     <para>
1509      For Database Drop, type must be set to <literal>drop</literal> in
1510      <function>ZOOM_package_send</function>.
1511     </para>
1512
1513     <table frame="top" id="zoom.database.drop.options">
1514      <title>Database Drop Options</title>
1515      <tgroup cols="3">
1516       <colspec colwidth="4*" colname="name"></colspec>
1517       <colspec colwidth="7*" colname="description"></colspec>
1518       <colspec colwidth="3*" colname="default"></colspec>
1519       <thead>
1520        <row>
1521         <entry>Option</entry>
1522         <entry>Description</entry>
1523         <entry>Default</entry>
1524        </row>
1525       </thead>
1526       <tbody>
1527        <row>
1528         <entry>databaseName</entry>
1529         <entry>Database from connection object</entry>
1530         <entry>Default</entry>
1531        </row>
1532       </tbody>
1533      </tgroup>
1534     </table>
1535    </sect2>
1536
1537    <sect2 id="zoom.commit"><title>Commit Operation</title>
1538     <para>
1539      For Commit, type must be set to <literal>commit</literal> in
1540      <function>ZOOM_package_send</function>.
1541     </para>
1542    </sect2>
1543
1544    <sect2 id="zoom.extended.services.behavior">
1545     <title>Protocol behavior</title>
1546     <para>
1547      All the extended services are Z39.50-only.
1548     </para>
1549     <note>
1550      <para>
1551       The database create, drop and commit services are privately defined
1552       operations.
1553       Refer to <filename>esadmin.asn</filename> in YAZ for the ASN.1
1554       definitions.
1555      </para>
1556     </note>
1557    </sect2>
1558   </sect1>
1559
1560   <sect1 id="zoom.options"><title>Options</title>
1561    <para>
1562     Most &zoom; objects provide a way to specify options to change behavior.
1563     From an implementation point of view a set of options is just like
1564     an associative array / hash.
1565    </para>
1566    <synopsis>
1567      ZOOM_options ZOOM_options_create(void);
1568
1569      ZOOM_options ZOOM_options_create_with_parent(ZOOM_options parent);
1570
1571      void ZOOM_options_destroy(ZOOM_options opt);
1572    </synopsis>
1573    <synopsis>
1574      const char *ZOOM_options_get(ZOOM_options opt, const char *name);
1575
1576      void ZOOM_options_set(ZOOM_options opt, const char *name,
1577                            const char *v);
1578    </synopsis>
1579    <synopsis>
1580      typedef const char *(*ZOOM_options_callback)
1581                             (void *handle, const char *name);
1582
1583      ZOOM_options_callback
1584              ZOOM_options_set_callback(ZOOM_options opt,
1585                                        ZOOM_options_callback c,
1586                                        void *handle);
1587    </synopsis>
1588   </sect1>
1589   <sect1 id="zoom.events"><title>Events</title>
1590    <para>
1591     If you're developing non-blocking applications, you have to deal
1592     with events.
1593    </para>
1594    <synopsis>
1595     int ZOOM_event(int no, ZOOM_connection *cs);
1596    </synopsis>
1597    <para>
1598     The <function>ZOOM_event</function> executes pending events for
1599     a number of connections. Supply the number of connections in
1600     <literal>no</literal> and an array of connections in
1601     <literal>cs</literal> (<literal>cs[0] ... cs[no-1]</literal>).
1602     A pending event could be a sending a search, receiving a response,
1603     etc.
1604     When an event has occurred for one of the connections, this function
1605     returns a positive integer <literal>n</literal> denoting that an event
1606     occurred for connection <literal>cs[n-1]</literal>.
1607     When no events are pending for the connections, a value of zero is
1608     returned.
1609     To ensure that all outstanding requests are performed call this function
1610     repeatedly until zero is returned.
1611    </para>
1612    <para>
1613     If <function>ZOOM_event</function> returns and returns non-zero, the
1614     last event that occurred can be expected.
1615    </para>
1616    <synopsis>
1617     int ZOOM_connection_last_event(ZOOM_connection cs);
1618    </synopsis>
1619    <para>
1620     <function>ZOOM_connection_last_event</function> returns an event type
1621     (integer) for the last event.
1622    </para>
1623
1624    <table frame="top" id="zoom.event.ids">
1625     <title>ZOOM Event IDs</title>
1626     <tgroup cols="2">
1627      <colspec colwidth="4*" colname="name"></colspec>
1628      <colspec colwidth="7*" colname="description"></colspec>
1629      <thead>
1630       <row>
1631        <entry>Event</entry>
1632        <entry>Description</entry>
1633       </row>
1634      </thead>
1635      <tbody>
1636       <row>
1637        <entry>ZOOM_EVENT_NONE</entry>
1638        <entry>No event has occurred</entry>
1639       </row>
1640       <row>
1641        <entry>ZOOM_EVENT_CONNECT</entry>
1642        <entry>TCP/IP connect has initiated</entry>
1643       </row>
1644       <row>
1645        <entry>ZOOM_EVENT_SEND_DATA</entry>
1646        <entry>Data has been transmitted (sending)</entry>
1647       </row>
1648       <row>
1649        <entry>ZOOM_EVENT_RECV_DATA</entry>
1650        <entry>Data has been received)</entry>
1651       </row>
1652       <row>
1653        <entry>ZOOM_EVENT_TIMEOUT</entry>
1654        <entry>Timeout</entry>
1655       </row>
1656       <row>
1657        <entry>ZOOM_EVENT_UNKNOWN</entry>
1658        <entry>Unknown event</entry>
1659       </row>
1660       <row>
1661        <entry>ZOOM_EVENT_SEND_APDU</entry>
1662        <entry>An APDU has been transmitted (sending)</entry>
1663       </row>
1664       <row>
1665        <entry>ZOOM_EVENT_RECV_APDU</entry>
1666        <entry>An APDU has been received</entry>
1667       </row>
1668       <row>
1669        <entry>ZOOM_EVENT_RECV_RECORD</entry>
1670        <entry>A result-set record has been received</entry>
1671       </row>
1672       <row>
1673        <entry>ZOOM_EVENT_RECV_SEARCH</entry>
1674        <entry>A search result been received</entry>
1675       </row>
1676      </tbody>
1677     </tgroup>
1678    </table>
1679   </sect1>
1680  </chapter>
1681
1682  <!-- Keep this comment at the end of the file
1683  Local variables:
1684  mode: sgml
1685  sgml-omittag:t
1686  sgml-shorttag:t
1687  sgml-minimize-attributes:nil
1688  sgml-always-quote-attributes:t
1689  sgml-indent-step:1
1690  sgml-indent-data:t
1691  sgml-parent-document: "yaz.xml"
1692  sgml-local-catalogs: nil
1693  sgml-namecase-general:t
1694  End:
1695  -->
1696