-<!-- $Id: zoom.xml,v 1.15 2002-01-02 10:30:25 adam Exp $ -->
+<!-- $Id: zoom.xml,v 1.16 2002-01-03 12:18:37 adam Exp $ -->
<chapter id="zoom"><title>Building clients with ZOOM</title>
<para>
</para>
</sect2>
</sect1>
- <sect1 id="zoom.options"><title>Options</title>
- <para>
- 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 associative array / hash array, etc.
- </para>
- <synopsis>
- ZOOM_options ZOOM_options_create (void);
-
- ZOOM_options ZOOM_options_create_with_parent (ZOOM_options parent);
-
- void ZOOM_options_destroy (ZOOM_options opt);
- </synopsis>
- <synopsis>
- const char *ZOOM_options_get (ZOOM_options opt, const char *name);
-
- void ZOOM_options_set (ZOOM_options opt, const char *name,
- const char *v);
- </synopsis>
- <synopsis>
- typedef const char *(*ZOOM_options_callback)
- (void *handle, const char *name);
-
- ZOOM_options_callback
- ZOOM_options_set_callback (ZOOM_options opt,
- ZOOM_options_callback c,
- void *handle);
- </synopsis>
- </sect1>
- <sect1 id="zoom.scan"><title>Scsn</title>
+ <sect1 id="zoom.scan"><title>Scan</title>
<para>
This section describes an interface for Scan. Scan is not an
official part of the ZOOM model yet. The result of a scan operation
void ZOOM_scanset_destroy (ZOOM_scanset scan);
+
+ const char *ZOOM_scanset_option_get (ZOOM_scanset scan,
+ const char *key);
+
+ void ZOOM_scanset_option_set (ZOOM_scanset scan, const char *key,
+ const char *val);
</synopsis>
<para>
The scan set is created by function
of the actual term respectively.
A scan set may be freed by a call to function
<function>ZOOM_scanset_destroy</function>.
- </para>
- </sect1>
+ Functions <function>ZOOM_scanset_option_get</function> and
+ <function>ZOOM_scanset_option_set</function> retrieves and sets
+ an option respectively.
+ </para>
+
+ <table frame="top"><title>ZOOM Scan Set Options</title>
+ <tgroup cols="3">
+ <colspec colwidth="4*" colname="name"></colspec>
+ <colspec colwidth="7*" colname="description"></colspec>
+ <colspec colwidth="2*" colname="default"></colspec>
+ <thead>
+ <row>
+ <entry>Option</entry>
+ <entry>Description</entry>
+ <entry>Default</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row><entry>
+ number</entry><entry>Number of Scan Terms requested in next scan.
+ After scan it holds the actual number of terms returend.
+ </entry><entry>10</entry></row>
+ <row><entry>
+ position</entry><entry>Preferred Position of term in response
+ in next scan; actual position after completion of scan.
+ </entry><entry>1</entry></row>
+ <row><entry>
+ stepSize</entry><entry>Step Size
+ </entry><entry>0</entry></row>
+ <row><entry>
+ scanStatus</entry><entry>An integer indicating the Scan Status
+ of last scan.
+ </entry><entry>0</entry></row>
+ </tbody>
+ </tgroup>
+ </table>
+
+ </sect1>
+ <sect1 id="zoom.options"><title>Options</title>
+ <para>
+ 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 associative array / hash array, etc.
+ </para>
+ <synopsis>
+ ZOOM_options ZOOM_options_create (void);
+
+ ZOOM_options ZOOM_options_create_with_parent (ZOOM_options parent);
+
+ void ZOOM_options_destroy (ZOOM_options opt);
+ </synopsis>
+ <synopsis>
+ const char *ZOOM_options_get (ZOOM_options opt, const char *name);
+
+ void ZOOM_options_set (ZOOM_options opt, const char *name,
+ const char *v);
+ </synopsis>
+ <synopsis>
+ typedef const char *(*ZOOM_options_callback)
+ (void *handle, const char *name);
+
+ ZOOM_options_callback
+ ZOOM_options_set_callback (ZOOM_options opt,
+ ZOOM_options_callback c,
+ void *handle);
+ </synopsis>
+ </sect1>
<sect1 id="zoom.events"><title>Events</title>
<para>
If you're developing non-blocking applications, you have to deal
/*
* Public header for ZOOM C.
- * $Id: zoom.h,v 1.9 2002-01-02 10:30:25 adam Exp $
+ * $Id: zoom.h,v 1.10 2002-01-03 12:18:37 adam Exp $
*/
#include <yaz/yconfig.h>
ZOOM_EXPORT
void ZOOM_scanset_destroy (ZOOM_scanset scan);
+
+ZOOM_EXPORT
+const char *ZOOM_scanset_option_get (ZOOM_scanset scan, const char *key);
+
+ZOOM_EXPORT
+void ZOOM_scanset_option_set (ZOOM_scanset scan, const char *key,
+ const char *val);
/* ----------------------------------------------------------- */
/* options */
typedef const char *(*ZOOM_options_callback)(void *handle, const char *name);
int ZOOM_options_get_int (ZOOM_options opt, const char *name, int defa);
ZOOM_EXPORT
+void ZOOM_options_set_int(ZOOM_options opt, const char *name, int value);
+
+ZOOM_EXPORT
void ZOOM_options_addref (ZOOM_options opt);
/* ----------------------------------------------------------- */
/*
- * $Id: zoom-c.c,v 1.17 2002-01-03 10:23:46 adam Exp $
+ * $Id: zoom-c.c,v 1.18 2002-01-03 12:18:38 adam Exp $
*
* ZOOM layer for C, connections, result sets, queries.
*/
response_diag(c, res->entries->nonsurrogateDiagnostics[0]);
scan->scan_response = res;
nmem_transfer (scan->odr->mem, nmem);
+ if (res->stepSize)
+ ZOOM_options_set_int (scan->options, "stepSize", *res->stepSize);
+ if (res->positionOfTerm)
+ ZOOM_options_set_int (scan->options, "position", *res->positionOfTerm);
+ if (res->scanStatus)
+ ZOOM_options_set_int (scan->options, "scanStatus", *res->scanStatus);
+ if (res->numberOfEntriesReturned)
+ ZOOM_options_set_int (scan->options, "number",
+ *res->numberOfEntriesReturned);
nmem_destroy (nmem);
return 1;
}
return term;
}
+const char *ZOOM_scanset_option_get (ZOOM_scanset scan, const char *key)
+{
+ return ZOOM_options_get (scan->options, key);
+}
+
+void ZOOM_scanset_option_set (ZOOM_scanset scan, const char *key,
+ const char *val)
+{
+ ZOOM_options_set (scan->options, key, val);
+}
+
static int ZOOM_connection_exec_task (ZOOM_connection c)
{
ZOOM_task task = c->tasks;
/*
- * $Id: zoom-opt.c,v 1.2 2001-11-18 21:14:23 adam Exp $
+ * $Id: zoom-opt.c,v 1.3 2002-01-03 12:18:38 adam Exp $
*
* ZOOM layer for C, options handling
*/
return defa;
return atoi(v);
}
+
+void ZOOM_options_set_int(ZOOM_options opt, const char *name, int value)
+{
+ char s[40];
+
+ sprintf (s, "%d", value);
+ ZOOM_options_set (opt, name, s);
+}
/*
- * $Id: zoomtst8.c,v 1.1 2001-12-30 22:21:11 adam Exp $
+ * $Id: zoomtst8.c,v 1.2 2002-01-03 12:18:38 adam Exp $
*
* Asynchronous multi-target client doing scan
*/
/* connect and init */
ZOOM_connection_connect (z[i], argv[1+i], 0);
+
}
- /* search all */
+ /* scan all */
for (i = 0; i<no; i++)
+ {
+ /* set number of scan terms to be returned. */
+ ZOOM_connection_option_set (z[i], "number", "7");
+ /* and perform scan */
s[i] = ZOOM_connection_scan (z[i], argv[argc-1]);
+ }
/* network I/O. pass number of connections and array of connections */
while (ZOOM_event (no, z))
term = ZOOM_scanset_term (s[i], j, &occur, &len);
if (term)
printf ("%d %.*s %d\n", j, len, term, occur);
-
}
}
}