Changed include/yaz/diagbib1.h and added include/yaz/diagsrw.h with
authorAdam Dickmeiss <adam@indexdata.dk>
Fri, 22 Apr 2005 08:27:57 +0000 (08:27 +0000)
committerAdam Dickmeiss <adam@indexdata.dk>
Fri, 22 Apr 2005 08:27:57 +0000 (08:27 +0000)
diagnostic messages+codes for Bib-1 and SRW. Preprocessor defines are
now defined for all those error codes. So instead of putting 109 in
in a program, YAZ_BIB1_DATABASE_UNAVAILABLE can be used. The messages
are now generated from a CSV files. See src/bib1.csv and srw/srw.csv.

16 files changed:
Makefile.am
NEWS
include/yaz/Makefile.am
include/yaz/diagbib1.h [deleted file]
include/yaz/srw.h
src/Makefile.am
src/bib1.csv [new file with mode: 0644]
src/csvtobib1.tcl [new file with mode: 0755]
src/csvtodiag.tcl [new file with mode: 0644]
src/csvtosrw.tcl [new file with mode: 0755]
src/diag-entry.c [new file with mode: 0644]
src/diag-entry.h [new file with mode: 0644]
src/diagbib1.c [deleted file]
src/diagsrw.c [deleted file]
src/seshigh.c
src/srw.csv [new file with mode: 0644]

index e5bb4da..7f9b87d 100644 (file)
@@ -1,6 +1,6 @@
-## Copyright (C) 1994-2004, Index Data
-## All rights reserved.
-## $Id: Makefile.am,v 1.30 2004-10-10 22:17:55 adam Exp $
+## This file is part of the YAZ toolkit.
+## Copyright (C) 1994-2005, Index Data, All rights reserved.
+## $Id: Makefile.am,v 1.31 2005-04-22 08:27:57 adam Exp $
 
 AUTOMAKE_OPTIONS = foreign 
 
 
 AUTOMAKE_OPTIONS = foreign 
 
diff --git a/NEWS b/NEWS
index d445814..3b4eb66 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,18 @@
 Possible compatibility problems with earlier versions marked with '*'.
 
 Possible compatibility problems with earlier versions marked with '*'.
 
+Changed include/yaz/diagbib1.h and added include/yaz/diagsrw.h with
+diagnostic messages+codes for Bib-1 and SRW. Preprocessor defines are
+now defined for all those error codes. So instead of putting 109 in
+your program you'd use YAZ_BIB1_DATABASE_UNAVAILABLE. The
+messages are now generated from a .csv - file. See src/bib1.csv and
+srw/srw.csv.
+
+Modified the yaz-marcdump utility to skip garbage bytes between MARC
+records in a file.
+
+Fixed bug - uinitialized memory - introduced by code introduced by
+the fix of bug #272.
+
 --- 2.1.2 2005/03/16 
 
 Fixed bug #273: Update for recent MARC-8 -> UNICODE changes. 
 --- 2.1.2 2005/03/16 
 
 Fixed bug #273: Update for recent MARC-8 -> UNICODE changes. 
index a673bb6..7de70f7 100644 (file)
@@ -1,8 +1,8 @@
-## $Id: Makefile.am,v 1.24 2004-12-13 14:21:55 heikki Exp $
+## $Id: Makefile.am,v 1.25 2005-04-22 08:27:57 adam Exp $
 
 pkginclude_HEADERS= backend.h ccl.h cql.h comstack.h \
 
 pkginclude_HEADERS= backend.h ccl.h cql.h comstack.h \
- diagbib1.h sortspec.h log.h logrpn.h marcdisp.h nmem.h odr.h oid.h \
- options.h otherinfo.h pquery.h prt-ext.h readconf.h statserv.h \
+ diagbib1.h diagsrw.h sortspec.h log.h logrpn.h marcdisp.h nmem.h odr.h \
+ oid.h options.h otherinfo.h pquery.h prt-ext.h readconf.h statserv.h \
  tcpip.h unix.h tpath.h wrbuf.h xmalloc.h \
  yaz-ccl.h yaz-iconv.h yaz-util.h yaz-version.h yconfig.h proto.h \
  \
  tcpip.h unix.h tpath.h wrbuf.h xmalloc.h \
  yaz-ccl.h yaz-iconv.h yaz-util.h yaz-version.h yconfig.h proto.h \
  \
diff --git a/include/yaz/diagbib1.h b/include/yaz/diagbib1.h
deleted file mode 100644 (file)
index 3339c64..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (C) 1995-2005, Index Data ApS
- *
- * Permission to use, copy, modify, distribute, and sell this software and
- * its documentation, in whole or in part, for any purpose, is hereby granted,
- * provided that:
- *
- * 1. This copyright and permission notice appear in all copies of the
- * software and its documentation. Notices of copyright or attribution
- * which appear at the beginning of any file must remain unchanged.
- *
- * 2. The name of Index Data or the individual authors may not be used to
- * endorse or promote products derived from this software without specific
- * prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS, IMPLIED, OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
- * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
- * IN NO EVENT SHALL INDEX DATA BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
- * INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR
- * NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
- * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
- * OF THIS SOFTWARE.
- *
- * $Id: diagbib1.h,v 1.5 2005-01-15 19:47:09 adam Exp $
- */
-
-/**
- * \file diagbib1.h
- * \brief Declares diagbib1_str
- */
-
-#ifndef DIAGBIB1_H
-#define DIAGBIB1_H
-
-#include <yaz/yconfig.h>
-
-YAZ_BEGIN_CDECL
-
-YAZ_EXPORT const char *diagbib1_str (int code);
-
-YAZ_END_CDECL
-
-#endif
index a6d60ad..2f6b505 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2005, Index Data ApS
  * See the file LICENSE for details.
  *
  * Copyright (C) 1995-2005, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: srw.h,v 1.20 2005-01-15 19:47:10 adam Exp $
