1 /* $Id: proxyp.h,v 1.8 2005-06-21 18:46:04 adam Exp $
2 Copyright (c) 1998-2005, Index Data.
4 This file is part of the yaz-proxy.
6 YAZ proxy is free software; you can redistribute it and/or modify it under
7 the terms of the GNU General Public License as published by the Free
8 Software Foundation; either version 2, or (at your option) any later
11 YAZ proxy is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 You should have received a copy of the GNU General Public License
17 along with YAZ proxy; see the file LICENSE. If not, write to the
18 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
23 #include <libxml/parser.h>
24 #include <libxml/tree.h>
25 #include <libxml/xinclude.h>
26 #include <libxslt/xsltutils.h>
27 #include <libxslt/transform.h>
31 #include <objectlist.h>
34 #include <yaz++/record-cache.h>
35 #include <yazproxy/proxy.h>
36 #include <yazproxy/module.h>
38 struct Yaz_RecordCache_Entry;
45 int convert(const char *stage1, const char *stage2,
46 const char *input, int input_len,
47 char **output, int *output_len);
56 class Yaz_CharsetConverter {
58 Yaz_CharsetConverter();
59 ~Yaz_CharsetConverter();
60 void set_target_query_charset(const char *s);
61 void set_client_query_charset(const char *org);
62 const char *get_client_query_charset(void);
63 const char *get_target_query_charset(void);
64 void convert_type_1(Z_RPNQuery *q, ODR o);
65 void set_client_charset_selected(int sel);
66 int get_client_charset_selected();
68 void convert_type_1(char *buf_in, int len_in,
69 char **buf_out, int *len_out,
71 void convert_type_1(Z_Term *q, ODR o);
72 void convert_type_1(Z_RPNStructure *q, ODR o);
73 void convert_type_1(Z_Operand *q, ODR o);
74 char *m_target_query_charset;
75 char *m_client_query_charset;
76 int m_client_charset_selected;
81 class Yaz_ProxyConfig {
85 int read_xml(const char *fname);
87 int get_target_no(int no,
96 int *keepalive_limit_bw,
97 int *keepalive_limit_pdu,
100 const char **authentication,
101 const char **negotiation_charset,
102 const char **negotiation_lang,
103 const char **query_charset);
105 void get_generic_info(int *log_mask, int *max_clients);
107 void get_target_info(const char *name, const char **url,
108 int *limit_bw, int *limit_pdu, int *limit_req,
109 int *target_idletime, int *client_idletime,
111 int *keepalive_limit_bw, int *keepalive_limit_pdu,
113 const char **cql2rpn,
114 const char **negotiation_charset,
115 const char **negotiation_lang,
116 const char **query_charset);
118 const char *check_mime_type(const char *path);
119 int check_query(ODR odr, const char *name, Z_Query *query, char **addinfo);
120 int check_syntax(ODR odr, const char *name,
121 Odr_oid *syntax, Z_RecordComposition *comp,
122 char **addinfo, char **stylesheet, char **schema,
123 char **backend_type, char **backend_charset,
124 char **usemarcon_ini_stage1, char **usemarcon_ini_stage2);
126 void target_authentication(const char *name,
130 int client_authentication(const char *name,
131 const char *user, const char *group,
132 const char *password,
133 const char *peer_IP);
134 char *get_explain_doc(ODR odr, const char *name, const char *db,
136 const char *get_explain_name(const char *db, const char **backend_db);
138 void operator=(const Yaz_ProxyConfig &conf);
139 class Yaz_ProxyConfigP *m_cp;
142 class Yaz_ProxyClient : public yazpp_1::Z_Assoc {
143 friend class Yaz_Proxy;
144 Yaz_ProxyClient(yazpp_1::IPDU_Observable *the_PDU_Observable,
147 void recv_GDU(Z_GDU *apdu, int len);
148 void recv_Z_PDU(Z_APDU *apdu, int len);
149 void recv_HTTP_response(Z_HTTP_Response *apdu, int len);
150 IPDU_Observer* sessionNotify
151 (yazpp_1::IPDU_Observable *the_PDU_Observable, int fd);
155 void timeoutNotify();
156 void connectNotify();
157 int send_to_target(Z_APDU *apdu);
158 const char *get_session_str();
160 Yaz_ProxyClient *m_next;
161 Yaz_ProxyClient **m_prev;
163 yazpp_1::Yaz_Z_Query *m_last_query;
164 yazpp_1::Yaz_Z_Databases m_last_databases;
165 char *m_last_resultSetId;
167 int m_last_resultCount;
171 int m_resultSetStartPoint;
176 Z_APDU *m_initResponse;
177 Z_Options *m_initResponse_options;
178 Z_ProtocolVersion *m_initResponse_version;
179 int m_initResponse_preferredMessageSize;
180 int m_initResponse_maximumRecordSize;
181 yazpp_1::RecordCache m_cache;
182 void pre_init_client();
183 int m_target_idletime;