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