Added support for MARC record conversion with Usemarcon
[yazproxy-moved-to-github.git] / include / yazproxy / proxy.h
index 6928ef4..9ddd94f 100644 (file)
@@ -1,39 +1,33 @@
-/* $Id: proxy.h,v 1.1 2004-04-11 11:37:01 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.
 
-Zebra is free software; you can redistribute it and/or modify it under
+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.
 
-Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
+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 Zebra; see the file LICENSE.proxy.  If not, write to the
+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_GETTIMEOFDAY
-#include <sys/time.h>
-#endif
+#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>
 #include <yaz++/cql2rpn.h>
 #include <yaz/cql.h>
-#include <yaz++/proxy/bw.h>
-#if HAVE_XSLT
-#include <libxml/parser.h>
-#include <libxml/tree.h>
-#include <libxslt/xsltutils.h>
-#include <libxslt/transform.h>
-#endif
+#include <yazproxy/bw.h>
 
 class Yaz_Proxy;
 
@@ -45,6 +39,8 @@ class Yaz_Proxy;
 #define PROXY_LOG_REQ_SERVER 8
 
 struct Yaz_RecordCache_Entry;
+class Yaz_ProxyConfigP;
+class Yaz_usemarcon;
 
 class YAZ_EXPORT Yaz_ProxyConfig {
 public:
@@ -64,7 +60,8 @@ public:
                      int *keepalive_limit_bw,
                      int *keepalive_limit_pdu,
                      int *pre_init,
-                     const char **cql2rpn);
+                     const char **cql2rpn,
+                     const char **authentication);
     
     void get_generic_info(int *log_mask, int *max_clients);
 
@@ -74,43 +71,22 @@ public:
                         int *max_clients,
                         int *keepalive_limit_bw, int *keepalive_limit_pdu,
                         int *pre_init,
-                        const char **cql2rpn);
+                        const char **cql2rpn,
+                        const char **authentication);
 
     int check_query(ODR odr, const char *name, Z_Query *query, char **addinfo);
     int check_syntax(ODR odr, const char *name,
                     Odr_oid *syntax, Z_RecordComposition *comp,
-                    char **addinfo, char **stylesheet, char **schema);
-    char *get_explain(ODR odr, const char *name, const char *db,
-                     int *len);
-private:
+                    char **addinfo, char **stylesheet, char **schema,
+                    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);
+ private:
     void operator=(const Yaz_ProxyConfig &conf);
-    int mycmp(const char *hay, const char *item, size_t len);
-#if HAVE_XSLT
-    int check_schema(xmlNodePtr ptr, Z_RecordComposition *comp,
-                    const char *schema_identifier);
-    xmlDocPtr m_docPtr;
-    xmlNodePtr m_proxyPtr;
-    void return_target_info(xmlNodePtr ptr, const char **url,
-                           int *limit_bw, int *limit_pdu, int *limit_req,
-                           int *target_idletime, int *client_idletime,
-                           int *keepalive_limit_bw, int *keepalive_limit_pdu,
-                           int *pre_init, const char **cql2rpn);
-    void return_limit(xmlNodePtr ptr,
-                     int *limit_bw, int *limit_pdu, int *limit_req);
-    int check_type_1(ODR odr, xmlNodePtr ptr, Z_RPNQuery *query,
-                    char **addinfo);
-    xmlNodePtr find_target_node(const char *name, const char *db);
-    xmlNodePtr find_target_db(xmlNodePtr ptr, const char *db);
-    const char *get_text(xmlNodePtr ptr);
-    int check_type_1_attributes(ODR odr, xmlNodePtr ptr,
-                               Z_AttributeList *attrs,
-                               char **addinfo);
-    int check_type_1_structure(ODR odr, xmlNodePtr ptr, Z_RPNStructure *q,
-                              char **addinfo);
-#endif
-    int m_copy;
-    int match_list(int v, const char *m);
-    int atoi_l(const char **cp);
+    class Yaz_ProxyConfigP *m_cp;
 };
 
 class YAZ_EXPORT Yaz_RecordCache {
@@ -191,9 +167,10 @@ class YAZ_EXPORT Yaz_Proxy : public Yaz_Z_Assoc {
     char *get_proxy(Z_OtherInformation **otherInfo);
     Yaz_ProxyClient *get_client(Z_APDU *apdu, const char *cookie,
                                const char *proxy_host);
+    void srw_get_client(const char *db, const char **backend_db);
     Z_APDU *result_set_optimize(Z_APDU *apdu);
     void shutdown();
-    
+    void releaseClient();    
     Yaz_ProxyClient *m_client;
     IYaz_PDU_Observable *m_PDU_Observable;
     Yaz_ProxyClient *m_clientPool;
@@ -237,16 +214,16 @@ class YAZ_EXPORT Yaz_Proxy : public Yaz_Z_Assoc {
     int m_request_no;
     int m_invalid_session;
     int m_marcxml_flag;
-#if HAVE_XSLT
-    xsltStylesheetPtr m_stylesheet_xsp;
-#else
-    void *m_stylesheet_xsp;
-#endif
+    void *m_stylesheet_xsp;  // Really libxslt's xsltStylesheetPtr 
     int m_stylesheet_offset;
     Z_APDU *m_stylesheet_apdu;
     Z_NamePlusRecordList *m_stylesheet_nprl;
     char *m_schema;
-    void convert_to_marcxml(Z_NamePlusRecordList *p);
+    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, const char *charset);
     int convert_xsl(Z_NamePlusRecordList *p, Z_APDU *apdu);
     void convert_xsl_delay();
     Z_APDU *m_initRequest_apdu;
@@ -279,9 +256,7 @@ class YAZ_EXPORT Yaz_Proxy : public Yaz_Z_Assoc {
     int m_http_keepalive;
     const char *m_http_version;
     Yaz_cql2rpn m_cql2rpn;
-#if HAVE_GETTIMEOFDAY
-    struct timeval m_time_tv;
-#endif
+    void *m_time_tv;
     void logtime();
     Z_ElementSetNames *mk_esn_from_schema(ODR o, const char *schema);
     Z_ReferenceId *m_referenceId;
@@ -290,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);
@@ -322,3 +300,4 @@ class YAZ_EXPORT Yaz_Proxy : public Yaz_Z_Assoc {
     int handle_init_response_for_invalid_session(Z_APDU *apdu);
 };
 
+#endif