Merge branch 'master' of ssh://git.indexdata.com/home/git/pub/yaz
authorAdam Dickmeiss <adam@indexdata.dk>
Fri, 29 Jul 2011 15:59:48 +0000 (17:59 +0200)
committerAdam Dickmeiss <adam@indexdata.dk>
Fri, 29 Jul 2011 15:59:48 +0000 (17:59 +0200)
16 files changed:
NEWS
configure.ac
debian/changelog
debian/rules
include/yaz/stemmer.h
include/yaz/wrbuf.h
src/dumpber.c
src/mutex-p.h
src/prt-ext.c
src/rpn2cql.c
src/stemmer.c
src/tcpip.c
src/wrbuf.c
src/zoom-c.c
util/cql2xcql.c
yaz.spec

diff --git a/NEWS b/NEWS
index 8fec542..4448f3b 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,12 @@
+--- 4.2.6 2011/07/28
+
+zoom: throw diagnostic for invalid value for option "sru". Before a
+bad SRU request was sent.
+
+Adding new utility wrbuf_vp_puts.
+
+Add cclxmlconfig.obj to win/makefile. It was missing completely.
+
 --- 4.2.5 2011/07/21
 
 ZOOM HTTP: use absoluteURI's in proxy mode as required by RFC 2616 (HTTP).
index 7cfba5c..2961291 100644 (file)
@@ -1,7 +1,7 @@
 dnl This file is part of the YAZ toolkit.
 dnl Copyright (C) 1995-2011 Index Data
 AC_PREREQ([2.60])
-AC_INIT([yaz],[4.2.5],[yaz-help@indexdata.dk])
+AC_INIT([yaz],[4.2.6],[yaz-help@indexdata.dk])
 AC_CONFIG_HEADERS(include/config.h)
 AC_CONFIG_SRCDIR([configure.ac])
 AC_CONFIG_AUX_DIR([config])
index 9a731ed..4c07b71 100644 (file)
@@ -1,3 +1,9 @@
+yaz (4.2.6-1indexdata) unstable; urgency=low
+
+  * Upstream.
+
+ -- Adam Dickmeiss <adam@indexdata.dk>  Thu, 28 Jul 2011 14:09:53 +0200
+
 yaz (4.2.5-1indexdata) unstable; urgency=low
 
    * Upstream.
index a108b09..49239e7 100755 (executable)
@@ -98,7 +98,7 @@ binary-arch: build install
        dh_fixperms
 #      dh_perl
 #      dh_python
-       dh_makeshlibs -V 'libyaz4 (>= 4.2.5)'
+       dh_makeshlibs -V 'libyaz4 (>= 4.2.6)'
        dh_installdeb
        dh_shlibdeps  -l debian/libyaz4/usr/lib
        dh_gencontrol
index 56f37fb..d20717e 100644 (file)
  */
 
 /**
- * \file stemming.h
- * \brief Header for the stemming API. Simple wrapper to hide underlying implementation.
+ * \file stemmer.h
+ * \brief Header for the stemming API.
+ *
+ * Simple wrapper to hide underlying implementation.
  */
 
 #ifndef YAZ_STEMMER_H
index 6cde6ee..1296538 100644 (file)
@@ -76,6 +76,12 @@ YAZ_EXPORT void wrbuf_write(WRBUF b, const char *buf, size_t size);
  */
 YAZ_EXPORT void wrbuf_puts(WRBUF b, const char *buf);
 
