From: Adam Dickmeiss Date: Tue, 9 Oct 2012 13:50:27 +0000 (+0200) Subject: auth_simple: get_user a static function X-Git-Tag: v1.3.49~3 X-Git-Url: http://lists.indexdata.dk/?a=commitdiff_plain;h=5482e353c65fea5e44b6c68c6975e6dd58e6d508;p=metaproxy-moved-to-github.git auth_simple: get_user a static function rather than member function. Fixes compilation errors on some platforms. --- 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; }; } }