Merge branch 'master' of ssh://git.indexdata.com/home/git/pub/yaz
authorDennis Schafroth <dennis@indexdata.com>
Thu, 7 Apr 2011 11:39:08 +0000 (13:39 +0200)
committerDennis Schafroth <dennis@indexdata.com>
Thu, 7 Apr 2011 11:39:08 +0000 (13:39 +0200)
32 files changed:
NEWS
configure.ac
debian/changelog
debian/rules
doc/yaz-icu-man.xml
include/yaz/odr.h
include/yaz/wrbuf.h
include/yaz/zoom.h
m4
src/facet.c
src/icu_transform.c
src/marcdisp.c
src/opacdisp.c
src/record_render.c
src/seshigh.c
src/spipe.c
src/srw.c
src/statserv.c
src/stemmer.c
src/wrbuf.c
src/zoom-c.c
src/zoom-z3950.c
test/test_file_glob.c
test/test_icu.c
test/test_libstemmer.c
test/test_record_conv.c
test/test_retrieval.c
util/marcdump.c
util/yaz-icu.c
win/makefile
win/yaz.nsi
yaz.spec

diff --git a/NEWS b/NEWS
index c86ab04..db88861 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,23 @@
+--- 4.1.7 2011/03/15
+
+Add -lCrun when linking with ICU on Solaris.
+
+More quicks character set conversions for OPAC records.
+
+--- 4.1.6 2011/03/10
+
+fix problem with record_render: records were converted (character set
+wise) even if no charset was given. Problem introduced in YAZ 4.1.5.
+
+--- 4.1.5 2011/03/08
+
+SRU: add methods for handling DADS SRU-proxy facets.
+
+Separate OPAC record character set for ZOOM_record. yaz_record_render
+allows a character set given as charset=from/opacfrom,to where 'from' is
+the character set of a bibliographic record, 'opacfrom' is character set
+of OPAC record and 'to' is the target character set.
+
 --- 4.1.4 2011/02/21
 
 yaz-client: show may XML format records. Command show followed by 'format'
index e295e4e..441b971 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.1.4],[yaz-help@indexdata.dk])
+AC_INIT([yaz],[4.1.7],[yaz-help@indexdata.dk])
 AC_CONFIG_HEADERS(include/config.h)
 AC_CONFIG_SRCDIR([configure.ac])
 AC_CONFIG_AUX_DIR([config])
index b2025f9..dc2cf57 100644 (file)
@@ -1,3 +1,21 @@
+yaz (4.1.7-1indexdata) unstable; urgency=low
+
+  * Upstream.
+
+ -- Adam Dickmeiss <adam@indexdata.dk>  Tue, 15 Mar 2011 13:59:18 +0100
+
+yaz (4.1.6-1indexdata) unstable; urgency=low
+
+  * Upstream.
+
+ -- Adam Dickmeiss <adam@indexdata.dk>  Thu, 10 Mar 2011 10:25:48 +0100
+
+yaz (4.1.5-1indexdata) unstable; urgency=low
+
+  * Upstream.
+
+ -- Adam Dickmeiss <adam@indexdata.dk>  Tue, 08 Mar 2011 13:53:17 +0100
+
 yaz (4.1.4-1indexdata) unstable; urgency=low
 
   * Upstream.
index 144918f..db5e508 100755 (executable)
@@ -98,7 +98,7 @@ binary-arch: build install
        dh_fixperms
 #      dh_perl
 #      dh_python
-       dh_makeshlibs -V 'libyaz4 (>= 4.1.0)'
+       dh_makeshlibs -V 'libyaz4 (>= 4.1.5)'
        dh_installdeb
        dh_shlibdeps  -l debian/libyaz4/usr/lib
        dh_gencontrol
index 5248b73..7c016bf 100644 (file)
  <refsynopsisdiv>
   <cmdsynopsis>
    <command>yaz-icu</command>
-   <arg choice="opt" rep="repeat">commands</arg>
    <arg>-c <replaceable>config</replaceable></arg>
    <arg>-p <replaceable>opt</replaceable></arg>
    <arg>-s</arg>
    <arg>-x</arg>
+   <arg choice="opt">infile</arg>
   </cmdsynopsis>
  </refsynopsisdiv>
  
    <command>yaz-icu</command> is utility which demonstrates 
    the ICU chain module of yaz. (<filename>yaz/icu.h</filename>).
   </para>
+  <para>
+    The utility can be used in two ways. It may read some text
+    using an XML configuration for configuring ICU and show text analysis.
+    This mode is triggered by option <literal>-c</literal> which specififies
+    the configuration to be used. The input file is read from standard
+    input or from a file if <literal>infile</literal> is specified.
+  </para>
+  <para>
+    The utility may also show ICU information. This is triggered by
+    option <literal>-p</literal>.
+  </para>
  </refsect1>
 
  <refsect1><title>OPTIONS</title>
index f081581..0dd0602 100644 (file)
@@ -211,7 +211,7 @@ YAZ_EXPORT Odr_null *odr_nullval(void);
 
 #define ODR_MASK_SET(mask, num)\
     (((mask)->bits[(num) >> 3] |= 0X80 >> ((num) & 0X07)),\
-    (mask)->top < (num) >> 3 ? ((mask)->top = (num) >> 3) : 0)
+    (void) ((mask)->top < (num) >> 3 ? ((mask)->top = (num) >> 3) : 0))
 
 #define ODR_MASK_CLEAR(mask, num)\
     ((mask)->bits[(num) >> 3] &= ~(0X80 >> ((num) & 0X07)))
index b222216..6cde6ee 100644 (file)
@@ -124,6 +124,19 @@ YAZ_EXPORT void wrbuf_printf(WRBUF b, const char *fmt, ...)
         __attribute__ ((format (printf, 2, 3)))
 #endif
         ;
+
+/** \brief general writer of string using iconv and cdata
+    \param b WRBUF
+    \param cd iconv handle (0 for no conversion)
+    \param buf buffer
+    \param size size of buffer
+    \param cdata non-zero for CDATA; 0 for cdata
+    \returns -1 if invalid sequence was encountered (truncation in effect)
+    \returns 0 if buffer could be converted and written
+*/
+int wrbuf_iconv_write_x(WRBUF b, yaz_iconv_t cd, const char *buf,
+                        size_t size, int cdata);
+
 /** \brief iconv converts buffer and appends to WRBUF
     \param b WRBUF
     \param cd iconv handle
@@ -202,7 +215,7 @@ YAZ_EXPORT int wrbuf_grow(WRBUF b, size_t minsize);
 YAZ_EXPORT const char *wrbuf_cstr(WRBUF b);
 
 #define wrbuf_putc(b, c) \
-    (((b)->pos >= (b)->size ? wrbuf_grow(b, 1) : 0),  \
+    ((void) ((b)->pos >= (b)->size ? wrbuf_grow(b, 1) : 0),  \
     (b)->buf[(b)->pos++] = (c), 0)
 
 YAZ_END_CDECL
index 4b0a4cc..a505e12 100644 (file)
@@ -140,6 +140,9 @@ ZOOM_diag_str (int error);
 #define ZOOM_ERROR_CQL_TRANSFORM 10012
 #define ZOOM_ERROR_CCL_CONFIG 10013
 #define ZOOM_ERROR_CCL_PARSE 10014
+#define ZOOM_ERROR_ES_INVALID_ACTION 10015
+#define ZOOM_ERROR_ES_INVALID_VERSION 10016
+#define ZOOM_ERROR_ES_INVALID_SYNTAX 10017
 
 ZOOM_API(int)
 ZOOM_connection_last_event(ZOOM_connection cs);
diff --git a/m4 b/m4
index f7d7eb4..96ff03f 160000 (submodule)
--- a/m4
+++ b/m4
@@ -1 +1 @@
-Subproject commit f7d7eb4b44b7fdad1942e32856d6afc2e6dcabda
+Subproject commit 96ff03f91b4539e315dadd50ab2564412c076394
index b83972c..e4e787c 100644 (file)
@@ -91,7 +91,6 @@ static void useattr(Z_AttributeElement *ae, struct yaz_facet_attr *av)
     if (ae->which == Z_AttributeValue_complex)
     {
         s = stringattr(ae->value.complex);
-        yaz_log(YLOG_DEBUG, "useattr %s %s", s, av->useattr);
         if (s)
         {
             if (!av->useattr)
@@ -147,7 +146,6 @@ static void limitattr(Z_AttributeElement *ae, struct yaz_facet_attr *av)
     if (ae->which == Z_AttributeValue_numeric)
     {
         av->limit = *ae->value.numeric;
-        yaz_log(YLOG_DEBUG, "limitattr %d ", av->limit);
     }
     else
     {
@@ -171,12 +169,9 @@ void yaz_facet_attr_get_z_attributes(const Z_AttributeList *attributes,
 {
     int i;
     Z_AttributeElement *ae;
-    yaz_log(YLOG_DEBUG, "Attribute num attributes: %d",
-            attributes->num_attributes);
     for (i=0; i < attributes->num_attributes; i++) {
         ae = attributes->attributes[i];
         /* ignoring the attributeSet here */
