auth_simple: get_user a static function
authorAdam Dickmeiss <adam@indexdata.dk>
Tue, 9 Oct 2012 13:50:27 +0000 (15:50 +0200)
committerAdam Dickmeiss <adam@indexdata.dk>
Tue, 9 Oct 2012 13:50:27 +0000 (15:50 +0200)
rather than member function. Fixes compilation errors on some
platforms.

src/filter_auth_simple.cpp
src/filter_auth_simple.hpp

index 93f5f18..c2d677f 100644 (file)
@@ -72,6 +72,36 @@ yf::AuthSimple::~AuthSimple()
 static void die(std::string s) { throw mp::filter::FilterException(s); }
 
 
+static std::string get_user(Z_InitRequest *initReq, std::string &password)
+{
+    Z_IdAuthentication *auth = initReq->idAuthentication;
+    std::string user;
+    if (auth)
+    {
+        const char *cp;
+        switch (auth->which)
+        {
+        case Z_IdAuthentication_open:
+            cp = strchr(auth->u.open, '/');
+            if (cp)
+            {
+                user.assign(auth->u.open, cp - auth->u.open);
+                password.assign(cp + 1);
+            }
+            else
+                user = auth->u.open;
+            break;
+        case Z_IdAuthentication_idPass:
+            if (auth->u.idPass->userId)
+                user = auth->u.idPass->userId;
+            if (auth->u.idPass->password)
+                password = auth->u.idPass->password;
+            break;
+        }
+    }
+    return user;
+}
+
 // Read XML config.. Put config info in m_p.
 void mp::filter::AuthSimple::configure(const xmlNode * ptr, bool test_only,
                                        const char *path)
@@ -338,37 +368,6 @@ static void reject_init(mp::Package &package, int err, const char *addinfo) {
     package.session().close();
 }
 
-std::string yf::AuthSimple::get_user(Z_InitRequest *initReq,
-                                     std::string &password) const
-{
-    Z_IdAuthentication *auth = initReq->idAuthentication;
-    std::string user;
-    if (auth)
-    {
-        const char *cp;
-        switch (auth->which)
-        {
-        case Z_IdAuthentication_open:
-            cp = strchr(auth->u.open, '/');
-            if (cp)
-            {
-                user.assign(auth->u.open, cp - auth->u.open);
-                password.assign(cp + 1);
-            }
-            else
-                user = auth->u.open;
-            break;
-        case Z_IdAuthentication_idPass:
-            if (auth->u.idPass->userId)
-                user = auth->u.idPass->userId;
-            if (auth->u.idPass->password)
-                password = auth->u.idPass->password;
-            break;
-        }
-    }
-    return user;
-}
-
 void yf::AuthSimple::check_targets(mp::Package & package) const
 {
     Z_InitRequest *initReq = package.request().get()->u.z3950->u.initRequest;
index 5888705..5565419 100644 (file)
@@ -41,8 +41,6 @@ namespace metaproxy_1 {
             void process_search(metaproxy_1::Package & package) const;
             void process_scan(metaproxy_1::Package & package) const;
             void check_targets(metaproxy_1::Package & package) const;
-            std::string get_user(Z_InitRequest *initReq, std::string &password)
-                const;
         };
     }
 }