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