]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/acl/IntRange.cc
2 * Copyright (C) 1996-2015 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"
23 while ((a
= strtokFile())) {
24 char *b
= strchr(a
, '-');
25 unsigned short port1
, port2
;
40 RangeType
temp(port1
, port2
+1);
41 ranges
.push_back(temp
);
43 debugs(28, DBG_CRITICAL
, "ACLIntRange::parse: Invalid port value");
50 ACLIntRange::empty() const
52 return ranges
.empty();
56 ACLIntRange::match(int i
)
58 RangeType
const toFind(i
, i
+1);
59 for (std::list
<RangeType
>::const_iterator iter
= ranges
.begin(); iter
!= ranges
.end(); ++iter
) {
60 const RangeType
& element
= *iter
;
61 RangeType result
= element
.intersection(toFind
);
71 ACLIntRange::clone() const
74 fatal("ACLIntRange::clone: attempt to clone used ACL");
76 return new ACLIntRange(*this);
79 ACLIntRange::~ACLIntRange()
83 ACLIntRange::dump() const
86 for (std::list
<RangeType
>::const_iterator iter
= ranges
.begin(); iter
!= ranges
.end(); ++iter
) {
88 const RangeType
& element
= *iter
;
90 if (element
.size() == 1)
91 sb
.Printf("%d", element
.start
);
93 sb
.Printf("%d-%d", element
.start
, element
.end
-1);