]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/acl/IntRange.cc
2 * Copyright (C) 1996-2017 The Squid Software Foundation and contributors
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.
9 /* DEBUG: section 28 Access Control */
12 #include "acl/IntRange.h"
14 #include "ConfigParser.h"
22 while (char *a
= ConfigParser::strtokFile()) {
23 char *b
= strchr(a
, '-');
24 unsigned short port1
, port2
;
39 RangeType
temp(port1
, port2
+1);
40 ranges
.push_back(temp
);
42 debugs(28, DBG_CRITICAL
, "ACLIntRange::parse: Invalid port value");
49 ACLIntRange::empty() const
51 return ranges
.empty();
55 ACLIntRange::match(int i
)
57 RangeType
const toFind(i
, i
+1);
58 for (std::list
<RangeType
>::const_iterator iter
= ranges
.begin(); iter
!= ranges
.end(); ++iter
) {
59 const RangeType
& element
= *iter
;
60 RangeType result
= element
.intersection(toFind
);
70 ACLIntRange::clone() const
73 fatal("ACLIntRange::clone: attempt to clone used ACL");
75 return new ACLIntRange(*this);
78 ACLIntRange::~ACLIntRange()
82 ACLIntRange::dump() const
85 for (std::list
<RangeType
>::const_iterator iter
= ranges
.begin(); iter
!= ranges
.end(); ++iter
) {
87 const RangeType
& element
= *iter
;
89 if (element
.size() == 1)
90 sb
.Printf("%d", element
.start
);
92 sb
.Printf("%d-%d", element
.start
, element
.end
-1);