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