From: Kinkie Date: Thu, 3 Jul 2008 15:49:47 +0000 (+0200) Subject: Moved Action initialization to object constructors. X-Git-Tag: SQUID_3_1_0_1~49^2~143^2~52 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2f53e9043801f9d71c152b44dad3c7ebacf9a571;p=thirdparty%2Fsquid.git Moved Action initialization to object constructors. --- diff --git a/src/CacheManager.h b/src/CacheManager.h index 832d97a92b..0437ec31ac 100644 --- a/src/CacheManager.h +++ b/src/CacheManager.h @@ -35,6 +35,7 @@ #define SQUID_CACHEMANAGER_H #include "squid.h" +#include /** \defgroup CacheManagerAPI Cache Manager API @@ -51,14 +52,22 @@ public: unsigned int pw_req:1; unsigned int atomic:1; } flags; + virtual ~CacheManagerAction(); + CacheManagerAction(char const *anAction, char const *aDesc, unsigned int isPwReq, unsigned int isAtomic); + CacheManagerAction *next; - virtual ~CacheManagerAction() { } }; +/** + \ingroup CacheManagerAPI + * wrapper allowing c-style callbacks to be used. Arguments are supposed to + * managed by the caller, as they will be copied over by the constructor. + */ class CacheManagerActionLegacy : public CacheManagerAction { public: OBJH *handler; virtual void run (StoreEntry *sentry); + CacheManagerActionLegacy(char const *anAction, char const *aDesc, unsigned int isPwReq, unsigned int isAtomic, OBJH *aHandler); }; class CacheManagerShutdownAction : public CacheManagerAction { @@ -66,14 +75,9 @@ public: virtual void run (StoreEntry *sentry); }; -/// \ingroup CacheManagerInternal -typedef struct -{ - StoreEntry *entry; - char *action; - char *user_name; - char *passwd; -} cachemgrStateData; +class CacheManagerActionList : public std::list { + +}; /// \ingroup CacheManagerInternal typedef struct diff --git a/src/cache_manager.cc b/src/cache_manager.cc index 9a616c7b78..9c8a6dab5f 100644 --- a/src/cache_manager.cc +++ b/src/cache_manager.cc @@ -81,13 +81,8 @@ CacheManager::registerAction(char const * action, char const * desc, OBJH * hand } assert (strstr (" ", action) == NULL); - a = new CacheManagerActionLegacy; - a->action = xstrdup(action); - a->desc = xstrdup(desc); - a->handler = handler; - a->flags.pw_req = pw_req_flag; - a->flags.atomic = atomic; - a->next=0; + a = new CacheManagerActionLegacy(action,desc,pw_req_flag,atomic,handler); + a->next=0; for (A = &ActionTable; *A; A = &(*A)->next); *A = a; @@ -436,3 +431,18 @@ void CacheManagerActionLegacy::run(StoreEntry *sentry) handler(sentry); } +CacheManagerAction::CacheManagerAction(char const *anAction, char const *aDesc, unsigned int isPwReq, unsigned int isAtomic) +{ + flags.pw_req = isPwReq; + flags.atomic = isAtomic; + action = xstrdup (anAction); + desc = xstrdup (aDesc); +} +CacheManagerAction::~CacheManagerAction() { + xfree(action); + xfree(desc); +} + +CacheManagerActionLegacy::CacheManagerActionLegacy(char const *anAction, char const *aDesc, unsigned int isPwReq, unsigned int isAtomic, OBJH *aHandler) : CacheManagerAction(anAction, aDesc, isPwReq, isAtomic), handler(aHandler) +{ +}