-        yaz_log(YLOG_DEBUG, "Attribute type %d", (int) *ae->attributeType);
         if (*ae->attributeType == 1)
         { /* use attribute */
             useattr(ae, av);
@@ -195,7 +190,7 @@ void yaz_facet_attr_get_z_attributes(const Z_AttributeList *attributes,
             sprintf(av->useattrbuff, ODR_INT_PRINTF,
                         *ae-> attributeType);
             av->errstring = av->useattrbuff;
-            yaz_log(YLOG_DEBUG, "Unsupported attribute type %s", av->useattrbuff);
+            yaz_log(YLOG_WARN, "Unsupported attribute type %s", av->useattrbuff);
             /* would like to give a better message, but the standard */
             /* tells me to return the attribute type */
         }
index 478efa1..e8d2012 100644 (file)
@@ -60,10 +60,8 @@ struct icu_transform * icu_transform_create(const char *id, char action,
     transform->trans = 0;
 
     if (id)
-    {
         icu_utf16_from_utf8_cstr(id16, id, status);
-        id16->utf16[id16->utf16_len] = 0;
-    }
+
     if (rules)
         icu_utf16_from_utf8_cstr(rules16, rules, status);
 
index 0ef545e..00d1ed8 100644 (file)
@@ -245,13 +245,17 @@ void yaz_marc_add_datafield(yaz_marc_t mt, const char *tag,
     mt->subfield_pp = &n->u.datafield.subfields;
 }
 
-// Magic function: adds a attribute value to the element name if it is plain characters.
-// if not, and if the attribute name is not null, it will append a attribute element with the value
-// if attribute name is null it will return a non-zero value meaning it couldnt handle the value.
-
-int element_name_append_attribute_value(yaz_marc_t mt, WRBUF buffer, const char *attribute_name, char *code_data, size_t code_len)
+/** \brief adds a attribute value to the element name if it is plain chars
+    
+    If not, and if the attribute name is not null, it will append a
+    attribute element with the value if attribute name is null it will
+    return a non-zero value meaning it couldnt handle the value.
+*/
+static int element_name_append_attribute_value(
+    yaz_marc_t mt, WRBUF buffer,
+    const char *attribute_name, char *code_data, size_t code_len)
 {
-    // TODO Map special codes to something possible for XML ELEMENT names
+    /* TODO Map special codes to something possible for XML ELEMENT names */
 
     int encode = 0;
     int index = 0;
@@ -263,7 +267,7 @@ int element_name_append_attribute_value(yaz_marc_t mt, WRBUF buffer, const char
               (code_data[index] >= 'A' && code_data[index] <= 'Z')))
             encode = 1;
     }
-    // Add as attribute
+    /* Add as attribute */
     if (encode && attribute_name)
         wrbuf_printf(buffer, " %s=\"", attribute_name);
 
@@ -273,7 +277,7 @@ int element_name_append_attribute_value(yaz_marc_t mt, WRBUF buffer, const char
         success = -1;
 
     if (encode && attribute_name)
-        wrbuf_printf(buffer, "\"");    // return error if we couldn't handle it.
+        wrbuf_printf(buffer, "\""); /* return error if we couldn't handle it.*/
     return success;
 }
 
@@ -300,7 +304,7 @@ void yaz_marc_add_datafield_xml2(yaz_marc_t mt, char *tag_value, char *indicator
     n->u.datafield.indicator = indicators;
     n->u.datafield.subfields = 0;
 
-    // make subfield_pp the current (last one)
+    /* make subfield_pp the current (last one) */
     mt->subfield_pp = &n->u.datafield.subfields;
 }
 
@@ -718,7 +722,7 @@ static int yaz_marc_write_marcxml_wrbuf(yaz_marc_t mt, WRBUF wr,
                 wrbuf_puts(wr, ">\n");
             }
             wrbuf_printf(wr, "  </%s", datafield_name[turbo]);
-            //TODO Not CDATA
+            /* TODO Not CDATA */
             if (turbo)
                wrbuf_iconv_write_cdata(wr, mt->iconv_cd, n->u.datafield.tag,
                                         strlen(n->u.datafield.tag));
@@ -735,7 +739,7 @@ static int yaz_marc_write_marcxml_wrbuf(yaz_marc_t mt, WRBUF wr,
             }
             else
             {
-                //TODO convert special
+                /* TODO convert special */
                 wrbuf_iconv_write_cdata(wr, mt->iconv_cd, n->u.controlfield.tag,
                                        strlen(n->u.controlfield.tag));
                 wrbuf_iconv_puts(wr, mt->iconv_cd, ">");
@@ -745,7 +749,7 @@ static int yaz_marc_write_marcxml_wrbuf(yaz_marc_t mt, WRBUF wr,
                                     strlen(n->u.controlfield.data));
             marc_iconv_reset(mt, wr);
             wrbuf_printf(wr, "</%s", controlfield_name[turbo]);
-            //TODO convert special
+            /* TODO convert special */
             if (turbo)
                 wrbuf_iconv_write_cdata(wr, mt->iconv_cd, n->u.controlfield.tag,
                                        strlen(n->u.controlfield.tag));
@@ -848,7 +852,7 @@ void add_marc_datafield_turbo_xml(yaz_marc_t mt, struct yaz_marc_node *n,
     struct yaz_marc_subfield *s;
     WRBUF subfield_name = wrbuf_alloc();
 
-    //TODO consider if safe
+    /* TODO consider if safe */
     char field[10];
     field[0] = 'd';
     strncpy(field + 1, n->u.datafield.tag, 3);
@@ -887,7 +891,7 @@ void add_marc_datafield_turbo_xml(yaz_marc_t mt, struct yaz_marc_node *n,
                                        BAD_CAST wrbuf_cstr(wr_cdata));
         if (not_written)
         {
-            // Generate code attribute value and add
+            /* Generate code attribute value and add */
             wrbuf_rewind(wr_cdata);
             wrbuf_iconv_write(wr_cdata, mt->iconv_cd,s->code_data, using_code_len);
             xmlNewProp(ptr_subfield, BAD_CAST "code",  BAD_CAST wrbuf_cstr(wr_cdata));
index 807ca2b..735d969 100644 (file)
 #include <yaz/proto.h>
 #include <yaz/marcdisp.h>
 
-static void opac_element_str(WRBUF wrbuf, yaz_iconv_t cd, 
+static void opac_element_str(WRBUF wrbuf, yaz_iconv_t cd1, yaz_iconv_t cd2,
                              int l, const char *elem,
                              const char *data)
 {
     if (data)
     {
+        size_t pos;
         while (--l >= 0)
             wrbuf_puts(wrbuf, " ");
         wrbuf_puts(wrbuf, "<");
         wrbuf_puts(wrbuf, elem);
         wrbuf_puts(wrbuf, ">");
-        wrbuf_iconv_puts_cdata(wrbuf, cd, data);
+        
+        pos = wrbuf->pos; /* save position */
+        if (wrbuf_iconv_write_x(wrbuf, cd1, data, strlen(data), 1) && cd2)
+        {
+            wrbuf->pos = pos; /* rewind to pos */
+            wrbuf_iconv_write_x(wrbuf, cd2, data, strlen(data), 1);
+        }
         wrbuf_puts(wrbuf, "</");
         wrbuf_puts(wrbuf, elem);
         wrbuf_puts(wrbuf, ">\n");
@@ -53,9 +60,10 @@ static void opac_element_bool(WRBUF wrbuf, int l, const char *elem, int *data)
 }
 
 void yaz_opac_decode_wrbuf2(yaz_marc_t mt, Z_OPACRecord *r, WRBUF wrbuf,
-                            yaz_iconv_t cd)
+                            yaz_iconv_t cd2)
 {
     int i;
+    yaz_iconv_t cd1 = yaz_marc_get_iconv(mt);
 
     wrbuf_puts(wrbuf, "<opacRecord>\n");
     if (r->bibliographicRecord)
@@ -92,35 +100,50 @@ void yaz_opac_decode_wrbuf2(yaz_marc_t mt, Z_OPACRecord *r, WRBUF wrbuf,
             
             Z_HoldingsAndCircData *d = h->u.holdingsAndCirc;
         
-            opac_element_str(wrbuf, cd, 2, "typeOfRecord", d->typeOfRecord);
-            opac_element_str(wrbuf, cd, 2, "encodingLevel", d->encodingLevel);
-            opac_element_str(wrbuf, cd, 2, "format", d->format);
-            opac_element_str(wrbuf, cd, 2, "receiptAcqStatus", d->receiptAcqStatus);
-            opac_element_str(wrbuf, cd, 2, "generalRetention", d->generalRetention);
-            opac_element_str(wrbuf, cd, 2, "completeness", d->completeness);
-            opac_element_str(wrbuf, cd, 2, "dateOfReport", d->dateOfReport);
-            opac_element_str(wrbuf, cd, 2, "nucCode", d->nucCode);
-            opac_element_str(wrbuf, cd, 2, "localLocation", d->localLocation);
-            opac_element_str(wrbuf, cd, 2, "shelvingLocation", d->shelvingLocation);
-            opac_element_str(wrbuf, cd, 2, "callNumber", d->callNumber);
-            opac_element_str(wrbuf, cd, 2, "shelvingData", d->shelvingData);
-            
-            opac_element_str(wrbuf, cd, 2, "copyNumber", d->copyNumber);
-            opac_element_str(wrbuf, cd, 2, "publicNote", d->publicNote);
-            opac_element_str(wrbuf, cd, 2, "reproductionNote", d->reproductionNote);
-            opac_element_str(wrbuf, cd, 2, "termsUseRepro", d->termsUseRepro);
-            opac_element_str(wrbuf, cd, 2, "enumAndChron", d->enumAndChron);
+            opac_element_str(wrbuf, cd1, cd2, 2, "typeOfRecord",
+                             d->typeOfRecord);
+            opac_element_str(wrbuf, cd1, cd2, 2, "encodingLevel",
+                             d->encodingLevel);
+            opac_element_str(wrbuf, cd1, cd2, 2, "format",
+                             d->format);
+            opac_element_str(wrbuf, cd1, cd2, 2, "receiptAcqStatus",
+                             d->receiptAcqStatus);
+            opac_element_str(wrbuf, cd1, cd2, 2, "generalRetention",
+                             d->generalRetention);
+            opac_element_str(wrbuf, cd1, cd2, 2, "completeness",
+                             d->completeness);
+            opac_element_str(wrbuf, cd1, cd2, 2, "dateOfReport",
+                             d->dateOfReport);
+            opac_element_str(wrbuf, cd1, cd2, 2, "nucCode", d->nucCode);
+            opac_element_str(wrbuf, cd1, cd2, 2, "localLocation",
+                             d->localLocation);
+            opac_element_str(wrbuf, cd1, cd2, 2, "shelvingLocation",
+                             d->shelvingLocation);
+            opac_element_str(wrbuf, cd1, cd2, 2, "callNumber",
+                             d->callNumber);
+            opac_element_str(wrbuf, cd1, cd2, 2, "shelvingData",
+                             d->shelvingData);
+            opac_element_str(wrbuf, cd1, cd2, 2, "copyNumber",
+                             d->copyNumber);
+            opac_element_str(wrbuf, cd1, cd2, 2, "publicNote",
+                             d->publicNote);
+            opac_element_str(wrbuf, cd1, cd2, 2, "reproductionNote",
+                             d->reproductionNote);
+            opac_element_str(wrbuf, cd1, cd2, 2, "termsUseRepro",
+                             d->termsUseRepro);
+            opac_element_str(wrbuf, cd1, cd2, 2, "enumAndChron",
+                             d->enumAndChron);
             if (d->num_volumes)
             {
                 wrbuf_puts (wrbuf, "  <volumes>\n");
                 for (j = 0; j<d->num_volumes; j++)
                 {
                     wrbuf_puts (wrbuf, "   <volume>\n");
-                    opac_element_str(wrbuf, cd, 4, "enumeration",
+                    opac_element_str(wrbuf, cd1, cd2, 4, "enumeration",
                                      d->volumes[j]->enumeration);
-                    opac_element_str(wrbuf, cd, 4, "chronology",
+                    opac_element_str(wrbuf, cd1, cd2, 4, "chronology",
                                      d->volumes[j]->chronology);
-                    opac_element_str(wrbuf, cd, 4, "enumAndChron",
+                    opac_element_str(wrbuf, cd1, cd2, 4, "enumAndChron",
                                      d->volumes[j]->enumAndChron);
                     wrbuf_puts(wrbuf, "   </volume>\n");
                 }
@@ -134,23 +157,23 @@ void yaz_opac_decode_wrbuf2(yaz_marc_t mt, Z_OPACRecord *r, WRBUF wrbuf,
                     wrbuf_puts(wrbuf,"   <circulation>\n");
                     opac_element_bool(wrbuf, 4, "availableNow",
                                       d->circulationData[j]->availableNow);
-                    opac_element_str(wrbuf, cd, 4, "availabiltyDate",
+                    opac_element_str(wrbuf, cd1, cd2, 4, "availabiltyDate",
                                      d->circulationData[j]->availablityDate);
-                    opac_element_str(wrbuf, cd, 4, "availableThru",
+                    opac_element_str(wrbuf, cd1, cd2, 4, "availableThru",
                                       d->circulationData[j]->availableThru);
-                    opac_element_str(wrbuf, cd, 4, "restrictions",
+                    opac_element_str(wrbuf, cd1, cd2, 4, "restrictions",
                                       d->circulationData[j]->restrictions);
-                    opac_element_str(wrbuf, cd, 4, "itemId",
+                    opac_element_str(wrbuf, cd1, cd2, 4, "itemId",
                                       d->circulationData[j]->itemId);
                     opac_element_bool(wrbuf, 4, "renewable",
                                       d->circulationData[j]->renewable);
                     opac_element_bool(wrbuf, 4, "onHold",
                                       d->circulationData[j]->onHold);
-                    opac_element_str(wrbuf, cd, 4, "enumAndChron",
+                    opac_element_str(wrbuf, cd1, cd2, 4, "enumAndChron",
                                       d->circulationData[j]->enumAndChron);
-                    opac_element_str(wrbuf, cd, 4, "midspine",
+                    opac_element_str(wrbuf, cd1, cd2, 4, "midspine",
                                       d->circulationData[j]->midspine);
-                    opac_element_str(wrbuf, cd, 4, "temporaryLocation",
+                    opac_element_str(wrbuf, cd1, cd2, 4, "temporaryLocation",
                                       d->circulationData[j]->temporaryLocation);
                     wrbuf_puts(wrbuf, "   </circulation>\n");
                 }
@@ -165,7 +188,7 @@ void yaz_opac_decode_wrbuf2(yaz_marc_t mt, Z_OPACRecord *r, WRBUF wrbuf,
 
 void yaz_opac_decode_wrbuf(yaz_marc_t mt, Z_OPACRecord *r, WRBUF wrbuf)
 {
-    yaz_opac_decode_wrbuf2(mt, r, wrbuf, yaz_marc_get_iconv(mt));
+    yaz_opac_decode_wrbuf2(mt, r, wrbuf, 0);
 }
 
 /*
index 16351a2..ddfd391 100644 (file)
@@ -28,7 +28,7 @@ static yaz_iconv_t iconv_create_charset(const char *record_charset,
     char *from_set1 = 0;
     char *from_set2 = 0;
     char *to_set = 0;
-    if (record_charset)
+    if (record_charset && *record_charset)
     {
         char *cp = charset_buf;
         
index e739d3a..0a3f9fa 100644 (file)
@@ -227,10 +227,6 @@ void destroy_association(association *h)
     request_delq(&h->outgoing);
     xfree(h);
     xmalloc_trav("session closed");
-    if (cb && cb->one_shot)
-    {
-        exit(0);
-    }
 }
 
 static void do_close_req(association *a, int reason, char *message,
index a2ee268..2a3bf14 100644 (file)
@@ -125,7 +125,7 @@ yaz_spipe_t yaz_spipe_create(int port_to_use, WRBUF *err_msg)
 #endif
         fd_set write_set;
 
-        // create server socket
+        /* create server socket */
         p->m_socket = socket(AF_INET, SOCK_STREAM, 0);
         if (p->m_socket == YAZ_INVALID_SOCKET)
         {
@@ -147,7 +147,7 @@ yaz_spipe_t yaz_spipe_create(int port_to_use, WRBUF *err_msg)
             }
         }
 #endif
-        // bind server socket
+        /* bind server socket */
         add.sin_family = AF_INET;
         add.sin_port = htons(port_to_use);
         add.sin_addr.s_addr = INADDR_ANY;
@@ -169,7 +169,7 @@ yaz_spipe_t yaz_spipe_create(int port_to_use, WRBUF *err_msg)
             return 0;
         }
 
-        // client socket
+        /* client socket */
         tmpadd = (unsigned) inet_addr("127.0.0.1");
         if (!tmpadd)
         {
@@ -194,9 +194,9 @@ yaz_spipe_t yaz_spipe_create(int port_to_use, WRBUF *err_msg)
         {
             if (
 #ifdef WIN32
-            WSAGetLastError() != WSAEWOULDBLOCK
+                WSAGetLastError() != WSAEWOULDBLOCK
 #else
-            errno != EINPROGRESS
+                errno != EINPROGRESS
 #endif
                 )
             {
index bd3c577..a037d36 100644 (file)
--- a/src/srw.c
+++ b/src/srw.c
@@ -262,10 +262,9 @@ static int yaz_srw_record(ODR o, xmlNodePtr pptr, Z_SRW_record *rec,
                                      &ex.extraRecordData_buf,
                                      &ex.extraRecordData_len) )
                 ;
-            else if (match_xsd_string(ptr, "recordIdentifier", o, 
-                                      &ex.recordIdentifier))
-                ;
-
+            else
+                match_xsd_string(ptr, "recordIdentifier", o, 
+                                 &ex.recordIdentifier);
         }
         if (data_ptr)
         {
@@ -392,13 +391,12 @@ static int yaz_srw_version(ODR o, xmlNodePtr pptr, Z_SRW_recordVersion *rec,
             if (match_xsd_string(ptr, "versionType", o, 
                                  &rec->versionType))
                 ;
-            else if (match_xsd_string(ptr, "versionValue", o, 
-                                      &rec->versionValue))
-                ;
+            else
+                match_xsd_string(ptr, "versionValue", o, &rec->versionValue);
         }
     }
     else if (o->direction == ODR_ENCODE)
-        {
+    {
         xmlNodePtr ptr = pptr;
         add_xsd_string(ptr, "versionType", rec->versionType);
         add_xsd_string(ptr, "versionValue", rec->versionValue);
@@ -438,7 +436,7 @@ static int yaz_srw_versions(ODR o, xmlNodePtr pptr,
     {
         int i;
         for (i = 0; i < *num; i++)
-            {
+        {
             xmlNodePtr rptr = xmlNewChild(pptr, 0, BAD_CAST "version",
                                           0);
             yaz_srw_version(o, rptr, (*vers)+i, client_data, ns);
@@ -447,8 +445,8 @@ static int yaz_srw_versions(ODR o, xmlNodePtr pptr,
     return 0;
 }
 
-Z_FacetTerm *yaz_sru_proxy_get_facet_term_count(ODR odr, xmlNodePtr node) {
-
+Z_FacetTerm *yaz_sru_proxy_get_facet_term_count(ODR odr, xmlNodePtr node)
+{
     int freq;
     xmlNodePtr child;
     WRBUF wrbuf = wrbuf_alloc();
@@ -461,7 +459,7 @@ Z_FacetTerm *yaz_sru_proxy_get_facet_term_count(ODR odr, xmlNodePtr node) {
 
     for (child = node->children; child ; child = child->next) {
         if (child->type == XML_TEXT_NODE)
-        wrbuf_puts(wrbuf, (const char *) child->content);
+            wrbuf_puts(wrbuf, (const char *) child->content);
     }
     term = term_create(odr, wrbuf_cstr(wrbuf));
     yaz_log(YLOG_DEBUG, "sru-proxy facet: %s %d", wrbuf_cstr(wrbuf), freq);
@@ -469,13 +467,14 @@ Z_FacetTerm *yaz_sru_proxy_get_facet_term_count(ODR odr, xmlNodePtr node) {
     return facet_term_create(odr, term, freq);
 };
 
-static Z_FacetField *yaz_sru_proxy_decode_facet_field(ODR odr, xmlNodePtr ptr) {
+static Z_FacetField *yaz_sru_proxy_decode_facet_field(ODR odr, xmlNodePtr ptr)
+{
     Z_AttributeList *list;
     Z_FacetField *facet_field;
     int num_terms = 0;
     int index = 0;
     xmlNodePtr node;
-    // USE attribute
+    /* USE attribute */
     const char* name = yaz_element_attribute_value_get(ptr, "facet", "code");
     yaz_log(YLOG_DEBUG, "sru-proxy facet type: %s", name);
 
@@ -486,16 +485,19 @@ static Z_FacetField *yaz_sru_proxy_decode_facet_field(ODR odr, xmlNodePtr ptr) {
     }
     facet_field = facet_field_create(odr, list, num_terms);
     index = 0;
-    for (node = ptr->children; node; node = node->next) {
-        if (match_element(node, "facetvalue")) {
+    for (node = ptr->children; node; node = node->next)
+    {
+        if (match_element(node, "facetvalue"))
+        {
             facet_field_term_set(odr, facet_field, yaz_sru_proxy_get_facet_term_count(odr, node), index);
-        index++;
+            index++;
         }
     }
     return facet_field;
 }
 
-static int yaz_sru_proxy_decode_facets(ODR o, xmlNodePtr root, Z_FacetList **facetList)
+static int yaz_sru_proxy_decode_facets(ODR o, xmlNodePtr root,
+                                       Z_FacetList **facetList)
 {
     xmlNodePtr ptr;
 
@@ -538,19 +540,19 @@ static int yaz_srw_decode_diagnostics(ODR o, xmlNodePtr pptr,
     *num = 0;
     for (ptr = pptr; ptr; ptr = ptr->next)
     {
-            if (ptr->type == XML_ELEMENT_NODE &&
-                !xmlStrcmp(ptr->name, BAD_CAST "diagnostic"))
-                (*num)++;
+        if (ptr->type == XML_ELEMENT_NODE &&
+            !xmlStrcmp(ptr->name, BAD_CAST "diagnostic"))
+            (*num)++;
     }
     if (!*num)
         return 1;
     *recs = (Z_SRW_diagnostic *) odr_malloc(o, *num * sizeof(**recs));
     for (i = 0; i < *num; i++)
-        {
-            (*recs)[i].uri = 0;
-            (*recs)[i].details = 0;
-            (*recs)[i].message = 0;
-        } 
+    {
+        (*recs)[i].uri = 0;
+        (*recs)[i].details = 0;
+        (*recs)[i].message = 0;
+    } 
     for (i = 0, ptr = pptr; ptr; ptr = ptr->next)
     {
         if (ptr->type == XML_ELEMENT_NODE &&
@@ -568,9 +570,8 @@ static int yaz_srw_decode_diagnostics(ODR o, xmlNodePtr pptr,
                 else if (match_xsd_string(rptr, "details", o, 
                                           &(*recs)[i].details))
                     ;
-                else if (match_xsd_string(rptr, "message", o, 
-                                          &(*recs)[i].message))
-                    ;
+                else
+                    match_xsd_string(rptr, "message", o, &(*recs)[i].message);
             }
             i++;
         }
@@ -659,14 +660,13 @@ static int yaz_srw_term(ODR o, xmlNodePtr pptr, Z_SRW_scanTerm *term,
             if (match_xsd_string(ptr, "value", o,  &term->value))
                 ;
             else if (match_xsd_integer(ptr, "numberOfRecords", o, 
-                                   &term->numberOfRecords))
+                                       &term->numberOfRecords))
                 ;
             else if (match_xsd_string(ptr, "displayTerm", o, 
                                       &term->displayTerm))
                 ;
-            else if (match_xsd_string(ptr, "whereInList", o, 
-                                      &term->whereInList))
-                ;
+            else
+                match_xsd_string(ptr, "whereInList", o, &term->whereInList);
         }
     }
     else if (o->direction == ODR_ENCODE)
@@ -763,13 +763,13 @@ int yaz_srw_codec(ODR o, void * vptr, Z_SRW_PDU **handler_data,
                                      &(*p)->srw_version))
                     ;
                 else if (match_xsd_string(ptr, "query", o, 
-                                     &req->query.cql))
+                                          &req->query.cql))
                     req->query_type = Z_SRW_query_type_cql;
                 else if (match_xsd_string(ptr, "pQuery", o, 
-                                     &req->query.pqf))
+                                          &req->query.pqf))
                     req->query_type = Z_SRW_query_type_pqf;
                 else if (match_xsd_string(ptr, "xQuery", o, 
-                                     &req->query.xcql))
+                                          &req->query.xcql))
                     req->query_type = Z_SRW_query_type_xcql;
                 else if (match_xsd_integer(ptr, "startRecord", o,
                                            &req->startRecord))
@@ -793,11 +793,10 @@ int yaz_srw_codec(ODR o, void * vptr, Z_SRW_PDU **handler_data,
                                           &req->sort.sortKeys))
                     req->sort_type = Z_SRW_sort_type_sort;
                 else if (match_xsd_string(ptr, "stylesheet", o,
-                                           &req->stylesheet))
-                    ;
-                else if (match_xsd_string(ptr, "database", o,
-                                           &req->database))
+                                          &req->stylesheet))
                     ;
+                else
+                    match_xsd_string(ptr, "database", o, &req->database);
             }
             if (!req->query.cql && !req->query.pqf && !req->query.xcql)
             {
@@ -834,7 +833,7 @@ int yaz_srw_codec(ODR o, void * vptr, Z_SRW_PDU **handler_data,
                                          &(*p)->extraResponseData_len))
                     ;
                 else if (match_xsd_integer(ptr, "numberOfRecords", o, 
-                                      &res->numberOfRecords))
+                                           &res->numberOfRecords))
                     ;
                 else if (match_xsd_string(ptr, "resultSetId", o, 
                                           &res->resultSetId))
@@ -871,7 +870,7 @@ int yaz_srw_codec(ODR o, void * vptr, Z_SRW_PDU **handler_data,
             for (; ptr; ptr = ptr->next)
             {
                 if (match_xsd_string(ptr, "version", o,
-                                           &(*p)->srw_version))
+                                     &(*p)->srw_version))
                     ;
                 else if (match_xsd_XML_n(ptr, "extraResponseData", o, 
                                          &(*p)->extraResponseData_buf,
@@ -881,11 +880,10 @@ int yaz_srw_codec(ODR o, void * vptr, Z_SRW_PDU **handler_data,
                                           &req->stylesheet))
                     ;
                 else if (match_xsd_string(ptr, "recordPacking", o,
-                                     &req->recordPacking))
-                    ;
-                else if (match_xsd_string(ptr, "database", o,
-                                     &req->database))
+                                          &req->recordPacking))
                     ;
+                else
+                    match_xsd_string(ptr, "database", o, &req->database);
             }
         }
         else if (!xmlStrcmp(method->name, BAD_CAST "explainResponse"))
@@ -906,7 +904,7 @@ int yaz_srw_codec(ODR o, void * vptr, Z_SRW_PDU **handler_data,
             for (; ptr; ptr = ptr->next)
             {
                 if (match_xsd_string(ptr, "version", o,
-                                           &(*p)->srw_version))
+                                     &(*p)->srw_version))
                     ;
                 else if (match_xsd_XML_n(ptr, "extraResponseData", o, 
                                          &(*p)->extraResponseData_buf,
@@ -947,7 +945,7 @@ int yaz_srw_codec(ODR o, void * vptr, Z_SRW_PDU **handler_data,
                                          &(*p)->extraResponseData_len))
                     ;
                 else if (match_xsd_string(ptr, "scanClause", o,
-                                     &req->scanClause.cql))
+                                          &req->scanClause.cql))
                     ;
                 else if (match_xsd_string(ptr, "pScanClause", o,
                                           &req->scanClause.pqf))
@@ -963,9 +961,8 @@ int yaz_srw_codec(ODR o, void * vptr, Z_SRW_PDU **handler_data,
                 else if (match_xsd_string(ptr, "stylesheet", o,
                                           &req->stylesheet))
                     ;
-                else if (match_xsd_string(ptr, "database", o,
-                                          &req->database))
-                    ;
+                else
+                    match_xsd_string(ptr, "database", o, &req->database);
             }
         }
         else if (!xmlStrcmp(method->name, BAD_CAST "scanResponse"))
@@ -1246,11 +1243,10 @@ int yaz_ucp_codec(ODR o, void * vptr, Z_SRW_PDU **handler_data,
                                    client_data, ns_ucp_str);
                 }
                 else if (match_xsd_string(ptr, "stylesheet", o,
-                                           &req->stylesheet))
-                    ;
-                else if (match_xsd_string(ptr, "database", o,
-                                           &req->database))
+                                          &req->stylesheet))
                     ;
+                else
+                    match_xsd_string(ptr, "database", o, &req->database);
             }
         }
         else if (!xmlStrcmp(method->name, BAD_CAST "updateResponse"))
@@ -1279,7 +1275,7 @@ int yaz_ucp_codec(ODR o, void * vptr, Z_SRW_PDU **handler_data,
                                      &(*p)->srw_version))
                     ;
                 else if (match_xsd_string(ptr, "operationStatus", o, 
-                                      &res->operationStatus ))
+                                          &res->operationStatus ))
                     ;
                 else if (match_xsd_string(ptr, "recordIdentifier", o, 
                                           &res->recordId))
index ab15c21..7560058 100644 (file)
@@ -610,6 +610,8 @@ static void xml_config_bend_stop(void)
     }
 }
 
+static void remove_listeners(void);
+
 /*
  * handle incoming connect requests.
  * The dynamic mode is a bit tricky mostly because we want to avoid
@@ -909,6 +911,9 @@ static void listener(IOCHAN h, int event)
             return;
         }
 
+        if (control_block.one_shot)
+            remove_listeners();
+
         yaz_log(log_sessiondetail, "Connect from %s", cs_addrstr(new_line));
 
         no_sessions++;
@@ -1129,6 +1134,13 @@ static int add_listener(char *where, int listen_id)
     return 0; /* OK */
 }
 
+static void remove_listeners(void)
+{
+    IOCHAN l = pListener;
+    for (; l; l = l->next)
+        iochan_destroy(l);
+}
+
 #ifndef WIN32
 /* UNIX only (for windows we don't need to catch the signals) */
 static void catchchld(int num)
index cdc1053..7ee2633 100644 (file)
@@ -87,8 +87,12 @@ void yaz_stemmer_stem(yaz_stemmer_p stemmer, struct icu_buf_utf16 *dst, struct i
                     icu_buf_utf16_copy(dst, src);
                 }
                 else {
-                    const char *cstr = (const char *) sb_symbol;
-                    icu_utf16_from_utf8_cstr(dst, cstr , status);
+
+                    const char *cstr2 = (const char *) sb_symbol;
+                    icu_utf16_from_utf8_cstr(dst, cstr2 , status);
+#if 0            
+                   yaz_log(YLOG_DEBUG, "stemming %s to %s ", cstr, cstr2);
+#endif
                 }
             }
             icu_buf_utf8_destroy(utf8_buf);
