-
-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;
-}
-