From 5482e353c65fea5e44b6c68c6975e6dd58e6d508 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Tue, 9 Oct 2012 15:50:27 +0200 Subject: [PATCH] auth_simple: get_user a static function rather than member function. Fixes compilation errors on some platforms. --- src/filter_auth_simple.cpp | 61 ++++++++++++++++++++++---------------------- src/filter_auth_simple.hpp | 2 -- 2 files changed, 30 insertions(+), 33 deletions(-) diff --git a/src/filter_auth_simple.cpp b/src/filter_auth_simple.cpp index 93f5f18..c2d677f 100644 --- a/src/filter_auth_simple.cpp +++ b/src/filter_auth_simple.cpp @@ -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; diff --git a/src/filter_auth_simple.hpp b/src/filter_auth_simple.hpp index 5888705..5565419 100644 --- a/src/filter_auth_simple.hpp +++ b/src/filter_auth_simple.hpp @@ -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; }; } } -- 1.7.10.4