index fd73beb..06e49de 100644 (file)
@@ -152,9 +152,10 @@ void wrbuf_printf(WRBUF b, const char *fmt, ...)
     va_end(ap);
 }
 
-static void wrbuf_iconv_write_x(WRBUF b, yaz_iconv_t cd, const char *buf,
-                                size_t size, int cdata)
+int wrbuf_iconv_write_x(WRBUF b, yaz_iconv_t cd, const char *buf,
+                        size_t size, int cdata)
 {
+    int ret = 0;
     if (cd)
     {
         char outbuf[128];
@@ -170,7 +171,10 @@ static void wrbuf_iconv_write_x(WRBUF b, yaz_iconv_t cd, const char *buf,
             {
                 int e = yaz_iconv_error(cd);
                 if (e != YAZ_ICONV_E2BIG)
+                {
+                    ret = -1;
                     break;
+                }
             }
             if (cdata)
                 wrbuf_xmlputs_n(b, outbuf, outp - outbuf);
@@ -185,6 +189,7 @@ static void wrbuf_iconv_write_x(WRBUF b, yaz_iconv_t cd, const char *buf,
         else
             wrbuf_write(b, buf, size);
     }
+    return ret;
 }
 
 void wrbuf_iconv_write(WRBUF b, yaz_iconv_t cd, const char *buf, size_t size)
index 005e724..c9a8676 100644 (file)
@@ -557,7 +557,7 @@ ZOOM_API(void)
         cs_close(c->cs);
 
 #if ZOOM_RESULT_LISTS
-    // Remove the connection's usage of resultsets
+    /* Remove the connection's usage of resultsets */
     list = c->resultsets;
     while (list) {
         ZOOM_resultsets removed = list;
@@ -1881,6 +1881,12 @@ ZOOM_API(const char *)
         return "CCL configuration error";
     case ZOOM_ERROR_CCL_PARSE:
         return "CCL parsing error";
+    case ZOOM_ERROR_ES_INVALID_ACTION:
+        return "Extended Service. invalid action";
+    case ZOOM_ERROR_ES_INVALID_VERSION:
+        return "Extended Service. invalid version";
+    case ZOOM_ERROR_ES_INVALID_SYNTAX:
+        return "Extended Service. invalid syntax";
     default:
         return diagbib1_str(error);
     }
index 2598eae..9db6319 100644 (file)
@@ -324,12 +324,15 @@ static Z_APDU *create_update_package(ZOOM_package p)
                                            p->odr_out);
     }
     if (!syntax_oid)
