From 13671e7cc0f3dd4e4b02f94d64a50778c5696ba6 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Sun, 18 Nov 2001 21:14:22 +0000 Subject: [PATCH] Prefix ZOOM_ instead of Z3950_. Documentation updates. --- CHANGELOG | 6 +- configure.in | 4 +- debian/rules | 2 +- doc/installation.xml | 40 ++-- doc/zoom.xml | 172 +++++++-------- include/yaz/yaz-version.h | 4 +- include/yaz/zoom.h | 110 +++++----- win/yaz.rc | 8 +- yaz.spec | 2 +- zoom/zoom-c.c | 506 ++++++++++++++++++++++----------------------- zoom/zoom-opt.c | 46 ++--- zoom/zoom-p.h | 76 +++---- zoom/zoomsh.c | 120 +++++------ zoom/zoomtst1.c | 20 +- zoom/zoomtst2.c | 24 +-- zoom/zoomtst3.c | 38 ++-- zoom/zoomtst4.c | 42 ++-- zoom/zoomtst5.c | 62 +++--- zoom/zoomtst6.c | 70 +++---- zoom/zoomtst7.c | 83 ++++---- 20 files changed, 719 insertions(+), 716 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index c1ef0fd..6d356bf 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,11 +1,13 @@ Possible compatibility problems with earlier versions marked with '*'. +*** ZOOM. Prefix for ZOOM definitions changed from Z3950_ to ZOOM_. + * 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. +* ZOOM. Added Z3950_record_clone and removed Z3950_resultset_get. Function Z3950_resultset_record(s) returns references to records -"owned" by resultset. To become owner use Z3950_record_dup. +"owned" by resultset. To become owner use Z3950_record_clone. Function z_ext_record handles Extended Services. Thanks to Irina Dijour. diff --git a/configure.in b/configure.in index 1885daf..51392a8 100644 --- a/configure.in +++ b/configure.in @@ -1,8 +1,8 @@ dnl YAZ Toolkit, Index Data 1994-2001 dnl See the file LICENSE for details. -dnl $Id: configure.in,v 1.54 2001-11-13 23:00:42 adam Exp $ +dnl $Id: configure.in,v 1.55 2001-11-18 21:14:22 adam Exp $ AC_INIT(include/yaz/yaz-version.h) -AM_INIT_AUTOMAKE(yaz, 1.8.2) +AM_INIT_AUTOMAKE(yaz, 1.8.3) dnl AC_SUBST(READLINE_LIBS) dnl ------ Checking programs diff --git a/debian/rules b/debian/rules index d4ee863..595e951 100755 --- a/debian/rules +++ b/debian/rules @@ -34,7 +34,7 @@ YAZSRCDIR=$(shell pwd) YAZ_VERSION=$(shell date -r$(YAZSRCDIR)/CVS +"CVS%Y%m%d") else YAZSRCDIR=$(shell pwd) -YAZ_VERSION=1.8.2 +YAZ_VERSION=1.8.3 endif configure: stamp-configure diff --git a/doc/installation.xml b/doc/installation.xml index 2394ed3..ae46e14 100644 --- a/doc/installation.xml +++ b/doc/installation.xml @@ -1,4 +1,4 @@ - + Compilation and Installation Introduction @@ -138,7 +138,7 @@ --disable-shared - The make process will be not create + The make process will not create static libraries (.a). By default, static libraries are created - equivalent to --enable-static. @@ -168,7 +168,7 @@ lib/libyazthread.la - When threading is supported/enabled by configure this GNU libtool + When threading is supported/enabled by configure this Libtool library is created. It includes functions that allows &yaz; to use threads. @@ -184,7 +184,7 @@ yaz-config - A Bourne-shell script, generate by configure, that + A Bourne-shell script, generated by configure, that specifies how external applications should compile - and link with &yaz;. @@ -200,7 +200,7 @@ A simple shell implemented on top of the ZOOM functions. The shell is a command line application that allows you to enter - simple commands perform to perform ZOOM operations. + simple commands to perform ZOOM operations. zoom/zoomtst1, @@ -213,9 +213,9 @@ - If you wish to install &yaz; in system directories such as + If you wish to install &yaz; in system directories /usr/local/bin, - /usr/local/lib you can type: + /usr/local/lib .. etc, you can type: @@ -230,7 +230,7 @@ - If you wish to perform an un-installation of &yaz; use: + If you wish to perform an un-installation of &yaz;, use: @@ -258,8 +258,8 @@ require you to pass more options to your linker/compiler. - The yaz-config script accepts the options - that makes the yaz-config script print + The yaz-config script accepts command line + options that makes the yaz-config script print options that you should use in your make process. The most important ones are: --cflags, --libs @@ -267,8 +267,8 @@ A small and complete Makefile for a C - application consisting of one source file - myprog.c may look like this: + application consisting of one source file, + myprog.c, may look like this: YAZCONFIG=/usr/local/bin/yaz-config CFLAGS=`$(YAZCONFIG) --cflags` @@ -278,8 +278,8 @@ - The CFLAGS string will consists of an option that will set the - include path to the parent directory + The CFLAGS variable consists of a C compiler directive that will set + the include path to the parent directory of yaz. That is, if &yaz; header files were installed in /usr/local/include/yaz, then include path is set to /usr/local/include. @@ -299,9 +299,9 @@ Libtool acrhive(s) for &yaz; rather than the ordinary ones. - Applications that wish to use the threaded version of &yaz; - should specify threads after the - other options. When threads is given + For applications using the threaded version of &yaz;, + specify threads after the + other options. When threads is given, more flags and linker flags will be printed by yaz-config. If our previous example was using threads, you'd have to modify the lines that set @@ -312,7 +312,7 @@ LIBS=`$(YAZCONFIG) --libs threads` There is no need specify POSIX thread libraries in your Makefile. - The LIBS includes that as well. + The LIBS variable includes that as well. @@ -422,9 +422,9 @@ Some people are confused by the fact that we use the nmake tool to build &yaz;. They think they have to do that too - in order - to make WIN32 applications using &yaz;. The good news is that + to make their WIN32 applications work with &yaz;. The good news is that you don't have to. You can use the integrated environement of - Visual Studio if desired. + Visual Studio if desired for your own application. When setting up a project or Makefile you have to set the following: diff --git a/doc/zoom.xml b/doc/zoom.xml index 0c702f1..6d2ced2 100644 --- a/doc/zoom.xml +++ b/doc/zoom.xml @@ -1,4 +1,4 @@ - + Building clients with ZOOM @@ -52,23 +52,23 @@ #include <yaz/zoom.h> - Z3950_connection Z3950_connection_new (const char *host, int portnum); + ZOOM_connection ZOOM_connection_new (const char *host, int portnum); - Z3950_connection Z3950_connection_create (Z3950_options options); + ZOOM_connection ZOOM_connection_create (ZOOM_options options); - void Z3950_connection_connect(Z3950_connection c, const char *host, + void ZOOM_connection_connect(ZOOM_connection c, const char *host, int portnum); - void Z3950_connection_destroy (Z3950_connection c); + void ZOOM_connection_destroy (ZOOM_connection c); Connection objects are created with either function - Z3950_connection_new or - Z3950_connection_create. + ZOOM_connection_new or + ZOOM_connection_create. The former creates and automatically attempts to establish a network connection with the target. The latter doesn't establish a connection immediately, thus allowing you to specify options before establishing network connection using the function - Z3950_connection_connect. + ZOOM_connection_connect. If the portnumber, portnum, is zero, the host is consulted for a port specification. If no port is given, 210 is used. A colon denotes the beginning of @@ -77,24 +77,24 @@ Connection objects should be destroyed using the function - Z3950_connection_destroy. + ZOOM_connection_destroy. - void Z3950_connection_option_set (Z3950_connection c, - const char *key, - const char *val); + void ZOOM_connection_option_set (ZOOM_connection c, + const char *key, + const char *val); - const char *Z3950_connection_option_get (Z3950_connection c, - const char *key); + const char *ZOOM_connection_option_get (ZOOM_connection c, + const char *key); - The Z3950_connection_option_set allows you to + The ZOOM_connection_option_set allows you to set an option given by key to the value value for the connection. - Function Z3950_connection_option_get returns + Function ZOOM_connection_option_get returns the value for an option given by key. - ZOOM Connection Options +
ZOOM Connection Options @@ -130,7 +130,7 @@ asyncIf true (1) the connection operates in asynchronous operation which means that all calls are non-blocking except - Z3950_event. + ZOOM_event. 0 maximumRecordSize Maximum size of single record. @@ -142,11 +142,11 @@
- int Z3950_connection_error (Z3950_connection c, const char **cp, + int ZOOM_connection_error (ZOOM_connection c, const char **cp, const char **addinfo); - Use Z3950_connection_error to check for + Use ZOOM_connection_error to check for errors for the last operation(s) performed. The function returns zero if no errors occurred; non-zero otherwise indicating the error. Pointers cp and addinfo @@ -155,8 +155,8 @@ Protocol behavior - The calls Z3950_connection_new and - Z3950_connection_connect establises a TCP/IP + The calls ZOOM_connection_new and + ZOOM_connection_connect establises a TCP/IP connection and sends an Initialize Request to the target if possible. In addition, the calls waits for an Initialize Response from the target and the result is inspected (OK or rejected). @@ -184,9 +184,9 @@ When option async is 1, it really means that all network operations are postponed (and queued) until the - function Z3950_event is invoked. When doing so + function ZOOM_event is invoked. When doing so it doesn't make sense to check for errors after - Z3950_connection_new is called since that + ZOOM_connection_new is called since that operation "connecting - and init" is still incomplete and the API cannot tell the outcome (yet). @@ -197,24 +197,24 @@ Query objects represents queries. - Z3950_query Z3950_query_create(void); + ZOOM_query ZOOM_query_create(void); - void Z3950_query_destroy(Z3950_query q); + void ZOOM_query_destroy(ZOOM_query q); - int Z3950_query_prefix(Z3950_query q, const char *str); + int ZOOM_query_prefix(ZOOM_query q, const char *str); - int Z3950_query_sortby(Z3950_query q, const char *criteria); + int ZOOM_query_sortby(ZOOM_query q, const char *criteria); - Create query objects using Z3950_query_create - and destroy them by calling Z3950_query_destroy. + Create query objects using ZOOM_query_create + and destroy them by calling ZOOM_query_destroy. RPN-queries can be specified in PQF notation by using the - function Z3950_query_prefix. More + function ZOOM_query_prefix. More query types will be added later, such as CCL to RPN-mapping, native CCL query, etc. In addition to a search, a sort criteria may be set. Function - Z3950_query_sortby specifies a + ZOOM_query_sortby specifies a sort criteria using the same string notation for sort as offered by the YAZ client. @@ -232,42 +232,42 @@ a target.
- Z3950_resultset Z3950_connection_search(Z3950_connection, - Z3950_query q); + ZOOM_resultset ZOOM_connection_search(ZOOM_connection, + ZOOM_query q); - Z3950_resultset Z3950_connection_search_pqf(Z3950_connection c, - const char *q); + ZOOM_resultset ZOOM_connection_search_pqf(ZOOM_connection c, + const char *q); - void Z3950_resultset_destroy(Z3950_resultset r); + void ZOOM_resultset_destroy(ZOOM_resultset r); - Function Z3950_connection_search creates + Function ZOOM_connection_search creates a result set given a connection and query. Destroy a result set by calling - Z3950_resultset_destroy. + ZOOM_resultset_destroy. Simple clients may using PQF only may use function - Z3950_connection_search_pqf in which case + ZOOM_connection_search_pqf in which case creating query objects is not necessary. - void Z3950_resultset_option_set (Z3950_resultset r, + void ZOOM_resultset_option_set (ZOOM_resultset r, const char *key, const char *val); - const char *Z3950_resultset_option_get (Z3950_resultset r, + const char *ZOOM_resultset_option_get (ZOOM_resultset r, const char *key); - size_t Z3950_resultset_size (Z3950_resultset r); + size_t ZOOM_resultset_size (ZOOM_resultset r); - Functions Z3950_resultset_options_set and - Z3950_resultset_get sets and gets an option - for a result set similar to Z3950_connection_option_get - and Z3950_connection_option_set. + Functions ZOOM_resultset_options_set and + ZOOM_resultset_get sets and gets an option + for a result set similar to ZOOM_connection_option_get + and ZOOM_connection_option_set. The number of hits also called result-count is returned by - function Z3950_resultset_size. + function ZOOM_resultset_size. ZOOM Result set Options @@ -390,54 +390,54 @@ created from result sets. - void Z3950_resultset_records (Z3950_resultset r, - Z3950_record *recs, - size_t start, size_t count); - Z3950_record Z3950_resultset_record (Z3950_resultset s, size_t pos); + void ZOOM_resultset_records (ZOOM_resultset r, + ZOOM_record *recs, + size_t start, size_t count); + ZOOM_record ZOOM_resultset_record (ZOOM_resultset s, size_t pos); - void *Z3950_record_get (Z3950_record rec, const char *type, - size_t *len); + void *ZOOM_record_get (ZOOM_record rec, const char *type, + size_t *len); - Z3950_record Z3950_record_dup (Z3950_record rec); + ZOOM_record ZOOM_record_clone (ZOOM_record rec); - void Z3950_record_destroy (Z3950_record rec); + void ZOOM_record_destroy (ZOOM_record rec); References to temporary records are returned by functions - Z3950_resultset_records or - Z3950_resultset_record. + ZOOM_resultset_records or + ZOOM_resultset_record. 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 - Z3950_record_destroy. + ZOOM_record_clone should be used. + It returns a record reference that should be destroyed + by a call to ZOOM_record_destroy. A single record is returned by function - Z3950_resultset_record that takes a + ZOOM_resultset_record that takes a position as argument. First record has position zero. If no record could be obtained NULL is returned. - Function Z3950_resultset_records retrieves + Function ZOOM_resultset_records retrieves a number of records from a result set. Parameter start and count specifies the range of records to be returned. Upon completion array recs[0], ..recs[count-1] holds record objects for the records. The array of records - recs should be allocate prior to calling - Z3950_resultset_records. Note that for those + recs should be allocated prior the call + ZOOM_resultset_records. Note that for those records that couldn't be retrieved from the target recs[ ..] is set to NULL. In order to extract information about a single record, - Z3950_record_get is provided. The + ZOOM_record_get is provided. The function returns a pointer to certain record information. The - nature (type) of the pointer depends on the type - given. In addition for certain types, the length + nature (type) of the pointer depends on the parameter, + type. + In addition, for certain types, the length len passed will be set to the size in bytes of the returned information. @@ -470,8 +470,8 @@ Protocol behavior - The functions Z3950_resultset_record and - Z3950_resultset_records inspects the client-side + The functions ZOOM_resultset_record and + ZOOM_resultset_records inspects the client-side record cache. Records not found in cache are fetched using Present. The functions may block (and perform network I/O) - even though option @@ -480,7 +480,7 @@ There is a trick, however, in the usage of function - Z3950_resultset_records that allows for + ZOOM_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 @@ -495,26 +495,26 @@ an associative array / hash array, etc. - Z3950_options Z3950_options_create (void); + ZOOM_options ZOOM_options_create (void); - Z3950_options Z3950_options_create_with_parent (Z3950_options parent); + ZOOM_options ZOOM_options_create_with_parent (ZOOM_options parent); - void Z3950_options_destroy (Z3950_options opt); + void ZOOM_options_destroy (ZOOM_options opt); - const char *Z3950_options_get (Z3950_options opt, const char *name); + const char *ZOOM_options_get (ZOOM_options opt, const char *name); - void Z3950_options_set (Z3950_options opt, const char *name, - const char *v); + void ZOOM_options_set (ZOOM_options opt, const char *name, + const char *v); - typedef const char *(*Z3950_options_callback) + typedef const char *(*ZOOM_options_callback) (void *handle, const char *name); - Z3950_options_callback - Z3950_options_set_callback (Z3950_options opt, - Z3950_options_callback c, - void *handle); + ZOOM_options_callback + ZOOM_options_set_callback (ZOOM_options opt, + ZOOM_options_callback c, + void *handle); Events @@ -523,16 +523,16 @@ with events. - int Z3950_event (int no, Z3950_connection *cs); + int ZOOM_event (int no, ZOOM_connection *cs); - The Z3950_event executes pending events for + The ZOOM_event executes pending events for a number of connections. Supply the number of connections in no and an array of connections in cs (cs[0] ... cs[no-1]). A pending event could be a sending a search, receiving a response, etc. - When an event has a occured for one of the connections, this function + When an event has occured for one of the connections, this function returns a positive integer n denoting that an event occurred for connection cs[n-1]. When no events are pending for the connections, a value of zero is diff --git a/include/yaz/yaz-version.h b/include/yaz/yaz-version.h index 45b471f..b38b77c 100644 --- a/include/yaz/yaz-version.h +++ b/include/yaz/yaz-version.h @@ -1,11 +1,11 @@ /* * Current software version. * - * $Id: yaz-version.h,v 1.9 2001-11-12 11:27:42 adam Exp $ + * $Id: yaz-version.h,v 1.10 2001-11-18 21:14:23 adam Exp $ */ #ifndef YAZ_VERSION -#define YAZ_VERSION "1.8.2" +#define YAZ_VERSION "1.8.3" #include #ifdef WIN32 diff --git a/include/yaz/zoom.h b/include/yaz/zoom.h index c7df143..61e7550 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.6 2001-11-16 09:52:39 adam Exp $ + * $Id: zoom.h,v 1.7 2001-11-18 21:14:23 adam Exp $ */ #include @@ -14,12 +14,12 @@ ZOOM_BEGIN_CDECL /* ----------------------------------------------------------- */ /* the types we use */ -typedef struct Z3950_options_p *Z3950_options; -typedef struct Z3950_query_p *Z3950_query; -typedef struct Z3950_connection_p *Z3950_connection; -typedef struct Z3950_resultset_p *Z3950_resultset; -typedef struct Z3950_task_p *Z3950_task; -typedef struct Z3950_record_p *Z3950_record; +typedef struct ZOOM_options_p *ZOOM_options; +typedef struct ZOOM_query_p *ZOOM_query; +typedef struct ZOOM_connection_p *ZOOM_connection; +typedef struct ZOOM_resultset_p *ZOOM_resultset; +typedef struct ZOOM_task_p *ZOOM_task; +typedef struct ZOOM_record_p *ZOOM_record; /* ----------------------------------------------------------- */ /* connections */ @@ -27,155 +27,155 @@ typedef struct Z3950_record_p *Z3950_record; /* create connection, connect to host, if portnum is 0, then port is read from host string (e.g. myhost:9821) */ ZOOM_EXPORT -Z3950_connection Z3950_connection_new (const char *host, int portnum); +ZOOM_connection ZOOM_connection_new (const char *host, int portnum); /* create connection, don't connect, apply options */ ZOOM_EXPORT -Z3950_connection Z3950_connection_create (Z3950_options options); +ZOOM_connection ZOOM_connection_create (ZOOM_options options); /* connect given existing connection */ ZOOM_EXPORT -void Z3950_connection_connect(Z3950_connection c, const char *host, +void ZOOM_connection_connect(ZOOM_connection c, const char *host, int portnum); /* destroy connection (close connection also) */ ZOOM_EXPORT -void Z3950_connection_destroy (Z3950_connection c); +void ZOOM_connection_destroy (ZOOM_connection c); /* get/set option for connection */ ZOOM_EXPORT -const char *Z3950_connection_option_get (Z3950_connection c, const char *key); +const char *ZOOM_connection_option_get (ZOOM_connection c, const char *key); ZOOM_EXPORT -void Z3950_connection_option_set (Z3950_connection c, const char *key, +void ZOOM_connection_option_set (ZOOM_connection c, const char *key, const char *val); /* return error code (0 == success, failure otherwise). cp holds error string on failure, addinfo holds addititional info (if any) */ ZOOM_EXPORT -int Z3950_connection_error (Z3950_connection c, const char **cp, +int ZOOM_connection_error (ZOOM_connection c, const char **cp, const char **addinfo); /* returns error code */ ZOOM_EXPORT -int Z3950_connection_errcode (Z3950_connection c); +int ZOOM_connection_errcode (ZOOM_connection c); /* returns error message */ ZOOM_EXPORT -const char *Z3950_connection_errmsg (Z3950_connection c); +const char *ZOOM_connection_errmsg (ZOOM_connection c); /* returns additional info */ ZOOM_EXPORT -const char *Z3950_connection_addinfo (Z3950_connection c); +const char *ZOOM_connection_addinfo (ZOOM_connection c); -#define Z3950_ERROR_NONE 0 -#define Z3950_ERROR_CONNECT 10000 -#define Z3950_ERROR_MEMORY 10001 -#define Z3950_ERROR_ENCODE 10002 -#define Z3950_ERROR_DECODE 10003 -#define Z3950_ERROR_CONNECTION_LOST 10004 -#define Z3950_ERROR_INIT 10005 -#define Z3950_ERROR_INTERNAL 10006 -#define Z3950_ERROR_TIMEOUT 10007 +#define ZOOM_ERROR_NONE 0 +#define ZOOM_ERROR_CONNECT 10000 +#define ZOOM_ERROR_MEMORY 10001 +#define ZOOM_ERROR_ENCODE 10002 +#define ZOOM_ERROR_DECODE 10003 +#define ZOOM_ERROR_CONNECTION_LOST 10004 +#define ZOOM_ERROR_INIT 10005 +#define ZOOM_ERROR_INTERNAL 10006 +#define ZOOM_ERROR_TIMEOUT 10007 /* ----------------------------------------------------------- */ /* result sets */ /* create result set given a search */ ZOOM_EXPORT -Z3950_resultset Z3950_connection_search(Z3950_connection, Z3950_query q); +ZOOM_resultset ZOOM_connection_search(ZOOM_connection, ZOOM_query q); /* create result set given PQF query */ ZOOM_EXPORT -Z3950_resultset Z3950_connection_search_pqf(Z3950_connection c, const char *q); +ZOOM_resultset ZOOM_connection_search_pqf(ZOOM_connection c, const char *q); /* destroy result set */ ZOOM_EXPORT -void Z3950_resultset_destroy(Z3950_resultset r); +void ZOOM_resultset_destroy(ZOOM_resultset r); /* result set option */ ZOOM_EXPORT -const char *Z3950_resultset_option_get (Z3950_resultset r, const char *key); +const char *ZOOM_resultset_option_get (ZOOM_resultset r, const char *key); ZOOM_EXPORT -void Z3950_resultset_option_set (Z3950_resultset r, const char *key, const char *val); +void ZOOM_resultset_option_set (ZOOM_resultset r, const char *key, const char *val); /* return size of result set (alias hit count AKA result count) */ ZOOM_EXPORT -size_t Z3950_resultset_size (Z3950_resultset r); +size_t ZOOM_resultset_size (ZOOM_resultset r); /* retrieve records */ ZOOM_EXPORT -void Z3950_resultset_records (Z3950_resultset r, Z3950_record *recs, +void ZOOM_resultset_records (ZOOM_resultset r, ZOOM_record *recs, size_t start, size_t count); /* return record object at pos. Returns 0 if unavailable */ ZOOM_EXPORT -Z3950_record Z3950_resultset_record (Z3950_resultset s, size_t pos); +ZOOM_record ZOOM_resultset_record (ZOOM_resultset s, size_t pos); -/* like Z3950_resultset_record - but never blocks .. */ +/* like ZOOM_resultset_record - but never blocks .. */ ZOOM_EXPORT -Z3950_record Z3950_resultset_record_immediate (Z3950_resultset s, size_t pos); +ZOOM_record ZOOM_resultset_record_immediate (ZOOM_resultset s, size_t pos); /* ----------------------------------------------------------- */ /* records */ /* get record information, in a form given by type */ ZOOM_EXPORT -void *Z3950_record_get (Z3950_record rec, const char *type, size_t *len); +void *ZOOM_record_get (ZOOM_record rec, const char *type, size_t *len); /* destroy record */ ZOOM_EXPORT -void Z3950_record_destroy (Z3950_record rec); +void ZOOM_record_destroy (ZOOM_record rec); /* return copy of record */ ZOOM_EXPORT -Z3950_record Z3950_record_dup (Z3950_record srec); +ZOOM_record ZOOM_record_clone (ZOOM_record srec); /* ----------------------------------------------------------- */ /* searches */ /* create search object */ ZOOM_EXPORT -Z3950_query Z3950_query_create(void); +ZOOM_query ZOOM_query_create(void); /* destroy it */ ZOOM_EXPORT -void Z3950_query_destroy(Z3950_query s); +void ZOOM_query_destroy(ZOOM_query s); /* specify prefix query for search */ ZOOM_EXPORT -int Z3950_query_prefix(Z3950_query s, const char *str); +int ZOOM_query_prefix(ZOOM_query s, const char *str); /* specify sort criteria for search */ ZOOM_EXPORT -int Z3950_query_sortby(Z3950_query s, const char *criteria); +int ZOOM_query_sortby(ZOOM_query s, const char *criteria); /* ----------------------------------------------------------- */ /* options */ -typedef const char *(*Z3950_options_callback)(void *handle, const char *name); +typedef const char *(*ZOOM_options_callback)(void *handle, const char *name); ZOOM_EXPORT -Z3950_options_callback Z3950_options_set_callback (Z3950_options opt, - Z3950_options_callback c, +ZOOM_options_callback ZOOM_options_set_callback (ZOOM_options opt, + ZOOM_options_callback c, void *handle); ZOOM_EXPORT -Z3950_options Z3950_options_create (void); +ZOOM_options ZOOM_options_create (void); ZOOM_EXPORT -Z3950_options Z3950_options_create_with_parent (Z3950_options parent); +ZOOM_options ZOOM_options_create_with_parent (ZOOM_options parent); ZOOM_EXPORT -const char *Z3950_options_get (Z3950_options opt, const char *name); +const char *ZOOM_options_get (ZOOM_options opt, const char *name); ZOOM_EXPORT -void Z3950_options_set (Z3950_options opt, const char *name, const char *v); +void ZOOM_options_set (ZOOM_options opt, const char *name, const char *v); ZOOM_EXPORT -void Z3950_options_destroy (Z3950_options opt); +void ZOOM_options_destroy (ZOOM_options opt); ZOOM_EXPORT -int Z3950_options_get_bool (Z3950_options opt, const char *name, int defa); +int ZOOM_options_get_bool (ZOOM_options opt, const char *name, int defa); ZOOM_EXPORT -int Z3950_options_get_int (Z3950_options opt, const char *name, int defa); +int ZOOM_options_get_int (ZOOM_options opt, const char *name, int defa); ZOOM_EXPORT -void Z3950_options_addref (Z3950_options opt); +void ZOOM_options_addref (ZOOM_options opt); /* ----------------------------------------------------------- */ /* events */ @@ -185,6 +185,6 @@ void Z3950_options_addref (Z3950_options opt); connection for which the event occurred. There's no way to get the details yet, sigh. */ ZOOM_EXPORT -int Z3950_event (int no, Z3950_connection *cs); +int ZOOM_event (int no, ZOOM_connection *cs); ZOOM_END_CDECL diff --git a/win/yaz.rc b/win/yaz.rc index 7851297..f2d3532 100644 --- a/win/yaz.rc +++ b/win/yaz.rc @@ -54,8 +54,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,8,2,0 - PRODUCTVERSION 1,8,2,0 + FILEVERSION 1,8,3,0 + PRODUCTVERSION 1,8,3,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -73,14 +73,14 @@ BEGIN VALUE "Comments", "Z39.50 C Library\0" VALUE "CompanyName", "Index Data\0" VALUE "FileDescription", "YAZ Toolkit\0" - VALUE "FileVersion", "1, 8, 2, 0\0" + VALUE "FileVersion", "1, 8, 3, 0\0" VALUE "InternalName", "YAZ\0" VALUE "LegalCopyright", "Copyright © 1996-2001 Index Data\0" VALUE "LegalTrademarks", "\0" VALUE "OriginalFilename", "yaz.rc\0" VALUE "PrivateBuild", "\0" VALUE "ProductName", "Index Data YAZ Toolkit\0" - VALUE "ProductVersion", "1, 8, 2, 0\0" + VALUE "ProductVersion", "1, 8, 3, 0\0" VALUE "SpecialBuild", "\0" END END diff --git a/yaz.spec b/yaz.spec index 865dd00..1e1e067 100644 --- a/yaz.spec +++ b/yaz.spec @@ -1,5 +1,5 @@ Name: yaz -Version: 1.8.2 +Version: 1.8.3 Release: 1 Copyright: YAZ License Group: Development/Libraries diff --git a/zoom/zoom-c.c b/zoom/zoom-c.c index d3dbe06..b5a26df 100644 --- a/zoom/zoom-c.c +++ b/zoom/zoom-c.c @@ -1,5 +1,5 @@ /* - * $Id: zoom-c.c,v 1.10 2001-11-16 10:18:20 adam Exp $ + * $Id: zoom-c.c,v 1.11 2001-11-18 21:14:23 adam Exp $ * * ZOOM layer for C, connections, result sets, queries. */ @@ -16,21 +16,21 @@ #include #endif -static Z3950_Event Z3950_Event_create (int kind) +static ZOOM_Event ZOOM_Event_create (int kind) { - Z3950_Event event = xmalloc (sizeof(*event)); + ZOOM_Event event = xmalloc (sizeof(*event)); event->kind = kind; event->next = 0; event->prev = 0; return event; } -static void Z3950_Event_destroy (Z3950_Event event) +static void ZOOM_Event_destroy (ZOOM_Event event) { xfree (event); } -static void Z3950_connection_put_event (Z3950_connection c, Z3950_Event event) +static void ZOOM_connection_put_event (ZOOM_connection c, ZOOM_Event event) { // put in back of queue if (c->m_queue_back) @@ -48,10 +48,10 @@ static void Z3950_connection_put_event (Z3950_connection c, Z3950_Event event) c->m_queue_back = event; } -static Z3950_Event Z3950_connection_get_event(Z3950_connection c) +static ZOOM_Event ZOOM_connection_get_event(ZOOM_connection c) { // get from front of queue - Z3950_Event event = c->m_queue_front; + ZOOM_Event event = c->m_queue_front; if (!event) return 0; assert (c->m_queue_back); @@ -66,16 +66,16 @@ static Z3950_Event Z3950_connection_get_event(Z3950_connection c) return event; } -static void clear_error (Z3950_connection c) +static void clear_error (ZOOM_connection c) { - c->error = Z3950_ERROR_NONE; + c->error = ZOOM_ERROR_NONE; xfree (c->addinfo); c->addinfo = 0; } -Z3950_task Z3950_connection_add_task (Z3950_connection c, int which) +ZOOM_task ZOOM_connection_add_task (ZOOM_connection c, int which) { - Z3950_task *taskp = &c->tasks; + ZOOM_task *taskp = &c->tasks; while (*taskp) taskp = &(*taskp)->next; *taskp = xmalloc (sizeof(**taskp)); @@ -87,22 +87,22 @@ Z3950_task Z3950_connection_add_task (Z3950_connection c, int which) return *taskp; } -void Z3950_connection_remove_task (Z3950_connection c) +void ZOOM_connection_remove_task (ZOOM_connection c) { - Z3950_task task = c->tasks; + ZOOM_task task = c->tasks; if (task) { c->tasks = task->next; switch (task->which) { - case Z3950_TASK_SEARCH: - Z3950_resultset_destroy (task->u.resultset); + case ZOOM_TASK_SEARCH: + ZOOM_resultset_destroy (task->u.resultset); break; - case Z3950_TASK_RETRIEVE: - Z3950_resultset_destroy (task->u.resultset); + case ZOOM_TASK_RETRIEVE: + ZOOM_resultset_destroy (task->u.resultset); break; - case Z3950_TASK_CONNECT: + case ZOOM_TASK_CONNECT: break; default: assert (0); @@ -111,24 +111,24 @@ void Z3950_connection_remove_task (Z3950_connection c) } } -void Z3950_connection_remove_tasks (Z3950_connection c) +void ZOOM_connection_remove_tasks (ZOOM_connection c) { while (c->tasks) - Z3950_connection_remove_task(c); + ZOOM_connection_remove_task(c); } -static Z3950_record record_cache_lookup (Z3950_resultset r, +static ZOOM_record record_cache_lookup (ZOOM_resultset r, int pos, const char *elementSetName); -Z3950_connection Z3950_connection_create (Z3950_options options) +ZOOM_connection ZOOM_connection_create (ZOOM_options options) { - Z3950_connection c = xmalloc (sizeof(*c)); + ZOOM_connection c = xmalloc (sizeof(*c)); c->cs = 0; c->mask = 0; c->state = STATE_IDLE; - c->error = Z3950_ERROR_NONE; + c->error = ZOOM_ERROR_NONE; c->addinfo = 0; c->buf_in = 0; c->len_in = 0; @@ -136,7 +136,7 @@ Z3950_connection Z3950_connection_create (Z3950_options options) c->len_out = 0; c->resultsets = 0; - c->options = Z3950_options_create_with_parent(options); + c->options = ZOOM_options_create_with_parent(options); c->host_port = 0; c->proxy = 0; @@ -157,12 +157,12 @@ Z3950_connection Z3950_connection_create (Z3950_options options) /* set database names. Take local databases (if set); otherwise take databases given in ZURL (if set); otherwise use Default */ -static char **set_DatabaseNames (Z3950_connection con, int *num) +static char **set_DatabaseNames (ZOOM_connection con, int *num) { char **databaseNames; const char *c; int no = 2; - const char *cp = Z3950_options_get (con->options, "databaseName"); + const char *cp = ZOOM_options_get (con->options, "databaseName"); if (!cp || !*cp) { @@ -207,21 +207,21 @@ static char **set_DatabaseNames (Z3950_connection con, int *num) return databaseNames; } -Z3950_connection Z3950_connection_new (const char *host, int portnum) +ZOOM_connection ZOOM_connection_new (const char *host, int portnum) { - Z3950_connection c = Z3950_connection_create (0); + ZOOM_connection c = ZOOM_connection_create (0); - Z3950_connection_connect (c, host, portnum); + ZOOM_connection_connect (c, host, portnum); return c; } -void Z3950_connection_connect(Z3950_connection c, +void ZOOM_connection_connect(ZOOM_connection c, const char *host, int portnum) { const char *val; - Z3950_task task; + ZOOM_task task; - val = Z3950_options_get (c->options, "proxy"); + val = ZOOM_options_get (c->options, "proxy"); if (val && *val) c->proxy = xstrdup (val); else @@ -236,22 +236,22 @@ void Z3950_connection_connect(Z3950_connection c, else c->host_port = xstrdup(host); - Z3950_options_set(c->options, "host", c->host_port); + ZOOM_options_set(c->options, "host", c->host_port); - c->async = Z3950_options_get_bool (c->options, "async", 0); + c->async = ZOOM_options_get_bool (c->options, "async", 0); - task = Z3950_connection_add_task (c, Z3950_TASK_CONNECT); + task = ZOOM_connection_add_task (c, ZOOM_TASK_CONNECT); if (!c->async) { - while (Z3950_event (1, &c)) + while (ZOOM_event (1, &c)) ; } } -Z3950_query Z3950_query_create(void) +ZOOM_query ZOOM_query_create(void) { - Z3950_query s = xmalloc (sizeof(*s)); + ZOOM_query s = xmalloc (sizeof(*s)); s->refcount = 1; s->query = 0; @@ -261,13 +261,13 @@ Z3950_query Z3950_query_create(void) return s; } -void Z3950_query_destroy(Z3950_query s) +void ZOOM_query_destroy(ZOOM_query s) { if (!s) return; (s->refcount)--; - yaz_log (LOG_DEBUG, "Z3950_query_destroy count=%d", s->refcount); + yaz_log (LOG_DEBUG, "ZOOM_query_destroy count=%d", s->refcount); if (s->refcount == 0) { odr_destroy (s->odr); @@ -275,7 +275,7 @@ void Z3950_query_destroy(Z3950_query s) } } -int Z3950_query_prefix(Z3950_query s, const char *str) +int ZOOM_query_prefix(ZOOM_query s, const char *str) { s->query = odr_malloc (s->odr, sizeof(*s->query)); s->query->which = Z_Query_type_1; @@ -285,7 +285,7 @@ int Z3950_query_prefix(Z3950_query s, const char *str) return 0; } -int Z3950_query_sortby(Z3950_query s, const char *criteria) +int ZOOM_query_sortby(ZOOM_query s, const char *criteria) { s->sort_spec = yaz_sort_spec (s->odr, criteria); if (!s->sort_spec) @@ -293,11 +293,11 @@ int Z3950_query_sortby(Z3950_query s, const char *criteria) return 0; } -static int do_write(Z3950_connection c); +static int do_write(ZOOM_connection c); -void Z3950_connection_destroy(Z3950_connection c) +void ZOOM_connection_destroy(ZOOM_connection c) { - Z3950_resultset r; + ZOOM_resultset r; if (!c) return; if (c->cs) @@ -309,20 +309,20 @@ void Z3950_connection_destroy(Z3950_connection c) xfree (c->addinfo); odr_destroy (c->odr_in); odr_destroy (c->odr_out); - Z3950_options_destroy (c->options); - Z3950_connection_remove_tasks (c); + ZOOM_options_destroy (c->options); + ZOOM_connection_remove_tasks (c); xfree (c->host_port); xfree (c); } -void Z3950_resultset_addref (Z3950_resultset r) +void ZOOM_resultset_addref (ZOOM_resultset r) { if (r) (r->refcount)++; } -Z3950_resultset Z3950_resultset_create () +ZOOM_resultset ZOOM_resultset_create () { - Z3950_resultset r = xmalloc (sizeof(*r)); + ZOOM_resultset r = xmalloc (sizeof(*r)); r->refcount = 1; r->size = 0; @@ -339,52 +339,52 @@ Z3950_resultset Z3950_resultset_create () return r; } -Z3950_resultset Z3950_connection_search_pqf(Z3950_connection c, const char *q) +ZOOM_resultset ZOOM_connection_search_pqf(ZOOM_connection c, const char *q) { - Z3950_resultset r; - Z3950_query s = Z3950_query_create(); + ZOOM_resultset r; + ZOOM_query s = ZOOM_query_create(); - Z3950_query_prefix (s, q); + ZOOM_query_prefix (s, q); - r = Z3950_connection_search (c, s); - Z3950_query_destroy (s); + r = ZOOM_connection_search (c, s); + ZOOM_query_destroy (s); return r; } -Z3950_resultset Z3950_connection_search(Z3950_connection c, Z3950_query q) +ZOOM_resultset ZOOM_connection_search(ZOOM_connection c, ZOOM_query q) { - Z3950_resultset r = Z3950_resultset_create (); - Z3950_task task; + ZOOM_resultset r = ZOOM_resultset_create (); + ZOOM_task task; r->r_sort_spec = q->sort_spec; r->r_query = q->query; r->search = q; - r->options = Z3950_options_create_with_parent(c->options); + r->options = ZOOM_options_create_with_parent(c->options); - r->start = Z3950_options_get_int(r->options, "start", 0); - r->count = Z3950_options_get_int(r->options, "count", 0); - r->piggyback = Z3950_options_get_bool (r->options, "piggyback", 1); + r->start = ZOOM_options_get_int(r->options, "start", 0); + r->count = ZOOM_options_get_int(r->options, "count", 0); + r->piggyback = ZOOM_options_get_bool (r->options, "piggyback", 1); r->connection = c; r->next = c->resultsets; c->resultsets = r; - task = Z3950_connection_add_task (c, Z3950_TASK_SEARCH); + task = ZOOM_connection_add_task (c, ZOOM_TASK_SEARCH); task->u.resultset = r; - Z3950_resultset_addref (r); + ZOOM_resultset_addref (r); (q->refcount)++; if (!c->async) { - while (Z3950_event (1, &c)) + while (ZOOM_event (1, &c)) ; } return r; } -void Z3950_resultset_destroy(Z3950_resultset r) +void ZOOM_resultset_destroy(ZOOM_resultset r) { if (!r) return; @@ -395,7 +395,7 @@ void Z3950_resultset_destroy(Z3950_resultset r) if (r->connection) { /* remove ourselves from the resultsets in connection */ - Z3950_resultset *rp = &r->connection->resultsets; + ZOOM_resultset *rp = &r->connection->resultsets; while (1) { assert (*rp); /* we must be in this list!! */ @@ -407,19 +407,19 @@ void Z3950_resultset_destroy(Z3950_resultset r) rp = &(*rp)->next; } } - Z3950_query_destroy (r->search); - Z3950_options_destroy (r->options); + ZOOM_query_destroy (r->search); + ZOOM_options_destroy (r->options); odr_destroy (r->odr); xfree (r); } } -size_t Z3950_resultset_size (Z3950_resultset r) +size_t ZOOM_resultset_size (ZOOM_resultset r) { return r->size; } -static void do_close (Z3950_connection c) +static void do_close (ZOOM_connection c) { if (c->cs) cs_close(c->cs); @@ -428,11 +428,11 @@ static void do_close (Z3950_connection c) c->state = STATE_IDLE; } -static void Z3950_resultset_retrieve (Z3950_resultset r, +static void ZOOM_resultset_retrieve (ZOOM_resultset r, int force_sync, int start, int count) { - Z3950_task task; - Z3950_connection c; + ZOOM_task task; + ZOOM_connection c; if (!r) return; @@ -445,19 +445,19 @@ static void Z3950_resultset_retrieve (Z3950_resultset r, if (start + count > r->size) count = r->size - start; - task = Z3950_connection_add_task (c, Z3950_TASK_RETRIEVE); + task = ZOOM_connection_add_task (c, ZOOM_TASK_RETRIEVE); task->u.resultset = r; - Z3950_resultset_addref (r); + ZOOM_resultset_addref (r); r->start = start; r->count = count; if (!r->connection->async || force_sync) - while (r->connection && Z3950_event (1, &r->connection)) + while (r->connection && ZOOM_event (1, &r->connection)) ; } -void Z3950_resultset_records (Z3950_resultset r, Z3950_record *recs, +void ZOOM_resultset_records (ZOOM_resultset r, ZOOM_record *recs, size_t start, size_t count) { int force_present = 0; @@ -466,16 +466,16 @@ void Z3950_resultset_records (Z3950_resultset r, Z3950_record *recs, return ; if (count && recs) force_present = 1; - Z3950_resultset_retrieve (r, force_present, start, count); + ZOOM_resultset_retrieve (r, force_present, start, count); if (force_present) { size_t i; for (i = 0; i< count; i++) - recs[i] = Z3950_resultset_record_immediate (r, i+start); + recs[i] = ZOOM_resultset_record_immediate (r, i+start); } } -static int do_connect (Z3950_connection c) +static int do_connect (ZOOM_connection c) { void *add; const char *effective_host; @@ -497,31 +497,31 @@ static int do_connect (Z3950_connection c) if (ret >= 0) { c->state = STATE_CONNECTING; - c->mask = Z3950_SELECT_READ | Z3950_SELECT_WRITE | - Z3950_SELECT_EXCEPT; + c->mask = ZOOM_SELECT_READ | ZOOM_SELECT_WRITE | + ZOOM_SELECT_EXCEPT; return 1; } } c->state = STATE_IDLE; - c->error = Z3950_ERROR_CONNECT; + c->error = ZOOM_ERROR_CONNECT; return 0; } -int z3950_connection_socket(Z3950_connection c) +int z3950_connection_socket(ZOOM_connection c) { if (c->cs) return cs_fileno(c->cs); return -1; } -int z3950_connection_mask(Z3950_connection c) +int z3950_connection_mask(ZOOM_connection c) { if (c->cs) return c->mask; return 0; } -static int encode_APDU(Z3950_connection c, Z_APDU *a, ODR out) +static int encode_APDU(ZOOM_connection c, Z_APDU *a, ODR out) { char str[120]; @@ -545,14 +545,14 @@ static int encode_APDU(Z3950_connection c, Z_APDU *a, ODR out) odr_destroy(odr_pr); fclose (outf); } - c->error = Z3950_ERROR_ENCODE; + c->error = ZOOM_ERROR_ENCODE; do_close (c); return -1; } return 0; } -static int send_APDU (Z3950_connection c, Z_APDU *a) +static int send_APDU (ZOOM_connection c, Z_APDU *a) { assert (a); if (encode_APDU(c, a, c->odr_out)) @@ -563,15 +563,15 @@ static int send_APDU (Z3950_connection c, Z_APDU *a) return 0; } -static int Z3950_connection_send_init (Z3950_connection c) +static int ZOOM_connection_send_init (ZOOM_connection c) { const char *impname; Z_APDU *apdu = zget_APDU(c->odr_out, Z_APDU_initRequest); Z_InitRequest *ireq = apdu->u.initRequest; Z_IdAuthentication *auth = odr_malloc(c->odr_out, sizeof(*auth)); - const char *auth_groupId = Z3950_options_get (c->options, "group"); - const char *auth_userId = Z3950_options_get (c->options, "user"); - const char *auth_password = Z3950_options_get (c->options, "pass"); + const char *auth_groupId = ZOOM_options_get (c->options, "group"); + const char *auth_userId = ZOOM_options_get (c->options, "user"); + const char *auth_password = ZOOM_options_get (c->options, "pass"); ODR_MASK_SET(ireq->options, Z_Options_search); ODR_MASK_SET(ireq->options, Z_Options_present); @@ -586,7 +586,7 @@ static int Z3950_connection_send_init (Z3950_connection c) ODR_MASK_SET(ireq->protocolVersion, Z_ProtocolVersion_2); ODR_MASK_SET(ireq->protocolVersion, Z_ProtocolVersion_3); - impname = Z3950_options_get (c->options, "implementationName"); + impname = ZOOM_options_get (c->options, "implementationName"); ireq->implementationName = odr_malloc (c->odr_out, 15 + (impname ? strlen(impname) : 0)); strcpy (ireq->implementationName, ""); @@ -598,9 +598,9 @@ static int Z3950_connection_send_init (Z3950_connection c) strcat (ireq->implementationName, "ZOOM-C/YAZ"); *ireq->maximumRecordSize = - Z3950_options_get_int (c->options, "maximumRecordSize", 1024*1024); + ZOOM_options_get_int (c->options, "maximumRecordSize", 1024*1024); *ireq->preferredMessageSize = - Z3950_options_get_int (c->options, "preferredMessageSize", 1024*1024); + ZOOM_options_get_int (c->options, "preferredMessageSize", 1024*1024); if (auth_groupId || auth_password) { @@ -650,9 +650,9 @@ static int Z3950_connection_send_init (Z3950_connection c) return 0; } -static int Z3950_connection_send_search (Z3950_connection c) +static int ZOOM_connection_send_search (ZOOM_connection c) { - Z3950_resultset r; + ZOOM_resultset r; int lslb, ssub, mspn; const char *syntax; Z_APDU *apdu = zget_APDU(c->odr_out, Z_APDU_searchRequest); @@ -662,16 +662,16 @@ static int Z3950_connection_send_search (Z3950_connection c) const char *mediumSetElementSetName; assert (c->tasks); - assert (c->tasks->which == Z3950_TASK_SEARCH); + assert (c->tasks->which == ZOOM_TASK_SEARCH); r = c->tasks->u.resultset; elementSetName = - Z3950_options_get (r->options, "elementSetName"); + ZOOM_options_get (r->options, "elementSetName"); smallSetElementSetName = - Z3950_options_get (r->options, "smallSetElementSetName"); + ZOOM_options_get (r->options, "smallSetElementSetName"); mediumSetElementSetName = - Z3950_options_get (r->options, "mediumSetElementSetName"); + ZOOM_options_get (r->options, "mediumSetElementSetName"); if (!smallSetElementSetName) smallSetElementSetName = elementSetName; @@ -689,11 +689,11 @@ static int Z3950_connection_send_search (Z3950_connection c) set_DatabaseNames (c, &search_req->num_databaseNames); /* get syntax (no need to provide unless piggyback is in effect) */ - syntax = Z3950_options_get (r->options, "preferredRecordSyntax"); + syntax = ZOOM_options_get (r->options, "preferredRecordSyntax"); - lslb = Z3950_options_get_int (r->options, "largeSetLowerBound", -1); - ssub = Z3950_options_get_int (r->options, "smallSetUpperBound", -1); - mspn = Z3950_options_get_int (r->options, "mediumSetPresentNumber", -1); + lslb = ZOOM_options_get_int (r->options, "largeSetLowerBound", -1); + ssub = ZOOM_options_get_int (r->options, "smallSetUpperBound", -1); + mspn = ZOOM_options_get_int (r->options, "mediumSetPresentNumber", -1); if (lslb != -1 && ssub != -1 && mspn != -1) { /* So're a Z39.50 expert? Let's hope you don't do sort */ @@ -743,7 +743,7 @@ static int Z3950_connection_send_search (Z3950_connection c) return 1; } -static void response_diag (Z3950_connection c, Z_DiagRec *p) +static void response_diag (ZOOM_connection c, Z_DiagRec *p) { Z_DefaultDiagFormat *r; char *addinfo = 0; @@ -752,7 +752,7 @@ static void response_diag (Z3950_connection c, Z_DiagRec *p) c->addinfo = 0; if (p->which != Z_DiagRec_defaultFormat) { - c->error = Z3950_ERROR_DECODE; + c->error = ZOOM_ERROR_DECODE; return; } r = p->u.defaultFormat; @@ -770,12 +770,12 @@ static void response_diag (Z3950_connection c, Z_DiagRec *p) c->error = *r->condition; } -Z3950_record Z3950_record_dup (Z3950_record srec) +ZOOM_record ZOOM_record_clone (ZOOM_record srec) { char *buf; int size; ODR odr_enc; - Z3950_record nrec; + ZOOM_record nrec; odr_enc = odr_createmem(ODR_ENCODE); if (!z_NamePlusRecord (odr_enc, &srec->npr, 0, 0)) @@ -792,18 +792,18 @@ Z3950_record Z3950_record_dup (Z3950_record srec) return nrec; } -Z3950_record Z3950_resultset_record_immediate (Z3950_resultset s,size_t pos) +ZOOM_record ZOOM_resultset_record_immediate (ZOOM_resultset s,size_t pos) { return record_cache_lookup (s, pos, 0); } -Z3950_record Z3950_resultset_record (Z3950_resultset r, size_t pos) +ZOOM_record ZOOM_resultset_record (ZOOM_resultset r, size_t pos) { - Z3950_resultset_retrieve (r, 1, pos, 1); - return Z3950_resultset_record_immediate (r, pos); + ZOOM_resultset_retrieve (r, 1, pos, 1); + return ZOOM_resultset_record_immediate (r, pos); } -void Z3950_record_destroy (Z3950_record rec) +void ZOOM_record_destroy (ZOOM_record rec) { if (!rec) return; @@ -813,7 +813,7 @@ void Z3950_record_destroy (Z3950_record rec) xfree (rec); } -void *Z3950_record_get (Z3950_record rec, const char *type, size_t *len) +void *ZOOM_record_get (ZOOM_record rec, const char *type, size_t *len) { Z_NamePlusRecord *npr; if (!rec) @@ -893,12 +893,12 @@ void *Z3950_record_get (Z3950_record rec, const char *type, size_t *len) return 0; } -static void record_cache_add (Z3950_resultset r, +static void record_cache_add (ZOOM_resultset r, Z_NamePlusRecord *npr, int pos, const char *elementSetName) { - Z3950_record_cache rc; + ZOOM_record_cache rc; for (rc = r->record_cache; rc; rc = rc->next) { @@ -929,11 +929,11 @@ static void record_cache_add (Z3950_resultset r, r->record_cache = rc; } -static Z3950_record record_cache_lookup (Z3950_resultset r, +static ZOOM_record record_cache_lookup (ZOOM_resultset r, int pos, const char *elementSetName) { - Z3950_record_cache rc; + ZOOM_record_cache rc; for (rc = r->record_cache; rc; rc = rc->next) { @@ -948,15 +948,15 @@ static Z3950_record record_cache_lookup (Z3950_resultset r, return 0; } -static void handle_records (Z3950_connection c, Z_Records *sr, +static void handle_records (ZOOM_connection c, Z_Records *sr, int present_phase) { - Z3950_resultset resultset; + ZOOM_resultset resultset; if (!c->tasks) return ; - if (c->tasks->which != Z3950_TASK_SEARCH && - c->tasks->which != Z3950_TASK_RETRIEVE) + if (c->tasks->which != ZOOM_TASK_SEARCH && + c->tasks->which != ZOOM_TASK_RETRIEVE) return ; resultset = c->tasks->u.resultset; @@ -974,7 +974,7 @@ static void handle_records (Z3950_connection c, Z_Records *sr, if (sr->u.multipleNonSurDiagnostics->num_diagRecs >= 1) response_diag(c, sr->u.multipleNonSurDiagnostics->diagRecs[0]); else - c->error = Z3950_ERROR_DECODE; + c->error = ZOOM_ERROR_DECODE; } else { @@ -999,29 +999,29 @@ static void handle_records (Z3950_connection c, Z_Records *sr, if (present_phase && p->num_records == 0) { /* present response and we didn't get any records! */ - c->error = Z3950_ERROR_DECODE; + c->error = ZOOM_ERROR_DECODE; } } else if (present_phase) { /* present response and we didn't get any records! */ - c->error = Z3950_ERROR_DECODE; + c->error = ZOOM_ERROR_DECODE; } } } -static void handle_present_response (Z3950_connection c, Z_PresentResponse *pr) +static void handle_present_response (ZOOM_connection c, Z_PresentResponse *pr) { handle_records (c, pr->records, 1); } -static void handle_search_response (Z3950_connection c, Z_SearchResponse *sr) +static void handle_search_response (ZOOM_connection c, Z_SearchResponse *sr) { - Z3950_resultset resultset; + ZOOM_resultset resultset; yaz_log (LOG_DEBUG, "got search response"); - if (!c->tasks || c->tasks->which != Z3950_TASK_SEARCH) + if (!c->tasks || c->tasks->which != ZOOM_TASK_SEARCH) return ; resultset = c->tasks->u.resultset; @@ -1030,17 +1030,17 @@ static void handle_search_response (Z3950_connection c, Z_SearchResponse *sr) handle_records (c, sr->records, 0); } -static void sort_response (Z3950_connection c, Z_SortResponse *res) +static void sort_response (ZOOM_connection c, Z_SortResponse *res) { if (res->diagnostics && res->num_diagnostics > 0) response_diag (c, res->diagnostics[0]); } -static int send_sort (Z3950_connection c) +static int send_sort (ZOOM_connection c) { - Z3950_resultset resultset; + ZOOM_resultset resultset; - if (!c->tasks || c->tasks->which != Z3950_TASK_SEARCH) + if (!c->tasks || c->tasks->which != ZOOM_TASK_SEARCH) return 0; resultset = c->tasks->u.resultset; @@ -1068,21 +1068,21 @@ static int send_sort (Z3950_connection c) return 0; } -static int send_present (Z3950_connection c) +static int send_present (ZOOM_connection c) { Z_APDU *apdu = zget_APDU(c->odr_out, Z_APDU_presentRequest); Z_PresentRequest *req = apdu->u.presentRequest; int i = 0; const char *syntax = - Z3950_options_get (c->options, "preferredRecordSyntax"); + ZOOM_options_get (c->options, "preferredRecordSyntax"); const char *element = - Z3950_options_get (c->options, "elementSetName"); - Z3950_resultset resultset; + ZOOM_options_get (c->options, "elementSetName"); + ZOOM_resultset resultset; if (!c->tasks) return 0; - if (c->tasks->which != Z3950_TASK_SEARCH && - c->tasks->which != Z3950_TASK_RETRIEVE) + if (c->tasks->which != ZOOM_TASK_SEARCH && + c->tasks->which != ZOOM_TASK_RETRIEVE) return 0; resultset = c->tasks->u.resultset; @@ -1093,7 +1093,7 @@ static int send_present (Z3950_connection c) return 0; for (i = 0; icount; i++) { - Z3950_record rec = + ZOOM_record rec = record_cache_lookup (resultset, i + resultset->start, 0); if (!rec) break; @@ -1126,43 +1126,43 @@ static int send_present (Z3950_connection c) return 1; } -static int Z3950_connection_exec_task (Z3950_connection c) +static int ZOOM_connection_exec_task (ZOOM_connection c) { - Z3950_task task = c->tasks; + ZOOM_task task = c->tasks; - yaz_log (LOG_LOG, "Z3950_connection_exec_task"); + yaz_log (LOG_DEBUG, "ZOOM_connection_exec_task"); if (!task) return 0; - if (c->error != Z3950_ERROR_NONE || - (!c->cs && task->which != Z3950_TASK_CONNECT)) + if (c->error != ZOOM_ERROR_NONE || + (!c->cs && task->which != ZOOM_TASK_CONNECT)) { - Z3950_connection_remove_tasks (c); + ZOOM_connection_remove_tasks (c); return 0; } - yaz_log (LOG_DEBUG, "Z3950_connection_exec_task type=%d", task->which); + yaz_log (LOG_DEBUG, "ZOOM_connection_exec_task type=%d", task->which); if (task->running) return 0; task->running = 1; switch (task->which) { - case Z3950_TASK_SEARCH: + case ZOOM_TASK_SEARCH: /* see if search hasn't been sent yet. */ - if (Z3950_connection_send_search (c)) + if (ZOOM_connection_send_search (c)) return 1; break; - case Z3950_TASK_RETRIEVE: + case ZOOM_TASK_RETRIEVE: if (send_present (c)) return 1; break; - case Z3950_TASK_CONNECT: + case ZOOM_TASK_CONNECT: if (do_connect(c)) return 1; } - Z3950_connection_remove_task (c); + ZOOM_connection_remove_task (c); return 0; } -static int send_sort_present (Z3950_connection c) +static int send_sort_present (ZOOM_connection c) { int r = send_sort (c); if (!r) @@ -1170,7 +1170,7 @@ static int send_sort_present (Z3950_connection c) return r; } -static void handle_apdu (Z3950_connection c, Z_APDU *apdu) +static void handle_apdu (ZOOM_connection c, Z_APDU *apdu) { Z_InitResponse *initrs; @@ -1182,7 +1182,7 @@ static void handle_apdu (Z3950_connection c, Z_APDU *apdu) initrs = apdu->u.initResponse; if (!*initrs->result) { - c->error = Z3950_ERROR_INIT; + c->error = ZOOM_ERROR_INIT; } else { @@ -1195,30 +1195,30 @@ static void handle_apdu (Z3950_connection c, Z_APDU *apdu) c->cookie_in = xstrdup(cookie); if (c->tasks) { - assert (c->tasks->which == Z3950_TASK_CONNECT); - Z3950_connection_remove_task (c); + assert (c->tasks->which == ZOOM_TASK_CONNECT); + ZOOM_connection_remove_task (c); } - Z3950_connection_exec_task (c); + ZOOM_connection_exec_task (c); } break; case Z_APDU_searchResponse: handle_search_response (c, apdu->u.searchResponse); if (!send_sort_present (c)) - Z3950_connection_remove_task (c); + ZOOM_connection_remove_task (c); break; case Z_APDU_presentResponse: handle_present_response (c, apdu->u.presentResponse); if (!send_present (c)) - Z3950_connection_remove_task (c); + ZOOM_connection_remove_task (c); break; case Z_APDU_sortResponse: sort_response (c, apdu->u.sortResponse); if (!send_present (c)) - Z3950_connection_remove_task (c); + ZOOM_connection_remove_task (c); } } -static int do_read (Z3950_connection c) +static int do_read (ZOOM_connection c) { int r; Z_APDU *apdu; @@ -1228,7 +1228,7 @@ static int do_read (Z3950_connection c) return 0; if (r <= 0) { - c->error= Z3950_ERROR_CONNECTION_LOST; + c->error= ZOOM_ERROR_CONNECTION_LOST; do_close (c); } else @@ -1237,7 +1237,7 @@ static int do_read (Z3950_connection c) odr_setbuf (c->odr_in, c->buf_in, r, 0); if (!z_APDU (c->odr_in, &apdu, 0, 0)) { - c->error = Z3950_ERROR_DECODE; + c->error = ZOOM_ERROR_DECODE; do_close (c); } else @@ -1248,81 +1248,81 @@ static int do_read (Z3950_connection c) return 1; } -static int do_write_ex (Z3950_connection c, char *buf_out, int len_out) +static int do_write_ex (ZOOM_connection c, char *buf_out, int len_out) { int r; if ((r=cs_put (c->cs, buf_out, len_out)) < 0) { if (c->state == STATE_CONNECTING) - c->error = Z3950_ERROR_CONNECT; + c->error = ZOOM_ERROR_CONNECT; else - c->error = Z3950_ERROR_CONNECTION_LOST; + c->error = ZOOM_ERROR_CONNECTION_LOST; do_close (c); return 1; } else if (r == 1) { c->state = STATE_ESTABLISHED; - c->mask = Z3950_SELECT_READ|Z3950_SELECT_WRITE|Z3950_SELECT_EXCEPT; + c->mask = ZOOM_SELECT_READ|ZOOM_SELECT_WRITE|ZOOM_SELECT_EXCEPT; } else { c->state = STATE_ESTABLISHED; - c->mask = Z3950_SELECT_READ|Z3950_SELECT_EXCEPT; + c->mask = ZOOM_SELECT_READ|ZOOM_SELECT_EXCEPT; } return 0; } -static int do_write(Z3950_connection c) +static int do_write(ZOOM_connection c) { return do_write_ex (c, c->buf_out, c->len_out); } -const char *Z3950_connection_option_get (Z3950_connection c, const char *key) +const char *ZOOM_connection_option_get (ZOOM_connection c, const char *key) { - return Z3950_options_get (c->options, key); + return ZOOM_options_get (c->options, key); } -void Z3950_connection_option_set (Z3950_connection c, const char *key, +void ZOOM_connection_option_set (ZOOM_connection c, const char *key, const char *val) { - Z3950_options_set (c->options, key, val); + ZOOM_options_set (c->options, key, val); } -const char *Z3950_resultset_option_get (Z3950_resultset r, const char *key) +const char *ZOOM_resultset_option_get (ZOOM_resultset r, const char *key) { - return Z3950_options_get (r->options, key); + return ZOOM_options_get (r->options, key); } -void Z3950_resultset_option_set (Z3950_resultset r, const char *key, +void ZOOM_resultset_option_set (ZOOM_resultset r, const char *key, const char *val) { - Z3950_options_set (r->options, key, val); + ZOOM_options_set (r->options, key, val); } -int Z3950_connection_errcode (Z3950_connection c) +int ZOOM_connection_errcode (ZOOM_connection c) { - return Z3950_connection_error (c, 0, 0); + return ZOOM_connection_error (c, 0, 0); } -const char *Z3950_connection_errmsg (Z3950_connection c) +const char *ZOOM_connection_errmsg (ZOOM_connection c) { const char *msg; - Z3950_connection_error (c, &msg, 0); + ZOOM_connection_error (c, &msg, 0); return msg; } -const char *Z3950_connection_addinfo (Z3950_connection c) +const char *ZOOM_connection_addinfo (ZOOM_connection c) { const char *addinfo; - Z3950_connection_error (c, 0, &addinfo); + ZOOM_connection_error (c, 0, &addinfo); return addinfo; } -int Z3950_connection_error (Z3950_connection c, const char **cp, +int ZOOM_connection_error (ZOOM_connection c, const char **cp, const char **addinfo) { int error = c->error; @@ -1330,23 +1330,23 @@ int Z3950_connection_error (Z3950_connection c, const char **cp, { switch (error) { - case Z3950_ERROR_NONE: + case ZOOM_ERROR_NONE: *cp = "No error"; break; - case Z3950_ERROR_CONNECT: + case ZOOM_ERROR_CONNECT: *cp = "Connect failed"; break; - case Z3950_ERROR_MEMORY: + case ZOOM_ERROR_MEMORY: *cp = "Out of memory"; break; - case Z3950_ERROR_ENCODE: + case ZOOM_ERROR_ENCODE: *cp = "Encoding failed"; break; - case Z3950_ERROR_DECODE: + case ZOOM_ERROR_DECODE: *cp = "Decoding failed"; break; - case Z3950_ERROR_CONNECTION_LOST: + case ZOOM_ERROR_CONNECTION_LOST: *cp = "Connection lost"; break; - case Z3950_ERROR_INIT: + case ZOOM_ERROR_INIT: *cp = "Init rejected"; break; - case Z3950_ERROR_INTERNAL: + case ZOOM_ERROR_INTERNAL: *cp = "Internal failure"; break; - case Z3950_ERROR_TIMEOUT: + case ZOOM_ERROR_TIMEOUT: *cp = "Timeout"; break; default: *cp = diagbib1_str (error); @@ -1362,17 +1362,17 @@ int Z3950_connection_error (Z3950_connection c, const char **cp, return c->error; } -int Z3950_connection_do_io(Z3950_connection c, int mask) +int ZOOM_connection_do_io(ZOOM_connection c, int mask) { - Z3950_Event event; + ZOOM_Event event; #if 0 int r = cs_look(c->cs); - yaz_log (LOG_LOG, "Z3950_connection_do_io c=%p mask=%d cs_look=%d", + yaz_log (LOG_LOG, "ZOOM_connection_do_io c=%p mask=%d cs_look=%d", c, mask, r); if (r == CS_NONE) { - c->error = Z3950_ERROR_CONNECT; + c->error = ZOOM_ERROR_CONNECT; do_close (c); } else if (r == CS_CONNECT) @@ -1380,55 +1380,55 @@ int Z3950_connection_do_io(Z3950_connection c, int mask) yaz_log (LOG_LOG, "calling rcvconnect"); if (cs_rcvconnect (c->cs) < 0) { - c->error = Z3950_ERROR_CONNECT; + c->error = ZOOM_ERROR_CONNECT; do_close (c); } else - Z3950_connection_send_init (c); + ZOOM_connection_send_init (c); } else { - if (mask & Z3950_SELECT_READ) + if (mask & ZOOM_SELECT_READ) do_read (c); - if (c->cs && (mask & Z3950_SELECT_WRITE)) + if (c->cs && (mask & ZOOM_SELECT_WRITE)) do_write (c); } #else - yaz_log (LOG_DEBUG, "Z3950_connection_do_io c=%p mask=%d", c, mask); + yaz_log (LOG_DEBUG, "ZOOM_connection_do_io c=%p mask=%d", c, mask); if (c->state == STATE_CONNECTING) { - if (mask & Z3950_SELECT_WRITE) - Z3950_connection_send_init (c); + if (mask & ZOOM_SELECT_WRITE) + ZOOM_connection_send_init (c); else { - c->error = Z3950_ERROR_CONNECT; + c->error = ZOOM_ERROR_CONNECT; do_close (c); } } else if (c->state == STATE_ESTABLISHED) { - if (mask & Z3950_SELECT_READ) + if (mask & ZOOM_SELECT_READ) do_read (c); - if (c->cs && (mask & Z3950_SELECT_WRITE)) + if (c->cs && (mask & ZOOM_SELECT_WRITE)) do_write (c); } else { - c->error = Z3950_ERROR_INTERNAL; + c->error = ZOOM_ERROR_INTERNAL; do_close (c); } #endif - event = Z3950_Event_create (1); - Z3950_connection_put_event (c, event); + event = ZOOM_Event_create (1); + ZOOM_connection_put_event (c, event); return 1; } -int Z3950_event (int no, Z3950_connection *cs) +int ZOOM_event (int no, ZOOM_connection *cs) { #if HAVE_SYS_POLL_H struct pollfd pollfds[1024]; - Z3950_connection poll_cs[1024]; + ZOOM_connection poll_cs[1024]; #else struct timeval tv; fd_set input, output, except; @@ -1438,18 +1438,18 @@ int Z3950_event (int no, Z3950_connection *cs) for (i = 0; imask) { int mask = 0; if (pollfds[i].revents & POLLIN) - mask += Z3950_SELECT_READ; + mask += ZOOM_SELECT_READ; if (pollfds[i].revents & POLLOUT) - mask += Z3950_SELECT_WRITE; + mask += ZOOM_SELECT_WRITE; if (pollfds[i].revents & POLLERR) - mask += Z3950_SELECT_EXCEPT; + mask += ZOOM_SELECT_EXCEPT; if (mask) - Z3950_connection_do_io(c, mask); + ZOOM_connection_do_io(c, mask); } else if (r == 0 && c->mask) { - Z3950_Event event = Z3950_Event_create(0); + ZOOM_Event event = ZOOM_Event_create(0); /* timeout and this connection was waiting */ - c->error = Z3950_ERROR_TIMEOUT; + c->error = ZOOM_ERROR_TIMEOUT; do_close (c); - Z3950_connection_put_event(c, event); + ZOOM_connection_put_event(c, event); } } #else @@ -1549,7 +1549,7 @@ int Z3950_event (int no, Z3950_connection *cs) yaz_log (LOG_DEBUG, "select stop, returned r=%d", r); for (i = 0; imask) { - Z3950_Event event = Z3950_Event_create(0); + ZOOM_Event event = ZOOM_Event_create(0); /* timeout and this connection was waiting */ - c->error = Z3950_ERROR_TIMEOUT; + c->error = ZOOM_ERROR_TIMEOUT; do_close (c); - yaz_log (LOG_LOG, "timeout"); - Z3950_connection_put_event(c, event); + yaz_log (LOG_DEBUG, "timeout"); + ZOOM_connection_put_event(c, event); } } #endif for (i = 0; irefcount = 1; opt->callback_func = 0; @@ -28,17 +28,17 @@ Z3950_options Z3950_options_create_with_parent (Z3950_options parent) return opt; } -void Z3950_options_addref (Z3950_options opt) +void ZOOM_options_addref (ZOOM_options opt) { (opt->refcount)++; } -Z3950_options_callback Z3950_options_set_callback ( - Z3950_options opt, - Z3950_options_callback callback_func, +ZOOM_options_callback ZOOM_options_set_callback ( + ZOOM_options opt, + ZOOM_options_callback callback_func, void *callback_handle) { - Z3950_options_callback callback_old; + ZOOM_options_callback callback_old; assert (opt); callback_old = opt->callback_func; @@ -47,20 +47,20 @@ Z3950_options_callback Z3950_options_set_callback ( return callback_old; } -void Z3950_options_destroy (Z3950_options opt) +void ZOOM_options_destroy (ZOOM_options opt) { if (!opt) return; (opt->refcount)--; if (opt->refcount == 0) { - struct Z3950_options_entry *e; + struct ZOOM_options_entry *e; - Z3950_options_destroy (opt->parent); + ZOOM_options_destroy (opt->parent); e = opt->entries; while (e) { - struct Z3950_options_entry *e0 = e; + struct ZOOM_options_entry *e0 = e; xfree (e->name); xfree (e->value); e = e->next; @@ -70,9 +70,9 @@ void Z3950_options_destroy (Z3950_options opt) } } -void Z3950_options_set (Z3950_options opt, const char *name, const char *value) +void ZOOM_options_set (ZOOM_options opt, const char *name, const char *value) { - struct Z3950_options_entry **e; + struct ZOOM_options_entry **e; e = &opt->entries; while (*e) @@ -91,7 +91,7 @@ void Z3950_options_set (Z3950_options opt, const char *name, const char *value) (*e)->next = 0; } -const char *Z3950_options_get (Z3950_options opt, const char *name) +const char *ZOOM_options_get (ZOOM_options opt, const char *name) { const char *v = 0; if (!opt) @@ -100,7 +100,7 @@ const char *Z3950_options_get (Z3950_options opt, const char *name) v = (*opt->callback_func)(opt->callback_handle, name); if (!v) { - struct Z3950_options_entry *e; + struct ZOOM_options_entry *e; for (e = opt->entries; e; e = e->next) if (!strcmp(e->name, name)) { @@ -109,13 +109,13 @@ const char *Z3950_options_get (Z3950_options opt, const char *name) } } if (!v) - return Z3950_options_get(opt->parent, name); + return ZOOM_options_get(opt->parent, name); return v; } -int Z3950_options_get_bool (Z3950_options opt, const char *name, int defa) +int ZOOM_options_get_bool (ZOOM_options opt, const char *name, int defa) { - const char *v = Z3950_options_get (opt, name); + const char *v = ZOOM_options_get (opt, name); if (!v) return defa; @@ -124,9 +124,9 @@ int Z3950_options_get_bool (Z3950_options opt, const char *name, int defa) return 0; } -int Z3950_options_get_int (Z3950_options opt, const char *name, int defa) +int ZOOM_options_get_int (ZOOM_options opt, const char *name, int defa) { - const char *v = Z3950_options_get (opt, name); + const char *v = ZOOM_options_get (opt, name); if (!v || !*v) return defa; diff --git a/zoom/zoom-p.h b/zoom/zoom-p.h index 5958aff..85a80db 100644 --- a/zoom/zoom-p.h +++ b/zoom/zoom-p.h @@ -1,15 +1,15 @@ /* * Private C header for ZOOM C. - * $Id: zoom-p.h,v 1.4 2001-11-13 22:57:03 adam Exp $ + * $Id: zoom-p.h,v 1.5 2001-11-18 21:14:23 adam Exp $ */ #include #include #include #include -typedef struct Z3950_Event_p *Z3950_Event; +typedef struct ZOOM_Event_p *ZOOM_Event; -struct Z3950_query_p { +struct ZOOM_query_p { Z_Query *query; Z_SortKeySpecList *sort_spec; int refcount; @@ -20,11 +20,11 @@ struct Z3950_query_p { #define STATE_CONNECTING 1 #define STATE_ESTABLISHED 2 -#define Z3950_SELECT_READ 1 -#define Z3950_SELECT_WRITE 2 -#define Z3950_SELECT_EXCEPT 4 +#define ZOOM_SELECT_READ 1 +#define ZOOM_SELECT_WRITE 2 +#define ZOOM_SELECT_EXCEPT 4 -struct Z3950_connection_p { +struct ZOOM_connection_p { COMSTACK cs; char *host_port; int error; @@ -41,76 +41,76 @@ struct Z3950_connection_p { char *cookie_out; char *cookie_in; int async; - Z3950_task tasks; - Z3950_options options; - Z3950_resultset resultsets; - Z3950_Event m_queue_front; - Z3950_Event m_queue_back; + ZOOM_task tasks; + ZOOM_options options; + ZOOM_resultset resultsets; + ZOOM_Event m_queue_front; + ZOOM_Event m_queue_back; }; -struct Z3950_options_entry { +struct ZOOM_options_entry { char *name; char *value; - struct Z3950_options_entry *next; + struct ZOOM_options_entry *next; }; -struct Z3950_options_p { +struct ZOOM_options_p { int refcount; void *callback_handle; - Z3950_options_callback callback_func; - struct Z3950_options_entry *entries; - Z3950_options parent; + ZOOM_options_callback callback_func; + struct ZOOM_options_entry *entries; + ZOOM_options parent; }; -typedef struct Z3950_record_cache_p *Z3950_record_cache; +typedef struct ZOOM_record_cache_p *ZOOM_record_cache; -struct Z3950_resultset_p { +struct ZOOM_resultset_p { Z_Query *r_query; Z_SortKeySpecList *r_sort_spec; - Z3950_query search; + ZOOM_query search; int refcount; int size; int start; int count; int piggyback; ODR odr; - Z3950_record_cache record_cache; - Z3950_options options; - Z3950_connection connection; - Z3950_resultset next; + ZOOM_record_cache record_cache; + ZOOM_options options; + ZOOM_connection connection; + ZOOM_resultset next; }; -struct Z3950_record_p { +struct ZOOM_record_p { ODR odr; WRBUF wrbuf_marc; Z_NamePlusRecord *npr; }; -struct Z3950_record_cache_p { - struct Z3950_record_p rec; +struct ZOOM_record_cache_p { + struct ZOOM_record_p rec; char *elementSetName; int pos; - Z3950_record_cache next; + ZOOM_record_cache next; }; -struct Z3950_task_p { +struct ZOOM_task_p { int running; int which; union { -#define Z3950_TASK_SEARCH 1 - Z3950_resultset resultset; -#define Z3950_TASK_RETRIEVE 2 +#define ZOOM_TASK_SEARCH 1 + ZOOM_resultset resultset; +#define ZOOM_TASK_RETRIEVE 2 /** also resultset here */ -#define Z3950_TASK_CONNECT 3 +#define ZOOM_TASK_CONNECT 3 } u; - Z3950_task next; + ZOOM_task next; }; -struct Z3950_Event_p { +struct ZOOM_Event_p { int kind; - Z3950_Event next; - Z3950_Event prev; + ZOOM_Event next; + ZOOM_Event prev; }; diff --git a/zoom/zoomsh.c b/zoom/zoomsh.c index e403a17..24746d2 100644 --- a/zoom/zoomsh.c +++ b/zoom/zoomsh.c @@ -1,5 +1,5 @@ /* - * $Id: zoomsh.c,v 1.6 2001-11-16 10:18:20 adam Exp $ + * $Id: zoomsh.c,v 1.7 2001-11-18 21:14:23 adam Exp $ * * ZOOM-C Shell */ @@ -64,8 +64,8 @@ static int is_command (const char *cmd_str, const char *this_str, int this_len) return 1; } -static void cmd_set (Z3950_connection *c, Z3950_resultset *r, - Z3950_options options, +static void cmd_set (ZOOM_connection *c, ZOOM_resultset *r, + ZOOM_options options, const char **args) { char key[40], val[80]; @@ -77,15 +77,15 @@ static void cmd_set (Z3950_connection *c, Z3950_resultset *r, } if (!next_token_copy (args, val, sizeof(val))) { - const char *val = Z3950_options_get(options, key); + const char *val = ZOOM_options_get(options, key); printf ("%s = %s\n", key, val ? val : ""); } else - Z3950_options_set(options, key, val); + ZOOM_options_set(options, key, val); } -static void cmd_close (Z3950_connection *c, Z3950_resultset *r, - Z3950_options options, +static void cmd_close (ZOOM_connection *c, ZOOM_resultset *r, + ZOOM_options options, const char **args) { char host[60]; @@ -96,33 +96,33 @@ static void cmd_close (Z3950_connection *c, Z3950_resultset *r, const char *h; if (!c[i]) continue; - if ((h = Z3950_connection_option_get(c[i], "host")) + if ((h = ZOOM_connection_option_get(c[i], "host")) && !strcmp (h, host)) { - Z3950_connection_destroy (c[i]); + ZOOM_connection_destroy (c[i]); c[i] = 0; } else if (*host == '\0') { - Z3950_connection_destroy (c[i]); + ZOOM_connection_destroy (c[i]); c[i] = 0; } } } -static void display_records (Z3950_connection c, - Z3950_resultset r, +static void display_records (ZOOM_connection c, + ZOOM_resultset r, int start, int count) { int i; for (i = 0; i\n"); @@ -254,8 +254,8 @@ static void cmd_help (Z3950_connection *c, Z3950_resultset *r, printf (" implementationName\n"); } -static void cmd_connect (Z3950_connection *c, Z3950_resultset *r, - Z3950_options options, +static void cmd_connect (ZOOM_connection *c, ZOOM_resultset *r, + ZOOM_options options, const char **args) { int error; @@ -270,10 +270,10 @@ static void cmd_connect (Z3950_connection *c, Z3950_resultset *r, for (j = -1, i = 0; i -static void display_records (const char *tname, Z3950_resultset r) +static void display_records (const char *tname, ZOOM_resultset r) { /* OK, no major errors. Look at the result count */ int pos; - printf ("%s: %d hits\n", tname, Z3950_resultset_size(r)); + printf ("%s: %d hits\n", tname, ZOOM_resultset_size(r)); /* go through all records at target */ for (pos = 0; pos < 2; pos++) { - Z3950_record rec = Z3950_resultset_record (r, pos); + ZOOM_record rec = ZOOM_resultset_record (r, pos); /* get database for record and record itself at pos */ - const char *db = Z3950_record_get (rec, "database", 0); + const char *db = ZOOM_record_get (rec, "database", 0); int len; - const char *render = Z3950_record_get (rec, "render", &len); + const char *render = ZOOM_record_get (rec, "render", &len); /* if rec is non-null, we got a record for display */ if (rec) { @@ -39,13 +39,13 @@ int main(int argc, char **argv) { int i; int no = argc-3; - Z3950_connection z[500]; /* allow at most 500 connections */ - Z3950_resultset r1[500]; /* and result sets .. */ - Z3950_resultset r2[500]; /* and result sets .. */ - Z3950_query q; - Z3950_options o; + ZOOM_connection z[500]; /* allow at most 500 connections */ + ZOOM_resultset r1[500]; /* and result sets .. */ + ZOOM_resultset r2[500]; /* and result sets .. */ + ZOOM_query q; + ZOOM_options o; - o = Z3950_options_create (); + o = ZOOM_options_create (); if (argc < 4) { fprintf (stderr, "usage:\n%s target1 .. targetN query1 query2\n", @@ -55,17 +55,17 @@ int main(int argc, char **argv) if (no > 500) no = 500; - Z3950_options_set (o, "async", "1"); + ZOOM_options_set (o, "async", "1"); /* get 3 (at most) records from beginning */ - Z3950_options_set (o, "count", "3"); + ZOOM_options_set (o, "count", "3"); - Z3950_options_set (o, "preferredRecordSyntax", "sutrs"); - Z3950_options_set (o, "elementSetName", "B"); + ZOOM_options_set (o, "preferredRecordSyntax", "sutrs"); + ZOOM_options_set (o, "elementSetName", "B"); /* create query */ - q = Z3950_query_create (); - if (Z3950_query_prefix (q, argv[argc-2])) + q = ZOOM_query_create (); + if (ZOOM_query_prefix (q, argv[argc-2])) { printf ("bad PQF: %s\n", argv[argc-2]); exit (2); @@ -73,29 +73,29 @@ int main(int argc, char **argv) /* connect - and search all */ for (i = 0; i 1) - Z3950_options_set (o, "async", "1"); + ZOOM_options_set (o, "async", "1"); for (i = 0; i<10; i++) { char host[40]; printf ("session %2d", i); sprintf (host, "localhost:9999/%d", i); - z = Z3950_connection_create (o); - Z3950_connection_connect (z, host, 0); + z = ZOOM_connection_create (o); + ZOOM_connection_connect (z, host, 0); for (j = 0; j < 10; j++) { - Z3950_record recs[2]; + ZOOM_record recs[2]; char query[40]; - Z3950_query s = Z3950_query_create (); + ZOOM_query s = ZOOM_query_create (); sprintf (query, "i%dr%d", i, j); - if (Z3950_query_prefix (s, query)) + if (ZOOM_query_prefix (s, query)) { printf ("bad PQF: %s\n", query); exit (2); } - Z3950_options_set (o, "start", "0"); - Z3950_options_set (o, "count", "0"); + ZOOM_options_set (o, "start", "0"); + ZOOM_options_set (o, "count", "0"); - r[j] = Z3950_connection_search (z, s); /* non-piggy */ + r[j] = ZOOM_connection_search (z, s); /* non-piggy */ - Z3950_resultset_records (r[j], recs, 0, 2); /* first two */ + ZOOM_resultset_records (r[j], recs, 0, 2); /* first two */ - Z3950_resultset_records (r[j], recs, 1, 2); /* third */ + ZOOM_resultset_records (r[j], recs, 1, 2); /* third */ - Z3950_resultset_records (r[j], recs, 0, 0); /* ignored */ + ZOOM_resultset_records (r[j], recs, 0, 0); /* ignored */ - if (Z3950_resultset_size (r[j]) > 2) + if (ZOOM_resultset_size (r[j]) > 2) { if (!recs[0]) { @@ -88,30 +89,30 @@ int main(int argc, char **argv) } } - Z3950_query_destroy (s); + ZOOM_query_destroy (s); putchar ('.'); if (block > 0) - while (Z3950_event (1, &z)) + while (ZOOM_event (1, &z)) ; } for (j = 0; j 0) - while (Z3950_event (1, &z)) + while (ZOOM_event (1, &z)) ; } - Z3950_connection_destroy (z); + ZOOM_connection_destroy (z); for (j = 0; j < 10; j++) { - Z3950_resultset_records (r[j], 0, 0, 1); + ZOOM_resultset_records (r[j], 0, 0, 1); if (block > 0) - while (Z3950_event (1, &z)) + while (ZOOM_event (1, &z)) ; } for (j = 0; j < 10; j++) - Z3950_resultset_destroy (r[j]); - Z3950_query_destroy (q); + ZOOM_resultset_destroy (r[j]); + ZOOM_query_destroy (q); printf ("10 searches, 10 ignored presents done\n"); } } - Z3950_options_destroy (o); + ZOOM_options_destroy (o); xmalloc_trav(""); nmem_exit(); xmalloc_trav(""); -- 1.7.10.4