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