3 ZOOM_connection_option_getl(c, key, len)
4 ZOOM_connection_option_setl(c, key, val, len)
5 ZOOM_connection_errcode(c)
6 ZOOM_connection_errmsg(c)
7 ZOOM_connection_addinfo(c)
9 ZOOM_resultset_record_immediate(s, pos)
10 ZOOM_resultset_cache_reset(r)
11 ZOOM_connection_package(c, options)
12 ZOOM_package_destroy(p)
13 ZOOM_package_send(p, type)
14 ZOOM_package_option_get(p, key)
15 ZOOM_package_option_set(p, key, val)
16 ZOOM_resultset_sort(r, sort_type, sort_spec)
17 ZOOM_resultset_sort1(r, sort_type, sort_spec)
18 ZOOM_options_set_callback(opt, function, handle)
19 ZOOM_options_create_with_parent2(parent1, parent2)
20 ZOOM_options_getl(opt, name, len)
21 ZOOM_options_setl(opt, name, value, len)
22 ZOOM_options_get_bool(opt, name, defa)
23 ZOOM_options_get_int(opt, name, defa)
24 ZOOM_options_set_int(opt, name, value)
27 <!-- $Id: zoom.xml,v 1.42 2005-11-08 17:12:55 mike Exp $ -->
28 <chapter id="zoom"><title>ZOOM</title>
30 &zoom; is an acronym for 'Z39.50 Object-Orientation Model' and is
31 an initiative started by Mike Taylor (Mike is from the UK, which
32 explains the peculiar name of the model). The goal of &zoom; is to
33 provide a common Z39.50 client API not bound to a particular
34 programming language or toolkit.
39 A recent addition to &yaz; is SRW support. You can now make
40 SRW ZOOM connections by specifying scheme <literal>http://</literal>
41 for the hostname for a connection.
46 The lack of a simple Z39.50 client API for &yaz; has become more
47 and more apparent over time. So when the first &zoom; specification
49 an implementation for &yaz; was quickly developed. For the first time, it is
50 now as easy (or easier!) to develop clients than servers with &yaz;. This
51 chapter describes the &zoom; C binding. Before going further, please
52 reconsider whether C is the right programming language for the job.
53 There are other language bindings available for &yaz;, and still
55 are in active development. See the
56 <ulink url="http://zoom.z3950.org/">ZOOM web-site</ulink> for
61 In order to fully understand this chapter you should read and
62 try the example programs <literal>zoomtst1.c</literal>,
63 <literal>zoomtst2.c</literal>, .. in the <literal>zoom</literal>
68 The C language misses features found in object oriented languages
69 such as C++, Java, etc. For example, you'll have to manually,
70 destroy all objects you create, even though you may think of them as
71 temporary. Most objects has a <literal>_create</literal> - and a
72 <literal>_destroy</literal> variant.
73 All objects are in fact pointers to internal stuff, but you don't see
74 that because of typedefs. All destroy methods should gracefully ignore a
75 <literal>NULL</literal> pointer.
78 In each of the sections below you'll find a sub section called
79 protocol behavior, that describes how the API maps to the Z39.50
82 <sect1 id="zoom.connections"><title>Connections</title>
84 <para>The Connection object is a session with a target.
87 #include <yaz/zoom.h>
89 ZOOM_connection ZOOM_connection_new (const char *host, int portnum);
91 ZOOM_connection ZOOM_connection_create (ZOOM_options options);
93 void ZOOM_connection_connect(ZOOM_connection c, const char *host,
95 void ZOOM_connection_destroy (ZOOM_connection c);
98 Connection objects are created with either function
99 <function>ZOOM_connection_new</function> or
100 <function>ZOOM_connection_create</function>.
101 The former creates and automatically attempts to establish a network
102 connection with the target. The latter doesn't establish
103 a connection immediately, thus allowing you to specify options
104 before establishing network connection using the function
105 <function>ZOOM_connection_connect</function>.
106 If the port number, <literal>portnum</literal>, is zero, the
107 <literal>host</literal> is consulted for a port specification.
108 If no port is given, 210 is used. A colon denotes the beginning of
109 a port number in the host string. If the host string includes a
110 slash, the following part specifies a database for the connection.
113 You can prefix the host with a scheme followed by colon. The
114 default scheme is <literal>tcp</literal> (Z39.50 protocol).
115 The scheme <literal>http</literal> selects SRW over HTTP.
118 Connection objects should be destroyed using the function
119 <function>ZOOM_connection_destroy</function>.
122 void ZOOM_connection_option_set (ZOOM_connection c,
126 const char *ZOOM_connection_option_get (ZOOM_connection c,
130 The <function>ZOOM_connection_option_set</function> allows you to
131 set an option given by <parameter>key</parameter> to the value
132 <parameter>value</parameter> for the connection.
133 Function <function>ZOOM_connection_option_get</function> returns
134 the value for an option given by <parameter>key</parameter>.
136 <table frame="top"><title>ZOOM Connection Options</title>
138 <colspec colwidth="4*" colname="name"></colspec>
139 <colspec colwidth="7*" colname="description"></colspec>
140 <colspec colwidth="3*" colname="default"></colspec>
143 <entry>Option</entry>
144 <entry>Description</entry>
145 <entry>Default</entry>
150 implementationName</entry><entry>Name of Your client
151 </entry><entry>none</entry></row>
153 user</entry><entry>Authentication user name
154 </entry><entry>none</entry></row>
156 group</entry><entry>Authentication group name
157 </entry><entry>none</entry></row>
159 password</entry><entry>Authentication password.
160 </entry><entry>none</entry></row>
162 host</entry><entry>Target host. This setting is "read-only".
163 It's automatically set internally when connecting to a target.
164 </entry><entry>none</entry></row>
166 proxy</entry><entry>Proxy host
167 </entry><entry>none</entry></row>
169 async</entry><entry>If true (1) the connection operates in
170 asynchronous operation which means that all calls are non-blocking
172 <link linkend="zoom.events"><function>ZOOM_event</function></link>.
173 </entry><entry>0</entry></row>
175 maximumRecordSize</entry><entry> Maximum size of single record.
176 </entry><entry>1 MB</entry></row>
178 preferredMessageSize</entry><entry> Maximum size of multiple records.
179 </entry><entry>1 MB</entry></row>
181 lang</entry><entry> Language for negotiation.
182 </entry><entry>none</entry></row>
184 charset</entry><entry> Character set for negotiation.
185 </entry><entry>none</entry></row>
187 serverImplementationId</entry><entry>
188 Implementation ID of server. (The old targetImplementationId
189 option is also supported for the benefit of old applications.)
190 </entry><entry>none</entry></row>
192 targetImplementationName</entry><entry>
193 Implementation Name of server. (The old
194 targetImplementationName option is also supported for the
195 benefit of old applications.)
196 </entry><entry>none</entry></row>
198 serverImplementationVersion</entry><entry>
199 Implementation Version of server. (the old
200 targetImplementationVersion option is also supported for the
201 benefit of old applications.)
202 </entry><entry>none</entry></row>
204 databaseName</entry><entry>One or more database names
205 separated by character plus (<literal>+</literal>), which to
206 be used by subsequent search requests on this Connection.
207 </entry><entry>Default</entry></row>
209 piggyback</entry><entry>True (1) if piggyback should be
210 used in searches; false (0) if not.
211 </entry><entry>1</entry></row>
213 smallSetUpperBound</entry><entry>If hits is less than or equal to this
214 value, then target will return all records using small element set name
215 </entry><entry>0</entry></row>
217 largeSetLowerBound</entry><entry>If hits is greater than this
218 value, the target will return no records.
219 </entry><entry>1</entry></row>
221 mediumSetPresentNumber</entry><entry>This value represents
222 the number of records to be returned as part of a search when when
223 hits is less than or equal to large set lower bound and if hits
224 is greater than small set upper bound.
225 </entry><entry>0</entry></row>
227 smallSetElementSetName</entry><entry>
228 The element set name to be used for small result sets.
229 </entry><entry>none</entry></row>
231 mediumSetElementSetName</entry><entry>
232 The element set name to be for medium-sized result sets.
233 </entry><entry>none</entry></row>
238 If either option <literal>lang</literal> or <literal>charset</literal>
240 <ulink url="http://lcweb.loc.gov/z3950/agency/defns/charneg-3.html">
241 Character Set and Language Negotiation</ulink> is in effect.
244 int ZOOM_connection_error (ZOOM_connection c, const char **cp,
245 const char **addinfo);
246 int ZOOM_connection_error_x (ZOOM_connection c, const char **cp,
247 const char **addinfo, const char **dset);
250 Function <function>ZOOM_connection_error</function> checks for
251 errors for the last operation(s) performed. The function returns
252 zero if no errors occurred; non-zero otherwise indicating the error.
253 Pointers <parameter>cp</parameter> and <parameter>addinfo</parameter>
254 holds messages for the error and additional-info if passed as
255 non-<literal>NULL</literal>. Function
256 <function>ZOOM_connection_error_x</function> is an extended version
257 of <function>ZOOM_connection_error</function> that is capable of
258 returning name of diagnostic set in <parameter>dset</parameter>.
260 <sect2><title>Z39.50 Protocol behavior</title>
262 The calls <function>ZOOM_connection_new</function> and
263 <function>ZOOM_connection_connect</function> establishes a TCP/IP
264 connection and sends an Initialize Request to the target if
265 possible. In addition, the calls waits for an Initialize Response
266 from the target and the result is inspected (OK or rejected).
269 If <literal>proxy</literal> is set then the client will establish
270 a TCP/IP connection with the peer as specified by the
271 <literal>proxy</literal> host and the hostname as part of the
272 connect calls will be set as part of the Initialize Request.
273 The proxy server will then "forward" the PDU's transparently
274 to the target behind the proxy.
277 For the authentication parameters, if option <literal>user</literal>
278 is set and both options <literal>group</literal> and
279 <literal>pass</literal> are unset, then Open style
280 authentication is used (Version 2/3) in which case the username
281 is usually followed by a slash, then by a password.
282 If either <literal>group</literal>
283 or <literal>pass</literal> is set then idPass authentication
284 (Version 3 only) is used. If none of the options are set, no
285 authentication parameters are set as part of the Initialize Request
289 When option <literal>async</literal> is 1, it really means that
290 all network operations are postponed (and queued) until the
291 function <literal>ZOOM_event</literal> is invoked. When doing so
292 it doesn't make sense to check for errors after
293 <literal>ZOOM_connection_new</literal> is called since that
294 operation "connecting - and init" is still incomplete and the
295 API cannot tell the outcome (yet).
298 <sect2><title>SRW Protocol behavior</title>
300 The SRW protocol doesn't feature an Inititialize Request, so
301 the connection phase merely establishes a TCP/IP connection
302 with the SOAP service.
304 <para>Most of the ZOOM connection options do not
305 affect SRW and they are ignored. However, future versions
306 of &yaz; might honor <literal>implementationName</literal> and
307 put that as part of User-Agent header for HTTP requests.
310 The <literal>charset</literal> is used in the Content-Type header
315 <sect1 id="zoom.query"><title>Queries</title>
317 Query objects represents queries.
320 ZOOM_query ZOOM_query_create(void);
322 void ZOOM_query_destroy(ZOOM_query q);
324 int ZOOM_query_prefix(ZOOM_query q, const char *str);
326 int ZOOM_query_cql(ZOOM_query s, const char *str);
328 int ZOOM_query_sortby(ZOOM_query q, const char *criteria);
331 Create query objects using <function>ZOOM_query_create</function>
332 and destroy them by calling <function>ZOOM_query_destroy</function>.
333 RPN-queries can be specified in <link linkend="PQF">PQF</link>
334 notation by using the
335 function <function>ZOOM_query_prefix</function>.
336 The <function>ZOOM_query_cql</function> specifies a CQL
337 query to be sent to the server/target.
338 More query types will be added in future versions of &yaz;, such as
339 <link linkend="CCL">CCL</link> to RPN-mapping, native CCL query,
340 etc. In addition to a search, a sort criteria may be set. Function
341 <function>ZOOM_query_sortby</function> specifies a
342 sort criteria using the same string notation for sort as offered by
343 the <link linkend="sortspec">YAZ client</link>.
345 <sect2><title>Protocol behavior</title>
347 The query object is just an interface for the member Query
348 in the SearchRequest. The sortby-function is an interface to the
349 sortSequence member of the SortRequest.
353 <sect1 id="zoom.resultsets"><title>Result sets</title>
355 The result set object is a container for records returned from
359 ZOOM_resultset ZOOM_connection_search(ZOOM_connection,
362 ZOOM_resultset ZOOM_connection_search_pqf(ZOOM_connection c,
365 void ZOOM_resultset_destroy(ZOOM_resultset r);
368 Function <function>ZOOM_connection_search</function> creates
369 a result set given a connection and query.
370 Destroy a result set by calling
371 <function>ZOOM_resultset_destroy</function>.
372 Simple clients may using PQF only may use function
373 <function>ZOOM_connection_search_pqf</function> in which case
374 creating query objects is not necessary.
377 void ZOOM_resultset_option_set (ZOOM_resultset r,
381 const char *ZOOM_resultset_option_get (ZOOM_resultset r,
384 size_t ZOOM_resultset_size (ZOOM_resultset r);
387 Functions <function>ZOOM_resultset_options_set</function> and
388 <function>ZOOM_resultset_get</function> sets and gets an option
389 for a result set similar to <function>ZOOM_connection_option_get</function>
390 and <function>ZOOM_connection_option_set</function>.
393 The number of hits also called result-count is returned by
394 function <function>ZOOM_resultset_size</function>.
396 <table frame="top"><title>ZOOM Result set Options</title>
398 <colspec colwidth="4*" colname="name"></colspec>
399 <colspec colwidth="7*" colname="description"></colspec>
400 <colspec colwidth="2*" colname="default"></colspec>
403 <entry>Option</entry>
404 <entry>Description</entry>
405 <entry>Default</entry>
410 start</entry><entry>Offset of first record to be
411 retrieved from target. First record has offset 0 unlike the
412 protocol specifications where first record has position 1.
413 </entry><entry>0</entry></row>
415 count</entry><entry>Number of records to be retrieved.
416 </entry><entry>0</entry></row>
418 presentChunk</entry><entry>The number of records to be
419 requested from the server in each chunk (present requst). The
420 value 0 means to request all the records in a single chunk.
421 (The old <literal>step</literal>
422 option is also supported for the benefit of old applications.)
423 </entry><entry>0</entry></row>
425 elementSetName</entry><entry>Element-Set name of records.
426 Most targets should honor element set name <literal>B</literal>
427 and <literal>F</literal> for brief and full respectively.
428 </entry><entry>none</entry></row>
430 preferredRecordSyntax</entry><entry>Preferred Syntax, such as
431 <literal>USMARC</literal>, <literal>SUTRS</literal>, etc.
432 </entry><entry>none</entry></row>
434 schema</entry><entry>Schema for retrieval, such as
435 <literal>Gils-schema</literal>, <literal>Geo-schema</literal>, etc.
436 </entry><entry>none</entry></row>
438 setname</entry><entry>Name of Result Set (Result Set ID).
439 If this option isn't set, the ZOOM module will automatically
440 allocate a result set name.
441 </entry><entry>default</entry></row>
446 For servers that support Search Info report, the following
447 options may be read using <function>ZOOM_resultset_get</function>.
448 This detailed information is read after a successful search has
452 This information is a list of of items, where each item is
453 information about a term or subquery. All items in the list
455 <literal>SearchResult.</literal><replaceable>no</replaceable>
456 where no presents the item number (0=first, 1=second).
457 Read <literal>searchresult.size</literal> to determine the
460 <table frame="top"><title>Search Info Report options</title>
462 <colspec colwidth="4*" colname="name"></colspec>
463 <colspec colwidth="7*" colname="description"></colspec>
466 <entry>Option</entry>
467 <entry>Description</entry>
472 <entry>searchresult.size</entry>
474 number of search result entries. This option is-nonexistant
475 if no entries are returned by the server.
479 <entry>searchresult.<replaceable>no</replaceable>.id</entry>
480 <entry>sub query ID</entry>
483 <entry>searchresult.<replaceable>no</replaceable>.count</entry>
484 <entry>result count for item (number of hits)</entry>
487 <entry>searchresult.<replaceable>no</replaceable>.subquery.term</entry>
488 <entry>subquery term</entry>
492 searchresult.<replaceable>no</replaceable>.interpretation.term
494 <entry>interpretation term</entry>
498 searchresult.<replaceable>no</replaceable>.recommendation.term
500 <entry>recommendation term</entry>
506 <title>Z39.50 Protocol behavior</title>
508 The creation of a result set involves at least a SearchRequest
509 - SearchResponse protocol handshake. Following that, if a sort
510 criteria was specified as part of the query, a SortRequest -
511 SortResponse handshake takes place. Note that it is necessary to
512 perform sorting before any retrieval takes place, so no records will
513 be returned from the target as part of the SearchResponse because these
514 would be unsorted. Hence, piggyback is disabled when sort criteria
515 are set. Following Search - and a possible sort - Retrieval takes
516 place - as one or more Present Requests/Response pairs being
520 The API allows for two different modes for retrieval. A high level
521 mode which is somewhat more powerful and a low level one.
522 The low level is enabled when searching on a Connection object
523 for which the settings
524 <literal>smallSetUpperBound</literal>,
525 <literal>mediumSetPresentNumber</literal> and
526 <literal>largeSetLowerBound</literal> are set. The low level mode
527 thus allows you to precisely set how records are returned as part
528 of a search response as offered by the Z39.50 protocol.
529 Since the client may be retrieving records as part of the
530 search response, this mode doesn't work well if sorting is used.
533 The high-level mode allows you to fetch a range of records from
534 the result set with a given start offset. When you use this mode
535 the client will automatically use piggyback if that is possible
536 with the target and perform one or more present requests as needed.
537 Even if the target returns fewer records as part of a present response
538 because of a record size limit, etc. the client will repeat sending
539 present requests. As an example, if option <literal>start</literal>
540 is 0 (default) and <literal>count</literal> is 4, and
541 <literal>piggyback</literal> is 1 (default) and no sorting criteria
542 is specified, then the client will attempt to retrieve the 4
543 records as part the search response (using piggyback). On the other
544 hand, if either <literal>start</literal> is positive or if
545 a sorting criteria is set, or if <literal>piggyback</literal>
546 is 0, then the client will not perform piggyback but send Present
550 If either of the options <literal>mediumSetElementSetName</literal> and
551 <literal>smallSetElementSetName</literal> are unset, the value
552 of option <literal>elementSetName</literal> is used for piggyback
553 searches. This means that for the high-level mode you only have
554 to specify one elementSetName option rather than three.
558 <title>SRW Protocol behavior</title>
560 Current version of &yaz; does not take advantage of a result set id
561 returned by the SRW server. Future versions might do, however.
562 Since, the ZOOM driver does not save result set IDs any
563 present (retrieval) is transformed to a SRW SearchRetrieveRequest
564 with same query but, possibly, different offsets.
567 Option <literal>schema</literal> specifies SRW schema
568 for retrieval. However, options <literal>elementSetName</literal> and
569 <literal>preferredRecordSyntax</literal> are ignored.
572 Options <literal>start</literal> and <literal>count</literal>
573 are supported by SRW.
574 The remaining options
575 <literal>piggyback</literal>,
576 <literal>smallSetUpperBound</literal>,
577 <literal>largeSetLowerBound</literal>,
578 <literal>mediumSetPresentNumber</literal>,
579 <literal>mediumSetElementSetName</literal>,
580 <literal>smallSetElementSetName</literal> are
584 SRW supports CQL queries, <emphasis>not</emphasis> PQF.
585 If PQF is used, however, the PQF query is transferred anyway
586 using non-standard element <literal>pQuery</literal> in
587 SRW SearchRetrieveRequest.
590 Unfortunately, SRW does not define a database setting. Hence,
591 <literal>databaseName</literal> is unsupported and ignored.
592 However, the path part in host parameter for functions
593 <function>ZOOM_connecton_new</function> and
594 <function>ZOOM_connection_connect</function> acts as a
595 database (at least for the &yaz; SRW server).
599 <sect1 id="zoom.records"><title>Records</title>
601 A record object is a retrieval record on the client side -
602 created from result sets.
605 void ZOOM_resultset_records (ZOOM_resultset r,
607 size_t start, size_t count);
608 ZOOM_record ZOOM_resultset_record (ZOOM_resultset s, size_t pos);
610 const char *ZOOM_record_get (ZOOM_record rec, const char *type,
613 ZOOM_record ZOOM_record_clone (ZOOM_record rec);
615 void ZOOM_record_destroy (ZOOM_record rec);
618 References to temporary records are returned by functions
619 <function>ZOOM_resultset_records</function> or
620 <function>ZOOM_resultset_record</function>.
623 If a persistent reference to a record is desired
624 <function>ZOOM_record_clone</function> should be used.
625 It returns a record reference that should be destroyed
626 by a call to <function>ZOOM_record_destroy</function>.
629 A single record is returned by function
630 <function>ZOOM_resultset_record</function> that takes a
631 position as argument. First record has position zero.
632 If no record could be obtained <literal>NULL</literal> is returned.
635 Function <function>ZOOM_resultset_records</function> retrieves
636 a number of records from a result set. Parameter <literal>start</literal>
637 and <literal>count</literal> specifies the range of records to
638 be returned. Upon completion array
639 <literal>recs[0], ..recs[count-1]</literal>
640 holds record objects for the records. The array of records
641 <literal>recs</literal> should be allocated prior the call
642 <function>ZOOM_resultset_records</function>. Note that for those
643 records that couldn't be retrieved from the target
644 <literal>recs[ ..]</literal> is set to <literal>NULL</literal>.
646 <para id="zoom.record.get">
647 In order to extract information about a single record,
648 <function>ZOOM_record_get</function> is provided. The
649 function returns a pointer to certain record information. The
650 nature (type) of the pointer depends on the parameter,
651 <parameter>type</parameter>.
654 The <parameter>type</parameter> is a string of the format:
657 <replaceable>form</replaceable>[; charset=<replaceable>from</replaceable>[,<replaceable>to</replaceable>]]
660 where <replaceable>form</replaceable> specifies the format of the
661 returned record, <replaceable>from</replaceable>
662 specifies the character set of the record in its original form
663 (as returned by the server), <replaceable>to</replaceable> specifies
664 the output (returned)
665 character set encoding.
666 If charset is not given, then no character set conversion takes place.
667 If <replaceable>to</replaceable> is omitted UTF-8 is assumed.
670 In addition, for certain types, the length
671 <literal>len</literal> passed will be set to the size in bytes of
672 the returned information.
675 The following are the supported values for <replaceable>form</replaceable>.
677 <varlistentry><term><literal>database</literal></term>
678 <listitem><para>Database of record is returned
679 as a C null-terminated string. Return type
680 <literal>const char *</literal>.
683 <varlistentry><term><literal>syntax</literal></term>
684 <listitem><para>The transfer syntax of the record is returned
685 as a C null-terminated string containing the symbolic name of
686 the record syntax, e.g. <literal>Usmarc</literal>. Return type
688 <literal>const char *</literal>.
691 <varlistentry><term><literal>render</literal></term>
692 <listitem><para>The record is returned in a display friendly
693 format. Upon completion buffer is returned
694 (type <literal>const char *</literal>) and length is stored in
695 <literal>*len</literal>.
698 <varlistentry><term><literal>raw</literal></term>
699 <listitem><para>The record is returned in the internal
700 YAZ specific format. For GRS-1, Explain, and others, the
701 raw data is returned as type
702 <literal>Z_External *</literal> which is just the type for
703 the member <literal>retrievalRecord</literal> in
704 type <literal>NamePlusRecord</literal>.
705 For SUTRS and octet aligned record (including all MARCs) the
706 octet buffer is returned and the length of the buffer.
709 <varlistentry><term><literal>xml</literal></term>
710 <listitem><para>The record is returned in XML if possible.
711 SRW/SRU and Z39.50 records with transfer syntax XML are
712 returned verbatim. MARC records are returned in
713 <ulink url="http://www.loc.gov/standards/marcxml/">
716 (converted from ISO2709 to MARCXML by YAZ).
717 GRS-1 and OPAC records are not supported for this form.
718 Upon completion, the XML buffer is returned
719 (type <literal>const char *</literal>) and length is stored in
720 <literal>*len</literal>.
723 <varlistentry><term><literal>opac</literal></term>
724 <listitem><para>OPAC for record is returned in XML.
731 <ulink url="http://www.loc.gov/marc/">
735 <ulink url="http://www.loc.gov/marc/specifications/speccharmarc8.html">
738 character set encoding.
739 An application that wishes to display in Latin-1 would use
741 render; charset=marc8,iso-8859-1
744 <sect2><title>Z39.50 Protocol behavior</title>
746 The functions <function>ZOOM_resultset_record</function> and
747 <function>ZOOM_resultset_records</function> inspects the client-side
748 record cache. Records not found in cache are fetched using
750 The functions may block (and perform network I/O) - even though option
751 <literal>async</literal> is 1, because they return records objects.
752 (and there's no way to return records objects without retrieving them!).
755 There is a trick, however, in the usage of function
756 <function>ZOOM_resultset_records</function> that allows for
757 delayed retrieval (and makes it non-blocking). By using
758 a null pointer for <parameter>recs</parameter> you're indicating
759 you're not interested in getting records objects
760 <emphasis>now</emphasis>.
763 <sect2><title>SRW Protocol behavior</title>
765 The ZOOM driver for SRW treats records returned by a SRW server
766 as if they where Z39.50 records with transfer syntax XML and
767 no element set name or database name.
771 <sect1 id="zoom.scan"><title>Scan</title>
773 This section describes an interface for Scan. Scan is not an
774 official part of the ZOOM model yet. The result of a scan operation
775 is the <literal>ZOOM_scanset</literal> which is a set of terms
776 returned by a target.
780 The Scan interface is Z39.50 only. SRW version 1.0 does not
785 ZOOM_scanset ZOOM_connection_scan (ZOOM_connection c,
786 const char *startterm);
788 size_t ZOOM_scanset_size(ZOOM_scanset scan);
790 const char * ZOOM_scanset_term(ZOOM_scanset scan, size_t pos,
791 int *occ, size_t *len);
793 const char * ZOOM_scanset_display_term(ZOOM_scanset scan, size_t pos,
794 int *occ, size_t *len);
796 void ZOOM_scanset_destroy (ZOOM_scanset scan);
798 const char *ZOOM_scanset_option_get (ZOOM_scanset scan,
801 void ZOOM_scanset_option_set (ZOOM_scanset scan, const char *key,
805 The scan set is created by function
806 <function>ZOOM_connection_scan</function> which performs a scan
807 operation on the connection using the specified startterm.
808 If the operation was successful, the size of the scan set can be
809 retrieved by a call to <function>ZOOM_scanset_size</function>.
810 Like result sets, the items are numbered 0,..size-1.
811 To obtain information about a particular scan term, call function
812 <function>ZOOM_scanset_term</function>. This function takes
813 a scan set offset <literal>pos</literal> and returns a pointer
814 to a <emphasis>raw term</emphasis> or <literal>NULL</literal> if
816 If present, the <literal>occ</literal> and <literal>len</literal>
817 are set to the number of occurrences and the length
818 of the actual term respectively.
819 <function>ZOOM_scanset_display_term</function> is similar to
820 <function>ZOOM_scanset_term</function> except that it returns
821 the <emphasis>display term</emphasis> rather than the raw term.
822 In a few cases, the term is different from display term. Always
823 use the display term for display and the raw term for subsequent
824 scan operations (to get more terms, next scan result, etc).
827 A scan set may be freed by a call to function
828 <function>ZOOM_scanset_destroy</function>.
829 Functions <function>ZOOM_scanset_option_get</function> and
830 <function>ZOOM_scanset_option_set</function> retrieves and sets
831 an option respectively.
834 <table frame="top"><title>ZOOM Scan Set Options</title>
836 <colspec colwidth="4*" colname="name"></colspec>
837 <colspec colwidth="7*" colname="description"></colspec>
838 <colspec colwidth="2*" colname="default"></colspec>
841 <entry>Option</entry>
842 <entry>Description</entry>
843 <entry>Default</entry>
848 number</entry><entry>Number of Scan Terms requested in next scan.
849 After scan it holds the actual number of terms returned.
850 </entry><entry>10</entry></row>
852 position</entry><entry>Preferred Position of term in response
853 in next scan; actual position after completion of scan.
854 </entry><entry>1</entry></row>
856 stepSize</entry><entry>Step Size
857 </entry><entry>0</entry></row>
859 scanStatus</entry><entry>An integer indicating the Scan Status
861 </entry><entry>0</entry></row>
867 <sect1 id="zoom.options"><title>Options</title>
869 Most &zoom; objects provide a way to specify options to change behavior.
870 From an implementation point of view a set of options is just like
871 an associative array / hash array, etc.
874 ZOOM_options ZOOM_options_create (void);
876 ZOOM_options ZOOM_options_create_with_parent (ZOOM_options parent);
878 void ZOOM_options_destroy (ZOOM_options opt);
881 const char *ZOOM_options_get (ZOOM_options opt, const char *name);
883 void ZOOM_options_set (ZOOM_options opt, const char *name,
887 typedef const char *(*ZOOM_options_callback)
888 (void *handle, const char *name);
890 ZOOM_options_callback
891 ZOOM_options_set_callback (ZOOM_options opt,
892 ZOOM_options_callback c,
896 <sect1 id="zoom.events"><title>Events</title>
898 If you're developing non-blocking applications, you have to deal
902 int ZOOM_event (int no, ZOOM_connection *cs);
905 The <function>ZOOM_event</function> executes pending events for
906 a number of connections. Supply the number of connections in
907 <literal>no</literal> and an array of connections in
908 <literal>cs</literal> (<literal>cs[0] ... cs[no-1]</literal>).
909 A pending event could be a sending a search, receiving a response,
911 When an event has occurred for one of the connections, this function
912 returns a positive integer <literal>n</literal> denoting that an event
913 occurred for connection <literal>cs[n-1]</literal>.
914 When no events are pending for the connections, a value of zero is
916 To ensure that all outstanding requests are performed call this function
917 repeatedly until zero is returned.
920 If <function>ZOOM_event</function> returns and returns non-zero, the
921 last event that occurred can be expected.
924 int ZOOM_connection_last_event(ZOOM_connection cs);
927 <function>ZOOM_connection_last_event</function> returns an event type
928 (integer) for the last event.
931 <table frame="top"><title>ZOOM Event IDs</title>
933 <colspec colwidth="4*" colname="name"></colspec>
934 <colspec colwidth="7*" colname="description"></colspec>
938 <entry>Description</entry>
943 <entry>ZOOM_EVENT_NONE</entry>
944 <entry>No event has occurred</entry>
947 <entry>ZOOM_EVENT_CONNECT</entry>
948 <entry>TCP/IP connect has initiated</entry>
951 <entry>ZOOM_EVENT_SEND_DATA</entry>
952 <entry>Data has been transmitted (sending)</entry>
955 <entry>ZOOM_EVENT_RECV_DATA</entry>
956 <entry>Data has been received)</entry>
959 <entry>ZOOM_EVENT_TIMEOUT</entry>
960 <entry>Timeout</entry>
963 <entry>ZOOM_EVENT_UNKNOWN</entry>
964 <entry>Unknown event</entry>
967 <entry>ZOOM_EVENT_SEND_APDU</entry>
968 <entry>An APDU has been transmitted (sending)</entry>
971 <entry>ZOOM_EVENT_RECV_APDU</entry>
972 <entry>An APDU has been received</entry>
975 <entry>ZOOM_EVENT_RECV_RECORD</entry>
976 <entry>A result-set record has been received</entry>
979 <entry>ZOOM_EVENT_RECV_SEARCH</entry>
980 <entry>A search result been received</entry>
988 <!-- Keep this comment at the end of the file
993 sgml-minimize-attributes:nil
994 sgml-always-quote-attributes:t
997 sgml-parent-document: "yaz.xml"
998 sgml-local-catalogs: nil
999 sgml-namecase-general:t