]> git.ipfire.org Git - thirdparty/squid.git/blob - src/HttpHdrCc.cci
SourceFormat Enforcement
[thirdparty/squid.git] / src / HttpHdrCc.cci
1 /*
2 * Copyright (C) 1996-2014 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 /* DEBUG: section 65 HTTP Cache Control Header */
10
11 #include "Debug.h"
12 #include "defines.h"
13
14 bool
15 HttpHdrCc::isSet(http_hdr_cc_type id) const
16 {
17 assert(id>=CC_PUBLIC && id < CC_ENUM_END);
18 return EBIT_TEST(mask,id);
19 }
20
21 void
22 HttpHdrCc::setMask(http_hdr_cc_type id, bool newval)
23 {
24 if (newval)
25 EBIT_SET(mask,id);
26 else
27 EBIT_CLR(mask,id);
28 }
29
30 /// set a data member to a new value, and set the corresponding mask-bit.
31 /// if setting is false, then the mask-bit is cleared.
32 void
33 HttpHdrCc::setValue(int32_t &value, int32_t new_value, http_hdr_cc_type hdr, bool setting)
34 {
35 if (setting) {
36 if (new_value < 0) {
37 debugs(65,3,HERE << "rejecting negative-value Cache-Control directive " << hdr
38 << " value " << new_value );
39 return;
40 }
41 } else {
42 new_value=-1; //rely on the convention that "unknown" is -1
43 }
44
45 value=new_value;
46 setMask(hdr,setting);
47 }
48