SUBDIRS = src include etc doc
-EXTRA_DIST= README LICENSE yazpp.m4 yaz.m4 buildconf.sh
-
+EXTRA_DIST= README LICENSE yazpp.m4 yaz.m4 usemarcon.m4 buildconf.sh
dist-hook:
mkdir $(distdir)/win
YAZPP_INIT(threads,1.0)
YAZ_DOC
+USEMARCON_INIT
AC_CHECK_FUNCS(setrlimit getrlimit gettimeofday)
dnl
-# $Id: Makefile.am,v 1.4 2004-11-09 14:24:22 adam Exp $
+# $Id: Makefile.am,v 1.5 2004-12-03 14:28:18 adam Exp $
proxydatadir=$(datadir)/yazproxy
proxydata_DATA = \
config.xml \
explain.xml \
voyager.xml \
+ config-mafi2ma.xml \
pqf.properties \
yazproxy.xsd \
zeerex-2.0.xsd \
--- /dev/null
+<?xml version="1.0"?>
+<!-- $Id: config-mafi2ma.xml,v 1.1 2004-12-03 14:28:18 adam Exp $ -->
+<proxy xmlns="http://indexdata.dk/yazproxy/schema/0.8/"
+ xmlns:xi="http://www.w3.org/2001/XInclude"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://indexdata.dk/yazproxy/schema/0.8/ yazproxy.xsd"
+>
+<!-- Config can be checked with xerces-c++: PParse -n -s config.xml -->
+ <target name="localhost" default="1">
+ <url>193.166.7.193:7590</url>
+ <target-timeout>30</target-timeout>
+ <client-timeout>60</client-timeout>
+ <keepalive>
+ <bandwidth>1000000</bandwidth>
+ <pdu>1000</pdu>
+ </keepalive>
+ <limit><!-- per minute limits .. -->
+ <bandwidth>2000000</bandwidth>
+ <pdu>50</pdu>
+ <retrieve>100</retrieve>
+ </limit>
+ <attribute type="1" value="1-11,13-1016"/>
+ <attribute type="1" value="*" error="114"/>
+ <syntax type="opac"/>
+ <syntax type="usmarc" backendtype="finmarc" usemarconstage1="mafi2ma/mafi2ma.ini"/>
+ <syntax type="none"/>
+ <syntax type="xml" marcxml="1" backendtype="finmarc" usemarconstage1="mafi2ma/mafi2ma.ini"/>
+ <syntax type="*" error="238"/>
+ <preinit>0</preinit>
+ <xi:include href="explain.xml"/>
+ <cql2rpn>pqf.properties</cql2rpn>
+ </target>
+ <target name="*">
+ <target-timeout>60</target-timeout>
+ <client-timeout>30</client-timeout>
+ <!-- everything else -->
+ </target>
+ <max-clients>50</max-clients>
+ <log>client-requests server-requests</log>
+</proxy>
<?xml version="1.0"?>
<!-- XML Schema for YAZ proxy config file.
- $Id: yazproxy.xsd,v 1.6 2004-10-23 23:12:23 adam Exp $
+ $Id: yazproxy.xsd,v 1.7 2004-12-03 14:28:18 adam Exp $
-->
<xs:schema
xmlns:xs="http://www.w3.org/2001/XMLSchema"
<xs:attribute name="stylesheet" type="xs:string" />
<xs:attribute name="backendtype" type="xs:string" />
<xs:attribute name="backendcharset" type="xs:string" />
+ <xs:attribute name="usemarconstage1" type="xs:string" />
+ <xs:attribute name="usemarconstage2" type="xs:string" />
</xs:complexType>
</xs:element>
-/* $Id: proxy.h,v 1.8 2004-10-23 23:12:24 adam Exp $
+/* $Id: proxy.h,v 1.9 2004-12-03 14:28:18 adam Exp $
Copyright (c) 1998-2004, Index Data.
This file is part of the yaz-proxy.
02111-1307, USA.
*/
+#ifndef YAZ_PROXY_H_INCLUDED
+#define YAZ_PROXY_H_INCLUDED
+
#include <yaz++/z-assoc.h>
#include <yaz++/z-query.h>
#include <yaz++/z-databases.h>
struct Yaz_RecordCache_Entry;
class Yaz_ProxyConfigP;
+class Yaz_usemarcon;
class YAZ_EXPORT Yaz_ProxyConfig {
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_charset);
+ char **backend_type, char **backend_charset,
+ char **usemarcon_ini_stage1, char **usemarcon_ini_stage2
+ );
char *get_explain_doc(ODR odr, const char *name, const char *db,
int *len);
const char *get_explain_name(const char *db, const char **backend_db);
int m_lo_fd[NO_SPARE_SOLARIS_FD];
void low_socket_open();
void low_socket_close();
+ char *m_usemarcon_ini_stage1;
+ char *m_usemarcon_ini_stage2;
+ Yaz_usemarcon *m_usemarcon;
public:
Yaz_Proxy(IYaz_PDU_Observable *the_PDU_Observable,
Yaz_Proxy *parent = 0);
int handle_init_response_for_invalid_session(Z_APDU *apdu);
};
+#endif
-## $Id: Makefile.am,v 1.2 2004-04-11 11:58:35 adam Exp $
+## $Id: Makefile.am,v 1.3 2004-12-03 14:28:18 adam Exp $
-AM_CXXFLAGS = $(YAZPPINC) -I$(srcdir)/../include $(XSLT_CFLAGS)
+AM_CXXFLAGS = $(YAZPPINC) -I$(srcdir)/../include $(XSLT_CFLAGS) $(USEMARCONINC)
lib_LTLIBRARIES = libyazproxy.la
libyazproxy_la_LDFLAGS=-version-info 1:0:0
-libyazproxy_la_SOURCES= yaz-proxy.cpp yaz-proxy-config.cpp yaz-bw.cpp
+libyazproxy_la_SOURCES= yaz-proxy.cpp yaz-proxy-config.cpp yaz-bw.cpp \
+ proxyp.h yaz-usemarcon.cpp
bin_PROGRAMS = yazproxy
yazproxy_SOURCES=yaz-proxy-main.cpp
-LDADD=libyazproxy.la $(YAZPPLALIB) $(XSLT_LIBS)
+LDADD=libyazproxy.la $(YAZPPLALIB) $(XSLT_LIBS) $(USEMARCONLALIB)
libyazproxy_la_LIBADD = $(XSLT_LIBS)
--- /dev/null
+/* $Id: proxyp.h,v 1.1 2004-12-03 14:28:18 adam Exp $
+ Copyright (c) 1998-2004, Index Data.
+
+This file is part of the yaz-proxy.
+
+YAZ proxy is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 2, or (at your option) any later
+version.
+
+YAZ proxy is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with YAZ proxy; see the file LICENSE. If not, write to the
+Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
+02111-1307, USA.
+ */
+
+#if HAVE_XSLT
+#include <libxml/parser.h>
+#include <libxml/tree.h>
+#include <libxml/xinclude.h>
+#include <libxslt/xsltutils.h>
+#include <libxslt/transform.h>
+#endif
+
+#if HAVE_USEMARCON
+#include <objectlist.h>
+#endif
+
+#include <yazproxy/proxy.h>
+
+class Yaz_usemarcon {
+ public:
+ Yaz_usemarcon();
+ ~Yaz_usemarcon();
+
+ int convert(const char *stage1, const char *stage2,
+ const char *input, int input_len,
+ char **output, int *output_len);
+#if HAVE_USEMARCON
+ CDetails *m_stage1;
+ CDetails *m_stage2;
+#else
+ int dummy;
+#endif
+};
-/* $Id: yaz-proxy-config.cpp,v 1.10 2004-11-30 21:10:45 adam Exp $
+/* $Id: yaz-proxy-config.cpp,v 1.11 2004-12-03 14:28:18 adam Exp $
Copyright (c) 1998-2004, Index Data.
This file is part of the yaz-proxy.
#include <ctype.h>
#include <yaz/ylog.h>
-#include <yazproxy/proxy.h>
-
-#if HAVE_XSLT
-#include <libxml/parser.h>
-#include <libxml/tree.h>
-#include <libxml/xinclude.h>
-#include <libxslt/xsltutils.h>
-#include <libxslt/transform.h>
-#endif
+#include "proxyp.h"
class Yaz_ProxyConfigP {
friend class Yaz_ProxyConfig;
char **addinfo,
char **stylesheet, char **schema,
char **backend_type,
- char **backend_charset)
+ char **backend_charset,
+ char **usemarcon_ini_stage1,
+ char **usemarcon_ini_stage2
+ )
{
if (stylesheet)
{
xfree (*backend_charset);
*backend_charset = 0;
}
+ if (usemarcon_ini_stage1)
+ {
+ xfree (*usemarcon_ini_stage1);
+ *usemarcon_ini_stage1 = 0;
+ }
+ if (usemarcon_ini_stage2)
+ {
+ xfree (*usemarcon_ini_stage2);
+ *usemarcon_ini_stage2 = 0;
+ }
#if HAVE_XSLT
int syntax_has_matched = 0;
xmlNodePtr ptr;
const char *match_identifier = 0;
const char *match_backend_type = 0;
const char *match_backend_charset = 0;
+ const char *match_usemarcon_ini_stage1 = 0;
+ const char *match_usemarcon_ini_stage2 = 0;
struct _xmlAttr *attr;
for (attr = ptr->properties; attr; attr = attr->next)
{
attr->children && attr->children->type == XML_TEXT_NODE)
match_backend_charset = (const char *)
attr->children->content;
+ if (!strcmp((const char *) attr->name, "usemarconstage1") &&
+ attr->children && attr->children->type == XML_TEXT_NODE)
+ match_usemarcon_ini_stage1 = (const char *)
+ attr->children->content;
+ if (!strcmp((const char *) attr->name, "usemarconstage2") &&
+ attr->children && attr->children->type == XML_TEXT_NODE)
+ match_usemarcon_ini_stage2 = (const char *)
+ attr->children->content;
}
if (match_type)
{
xfree(*backend_charset);
*backend_charset = xstrdup(match_backend_charset);
}
+ if (usemarcon_ini_stage1 && match_usemarcon_ini_stage1)
+ {
+ xfree(*usemarcon_ini_stage1);
+ *usemarcon_ini_stage1 = xstrdup(match_usemarcon_ini_stage1);
+ }
+ if (usemarcon_ini_stage1 && match_usemarcon_ini_stage2)
+ {
+ xfree(*usemarcon_ini_stage2);
+ *usemarcon_ini_stage2 = xstrdup(match_usemarcon_ini_stage2);
+ }
if (match_marcxml)
{
return -1;
-/* $Id: yaz-proxy.cpp,v 1.12 2004-11-30 21:10:45 adam Exp $
+/* $Id: yaz-proxy.cpp,v 1.13 2004-12-03 14:28:18 adam Exp $
Copyright (c) 1998-2004, Index Data.
This file is part of the yaz-proxy.
#include <yaz/yaz-iconv.h>
#include <yaz/ylog.h>
#include <yaz/diagbib1.h>
-#include <yazproxy/proxy.h>
+#include "proxyp.h"
#include <yaz/pquery.h>
#include <yaz/otherinfo.h>
-#if HAVE_XSLT
-#include <libxml/parser.h>
-#include <libxml/tree.h>
-#include <libxslt/xsltutils.h>
-#include <libxslt/transform.h>
-#endif
-
static const char *apdu_name(Z_APDU *apdu)
{
switch (apdu->which)
#else
m_time_tv = 0;
#endif
+ m_usemarcon_ini_stage1 = 0;
+ m_usemarcon_ini_stage2 = 0;
+ m_usemarcon = new Yaz_usemarcon();
if (!m_parent)
low_socket_open();
}
xfree (m_schema);
xfree (m_backend_type);
xfree (m_backend_charset);
+ xfree (m_usemarcon_ini_stage1);
+ xfree (m_usemarcon_ini_stage2);
+ delete m_usemarcon;
if (m_s2z_odr_init)
odr_destroy(m_s2z_odr_init);
if (m_s2z_odr_search)
Z_External *r = npr->u.databaseRecord;
if (r->which == Z_External_octet)
{
+#if HAVE_USEMARCON
+ if (m_usemarcon_ini_stage1 && *m_usemarcon_ini_stage1)
+ {
+ if (!m_usemarcon->m_stage1)
+ {
+ m_usemarcon->m_stage1 = new CDetails();
+ }
+ m_usemarcon->m_stage1->SetIniFileName(m_usemarcon_ini_stage1);
+ m_usemarcon->m_stage1->SetMarcRecord((char*) r->u.octet_aligned->buf, r->u.octet_aligned->len);
+ int res = m_usemarcon->m_stage1->Start();
+ if (res == 0)
+ {
+ char *converted;
+ int convlen;
+ m_usemarcon->m_stage1->GetMarcRecord(converted, convlen);
+ if (m_usemarcon_ini_stage2 && *m_usemarcon_ini_stage2)
+ {
+ if (!m_usemarcon->m_stage2)
+ {
+ m_usemarcon->m_stage2 = new CDetails();
+ }
+ m_usemarcon->m_stage2->SetIniFileName(m_usemarcon_ini_stage2);
+ m_usemarcon->m_stage2->SetMarcRecord(converted, convlen);
+ res = m_usemarcon->m_stage2->Start();
+ if (res == 0)
+ {
+ free(converted);
+ m_usemarcon->m_stage2->GetMarcRecord(converted, convlen);
+ }
+ else
+ {
+ yaz_log(YLOG_LOG, "%sUSEMARCON stage 2 error %d", m_session_str, res);
+ }
+ }
+ npr->u.databaseRecord =
+ z_ext_record(odr_encode(),
+ m_frontend_type,
+ converted,
+ strlen(converted));
+ free(converted);
+ }
+ else
+ {
+ yaz_log(YLOG_LOG, "%sUSEMARCON stage 1 error %d", m_session_str, res);
+ }
+ continue;
+ }
+#endif
npr->u.databaseRecord =
z_ext_record(odr_encode(),
m_frontend_type,
{
if (p && p->which == Z_Records_DBOSD)
{
- if (m_backend_type)
+ if (m_backend_type
+#if HAVE_USEMARCON
+ || m_usemarcon_ini_stage1 || m_usemarcon_ini_stage2
+#endif
+ )
convert_to_frontend_type(p->u.databaseOrSurDiagnostics);
if (m_marcxml_flag)
convert_to_marcxml(p->u.databaseOrSurDiagnostics,
}
if (p && p->which == Z_Records_DBOSD)
{
- if (m_backend_type)
+ if (m_backend_type
+#if HAVE_USEMARCON
+ || m_usemarcon_ini_stage1 || m_usemarcon_ini_stage2
+#endif
+ )
convert_to_frontend_type(p->u.databaseOrSurDiagnostics);
if (m_marcxml_flag)
convert_to_marcxml(p->u.databaseOrSurDiagnostics,
m_default_target,
sr->preferredRecordSyntax, rc,
&addinfo, &stylesheet_name, &m_schema,
- &m_backend_type, &m_backend_charset);
+ &m_backend_type, &m_backend_charset,
+ &m_usemarcon_ini_stage1,
+ &m_usemarcon_ini_stage2);
if (stylesheet_name)
{
m_parent->low_socket_close();
pr->preferredRecordSyntax,
pr->recordComposition,
&addinfo, &stylesheet_name, &m_schema,
- &m_backend_type, &m_backend_charset);
+ &m_backend_type, &m_backend_charset,
+ &m_usemarcon_ini_stage1,
+ &m_usemarcon_ini_stage2
+ );
if (stylesheet_name)
{
m_parent->low_socket_close();
--- /dev/null
+/* $Id: yaz-usemarcon.cpp,v 1.1 2004-12-03 14:28:18 adam Exp $
+ Copyright (c) 1998-2004, Index Data.
+
+This file is part of the yaz-proxy.
+
+YAZ proxy is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 2, or (at your option) any later
+version.
+
+YAZ proxy is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with YAZ proxy; see the file LICENSE. If not, write to the
+Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
+02111-1307, USA.
+ */
+
+#include "proxyp.h"
+
+Yaz_usemarcon::Yaz_usemarcon()
+{
+#if HAVE_USEMARCON
+ m_stage1 = 0;
+ m_stage2 = 0;
+#endif
+}
+
+Yaz_usemarcon::~Yaz_usemarcon()
+{
+#if HAVE_USEMARCON
+ delete m_stage1;
+ delete m_stage2;
+#endif
+}
+
+int Yaz_usemarcon::convert(const char *stage1, const char *stage2,
+ const char *input, int input_len,
+ char **output, int *output_len)
+{
+#if HAVE_USEMARCON
+ if (stage1 && *stage1)
+ {
+ char *converted;
+ int convlen;
+ if (!m_stage1)
+ {
+ m_stage1 = new CDetails();
+ }
+ m_stage1->SetIniFileName(stage1);
+ m_stage1->SetMarcRecord((char*) input, input_len);
+ int res = m_stage1->Start();
+ if (res == 0)
+ {
+ m_stage1->GetMarcRecord(converted, convlen);
+ if (stage2 && *stage2)
+ {
+ if (!m_stage2)
+ {
+ m_stage2 = new CDetails();
+ }
+ m_stage2->SetIniFileName(stage2);
+ m_stage2->SetMarcRecord(converted, convlen);
+ res = m_stage2->Start();
+ if (res == 0)
+ {
+ free(converted);
+ m_stage2->GetMarcRecord(converted, convlen);
+ }
+ else
+ return 0;
+ }
+ *output = converted;
+ *output_len = convlen;
+ return 1;
+ }
+ }
+#endif
+ return 0;
+}
--- /dev/null
+## $Id: usemarcon.m4,v 1.1 2004-12-03 14:28:18 adam Exp $
+AC_DEFUN([USEMARCON_INIT],
+[
+ AC_SUBST(USEMARCONLALIB)
+ AC_SUBST(USEMARCONINC)
+ usemarconconfig=NONE
+ usemarconpath=NONE
+ AC_ARG_WITH(usemarcon, [ --with-usemarcon=DIR usemarcon-config in DIR (example /home/usemarcon145)], [usemarconpath=$withval])
+
+ if test "x$usemarconpath" != "xNONE"; then
+ usemarconconfig=$usemarconpath/usemarcon-config
+ else
+ if test "x$srcdir" = "x"; then
+ usemarconsrcdir=.
+ else
+ usemarconsrcdir=$srcdir
+ fi
+ for i in ${usemarconsrcdir}/../usemarcon*; do
+ if test -d $i; then
+ if test -r $i/usemarcon-config; then
+ usemarconconfig=$i/usemarcon-config
+ fi
+ fi
+ done
+ if test "x$usemarconconfig" = "xNONE"; then
+ AC_PATH_PROG(usemarconconfig, usemarcon-config, NONE)
+ fi
+ fi
+
+ AC_MSG_CHECKING(for USEMARCON)
+ if $usemarconconfig --version >/dev/null 2>&1; then
+ USEMARCONLALIB=`$usemarconconfig --lalibs $1`
+ USEMARCONINC=`$usemarconconfig --cflags $1`
+ USEMARCONVERSION=`$usemarconconfig --version`
+ AC_MSG_RESULT($usemarconconfig)
+ AC_DEFINE(HAVE_USEMARCON)
+ else
+ AC_MSG_RESULT(Not found)
+ USEMARCONVERSION=NONE
+ fi
+])
+