New attribute "backendcharset" for syntax section which specifies
authorAdam Dickmeiss <adam@indexdata.dk>
Sun, 29 Aug 2004 13:01:43 +0000 (13:01 +0000)
committerAdam Dickmeiss <adam@indexdata.dk>
Sun, 29 Aug 2004 13:01:43 +0000 (13:01 +0000)
charset (encoding) for record that is returned by backend. If omitted
the proxy assumes backend record encoding is MARC-8 (for backwards
compatibility).

NEWS
configure.in
debian/changelog
etc/yazproxy.xsd
include/yazproxy/proxy.h
src/yaz-proxy-config.cpp
src/yaz-proxy.cpp

diff --git a/NEWS b/NEWS
index 63956ac..4c7ca70 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,4 +1,9 @@
 
+New attribute "backendcharset" for syntax section which specifies
+charset (encoding) for record that is returned by backend. If omitted
+the proxy assumes backend record encoding is MARC-8 (for backwards
+compatibility). 
+
 New attribute "backendtype" for syntax section which specifies
 record syntax to be transmitted to backend. This allows proxy to
 offer a record syntax different from that offered by backend.
index b02400e..b79e9a4 100644 (file)
@@ -1,5 +1,5 @@
 AC_INIT(configure.in)
-AM_INIT_AUTOMAKE(yazproxy,0.8)
+AM_INIT_AUTOMAKE(yazproxy,0.9)
 
 AC_PROG_CC
 AC_PROG_CPP
@@ -8,7 +8,7 @@ AC_HEADER_STDC
 AM_DISABLE_SHARED
 AM_PROG_LIBTOOL
 
-YAZPP_INIT(threads,0.8)
+YAZPP_INIT(threads,1.0)
 YAZ_DOC
 
 AC_CHECK_FUNCS(setrlimit getrlimit gettimeofday)
index 27f267c..1d6cafd 100644 (file)
@@ -1,3 +1,9 @@
+yazproxy (0.9-1) unstable; urgency=low
+
+  * Upstream.
+
+ -- Adam Dickmeiss <adam@indexdata.dk>  Fri, 13 Aug 2004 13:40:47 +0200
+
 yazproxy (0.8-2) unstable; urgency=low
 
   * Fix depends on libyaz++
index 49cbc0d..90e39cc 100644 (file)
@@ -1,6 +1,6 @@
 <?xml version="1.0"?>
 <!-- XML Schema for YAZ proxy config file.
-    $Id: yazproxy.xsd,v 1.3 2004-08-10 09:02:16 adam Exp $
+    $Id: yazproxy.xsd,v 1.4 2004-08-29 13:01:43 adam Exp $
 -->
 <xs:schema
   xmlns:xs="http://www.w3.org/2001/XMLSchema"
@@ -86,6 +86,7 @@
    <xs:attribute name="identifier" type="xs:string" />
    <xs:attribute name="stylesheet" type="xs:string" />
    <xs:attribute name="backendtype" type="xs:string" />
+   <xs:attribute name="backendcharset" type="xs:string" />
   </xs:complexType>
  </xs:element>
 
