From: Adam Dickmeiss Date: Thu, 15 Nov 2001 08:58:28 +0000 (+0000) Subject: ZOOM: record objects "owned" by result sets. X-Git-Tag: YAZ.1.8.3~12 X-Git-Url: http://lists.indexdata.dk/?a=commitdiff_plain;h=d00666d5391066b1acba398090170d3766ec7e4f;p=yaz-moved-to-github.git ZOOM: record objects "owned" by result sets. Added Z3950_record_dup. --- diff --git a/CHANGELOG b/CHANGELOG index a3b69b8..993efc3 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,11 @@ Possible compatibility problems with earlier versions marked with '*'. +* ZOOO. Added Z3950_record_dup. Removed Z3950_resultset_get. +Function Z3950_resultset_record(s) returns references to records +"owned" by resultset. To become owner use Z3950_record_dup. + +Function z_ext_record handles Extended Services. + --- 1.8.2 2001/11/12 CCL Parser fix: ignore token comma when dealing with and-lists. diff --git a/doc/zoom.xml b/doc/zoom.xml index 5049709..4b62b50 100644 --- a/doc/zoom.xml +++ b/doc/zoom.xml @@ -1,4 +1,4 @@ - + Building clients with ZOOM @@ -10,16 +10,16 @@ The lack of a simple Z39.50 client API for &yaz; has become more - and more apparent over time. So when the first ZOOM specification + and more apparent over time. So when the first &zoom; specification became available, an implementation for &yaz; was quickly developed. For the first time, it is now as easy (or easier!) to develop clients than servers with &yaz;. This - chapter describes the ZOOM C binding. Before going futher, please + chapter describes the &zoom; C binding. Before going futher, please reconsider whether C is the right programming language for the job. There are other language bindings available for &yaz;, and still more - are in active development. See the ZOOM website at - zoom.z3950.org for + are in active development. See the + ZOOM website for more information. @@ -260,10 +260,7 @@ const char *key, const char *val); - int Z3950_resultset_size (Z3950_resultset r); - - void *Z3950_resultset_get (Z3950_resultset s, size_t pos, - const char *type, size_t *len); + size_t Z3950_resultset_size (Z3950_resultset r); Function Z3950_resultset_options sets or @@ -274,13 +271,6 @@ The number of hits also called result-count is returned by function Z3950_resultset_size. - - Function Z3950_resultset_get is similar to - - Z3950_record_get but - instead of operating on a record object, it operates on a record on - a given offset within a result set. - ZOOM Result set Options @@ -410,16 +400,24 @@ void *Z3950_record_get (Z3950_record rec, const char *type, size_t *len); + Z3950_record Z3950_record_dup (Z3950_record rec); + void Z3950_record_destroy (Z3950_record rec); - Records are created by functions + References to temporary records are returned by functions Z3950_resultset_records or - Z3950_resultset_record - and destroyed by Z3950_record_destroy. + Z3950_resultset_record. + + + If a persistent pointer 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 + Z3950_record_destroy. - A single record is created and returned by function + A single record is returned by function Z3950_resultset_record that takes a position as argument. First record has position zero. If no record could be obtained NULL is returned. @@ -446,13 +444,13 @@ the returned information. database - The database that holds the record is returned - as a C string. Return type char *. + Database of record is returned + as a C null-terminated string. Return type char *. syntax The transfer syntax (OID) of the record is returned - as a C string. Return type char *. + as a C null-terminated string. Return type char *. render diff --git a/include/yaz/zoom.h b/include/yaz/zoom.h index 484a7cd..baa1084 100644 --- a/include/yaz/zoom.h +++ b/include/yaz/zoom.h @@ -1,12 +1,14 @@ /* * Public header for ZOOM C. - * $Id: zoom.h,v 1.3 2001-11-06 17:05:19 adam Exp $ + * $Id: zoom.h,v 1.4 2001-11-15 08:58:29 adam Exp $ */ -/* 1. Modification - Renamed type Z3950_search to Z3950_query and the functions +/* 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 @@ -100,14 +102,10 @@ void Z3950_resultset_destroy(Z3950_resultset r); ZOOM_EXPORT const char *Z3950_resultset_option (Z3950_resultset r, const char *key, const char *val); -/* return size of result set (hit count, AKA resultCount) */ +/* return size of result set (alias hit count AKA result count) */ ZOOM_EXPORT -int Z3950_resultset_size (Z3950_resultset r); +size_t Z3950_resultset_size (Z3950_resultset r); -/* return record at pos (starting from ), render given spec in type */ -ZOOM_EXPORT -void *Z3950_resultset_get (Z3950_resultset s, size_t pos, const char *type, - size_t *len); /* retrieve records */ ZOOM_EXPORT void Z3950_resultset_records (Z3950_resultset r, Z3950_record *recs, @@ -124,14 +122,18 @@ Z3950_record Z3950_resultset_record_immediate (Z3950_resultset s, size_t pos); /* ----------------------------------------------------------- */ /* records */ -/* Get record information, in a form given by type */ +/* get record information, in a form given by type */ ZOOM_EXPORT void *Z3950_record_get (Z3950_record rec, const char *type, size_t *len); -/* Destroy record */ +/* destroy record */ ZOOM_EXPORT void Z3950_record_destroy (Z3950_record rec); +/* return copy of record */ +ZOOM_EXPORT +Z3950_record Z3950_record_dup (Z3950_record srec); + /* ----------------------------------------------------------- */ /* searches */ @@ -148,7 +150,6 @@ int Z3950_query_prefix(Z3950_query s, const char *str); ZOOM_EXPORT int Z3950_query_sortby(Z3950_query s, const char *criteria); - /* ----------------------------------------------------------- */ /* options */ typedef const char *(*Z3950_options_callback)(void *handle, const char *name); diff --git a/zoom/zoom-c.c b/zoom/zoom-c.c index 45181e7..fa38d1d 100644 --- a/zoom/zoom-c.c +++ b/zoom/zoom-c.c @@ -1,5 +1,5 @@ /* - * $Id: zoom-c.c,v 1.5 2001-11-13 22:57:03 adam Exp $ + * $Id: zoom-c.c,v 1.6 2001-11-15 08:58:29 adam Exp $ * * ZOOM layer for C, connections, result sets, queries. */ @@ -417,7 +417,7 @@ void Z3950_resultset_destroy(Z3950_resultset r) } } -int Z3950_resultset_size (Z3950_resultset r) +size_t Z3950_resultset_size (Z3950_resultset r) { return r->size; } @@ -767,7 +767,7 @@ static void response_diag (Z3950_connection c, Z_DiagRec *p) c->error = *r->condition; } -Z3950_record Z3950_record_dup (Z3950_record srec) +Z3950_record Z3950_record_dup (const Z3950_record srec) { char *buf; int size; @@ -791,10 +791,7 @@ Z3950_record Z3950_record_dup (Z3950_record srec) Z3950_record Z3950_resultset_record_immediate (Z3950_resultset s,size_t pos) { - Z3950_record rec = record_cache_lookup (s, pos, 0); - if (!rec) - return 0; - return Z3950_record_dup (rec); + return record_cache_lookup (s, pos, 0); } Z3950_record Z3950_resultset_record (Z3950_resultset r, size_t pos) @@ -893,13 +890,6 @@ void *Z3950_record_get (Z3950_record rec, const char *type, size_t *len) return 0; } -void *Z3950_resultset_get (Z3950_resultset s, size_t pos, const char *type, - size_t *len) -{ - Z3950_record rec = record_cache_lookup (s, pos, 0); - return Z3950_record_get (rec, type, len); -} - static void record_cache_add (Z3950_resultset r, Z_NamePlusRecord *npr, int pos, diff --git a/zoom/zoomsh.c b/zoom/zoomsh.c index 8ff31b1..69e3195 100644 --- a/zoom/zoomsh.c +++ b/zoom/zoomsh.c @@ -1,5 +1,5 @@ /* - * $Id: zoomsh.c,v 1.3 2001-11-06 17:05:19 adam Exp $ + * $Id: zoomsh.c,v 1.4 2001-11-15 08:58:29 adam Exp $ * * ZOOM-C Shell */ @@ -117,16 +117,17 @@ static void display_records (Z3950_connection c, for (i = 0; i