+/** \brief appends C-string to WRBUF - void pointer variant
+    \param buf C-string
+    \param client_data assumed WRBUF
+*/
+YAZ_EXPORT void wrbuf_vp_puts(const char *buf, void *client_data);
+
 /** \brief writes buffer of certain size to WRBUF and XML encode (as CDATA)
     \param b WRBUF
     \param cp CDATA
index c02ae3b..d249c0d 100644 (file)
@@ -18,7 +18,7 @@
 static int do_dumpBER(FILE *f, const char *buf, int len, int level, int offset)
 {
     int res, ll, zclass, tag, cons, lenlen, taglen;
-    const char *b = buf, *bp = buf;
+    const char *b = buf;
     
     if (!len)
         return 0;
@@ -56,7 +56,6 @@ static int do_dumpBER(FILE *f, const char *buf, int len, int level, int offset)
     b += res;
     taglen = res;
     len -= res;
-    bp = b;
     if ((res = ber_declen((unsigned char*)b, &ll, len)) <= 0)
     {
         fprintf(f, "\n%*sBad length\n", level*4+5, "");
index 21c61b9..97e4f0a 100644 (file)
@@ -1,6 +1,33 @@
 /* This file is part of the YAZ toolkit.
- * Copyright (C) 1995-2011 Index Data
- * See the file LICENSE for details.
+ * Copyright (C) 1995-2011 Index Data.
+ * All rights reserved.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ *       notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above copyright
+ *       notice, this list of conditions and the following disclaimer in the
+ *       documentation and/or other materials provided with the distribution.
+ *     * Neither the name of Index Data nor the names of its contributors
+ *       may be used to endorse or promote products derived from this
+ *       software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**
+ * \file mutex-p.h
+ * \brief Declares internal definitinos of for Mutex functions
  */
 
 struct yaz_mutex {
index aad4cc7..f170994 100644 (file)
@@ -261,18 +261,12 @@ int z_External(ODR o, Z_External **p, int opt, const char *name)
 Z_External *z_ext_record_oid(ODR o, const Odr_oid *oid, const char *buf, int len)
 {
     Z_External *thisext;
-    char oid_str_buf[OID_STR_MAX];
-    const char *oid_str;
-    oid_class oclass;
 
     if (!oid)
         return 0;
     thisext = (Z_External *) odr_malloc(o, sizeof(*thisext));
     thisext->descriptor = 0;
     thisext->indirect_reference = 0;
-
-    oid_str = yaz_oid_to_string_buf(oid, &oclass, oid_str_buf);
-
     thisext->direct_reference = odr_oiddup(o, oid);
 
     if (len < 0) /* Structured data */
@@ -343,18 +337,12 @@ Z_External *z_ext_record_oid_any(ODR o, const Odr_oid *oid,
                                  const char *buf, int len)
 {
     Z_External *thisext;
-    char oid_str_buf[OID_STR_MAX];
-    const char *oid_str;
-    oid_class oclass;
 
     if (!oid)
         return 0;
     thisext = (Z_External *) odr_malloc(o, sizeof(*thisext));
     thisext->descriptor = 0;
     thisext->indirect_reference = 0;
-
-    oid_str = yaz_oid_to_string_buf(oid, &oclass, oid_str_buf);
-
     thisext->direct_reference = odr_oiddup(o, oid);
 
     thisext->which = Z_External_single;
index b1063a1..8dc40f5 100644 (file)
@@ -158,8 +158,7 @@ static int rpn2cql_attr(cql_transform_t ct,
     return 0;
 }
 
-/* Bug 2878: Currently only support left and right truncation. Specific check for this */
-static int checkForTruncation(int flag, Z_AttributeList *attributes)
+static Odr_int lookup_truncation(Z_AttributeList *attributes)
 {
     int j;
     for (j = 0; j < attributes->num_attributes; j++)
@@ -168,27 +167,13 @@ static int checkForTruncation(int flag, Z_AttributeList *attributes)
         if (*ae->attributeType == 5) /* truncation attribute */
         {
             if (ae->which == Z_AttributeValue_numeric)
-            {
-                Odr_int truncation = *(ae->value.numeric);
-                /* This logic only works for Left, right and both. eg. 1,2,3 */
-               if (truncation <= 3)
-                    return ((int) truncation & flag);
-            }
-            /* Complex: Shouldn't happen */
+                return *(ae->value.numeric);
         }
     }
-    /* No truncation or unsupported */
+    /* No truncation specified */
     return 0;
 };
 
-static int checkForLeftTruncation(Z_AttributeList *attributes) {
-       return checkForTruncation(2, attributes);
-}
-
-static int checkForRightTruncation(Z_AttributeList *attributes) {
-       return checkForTruncation(1, attributes);
-};
-
 static int rpn2cql_simple(cql_transform_t ct,
                           void (*pr)(const char *buf, void *client_data),
                           void *client_data,
@@ -232,17 +217,23 @@ static int rpn2cql_simple(cql_transform_t ct,
         {
             size_t i;
             int must_quote = 0;
+            Odr_int trunc = lookup_truncation(apt->attributes);
+
+            if (trunc > 3 && trunc != 100)
+            {
+                cql_transform_set_error(
+                    ct, YAZ_BIB1_UNSUPP_TRUNCATION_ATTRIBUTE, 0);
+                ret = -1;
+            }
             for (i = 0 ; i < lterm; i++)
                 if (sterm[i] == ' ')
                     must_quote = 1;
             if (must_quote)
                 wrbuf_puts(w, "\"");
-            /* Bug 2878: Check and add Truncation */
-                       if (checkForLeftTruncation(apt->attributes))
+            if (trunc == 2 || trunc == 3)
                 wrbuf_puts(w, "*");
             wrbuf_write(w, sterm, lterm);
-            /* Bug 2878: Check and add Truncation */
-                       if (checkForRightTruncation(apt->attributes))
+            if (trunc == 1 || trunc == 3)
                 wrbuf_puts(w, "*");
             if (must_quote)
                 wrbuf_puts(w, "\"");
index 21682a3..059a053 100644 (file)
@@ -1,4 +1,12 @@
-
+/* This file is part of the YAZ toolkit.
+ * Copyright (C) 1995-2011 Index Data
+ * See the file LICENSE for details.
+ */
+
+/** 
+ * \file stemmer.c
+ * \brief Implements stemmer wrapper
+ */
 
 #if HAVE_CONFIG_H
 #include <config.h>
index 8ffa3ab..b9466d6 100644 (file)
@@ -1524,47 +1524,44 @@ void cs_print_session_info(COMSTACK cs)
 void *cs_get_ssl(COMSTACK cs)
 {
 #if HAVE_OPENSSL_SSL_H
-    struct tcpip_state *sp;
-    if (!cs || cs->type != ssl_type)
-        return 0;
-    sp = (struct tcpip_state *) cs->cprivate;
-    return sp->ssl;  
-#else
-    return 0;
+    if (cs && cs->type == ssl_type)
+    {
+        struct tcpip_state *sp = (struct tcpip_state *) cs->cprivate;
+        return sp->ssl;  
+    }
 #endif
+    return 0;
 }
 
 int cs_set_ssl_ctx(COMSTACK cs, void *ctx)
 {
 #if ENABLE_SSL
-    struct tcpip_state *sp;
-    if (!cs || cs->type != ssl_type)
-        return 0;
-    sp = (struct tcpip_state *) cs->cprivate;
+    if (cs && cs->type == ssl_type)
+    {
 #if HAVE_OPENSSL_SSL_H
-    if (sp->ctx_alloc)
-        return 0;
-    sp->ctx = (SSL_CTX *) ctx;
+        struct tcpip_state *sp = (struct tcpip_state *) cs->cprivate;
+        if (sp->ctx_alloc)
+            return 0;
+        sp->ctx = (SSL_CTX *) ctx;
 #endif
-    return 1;
-#else
-    return 0;
+        return 1;
+    }
 #endif
+    return 0;
 }
 
 int cs_set_ssl_certificate_file(COMSTACK cs, const char *fname)
 {
 #if ENABLE_SSL
-    struct tcpip_state *sp;
-    if (!cs || cs->type != ssl_type)
-        return 0;
-    sp = (struct tcpip_state *) cs->cprivate;
-    strncpy(sp->cert_fname, fname, sizeof(sp->cert_fname)-1);
-    sp->cert_fname[sizeof(sp->cert_fname)-1] = '\0';
-    return 1;
-#else
-    return 0;
+    if (cs && cs->type == ssl_type)
+    {
+        struct tcpip_state *sp = (struct tcpip_state *) cs->cprivate;
+        strncpy(sp->cert_fname, fname, sizeof(sp->cert_fname)-1);
+        sp->cert_fname[sizeof(sp->cert_fname)-1] = '\0';
+        return 1;
+    }
 #endif
+    return 0;
 }
 
 int cs_get_peer_certificate_x509(COMSTACK cs, char **buf, int *len)
index 06e49de..67de45e 100644 (file)
@@ -79,6 +79,12 @@ void wrbuf_puts(WRBUF b, const char *buf)
     wrbuf_write(b, buf, strlen(buf));
 }
 
+void wrbuf_vp_puts(const char *buf, void *client_data)
+{
+    WRBUF b = (WRBUF) client_data;
+    wrbuf_puts(b, buf);
+}
+
 void wrbuf_puts_replace_char(WRBUF b, const char *buf, 
                             const char from, const char to)
 {
index 742b956..d2f33da 100644 (file)
@@ -506,8 +506,15 @@ ZOOM_API(void)
         ZOOM_options_get_int(c->options, "preferredMessageSize", 1024*1024);
 
     c->async = ZOOM_options_get_bool(c->options, "async", 0);
+
+    if (c->sru_mode == zoom_sru_error)
+    {
+        ZOOM_set_error(c, ZOOM_ERROR_UNSUPPORTED_PROTOCOL, val);
+        ZOOM_connection_remove_tasks(c);
+        return;
+    }
+
     yaz_log(c->log_details, "%p ZOOM_connection_connect async=%d", c, c->async);
     ZOOM_connection_add_task(c, ZOOM_TASK_CONNECT);
 
     if (!c->async)
index 5c70d7a..31a9e51 100644 (file)
 #include <stdlib.h>
 
 #include <yaz/cql.h>
+#include <yaz/wrbuf.h>
 #include <yaz/options.h>
 
 static void usage(const char *prog)
 {
-    fprintf(stderr, "%s: [-c] [-n iterations] [infile]\n", prog);
+    fprintf(stderr, "%s: [-c] [-n iterations] [-s] [infile]\n", prog);
     exit(1);
 }
 
@@ -28,8 +29,9 @@ int main(int argc, char **argv)
     int convert_to_ccl = 0;
     char *arg;
     char *prog = argv[0];
+    int do_sortkeys = 0;
 
-    while ((ret = options("cn:", argv, argc, &arg)) != -2)
+    while ((ret = options("cn:s", argv, argc, &arg)) != YAZ_OPTIONS_EOF)
     {
         switch (ret)
         {
@@ -42,6 +44,9 @@ int main(int argc, char **argv)
         case 'n':
             iterations = atoi(arg);
             break;
+        case 's':
+            do_sortkeys = 1;
+            break;
         default:
             usage(prog);            
         }
@@ -67,6 +72,17 @@ int main(int argc, char **argv)
         }
         else
             cql_to_xml_stdio(cql_parser_result(cp), stdout);
+        if (do_sortkeys)
+        {
+            WRBUF w = wrbuf_alloc();
+            r = cql_sortby_to_sortkeys(cql_parser_result(cp), 
+                                       wrbuf_vp_puts, w);
+            if (r == 0)
+                printf("sortkeys: %s\n", wrbuf_cstr(w));
+            else
+                fprintf(stderr, "failed to generate sortkeys\n");
+            wrbuf_destroy(w);
+        }
     }
     cql_parser_destroy(cp);
     return 0;
index 3512f16..4a98bd7 100644 (file)
--- a/yaz.spec
+++ b/yaz.spec
@@ -5,7 +5,7 @@
 
 Name: yaz
 Summary: Z39.50 Programs
-Version: 4.2.5
+Version: 4.2.6
 Release: 1indexdata
 
 # determine system