]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Yet more refactoring
authorKinkie <kinkie@squid-cache.org>
Sun, 29 Jun 2008 20:45:58 +0000 (22:45 +0200)
committerKinkie <kinkie@squid-cache.org>
Sun, 29 Jun 2008 20:45:58 +0000 (22:45 +0200)
src/CacheManager.h
src/cache_manager.cc

index 2a5397233ad5af2edef4dbf2fa5ad121ea56f81d..ec38f63f8beae8c58693097aa1b4477469f35a6c 100644 (file)
@@ -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;
index d0cc60bf6df36940fec62d50971742dcb33d2b6d..4284bd4adc518657b20b3783f1fa7a05ec369871 100644 (file)
 
 
 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;