index 9c87ab8..7478351 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: proxy.h,v 1.5 2004-08-10 09:02:16 adam Exp $
+/* $Id: proxy.h,v 1.6 2004-08-29 13:01:43 adam Exp $
    Copyright (c) 1998-2004, Index Data.
 
 This file is part of the yaz-proxy.
@@ -72,7 +72,7 @@ public:
     int check_syntax(ODR odr, const char *name,
                     Odr_oid *syntax, Z_RecordComposition *comp,
                     char **addinfo, char **stylesheet, char **schema,
-                    char **backend_type);
+                    char **backend_type, char **backend_charset);
     char *get_explain(ODR odr, const char *name, const char *db,
                      int *len);
 private:
@@ -210,9 +210,10 @@ class YAZ_EXPORT Yaz_Proxy : public Yaz_Z_Assoc {
     Z_NamePlusRecordList *m_stylesheet_nprl;
     char *m_schema;
     char *m_backend_type;
+    char *m_backend_charset;
     int m_frontend_type;
     void convert_to_frontend_type(Z_NamePlusRecordList *p);
-    void convert_to_marcxml(Z_NamePlusRecordList *p);
+    void convert_to_marcxml(Z_NamePlusRecordList *p, const char *charset);
     int convert_xsl(Z_NamePlusRecordList *p, Z_APDU *apdu);
     void convert_xsl_delay();
     Z_APDU *m_initRequest_apdu;
index 772b678..2102e9a 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: yaz-proxy-config.cpp,v 1.5 2004-08-10 09:02:16 adam Exp $
+/* $Id: yaz-proxy-config.cpp,v 1.6 2004-08-29 13:01:43 adam Exp $
    Copyright (c) 1998-2004, Index Data.
 
 This file is part of the yaz-proxy.
@@ -447,7 +447,8 @@ int Yaz_ProxyConfig::check_syntax(ODR odr, const char *name,
                                  Odr_oid *syntax, Z_RecordComposition *comp,
                                  char **addinfo,
                                  char **stylesheet, char **schema,
-                                 char **backend_type)
+                                 char **backend_type,
+                                 char **backend_charset)
 {
     if (stylesheet)
     {
@@ -464,6 +465,11 @@ int Yaz_ProxyConfig::check_syntax(ODR odr, const char *name,
        xfree (*backend_type);
        *backend_type = 0;
     }
+    if (backend_charset)
+    {
+       xfree (*backend_charset);
+       *backend_charset = 0;
+    }
 #if HAVE_XSLT
     int syntax_has_matched = 0;
     xmlNodePtr ptr;
@@ -483,6 +489,7 @@ int Yaz_ProxyConfig::check_syntax(ODR odr, const char *name,
            const char *match_stylesheet = 0;
            const char *match_identifier = 0;
            const char *match_backend_type = 0;
+           const char *match_backend_charset = 0;
            struct _xmlAttr *attr;
            for (attr = ptr->properties; attr; attr = attr->next)
            {
@@ -505,6 +512,10 @@ int Yaz_ProxyConfig::check_syntax(ODR odr, const char *name,
                    attr->children && attr->children->type == XML_TEXT_NODE)
                    match_backend_type = (const char *)
                        attr->children->content;
+               if (!strcmp((const char *) attr->name, "backendcharset") &&
+                   attr->children && attr->children->type == XML_TEXT_NODE)
+                   match_backend_charset = (const char *)
+                       attr->children->content;
            }
            if (match_type)
            {
@@ -547,6 +558,11 @@ int Yaz_ProxyConfig::check_syntax(ODR odr, const char *name,
                    xfree(*backend_type);
                    *backend_type = xstrdup(match_backend_type);
                }
+               if (backend_charset && match_backend_charset)
+               {
+                   xfree(*backend_charset);
+                   *backend_charset = xstrdup(match_backend_charset);
+               }
                if (match_marcxml)
                {
                    return -1;
index f319d5d..3b43840 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: yaz-proxy.cpp,v 1.5 2004-08-10 09:02:16 adam Exp $
+/* $Id: yaz-proxy.cpp,v 1.6 2004-08-29 13:01:43 adam Exp $
    Copyright (c) 1998-2004, Index Data.
 
 This file is part of the yaz-proxy.
@@ -142,6 +142,7 @@ Yaz_Proxy::Yaz_Proxy(IYaz_PDU_Observable *the_PDU_Observable,
     m_s2z_database = 0;
     m_schema = 0;
     m_backend_type = 0;
+    m_backend_charset = 0;
     m_frontend_type = 0;
     m_initRequest_apdu = 0;
     m_initRequest_mem = 0;
@@ -193,6 +194,7 @@ Yaz_Proxy::~Yaz_Proxy()
 
     xfree (m_schema);
     xfree (m_backend_type);
+    xfree (m_backend_charset);
     if (m_s2z_odr_init)
        odr_destroy(m_s2z_odr_init);
     if (m_s2z_odr_search)
@@ -752,10 +754,13 @@ void Yaz_Proxy::convert_to_frontend_type(Z_NamePlusRecordList *p)
     }
 }
 
-void Yaz_Proxy::convert_to_marcxml(Z_NamePlusRecordList *p)
+void Yaz_Proxy::convert_to_marcxml(Z_NamePlusRecordList *p,
+                                  const char *backend_charset)
 {
     int i;
 
+    if (!backend_charset)
+       backend_charset = "MARC-8";
     yaz_iconv_t cd = yaz_iconv_open("UTF-8", "MARC-8");
     yaz_marc_t mt = yaz_marc_create();
     yaz_marc_xml(mt, YAZ_MARC_MARCXML);
@@ -1092,7 +1097,8 @@ int Yaz_Proxy::send_to_client(Z_APDU *apdu)
                if (m_backend_type)
                    convert_to_frontend_type(p->u.databaseOrSurDiagnostics);
                if (m_marcxml_flag)
-                   convert_to_marcxml(p->u.databaseOrSurDiagnostics);
+                   convert_to_marcxml(p->u.databaseOrSurDiagnostics,
+                                      m_backend_charset);
                if (convert_xsl(p->u.databaseOrSurDiagnostics, apdu))
                    return 0;
                    
@@ -1132,7 +1138,8 @@ int Yaz_Proxy::send_to_client(Z_APDU *apdu)
            if (m_backend_type)
                convert_to_frontend_type(p->u.databaseOrSurDiagnostics);
            if (m_marcxml_flag)
-               convert_to_marcxml(p->u.databaseOrSurDiagnostics);
+               convert_to_marcxml(p->u.databaseOrSurDiagnostics,
+                                  m_backend_charset);
            if (convert_xsl(p->u.databaseOrSurDiagnostics, apdu))
                return 0;
        }
@@ -1645,7 +1652,7 @@ Z_APDU *Yaz_Proxy::handle_syntax_validation(Z_APDU *apdu)
                                    m_default_target,
                                    sr->preferredRecordSyntax, rc,
                                    &addinfo, &stylesheet_name, &m_schema,
-                                   &m_backend_type);
+                                   &m_backend_type, &m_backend_charset);
        if (stylesheet_name)
        {
            m_parent->low_socket_close();
@@ -1719,7 +1726,7 @@ Z_APDU *Yaz_Proxy::handle_syntax_validation(Z_APDU *apdu)
                                    pr->preferredRecordSyntax,
                                    pr->recordComposition,
                                    &addinfo, &stylesheet_name, &m_schema,
-                                   &m_backend_type);
+                                   &m_backend_type, &m_backend_charset);
        if (stylesheet_name)
        {
            m_parent->low_socket_close();