+ * $Id: srw.h,v 1.21 2005-04-22 08:27:57 adam Exp $
  */
 /**
  * \file srw.h
  */
 /**
  * \file srw.h
@@ -14,6 +14,7 @@
 
 #include <yaz/soap.h>
 #include <yaz/zgdu.h>
 
 #include <yaz/soap.h>
 #include <yaz/zgdu.h>
+#include <yaz/diagsrw.h>
 
 YAZ_BEGIN_CDECL
 
 
 YAZ_BEGIN_CDECL
 
@@ -141,8 +142,6 @@ YAZ_EXPORT int yaz_srw_codec(ODR o, void * pptr,
                              void *client_data, const char *ns);
 YAZ_EXPORT Z_SRW_PDU *yaz_srw_get(ODR o, int which);
 
                              void *client_data, const char *ns);
 YAZ_EXPORT Z_SRW_PDU *yaz_srw_get(ODR o, int which);
 
-YAZ_EXPORT const char *yaz_diag_srw_str (int code);
-
 YAZ_EXPORT int yaz_diag_bib1_to_srw (int bib1_code);
 
 YAZ_EXPORT int yaz_diag_srw_to_bib1(int srw_code);
 YAZ_EXPORT int yaz_diag_bib1_to_srw (int bib1_code);
 
 YAZ_EXPORT int yaz_diag_srw_to_bib1(int srw_code);
index 3810b5a..fd261a2 100644 (file)
@@ -1,6 +1,6 @@
-## Copyright (C) 1994-2004, Index Data
-## All rights reserved.
-## $Id: Makefile.am,v 1.19 2005-04-11 08:41:39 adam Exp $
+## This file is part of the YAZ toolkit.
+## Copyright (C) 1994-2005, Index Data, All rights reserved.
+## $Id: Makefile.am,v 1.20 2005-04-22 08:27:57 adam Exp $
 
 if ISTHR
 thrlib=libyazthread.la
 
 if ISTHR
 thrlib=libyazthread.la
@@ -21,7 +21,8 @@ illdatadir=$(pkgdatadir)/ill
 illdata_DATA=ill9702.asn item-req.asn ill.tcl
 
 EXTRA_DIST=$(tabdata_DATA) $(illdata_DATA) \
 illdata_DATA=ill9702.asn item-req.asn ill.tcl
 
 EXTRA_DIST=$(tabdata_DATA) $(illdata_DATA) \
- charconv.tcl codetables.xml
+ charconv.tcl codetables.xml \
+ csvtodiag.tcl csvtobib1.tcl csvtosrw.tcl bib1.csv srw.csv
 
 YAZCOMP = $(top_srcdir)/util/yaz-asncomp
 YAZCOMPLINE = $(YAZCOMP) -d z.tcl -i yaz -I../include $(YCFLAGS)
 
 YAZCOMP = $(top_srcdir)/util/yaz-asncomp
 YAZCOMPLINE = $(YAZCOMP) -d z.tcl -i yaz -I../include $(YCFLAGS)
@@ -34,6 +35,13 @@ THREADED_FLAGS = @CFLAGSTHREADS@
 marc8.c: charconv.tcl codetables.xml
        cd $(srcdir); ./charconv.tcl -p marc8 codetables.xml -o marc8.c
 
 marc8.c: charconv.tcl codetables.xml
        cd $(srcdir); ./charconv.tcl -p marc8 codetables.xml -o marc8.c
 
+# Generate diagnostics from CSVs
+$(top_srcdir)/include/yaz/diagbib1.h diagbib1.c: csvtobib1.tcl bib1.csv
+       cd $(srcdir); ./csvtobib1.tcl
+
+$(top_srcdir)/include/yaz/diagsrw.h diagsrw.c: csvtosrw.tcl srw.csv
+       cd $(srcdir); ./csvtosrw.tcl
+
 libyaz_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 \
 libyaz_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 \
@@ -51,7 +59,7 @@ libyaz_la_SOURCES=version.c options.c log.c marcdisp.c oid.c wrbuf.c \
   z-charneg.c \
   prt-ext.c \
   ill-core.c item-req.c ill-get.c \
   z-charneg.c \
   prt-ext.c \
   ill-core.c item-req.c ill-get.c \
-  zget.c yaz-ccl.c diagbib1.c diagsrw.c logrpn.c \
+  zget.c yaz-ccl.c diag-entry.c diag-entry.h diagbib1.c diagsrw.c logrpn.c \
   otherinfo.c pquery.c sortspec.c z3950oid.c charneg.c initopt.c \
   zoom-c.c zoom-opt.c zoom-p.h grs1disp.c zgdu.c soap.c srw.c srwutil.c \
   opacdisp.c cclfind.c ccltoken.c cclerrms.c cclqual.c cclptree.c \
   otherinfo.c pquery.c sortspec.c z3950oid.c charneg.c initopt.c \
   zoom-c.c zoom-opt.c zoom-p.h grs1disp.c zgdu.c soap.c srw.c srwutil.c \
   opacdisp.c cclfind.c ccltoken.c cclerrms.c cclqual.c cclptree.c \
@@ -89,8 +97,8 @@ $(srcdir)/zes-pquery.c \
 $(srcdir)/zes-psched.c \
 $(srcdir)/zes-pset.c \
 $(srcdir)/zes-update0.c \
 $(srcdir)/zes-psched.c \
 $(srcdir)/zes-pset.c \
 $(srcdir)/zes-update0.c \
-$(top_srcdir)/include/z-accdes1.h \
-$(top_srcdir)/include/z-core.h: \
+$(top_srcdir)/include/yaz/z-accdes1.h \
+$(top_srcdir)/include/yaz/z-core.h: \
 $(srcdir)/z.tcl $(srcdir)/z3950v3.asn $(YAZCOMP)
        cd $(srcdir); $(YAZCOMPLINE) z3950v3.asn
 
 $(srcdir)/z.tcl $(srcdir)/z3950v3.asn $(YAZCOMP)
        cd $(srcdir); $(YAZCOMPLINE) z3950v3.asn
 
diff --git a/src/bib1.csv b/src/bib1.csv
new file mode 100644 (file)
index 0000000..ef86981
--- /dev/null
@@ -0,0 +1,176 @@
+"$Id: bib1.csv,v 1.1 2005-04-22 08:27:58 adam Exp $"
+1, "Permanent system error"
+2, "Temporary system error"
+3, "Unsupported search"
+4, "Terms only exclusion (stop) words"
+5, "Too many argument words"
+6, "Too many boolean operators"
+7, "Too many truncated words"
+8, "Too many incomplete subfields"
+9, "Truncated words too short"
+10, "Invalid format for record number (search term)"
+11, "Too many characters in search statement"
+12, "Too many records retrieved"
+13, "Present request out of range"
+14, "System error in presenting records"
+15, "Record no authorized to be sent intersystem"
+16, "Record exceeds Preferred-message-size"
+17, "Record exceeds Maximum-record-size"
+18, "Result set not supported as a search term"
+19, "Only single result set as search term supported"
+20, "Only ANDing of a single result set as search term supported"
+21, "Result set exists and replace indicator off"
+22, "Result set naming not supported"
+23, "Combination of specified databases not supported"
+24, "Element set names not supported"
+25, "Specified element set name not valid for specified database"
+26, "Only a single element set name supported"
+27, "Result set no longer exists - unilaterally deleted by target"
+28, "Result set is in use"
+29, "One of the specified databases is locked"
+30, "Specified result set does not exist"
+31, "Resources exhausted - no results available"
+32, "Resources exhausted - unpredictable partial results available"
+33, "Resources exhausted - valid subset of results available"
+100, "Unspecified error"
+101, "Access-control failure"
+102, "Security challenge required but could not be issued - request terminated"
+103, "Security challenge required but could not be issued - record not included"
+104, "Security challenge failed - record not included"
+105, "Terminated by negative continue response"
+106, "No abstract syntaxes agreed to for this record"
+107, "Query type not supported"
+108, "Malformed query"
+109, "Database unavailable"
+110, "Operator unsupported"
+111, "Too many databases specified"
+112, "Too many result sets created"
+113, "Unsupported attribute type"
+114, "Unsupported Use attribute"
+115, "Unsupported value for Use attribute"
+116, "Use attribute required but not supplied"
+117, "Unsupported Relation attribute"
+118, "Unsupported Structure attribute"
+119, "Unsupported Position attribute"
+120, "Unsupported Truncation attribute"
+121, "Unsupported Attribute Set"
+122, "Unsupported Completeness attribute"
+123, "Unsupported attribute combination"
+124, "Unsupported coded value for term"
+125, "Malformed search term"
+126, "Illegal term value for attribute"
+127, "Unparsable format for un-normalized value"
+128, "Illegal result set name"
+129, "Proximity search of sets not supported"
+130, "Illegal result set in proximity search"
+131, "Unsupported proximity relation"
+132, "Unsupported proximity unit code"
+201, "Proximity not supported with this attribute combination"
+202, "Unsupported distance for proximity"
+203, "Ordered flag not supported for proximity"
+205, "Only zero step size supported for Scan"
+206, "Specified step size not supported for Scan"
+207, "Cannot sort according to sequence"
+208, "No result set name supplied on Sort"
+209, "Generic sort not supported (database-specific sort only supported)"
+210, "Database specific sort not supported"
+211, "Too many sort keys"
+212, "Duplicate sort keys"
+213, "Unsupported missing data action"
+214, "Illegal sort relation"
+215, "Illegal case value"
+216, "Illegal missing data action"
+217, "Segmentation: Cannot guarantee records will fit in specified segments"
+218, "ES: Package name already in use"
+219, "ES: no such package, on modify/delete"
+220, "ES: quota exceeded"
+221, "ES: extended service type not supported"
+222, "ES: permission denied on ES - id not authorized"
+223, "ES: permission denied on ES - cannot modify or delete"
+224, "ES: immediate execution failed"
+225, "ES: immediate execution not supported for this service"
+226, "ES: immediate execution not supported for these parameters"
+227, "No data available in requested record syntax"
+228, "Scan: malformed scan"
+229, "Term type not supported"
+230, "Sort: too many input results"
+231, "Sort: incompatible record formats"
+232, "Scan: term list not supported"
+233, "Scan: unsupported value of position-in-response"
+234, "Too many index terms processed"
+235, "Database does not exist"
+236, "Access to specified database denied"
+237, "Sort: illegal sort"
+238, "Record not available in requested syntax"
+239, "Record syntax not supported"
+240, "Scan: Resources exhausted looking for satisfying terms"
+241, "Scan: Beginning or end of term list"
+242, "Segmentation: max-segment-size too small to segment record"
+243, "Present:  additional-ranges parameter not supported"
+244, "Present:  comp-spec parameter not supported"
+245, "Type-1 query: restriction ('resultAttr') operand not supported"
+246, "Type-1 query: 'complex' attributeValue not supported"
+247, "Type-1 query: 'attributeSet' as part of AttributeElement not supported"
+1001, "Malformed APDU" 
+1002, "ES: EXTERNAL form of Item Order request not supported"
+1003, "ES: Result set item form of Item Order request not supported"
+1004, "ES: Extended services not supported unless access control is in effect"
+1005, "Response records in Search response not supported"
+1006, "Response records in Search response not possible for specified database (or database combination)"
+1007, "No Explain server. Addinfo: pointers to servers that have a surrogate Explain database for this server"
+1008, "ES: missing mandatory parameter for specified function. Addinfo: parameter"
+1009, "ES: Item Order, unsupported OID in itemRequest. Addinfo: OID"
+1010, "Init/AC: Bad Userid"
+1011, "Init/AC: Bad Userid and/or Password"
+1012, "Init/AC: No searches remaining (pre-purchased searches exhausted)"
+1013, "Init/AC: Incorrect interface type (specified id valid only when used with a particular access method or client)"
+1014, "Init/AC: Authentication System error"
+1015, "Init/AC: Maximum number of simultaneous sessions for Userid"
+1016, "Init/AC: Blocked network address"
+1017, "Init/AC: No databases available for specified userId"
+1018, "Init/AC: System temporarily out of resources"
+1019, "Init/AC: System not available due to maintenance"
+1020, "Init/AC: System temporarily unavailable (Addinfo: when it's expected back up)"
+1021, "Init/AC: Account has expired"
+1022, "Init/AC: Password has expired so a new one must be supplied"
+1023, "Init/AC: Password has been changed by an administrator so a new one must be supplied"
+1024, "Unsupported Attribute"
+1025, "Service not supported for this database"
+1026, "Record cannot be opened because it is locked"
+1027, "SQL error"
+1028, "Record deleted"
+1029, "Scan: too many terms requested. Addinfo: max terms supported"
+1040, "ES: Invalid function"
+1041, "ES: Error in retention time"
+1042, "ES: Permissions data not understood"
+1043, "ES: Invalid OID for task specific parameters"
+1044, "ES: Invalid action"
+1045, "ES: Unknown schema"
+1046, "ES: Too many records in package"
+1047, "ES: Invalid wait action"
+1048, "ES: Cannot create task package -- exceeds maximum permissable size"
+1049, "ES: Cannot return task package -- exceeds maximum permissable size"
+1050, "ES: Extended services request too large"
+1051, "Scan: Attribute set id required -- not supplied"
+1052, "ES: Cannot process task package record -- exceeds maximum permissible record size for ES"
+1053, "ES: Cannot return task package record -- exceeds maximum permissible record size for ES response"
+1054, "Init: Required negotiation record not included"
+1055, "Init: negotiation option required"
+1056, "Attribute not supported for database"
+1057, "ES: Unsupported value of task package parameter"
+1058, "Duplicate Detection: Cannot dedup on requested record portion"  
+1059, "Duplicate Detection: Requested detection criterion not supported"
+1060, "Duplicate Detection: Requested level of match not supported"
+1061, "Duplicate Detection: Requested regular expression not supported"
+1062, "Duplicate Detection: Cannot do clustering"
+1063, "Duplicate Detection: Retention criterion not supported"
+1064, "Duplicate Detection: Requested number (or percentage) of entries "
+      "for retention too large"
+1065, "Duplicate Detection: Requested sort criterion not supported"
+1066, "CompSpec: Unknown schema, or schema not supported."
+1067, "Encapsulation: Encapsulated sequence of PDUs not supported"
+1068, "Encapsulation: Base operation (and encapsulated PDUs) not executed based on pre-screening analysis"
+1069, "No syntaxes available for this request"
+1070, "user not authorized to receive record(s) in requested syntax"
+1071, "preferredRecordSyntax not supplied"
+1072, "Query term includes characters that do not translate into the target character set"
diff --git a/src/csvtobib1.tcl b/src/csvtobib1.tcl
new file mode 100755 (executable)
index 0000000..04a1b2b
--- /dev/null
@@ -0,0 +1,18 @@
+#!/bin/sh
+# the next line restats using tclsh \
+exec tclsh "$0" "$@"
+#
+# This file is part of the YAZ toolkit
+# Copyright (c) Index Data 1996-2005
+# See the file LICENSE for details.
+#
+# $Id: csvtobib1.tcl,v 1.1 2005-04-22 08:27:58 adam Exp $
+#
+# Converts a CSV file with Bib-1 diagnostics to C+H file for easy
+# maintenance
+#
+# $Id: csvtobib1.tcl,v 1.1 2005-04-22 08:27:58 adam Exp $
+
+source csvtodiag.tcl
+
+csvtodiag {bib1.csv diagbib1.c ../include/yaz/diagbib1.h} bib1 diagbib1_str
\ No newline at end of file
diff --git a/src/csvtodiag.tcl b/src/csvtodiag.tcl
new file mode 100644 (file)
index 0000000..e5d6a3f
--- /dev/null
@@ -0,0 +1,90 @@
+# This file is part of the YAZ toolkit
+# Copyright (c) Index Data 1996-2005
+# See the file LICENSE for details.
+#
+# $Id: csvtodiag.tcl,v 1.1 2005-04-22 08:27:58 adam Exp $
+#
+# Converts a CSV file with diagnostics to C+H file for easy
+# maintenance
+
+proc csvtodiag {ifiles name alias} {
+    set uname [string toupper $name]
+    set funcproto "const char *yaz_diag_${name}_str(int code)"
+    if {[string length $alias]} {
+       set funcalias "const char *${alias}(int code)"
+    }
+    set csv [open [lindex $ifiles 0] r]
+    set cfile [open [lindex $ifiles 1] w]
+    set hfile [open [lindex $ifiles 2] w]
+    set lineno 0
+    set preamble "/* Generated automatically by csvtodiag.tcl from [lindex $ifiles 0] */"
+    puts $cfile $preamble
+    puts $cfile "
+#include \"diag-entry.h\"
+struct yaz_diag_entry yaz_diag_${name}_tab\[\] = \{
+"
+    puts $hfile $preamble
+    puts $hfile "
+\#include <yaz/yconfig.h>
+
+\#ifndef YAZ_DIAG_${name}_H
+\#define YAZ_DIAG_${name}_H
+YAZ_BEGIN_CDECL
+YAZ_EXPORT $funcproto;"
+
+    if {[info exists funcalias]} {
+         puts $hfile "YAZ_EXPORT $funcalias;"
+}
+    while {1} {
+       incr lineno
+       set cnt [gets $csv line]
+       if {$cnt < 0} {
+           break
+       }
+       if {[regexp {([0-9]+)[^\"]*"([^\"]*)"} $line s code msg]} {
+           puts $cfile "\{$code, \"$msg\"\},"
+
+           set m [string toupper $msg]
+           regsub -all {DUPLICATE} $m {DUP} m
+           regsub -all {SECURITY CHALLENGE} $m {SEC_CHAL} m
+           regsub -all {COULD NOT} $m {COULDNT} m
+           regsub -all {COULD NOT} $m {COULDNT} m
+           regsub -all {NOT SUPPORTED} $m {UNSUPP} m
+           regsub -all {UNSUPPORTED} $m {UNSUPP} m
+           regsub -all {COMBINATION} $m {COMBI} m
+           regsub -all {PROXIMITY} $m {PROX} m
+           regsub -all {CHARACTERS} $m {CHARS} m
+           regsub -all {CHARACTER} $m {CHAR} m
+           regsub -all {[-/,:;."' \{\}()]} $m _ m
+            set m [string map {___ _ __ _} $m]
+           if {[string length $m] > 55} {
+               set m [string range $m 0 55]
+               set p [string last _ $m]
+               if {$p > 30} {
+                   set m [string range $m 0 $p]
+               }
+           }
+            puts $hfile "\#define YAZ_${uname}_${m} $code"
+       }
+    }
+    puts $cfile "\{0, 0\}\}\;"
+    puts $cfile $funcproto
+    puts $cfile "\{"
+    puts $cfile "    return yaz_diag_to_str(yaz_diag_${name}_tab, code);"
+    puts $cfile "\}"
+
+    if {[info exists funcalias]} {
+        puts $cfile $funcalias
+        puts $cfile "\{"
+        puts $cfile "    return yaz_diag_to_str(yaz_diag_${name}_tab, code);"
+        puts $cfile "\}"
+    }
+    puts $hfile "
+YAZ_END_CDECL
+\#endif
+"
+    close $csv
+    close $cfile
+    close $hfile
+}
+
diff --git a/src/csvtosrw.tcl b/src/csvtosrw.tcl
new file mode 100755 (executable)
index 0000000..157e231
--- /dev/null
@@ -0,0 +1,18 @@
+#!/bin/sh
+# the next line restats using tclsh \
+exec tclsh "$0" "$@"
+#
+# This file is part of the YAZ toolkit
+# Copyright (c) Index Data 1996-2005
+# See the file LICENSE for details.
+#
+# $Id: csvtosrw.tcl,v 1.1 2005-04-22 08:27:58 adam Exp $
+#
+# Converts a CSV file with SRW diagnostics to C+H file for easy
+# maintenance
+#
+# $Id: csvtosrw.tcl,v 1.1 2005-04-22 08:27:58 adam Exp $
+
+source csvtodiag.tcl
+
+csvtodiag {srw.csv diagsrw.c ../include/yaz/diagsrw.h} srw {}
\ No newline at end of file
diff --git a/src/diag-entry.c b/src/diag-entry.c
new file mode 100644 (file)
index 0000000..d3c082c
--- /dev/null
@@ -0,0 +1,17 @@
+/*
+ * Copyright (C) 1995-2005, Index Data ApS
+ * See the file LICENSE for details.
+ *
+ * $Id: diag-entry.c,v 1.1 2005-04-22 08:27:58 adam Exp $
+ */
+
+#include "diag-entry.h"
+
+const char *yaz_diag_to_str(struct yaz_diag_entry *tab, int code)
+{
+    int i;
+    for (i=0; tab[i].msg; i++)
+        if (tab[i].code == code)
+            return tab[i].msg;
+    return "Unknown error";
+}
diff --git a/src/diag-entry.h b/src/diag-entry.h
new file mode 100644 (file)
index 0000000..e8a3508
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Copyright (C) 1995-2005, Index Data ApS
+ * See the file LICENSE for details.
+ *
+ * $Id: diag-entry.h,v 1.1 2005-04-22 08:27:58 adam Exp $
+ */
+
+struct yaz_diag_entry {
+    int code;
+    char *msg;
+};
+
+const char *yaz_diag_to_str(struct yaz_diag_entry *tab, int code);
diff --git a/src/diagbib1.c b/src/diagbib1.c
deleted file mode 100644 (file)
index cb0231b..0000000
+++ /dev/null
@@ -1,237 +0,0 @@
-/*
- * Copyright (C) 1995-2005, Index Data ApS
- * See the file LICENSE for details.
- *
- * $Id: diagbib1.c,v 1.3 2005-01-15 19:47:13 adam Exp $
- */
-
-/**
- * \file diagbib1.c
- * \brief Implements diagbib1_str
- */
-
-#include <stdio.h>
-
-#include <yaz/diagbib1.h>
-
-static struct {
-    int code;
-    char *msg;
-} msg_tab[] = {
-{ 1, "Permanent system error" },
-{ 2, "Temporary system error" },
-{ 3, "Unsupported search" },
-{ 4, "Terms only exclusion (stop) words" },
-{ 5, "Too many argument words" },
-{ 6, "Too many boolean operators" },
-{ 7, "Too many truncated words" },
-{ 8, "Too many incomplete subfields" },
-{ 9, "Truncated words too short" },
-{ 10, "Invalid format for record number (search term)" },
-{ 11, "Too many characters in search statement" },
-{ 12, "Too many records retrieved" },
-{ 13, "Present request out of range" },
-{ 14, "System error in presenting records" },
-{ 15, "Record no authorized to be sent intersystem" },
-{ 16, "Record exceeds Preferred-message-size" },
-{ 17, "Record exceeds Maximum-record-size" },
-{ 18, "Result set not supported as a search term" },
-{ 19, "Only single result set as search term supported" },
-{ 20, "Only ANDing of a single result set as search term supported" },
-{ 21, "Result set exists and replace indicator off" },
-{ 22, "Result set naming not supported" },
-{ 23, "Combination of specified databases not supported" },
-{ 24, "Element set names not supported" },
-{ 25, "Specified element set name not valid for specified database" },
-{ 26, "Only a single element set name supported" },
-{ 27, "Result set no longer exists - unilaterally deleted by target" },
-{ 28, "Result set is in use" },
-{ 29, "One of the specified databases is locked" },
-{ 30, "Specified result set does not exist" },
-{ 31, "Resources exhausted - no results available" },
-{ 32, "Resources exhausted - unpredictable partial results available" },
-{ 33, "Resources exhausted - valid subset of results available" },
-{ 100, "Unspecified error" },
-{ 101, "Access-control failure" },
-{ 102, "Security challenge required but could not be issued -"
-" request terminated" },
-{ 103, "Security challenge required but could not be issued -"
-" record not included" },
-{ 104, "Security challenge failed - record not included" },
-{ 105, "Terminated by negative continue response" },
-{ 106, "No abstract syntaxes agreed to for this record" },
-{ 107, "Query type not supported" },
-{ 108, "Malformed query" },
-{ 109, "Database unavailable" },
-{ 110, "Operator unsupported" },
-{ 111, "Too many databases specified" },
-{ 112, "Too many result sets created" },
-{ 113, "Unsupported attribute type" },
-{ 114, "Unsupported Use attribute" },
-{ 115, "Unsupported value for Use attribute" },
-{ 116, "Use attribute required but not supplied" },
-{ 117, "Unsupported Relation attribute" },
-{ 118, "Unsupported Structure attribute" },
-{ 119, "Unsupported Position attribute" },
-{ 120, "Unsupported Truncation attribute" },
-{ 121, "Unsupported Attribute Set" },
-{ 122, "Unsupported Completeness attribute" },
-{ 123, "Unsupported attribute combination" },
-{ 124, "Unsupported coded value for term" },
-{ 125, "Malformed search term" },
-{ 126, "Illegal term value for attribute" },
-{ 127, "Unparsable format for un-normalized value" },
-{ 128, "Illegal result set name" },
-{ 129, "Proximity search of sets not supported" },
-{ 130, "Illegal result set in proximity search" },
-{ 131, "Unsupported proximity relation" },
-{ 132, "Unsupported proximity unit code" },
-{ 201, "Proximity not supported with this attribute combination" },
-{ 202, "Unsupported distance for proximity" },
-{ 203, "Ordered flag not supported for proximity" },
-{ 205, "Only zero step size supported for Scan" },
-{ 206, "Specified step size not supported for Scan" },
-{ 207, "Cannot sort according to sequence" },
-{ 208, "No result set name supplied on Sort" },
-{ 209, "Generic sort not supported (database-specific sort only supported)" },
-{ 210, "Database specific sort not supported" },
-{ 211, "Too many sort keys" },
-{ 212, "Duplicate sort keys" },
-{ 213, "Unsupported missing data action" },
-{ 214, "Illegal sort relation" },
-{ 215, "Illegal case value" },
-{ 216, "Illegal missing data action" },
-{ 217, "Segmentation: Cannot guarantee records will fit in specified segments"
-},
-{ 218, "ES: Package name already in use" },
-{ 219, "ES: no such package, on modify/delete" },
-{ 220, "ES: quota exceeded" },
-{ 221, "ES: extended service type not supported" },
-{ 222, "ES: permission denied on ES - id not authorized" },
-{ 223, "ES: permission denied on ES - cannot modify or delete" },
-{ 224, "ES: immediate execution failed" },
-{ 225, "ES: immediate execution not supported for this service" },
-{ 226, "ES: immediate execution not supported for these parameters" },
-{ 227, "No data available in requested record syntax" },
-{ 228, "Scan: malformed scan" },
-{ 229, "Term type not supported" },
-{ 230, "Sort: too many input results" },
-{ 231, "Sort: incompatible record formats" },
-{ 232, "Scan: term list not supported" },
-{ 233, "Scan: unsupported value of position-in-response" },
-{ 234, "Too many index terms processed" },
-{ 235, "Database does not exist" },
-{ 236, "Access to specified database denied" },
-{ 237, "Sort: illegal sort" },
-{ 238, "Record not available in requested syntax" },
-{ 239, "Record syntax not supported" },
-{ 240, "Scan: Resources exhausted looking for satisfying terms" },
-{ 241, "Scan: Beginning or end of term list" },
-{ 242, "Segmentation: max-segment-size too small to segment record" },
-{ 243, "Present:  additional-ranges parameter not supported" },
-{ 244, "Present:  comp-spec parameter not supported" },
-{ 245, "Type-1 query: restriction ('resultAttr') operand not supported" },
-{ 246, "Type-1 query: 'complex' attributeValue not supported" },
-{ 247, "Type-1 query: 'attributeSet' as part of AttributeElement not supported" },
-{ 1001, "Malformed APDU"}, 
-{ 1002, "ES: EXTERNAL form of Item Order request not supported" },
-{ 1003, "ES: Result set item form of Item Order request not supported" },
-{ 1004, "ES: Extended services not supported unless access control is in effect" },
-{ 1005, "Response records in Search response not supported" },
-{ 1006, "Response records in Search response not possible for specified database (or database combination)" },
-{ 1007, "No Explain server. Addinfo: pointers to servers that have a surrogate Explain database for this server" },
-{ 1008, "ES: missing mandatory parameter for specified function. Addinfo: parameter" },
-{ 1009, "ES: Item Order, unsupported OID in itemRequest. Addinfo: OID" },
-{ 1010, "Init/AC: Bad Userid" },
-{ 1011, "Init/AC: Bad Userid and/or Password" },
-{ 1012, "Init/AC: No searches remaining (pre-purchased searches exhausted)" },
-{ 1013, "Init/AC: Incorrect interface type (specified id valid only when used with a particular access method or client)" },
-{ 1014, "Init/AC: Authentication System error" },
-{ 1015, "Init/AC: Maximum number of simultaneous sessions for Userid" },
-{ 1016, "Init/AC: Blocked network address"},
-{ 1017, "Init/AC: No databases available for specified userId"},
-{ 1018, "Init/AC: System temporarily out of resources"},
-{ 1019, "Init/AC: System not available due to maintenance" },
-{ 1020, "Init/AC: System temporarily unavailable (Addinfo: when it's expected back up)"},
-{ 1021, "Init/AC: Account has expired"},
-{ 1022, "Init/AC: Password has expired so a new one must be supplied"},
-{ 1023, "Init/AC: Password has been changed by an administrator so a new one must be supplied"},
-{ 1024, "Unsupported Attribute" },
-{ 1025, "Service not supported for this database" },
-{ 1026, "Record cannot be opened because it is locked"},
-{ 1027, "SQL error" },
-{ 1028, "Record deleted" },
-{ 1029, "Scan: too many terms requested. Addinfo: max terms supported" },
-/* 1030 - 1039 /currently unnassigned */
-    
-/* The following, 1040 - 1047, were approved at the June 1998 ZIG meeting.
-   These were originally proposed for addition to the Extended Services
-   diagnostic set. */
-{ 1040, "ES: Invalid function" },
-{ 1041, "ES: Error in retention time" },
-{ 1042, "ES: Permissions data not understood" },
-{ 1043, "ES: Invalid OID for task specific parameters" },
-{ 1044, "ES: Invalid action" },
-{ 1045, "ES: Unknown schema" },
-{ 1046, "ES: Too many records in package" },
-{ 1047, "ES: Invalid wait action" },
-/* The following, 1048 - 1053, were approved at the October 1998 ZIG
-   meeting. */
-{ 1048, "ES: Cannot create task package -- exceeds maximum permissable size"},
-{ 1049, "ES: Cannot return task package -- exceeds maximum permissable size"},
-{ 1050, "ES: Extended services request too large"},
-{ 1051, "Scan: Attribute set id required -- not supplied"},
-{ 1052, "ES: Cannot process task package record -- exceeds maximum "
-      "permissible record size for ES" },
-{ 1053, "ES: Cannot return task package record -- exceeds maximum "
-      "permissible record size for ES response" },
-/* The following, 1054 - 1057, were approved at the March 1999 ZIG
-   meeting. 1054 and 1055 are added for support of the Model for Z39.50
-   Negotiation During Initialization
-   <http://lcweb.loc.gov/z3950/agency/nego.html>. 1056 was added in
-   conjunction with the clarification Single-PDU, Multi-database Searching
-   -- Status <http://lcweb.loc.gov/z3950/agency/clarify/db-status.html> */
-{ 1054, "Init: Required negotiation record not included"},
-{ 1055, "Init: negotiation option required"},
-{ 1056, "Attribute not supported for database" },
-{ 1057, "ES: Unsupported value of task package parameter"},
-/* The following, 1058 - 1066, were approved at the August 1999 ZIG
-   meeting. 1058 through 1065 are added for support of the Z39.50 Duplicate
-   Detection Service <http://lcweb.loc.gov/z3950/agency/amend/dedup.html>. */
-{ 1058, "Duplicate Detection: Cannot dedup on requested record portion" },  
-{ 1059, "Duplicate Detection: Requested detection criterion not supported" },
-{ 1060, "Duplicate Detection: Requested level of match not supported" },
-{ 1061, "Duplicate Detection: Requested regular expression not supported" },
-{ 1062, "Duplicate Detection: Cannot do clustering" },
-{ 1063, "Duplicate Detection: Retention criterion not supported"},
-{ 1064, "Duplicate Detection: Requested number (or percentage) of entries "
-      "for retention too large" },
-{ 1065, "Duplicate Detection: Requested sort criterion not supported" },
-{ 1066, "CompSpec: Unknown schema, or schema not supported."},
-/* The following, 1067 - 1069, were approved at the January 2000 ZIG
-   meeting. 1067 and 1068 are added for support of encapsulation
-   <http://lcweb.loc.gov/z3950/agency/amend/encapsulation.html> . */
-{ 1067, "Encapsulation: Encapsulated sequence of PDUs not supported" },
-{ 1068, "Encapsulation: Base operation (and encapsulated PDUs) not executed "
-      "based on pre-screening analysis" },
-{ 1069, "No syntaxes available for this request" },
-/* The following, 1070-1071, were approved at the July 2000 ZIG meeting.
-   These are defined in conjunction with the clarification Server Selected
-   Record Syntax <http://lcweb.loc.gov/z3950/agency/clarify/altsyntax.html> */
-{ 1070, "user not authorized to receive record(s) in requested syntax" },
-{ 1071, "preferredRecordSyntax not supplied" },
-/* The following diagnostic was approved at the October 2001 ZIG meeting.
-   See http://lists.w3.org/Archives/Public/www-zig/2001Jun/0006.html */
-{ 1072, "Query term includes characters that do not translate into the "
-      "target character set"},
-{ 0, NULL} 
-};
-
-const char *diagbib1_str (int code)
-{
-    int i;
-    for (i=0; msg_tab[i].msg; i++)
-        if (msg_tab[i].code == code)
-            return msg_tab[i].msg;
-    return "Unknown error";
-}
diff --git a/src/diagsrw.c b/src/diagsrw.c
deleted file mode 100644 (file)
index 3caec15..0000000
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- * Copyright (C) 1995-2005, Index Data ApS
- * See the file LICENSE for details.
- *
- * $Id: diagsrw.c,v 1.2 2005-01-15 19:47:13 adam Exp $
- */
-/**
- * \file diagsrw.c
- * \brief SRW/SRU Diagnostic messages.
- */
-
-#include <yaz/srw.h>
-
-static struct {
-    int code;
-    const char *msg;
-} yaz_srw_codes [] = {
-{1, "Permanent system error"}, 
-{2, "System temporarily unavailable"}, 
-{3, "Authentication error"}, 
-{4, "Unsupported operation"},
-{5, "Unsupported version"},
-{6, "Unsupported parameter value"},
-{7, "Mandatory parameter not supplied"},
-{8, "Unsupported parameter"},
-/* Diagnostics Relating to CQL */
-{10, "Query syntax error"}, 
-{11, "Unsupported query type"}, 
-{12, "Too many characters in query"}, 
-{13, "Invalid or unsupported use of parentheses"}, 
-{14, "Invalid or unsupported use of quotes"}, 
-{15, "Unsupported context set"}, 
-{16, "Unsupported index"}, 
-{17, "Unsupported combination of index and context set"}, 
-{18, "Unsupported combination of indexes"}, 
-{19, "Unsupported relation"}, 
-{20, "Unsupported relation modifier"}, 
-{21, "Unsupported combination of relation modifers"}, 
-{22, "Unsupported combination of relation and index"}, 
-{23, "Too many characters in term"}, 
-{24, "Unsupported 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 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 stopwords"}, 
-{36, "Term in invalid format for index or relation"}, 
-{37, "Unsupported boolean operator"}, 
-{38, "Too many boolean operators in query"}, 
-{39, "Proximity not supported"}, 
-{40, "Unsupported proximity relation"}, 
-{41, "Unsupported proximity distance"}, 
-{42, "Unsupported proximity unit"}, 
-{43, "Unsupported proximity ordering"}, 
-{44, "Unsupported combination of proximity modifiers"}, 
-{45, "Prefix assigned to multiple identifiers"}, 
-{46, "Unsupported boolean modifier"},
-{47, "Cannot process query; reason unknown"},
-{48, "Query feature unsupported"},
-{49, "Masking character in unsupported position"},
-/* Diagnostics Relating to Result Sets */
-{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"}, 
-{60, "Result set no created: too many records retrieved"}, 
-/* Diagnostics Relating to Records */
-{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"}, 
-{71, "Unsupported record packing"},
-{72, "XPath retrieval unsupported"},
-{73, "XPath expression contains unsupported feature"},
-{74, "Unable to evaluate XPath expression"},
-/* Diagnostics Relating to Sorting */
-{80, "Sort not supported"}, 
-{81, "Unsupported sort type"}, 
-{82, "Unsupported sort sequence"}, 
-{83, "Too many records to sort"}, 
-{84, "Too many sort keys to sort"}, 
-{85, "Duplicate sort keys"}, 
-{86, "Cannot sort: incompatible record formats"}, 
-{87, "Unsupported schema for sort"}, 
-{88, "Unsupported path for sort"}, 
-{89, "Path unsupported for schema"}, 
-{90, "Unsupported direction value"}, 
-{91, "Unsupported case value"}, 
-{92, "Unsupported missing value action"}, 
-/* Diagnostics Relating to Explain */
-{100, "Explain not supported"}, 
-{101, "Explain request type not supported (SOAP vs GET)"}, 
-{102, "Explain record temporarily unavailable"},
-/* Diagnostics Relating to Stylesheets */
-{110, "Stylesheets not supported"},
-{111, "Unsupported stylesheet"},
-/* Diagnostics relating to Scan */
-{120, "Response position out of range"},
-{121, "Too many terms requested"},
-{0, 0}
-};
-
-const char *yaz_diag_srw_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;
-}
-
index dbc9af1..88dc833 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2005, Index Data ApS
  * See the file LICENSE for details.
  *
  * Copyright (C) 1995-2005, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: seshigh.c,v 1.52 2005-04-14 11:59:46 adam Exp $
+ * $Id: seshigh.c,v 1.53 2005-04-22 08:27:58 adam Exp $
  */
 /**
  * \file seshigh.c
  */
 /**
  * \file seshigh.c
@@ -506,7 +506,8 @@ static int srw_bend_init(association *assoc, Z_SRW_diagnostic **d, int *num)
        if (!(binitres = (*cb->bend_init)(assoc->init)))
        {
            assoc->state = ASSOC_DEAD;
        if (!(binitres = (*cb->bend_init)(assoc->init)))
        {
            assoc->state = ASSOC_DEAD;
-           yaz_add_srw_diagnostic(assoc->encode, d, num, 3, 0);
+           yaz_add_srw_diagnostic(assoc->encode, d, num,
+                           YAZ_SRW_AUTHENTICATION_ERROR, 0);
            return 0;
        }
        assoc->backend = binitres->handle;
            return 0;
        }
        assoc->backend = binitres->handle;
@@ -714,7 +715,8 @@ static void srw_bend_search(association *assoc, request *req,
     srw_bend_init(assoc, &srw_res->diagnostics, &srw_res->num_diagnostics);
     if (srw_req->sort_type != Z_SRW_sort_type_none)
        yaz_add_srw_diagnostic(assoc->encode, &srw_res->diagnostics,
     srw_bend_init(assoc, &srw_res->diagnostics, &srw_res->num_diagnostics);
     if (srw_req->sort_type != Z_SRW_sort_type_none)
        yaz_add_srw_diagnostic(assoc->encode, &srw_res->diagnostics,
-                              &srw_res->num_diagnostics, 80, 0);
+                              &srw_res->num_diagnostics,
+                              YAZ_SRW_SORT_UNSUPP, 0);
     else if (srw_res->num_diagnostics == 0 && assoc->init)
     {
        bend_search_rr rr;
     else if (srw_res->num_diagnostics == 0 && assoc->init)
     {
        bend_search_rr rr;
@@ -772,7 +774,7 @@ static void srw_bend_search(association *assoc, request *req,
                int code = yaz_pqf_error (pqf_parser, &pqf_msg, &off);
                yaz_log(log_requestdetail, "Parse error %d %s near offset %d",
                        code, pqf_msg, off);
                int code = yaz_pqf_error (pqf_parser, &pqf_msg, &off);
                yaz_log(log_requestdetail, "Parse error %d %s near offset %d",
                        code, pqf_msg, off);
-               srw_error = 10;
+               srw_error = YAZ_SRW_QUERY_SYNTAX_ERROR;
            }
            
            rr.query->which = Z_Query_type_1;
            }
            
            rr.query->which = Z_Query_type_1;
@@ -783,7 +785,8 @@ static void srw_bend_search(association *assoc, request *req,
        else
        {
            yaz_add_srw_diagnostic(assoc->encode, &srw_res->diagnostics,
        else
        {
            yaz_add_srw_diagnostic(assoc->encode, &srw_res->diagnostics,
-                                  &srw_res->num_diagnostics, 11, 0);
+                                  &srw_res->num_diagnostics,
+                                  YAZ_SRW_UNSUPP_QUERY_TYPE, 0);
        }
        if (rr.query->u.type_1)
        {
        }
        if (rr.query->u.type_1)
        {
@@ -802,7 +805,7 @@ static void srw_bend_search(association *assoc, request *req,
            (assoc->init->bend_search)(assoc->backend, &rr);
            if (rr.errcode)
            {
            (assoc->init->bend_search)(assoc->backend, &rr);
            if (rr.errcode)
            {
-               if (rr.errcode == 109) /* database unavailable */
+               if (rr.errcode == YAZ_BIB1_DATABASE_UNAVAILABLE)
                {
                    *http_code = 404;
                }
                {
                    *http_code = 404;
                }
@@ -832,7 +835,7 @@ static void srw_bend_search(association *assoc, request *req,
                    {
                        yaz_add_srw_diagnostic(assoc->encode, &srw_res->diagnostics,
                                               &srw_res->num_diagnostics,
                    {
                        yaz_add_srw_diagnostic(assoc->encode, &srw_res->diagnostics,
                                               &srw_res->num_diagnostics,
-                                              61, 0);
+                                              YAZ_SRW_FIRST_RECORD_POSITION_OUT_OF_RANGE, 0);
                    }
                    else
                    {
                    }
                    else
                    {
@@ -1094,12 +1097,13 @@ static void srw_bend_scan(association *assoc, request *req,
        else
        {
            yaz_add_srw_diagnostic(assoc->encode, &srw_res->diagnostics,
        else
        {
            yaz_add_srw_diagnostic(assoc->encode, &srw_res->diagnostics,
-                                  &srw_res->num_diagnostics, 4, "scan");
+                                  &srw_res->num_diagnostics,
+                                  YAZ_SRW_UNSUPP_OPERATION, "scan");
        }
        if (bsrr->errcode)
        {
            int srw_error;
        }
        if (bsrr->errcode)
        {
            int srw_error;
-           if (bsrr->errcode == 109) /* database unavailable */
+           if (bsrr->errcode == YAZ_BIB1_DATABASE_UNAVAILABLE)
            {
                *http_code = 404;
                return;
            {
                *http_code = 404;
                return;
@@ -1639,8 +1643,8 @@ static Z_APDU *process_initRequest(association *assoc, request *reqb)
        /* no backend. return error */
        binitres = odr_malloc(assoc->encode, sizeof(*binitres));
        binitres->errstring = 0;
        /* no backend. return error */
        binitres = odr_malloc(assoc->encode, sizeof(*binitres));
        binitres->errstring = 0;
-       binitres->errcode = 1;
-        iochan_settimeout(assoc->client_chan, 10);
+       binitres->errcode = YAZ_BIB1_PERMANENT_SYSTEM_ERROR;
+       iochan_settimeout(assoc->client_chan, 10);
     }
     if ((assoc->init->bend_sort))
        yaz_log (YLOG_DEBUG, "Sort handler installed");
     }
     if ((assoc->init->bend_sort))
        yaz_log (YLOG_DEBUG, "Sort handler installed");
@@ -1760,7 +1764,7 @@ static Z_APDU *process_initRequest(association *assoc, request *reqb)
                 assoc->init->implementation_name,
                 odr_prepend(assoc->encode, "GFS", resp->implementationName));
 
                 assoc->init->implementation_name,
                 odr_prepend(assoc->encode, "GFS", resp->implementationName));
 
-    version = odr_strdup(assoc->encode, "$Revision: 1.52 $");
+    version = odr_strdup(assoc->encode, "$Revision: 1.53 $");
     if (strlen(version) > 10)   /* check for unexpanded CVS strings */
         version[strlen(version)-2] = '\0';
     resp->implementationVersion = odr_prepend(assoc->encode,
     if (strlen(version) > 10)   /* check for unexpanded CVS strings */
         version[strlen(version)-2] = '\0';
     resp->implementationVersion = odr_prepend(assoc->encode,
@@ -1903,7 +1907,8 @@ static Z_Records *pack_records(association *a, char *setname, int start,
                 *pres = Z_PresentStatus_failure;
                 /* for 'present request out of range',
                    set addinfo to record position if not set */
                 *pres = Z_PresentStatus_failure;
                 /* for 'present request out of range',
                    set addinfo to record position if not set */
-                if (freq.errcode == 13 && freq.errstring == 0)
+                if (freq.errcode == YAZ_BIB1_PRESENT_REQUEST_OUT_OF_RANGE  && 
+                               freq.errstring == 0)
                 {
                     sprintf (s, "%d", recno);
                     freq.errstring = s;
                 {
                     sprintf (s, "%d", recno);
                     freq.errstring = s;
diff --git a/src/srw.csv b/src/srw.csv
new file mode 100644 (file)
index 0000000..9e017b9
--- /dev/null
@@ -0,0 +1,94 @@
+"$Id: srw.csv,v 1.1 2005-04-22 08:27:58 adam Exp $
+1, "Permanent system error" 
+2, "System temporarily unavailable" 
+3, "Authentication error" 
+4, "Unsupported operation"
+5, "Unsupported version"
+6, "Unsupported parameter value"
+7, "Mandatory parameter not supplied"
+8, "Unsupported parameter"
+10, "Query syntax error" 
+11, "Unsupported query type" 
+12, "Too many characters in query" 
+13, "Invalid or unsupported use of parentheses" 
+14, "Invalid or unsupported use of quotes" 
+15, "Unsupported context set" 
+16, "Unsupported index" 
+17, "Unsupported combination of index and context set" 
+18, "Unsupported combination of indexes" 
+19, "Unsupported relation" 
+20, "Unsupported relation modifier" 
+21, "Unsupported combination of relation modifers" 
+22, "Unsupported combination of relation and index" 
+23, "Too many characters in term" 
+24, "Unsupported 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 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 stopwords" 
+36, "Term in invalid format for index or relation" 
+37, "Unsupported boolean operator" 
+38, "Too many boolean operators in query" 
+39, "Proximity not supported" 
+40, "Unsupported proximity relation" 
+41, "Unsupported proximity distance" 
+42, "Unsupported proximity unit" 
+43, "Unsupported proximity ordering" 
+44, "Unsupported combination of proximity modifiers" 
+45, "Prefix assigned to multiple identifiers" 
+46, "Unsupported boolean modifier"
+47, "Cannot process query; reason unknown"
+48, "Query feature unsupported"
+49, "Masking character in unsupported position"
+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" 
+60, "Result set no created: 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" 
+71, "Unsupported record packing"
+72, "XPath retrieval unsupported"
+73, "XPath expression contains unsupported feature"
+74, "Unable to evaluate XPath expression"
+80, "Sort not supported" 
+81, "Unsupported sort type" 
+82, "Unsupported sort sequence" 
+83, "Too many records to sort" 
+84, "Too many sort keys to sort" 
+85, "Duplicate sort keys" 
+86, "Cannot sort: incompatible record formats" 
+87, "Unsupported schema for sort" 
+88, "Unsupported path for sort" 
+89, "Path unsupported for schema" 
+90, "Unsupported direction value" 
+91, "Unsupported case value" 
+92, "Unsupported missing value action" 
+100, "Explain not supported" 
+101, "Explain request type not supported (SOAP vs GET)" 
+102, "Explain record temporarily unavailable"
+110, "Stylesheets not supported"
+111, "Unsupported stylesheet"
+120, "Response position out of range"
+121, "Too many terms requested"