From: Kinkie Date: Sun, 29 Jun 2008 20:45:58 +0000 (+0200) Subject: Yet more refactoring X-Git-Tag: SQUID_3_1_0_1~49^2~143^2~53^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5d970c4cde0be0ab6540d33856ea05a1c53dcc61;p=thirdparty%2Fsquid.git Yet more refactoring --- diff --git a/src/CacheManager.h b/src/CacheManager.h index 2a5397233a..ec38f63f8b 100644 --- a/src/CacheManager.h +++ b/src/CacheManager.h @@ -100,11 +100,14 @@ public: virtual void Start(int fd, HttpRequest * request, StoreEntry * entry); static CacheManager* GetInstance(); + const char *ActionProtection(const CacheManagerAction * at); //needs to be called from C protected: CacheManager(); virtual cachemgrStateData* ParseUrl(const char *url); virtual void ParseHeaders(cachemgrStateData * mgr, const HttpRequest * request); + int CheckPassword(cachemgrStateData * mgr); + char *PasswdGet(cachemgr_passwd *, const char *); private: static CacheManager* instance; diff --git a/src/cache_manager.cc b/src/cache_manager.cc index d0cc60bf6d..4284bd4adc 100644 --- a/src/cache_manager.cc +++ b/src/cache_manager.cc @@ -52,10 +52,7 @@ static CacheManagerAction *cachemgrFindAction(const char *action); -static int cachemgrCheckPassword(cachemgrStateData *); static void cachemgrStateFree(cachemgrStateData * mgr); -static char *cachemgrPasswdGet(cachemgr_passwd *, const char *); -static const char *cachemgrActionProtection(const CacheManagerAction * at); static OBJH cachemgrShutdown; static OBJH cachemgrReconfigure; static OBJH cachemgrMenu; @@ -151,7 +148,7 @@ CacheManager::ParseUrl(const char *url) debugs(16, 1, "CacheManager::ParseUrl: action '" << request << "' not found"); return NULL; } else { - prot = cachemgrActionProtection(a); + prot = ActionProtection(a); if (!strcmp(prot, "disabled") || !strcmp(prot, "hidden")) { debugs(16, 1, "CacheManager::ParseUrl: action '" << request << "' is " << prot); @@ -210,10 +207,10 @@ CacheManager::ParseHeaders(cachemgrStateData * mgr, const HttpRequest * request) \retval 1 if mgr->password is "disable" \retval !0 if mgr->password does not match configured password */ -static int -cachemgrCheckPassword(cachemgrStateData * mgr) +int +CacheManager::CheckPassword(cachemgrStateData * mgr) { - char *pwd = cachemgrPasswdGet(Config.passwd_list, mgr->action); + char *pwd = PasswdGet(Config.passwd_list, mgr->action); CacheManagerAction *a = cachemgrFindAction(mgr->action); assert(a != NULL); @@ -272,7 +269,7 @@ CacheManager::Start(int fd, HttpRequest * request, StoreEntry * entry) /* Check password */ - if (cachemgrCheckPassword(mgr) != 0) { + if (CheckPassword(mgr) != 0) { /* build error message */ ErrorState *err; HttpReply *rep; @@ -374,12 +371,12 @@ cachemgrOfflineToggle(StoreEntry * sentry) } /// \ingroup CacheManagerInternal -static const char * -cachemgrActionProtection(const CacheManagerAction * at) +const char * +CacheManager::ActionProtection(const CacheManagerAction * at) { char *pwd; assert(at); - pwd = cachemgrPasswdGet(Config.passwd_list, at->action); + pwd = PasswdGet(Config.passwd_list, at->action); if (!pwd) return at->flags.pw_req ? "hidden" : "public"; @@ -401,13 +398,13 @@ cachemgrMenu(StoreEntry * sentry) for (a = ActionTable; a != NULL; a = a->next) { storeAppendPrintf(sentry, " %-22s\t%-32s\t%s\n", - a->action, a->desc, cachemgrActionProtection(a)); + a->action, a->desc, CacheManager::GetInstance()->ActionProtection(a)); } } /// \ingroup CacheManagerInternal -static char * -cachemgrPasswdGet(cachemgr_passwd * a, const char *action) +char * +CacheManager::PasswdGet(cachemgr_passwd * a, const char *action) { wordlist *w;