From: Adam Dickmeiss Date: Fri, 16 Nov 2001 09:52:39 +0000 (+0000) Subject: Removed Z3950_connection_host. X-Git-Tag: YAZ.1.8.3~6 X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=commitdiff_plain;h=fd2f1538cdb20385c2c267d318c59d567eb3d242 Removed Z3950_connection_host. --- diff --git a/CHANGELOG b/CHANGELOG index 6dc7bcb..c1ef0fd 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,9 @@ 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. diff --git a/doc/zoom.xml b/doc/zoom.xml index 315e78e..0c702f1 100644 --- a/doc/zoom.xml +++ b/doc/zoom.xml @@ -1,4 +1,4 @@ - + Building clients with ZOOM @@ -86,8 +86,6 @@ const char *Z3950_connection_option_get (Z3950_connection c, const char *key); - - const char *Z3950_connection_host (Z3950_connection c); The Z3950_connection_option_set allows you to @@ -122,6 +120,10 @@ passAuthentication password none + hostTarget host. This setting is "read-only". + It's automatically set internally when connecting to a target. + none + proxyProxy host none @@ -139,14 +141,6 @@ - - Function Z3950_connection_host returns - the host for the connection as specified in a call to - Z3950_connection_new or - Z3950_connection_connect. - This function returns NULL if host isn't - set for the connection. - int Z3950_connection_error (Z3950_connection c, const char **cp, const char **addinfo); @@ -414,7 +408,7 @@ Z3950_resultset_record. - If a persistent pointer to a record is desired + If a persistent reference to a record is desired Z3950_record_dup should be used. It returns a record reference that at any later stage should be destroyed by @@ -478,16 +472,27 @@ The functions Z3950_resultset_record and Z3950_resultset_records 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 + async is 1, because they return records objects. + (and there's no way to return records objects without retrieving them!). + + + There is a trick, however, in the usage of function + Z3950_resultset_records that allows for + delayed retrieval (and makes it non-blocking). By passing + a null pointer for recs you're indicating + you're not interested in getting records objects + now. Options - 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. Z3950_options Z3950_options_create (void); diff --git a/include/yaz/zoom.h b/include/yaz/zoom.h index d1abf25..c7df143 100644 --- a/include/yaz/zoom.h +++ b/include/yaz/zoom.h @@ -1,15 +1,8 @@ /* * 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 #define ZOOM_EXPORT YAZ_EXPORT @@ -56,9 +49,6 @@ const char *Z3950_connection_option_get (Z3950_connection c, const char *key); 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) diff --git a/zoom/zoom-c.c b/zoom/zoom-c.c index 436fae9..04fb7e8 100644 --- a/zoom/zoom-c.c +++ b/zoom/zoom-c.c @@ -1,5 +1,5 @@ /* - * $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. */ @@ -236,6 +236,8 @@ void Z3950_connection_connect(Z3950_connection c, 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); @@ -259,11 +261,6 @@ Z3950_query Z3950_query_create(void) return s; } -const char *Z3950_connection_host (Z3950_connection c) -{ - return c->host_port; -} - void Z3950_query_destroy(Z3950_query s) { if (!s) diff --git a/zoom/zoomsh.c b/zoom/zoomsh.c index 69e3195..f0bcadd 100644 --- a/zoom/zoomsh.c +++ b/zoom/zoomsh.c @@ -1,5 +1,5 @@ /* - * $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 */ @@ -96,7 +96,8 @@ static void cmd_close (Z3950_connection *c, Z3950_resultset *r, 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; @@ -160,7 +161,7 @@ static void cmd_show (Z3950_connection *c, Z3950_resultset *r, 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]) { @@ -208,7 +209,7 @@ static void cmd_search (Z3950_connection *c, Z3950_resultset *r, 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]) { @@ -216,7 +217,7 @@ static void cmd_search (Z3950_connection *c, Z3950_resultset *r, 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); @@ -269,7 +270,7 @@ static void cmd_connect (Z3950_connection *c, Z3950_resultset *r, for (j = -1, i = 0; i