Added support for MARC record conversion with Usemarcon
authorAdam Dickmeiss <adam@indexdata.dk>
Fri, 3 Dec 2004 14:28:18 +0000 (14:28 +0000)
committerAdam Dickmeiss <adam@indexdata.dk>
Fri, 3 Dec 2004 14:28:18 +0000 (14:28 +0000)
12 files changed:
Makefile.am
configure.in
etc/Makefile.am
etc/config-mafi2ma.xml [new file with mode: 0644]
etc/yazproxy.xsd
include/yazproxy/proxy.h
src/Makefile.am
src/proxyp.h [new file with mode: 0644]
src/yaz-proxy-config.cpp
src/yaz-proxy.cpp
src/yaz-usemarcon.cpp [new file with mode: 0644]
usemarcon.m4 [new file with mode: 0644]

index ca05423..16e47c8 100644 (file)
@@ -2,8 +2,7 @@ AUTOMAKE_OPTIONS = foreign
 
 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
index b79e9a4..8a9a848 100644 (file)
@@ -10,6 +10,7 @@ AM_PROG_LIBTOOL
 
 YAZPP_INIT(threads,1.0)
 YAZ_DOC
+USEMARCON_INIT
 
 AC_CHECK_FUNCS(setrlimit getrlimit gettimeofday)
 dnl
index 7904c47..3a58871 100644 (file)
@@ -1,4 +1,4 @@
-# $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 = \
@@ -11,6 +11,7 @@ proxydata_DATA = \
  config.xml \
  explain.xml \
  voyager.xml \
+ config-mafi2ma.xml \
  pqf.properties \
  yazproxy.xsd \
  zeerex-2.0.xsd \
diff --git a/etc/config-mafi2ma.xml b/etc/config-mafi2ma.xml
new file mode 100644 (file)
index 0000000..7e4c0e5
--- /dev/null
@@ -0,0 +1,40 @@
+<?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>
index 531a339..f447afc 100644 (file)
@@ -1,6 +1,6 @@
 <?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"
@@ -90,6 +90,8 @@
    <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>
 
index c9c64ee..9ddd94f 100644 (file)
@@ -1,4 +1,4 @@
-/* $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.
@@ -19,6 +19,9 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 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>
@@ -37,6 +40,7 @@ class Yaz_Proxy;
 
 struct Yaz_RecordCache_Entry;
 class Yaz_ProxyConfigP;
+class Yaz_usemarcon;
 
 class YAZ_EXPORT Yaz_ProxyConfig {
 public:
@@ -74,7 +78,9 @@ 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);
@@ -259,6 +265,9 @@ class YAZ_EXPORT Yaz_Proxy : public Yaz_Z_Assoc {
     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);
@@ -291,3 +300,4 @@ class YAZ_EXPORT Yaz_Proxy : public Yaz_Z_Assoc {
     int handle_init_response_for_invalid_session(Z_APDU *apdu);
 };
 
+#endif
index 029f8c5..86142f9 100644 (file)
@@ -1,15 +1,16 @@
-## $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)
diff --git a/src/proxyp.h b/src/proxyp.h
new file mode 100644 (file)
index 0000000..8839106
--- /dev/null
@@ -0,0 +1,50 @@
+/* $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
+};
index 804018b..2bc8cfe 100644 (file)
@@ -1,4 +1,4 @@
-/* $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.
@@ -21,15 +21,7 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 
 #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;
@@ -464,7 +456,10 @@ int Yaz_ProxyConfig::check_syntax(ODR odr, const char *name,
                                  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)
     {
@@ -486,6 +481,16 @@ int Yaz_ProxyConfig::check_syntax(ODR odr, const char *name,
        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;
@@ -506,6 +511,8 @@ int Yaz_ProxyConfig::check_syntax(ODR odr, const char *name,
            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)
            {
@@ -532,6 +539,14 @@ int Yaz_ProxyConfig::check_syntax(ODR odr, const char *name,
                    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)
            {
@@ -579,6 +594,16 @@ int Yaz_ProxyConfig::check_syntax(ODR odr, const char *name,
                    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;
index fa3b441..6857d0c 100644 (file)
@@ -1,4 +1,4 @@
-/* $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.
@@ -38,17 +38,10 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 #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)
@@ -170,6 +163,9 @@ Yaz_Proxy::Yaz_Proxy(IYaz_PDU_Observable *the_PDU_Observable,
 #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();
 }
@@ -196,6 +192,9 @@ Yaz_Proxy::~Yaz_Proxy()
     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)
@@ -756,6 +755,54 @@ void Yaz_Proxy::convert_to_frontend_type(Z_NamePlusRecordList *p)
                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,
@@ -1107,7 +1154,11 @@ int Yaz_Proxy::send_to_client(Z_APDU *apdu)
        {
            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,
@@ -1148,7 +1199,11 @@ int Yaz_Proxy::send_to_client(Z_APDU *apdu)
        }
        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,
@@ -1664,7 +1719,9 @@ 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_charset);
+                                   &m_backend_type, &m_backend_charset,
+                                    &m_usemarcon_ini_stage1,
+                                   &m_usemarcon_ini_stage2);
        if (stylesheet_name)
        {
            m_parent->low_socket_close();
@@ -1738,7 +1795,10 @@ Z_APDU *Yaz_Proxy::handle_syntax_validation(Z_APDU *apdu)
                                    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();
diff --git a/src/yaz-usemarcon.cpp b/src/yaz-usemarcon.cpp
new file mode 100644 (file)
index 0000000..d769e25
--- /dev/null
@@ -0,0 +1,83 @@
+/* $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;
+}
diff --git a/usemarcon.m4 b/usemarcon.m4
new file mode 100644 (file)
index 0000000..5b9ae5c
--- /dev/null
@@ -0,0 +1,42 @@
+## $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
+])
+