]> git.ipfire.org Git - thirdparty/squid.git/blame - src/HttpHdrCc.cci
SourceFormat Enforcement
[thirdparty/squid.git] / src / HttpHdrCc.cci
CommitLineData
9774b48e 1/*
4ac4a490 2 * Copyright (C) 1996-2017 The Squid Software Foundation and contributors
9774b48e 3 *
bbc27441
AJ
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.
9774b48e 7 */
582c2af2 8
bbc27441
AJ
9/* DEBUG: section 65 HTTP Cache Control Header */
10
582c2af2 11#include "Debug.h"
602d9612 12#include "defines.h"
582c2af2 13
f9517ad8 14bool
1da82544 15HttpHdrCc::isSet(HttpHdrCcType id) const
f9517ad8 16{
a242e34c 17 assert(id < HttpHdrCcType::CC_ENUM_END);
a45f2153 18 return EBIT_TEST(mask, static_cast<long>(id));
f9517ad8
FC
19}
20
cf7c2e94 21void
1da82544 22HttpHdrCc::setMask(HttpHdrCcType id, bool newval)
cf7c2e94 23{
f9517ad8 24 if (newval)
a45f2153 25 EBIT_SET(mask,static_cast<long>(id));
f9517ad8 26 else
a45f2153 27 EBIT_CLR(mask, static_cast<long>(id));
f9517ad8 28}
d74ad83f
FC
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.
32void
1da82544 33HttpHdrCc::setValue(int32_t &value, int32_t new_value, HttpHdrCcType hdr, bool setting)
d74ad83f
FC
34{
35 if (setting) {
c397963f
FC
36 if (new_value < 0) {
37 debugs(65,3,HERE << "rejecting negative-value Cache-Control directive " << hdr
77da1817 38 << " value " << new_value );
c397963f
FC
39 return;
40 }
d74ad83f
FC
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}
f53969cc 48