]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/Notes.cc
2 * SQUID Web Proxy Cache http://www.squid-cache.org/
3 * ----------------------------------------------------------
5 * Squid is the result of efforts by numerous individuals from
6 * the Internet community; see the CONTRIBUTORS file for full
7 * details. Many organizations have provided support for Squid's
8 * development; see the SPONSORS file for full details. Squid is
9 * Copyrighted (C) 2001 by the Regents of the University of
10 * California; see the COPYRIGHT file for full details. Squid
11 * incorporates software developed and/or copyrighted by other
12 * sources; see the CREDITS file for full details.
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
32 #include "acl/FilledChecklist.h"
33 #include "acl/Gadgets.h"
34 #include "ConfigParser.h"
35 #include "HttpRequest.h"
36 #include "HttpReply.h"
37 #include "SquidConfig.h"
45 aclDestroyAclList(&aclList
);
49 Note::addValue(const String
&value
)
51 Value::Pointer v
= new Value(value
);
57 Note::match(HttpRequest
*request
, HttpReply
*reply
)
60 typedef Values::iterator VLI
;
61 ACLFilledChecklist
ch(NULL
, request
, NULL
);
63 ch
.reply
= HTTPMSGLOCK(reply
);
65 for (VLI i
= values
.begin(); i
!= values
.end(); ++i
) {
66 const int ret
= ch
.fastCheck((*i
)->aclList
);
67 debugs(93, 5, HERE
<< "Check for header name: " << key
<< ": " << (*i
)->value
68 <<", HttpRequest: " << request
<< " HttpReply: " << reply
<< " matched: " << ret
);
69 if (ret
== ACCESS_ALLOWED
)
70 return (*i
)->value
.termedBuf();
76 Notes::findByName(const String
¬eKey
) const
78 typedef Notes::NotesList::const_iterator AMLI
;
79 for (AMLI i
= notes
.begin(); i
!= notes
.end(); ++i
) {
80 if ((*i
)->key
== noteKey
)
84 return Note::Pointer();
88 Notes::add(const String
¬eKey
, const String
¬eValue
)
90 Note::Pointer key
= add(noteKey
);
91 key
->addValue(noteValue
);
95 Notes::add(const String
¬eKey
)
97 Note::Pointer note
= findByName(noteKey
);
99 note
= new Note(noteKey
);
100 notes
.push_back(note
);
106 Notes::parse(ConfigParser
&parser
)
109 ConfigParser::ParseString(&key
);
110 ConfigParser::ParseQuotedString(&value
);
111 Note::Pointer note
= add(key
);
112 Note::Value::Pointer noteValue
= note
->addValue(value
);
113 aclParseAclList(parser
, ¬eValue
->aclList
);
116 for (int i
= 0; blacklisted
[i
] != NULL
; ++i
) {
117 if (note
->key
.caseCmp(blacklisted
[i
]) == 0) {
118 fatalf("%s:%d: meta key \"%s\" is a reserved %s name",
119 cfg_filename
, config_lineno
, note
->key
.termedBuf(),
129 Notes::dump(StoreEntry
*entry
, const char *key
)
131 typedef Notes::NotesList::iterator AMLI
;
132 for (AMLI m
= notes
.begin(); m
!= notes
.end(); ++m
) {
133 typedef Note::Values::iterator VLI
;
134 for (VLI v
=(*m
)->values
.begin(); v
!= (*m
)->values
.end(); ++v
) {
135 storeAppendPrintf(entry
, "%s " SQUIDSTRINGPH
" %s",
136 key
, SQUIDSTRINGPRINT((*m
)->key
), ConfigParser::QuoteString((*v
)->value
));
137 dump_acl_list(entry
, (*v
)->aclList
);
138 storeAppendPrintf(entry
, "\n");