+
+class Yaz_ProxyModule {
+private:
+ void *m_dl_handle; /* dlopen/close handle */
+ Yaz_ProxyModule_entry *m_entry;
+ Yaz_ProxyModule *m_next;
+ void *m_user_handle; /* user handle */
+public:
+ Yaz_ProxyModule(void *dl_handle, Yaz_ProxyModule_entry *ent,
+ Yaz_ProxyModule *next);
+ ~Yaz_ProxyModule();
+
+ Yaz_ProxyModule *get_next() { return m_next; };
+ int is_module(const char *name);
+ int authenticate(const char *target_name, void *element_ptr,
+ const char *user, const char *group, const char *password);
+};
+
+int Yaz_ProxyModule::is_module(const char *type)
+{
+ if (!type || !strcmp(m_entry->module_name, type))
+ return 1;
+ return 0;
+}
+
+Yaz_ProxyModule::Yaz_ProxyModule(void *dl_handle, Yaz_ProxyModule_entry *ent,
+ Yaz_ProxyModule *next)
+{
+ m_dl_handle = dl_handle;
+ m_entry = ent;
+ m_next = next;
+ m_user_handle = 0;
+ if (m_entry->int_version == 0)
+ {
+ struct Yaz_ProxyModule_int0 *int0 =
+ reinterpret_cast<Yaz_ProxyModule_int0 *>(m_entry->fl);
+ if (int0->init)
+ m_user_handle = (*int0->init)();
+ }
+}
+
+Yaz_ProxyModule::~Yaz_ProxyModule()
+{
+ if (m_entry->int_version == 0)
+ {
+ struct Yaz_ProxyModule_int0 *int0 =
+ reinterpret_cast<Yaz_ProxyModule_int0 *>(m_entry->fl);
+ if (int0->destroy)
+ (*int0->destroy)(m_user_handle);
+ }
+#if HAVE_DLFCN_H
+ dlclose(m_dl_handle);
+#endif
+}
+
+int Yaz_ProxyModule::authenticate(const char *name,
+ void *element_ptr,
+ const char *user, const char *group,
+ const char *password)
+{
+ if (m_entry->int_version == 0)
+ {
+ struct Yaz_ProxyModule_int0 *int0 =
+ reinterpret_cast<Yaz_ProxyModule_int0 *>(m_entry->fl);
+
+ if (!int0->authenticate)
+ return YAZPROXY_RET_NOT_ME;
+ return (*int0->authenticate)(m_user_handle, name, element_ptr,
+ user, group, password);
+ }
+ return YAZPROXY_RET_NOT_ME;
+}
+
+class Yaz_ProxyConfigP {
+ friend class Yaz_ProxyConfig;
+
+ Yaz_ProxyModule *m_modules;
+
+ int mycmp(const char *hay, const char *item, size_t len);
+ int match_list(int v, const char *m);
+ int atoi_l(const char **cp);
+#if HAVE_XSLT
+ void load_modules(void);
+ void unload_modules(void);
+ 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,
+ const char **negotiation_charset,
+ const char **negotiation_lang,
+ const char **query_charset);
+ 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);
+ int get_explain_ptr(const char *host, const char *db,
+ xmlNodePtr *ptr_target, xmlNodePtr *ptr_explain);
+#endif
+ Yaz_ProxyConfigP();
+ ~Yaz_ProxyConfigP();
+};
+
+Yaz_ProxyConfigP::Yaz_ProxyConfigP()