Handle multiple input PDU packages using GDU class of YAZ++ 1.0.
[yazproxy-moved-to-github.git] / src / modules.cpp
index 4e7f473..4d00b66 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: modules.cpp,v 1.1 2005-05-30 20:09:21 adam Exp $
+/* $Id: modules.cpp,v 1.3 2005-06-21 18:46:04 adam Exp $
    Copyright (c) 1998-2005, Index Data.
 
 This file is part of the yaz-proxy.
@@ -25,6 +25,7 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 #endif
 
 #include <yaz/nmem.h>
+#include <yaz/log.h>
 #include <yazproxy/module.h>
 
 class Yaz_ProxyModule {
@@ -42,7 +43,8 @@ public:
     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);
+                    const char *user, const char *group, const char *password,
+                    const char *peer_IP);
 };
 
 int Yaz_ProxyModule::is_module(const char *name)
@@ -85,7 +87,8 @@ Yaz_ProxyModule::~Yaz_ProxyModule()
 int Yaz_ProxyModule::authenticate(const char *name,
                                  void *element_ptr,
                                  const char *user, const char *group,
-                                 const char *password)
+                                 const char *password,
+                                 const char *peer_IP)
 {
     if (m_entry->int_version == 0)
     {
@@ -95,7 +98,7 @@ int Yaz_ProxyModule::authenticate(const char *name,
        if (!int0->authenticate)
            return YAZPROXY_RET_NOT_ME;
        return (*int0->authenticate)(m_user_handle, name, element_ptr,
-                                    user, group, password);
+                                    user, group, password, peer_IP);
     }
     return YAZPROXY_RET_NOT_ME;
 }
@@ -103,6 +106,7 @@ int Yaz_ProxyModule::authenticate(const char *name,
 Yaz_ProxyModules::Yaz_ProxyModules()
 {
     m_list = 0;
+    m_no_open = 0;
 }
 
 
@@ -118,6 +122,7 @@ void Yaz_ProxyModules::unload_modules()
     {
        Yaz_ProxyModule *m_next = m->get_next();
        delete m;
+       m_no_open--;
        m = m_next;
     }
     m_list = 0;
@@ -128,7 +133,8 @@ int Yaz_ProxyModules::authenticate(const char *module_name,
                                   const char *target_name, void *element_ptr,
                                   const char *user,
                                   const char *group,
-                                  const char *password)
+                                  const char *password,
+                                  const char *peer_IP)
 {
     int ret = YAZPROXY_RET_NOT_ME;
     Yaz_ProxyModule *m = m_list;
@@ -137,7 +143,8 @@ int Yaz_ProxyModules::authenticate(const char *module_name,
        if (m->is_module(module_name))
        {
            ret = m->authenticate(target_name, element_ptr,
-                                      user, group, password);
+                                 user, group, password,
+                                 peer_IP);
            if (ret != YAZPROXY_RET_NOT_ME)
                break;
        }
@@ -161,6 +168,8 @@ int Yaz_ProxyModules::add_module(const char *fname)
                                                     m_list);
            m_list = m;
 
+           m_no_open++;
+           yaz_log(YLOG_LOG, "Loaded module no_open=%d", m_no_open);
            return 0;
        }
        else