+    { 
+        ZOOM_set_error(p->connection, ZOOM_ERROR_ES_INVALID_SYNTAX, syntax_str);
         return 0;
+    }
 
     if (num_db > 0)
         first_db = db[0];
     
-    switch(*version)
+    switch (*version)
     {
     case '1':
         package_oid = yaz_oid_extserv_database_update_first_version;
@@ -348,6 +351,7 @@ static Z_APDU *create_update_package(ZOOM_package p)
         package_oid = yaz_oid_extserv_database_update;
         break;
     default:
+        ZOOM_set_error(p->connection, ZOOM_ERROR_ES_INVALID_VERSION, version);
         return 0;
     }
     
@@ -362,7 +366,10 @@ static Z_APDU *create_update_package(ZOOM_package p)
     else if (!strcmp(action, "specialUpdate"))
         action_no = Z_IUOriginPartToKeep_specialUpdate;
     else
+    {
+        ZOOM_set_error(p->connection, ZOOM_ERROR_ES_INVALID_ACTION, action);
         return 0;
+    }
 
     apdu = create_es_package(p, package_oid);
     if (apdu)
@@ -984,63 +991,60 @@ static void response_diag(ZOOM_connection c, Z_DiagRec *p)
 }
 
 static int es_response_taskpackage_update(ZOOM_connection c,
-               Z_IUUpdateTaskPackage *utp)
+                                          Z_IUUpdateTaskPackage *utp)
 {
-       if (utp && utp->targetPart)
-       {
-               Z_IUTargetPart *targetPart = utp->targetPart;
-               switch ( *targetPart->updateStatus ) {
-                       case Z_IUTargetPart_success:
-                               ZOOM_options_set(c->tasks->u.package->options,"updateStatus", "success");
-                               break;
-                       case Z_IUTargetPart_partial:
-                               ZOOM_options_set(c->tasks->u.package->options,"updateStatus", "partial");
-                               break;
-                       case Z_IUTargetPart_failure:
-                               ZOOM_options_set(c->tasks->u.package->options,"updateStatus", "failure");
-                               if (targetPart->globalDiagnostics && targetPart->num_globalDiagnostics > 0)
-                                       response_diag(c, targetPart->globalDiagnostics[0]);
-                               break;
-               }
-               // NOTE: Individual record status, surrogate diagnostics, and supplemental diagnostics ARE NOT REPORTED.
-       }
+    if (utp && utp->targetPart)
+    {
+        Z_IUTargetPart *targetPart = utp->targetPart;
+        switch ( *targetPart->updateStatus ) {
+        case Z_IUTargetPart_success:
+            ZOOM_options_set(c->tasks->u.package->options,"updateStatus", "success");
+            break;
+        case Z_IUTargetPart_partial:
+            ZOOM_options_set(c->tasks->u.package->options,"updateStatus", "partial");
+            break;
+        case Z_IUTargetPart_failure:
+            ZOOM_options_set(c->tasks->u.package->options,"updateStatus", "failure");
+            if (targetPart->globalDiagnostics && targetPart->num_globalDiagnostics > 0)
+                response_diag(c, targetPart->globalDiagnostics[0]);
+            break;
+        }
+        /* NOTE: Individual record status, surrogate diagnostics, and supplemental diagnostics ARE NOT REPORTED. */
+    }
     return 1;
 }
 
 static int es_response_taskpackage(ZOOM_connection c,
                                    Z_TaskPackage *taskPackage)
 {
-       // targetReference
-       Odr_oct *id = taskPackage->targetReference;
-       if (id)
-               ZOOM_options_setl(c->tasks->u.package->options,
-                                                       "targetReference", (char*) id->buf, id->len);
-       
-       // taskStatus
-       switch ( *taskPackage->taskStatus ) {
-               case Z_TaskPackage_pending:
-                       ZOOM_options_set(c->tasks->u.package->options,"taskStatus", "pending");
-                       break;
-               case Z_TaskPackage_active:
-                       ZOOM_options_set(c->tasks->u.package->options,"taskStatus", "active");
-                       break;
-               case Z_TaskPackage_complete:
-                       ZOOM_options_set(c->tasks->u.package->options,"taskStatus", "complete");
-                       break;
-               case Z_TaskPackage_aborted:
-                       ZOOM_options_set(c->tasks->u.package->options,"taskStatus", "aborted");
-                       if ( taskPackage->num_packageDiagnostics && taskPackage->packageDiagnostics )
-                               response_diag(c, taskPackage->packageDiagnostics[0]);
-                       break;
-       }
-       
-       // taskSpecificParameters
-       // NOTE: Only Update implemented, no others.
-       if ( taskPackage->taskSpecificParameters->which == Z_External_update ) {
-                       Z_IUUpdateTaskPackage *utp = taskPackage->taskSpecificParameters->u.update->u.taskPackage;
-                       es_response_taskpackage_update(c, utp);
-       }
-       return 1;
+    Odr_oct *id = taskPackage->targetReference;
+    if (id)
+        ZOOM_options_setl(c->tasks->u.package->options,
+                          "targetReference", (char*) id->buf, id->len);
+    
+    switch ( *taskPackage->taskStatus ) {
+    case Z_TaskPackage_pending:
+        ZOOM_options_set(c->tasks->u.package->options,"taskStatus", "pending");
+        break;
+    case Z_TaskPackage_active:
+        ZOOM_options_set(c->tasks->u.package->options,"taskStatus", "active");
+        break;
+    case Z_TaskPackage_complete:
+        ZOOM_options_set(c->tasks->u.package->options,"taskStatus", "complete");
+        break;
+    case Z_TaskPackage_aborted:
+        ZOOM_options_set(c->tasks->u.package->options,"taskStatus", "aborted");
+        if ( taskPackage->num_packageDiagnostics && taskPackage->packageDiagnostics )
+            response_diag(c, taskPackage->packageDiagnostics[0]);
+        break;
+    }
+    /* NOTE: Only Update implemented, no others. */
+    if ( taskPackage->taskSpecificParameters->which == Z_External_update )
+    {
+        Z_IUUpdateTaskPackage *utp = taskPackage->taskSpecificParameters->u.update->u.taskPackage;
+        es_response_taskpackage_update(c, utp);
+    }
+    return 1;
 }
 
 
