static void
dump_cachemgrpasswd(StoreEntry * entry, const char *name, Mgr::ActionPasswordList * list)
{
- wordlist *w;
-
- while (list != NULL) {
+ while (list) {
if (strcmp(list->passwd, "none") && strcmp(list->passwd, "disable"))
storeAppendPrintf(entry, "%s XXXXXXXXXX", name);
else
storeAppendPrintf(entry, "%s %s", name, list->passwd);
- for (w = list->actions; w != NULL; w = w->next) {
- storeAppendPrintf(entry, " %s", w->key);
- }
+ for (auto w : list->actions)
+ entry->appendf(" " SQUIDSBUFPH, SQUIDSBUFPRINT(w));
storeAppendPrintf(entry, "\n");
list = list->next;
static void
parse_cachemgrpasswd(Mgr::ActionPasswordList ** head)
{
- char *passwd = NULL;
- wordlist *actions = NULL;
- Mgr::ActionPasswordList *p;
- Mgr::ActionPasswordList **P;
+ char *passwd = nullptr;
parse_string(&passwd);
- parse_wordlist(&actions);
- p = new Mgr::ActionPasswordList;
+
+ Mgr::ActionPasswordList *p = new Mgr::ActionPasswordList;
p->passwd = passwd;
- p->actions = actions;
+ while (char *token = ConfigParser::NextQuotedToken())
+ p->actions.push_back(SBuf(token));
+
+ Mgr::ActionPasswordList **P;
for (P = head; *P; P = &(*P)->next) {
/*
* See if any of the actions from this line already have a
* requested action. Thus, we should warn users who might
* think they can have two passwords for the same action.
*/
- wordlist *w;
- wordlist *u;
-
- for (w = (*P)->actions; w; w = w->next) {
- for (u = actions; u; u = u->next) {
- if (strcmp(w->key, u->key))
+ for (const auto &w : (*P)->actions) {
+ for (const auto &u : p->actions) {
+ if (w != u)
continue;
- debugs(0, DBG_CRITICAL, "WARNING: action '" << u->key << "' (line " << config_lineno << ") already has a password");
+ debugs(0, DBG_PARSE_NOTE(1), "ERROR: action '" << u << "' (line " << config_lineno << ") already has a password");
}
}
}
static void
free_cachemgrpasswd(Mgr::ActionPasswordList ** head)
{
- Mgr::ActionPasswordList *p;
-
- while ((p = *head) != NULL) {
- *head = p->next;
- xfree(p->passwd);
- wordlistDestroy(&p->actions);
- xfree(p);
- }
+ delete *head;
+ *head = nullptr;
}
static void
char *
CacheManager::PasswdGet(Mgr::ActionPasswordList * a, const char *action)
{
- wordlist *w;
-
- while (a != NULL) {
- for (w = a->actions; w != NULL; w = w->next) {
- if (0 == strcmp(w->key, action))
+ while (a) {
+ for (auto &w : a->actions) {
+ if (w.cmp(action) == 0)
return a->passwd;
- if (0 == strcmp(w->key, "all"))
+ static const SBuf allAction("all");
+ if (w == allAction)
return a->passwd;
}