]> git.ipfire.org Git - thirdparty/squid.git/blob - src/auth/SchemesConfig.cc
Bug 5343: Fix GCC v14 not finding std::find() (#1672)
[thirdparty/squid.git] / src / auth / SchemesConfig.cc
1 /*
2 * Copyright (C) 1996-2023 The Squid Software Foundation and contributors
3 *
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
7 */
8
9 #include "squid.h"
10 #include "auth/Config.h"
11 #include "fatal.h"
12 #include "parser/Tokenizer.h"
13
14 #include <algorithm>
15
16 static void
17 addUnique(const SBuf &scheme, std::vector<SBuf> &vec)
18 {
19 static const SBuf all("ALL");
20 if (scheme == all) {
21 for (const auto config: Auth::TheConfig.schemes)
22 addUnique(SBuf(config->type()), vec);
23 } else if (std::find(vec.begin(), vec.end(), scheme) == vec.end())
24 vec.push_back(scheme);
25 }
26
27 void
28 Auth::SchemesConfig::expand()
29 {
30 static const CharacterSet delimiters("delimiters", ",");
31 static const CharacterSet quotedDelimiters("quotedDelimiters", ", ");
32 const CharacterSet *resultDelimiters = quoted ? &quotedDelimiters : &delimiters;
33 std::vector<SBuf> expanded;
34 Parser::Tokenizer t(schemes);
35 SBuf scheme;
36 while (t.token(scheme, *resultDelimiters))
37 addUnique(scheme, expanded);
38 t.skipAllTrailing(CharacterSet::SP + CharacterSet::HTAB);
39 if (!t.remaining().isEmpty())
40 addUnique(t.remaining(), expanded);
41
42 authConfigs.clear();
43 transform(expanded.begin(), expanded.end(),
44 back_inserter(authConfigs), [](SBuf &s) {
45 return Auth::SchemeConfig::GetParsed(s.c_str());
46 });
47 }
48