@@ -1049,18 +1053,19 @@ static int handle_Z3950_es_response(ZOOM_connection c,
 {
     if (!c->tasks || c->tasks->which != ZOOM_TASK_PACKAGE)
         return 0;
-    switch (*res->operationStatus) {
-        case Z_ExtendedServicesResponse_done:
-            ZOOM_options_set(c->tasks->u.package->options,"operationStatus", "done");
-            break;
-        case Z_ExtendedServicesResponse_accepted:
-            ZOOM_options_set(c->tasks->u.package->options,"operationStatus", "accepted");
-            break;
-        case Z_ExtendedServicesResponse_failure:
-            ZOOM_options_set(c->tasks->u.package->options,"operationStatus", "failure");
-            if (res->diagnostics && res->num_diagnostics > 0)
-                response_diag(c, res->diagnostics[0]);
-            break;
+    switch (*res->operationStatus)
+    {
+    case Z_ExtendedServicesResponse_done:
+        ZOOM_options_set(c->tasks->u.package->options,"operationStatus", "done");
+        break;
+    case Z_ExtendedServicesResponse_accepted:
+        ZOOM_options_set(c->tasks->u.package->options,"operationStatus", "accepted");
+        break;
+    case Z_ExtendedServicesResponse_failure:
+        ZOOM_options_set(c->tasks->u.package->options,"operationStatus", "failure");
+        if (res->diagnostics && res->num_diagnostics > 0)
+            response_diag(c, res->diagnostics[0]);
+        break;
     }
     if (res->taskPackage &&
         res->taskPackage->which == Z_External_extendedService)
index 029382b..6812e38 100644 (file)
@@ -33,7 +33,7 @@ void tst_with_path(const char *tpath)
     yaz_file_globfree(&glob_res);
 }
 
-static check_file(const char *got, const char *expect)
+static int check_file(const char *got, const char *expect)
 {
     const char *f = got;
     size_t l_match = strlen(expect);
index 1c04fb0..692e82f 100644 (file)
@@ -21,6 +21,7 @@
 
 #if YAZ_HAVE_ICU
 #include <yaz/icu_I18N.h>
+#include <unicode/uclean.h>
 
 #if YAZ_POSIX_THREADS
 #include <pthread.h>
@@ -645,7 +646,7 @@ static void check_icu_iter1(void)
     if (!xml_node)
         return ;
 
-    chain = icu_chain_xml_config(xml_node, 0, &status);
+    chain = icu_chain_xml_config(xml_node, 1, &status);
 
     xmlFreeDoc(doc);
     YAZ_CHECK(chain);
@@ -667,7 +668,7 @@ static int test_iter(struct icu_chain *chain, const char *input,
                      const char *expected)
 {
     yaz_icu_iter_t iter = icu_iter_create(chain);
-    WRBUF result, second;
+    WRBUF result, second, sort_result;
     int success = 1;
 
     if (!iter)
@@ -682,15 +683,27 @@ static int test_iter(struct icu_chain *chain, const char *input,
         return 0;
     }
 
+    sort_result = wrbuf_alloc();
     result = wrbuf_alloc();
     icu_iter_first(iter, input);
     while (icu_iter_next(iter))
     {
+        const char *sort_str = icu_iter_get_sortkey(iter);
+        if (sort_str)
+        {
+            wrbuf_puts(sort_result, "[");
+            wrbuf_puts_escaped(sort_result, sort_str);
+            wrbuf_puts(sort_result, "]");
+        }
+        else
+        {
+            wrbuf_puts(sort_result, "[NULL]");
+        }
         wrbuf_puts(result, "[");
         wrbuf_puts(result, icu_iter_get_norm(iter));
         wrbuf_puts(result, "]");
     }
-
+    yaz_log(YLOG_LOG, "sortkey=%s", wrbuf_cstr(sort_result));
     second = wrbuf_alloc();
     icu_iter_first(iter, input);
     while (icu_iter_next(iter))
@@ -718,6 +731,7 @@ static int test_iter(struct icu_chain *chain, const char *input,
 
     wrbuf_destroy(result);
     wrbuf_destroy(second);
+    wrbuf_destroy(sort_result);
     return success;
 }
 
@@ -726,7 +740,7 @@ static void *iter_thread(void *p)
     struct icu_chain *chain = (struct icu_chain *) p;
     int i;
     
-    for (i = 0; i < 10000; i++)
+    for (i = 0; i < 1000; i++)
     {
         YAZ_CHECK(test_iter(chain, "Adobe Acrobat Reader, 1991-1999.",
                             "[adobe][acrobat][reader][1991][][1999][]"));
@@ -749,6 +763,7 @@ static void check_iter_threads(struct icu_chain *chain)
         pthread_join(t[i], 0);
 #endif
 }
+
 static void check_icu_iter2(void)
 {
     UErrorCode status = U_ZERO_ERROR;
@@ -773,7 +788,7 @@ static void check_icu_iter2(void)
     if (!xml_node)
         return ;
 
-    chain = icu_chain_xml_config(xml_node, 0, &status);
+    chain = icu_chain_xml_config(xml_node, 1, &status);
 
     xmlFreeDoc(doc);
     YAZ_CHECK(chain);
@@ -783,11 +798,54 @@ static void check_icu_iter2(void)
     YAZ_CHECK(test_iter(chain, "Adobe Acrobat Reader, 1991-1999.",
                         "[adobe][acrobat][reader][1991][][1999][]"));
 
+    YAZ_CHECK(test_iter(chain, "Νόταρης, Γιάννης Σωτ",
+                        "[νόταρης][γιάννης][σωτ]"));
+
     check_iter_threads(chain);
 
     icu_chain_destroy(chain);
 }
 
+static void check_icu_iter3(void)
+{
+    UErrorCode status = U_ZERO_ERROR;
+    struct icu_chain * chain = 0;
+    xmlNode *xml_node;
+
+    const char * xml_str = 
+        "<icu_chain id=\"sort\" locale=\"el\">\n"
+        "<transform rule=\"[:Control:] Any-Remove\"/>\n"
+        "<transform rule=\"[[:Control:][:WhiteSpace:][:Punctuation:]] Remove\"/>\n"
+        "<transform rule=\"NFD; [:Nonspacing Mark:] Remove; NFC\"/>\n"
+        "<casemap rule=\"l\"/>\n"
+        "<display/>\n"
+        "</icu_chain>\n";
+
+    xmlDoc *doc = xmlParseMemory(xml_str, strlen(xml_str));
+    YAZ_CHECK(doc);
+    if (!doc)
+        return;
+    xml_node = xmlDocGetRootElement(doc);
+    YAZ_CHECK(xml_node);
+    if (!xml_node)
+        return ;
+
+    chain = icu_chain_xml_config(xml_node, 1, &status);
+
+    xmlFreeDoc(doc);
+    YAZ_CHECK(chain);
+    if (!chain)
+        return;
+    
+    YAZ_CHECK(test_iter(chain, "Adobe Acrobat Reader, 1991-1999.",
+                        "[adobeacrobatreader19911999]"));
+
+    YAZ_CHECK(test_iter(chain, "Νόταρης, Γιάννης Σωτ",
+                        "[νοταρηςγιαννηςσωτ]"));
+
+    icu_chain_destroy(chain);
+}
+
 #endif /* YAZ_HAVE_ICU */
 
 int main(int argc, char **argv)
@@ -804,11 +862,13 @@ int main(int argc, char **argv)
     check_icu_chain();
     check_chain_empty_token();
     check_chain_empty_chain();
-    check_icu_iter1();
+    check_icu_iter1();  
     check_icu_iter2();
-    
+    check_icu_iter3();
+  
     check_bug_1140();
 
+    u_cleanup();
 #else /* YAZ_HAVE_ICU */
 
     yaz_log(YLOG_LOG, "ICU unit tests omitted");
index a2ea678..3c18e04 100644 (file)
@@ -8,6 +8,7 @@
 
 #include <stdlib.h>
 #include <stdio.h>
+#include <string.h>
 
 #include <yaz/test.h>
 
index 2612f0e..9978fda 100644 (file)
@@ -2,16 +2,16 @@
  * Copyright (C) 1995-2011 Index Data
  * See the file LICENSE for details.
  */
+#if HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include <yaz/record_conv.h>
 #include <yaz/test.h>
 #include <yaz/wrbuf.h>
 #include <string.h>
 #include <yaz/log.h>
 
-#if HAVE_CONFIG_H
-#include <config.h>
-#endif
-
 #if YAZ_HAVE_XML2
 
 #include <libxml/parser.h>
index 6983739..c35cbc9 100644 (file)
@@ -2,16 +2,16 @@
  * Copyright (C) 1995-2011 Index Data
  * See the file LICENSE for details.
  */
+#if HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include <yaz/retrieval.h>
 #include <yaz/test.h>
 #include <yaz/wrbuf.h>
 #include <string.h>
 #include <yaz/log.h>
 
-#if HAVE_CONFIG_H
-#include <config.h>
-#endif
-
 #if YAZ_HAVE_XSLT
 
 #include <libxml/parser.h>
index 041a7df..b963320 100644 (file)
@@ -58,10 +58,10 @@ static char *prog;
 
 static void usage(const char *prog)
 {
-    fprintf (stderr, "Usage: %s [-i format] [-o format] [-f from] [-t to] "
-             "[-l pos=value] [-c cfile] [-s prefix] [-C size] [-n] "
-             "[-p] [-v] [-V] file...\n",
-             prog);
+    fprintf(stderr, "Usage: %s [-i format] [-o format] [-f from] [-t to] "
+            "[-l pos=value] [-c cfile] [-s prefix] [-C size] [-n] "
+            "[-p] [-v] [-V] file...\n",
+            prog);
 } 
 
 static void show_version(void)
@@ -99,8 +99,8 @@ static void marcdump_read_line(yaz_marc_t mt, const char *fname)
     FILE *inf = fopen(fname, "rb");
     if (!inf)
     {
-        fprintf (stderr, "%s: cannot open %s:%s\n",
-                 prog, fname, strerror (errno));
+        fprintf(stderr, "%s: cannot open %s:%s\n",
+                prog, fname, strerror(errno));
         exit(1);
     }
     
@@ -241,12 +241,12 @@ static void dump(const char *fname, const char *from, const char *to,
         int split_file_no = -1;
         if (!inf)
         {
-            fprintf (stderr, "%s: cannot open %s:%s\n",
-                     prog, fname, strerror (errno));
+            fprintf(stderr, "%s: cannot open %s:%s\n",
+                    prog, fname, strerror(errno));
             exit(1);
         }
         if (cfile)
-            fprintf (cfile, "char *marc_records[] = {\n");
+            fprintf(cfile, "char *marc_records[] = {\n");
         for(;; marc_no++)
         {
             const char *result = 0;
@@ -256,12 +256,12 @@ static void dump(const char *fname, const char *from, const char *to,
             size_t r;
             char buf[100001];
             
-            r = fread (buf, 1, 5, inf);
+            r = fread(buf, 1, 5, inf);
             if (r < 5)
             {
                 if (r && print_offset && verbose)
-                    printf ("<!-- Extra %ld bytes at end of file -->\n",
-                            (long) r);
+                    printf("<!-- Extra %ld bytes at end of file -->\n",
+                           (long) r);
                 break;
             }
             while (*buf < '0' || *buf > '9')
@@ -282,14 +282,14 @@ static void dump(const char *fname, const char *from, const char *to,
             if (r < 1)
             {
                 if (verbose || print_offset)
-                    printf ("<!-- End of file with data -->\n");
+                    printf("<!-- End of file with data -->\n");
                 break;
             }
             if (print_offset)
             {
                 long off = ftell(inf) - 5;
-                printf ("<!-- Record %d offset %ld (0x%lx) -->\n",
-                        num, off, off);
+                printf("<!-- Record %d offset %ld (0x%lx) -->\n",
+                       num, off, off);
             }
             len = atoi_n(buf, 5);
             if (len < 25 || len > 100000)
@@ -300,14 +300,14 @@ static void dump(const char *fname, const char *from, const char *to,
                 break;
             }
             rlen = len - 5;
-            r = fread (buf + 5, 1, rlen, inf);
+            r = fread(buf + 5, 1, rlen, inf);
             if (r < rlen)
                 break;
             while (buf[len-1] != ISO2709_RS)
             {
                 if (len > sizeof(buf)-2)
                     break;
-                r = fread (buf + len, 1, 1, inf);
+                r = fread(buf + len, 1, 1, inf);
                 if (r != 1)
                     break;
                 len++;
@@ -357,26 +357,26 @@ static void dump(const char *fname, const char *from, const char *to,
                 char *p = buf;
                 size_t i;
                 if (marc_no)
-                    fprintf (cfile, ",");
-                fprintf (cfile, "\n");
+                    fprintf(cfile, ",");
+                fprintf(cfile, "\n");
                 for (i = 0; i < r; i++)
                 {
                     if ((i & 15) == 0)
-                        fprintf (cfile, "  \"");
-                    fprintf (cfile, "\\x%02X", p[i] & 255);
+                        fprintf(cfile, "  \"");
+                    fprintf(cfile, "\\x%02X", p[i] & 255);
                     
                     if (i < r - 1 && (i & 15) == 15)
-                        fprintf (cfile, "\"\n");
+                        fprintf(cfile, "\"\n");
                     
                 }
-                fprintf (cfile, "\"\n");
+                fprintf(cfile, "\"\n");
             }
             num++;
             if (verbose)
                 printf("\n");
         }
         if (cfile)
-            fprintf (cfile, "};\n");
+            fprintf(cfile, "};\n");
         fclose(inf);
     }
     {
@@ -470,7 +470,7 @@ int main (int argc, char **argv)
             break;
         case 'c':
             if (cfile)
-                fclose (cfile);
+                fclose(cfile);
             cfile = fopen(arg, "w");
             break;
         case 'x':
@@ -528,13 +528,13 @@ int main (int argc, char **argv)
         }
     }
     if (cfile)
-        fclose (cfile);
+        fclose(cfile);
     if (!no)
     {
         usage(prog);
-        exit (1);
+        exit(1);
     }
-    exit (0);
+    exit(0);
 }
 /*
  * Local variables:
index 25e4de0..2833109 100644 (file)
@@ -11,6 +11,7 @@
 
 #include <stdio.h>
 #include <stdlib.h>
+#include <errno.h>
 
 #include <yaz/options.h>
 
 #include <unicode/ucol.h> 
 #include <unicode/ubrk.h>
 #include <unicode/utrans.h>
+#include <unicode/uclean.h>
 
 #include <yaz/icu.h>
 #include <yaz/wrbuf.h>
 
 /* commando line and config parameters */
-static struct config_t { 
+struct config_t { 
     char conffile[1024];
     char print[1024];
     int xmloutput;
@@ -34,18 +36,16 @@ static struct config_t {
     yaz_icu_chain_t chain;
     FILE * infile;
     FILE * outfile;
-} config;
-
-
+};
   
 void print_option_error(const struct config_t *p_config)
 {  
-    fprintf(stderr, "Calling error, valid options are :\n");
-    fprintf(stderr, "yaz-icu\n"
-            "   [-c (path/to/config/file.xml)]\n"
-            "   [-p (a|c|l|t)] print ICU info \n"
-            "   [-s] Show sort normalization key\n"
-            "   [-x] XML output\n"
+    fprintf(stderr, "yaz-icu [options] [infile]\n"
+            "Options:\n"
+            "   -c file         XML configuration\n"
+            "   -p a|c|l|t      Print ICU info \n"
+            "   -s              Show sort normalization key\n"
+            "   -x              XML output instread of text\n"
             "\n"
             "Examples:\n"
             "cat hugetextfile.txt | ./yaz-icu -c config.xml \n"
@@ -75,7 +75,7 @@ void read_params(int argc, char **argv, struct config_t *p_config)
     p_config->xmloutput = 0;
     p_config->sortoutput = 0;
     p_config->chain = 0;
-    p_config->infile = stdin;
+    p_config->infile = 0;
     p_config->outfile = stdout;
     
     /* set up command line parameters */
@@ -96,38 +96,32 @@ void read_params(int argc, char **argv, struct config_t *p_config)
         case 'x':
             p_config->xmloutput = 1;
             break;
+        case 0:
+            if (p_config->infile)
+            {
+                fprintf(stderr, "yaz-icu: only one input file may be given\n");
+                print_option_error(p_config);
+            }
+            p_config->infile = fopen(arg, "r");
+            if (!p_config->infile)
+            {
+                fprintf(stderr, "yaz-icu: cannot open %s : %s\n",
+                        arg, strerror(errno));
+                exit(1);
+            }
+            break;
         default:
-            printf("Got %d\n", ret);
+            fprintf(stderr, "yaz_icu: invalid option: %s\n", arg);
             print_option_error(p_config);
         }
     }
-    
-    if ((!strlen(p_config->conffile)
-         && !strlen(p_config->print))
-        || !config.infile
-        || !config.outfile)
-        
-        print_option_error(p_config);
-}
-
-
-/*     UConverter *conv; */
-/*     conv = ucnv_open("utf-8", &status); */
-/*     assert(U_SUCCESS(status)); */
-
-/*     *ustr16_len  */
-/*       = ucnv_toUChars(conv, ustr16, 1024,  */
-/*                       (const char *) *xstr8, strlen((const char *) *xstr8), */
-/*                       &status); */
-  
 
+    if (p_config->infile == 0)
+        p_config->infile = stdin;
 
-/*      ucnv_fromUChars(conv, */
-/*                      (char *) *xstr8, strlen((const char *) *xstr8), */
-/*                      ustr16, *ustr16_len, */
-/*                      &status); */
-/*      ucnv_close(conv); */
-
+    if (!strlen(p_config->conffile) && !strlen(p_config->print))
+        print_option_error(p_config);
+}
 
 static void print_icu_converters(const struct config_t *p_config)
 {
@@ -136,28 +130,28 @@ static void print_icu_converters(const struct config_t *p_config)
 
     count = ucnv_countAvailable();
     if (p_config->xmloutput)
-        fprintf(config.outfile, "<converters count=\"%d\" default=\"%s\">\n",
+        fprintf(p_config->outfile, "<converters count=\"%d\" default=\"%s\">\n",
                 count, ucnv_getDefaultName());
     else
     {    
-        fprintf(config.outfile, "Available ICU converters: %d\n", count);
-        fprintf(config.outfile, "Default ICU Converter is: '%s'\n", 
+        fprintf(p_config->outfile, "Available ICU converters: %d\n", count);
+        fprintf(p_config->outfile, "Default ICU Converter is: '%s'\n", 
                 ucnv_getDefaultName());
     }
     
     for (i = 0; i < count; i++)
     {
         if (p_config->xmloutput)
-            fprintf(config.outfile, "<converter id=\"%s\"/>\n", 
+            fprintf(p_config->outfile, "<converter id=\"%s\"/>\n", 
                     ucnv_getAvailableName(i));
         else     
-            fprintf(config.outfile, "%s\n", ucnv_getAvailableName(i));
+            fprintf(p_config->outfile, "%s\n", ucnv_getAvailableName(i));
     }
     
     if (p_config->xmloutput)
-        fprintf(config.outfile, "</converters>\n");
+        fprintf(p_config->outfile, "</converters>\n");
     else
-        fprintf(config.outfile, "\n");
+        fprintf(p_config->outfile, "\n");
 }
 
 static void print_icu_transliterators(const struct config_t *p_config)
@@ -169,23 +163,23 @@ static void print_icu_transliterators(const struct config_t *p_config)
     int32_t length;
 
     if (p_config->xmloutput)
-        fprintf(config.outfile, "<transliterators count=\"%d\">\n",  count);
+        fprintf(p_config->outfile, "<transliterators count=\"%d\">\n",  count);
     else 
-        fprintf(config.outfile, "Available ICU transliterators: %d\n", count);
+        fprintf(p_config->outfile, "Available ICU transliterators: %d\n", count);
 
     while ((name = uenum_next(en, &length, &status)))
     {
         if (p_config->xmloutput)
-            fprintf(config.outfile, "<transliterator id=\"%s\"/>\n", name);
+            fprintf(p_config->outfile, "<transliterator id=\"%s\"/>\n", name);
         else
-            fprintf(config.outfile, "%s\n", name);
+            fprintf(p_config->outfile, "%s\n", name);
     }
     uenum_close(en);
     if (p_config->xmloutput)
-        fprintf(config.outfile, "</transliterators>\n");
+        fprintf(p_config->outfile, "</transliterators>\n");
     else
     {
-        fprintf(config.outfile, "\n\nUnicode Set Patterns:\n"
+        fprintf(p_config->outfile, "\n\nUnicode Set Patterns:\n"
                 "   Pattern         Description\n"
                 "   Ranges          [a-z]      The lower case letters a through z\n"
                 "   Named Chars     [abc123] The six characters a,b,c,1,2 and 3\n"
@@ -227,7 +221,7 @@ static void print_icu_transliterators(const struct config_t *p_config)
             );
         
         
-        fprintf(config.outfile, "\n\n");
+        fprintf(p_config->outfile, "\n\n");
         
     }
 }
@@ -277,13 +271,13 @@ static void print_icu_xml_locales(const struct config_t *p_config)
 
     if (p_config->xmloutput)
     {
-        fprintf(config.outfile, "<locales count=\"%d\" default=\"%s\" collations=\"%d\">\n", 
+        fprintf(p_config->outfile, "<locales count=\"%d\" default=\"%s\" collations=\"%d\">\n", 
                 count, uloc_getDefault(), ucol_countAvailable());
     }
     else
     {
-        fprintf(config.outfile, "Available ICU locales: %d\n", count);
-        fprintf(config.outfile, "Default locale is: %s\n",  uloc_getDefault());
+        fprintf(p_config->outfile, "Available ICU locales: %d\n", count);
+        fprintf(p_config->outfile, "Default locale is: %s\n",  uloc_getDefault());
     }
   
     for (i = 0; i < count; i++) 
@@ -357,47 +351,42 @@ static void print_icu_xml_locales(const struct config_t *p_config)
 
         if (p_config->xmloutput)
         {
-            fprintf(config.outfile, "<locale id=\"%s\"", uloc_getAvailable(i)); 
-            /* fprintf(config.outfile, " locale=\"%s\"", uloc_getAvailable(i)); */
-            /* if (strlen(keyword_str)) */
-            /*   fprintf(config.outfile, " keyword=\"%s\"", keyword_str); */
-            /* if (ucol_getAvailable(i)) */
-            /*   fprintf(config.outfile, " collation=\"1\""); */
+            fprintf(p_config->outfile, "<locale id=\"%s\"", uloc_getAvailable(i)); 
             if (strlen(lang_str))
-                fprintf(config.outfile, " language=\"%s\"", lang_str);
+                fprintf(p_config->outfile, " language=\"%s\"", lang_str);
             if (strlen(script_str))
-                fprintf(config.outfile, " script=\"%s\"", script_str);
+                fprintf(p_config->outfile, " script=\"%s\"", script_str);
             if (strlen(location_str))
-                fprintf(config.outfile, " location=\"%s\"", location_str);
+                fprintf(p_config->outfile, " location=\"%s\"", location_str);
             if (strlen(variant_str))
-                fprintf(config.outfile, " variant=\"%s\"", variant_str);
+                fprintf(p_config->outfile, " variant=\"%s\"", variant_str);
             if (strlen(name_str))
-                fprintf(config.outfile, " name=\"%s\"", name_str);
+                fprintf(p_config->outfile, " name=\"%s\"", name_str);
             if (strlen(localname_str))
-                fprintf(config.outfile, " localname=\"%s\"", localname_str);
-            fprintf(config.outfile, ">");
+                fprintf(p_config->outfile, " localname=\"%s\"", localname_str);
+            fprintf(p_config->outfile, ">");
             if (strlen(localname_str))
-                fprintf(config.outfile, "%s", localname_str);
-            fprintf(config.outfile, "</locale>\n"); 
+                fprintf(p_config->outfile, "%s", localname_str);
+            fprintf(p_config->outfile, "</locale>\n"); 
         }
         else if (1 == p_config->xmloutput)
         {
-            fprintf(config.outfile, "%s", uloc_getAvailable(i)); 
-            fprintf(config.outfile, " | ");
+            fprintf(p_config->outfile, "%s", uloc_getAvailable(i)); 
+            fprintf(p_config->outfile, " | ");
             if (strlen(name_str))
-                fprintf(config.outfile, "%s", name_str);
-            fprintf(config.outfile, " | ");
+                fprintf(p_config->outfile, "%s", name_str);
+            fprintf(p_config->outfile, " | ");
             if (strlen(localname_str))
-                fprintf(config.outfile, "%s", localname_str);
-            fprintf(config.outfile, "\n");
+                fprintf(p_config->outfile, "%s", localname_str);
+            fprintf(p_config->outfile, "\n");
         }
         else
-            fprintf(config.outfile, "%s\n", uloc_getAvailable(i));
+            fprintf(p_config->outfile, "%s\n", uloc_getAvailable(i));
     }
     if (p_config->xmloutput)
-        fprintf(config.outfile, "</locales>\n");
+        fprintf(p_config->outfile, "</locales>\n");
     else
-        fprintf(config.outfile, "\n");
+        fprintf(p_config->outfile, "\n");
 
     if (U_FAILURE(status))
     {
@@ -410,35 +399,35 @@ static void print_icu_xml_locales(const struct config_t *p_config)
 static void print_info(const struct config_t *p_config)
 {
     if (p_config->xmloutput)
-        fprintf(config.outfile, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+        fprintf(p_config->outfile, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
                 "<icu>\n");
 
-    if ('c' == config.print[0])
-        print_icu_converters(&config);
-    else if ('l' == config.print[0])
-        print_icu_xml_locales(&config);
-    else if ('t' == config.print[0])
-        print_icu_transliterators(&config);
+    if ('c' == p_config->print[0])
+        print_icu_converters(p_config);
+    else if ('l' == p_config->print[0])
+        print_icu_xml_locales(p_config);
+    else if ('t' == p_config->print[0])
+        print_icu_transliterators(p_config);
     else {
-        print_icu_converters(&config);
-        print_icu_xml_locales(&config);
-        print_icu_transliterators(&config);
+        print_icu_converters(p_config);
+        print_icu_xml_locales(p_config);
+        print_icu_transliterators(p_config);
     }
 
     if (p_config->xmloutput)
-        fprintf(config.outfile, "</icu>\n");
+        fprintf(p_config->outfile, "</icu>\n");
 
     exit(0);
 }
 
 
 
-static void process_text_file(const struct config_t *p_config)
+static void process_text_file(struct config_t *p_config)
 {
     char *line = 0;
     char linebuf[1024];
  
-    xmlDoc *doc = xmlParseFile(config.conffile);  
+    xmlDoc *doc = xmlParseFile(p_config->conffile);  
     xmlNode *xml_node = xmlDocGetRootElement(doc);
 
     long unsigned int token_count = 0;    
@@ -449,82 +438,82 @@ static void process_text_file(const struct config_t *p_config)
     if (!xml_node)
     {   
         printf("Could not parse XML config file '%s' \n",
-                config.conffile);
+                p_config->conffile);
         exit(1);
     }
 
-    config.chain = icu_chain_xml_config(xml_node, 1, &status);
+    p_config->chain = icu_chain_xml_config(xml_node, 1, &status);
 
-    if (!config.chain || !U_SUCCESS(status))
+    if (!p_config->chain || !U_SUCCESS(status))
     {   
         printf("Could not set up ICU chain from config file '%s' \n",
-                config.conffile);
+                p_config->conffile);
         if (!U_SUCCESS(status))
             printf("ICU Error: %d %s\n", status, u_errorName(status));
         exit(1);
     }
 
     if (p_config->xmloutput)
-        fprintf(config.outfile,
+        fprintf(p_config->outfile,
                 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
                 "<icu>\n"
                 "<tokens>\n");
     
     /* read input lines for processing */
-    while ((line=fgets(linebuf, sizeof(linebuf)-1, config.infile)))
+    while ((line=fgets(linebuf, sizeof(linebuf)-1, p_config->infile)))
     {
         WRBUF sw = wrbuf_alloc();
         WRBUF cdata = wrbuf_alloc();
-        int success = icu_chain_assign_cstr(config.chain, line, &status);
+        int success = icu_chain_assign_cstr(p_config->chain, line, &status);
         line_count++;
 
-        while (success && icu_chain_next_token(config.chain, &status))
+        while (success && icu_chain_next_token(p_config->chain, &status))
         {
             if (U_FAILURE(status))
                 success = 0;
             else
             {
-                const char *sortkey = icu_chain_token_sortkey(config.chain);
+                const char *sortkey = icu_chain_token_sortkey(p_config->chain);
                 wrbuf_rewind(sw);
                 wrbuf_puts_escaped(sw, sortkey);
                 token_count++;
                 if (p_config->xmloutput)                    
                 {
-                    fprintf(config.outfile, 
+                    fprintf(p_config->outfile, 
                             "<token id=\"%lu\" line=\"%lu\"",
                             token_count, line_count);
 
                     wrbuf_rewind(cdata);
-                    wrbuf_xmlputs(cdata, icu_chain_token_norm(config.chain));
-                    fprintf(config.outfile, " norm=\"%s\"",
+                    wrbuf_xmlputs(cdata, icu_chain_token_norm(p_config->chain));
+                    fprintf(p_config->outfile, " norm=\"%s\"",
                             wrbuf_cstr(cdata));
 
                     wrbuf_rewind(cdata);
-                    wrbuf_xmlputs(cdata, icu_chain_token_display(config.chain));
-                    fprintf(config.outfile, " display=\"%s\"",
+                    wrbuf_xmlputs(cdata, icu_chain_token_display(p_config->chain));
+                    fprintf(p_config->outfile, " display=\"%s\"",
                             wrbuf_cstr(cdata));
                     
                     if (p_config->sortoutput)
                     {
                         wrbuf_rewind(cdata);
                         wrbuf_xmlputs(cdata, wrbuf_cstr(sw));
-                        fprintf(config.outfile, " sortkey=\"%s\"",
+                        fprintf(p_config->outfile, " sortkey=\"%s\"",
                                 wrbuf_cstr(cdata));
                     }
-                    fprintf(config.outfile, "/>\n");
+                    fprintf(p_config->outfile, "/>\n");
                 }
                 else
                 {
-                    fprintf(config.outfile, "%lu %lu '%s' '%s'",
+                    fprintf(p_config->outfile, "%lu %lu '%s' '%s'",
                             token_count,
                             line_count,
-                            icu_chain_token_norm(config.chain),
-                            icu_chain_token_display(config.chain));
+                            icu_chain_token_norm(p_config->chain),
+                            icu_chain_token_display(p_config->chain));
                     if (p_config->sortoutput)
                     {
-                        fprintf(config.outfile, " '%s'", wrbuf_cstr(sw));
+                        fprintf(p_config->outfile, " '%s'", wrbuf_cstr(sw));
                     }
-                    fprintf(config.outfile, "\n");
+                    fprintf(p_config->outfile, "\n");
                 }
             }
         }
@@ -533,11 +522,11 @@ static void process_text_file(const struct config_t *p_config)
     }
 
     if (p_config->xmloutput)
-        fprintf(config.outfile,
+        fprintf(p_config->outfile,
                 "</tokens>\n"
                 "</icu>\n");
     
-    icu_chain_destroy(config.chain);
+    icu_chain_destroy(p_config->chain);
     xmlFreeDoc(doc);
     if (line)
         free(line);
@@ -548,9 +537,9 @@ static void process_text_file(const struct config_t *p_config)
 
 int main(int argc, char **argv) 
 {
+    struct config_t config;
 
 #if YAZ_HAVE_ICU
-
     read_params(argc, argv, &config);
 
     if (config.conffile && strlen(config.conffile))
@@ -559,6 +548,7 @@ int main(int argc, char **argv)
     if (config.print && strlen(config.print))
         print_info(&config);
 
+    u_cleanup();
 #else /* YAZ_HAVE_ICU */
 
     printf("ICU not available on your system.\n"
index 4747104..b850872 100644 (file)
@@ -18,7 +18,9 @@ ICONV_DIR = c:\iconv-1.9.2.win32
 # icu charcter conversion utility
 # get icu libraries from http://www.icu-project.org
 HAVE_ICU=1
-ICU_DIR = c:\icu
+ICU_LIB = c:\icu\lib
+ICU_BIN = c:\icu\bin
+ICU_INCLUDE = c:\icu\include
 
 # libxslt
 HAVE_LIBXSLT=1
@@ -50,8 +52,8 @@ dist: yaz.win32.nsi yaz.nsi distclean
        $(NSIS) yaz.win32.nsi
 
 dist64: yaz.win64.nsi yaz.nsi distclean
-       nmake DEBUG=0 HAVE_LIBXSLT=0 HAVE_LIBXML2=0 HAVE_ICONV=0 HAVE_ICU=0
-       $(NSIS) yaz.win64.nsi
+       nmake DEBUG=0 HAVE_LIBXSLT=1 HAVE_LIBXML2=1 HAVE_ICONV=0 HAVE_ICU=1 LIBXML2_DIR=c:\libxml2-2.7.8.win64 LIBXSLT_DIR=c:\libxslt-1.1.26.win64 ICU_LIB=\icu64\lib64 ICU_INCLUDE=\icu64\include ICU_BIN=\icu64\bin64
+       $(NSIS) yaz.win64.nsi 
 
 distclean:
        nmake DEBUG=1 clean
@@ -179,23 +181,22 @@ iconv:
 
 !if $(HAVE_ICU)
 ICU_DEF= \
-  /D YAZ_HAVE_ICU=1 /D HAVE_ICU_H=1 \
-  /I"$(ICU_DIR)\include"
-ICU_LIB= \
-  $(ICU_DIR)\lib\icudt.lib $(ICU_DIR)\lib\icuin.lib $(ICU_DIR)\lib\icuuc.lib
+  /D YAZ_HAVE_ICU=1 /D HAVE_ICU_H=1 /I"$(ICU_INCLUDE)"
+ICU_LIBS= \
+  $(ICU_LIB)\icudt.lib $(ICU_LIB)\icuin.lib $(ICU_LIB)\icuuc.lib
 icu: $(BINDIR)\icudt42.dll $(BINDIR)\icuin42.dll $(BINDIR)\icuuc42.dll
 yazicu: dirs generate $(YAZ_ICU) 
 
 $(BINDIR)\icudt42.dll:
-  copy "$(ICU_DIR)\bin\icudt42.dll" $(BINDIR)
+  copy "$(ICU_BIN)\icudt42.dll" $(BINDIR)
 $(BINDIR)\icuin42.dll:
-  copy "$(ICU_DIR)\bin\icuin42.dll" $(BINDIR)
+  copy "$(ICU_BIN)\icuin42.dll" $(BINDIR)
 $(BINDIR)\icuuc42.dll:
-  copy "$(ICU_DIR)\bin\icuuc42.dll" $(BINDIR)
+  copy "$(ICU_BIN)\icuuc42.dll" $(BINDIR)
 !else
 ICU_DEF= \
   /D YAZ_HAVE_ICU=0
-ICU_LIB=
+ICU_LIBS=
 icu:
 yazicu:
 !endif
@@ -257,7 +258,8 @@ COMMON_C_OPTIONS=          \
   /Fd"$(OBJDIR)\\" 
 
 COMMON_C_INCLUDES= \
-  /I"$(ROOTDIR)\include"
+  /I"$(ROOTDIR)\include" \
+  /I"$(ROOTDIR)\libstemmer_c\include"
 
 DEBUG_C_OPTIONS=  \
   /D "_DEBUG"      \
@@ -571,10 +573,17 @@ ILL_OBJS= \
    $(OBJDIR)\ill-core.obj\
    $(OBJDIR)\item-req.obj
 
+STEMMER_OBJS = \
+   $(OBJDIR)\libstemmer.obj \
+   $(OBJDIR)\api.obj \
+   $(OBJDIR)\utilities.obj \
+   $(OBJDIR)\stem_UTF_8_porter.obj \
+   $(OBJDIR)\stem_UTF_8_english.obj
+
 DLL_OBJS =\
    $(MISC_OBJS) \
    $(Z3950_OBJS) \
-   $(ILL_OBJS) \
+   $(ILL_OBJS)
    
 ICU_DLL_OBJS =\
    $(OBJDIR)\icu_chain.obj \
@@ -583,7 +592,9 @@ ICU_DLL_OBJS =\
    $(OBJDIR)\icu_transform.obj \
    $(OBJDIR)\icu_casemap.obj \
    $(OBJDIR)\icu_tokenizer.obj \
-   $(OBJDIR)\icu_sortkey.obj
+   $(OBJDIR)\icu_sortkey.obj \
+   $(OBJDIR)\stemmer.obj \
+   $(STEMMER_OBJS) 
 
 # Generated C and H files
 
@@ -743,6 +754,15 @@ generate: \
 {$(TESTDIR)}.c{$(OBJDIR)}.obj:
        $(CPP) $(COPT) $< 
 
+{$(ROOTDIR)\libstemmer_c\libstemmer}.c{$(OBJDIR)}.obj:
+       $(CPP) $(COPT) $< 
+
+{$(ROOTDIR)\libstemmer_c\runtime}.c{$(OBJDIR)}.obj:
+       $(CPP) $(COPT) $< 
+
+{$(ROOTDIR)\libstemmer_c\src_c}.c{$(OBJDIR)}.obj:
+       $(CPP) $(COPT) $< 
+
 # ASN-generated files
 
 !if $(HAVE_TCL)
@@ -875,7 +895,7 @@ $(YAZ_DLL) $(YAZ_IMPLIB): "$(BINDIR)" $(DLL_OBJS) $(YAZ_RES)
        $(MT) -manifest $@.manifest -outputresource:$@;2
 
 $(YAZ_ICU_DLL) $(YAZ_ICU_IMPLIB): "$(BINDIR)" $(ICU_DLL_OBJS) $(YAZ_ICU_RES)
-       $(LINK_DLL) $(ICU_LIB) $(YAZ_IMPLIB)\
+       $(LINK_DLL) $(ICU_LIBS) $(YAZ_IMPLIB)\
                $(ICU_DLL_OBJS) \
                $(YAZ_ICU_RES) \
                /out:$@ \
@@ -895,7 +915,7 @@ $(CLIENT) : "$(BINDIR)" $(YAZ_CLIENT_OBJS) $(YAZ_DLL)
        $(MT) -manifest $@.manifest -outputresource:$@;1
 
 $(YAZ_ICU) : "$(BINDIR)" $(YAZ_ICU_OBJS) $(YAZ_ICU_DLL)
-       $(LINK_PROGRAM) $(ICU_LIB) $(YAZ_ICU_IMPLIB) $(YAZ_ICU_OBJS) /out:$@
+       $(LINK_PROGRAM) $(ICU_LIBS) $(YAZ_ICU_IMPLIB) $(YAZ_ICU_OBJS) /out:$@
        $(MT) -manifest $@.manifest -outputresource:$@;1
 
 
index 1ae7d9a..be73f62 100644 (file)
@@ -143,6 +143,7 @@ SectionEnd
 Section "YAZ Source" YAZ_Source
        SectionIn 1
        SetOutPath $INSTDIR
+       File ..\configure.ac
        File /r ..\*.c
        File /r /x yaz ..\*.h
        SetOutPath $INSTDIR\util
index 8e4b351..ac8fcc7 100644 (file)
--- a/yaz.spec
+++ b/yaz.spec
@@ -5,7 +5,7 @@
 
 Name: yaz
 Summary: Z39.50 Programs
-Version: 4.1.4
+Version: 4.1.7
 Release: 1indexdata
 
 # determine system