From: Adam Dickmeiss Date: Thu, 3 Jan 2002 12:18:37 +0000 (+0000) Subject: More options handling for scan. X-Git-Tag: YAZ.1.8.4~4 X-Git-Url: http://lists.indexdata.dk/?a=commitdiff_plain;h=cd8a27308e5bb886f561b517d091437c7afbf53c;p=yaz-moved-to-github.git More options handling for scan. --- diff --git a/doc/zoom.xml b/doc/zoom.xml index b08d798..1a4efe0 100644 --- a/doc/zoom.xml +++ b/doc/zoom.xml @@ -1,4 +1,4 @@ - + Building clients with ZOOM @@ -497,36 +497,7 @@ - Options - - 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. - - - ZOOM_options ZOOM_options_create (void); - - ZOOM_options ZOOM_options_create_with_parent (ZOOM_options parent); - - void ZOOM_options_destroy (ZOOM_options opt); - - - const char *ZOOM_options_get (ZOOM_options opt, const char *name); - - void ZOOM_options_set (ZOOM_options opt, const char *name, - const char *v); - - - 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); - - - Scsn + Scan This section describes an interface for Scan. Scan is not an official part of the ZOOM model yet. The result of a scan operation @@ -544,6 +515,12 @@ 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); The scan set is created by function @@ -561,8 +538,73 @@ of the actual term respectively. A scan set may be freed by a call to function ZOOM_scanset_destroy. - - + Functions ZOOM_scanset_option_get and + ZOOM_scanset_option_set retrieves and sets + an option respectively. + + + ZOOM Scan Set Options + + + + + + + Option + Description + Default + + + + + numberNumber of Scan Terms requested in next scan. + After scan it holds the actual number of terms returend. + 10 + + positionPreferred Position of term in response + in next scan; actual position after completion of scan. + 1 + + stepSizeStep Size + 0 + + scanStatusAn integer indicating the Scan Status + of last scan. + 0 + + +
+ +
+ Options + + 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. + + + ZOOM_options ZOOM_options_create (void); + + ZOOM_options ZOOM_options_create_with_parent (ZOOM_options parent); + + void ZOOM_options_destroy (ZOOM_options opt); + + + const char *ZOOM_options_get (ZOOM_options opt, const char *name); + + void ZOOM_options_set (ZOOM_options opt, const char *name, + const char *v); + + + 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); + + Events If you're developing non-blocking applications, you have to deal diff --git a/include/yaz/zoom.h b/include/yaz/zoom.h index ebbbf13..f44dde5 100644 --- a/include/yaz/zoom.h +++ b/include/yaz/zoom.h @@ -1,6 +1,6 @@ /* * 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 @@ -172,6 +172,13 @@ size_t ZOOM_scanset_size(ZOOM_scanset scan); 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); @@ -202,6 +209,9 @@ ZOOM_EXPORT 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); /* ----------------------------------------------------------- */ diff --git a/zoom/zoom-c.c b/zoom/zoom-c.c index c87a035..2c6297b 100644 --- a/zoom/zoom-c.c +++ b/zoom/zoom-c.c @@ -1,5 +1,5 @@ /* - * $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. */ @@ -1092,6 +1092,15 @@ static int scan_response (ZOOM_connection c, Z_ScanResponse *res) 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; } @@ -1350,6 +1359,17 @@ const char *ZOOM_scanset_term (ZOOM_scanset scan, size_t pos, 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; diff --git a/zoom/zoom-opt.c b/zoom/zoom-opt.c index f99092e..a7efdc7 100644 --- a/zoom/zoom-opt.c +++ b/zoom/zoom-opt.c @@ -1,5 +1,5 @@ /* - * $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 */ @@ -132,3 +132,11 @@ int ZOOM_options_get_int (ZOOM_options opt, const char *name, int defa) 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); +} diff --git a/zoom/zoomtst8.c b/zoom/zoomtst8.c index 81c1173..71fdbf5 100644 --- a/zoom/zoomtst8.c +++ b/zoom/zoomtst8.c @@ -1,5 +1,5 @@ /* - * $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 */ @@ -39,10 +39,16 @@ int main(int argc, char **argv) /* connect and init */ ZOOM_connection_connect (z[i], argv[1+i], 0); + } - /* search all */ + /* scan all */ for (i = 0; i