2.0.9 candidate
authorAdam Dickmeiss <adam@indexdata.dk>
Mon, 5 Jan 2004 09:34:41 +0000 (09:34 +0000)
committerAdam Dickmeiss <adam@indexdata.dk>
Mon, 5 Jan 2004 09:34:41 +0000 (09:34 +0000)
15 files changed:
CHANGELOG
LICENSE
README
configure.in
debian/changelog
doc/yaz.xml.in
include/yaz/srw.h
include/yaz/yaz-version.h
src/Makefile.am
src/seshigh.c
src/soap.c
src/srw.c
src/srwutil.c
win/yaz.nsi
win/yaz.rc

index f80bd9f..1d776d6 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,6 @@
 Possible compatibility problems with earlier versions marked with '*'.
 
 Possible compatibility problems with earlier versions marked with '*'.
 
---- 2.0.9 NOT YET RELEASED
+--- 2.0.9 2004/01/05
 
 Fixed bug in Generic Frontend Server which could drop records exceeding
 preferred message size. Reported and fixed by Irina Dijour.
 
 Fixed bug in Generic Frontend Server which could drop records exceeding
 preferred message size. Reported and fixed by Irina Dijour.
diff --git a/LICENSE b/LICENSE
index db81ecc..7727c4a 100644 (file)
--- a/LICENSE
+++ b/LICENSE
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (c) 1995-2003, Index Data.
+ * Copyright (c) 1995-2004, 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,
  *
  * Permission to use, copy, modify, distribute, and sell this software and
  * its documentation, in whole or in part, for any purpose, is hereby granted,
diff --git a/README b/README
index a8bc9f2..166a387 100644 (file)
--- a/README
+++ b/README
@@ -1,6 +1,6 @@
-YAZ toolkit - $Id: README,v 1.44 2003-10-27 12:21:21 adam Exp $
+YAZ toolkit - $Id: README,v 1.45 2004-01-05 09:34:41 adam Exp $
 
 
-Copyright (C) 1995-2003, Index Data ApS.
+Copyright (C) 1995-2004, Index Data ApS.
 See the file LICENSE for details.
 
 The primary output of the source here is the YAZ library, which
 See the file LICENSE for details.
 
 The primary output of the source here is the YAZ library, which
index d8750ad..a679ca1 100644 (file)
@@ -1,8 +1,8 @@
 dnl YAZ Toolkit, Index Data 1994-2003
 dnl See the file LICENSE for details.
 dnl YAZ Toolkit, Index Data 1994-2003
 dnl See the file LICENSE for details.
-dnl $Id: configure.in,v 1.121 2003-12-22 14:46:26 adam Exp $
+dnl $Id: configure.in,v 1.122 2004-01-05 09:34:41 adam Exp $
 AC_INIT(include/yaz/yaz-version.h)
 AC_INIT(include/yaz/yaz-version.h)
-AM_INIT_AUTOMAKE(yaz, 2.0.8)
+AM_INIT_AUTOMAKE(yaz, 2.0.9)
 AM_MAINTAINER_MODE
 dnl
 AC_SUBST(READLINE_LIBS)
 AM_MAINTAINER_MODE
 dnl
 AC_SUBST(READLINE_LIBS)
index c722b80..661831c 100644 (file)
@@ -1,3 +1,9 @@
+yaz (2.0.9-1) unstable; urgency=low
+
+  * Upstream.
+
+ -- Adam Dickmeiss <adam@indexdata.dk>  Mon,  5 Jan 2004 10:32:40 +0100
+
 yaz (2.0.8-1) unstable; urgency=low
 
   * Upstream.
 yaz (2.0.8-1) unstable; urgency=low
 
   * Upstream.
index 85a2951..f424833 100644 (file)
@@ -25,7 +25,7 @@
      <!ENTITY comstack "<acronym>COMSTACK</acronym>">
      <!ENTITY zoom "<acronym>ZOOM</acronym>">
 ]>
      <!ENTITY comstack "<acronym>COMSTACK</acronym>">
      <!ENTITY zoom "<acronym>ZOOM</acronym>">
 ]>
-<!-- $Id: yaz.xml.in,v 1.12 2003-11-03 10:56:15 adam Exp $ -->
+<!-- $Id: yaz.xml.in,v 1.13 2004-01-05 09:35:12 adam Exp $ -->
 <book id="yaz">
  <bookinfo>
   <title>YAZ User&apos;s Guide and Reference</title>
 <book id="yaz">
  <bookinfo>
   <title>YAZ User&apos;s Guide and Reference</title>
@@ -33,7 +33,7 @@
   <author><firstname>Adam</firstname><surname>Dickmeiss</surname></author>
   <author><firstname>Mike</firstname><surname>Taylor</surname></author>
   <copyright>
   <author><firstname>Adam</firstname><surname>Dickmeiss</surname></author>
   <author><firstname>Mike</firstname><surname>Taylor</surname></author>
   <copyright>
-   <year>1995-2003</year>
+   <year>1995-2004</year>
    <holder>Index Data</holder>
   </copyright>
   <abstract><simpara>
    <holder>Index Data</holder>
   </copyright>
   <abstract><simpara>
index c031b24..1b61e2a 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (c) 2002-2003, Index Data.
  * See the file LICENSE for details.
  *
  * Copyright (c) 2002-2003, Index Data.
  * See the file LICENSE for details.
  *
- * $Id: srw.h,v 1.10 2003-12-29 14:54:33 adam Exp $
+ * $Id: srw.h,v 1.11 2004-01-05 09:34:42 adam Exp $
  */
 
 #ifndef YAZ_SRW_H
  */
 
 #ifndef YAZ_SRW_H
@@ -138,10 +138,10 @@ YAZ_EXPORT int yaz_diag_srw_to_bib1(int srw_code);
 YAZ_EXPORT char *yaz_uri_val(const char *path, const char *name, ODR o);
 YAZ_EXPORT void yaz_uri_val_int(const char *path, const char *name,
                                ODR o, int **intp);
 YAZ_EXPORT char *yaz_uri_val(const char *path, const char *name, ODR o);
 YAZ_EXPORT void yaz_uri_val_int(const char *path, const char *name,
                                ODR o, int **intp);
-YAZ_EXPORT int yaz_check_for_srw(Z_HTTP_Request *hreq, Z_SRW_PDU **srw_pdu,
-                                char **soap_ns, ODR decode);
-YAZ_EXPORT int yaz_check_for_sru(Z_HTTP_Request *hreq, Z_SRW_PDU **srw_pdu,
-                                char **soap_ns, ODR decode);
+YAZ_EXPORT int yaz_srw_decode(Z_HTTP_Request *hreq, Z_SRW_PDU **srw_pdu,
+                             Z_SOAP **soap_package, ODR decode, char **charset);
+YAZ_EXPORT int yaz_sru_decode(Z_HTTP_Request *hreq, Z_SRW_PDU **srw_pdu,
+                             Z_SOAP **soap_package, ODR decode, char **charset);
 YAZ_END_CDECL
 
 #endif
 YAZ_END_CDECL
 
 #endif
