From 39f322672612cc6146a9a85fd32d2f8c325763da Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Tue, 18 Feb 2003 14:28:52 +0000 Subject: [PATCH] Function yaz_version. Better handling of non-SOAP enabled YAZ --- include/yaz/xmalloc.h | 58 +------------- include/yaz/yaz-util.h | 3 +- include/yaz/yaz-version.h | 17 ++++- include/yaz/yconfig.h | 4 +- server/seshigh.c | 6 +- util/Makefile.am | 7 +- util/log.c | 4 +- util/version.c | 21 ++++++ zutil/soap.c | 28 ++++++- zutil/srw.c | 184 +++++++++++++++++++++++---------------------- 10 files changed, 169 insertions(+), 163 deletions(-) create mode 100644 util/version.c diff --git a/include/yaz/xmalloc.h b/include/yaz/xmalloc.h index da439ac..2ba02bd 100644 --- a/include/yaz/xmalloc.h +++ b/include/yaz/xmalloc.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995-2000, Index Data. + * Copyright (c) 1995-2003, Index Data. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation, in whole or in part, for any purpose, is hereby granted, @@ -23,61 +23,7 @@ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. * - * $Log: xmalloc.h,v $ - * Revision 1.2 2000-02-28 11:20:06 adam - * Using autoconf. New definitions: YAZ_BEGIN_CDECL/YAZ_END_CDECL. - * - * Revision 1.1 1999/11/30 13:47:11 adam - * Improved installation. Moved header files to include/yaz. - * - * Revision 1.6 1999/07/13 13:24:53 adam - * Updated memory debugging memory allocatation routines. - * - * Revision 1.5 1998/07/20 12:36:22 adam - * Minor changes. - * - * Revision 1.4 1997/10/31 12:20:08 adam - * Improved memory debugging for xmalloc/nmem.c. References to NMEM - * instead of ODR in n ESPEC-1 handling in source d1_espec.c. - * Bug fix: missing fclose in data1_read_espec1. - * - * Revision 1.3 1997/09/01 08:49:54 adam - * New windows NT/95 port using MSV5.0. To export DLL functions the - * YAZ_EXPORT modifier was added. Defined in yconfig.h. - * - * Revision 1.2 1997/05/14 06:53:53 adam - * C++ support. - * - * Revision 1.1 1995/11/01 11:55:41 quinn - * Added xmalloc.c - * - * Revision 1.8 1995/10/16 14:03:07 quinn - * Changes to support element set names and espec1 - * - * Revision 1.7 1994/10/05 10:15:18 quinn - * Added xrealloc. - * - * Revision 1.6 1994/09/26 16:31:24 adam - * Minor changes. xmalloc declares xcalloc now. - * - * Revision 1.5 1994/09/19 15:46:34 quinn - * Added stdlib.h - * - * Revision 1.4 1994/08/18 08:22:27 adam - * Res.h modified. xmalloc now declares xstrdup. - * - * Revision 1.3 1994/08/17 15:34:15 adam - * Initial version of resource manager. - * - * Revision 1.2 1994/08/17 14:09:48 quinn - * Small changes - * - * Revision 1.1 1994/08/17 13:39:07 adam - * Added xmalloc header. - * - * Revision 1.1 1994/08/16 16:16:02 adam - * bfile header created. - * + * $Id: xmalloc.h,v 1.3 2003-02-18 14:28:52 adam Exp $ */ #ifndef XMALLOC_H diff --git a/include/yaz/yaz-util.h b/include/yaz/yaz-util.h index 8db1ed7..2c47f44 100644 --- a/include/yaz/yaz-util.h +++ b/include/yaz/yaz-util.h @@ -3,13 +3,14 @@ * See the file LICENSE for details. * Sebastian Hammer, Adam Dickmeiss * - * $Id: yaz-util.h,v 1.8 2003-01-06 08:20:27 adam Exp $ + * $Id: yaz-util.h,v 1.9 2003-02-18 14:28:52 adam Exp $ */ #ifndef YAZ_UTIL_H #define YAZ_UTIL_H #include +#include #include #include #include diff --git a/include/yaz/yaz-version.h b/include/yaz/yaz-version.h index 2a1327e..951b477 100644 --- a/include/yaz/yaz-version.h +++ b/include/yaz/yaz-version.h @@ -1,10 +1,17 @@ /* - * Current software version. + * Copyright (c) 1995-2003, Index Data. + * See the file LICENSE for details. * - * $Id: yaz-version.h,v 1.22 2003-02-10 08:58:40 adam Exp $ + * $Id: yaz-version.h,v 1.23 2003-02-18 14:28:52 adam Exp $ + */ + +/* + * Current software version. */ #ifndef YAZ_VERSION +#include + #define YAZ_VERSION "1.9.3" #define YAZ_VERSIONL 0x010903 @@ -18,5 +25,11 @@ #endif #endif +YAZ_BEGIN_CDECL + +YAZ_EXPORT unsigned long yaz_version(char *version_str, char *sys_str); + +YAZ_END_CDECL + #endif diff --git a/include/yaz/yconfig.h b/include/yaz/yconfig.h index fbb6d48..5c995b4 100644 --- a/include/yaz/yconfig.h +++ b/include/yaz/yconfig.h @@ -1,8 +1,8 @@ /* - * Copyright (c) 1995-2000, Index Data. + * Copyright (c) 1995-2003, Index Data. * See the file LICENSE for details. * - * $Id: yconfig.h,v 1.5 2000-03-01 09:53:32 adam Exp $ + * $Id: yconfig.h,v 1.6 2003-02-18 14:28:52 adam Exp $ */ #ifndef YCONFIG_H diff --git a/server/seshigh.c b/server/seshigh.c index b97a9c1..ce4d412 100644 --- a/server/seshigh.c +++ b/server/seshigh.c @@ -2,7 +2,7 @@ * Copyright (c) 1995-2003, Index Data * See the file LICENSE for details. * - * $Id: seshigh.c,v 1.140 2003-02-18 11:59:14 adam Exp $ + * $Id: seshigh.c,v 1.141 2003-02-18 14:28:52 adam Exp $ */ /* @@ -287,7 +287,7 @@ void ir_session(IOCHAN h, int event) /* We aren't speaking to this fellow */ if (assoc->state == ASSOC_DEAD) { - yaz_log(LOG_LOG, "Closed connection after reject"); + yaz_log(LOG_LOG, "Connection closed - end of session"); cs_close(conn); destroy_association(assoc); iochan_destroy(h); @@ -695,7 +695,6 @@ static void process_http_request(association *assoc, request *req) } else if (!strcmp(hreq->method, "POST")) { -#if HAVE_XML2 const char *content_type = z_HTTP_header_lookup(hreq->headers, "Content-Type"); const char *soap_action = z_HTTP_header_lookup(hreq->headers, @@ -763,7 +762,6 @@ static void process_http_request(association *assoc, request *req) hres->code = http_code; z_HTTP_header_add(o, &hres->headers, "Content-Type", "text/xml"); } -#endif if (!p) /* still no response ? */ p = z_get_HTTP_Response(o, 500); } diff --git a/util/Makefile.am b/util/Makefile.am index c72fc55..237aa9c 100644 --- a/util/Makefile.am +++ b/util/Makefile.am @@ -1,6 +1,6 @@ ## Copyright (C) 1994-2003, Index Data ## All rights reserved. -## $Id: Makefile.am,v 1.15 2003-01-06 08:20:28 adam Exp $ +## $Id: Makefile.am,v 1.16 2003-02-18 14:28:52 adam Exp $ noinst_LTLIBRARIES = libutil.la @@ -23,6 +23,7 @@ yaziconv_SOURCES = siconvtst.c marc8.c: charconv.sgm charconv.tcl cd $(srcdir); ./charconv.tcl -p marc8 -s 50 charconv.sgm marc8.c -libutil_la_SOURCES=options.c log.c marcdisp.c oid.c wrbuf.c nmemsdup.c \ - xmalloc.c readconf.c tpath.c nmem.c matchstr.c atoin.c siconv.c marc8.c +libutil_la_SOURCES=version.c options.c log.c marcdisp.c oid.c wrbuf.c \ + nmemsdup.c xmalloc.c readconf.c tpath.c nmem.c matchstr.c atoin.c \ + siconv.c marc8.c diff --git a/util/log.c b/util/log.c index cfcbf77..00c3e9d 100644 --- a/util/log.c +++ b/util/log.c @@ -2,7 +2,7 @@ * Copyright (c) 1995-2003, Index Data * See the file LICENSE for details. * - * $Id: log.c,v 1.36 2003-02-12 14:17:50 heikki Exp $ + * $Id: log.c,v 1.37 2003-02-18 14:28:53 adam Exp $ */ #if HAVE_CONFIG_H @@ -54,7 +54,7 @@ static struct { { LOG_MALLOC, "malloc"}, { LOG_APP, "app" }, { LOG_NOTIME, "" }, - /* { LOG_ALL, "all" }, */ + { LOG_ALL, "all" }, { 0, "none" }, { 0, NULL } }; diff --git a/util/version.c b/util/version.c new file mode 100644 index 0000000..050659d --- /dev/null +++ b/util/version.c @@ -0,0 +1,21 @@ +/* + * Copyright (c) 1995-2003, Index Data. + * See the file LICENSE for details. + * Sebastian Hammer, Adam Dickmeiss + * + * $Id: version.c,v 1.1 2003-02-18 14:28:53 adam Exp $ + */ +#if HAVE_CONFIG_H +#include +#endif + +#include + +unsigned long yaz_version(char *version_str, char *sys_str) +{ + if (version_str) + strcpy(version_str, YAZ_VERSION); + if (sys_str) + strcpy(sys_str, ""); + return YAZ_VERSIONL; +} diff --git a/zutil/soap.c b/zutil/soap.c index f06ae8f..2b416b3 100644 --- a/zutil/soap.c +++ b/zutil/soap.c @@ -2,7 +2,7 @@ * Copyright (c) 2002-2003, Index Data. * See the file LICENSE for details. * - * $Id: soap.c,v 1.4 2003-02-17 22:35:48 adam Exp $ + * $Id: soap.c,v 1.5 2003-02-18 14:28:53 adam Exp $ */ #include @@ -165,7 +165,7 @@ int z_soap_codec(ODR o, Z_SOAP **pp, else { ret = z_soap_error(o, p, "SOAP-ENV:Client", - "No handler for NS", 0); + "No handler for NS", ptr->ns->href); } } xmlFreeDoc(doc); @@ -217,4 +217,28 @@ int z_soap_codec(ODR o, Z_SOAP **pp, } return 0; } +#else +int z_soap_codec(ODR o, Z_SOAP **pp, + char **content_buf, int *content_len, + Z_SOAP_Handler *handlers) +{ + const char *err_xml = + "\n" + "\n" + "\t\n" + "\t\t\n" + "\t\t\tSOAP-ENV:Server\n" + "\t\t\tHTTP error\n" + "\t\t\tSOAP not supported in this YAZ configuration\n" + "\t\t\n" + "\t\n" + "\n"; + if (o->direction == ODR_ENCODE) + { + *content_buf = err_xml; + *content_len = strlen(err_xml); + } + return -1; +} #endif diff --git a/zutil/srw.c b/zutil/srw.c index 61e1509..71391eb 100644 --- a/zutil/srw.c +++ b/zutil/srw.c @@ -2,7 +2,7 @@ * Copyright (c) 2002-2003, Index Data. * See the file LICENSE for details. * - * $Id: srw.c,v 1.4 2003-02-17 22:35:48 adam Exp $ + * $Id: srw.c,v 1.5 2003-02-18 14:28:53 adam Exp $ */ #include @@ -416,98 +416,100 @@ Z_SRW_searchRetrieve *yaz_srw_get(ODR o, int which) #endif -const char *yaz_srw_error_str (int code) -{ - return "SRW error"; -} - -#if 0 - -1 Permanent system error -2 System temporarily unavailable -3 Authentication error - /* Diagnostics Relating to CQL */ -Number Description -10 Illegal query -11 Unsupported query type (XCQL vs CQL) -12 Too many characters in query -13 Unbalanced or illegal use of parentheses -14 Unbalanced or illegal use of quotes -15 Illegal or unsupported index set -16 Illegal or unsupported index -17 Illegal or unsupported combination of index and index set -18 Illegal or unsupported combination of indexes -19 Illegal or unsupported relation -20 Illegal or unsupported relation modifier -21 Illegal or unsupported combination of relation modifers -22 Illegal or unsupported combination of relation and index -23 Too many characters in term -24 Illegal combination of relation and term -25 Special characters not quoted in term -26 Non special character escaped in term -27 Empty term unsupported -28 Masking character not supported -29 Masked words too short -30 Too many masking characters in term -31 Anchoring character not supported -32 Anchoring character in illegal or unsupported position -33 Combination of proximity/adjacency and masking characters not supported -34 Combination of proximity/adjacency and anchoring characters not supported -35 Terms only exclusion (stop) words -36 Term in invalid format for index or relation -37 Illegal or unsupported boolean operator -38 Too many boolean operators in query -39 Proximity not supported -40 Illegal or unsupported proximity relation -41 Illegal or unsupported proximity distance -42 Illegal or unsupported proximity unit -43 Illegal or unsupported proximity ordering -44 Illegal or unsupported combination of proximity modifiers -45 Index set name (prefix) assigned to multiple identifiers +static struct { + int code; + const char *msg; +} yaz_srw_codes [] = { +{1, "Permanent system error"}, +{2, "System temporarily unavailable"}, +{3, "Authentication error"}, +/* Diagnostics Relating to CQL */ +{10, "Illegal query"}, +{11, "Unsupported query type (XCQL vs CQL)"}, +{12, "Too many characters in query"}, +{13, "Unbalanced or illegal use of parentheses"}, +{14, "Unbalanced or illegal use of quotes"}, +{15, "Illegal or unsupported index set"}, +{16, "Illegal or unsupported index"}, +{17, "Illegal or unsupported combination of index and index set"}, +{18, "Illegal or unsupported combination of indexes"}, +{19, "Illegal or unsupported relation"}, +{20, "Illegal or unsupported relation modifier"}, +{21, "Illegal or unsupported combination of relation modifers"}, +{22, "Illegal or unsupported combination of relation and index"}, +{23, "Too many characters in term"}, +{24, "Illegal combination of relation and term"}, +{25, "Special characters not quoted in term"}, +{26, "Non special character escaped in term"}, +{27, "Empty term unsupported"}, +{28, "Masking character not supported"}, +{29, "Masked words too short"}, +{30, "Too many masking characters in term"}, +{31, "Anchoring character not supported"}, +{32, "Anchoring character in illegal or unsupported position"}, +{33, "Combination of proximity/adjacency and masking characters not supported"}, +{34, "Combination of proximity/adjacency and anchoring characters not supported"}, +{35, "Terms only exclusion (stop) words"}, +{36, "Term in invalid format for index or relation"}, +{37, "Illegal or unsupported boolean operator"}, +{38, "Too many boolean operators in query"}, +{39, "Proximity not supported"}, +{40, "Illegal or unsupported proximity relation"}, +{41, "Illegal or unsupported proximity distance"}, +{42, "Illegal or unsupported proximity unit"}, +{43, "Illegal or unsupported proximity ordering"}, +{44, "Illegal or unsupported combination of proximity modifiers"}, +{45, "Index set name (prefix) assigned to multiple identifiers"}, /* Diagnostics Relating to Result Sets */ -Number Description -50 Result sets not supported -51 Result set does not exist -52 Result set temporarily unavailable -53 Result sets only supported for retrieval -54 Retrieval may only occur from an existing result set -55 Combination of result sets with search terms not supported -56 Only combination of single result set with search terms supported -57 Result set created but no records available -58 Result set created with unpredictable partial results available -59 Result set created with valid partial results available +{50, "Result sets not supported"}, +{51, "Result set does not exist"}, +{52, "Result set temporarily unavailable"}, +{53, "Result sets only supported for retrieval"}, +{54, "Retrieval may only occur from an existing result set"}, +{55, "Combination of result sets with search terms not supported"}, +{56, "Only combination of single result set with search terms supported"}, +{57, "Result set created but no records available"}, +{58, "Result set created with unpredictable partial results available"}, +{59, "Result set created with valid partial results available"}, /* Diagnostics Relating to Records */ -Number Description -60 Too many records retrieved -61 First record position out of range -62 Negative number of records requested -63 System error in retrieving records -64 Record temporarily unavailable -65 Record does not exist -66 Unknown schema for retrieval -67 Record not available in this schema -68 Not authorised to send record -69 Not authorised to send record in this schema -70 Record too large to send +{60, "Too many records retrieved"}, +{61, "First record position out of range"}, +{62, "Negative number of records requested"}, +{63, "System error in retrieving records"}, +{64, "Record temporarily unavailable"}, +{65, "Record does not exist"}, +{66, "Unknown schema for retrieval"}, +{67, "Record not available in this schema"}, +{68, "Not authorised to send record"}, +{69, "Not authorised to send record in this schema"}, +{70, "Record too large to send"}, /* Diagnostics Relating to Sorting */ -Number Description -80 Sort not supported -81 Unsupported sort type (sortKeys vs xSortKeys) -82 Illegal or unsupported sort sequence -83 Too many records -84 Too many sort keys -85 Duplicate sort keys -86 Incompatible record formats -87 Unsupported schema for sort -88 Unsupported tag path for sort -89 Tag path illegal or unsupported for schema -90 Illegal or unsupported direction value -91 Illegal or unsupported case value -92 Illegal or unsupported missing value action +{80, "Sort not supported"}, +{81, "Unsupported sort type (sortKeys vs xSortKeys)"}, +{82, "Illegal or unsupported sort sequence"}, +{83, "Too many records"}, +{84, "Too many sort keys"}, +{85, "Duplicate sort keys"}, +{86, "Incompatible record formats"}, +{87, "Unsupported schema for sort"}, +{88, "Unsupported tag path for sort"}, +{89, "Tag path illegal or unsupported for schema"}, +{90, "Illegal or unsupported direction value"}, +{91, "Illegal or unsupported case value"}, +{92, "Illegal or unsupported missing value action"}, /* Diagnostics Relating to Explain */ -Number Description -100 Explain not supported -101 Explain request type not supported (SOAP vs GET) -102 Explain record temporarily unavailable +{100, "Explain not supported"}, +{101, "Explain request type not supported (SOAP vs GET)"}, +{102, "Explain record temporarily unavailable"}, +{0, 0} +}; + +const char *yaz_srw_error_str (int code) +{ + int i; + for (i = 0; yaz_srw_codes[i].code; i++) + if (yaz_srw_codes[i].code == code) + return yaz_srw_codes[i].msg; + return 0; +} -#endif -- 1.7.10.4