Possible compatibility problems with earlier versions marked with '*'.
-* ZOOO. Added Z3950_record_dup. Removed Z3950_resultset_get.
+* ZOOM. Removed Z3950_connection_host. Use Z3950_connection_option_get
+with key="host" to get same result.
+
+* ZOOM. Added Z3950_record_dup and removed Z3950_resultset_get.
Function Z3950_resultset_record(s) returns references to records
"owned" by resultset. To become owner use Z3950_record_dup.
-<!-- $Id: zoom.xml,v 1.10 2001-11-15 21:58:50 adam Exp $ -->
+<!-- $Id: zoom.xml,v 1.11 2001-11-16 09:52:39 adam Exp $ -->
<chapter id="zoom"><title>Building clients with ZOOM</title>
<para>
const char *Z3950_connection_option_get (Z3950_connection c,
const char *key);
-
- const char *Z3950_connection_host (Z3950_connection c);
</synopsis>
<para>
The <function>Z3950_connection_option_set</function> allows you to
pass</entry><entry>Authentication password
</entry><entry>none</entry></row>
<row><entry>
+ host</entry><entry>Target host. This setting is "read-only".
+ It's automatically set internally when connecting to a target.
+ </entry><entry>none</entry></row>
+ <row><entry>
proxy</entry><entry>Proxy host
</entry><entry>none</entry></row>
<row><entry>
</tbody>
</tgroup>
</table>
- <para>
- Function <function>Z3950_connection_host</function> returns
- the host for the connection as specified in a call to
- <function>Z3950_connection_new</function> or
- <function>Z3950_connection_connect</function>.
- This function returns <literal>NULL</literal> if host isn't
- set for the connection.
- </para>
<synopsis>
int Z3950_connection_error (Z3950_connection c, const char **cp,
const char **addinfo);
<function>Z3950_resultset_record</function>.
</para>
<para>
- If a persistent pointer to a record is desired
+ If a persistent reference to a record is desired
<function>Z3950_record_dup</function> should be used.
It returns a record reference that at any
later stage should be destroyed by
<para>
The functions <function>Z3950_resultset_record</function> and
<function>Z3950_resultset_records</function> inspects the client-side
- record cache. If the records(s) were not found, i.e. not yet retrieved
- from, they are fetched using Present Requests.
+ record cache. Records not found in cache are fetched using
+ Present.
+ The functions may block (and perform network I/O) - even though option
+ <literal>async</literal> is 1, because they return records objects.
+ (and there's no way to return records objects without retrieving them!).
+ </para>
+ <para>
+ There is a trick, however, in the usage of function
+ <function>Z3950_resultset_records</function> that allows for
+ delayed retrieval (and makes it non-blocking). By passing
+ a null pointer for <parameter>recs</parameter> you're indicating
+ you're not interested in getting records objects
+ <emphasis>now</emphasis>.
</para>
</sect2>
</sect1>
<sect1 id="zoom.options"><title>Options</title>
<para>
- Most &zoom; objects provide a way to specify options to default behavior.
+ Most &zoom; objects provide a way to specify options to change behavior.
From an implementation point of view a set of options is just like
- an associate array / hash array, etc.
+ an associative array / hash array, etc.
</para>
<synopsis>
Z3950_options Z3950_options_create (void);
/*
* Public header for ZOOM C.
- * $Id: zoom.h,v 1.5 2001-11-15 13:16:02 adam Exp $
+ * $Id: zoom.h,v 1.6 2001-11-16 09:52:39 adam Exp $
*/
-/* 1. Renamed type Z3950_search to Z3950_query and the functions
- that manipulate it..
- Changed positions/sizes to be of type size_t rather than int.
- 2. Deleted Z3950_resultset_get. Added Z3950_record_dup. Record
- reference(s) returned by Z350_resultset_records and
- Z3950_resultset_record are "owned" by result set.
-*/
#include <yaz/yconfig.h>
#define ZOOM_EXPORT YAZ_EXPORT
ZOOM_EXPORT
void Z3950_connection_option_set (Z3950_connection c, const char *key,
const char *val);
-/* return host for connection */
-ZOOM_EXPORT
-const char *Z3950_connection_host (Z3950_connection c);
/* return error code (0 == success, failure otherwise). cp
holds error string on failure, addinfo holds addititional info (if any)
/*
- * $Id: zoom-c.c,v 1.8 2001-11-15 21:59:40 adam Exp $
+ * $Id: zoom-c.c,v 1.9 2001-11-16 09:52:39 adam Exp $
*
* ZOOM layer for C, connections, result sets, queries.
*/
else
c->host_port = xstrdup(host);
+ Z3950_options_set(c->options, "host", c->host_port);
+
c->async = Z3950_options_get_bool (c->options, "async", 0);
task = Z3950_connection_add_task (c, Z3950_TASK_CONNECT);
return s;
}
-const char *Z3950_connection_host (Z3950_connection c)
-{
- return c->host_port;
-}
-
void Z3950_query_destroy(Z3950_query s)
{
if (!s)
/*
- * $Id: zoomsh.c,v 1.4 2001-11-15 08:58:29 adam Exp $
+ * $Id: zoomsh.c,v 1.5 2001-11-16 09:52:39 adam Exp $
*
* ZOOM-C Shell
*/
const char *h;
if (!c[i])
continue;
- if ((h = Z3950_connection_host(c[i])) && !strcmp (h, host))
+ if ((h = Z3950_connection_option_get(c[i], "host"))
+ && !strcmp (h, host))
{
Z3950_connection_destroy (c[i]);
c[i] = 0;
continue;
if ((error = Z3950_connection_error(c[i], &errmsg, &addinfo)))
fprintf (stderr, "%s error: %s (%d) %s\n",
- Z3950_connection_host(c[i]), errmsg,
+ Z3950_connection_option_get(c[i], "host"), errmsg,
error, addinfo);
else if (r[i])
{
continue;
if ((error = Z3950_connection_error(c[i], &errmsg, &addinfo)))
fprintf (stderr, "%s error: %s (%d) %s\n",
- Z3950_connection_host(c[i]), errmsg,
+ Z3950_connection_option_get(c[i], "host"), errmsg,
error, addinfo);
else if (r[i])
{
int start = Z3950_options_get_int (options, "start", 0);
int count = Z3950_options_get_int (options, "count", 0);
- printf ("%s: %d hits\n", Z3950_connection_host(c[i]),
+ printf ("%s: %d hits\n", Z3950_connection_option_get(c[i], "host"),
Z3950_resultset_size(r[i]));
/* and display */
display_records (c[i], r[i], start, count);
for (j = -1, i = 0; i<MAX_CON; i++)
{
const char *h;
- if (c[i] && (h = Z3950_connection_host(c[i])) &&
+ if (c[i] && (h = Z3950_connection_option_get(c[i], "host")) &&
!strcmp (h, host))
{
Z3950_connection_destroy (c[i]);
Z3950_connection_connect (c[i], host, 0);
if ((error = Z3950_connection_error(c[i], &errmsg, &addinfo)))
- printf ("%s error: %s (%d) %s\n", Z3950_connection_host(c[i]),
+ printf ("%s error: %s (%d) %s\n",
+ Z3950_connection_option_get(c[i], "host"),
errmsg, error, addinfo);
}
/*
- * $Id: zoomtst4.c,v 1.3 2001-11-06 17:05:19 adam Exp $
+ * $Id: zoomtst4.c,v 1.4 2001-11-16 09:52:39 adam Exp $
*
* Asynchronous multi-target going through proxy doing search and retrieve
* using present.
const char *errmsg, *addinfo;
if ((error = Z3950_connection_error(z[i], &errmsg, &addinfo)))
fprintf (stderr, "%s error: %s (%d) %s\n",
- Z3950_connection_host(z[i]), errmsg, error, addinfo);
+ Z3950_connection_option_get(z[i], "host"),
+ errmsg, error, addinfo);
}
/* destroy stuff and exit */
/*
- * $Id: zoomtst5.c,v 1.4 2001-11-15 08:58:29 adam Exp $
+ * $Id: zoomtst5.c,v 1.5 2001-11-16 09:52:39 adam Exp $
*
* Asynchronous multi-target client doing search, sort and present
*/
const char *errmsg, *addinfo;
if ((error = Z3950_connection_error(z[i], &errmsg, &addinfo)))
fprintf (stderr, "%s error: %s (%d) %s\n",
- Z3950_connection_host(z[i]),
+ Z3950_connection_option_get(z[i], "host"),
errmsg, error, addinfo);
else
{
/* OK, no major errors. Look at the result count */
int pos;
- printf ("%s: %d hits\n", Z3950_connection_host(z[i]),
+ printf ("%s: %d hits\n", Z3950_connection_option_get(z[i], "host"),
Z3950_resultset_size(r[i]));
/* go through all records at target */
for (pos = 0; pos < 20; pos++)
/*
- * $Id: zoomtst6.c,v 1.5 2001-11-15 21:59:40 adam Exp $
+ * $Id: zoomtst6.c,v 1.6 2001-11-16 09:52:39 adam Exp $
*
* Asynchronous multi-target client doing two searches
*/
const char *errmsg, *addinfo;
if ((error = Z3950_connection_error(z[i], &errmsg, &addinfo)))
fprintf (stderr, "%s error: %s (%d) %s\n",
- Z3950_connection_host(z[i]),
+ Z3950_connection_option_get(z[i], "host"),
errmsg, error, addinfo);
else
{
- display_records (Z3950_connection_host(z[i]), r1[i]);
- display_records (Z3950_connection_host(z[i]), r2[i]);
+ display_records (Z3950_connection_option_get(z[i], "host"), r1[i]);
+ display_records (Z3950_connection_option_get(z[i], "host"), r2[i]);
}
}
/* destroy stuff and exit */