index 8e6b7f6..1e6914a 100644 (file)
@@ -1,8 +1,8 @@
 /*
 /*
- * Copyright (c) 1995-2003, Index Data.
+ * Copyright (c) 1995-2004, Index Data.
  * See the file LICENSE for details.
  *
  * See the file LICENSE for details.
  *
- * $Id: yaz-version.h,v 1.33 2003-12-22 14:46:26 adam Exp $
+ * $Id: yaz-version.h,v 1.34 2004-01-05 09:34:42 adam Exp $
  */
 
 /*
  */
 
 /*
@@ -12,8 +12,8 @@
 
 #include <yaz/yconfig.h>
 
 
 #include <yaz/yconfig.h>
 
-#define YAZ_VERSION "2.0.8"
-#define YAZ_VERSIONL 0x020008
+#define YAZ_VERSION "2.0.9"
+#define YAZ_VERSIONL 0x020009
 
 #define YAZ_DATE 1
 
 
 #define YAZ_DATE 1
 
index 3f2cf90..d4744fb 100644 (file)
@@ -1,6 +1,6 @@
 ## Copyright (C) 1994-2003, Index Data
 ## All rights reserved.
 ## Copyright (C) 1994-2003, Index Data
 ## All rights reserved.
-## $Id: Makefile.am,v 1.2 2003-12-20 00:51:19 adam Exp $
+## $Id: Makefile.am,v 1.3 2004-01-05 09:34:42 adam Exp $
 
 if ISTHR
 thrlib=libyazthread.la
 
 if ISTHR
 thrlib=libyazthread.la
@@ -29,7 +29,7 @@ EXTRA_DIST=$(tabdata_DATA) $(illdata_DATA) \
 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)
 
-AM_CPPFLAGS=-I$(top_srcdir)/include $(XML2_CFLAGS)
+AM_CPPFLAGS=-I$(top_srcdir)/include $(XSLT_CFLAGS)
 AM_YFLAGS=-p cql_
 THREADED_FLAGS = @CFLAGSTHREADS@
 
 AM_YFLAGS=-p cql_
 THREADED_FLAGS = @CFLAGSTHREADS@
 
index 533ab9a..7a8a7aa 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (c) 1995-2003, Index Data
  * See the file LICENSE for details.
  *
  * Copyright (c) 1995-2003, Index Data
  * See the file LICENSE for details.
  *
- * $Id: seshigh.c,v 1.12 2003-12-31 00:14:01 adam Exp $
+ * $Id: seshigh.c,v 1.13 2004-01-05 09:34:42 adam Exp $
  */
 
 /*
  */
 
 /*
@@ -271,7 +271,7 @@ void ir_session(IOCHAN h, int event)
            destroy_association(assoc);
            iochan_destroy(h);
        }
            destroy_association(assoc);
            iochan_destroy(h);
        }
-       iochan_clearflag (h, EVENT_OUTPUT|EVENT_OUTPUT);
+       iochan_clearflag (h, EVENT_OUTPUT);
        if (conn->io_pending) 
        {   /* cs_accept didn't complete */
            assoc->cs_accept_mask = 
        if (conn->io_pending) 
        {   /* cs_accept didn't complete */
            assoc->cs_accept_mask = 
@@ -779,370 +779,77 @@ static void process_http_request(association *assoc, request *req)
 {
     Z_HTTP_Request *hreq = req->gdu_request->u.HTTP_Request;
     ODR o = assoc->encode;
 {
     Z_HTTP_Request *hreq = req->gdu_request->u.HTTP_Request;
     ODR o = assoc->encode;
+    int r;
+    Z_SRW_PDU *sr = 0;
+    Z_SOAP *soap_package = 0;
     Z_GDU *p = 0;
     Z_GDU *p = 0;
-    Z_HTTP_Response *hres = 0;
+    char *charset = 0;
+    Z_HTTP_Response *hres;
     int keepalive = 1;
 
     int keepalive = 1;
 
-    if (!strcmp(hreq->method, "GET"))
+    r = yaz_srw_decode(hreq, &sr, &soap_package, assoc->decode, &charset);
+    if (r == 2)  /* not taken */
+       r = yaz_sru_decode(hreq, &sr, &soap_package, assoc->decode, &charset);
+    if (r == 0)  /* decode SRW/SRU OK .. */
     {
     {
-        char *db = "Default";
-        const char *p0 = hreq->path, *p1;
-       const char *operation = 0;
-#if HAVE_XML2
-        int ret = -1;
-        char *charset = 0;
-        Z_SOAP *soap_package = 0;
-        static Z_SOAP_Handler soap_handlers[2] = {
-            {"http://www.loc.gov/zing/srw/", 0,
-             (Z_SOAP_fun) yaz_srw_codec},
-            {0, 0, 0}
-        };
-#endif
-        if (*p0 == '/')
-            p0++;
-        p1 = strchr(p0, '?');
-        if (!p1)
-            p1 = p0 + strlen(p0);
-        if (p1 != p0)
-        {
-            db = odr_malloc(assoc->decode, p1 - p0 + 1);
-            memcpy (db, p0, p1 - p0);
-            db[p1 - p0] = '\0';
-        }
-       if (p1)
-           operation = yaz_uri_val(p1, "operation", o);
-       if (!operation)
-           operation = "explain";
-#if HAVE_XML2
-        if (p1 && !strcmp(operation, "searchRetrieve"))
-        {
-            Z_SRW_PDU *res = yaz_srw_get(o, Z_SRW_searchRetrieve_response);
-            Z_SRW_PDU *sr = yaz_srw_get(o, Z_SRW_searchRetrieve_request);
-            char *query = yaz_uri_val(p1, "query", o);
-            char *pQuery = yaz_uri_val(p1, "pQuery", o);
-            char *sortKeys = yaz_uri_val(p1, "sortKeys", o);
-           int http_code = 200;
-            
-            if (query)
-            {
-                sr->u.request->query_type = Z_SRW_query_type_cql;
-                sr->u.request->query.cql = query;
-            }
-            if (pQuery)
-            {
-                sr->u.request->query_type = Z_SRW_query_type_pqf;
-                sr->u.request->query.pqf = pQuery;
-            }
-            if (sortKeys)
-            {
-                sr->u.request->sort_type = Z_SRW_sort_type_sort;
-                sr->u.request->sort.sortKeys = sortKeys;
-            }
-            sr->u.request->recordSchema = yaz_uri_val(p1, "recordSchema", o);
-            sr->u.request->recordPacking = yaz_uri_val(p1, "recordPacking", o);
-            if (!sr->u.request->recordPacking)
-                sr->u.request->recordPacking = "xml";
-            yaz_uri_val_int(p1, "maximumRecords", o, 
-                        &sr->u.request->maximumRecords);
-            yaz_uri_val_int(p1, "startRecord", o,
-                        &sr->u.request->startRecord);
-            sr->u.request->database = db;
-            srw_bend_search(assoc, req, sr->u.request, res->u.response, 
+       int http_code = 200;
+       if (sr->which == Z_SRW_searchRetrieve_request)
+       {
+           Z_SRW_PDU *res =
+               yaz_srw_get(assoc->encode, Z_SRW_searchRetrieve_response);
+           
+           srw_bend_search(assoc, req, sr->u.request, res->u.response, 
                            &http_code);
                            &http_code);
-            
-            soap_package = odr_malloc(o, sizeof(*soap_package));
-            soap_package->which = Z_SOAP_generic;
-
-            soap_package->u.generic =
-                odr_malloc(o, sizeof(*soap_package->u.generic));
-
-            soap_package->u.generic->p = res;
-            soap_package->u.generic->ns = soap_handlers[0].ns;
-            soap_package->u.generic->no = 0;
-            
-            soap_package->ns = "SRU";
-
-            p = z_get_HTTP_Response(o, http_code);
            if (http_code == 200)
            if (http_code == 200)
-           {
-               hres = p->u.HTTP_Response;
-               
-               ret = z_soap_codec_enc(assoc->encode, &soap_package,
-                                      &hres->content_buf, &hres->content_len,
-                                      soap_handlers, charset);
-               if (!charset)
-                   z_HTTP_header_add(o, &hres->headers, "Content-Type", "text/xml");
-               else
-               {
-                   char ctype[60];
-                   strcpy(ctype, "text/xml; charset=");
-                   strcat(ctype, charset);
-                   z_HTTP_header_add(o, &hres->headers, "Content-Type", ctype);
-               }
-           }
-        }
-        else if (p1 && !strcmp(operation, "explain"))
-        {
+               soap_package->u.generic->p = res;
+       }
+       else if (sr->which == Z_SRW_explain_request)
+       {
             Z_SRW_PDU *res = yaz_srw_get(o, Z_SRW_explain_response);
             Z_SRW_PDU *res = yaz_srw_get(o, Z_SRW_explain_response);
-            Z_SRW_PDU *sr = yaz_srw_get(o, Z_SRW_explain_request);
-           int http_code = 200;
-
-            sr->u.explain_request->database = db;
-            sr->u.explain_request->recordPacking =
-               yaz_uri_val(p1, "recordPacking", o);
-            if (!sr->u.explain_request->recordPacking)
-                sr->u.explain_request->recordPacking = "xml";
-
             srw_bend_explain(assoc, req, sr->u.explain_request,
             srw_bend_explain(assoc, req, sr->u.explain_request,
-                            res->u.explain_response, &http_code);
-
-            if (res->u.explain_response->record.recordData_buf)
-            {
-                soap_package = odr_malloc(o, sizeof(*soap_package));
-                soap_package->which = Z_SOAP_generic;
-                
-                soap_package->u.generic =
-                    odr_malloc(o, sizeof(*soap_package->u.generic));
-                
-                soap_package->u.generic->p = res;
-                soap_package->u.generic->ns = soap_handlers[0].ns;
-                soap_package->u.generic->no = 0;
-                
-                soap_package->ns = "SRU";
-                
-                p = z_get_HTTP_Response(o, 200);
-                hres = p->u.HTTP_Response;
-                
-                ret = z_soap_codec_enc(assoc->encode, &soap_package,
-                                       &hres->content_buf, &hres->content_len,
-                                       soap_handlers, charset);
-                if (!charset)
-                    z_HTTP_header_add(o, &hres->headers, "Content-Type", "text/xml");
-                else
-                {
-                    char ctype[60];
-                    strcpy(ctype, "text/xml; charset=");
-                    strcat(ctype, charset);
-                    z_HTTP_header_add(o, &hres->headers, "Content-Type",
-                                      ctype);
-                }
-            }
-        }
-#endif
-#ifdef DOCDIR
-       if (strlen(hreq->path) >= 5 && strlen(hreq->path) < 80 &&
-                        !memcmp(hreq->path, "/doc/", 5))
-        {
-           FILE *f;
-            char fpath[120];
-
-           strcpy(fpath, DOCDIR);
-           strcat(fpath, hreq->path+4);
-           f = fopen(fpath, "rb");
-           if (f) {
-                struct stat sbuf;
-                if (fstat(fileno(f), &sbuf) || !S_ISREG(sbuf.st_mode))
-                {
-                    fclose(f);
-                    f = 0;
-                }
-            }
-            if (f)
-            {
-               long sz;
-               fseek(f, 0L, SEEK_END);
-               sz = ftell(f);
-               if (sz >= 0 && sz < 500000)
-               {
-                   const char *ctype = "application/octet-stream";
-                   const char *cp;
-
-                    p = z_get_HTTP_Response(o, 200);
-                    hres = p->u.HTTP_Response;
-                   hres->content_buf = (char *) odr_malloc(o, sz + 1);
-                   hres->content_len = sz;
-                   fseek(f, 0L, SEEK_SET);
-                   fread(hres->content_buf, 1, sz, f);
-                   if ((cp = strrchr(fpath, '.'))) {
-                       cp++;
-                       if (!strcmp(cp, "png"))
-                           ctype = "image/png";
-                       else if (!strcmp(cp, "gif"))
-                           ctype = "image/gif";
-                       else if (!strcmp(cp, "xml"))
-                           ctype = "text/xml";
-                       else if (!strcmp(cp, "html"))
-                           ctype = "text/html";
-                   }
-                    z_HTTP_header_add(o, &hres->headers, "Content-Type", ctype);
-               }
-               fclose(f);
-           }
+                            res->u.explain_response, &http_code);
+           if (http_code == 200)
+               soap_package->u.generic->p = res;
        }
        }
-#endif
-
-#if 0
-       if (!strcmp(hreq->path, "/")) 
-        {
-#ifdef DOCDIR
-            struct stat sbuf;
-#endif
-            const char *doclink = "";
-            p = z_get_HTTP_Response(o, 200);
-            hres = p->u.HTTP_Response;
-            hres->content_buf = (char *) odr_malloc(o, 400);
-#ifdef DOCDIR
-            if (stat(DOCDIR "/yaz.html", &sbuf) == 0 && S_ISREG(sbuf.st_mode))
-                doclink = "<P><A HREF=\"/doc/yaz.html\">Documentation</A></P>";
-#endif
-            sprintf (hres->content_buf, 
-                     "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\n"
-                     "<HTML>\n"
-                     " <HEAD>\n"
-                     "  <TITLE>YAZ " YAZ_VERSION "</TITLE>\n"
-                     " </HEAD>\n"
-                     " <BODY>\n"
-                     "  <P><A HREF=\"http://www.indexdata.dk/yaz/\">YAZ</A> " 
-                     YAZ_VERSION "</P>\n"
-                     "%s"
-                     " </BODY>\n"
-                     "</HTML>\n", doclink);
-            hres->content_len = strlen(hres->content_buf);
-            z_HTTP_header_add(o, &hres->headers, "Content-Type", "text/html");
-        }
-#endif
-
-        if (!p)
-        {
-            p = z_get_HTTP_Response(o, 404);
-        }
-    }
-    else if (!strcmp(hreq->method, "POST"))
-    {
-        const char *content_type = z_HTTP_header_lookup(hreq->headers,
-                                                        "Content-Type");
-        if (content_type && !yaz_strcmp_del("text/xml", content_type, "; "))
-        {
-            Z_SOAP *soap_package = 0;
-            int ret = -1;
-            int http_code = 500;
-            const char *charset_p = 0;
-            char *charset = 0;
-
-            static Z_SOAP_Handler soap_handlers[3] = {
+       else
+       {
+           http_code = 500;
+           z_soap_error(assoc->encode, soap_package,
+                        "SOAP-ENV:Client", "Bad method", 0); 
+       }
+       if (http_code == 200 || http_code == 500)
+       {
+           static Z_SOAP_Handler soap_handlers[3] = {
 #if HAVE_XML2
 #if HAVE_XML2
-                {"http://www.loc.gov/zing/srw/", 0,
-                 (Z_SOAP_fun) yaz_srw_codec},
+               {"http://www.loc.gov/zing/srw/", 0,
+                (Z_SOAP_fun) yaz_srw_codec},
                 {"http://www.loc.gov/zing/srw/v1.0/", 0,
                  (Z_SOAP_fun) yaz_srw_codec},
 #endif
                 {"http://www.loc.gov/zing/srw/v1.0/", 0,
                  (Z_SOAP_fun) yaz_srw_codec},
 #endif
-                {0, 0, 0}
-            };
-            if ((charset_p = strstr(content_type, "; charset=")))
-            {
-                int i = 0;
-                charset_p += 10;
-                while (i < 20 && charset_p[i] &&
-                       !strchr("; \n\r", charset_p[i]))
-                    i++;
-                charset = odr_malloc(assoc->encode, i+1);
-                memcpy(charset, charset_p, i);
-                charset[i] = '\0';
-                yaz_log(LOG_LOG, "SOAP encoding %s", charset);
-            }
-            ret = z_soap_codec(assoc->decode, &soap_package, 
-                               &hreq->content_buf, &hreq->content_len,
-                               soap_handlers);
-#if HAVE_XML2
-            if (!ret && soap_package->which == Z_SOAP_generic)
-            {
-                /* SRW package */
-               char *db = "Default";
-               const char *p0 = hreq->path, *p1;
-                Z_SRW_PDU *sr = soap_package->u.generic->p;
-               
-               if (*p0 == '/')
-                   p0++;
-               p1 = strchr(p0, '?');
-               if (!p1)
-                   p1 = p0 + strlen(p0);
-               if (p1 != p0)
-               {
-                   db = (char*) odr_malloc(assoc->decode, p1 - p0 + 1);
-                   memcpy (db, p0, p1 - p0);
-                   db[p1 - p0] = '\0';
-               }
-
-                if (sr->which == Z_SRW_searchRetrieve_request)
-                {
-                    Z_SRW_PDU *res =
-                        yaz_srw_get(assoc->encode,
-                                    Z_SRW_searchRetrieve_response);
-
-                    if (!sr->u.request->database)
-                       sr->u.request->database = db;
-
-                   if (soap_package->u.generic->no == 1)  /* SRW 1.0 */
-                       res->srw_version = 0;
-
-                    srw_bend_search(assoc, req, sr->u.request,
-                                    res->u.response, &http_code);
-                    
-                    soap_package->u.generic->p = res;
-                }
-                else if (sr->which == Z_SRW_explain_request)
-                {
-                    Z_SRW_PDU *res =
-                        yaz_srw_get(assoc->encode, Z_SRW_explain_response);
-                   sr->u.explain_request->database = db;
-
-                   if (soap_package->u.generic->no == 1)  /* SRW 1.0 */
-                       res->srw_version = 0;
-
-                    srw_bend_explain(assoc, req, sr->u.explain_request,
-                                     res->u.explain_response, &http_code);
-                   if (http_code == 200)
-                        soap_package->u.generic->p = res;
-                }
-                else
-                {
-                    z_soap_error(assoc->encode, soap_package,
-                                 "SOAP-ENV:Client", "Bad method", 0); 
-                }
-
-            }
-#endif
-           if (http_code == 200 || http_code == 500)
+               {0, 0, 0}
+           };
+           char ctype[60];
+           int ret;
+           p = z_get_HTTP_Response(o, 200);
+           hres = p->u.HTTP_Response;
+           ret = z_soap_codec_enc(assoc->encode, &soap_package,
+                                  &hres->content_buf, &hres->content_len,
+                                  soap_handlers, charset);
+           hres->code = http_code;
+
+           strcpy(ctype, "text/xml");
+           if (charset)
            {
            {
-               p = z_get_HTTP_Response(o, 200);
-               hres = p->u.HTTP_Response;
-               ret = z_soap_codec_enc(assoc->encode, &soap_package,
-                                      &hres->content_buf, &hres->content_len,
-                                      soap_handlers, charset);
-               hres->code = http_code;
-               if (!charset)
-                   z_HTTP_header_add(o, &hres->headers, "Content-Type", "text/xml");
-               else
-               {
-                   char ctype[60];
-                   strcpy(ctype, "text/xml; charset=");
-                   strcat(ctype, charset);
-                   z_HTTP_header_add(o, &hres->headers, "Content-Type", ctype);
-               }
+               strcat(ctype, "; charset=");
+               strcat(ctype, charset);
            }
            }
-           else
-               p = z_get_HTTP_Response(o, http_code);
-        }
-        if (!p) /* still no response ? */
-            p = z_get_HTTP_Response(o, 500);
+           z_HTTP_header_add(o, &hres->headers, "Content-Type", ctype);
+       }
+       else
+           p = z_get_HTTP_Response(o, http_code);
     }
     else
     }
     else
-    {
-        p = z_get_HTTP_Response(o, 405);
-        hres = p->u.HTTP_Response;
-
-        z_HTTP_header_add(o, &hres->headers, "Allow", "GET, POST");
-    }
+       p = z_get_HTTP_Response(o, 500);
     hres = p->u.HTTP_Response;
     if (!strcmp(hreq->version, "1.0")) 
     {
     hres = p->u.HTTP_Response;
     if (!strcmp(hreq->version, "1.0")) 
     {
@@ -1166,6 +873,7 @@ static void process_http_request(association *assoc, request *req)
     {
         z_HTTP_header_add(o, &hres->headers, "Connection", "close");
         assoc->state = ASSOC_DEAD;
     {
         z_HTTP_header_add(o, &hres->headers, "Connection", "close");
         assoc->state = ASSOC_DEAD;
+       assoc->cs_get_mask = 0;
     }
     else
     {
     }
     else
     {
@@ -1563,7 +1271,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.12 $");
+    version = odr_strdup(assoc->encode, "$Revision: 1.13 $");
     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,
index f33f2de..96a9ac1 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (c) 2002-2003, Index Data.
  * See the file LICENSE for details.
  *
  * Copyright (c) 2002-2003, Index Data.
  * See the file LICENSE for details.
  *
- * $Id: soap.c,v 1.3 2003-12-20 00:51:19 adam Exp $
+ * $Id: soap.c,v 1.4 2004-01-05 09:34:42 adam Exp $
  */
 
 #include <yaz/soap.h>
  */
 
 #include <yaz/soap.h>
 static const char *soap_v1_1 = "http://schemas.xmlsoap.org/soap/envelope/";
 static const char *soap_v1_2 = "http://www.w3.org/2001/06/soap-envelope";
 
 static const char *soap_v1_1 = "http://schemas.xmlsoap.org/soap/envelope/";
 static const char *soap_v1_2 = "http://www.w3.org/2001/06/soap-envelope";
 
-int z_soap_error(ODR o, Z_SOAP *p,
-                 const char *fault_code, const char *fault_string,
-                 const char *details)
-{
-    p->which = Z_SOAP_error;
-    p->u.soap_error = (Z_SOAP_Fault *) 
-        odr_malloc(o, sizeof(*p->u.soap_error));
-    p->u.soap_error->fault_code = odr_strdup(o, fault_code);
-    p->u.soap_error->fault_string = odr_strdup(o, fault_string);
-    if (details)
-        p->u.soap_error->details = odr_strdup(o, details);
-    else
-        p->u.soap_error->details = 0;
-    return -1;
-}
-
 int z_soap_codec_enc(ODR o, Z_SOAP **pp, 
                  char **content_buf, int *content_len,
                  Z_SOAP_Handler *handlers,
 int z_soap_codec_enc(ODR o, Z_SOAP **pp, 
                  char **content_buf, int *content_len,
                  Z_SOAP_Handler *handlers,
@@ -269,3 +253,19 @@ int z_soap_codec(ODR o, Z_SOAP **pp,
     return z_soap_codec_enc(o, pp, content_buf, content_len, handlers, 0);
 }
 
     return z_soap_codec_enc(o, pp, content_buf, content_len, handlers, 0);
 }
 
+int z_soap_error(ODR o, Z_SOAP *p,
+                 const char *fault_code, const char *fault_string,
+                 const char *details)
+{
+    p->which = Z_SOAP_error;
+    p->u.soap_error = (Z_SOAP_Fault *) 
+        odr_malloc(o, sizeof(*p->u.soap_error));
+    p->u.soap_error->fault_code = odr_strdup(o, fault_code);
+    p->u.soap_error->fault_string = odr_strdup(o, fault_string);
+    if (details)
+        p->u.soap_error->details = odr_strdup(o, details);
+    else
+        p->u.soap_error->details = 0;
+    return -1;
+}
+
index 7100dbf..2663d97 100644 (file)
--- a/src/srw.c
+++ b/src/srw.c
@@ -2,7 +2,7 @@
  * Copyright (c) 2002-2003, Index Data.
  * See the file LICENSE for details.
  *
  * Copyright (c) 2002-2003, Index Data.
  * See the file LICENSE for details.
  *
- * $Id: srw.c,v 1.10 2003-12-30 00:29:53 adam Exp $
+ * $Id: srw.c,v 1.11 2004-01-05 09:34:42 adam Exp $
  */
 
 #include <yaz/srw.h>
  */
 
 #include <yaz/srw.h>
@@ -768,354 +768,6 @@ int yaz_srw_codec(ODR o, void * vptr, Z_SRW_PDU **handler_data,
     return 0;
 }
 
     return 0;
 }
 
-Z_SRW_PDU *yaz_srw_get(ODR o, int which)
-{
-    Z_SRW_PDU *sr = odr_malloc(o, sizeof(*o));
-
-    sr->srw_version = odr_strdup(o, "1.1");
-    sr->which = which;
-    switch(which)
-    {
-    case Z_SRW_searchRetrieve_request:
-        sr->u.request = (Z_SRW_searchRetrieveRequest *)
-            odr_malloc(o, sizeof(*sr->u.request));
-        sr->u.request->query_type = Z_SRW_query_type_cql;
-        sr->u.request->query.cql = 0;
-        sr->u.request->sort_type = Z_SRW_sort_type_none;
-        sr->u.request->sort.none = 0;
-        sr->u.request->startRecord = 0;
-        sr->u.request->maximumRecords = 0;
-        sr->u.request->recordSchema = 0;
-        sr->u.request->recordPacking = 0;
-        sr->u.request->recordXPath = 0;
-       sr->u.request->database = 0;
-       sr->u.request->resultSetTTL = 0;
-       sr->u.request->stylesheet = 0;
-        break;
-    case Z_SRW_searchRetrieve_response:
-        sr->u.response = (Z_SRW_searchRetrieveResponse *)
-            odr_malloc(o, sizeof(*sr->u.response));
-        sr->u.response->numberOfRecords = 0;
-        sr->u.response->resultSetId = 0;
-        sr->u.response->resultSetIdleTime = 0;
-        sr->u.response->records = 0;
-        sr->u.response->num_records = 0;
-        sr->u.response->diagnostics = 0;
-        sr->u.response->num_diagnostics = 0;
-        sr->u.response->nextRecordPosition = 0;
-        break;
-    case Z_SRW_explain_request:
-        sr->u.explain_request = (Z_SRW_explainRequest *)
-            odr_malloc(o, sizeof(*sr->u.explain_request));
-        sr->u.explain_request->recordPacking = 0;
-       sr->u.explain_request->database = 0;
-        break;
-    case Z_SRW_explain_response:
-        sr->u.explain_response = (Z_SRW_explainResponse *)
-            odr_malloc(o, sizeof(*sr->u.explain_response));
-       sr->u.explain_response->record.recordData_buf = 0;
-       sr->u.explain_response->record.recordData_len = 0;
-       sr->u.explain_response->record.recordSchema = 0;
-       sr->u.explain_response->record.recordPosition = 0;
-       sr->u.explain_response->record.recordPacking =
-           Z_SRW_recordPacking_string;
-       sr->u.explain_response->diagnostics = 0;
-       sr->u.explain_response->num_diagnostics = 0;
-    }
-    return sr;
-}
-
 #endif
 
 
 #endif
 
 
-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 context set"}, 
-{16, "Illegal or unsupported index"}, 
-{17, "Illegal or unsupported combination of index and context 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, "context set name (prefix) assigned to multiple identifiers"}, 
-/* 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"}, 
-/* Diagnostics Relating to Records */
-{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 */
-{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 */
-{100, "Explain not supported"}, 
-{101, "Explain request type not supported (SOAP vs GET)"}, 
-{102, "Explain record temporarily unavailable"},
-{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;
-}
-
-
-/* bib1:srw */
-static int srw_bib1_map[] = {
-    1, 1,
-    2, 2,
-    3, 11,
-    4, 35,
-    5, 12,
-    6, 38,
-    7, 30,
-    8, 32,
-    9, 29,
-    10, 10,
-    11, 12,
-    11, 23,
-    12, 60,
-    13, 61,
-    13, 62,
-    14, 63,
-    14, 64,
-    14, 65,
-    15, 68,
-    15, 69,
-    16, 70,
-    17, 70,
-    18, 50,
-    19, 55,
-    20, 56, 
-    21, 52,
-    22, 50,
-    23, 1,  /* bad map */
-    24, 63, /* bad map */
-    25, 63, /* bad map */
-    26, 63, /* bad map */
-    27, 51,
-    28, 52,
-    29, 52,
-    30, 51,
-    31, 57,
-    32, 58,
-    33, 59,
-    100, 1, /* bad map */
-    101, 3,
-    102, 3,
-    103, 3,
-    104, 3,
-    105, 3, 
-    106, 66,
-    107, 11,
-    108, 10,
-    108, 13,
-    108, 14,
-    108, 25,
-    108, 26,
-    108, 27,
-    108, 45,
-        
-    109, 1,
-    110, 37,
-    111, 1,
-    112, 58,
-    113, 10,
-    114, 16,
-    115, 16,
-    116, 16,
-    117, 19,
-    118, 22,
-    119, 32,
-    119, 31,
-    120, 28,
-    121, 15,
-    122, 32,
-    123, 22,
-    123, 17,
-    123, 18,
-    124, 24,
-    125, 36,
-    126, 36, 
-    127, 36,
-    128, 51,
-    129, 39,
-    130, 43,
-    131, 40,
-    132, 42,
-    201, 44,
-    201, 33,
-    201, 34,
-    202, 41,
-    203, 43,
-    205, 1,  /* bad map */
-    206, 1,  /* bad map */
-    207, 89,
-    208, 1,  /* bad map */
-    209, 80,
-    210, 80,
-    210, 81,
-    211, 84,
-    212, 85,
-    213, 92,
-    214, 90,
-    215, 91,
-    216, 92,
-    217, 63,
-    218, 1,  /* bad map */
-    219, 1,  /* bad map */
-    220, 1,  /* bad map */
-    221, 1,  /* bad map */
-    222, 1,  /* bad map */
-    223, 1,  /* bad map */
-    224, 1,  /* bad map */
-    225, 1,  /* bad map */
-    226, 1,  /* bad map */
-    227, 66,
-    228, 1,  /* bad map */
-    229, 36,
-    230, 83,
-    231, 89,
-    232, 1,
-    233, 1, /* bad map */
-    234, 1, /* bad map */
-    235, 2,
-    236, 3, 
-    237, 82,
-    238, 67,
-    239, 66,
-    240, 1, /* bad map */
-    241, 1, /* bad map */
-    242, 70,
-    243, 1, /* bad map */
-    244, 66,
-    245, 10,
-    246, 10,
-    247, 10,
-    1001, 1, /* bad map */
-    1002, 1, /* bad map */
-    1003, 1, /* bad map */
-    1004, 1, /* bad map */
-    1005, 1, /* bad map */
-    1006, 1, /* bad map */
-    1007, 100,
-    1008, 1, 
-    1009, 1,
-    1010, 3,
-    1011, 3,
-    1012, 3,
-    1013, 3,
-    1014, 3,
-    1015, 3,
-    1015, 3,
-    1016, 3,
-    1017, 3,
-    1018, 2,
-    1019, 2,
-    1020, 2,
-    1021, 3,
-    1022, 3,
-    1023, 3,
-    1024, 16,
-    1025, 3,
-    1026, 64,
-    1027, 1,
-    1028, 65,
-    1029, 1,
-    1040, 1,
-    /* 1041-1065 */
-    1066, 66,
-    1066, 67,
-    0
-};
-
-int yaz_diag_bib1_to_srw (int code)
-{
-    const int *p = srw_bib1_map;
-    while (*p)
-    {
-        if (code == p[0])
-            return p[1];
-        p += 2;
-    }
-    return 1;
-}
-
-int yaz_diag_srw_to_bib1(int code)
-{
-    const int *p = srw_bib1_map;
-    while (*p)
-    {
-        if (code == p[1])
-            return p[0];
-        p += 2;
-    }
-    return 1;
-}
-
index 998deb9..16425c4 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (c) 2002-2003, Index Data.
  * See the file LICENSE for details.
  *
  * Copyright (c) 2002-2003, Index Data.
  * See the file LICENSE for details.
  *
- * $Id: srwutil.c,v 1.2 2003-12-30 00:29:53 adam Exp $
+ * $Id: srwutil.c,v 1.3 2004-01-05 09:34:42 adam Exp $
  */
 
 #include <yaz/srw.h>
  */
 
 #include <yaz/srw.h>
@@ -72,8 +72,8 @@ void yaz_uri_val_int(const char *path, const char *name, ODR o, int **intp)
         *intp = odr_intdup(o, atoi(v));
 }
 
         *intp = odr_intdup(o, atoi(v));
 }
 
-int yaz_check_for_srw(Z_HTTP_Request *hreq, Z_SRW_PDU **srw_pdu,
-                     char **soap_ns, ODR decode)
+int yaz_srw_decode(Z_HTTP_Request *hreq, Z_SRW_PDU **srw_pdu,
+                  Z_SOAP **soap_package, ODR decode, char **charset)
 {
     if (!strcmp(hreq->method, "POST"))
     {
 {
     if (!strcmp(hreq->method, "POST"))
     {
@@ -83,15 +83,15 @@ int yaz_check_for_srw(Z_HTTP_Request *hreq, Z_SRW_PDU **srw_pdu,
        {
            char *db = "Default";
            const char *p0 = hreq->path, *p1;
        {
            char *db = "Default";
            const char *p0 = hreq->path, *p1;
-           Z_SOAP *soap_package = 0;
             int ret = -1;
             const char *charset_p = 0;
             int ret = -1;
             const char *charset_p = 0;
-            char *charset = 0;
            
            
-            static Z_SOAP_Handler soap_handlers[2] = {
+            static Z_SOAP_Handler soap_handlers[3] = {
 #if HAVE_XML2
                 {"http://www.loc.gov/zing/srw/", 0,
                  (Z_SOAP_fun) yaz_srw_codec},
 #if HAVE_XML2
                 {"http://www.loc.gov/zing/srw/", 0,
                  (Z_SOAP_fun) yaz_srw_codec},
+                {"http://www.loc.gov/zing/srw/v1.0/", 0,
+                 (Z_SOAP_fun) yaz_srw_codec},
 #endif
                 {0, 0, 0}
             };
 #endif
                 {0, 0, 0}
             };
@@ -108,24 +108,23 @@ int yaz_check_for_srw(Z_HTTP_Request *hreq, Z_SRW_PDU **srw_pdu,
                db[p1 - p0] = '\0';
            }
 
                db[p1 - p0] = '\0';
            }
 
-            if ((charset_p = strstr(content_type, "; charset=")))
+            if (charset && (charset_p = strstr(content_type, "; charset=")))
             {
                 int i = 0;
                 charset_p += 10;
                 while (i < 20 && charset_p[i] &&
                        !strchr("; \n\r", charset_p[i]))
                     i++;
             {
                 int i = 0;
                 charset_p += 10;
                 while (i < 20 && charset_p[i] &&
                        !strchr("; \n\r", charset_p[i]))
                     i++;
-                charset = (char*) odr_malloc(decode, i+1);
-                memcpy(charset, charset_p, i);
-                charset[i] = '\0';
+                *charset = (char*) odr_malloc(decode, i+1);
+                memcpy(*charset, charset_p, i);
+                (*charset)[i] = '\0';
             }
             }
-            ret = z_soap_codec(decode, &soap_package, 
+            ret = z_soap_codec(decode, soap_package, 
                                &hreq->content_buf, &hreq->content_len,
                                soap_handlers);
                                &hreq->content_buf, &hreq->content_len,
                                soap_handlers);
-           if (!ret && soap_package->which == Z_SOAP_generic &&
-               soap_package->u.generic->no == 0)
+           if (ret == 0 && (*soap_package)->which == Z_SOAP_generic)
            {
            {
-               *srw_pdu = (Z_SRW_PDU*) soap_package->u.generic->p;
+               *srw_pdu = (Z_SRW_PDU*) (*soap_package)->u.generic->p;
                
                if ((*srw_pdu)->which == Z_SRW_searchRetrieve_request &&
                    (*srw_pdu)->u.request->database == 0)
                
                if ((*srw_pdu)->which == Z_SRW_searchRetrieve_request &&
                    (*srw_pdu)->u.request->database == 0)
@@ -135,7 +134,10 @@ int yaz_check_for_srw(Z_HTTP_Request *hreq, Z_SRW_PDU **srw_pdu,
                    (*srw_pdu)->u.explain_request->database == 0)
                    (*srw_pdu)->u.explain_request->database = db;
 
                    (*srw_pdu)->u.explain_request->database == 0)
                    (*srw_pdu)->u.explain_request->database = db;
 
-               *soap_ns = odr_strdup(decode, soap_package->ns);
+               if ((*srw_pdu)->which == Z_SRW_scan_request &&
+                   (*srw_pdu)->u.scan_request->database == 0)
+                   (*srw_pdu)->u.scan_request->database = db;
+
                return 0;
            }
            return 1;
                return 0;
            }
            return 1;
@@ -144,15 +146,26 @@ int yaz_check_for_srw(Z_HTTP_Request *hreq, Z_SRW_PDU **srw_pdu,
     return 2;
 }
 
     return 2;
 }
 
-int yaz_check_for_sru(Z_HTTP_Request *hreq, Z_SRW_PDU **srw_pdu,
-                     char **soap_ns, ODR decode)
+int yaz_sru_decode(Z_HTTP_Request *hreq, Z_SRW_PDU **srw_pdu,
+                  Z_SOAP **soap_package, ODR decode, char **charset)
 {
 {
+#if HAVE_XML2
+    static Z_SOAP_Handler soap_handlers[2] = {
+       {"http://www.loc.gov/zing/srw/", 0,
+        (Z_SOAP_fun) yaz_srw_codec},
+       {0, 0, 0}
+    };
+#endif
     if (!strcmp(hreq->method, "GET"))
     {
         char *db = "Default";
         const char *p0 = hreq->path, *p1;
        const char *operation = 0;
     if (!strcmp(hreq->method, "GET"))
     {
         char *db = "Default";
         const char *p0 = hreq->path, *p1;
        const char *operation = 0;
+       char *query = 0;
+       char *pQuery = 0;
         
         
+       if (charset)
+           *charset = 0;
         if (*p0 == '/')
             p0++;
         p1 = strchr(p0, '?');
         if (*p0 == '/')
             p0++;
         p1 = strchr(p0, '?');
@@ -165,15 +178,15 @@ int yaz_check_for_sru(Z_HTTP_Request *hreq, Z_SRW_PDU **srw_pdu,
             db[p1 - p0] = '\0';
         }
 #if HAVE_XML2
             db[p1 - p0] = '\0';
         }
 #if HAVE_XML2
-       if (p1)
-           operation = yaz_uri_val(p1, "operation", decode);
+       query = yaz_uri_val(p1, "query", decode);
+       pQuery = yaz_uri_val(p1, "pQuery", decode);
+       operation = yaz_uri_val(p1, "operation", decode);
        if (!operation)
            operation = "explain";
        if (!operation)
            operation = "explain";
-        if (p1 && !strcmp(operation, "searchRetrieve"))
+        if ((operation && !strcmp(operation, "searchRetrieve"))
+           || pQuery || query)
         {
             Z_SRW_PDU *sr = yaz_srw_get(decode, Z_SRW_searchRetrieve_request);
         {
             Z_SRW_PDU *sr = yaz_srw_get(decode, Z_SRW_searchRetrieve_request);
-            char *query = yaz_uri_val(p1, "query", decode);
-            char *pQuery = yaz_uri_val(p1, "pQuery", decode);
             char *sortKeys = yaz_uri_val(p1, "sortKeys", decode);
             
            *srw_pdu = sr;
             char *sortKeys = yaz_uri_val(p1, "sortKeys", decode);
             
            *srw_pdu = sr;
@@ -202,7 +215,19 @@ int yaz_check_for_sru(Z_HTTP_Request *hreq, Z_SRW_PDU **srw_pdu,
                         &sr->u.request->startRecord);
 
             sr->u.request->database = db;
                         &sr->u.request->startRecord);
 
             sr->u.request->database = db;
-           *soap_ns = "SRU";
+
+           (*soap_package) = odr_malloc(decode, sizeof(**soap_package));
+           (*soap_package)->which = Z_SOAP_generic;
+           
+           (*soap_package)->u.generic =
+               odr_malloc(decode, sizeof(*(*soap_package)->u.generic));
+           
+           (*soap_package)->u.generic->p = sr;
+           (*soap_package)->u.generic->ns = soap_handlers[0].ns;
+           (*soap_package)->u.generic->no = 0;
+           
+           (*soap_package)->ns = "SRU";
+
            return 0;
         }
        else if (p1 && !strcmp(operation, "explain"))
            return 0;
         }
        else if (p1 && !strcmp(operation, "explain"))
@@ -215,7 +240,19 @@ int yaz_check_for_sru(Z_HTTP_Request *hreq, Z_SRW_PDU **srw_pdu,
             if (!sr->u.explain_request->recordPacking)
                 sr->u.explain_request->recordPacking = "xml";
            sr->u.explain_request->database = db;
             if (!sr->u.explain_request->recordPacking)
                 sr->u.explain_request->recordPacking = "xml";
            sr->u.explain_request->database = db;
-           *soap_ns = "SRU";
+
+           (*soap_package) = odr_malloc(decode, sizeof(**soap_package));
+           (*soap_package)->which = Z_SOAP_generic;
+           
+           (*soap_package)->u.generic =
+               odr_malloc(decode, sizeof(*(*soap_package)->u.generic));
+           
+           (*soap_package)->u.generic->p = sr;
+           (*soap_package)->u.generic->ns = soap_handlers[0].ns;
+           (*soap_package)->u.generic->no = 0;
+           
+           (*soap_package)->ns = "SRU";
+
            return 0;
        }
 #endif
            return 0;
        }
 #endif
@@ -223,3 +260,353 @@ int yaz_check_for_sru(Z_HTTP_Request *hreq, Z_SRW_PDU **srw_pdu,
     }
     return 2;
 }
     }
     return 2;
 }
+
+Z_SRW_PDU *yaz_srw_get(ODR o, int which)
+{
+    Z_SRW_PDU *sr = odr_malloc(o, sizeof(*o));
+
+    sr->srw_version = odr_strdup(o, "1.1");
+    sr->which = which;
+    switch(which)
+    {
+    case Z_SRW_searchRetrieve_request:
+        sr->u.request = (Z_SRW_searchRetrieveRequest *)
+            odr_malloc(o, sizeof(*sr->u.request));
+        sr->u.request->query_type = Z_SRW_query_type_cql;
+        sr->u.request->query.cql = 0;
+        sr->u.request->sort_type = Z_SRW_sort_type_none;
+        sr->u.request->sort.none = 0;
+        sr->u.request->startRecord = 0;
+        sr->u.request->maximumRecords = 0;
+        sr->u.request->recordSchema = 0;
+        sr->u.request->recordPacking = 0;
+        sr->u.request->recordXPath = 0;
+       sr->u.request->database = 0;
+       sr->u.request->resultSetTTL = 0;
+       sr->u.request->stylesheet = 0;
+        break;
+    case Z_SRW_searchRetrieve_response:
+        sr->u.response = (Z_SRW_searchRetrieveResponse *)
+            odr_malloc(o, sizeof(*sr->u.response));
+        sr->u.response->numberOfRecords = 0;
+        sr->u.response->resultSetId = 0;
+        sr->u.response->resultSetIdleTime = 0;
+        sr->u.response->records = 0;
+        sr->u.response->num_records = 0;
+        sr->u.response->diagnostics = 0;
+        sr->u.response->num_diagnostics = 0;
+        sr->u.response->nextRecordPosition = 0;
+        break;
+    case Z_SRW_explain_request:
+        sr->u.explain_request = (Z_SRW_explainRequest *)
+            odr_malloc(o, sizeof(*sr->u.explain_request));
+        sr->u.explain_request->recordPacking = 0;
+       sr->u.explain_request->database = 0;
+        break;
+    case Z_SRW_explain_response:
+        sr->u.explain_response = (Z_SRW_explainResponse *)
+            odr_malloc(o, sizeof(*sr->u.explain_response));
+       sr->u.explain_response->record.recordData_buf = 0;
+       sr->u.explain_response->record.recordData_len = 0;
+       sr->u.explain_response->record.recordSchema = 0;
+       sr->u.explain_response->record.recordPosition = 0;
+       sr->u.explain_response->record.recordPacking =
+           Z_SRW_recordPacking_string;
+       sr->u.explain_response->diagnostics = 0;
+       sr->u.explain_response->num_diagnostics = 0;
+    }
+    return sr;
+}
+
+
+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 context set"}, 
+{16, "Illegal or unsupported index"}, 
+{17, "Illegal or unsupported combination of index and context 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, "context set name (prefix) assigned to multiple identifiers"}, 
+/* 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"}, 
+/* Diagnostics Relating to Records */
+{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 */
+{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 */
+{100, "Explain not supported"}, 
+{101, "Explain request type not supported (SOAP vs GET)"}, 
+{102, "Explain record temporarily unavailable"},
+{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;
+}
+
+
+/* bib1:srw */
+static int srw_bib1_map[] = {
+    1, 1,
+    2, 2,
+    3, 11,
+    4, 35,
+    5, 12,
+    6, 38,
+    7, 30,
+    8, 32,
+    9, 29,
+    10, 10,
+    11, 12,
+    11, 23,
+    12, 60,
+    13, 61,
+    13, 62,
+    14, 63,
+    14, 64,
+    14, 65,
+    15, 68,
+    15, 69,
+    16, 70,
+    17, 70,
+    18, 50,
+    19, 55,
+    20, 56, 
+    21, 52,
+    22, 50,
+    23, 1,  /* bad map */
+    24, 63, /* bad map */
+    25, 63, /* bad map */
+    26, 63, /* bad map */
+    27, 51,
+    28, 52,
+    29, 52,
+    30, 51,
+    31, 57,
+    32, 58,
+    33, 59,
+    100, 1, /* bad map */
+    101, 3,
+    102, 3,
+    103, 3,
+    104, 3,
+    105, 3, 
+    106, 66,
+    107, 11,
+    108, 10,
+    108, 13,
+    108, 14,
+    108, 25,
+    108, 26,
+    108, 27,
+    108, 45,
+        
+    109, 1,
+    110, 37,
+    111, 1,
+    112, 58,
+    113, 10,
+    114, 16,
+    115, 16,
+    116, 16,
+    117, 19,
+    118, 22,
+    119, 32,
+    119, 31,
+    120, 28,
+    121, 15,
+    122, 32,
+    123, 22,
+    123, 17,
+    123, 18,
+    124, 24,
+    125, 36,
+    126, 36, 
+    127, 36,
+    128, 51,
+    129, 39,
+    130, 43,
+    131, 40,
+    132, 42,
+    201, 44,
+    201, 33,
+    201, 34,
+    202, 41,
+    203, 43,
+    205, 1,  /* bad map */
+    206, 1,  /* bad map */
+    207, 89,
+    208, 1,  /* bad map */
+    209, 80,
+    210, 80,
+    210, 81,
+    211, 84,
+    212, 85,
+    213, 92,
+    214, 90,
+    215, 91,
+    216, 92,
+    217, 63,
+    218, 1,  /* bad map */
+    219, 1,  /* bad map */
+    220, 1,  /* bad map */
+    221, 1,  /* bad map */
+    222, 1,  /* bad map */
+    223, 1,  /* bad map */
+    224, 1,  /* bad map */
+    225, 1,  /* bad map */
+    226, 1,  /* bad map */
+    227, 66,
+    228, 1,  /* bad map */
+    229, 36,
+    230, 83,
+    231, 89,
+    232, 1,
+    233, 1, /* bad map */
+    234, 1, /* bad map */
+    235, 2,
+    236, 3, 
+    237, 82,
+    238, 67,
+    239, 66,
+    240, 1, /* bad map */
+    241, 1, /* bad map */
+    242, 70,
+    243, 1, /* bad map */
+    244, 66,
+    245, 10,
+    246, 10,
+    247, 10,
+    1001, 1, /* bad map */
+    1002, 1, /* bad map */
+    1003, 1, /* bad map */
+    1004, 1, /* bad map */
+    1005, 1, /* bad map */
+    1006, 1, /* bad map */
+    1007, 100,
+    1008, 1, 
+    1009, 1,
+    1010, 3,
+    1011, 3,
+    1012, 3,
+    1013, 3,
+    1014, 3,
+    1015, 3,
+    1015, 3,
+    1016, 3,
+    1017, 3,
+    1018, 2,
+    1019, 2,
+    1020, 2,
+    1021, 3,
+    1022, 3,
+    1023, 3,
+    1024, 16,
+    1025, 3,
+    1026, 64,
+    1027, 1,
+    1028, 65,
+    1029, 1,
+    1040, 1,
+    /* 1041-1065 */
+    1066, 66,
+    1066, 67,
+    0
+};
+
+int yaz_diag_bib1_to_srw (int code)
+{
+    const int *p = srw_bib1_map;
+    while (*p)
+    {
+        if (code == p[0])
+            return p[1];
+        p += 2;
+    }
+    return 1;
+}
+
+int yaz_diag_srw_to_bib1(int code)
+{
+    const int *p = srw_bib1_map;
+    while (*p)
+    {
+        if (code == p[1])
+            return p[0];
+        p += 2;
+    }
+    return 1;
+}
+
index 30c98e3..94e782d 100644 (file)
@@ -1,6 +1,6 @@
-; $Id: yaz.nsi,v 1.31 2003-12-22 14:46:26 adam Exp $
+; $Id: yaz.nsi,v 1.32 2004-01-05 09:34:43 adam Exp $
 
 
-!define VERSION "2.0.8"
+!define VERSION "2.0.9"
 
 Name "YAZ"
 Caption "Index Data YAZ ${VERSION} Setup"
 
 Name "YAZ"
 Caption "Index Data YAZ ${VERSION} Setup"
index 924bd47..d64a2ab 100644 (file)
@@ -54,8 +54,8 @@ END
 //
 
 VS_VERSION_INFO VERSIONINFO
 //
 
 VS_VERSION_INFO VERSIONINFO
- FILEVERSION 2,0,8,1
- PRODUCTVERSION 2,0,8,1
+ FILEVERSION 2,0,9,1
+ PRODUCTVERSION 2,0,9,1
  FILEFLAGSMASK 0x3fL
 #ifdef _DEBUG
  FILEFLAGS 0x1L
  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 "Comments", "Z39.50 C Library\0"
             VALUE "CompanyName", "Index Data\0"
             VALUE "FileDescription", "YAZ Toolkit\0"
-            VALUE "FileVersion", "2, 0, 8, 1\0"
+            VALUE "FileVersion", "2, 0, 9, 1\0"
             VALUE "InternalName", "YAZ\0"
             VALUE "InternalName", "YAZ\0"
-            VALUE "LegalCopyright", "Copyright © 1995-2003 Index Data\0"
+            VALUE "LegalCopyright", "Copyright © 1995-2004 Index Data\0"
             VALUE "LegalTrademarks", "\0"
             VALUE "OriginalFilename", "yaz.rc\0"
             VALUE "PrivateBuild", "\0"
             VALUE "ProductName", "Index Data YAZ Toolkit\0"
             VALUE "LegalTrademarks", "\0"
             VALUE "OriginalFilename", "yaz.rc\0"
             VALUE "PrivateBuild", "\0"
             VALUE "ProductName", "Index Data YAZ Toolkit\0"
-            VALUE "ProductVersion", "2, 0, 8, 1\0"
+            VALUE "ProductVersion", "2, 0, 9, 1\0"
             VALUE "SpecialBuild", "\0"
         END
     END
             VALUE "SpecialBuild", "\0"
         END
     END