Added Z3950_record_dup.
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.
-<!-- $Id: zoom.xml,v 1.8 2001-11-13 23:00:42 adam Exp $ -->
+<!-- $Id: zoom.xml,v 1.9 2001-11-15 08:58:28 adam Exp $ -->
<chapter id="zoom"><title>Building clients with ZOOM</title>
<para>
</para>
<para>
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
- <ulink url="http://zoom.z3950.org/">zoom.z3950.org</ulink> for
+ are in active development. See the
+ <ulink url="http://zoom.z3950.org/">ZOOM website</ulink> for
more information.
</para>
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);
</synopsis>
<para>
Function <function>Z3950_resultset_options</function> sets or
The number of hits also called result-count is returned by
function <function>Z3950_resultset_size</function>.
</para>
- <para>
- Function <function>Z3950_resultset_get</function> is similar to
- <link linkend="zoom.record.get">
- <function>Z3950_record_get</function></link> but
- instead of operating on a record object, it operates on a record on
- a given offset within a result set.
- </para>
<table frame="top"><title>ZOOM Result set Options</title>
<tgroup cols="3">
<colspec colwidth="4*" colname="name"></colspec>
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);
</synopsis>
<para>
- Records are created by functions
+ References to temporary records are returned by functions
<function>Z3950_resultset_records</function> or
- <function>Z3950_resultset_record</function>
- and destroyed by <function>Z3950_record_destroy</function>.
+ <function>Z3950_resultset_record</function>.
+ </para>
+ <para>
+ If a persistent pointer 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
+ <function>Z3950_record_destroy</function>.
</para>
<para>
- A single record is created and returned by function
+ A single record is returned by function
<function>Z3950_resultset_record</function> that takes a
position as argument. First record has position zero.
If no record could be obtained <literal>NULL</literal> is returned.
the returned information.
<variablelist>
<varlistentry><term><literal>database</literal></term>
- <listitem><para>The database that holds the record is returned
- as a C string. Return type <literal>char *</literal>.
+ <listitem><para>Database of record is returned
+ as a C null-terminated string. Return type <literal>char *</literal>.
</para></listitem>
</varlistentry>
<varlistentry><term><literal>syntax</literal></term>
<listitem><para>The transfer syntax (OID) of the record is returned
- as a C string. Return type <literal>char *</literal>.
+ as a C null-terminated string. Return type <literal>char *</literal>.
</para></listitem>
</varlistentry>
<varlistentry><term><literal>render</literal></term>
/*
* 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 <yaz/yconfig.h>
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,
/* ----------------------------------------------------------- */
/* 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 */
ZOOM_EXPORT
int Z3950_query_sortby(Z3950_query s, const char *criteria);
-
/* ----------------------------------------------------------- */
/* options */
typedef const char *(*Z3950_options_callback)(void *handle, const char *name);
/*
- * $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.
*/
}
}
-int Z3950_resultset_size (Z3950_resultset r)
+size_t Z3950_resultset_size (Z3950_resultset r)
{
return r->size;
}
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;
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)
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,
/*
- * $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
*/
for (i = 0; i<count; i++)
{
int pos = i + start;
- const char *db = Z3950_resultset_get (r, pos, "database", 0);
+ Z3950_record rec = Z3950_resultset_record (r, pos);
+ const char *db = Z3950_record_get (rec, "database", 0);
int len;
- const char *rec = Z3950_resultset_get (r, pos, "render", &len);
- const char *syntax = Z3950_resultset_get (r, pos, "syntax", 0);
+ const char *render = Z3950_record_get (rec, "render", &len);
+ const char *syntax = Z3950_record_get (rec, "syntax", 0);
/* if rec is non-null, we got a record for display */
if (rec)
{
printf ("%d %s %s\n", pos+1, (db ? db : "unknown"), syntax);
- if (rec)
- fwrite (rec, 1, len, stdout);
+ if (render)
+ fwrite (render, 1, len, stdout);
putchar ('\n');
}
}
/*
- * $Id: zoomtst3.c,v 1.2 2001-10-24 12:24:43 adam Exp $
+ * $Id: zoomtst3.c,v 1.3 2001-11-15 08:58:29 adam Exp $
*
* Asynchronous multi-target client doing search and piggyback retrieval
*/
{
int len; /* length of buffer rec */
const char *rec =
- Z3950_resultset_get (r[i], pos, "render", &len);
+ Z3950_record_get (
+ Z3950_resultset_record (r[i], pos), "render", &len);
/* if rec is non-null, we got a record for display */
if (rec)
{
/*
- * $Id: zoomtst5.c,v 1.3 2001-11-06 17:05:19 adam Exp $
+ * $Id: zoomtst5.c,v 1.4 2001-11-15 08:58:29 adam Exp $
*
* Asynchronous multi-target client doing search, sort and present
*/
fwrite (str, 1, len, stdout);
putchar ('\n');
}
- Z3950_record_destroy (rec);
}
}
}
Z3950_connection_destroy (z[i]);
}
Z3950_options_destroy(o);
+ exit(0);
}
/*
- * $Id: zoomtst6.c,v 1.3 2001-11-06 17:05:19 adam Exp $
+ * $Id: zoomtst6.c,v 1.4 2001-11-15 08:58:29 adam Exp $
*
* Asynchronous multi-target client doing two searches
*/
/* go through all records at target */
for (pos = 0; pos < 20; pos++)
{
+ Z3950_record rec = Z3950_resultset_record (r, pos);
+
/* get database for record and record itself at pos */
- const char *db = Z3950_resultset_get (r, pos, "database", 0);
+ const char *db = Z3950_record_get (rec, "database", 0);
int len;
- const char *rec = Z3950_resultset_get (r, pos, "render", &len);
+ const char *render = Z3950_record_get (rec, "render", &len);
/* if rec is non-null, we got a record for display */
if (rec)
{
printf ("%d %s\n", pos+1, (db ? db : "unknown"));
- if (rec)
- fwrite (rec, 1, len, stdout);
+ if (render)
+ fwrite (render, 1, len, stdout);
putchar ('\n');
}
}
/*
- * $Id: zoomtst7.c,v 1.5 2001-11-13 22:57:03 adam Exp $
+ * $Id: zoomtst7.c,v 1.6 2001-11-15 08:58:29 adam Exp $
*
* API test..
*/
for (j = 0; j < 10; j++)
{
Z3950_record recs[2];
- size_t recs_count = 2;
char query[40];
Z3950_query s = Z3950_query_create ();
r[j] = Z3950_connection_search (z, s); /* non-piggy */
Z3950_resultset_records (r[j], recs, 0, 2); /* first two */
- Z3950_record_destroy (recs[0]);
- Z3950_record_destroy (recs[1]);
Z3950_resultset_records (r[j], recs, 1, 2); /* third */
exit (1);
}
}
- Z3950_record_destroy (recs[0]);
- Z3950_record_destroy (recs[1]);
Z3950_query_destroy (s);
}
}
Z3950_options_destroy (o);
+ xmalloc_trav("");
+ nmem_exit();
+ xmalloc_trav("");
exit (0);
}