/*
- * $Id$
+ * Copyright (C) 1996-2015 The Squid Software Foundation and contributors
*
- * DEBUG: section 28 Access Control
- * AUTHOR: Duane Wessels
- *
- * SQUID Web Proxy Cache http://www.squid-cache.org/
- * ----------------------------------------------------------
- *
- * Squid is the result of efforts by numerous individuals from
- * the Internet community; see the CONTRIBUTORS file for full
- * details. Many organizations have provided support for Squid's
- * development; see the SPONSORS file for full details. Squid is
- * Copyrighted (C) 2001 by the Regents of the University of
- * California; see the COPYRIGHT file for full details. Squid
- * incorporates software developed and/or copyrighted by other
- * sources; see the CREDITS file for full details.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
- *
- *
- * Copyright (c) 2003, Robert Collins <robertc@squid-cache.org>
+ * Squid software is distributed under GPLv2+ license and includes
+ * contributions from numerous individuals and organizations.
+ * Please see the COPYING and CONTRIBUTORS files for details.
*/
+/* DEBUG: section 28 Access Control */
+
#include "squid.h"
-#include "acl/TimeData.h"
#include "acl/Checklist.h"
+#include "acl/TimeData.h"
+#include "cache_cf.h"
+#include "Debug.h"
#include "wordlist.h"
ACLTimeData::ACLTimeData () : weekbits (0), start (0), stop (0), next (NULL) {}
if (when != last_when) {
last_when = when;
-
- xmemcpy(&tm, localtime(&when), sizeof(struct tm));
+ memcpy(&tm, localtime(&when), sizeof(struct tm));
}
t = (time_t) (tm.tm_hour * 60 + tm.tm_min);
return 0;
}
-wordlist *
-ACLTimeData::dump()
+SBufList
+ACLTimeData::dump() const
{
- wordlist *W = NULL;
- char buf[128];
- ACLTimeData *t = this;
+ SBufList sl;
+ const ACLTimeData *t = this;
while (t != NULL) {
- snprintf(buf, sizeof(buf), "%c%c%c%c%c%c%c %02d:%02d-%02d:%02d",
+ SBuf s;
+ s.Printf("%c%c%c%c%c%c%c %02d:%02d-%02d:%02d",
t->weekbits & ACL_SUNDAY ? 'S' : '-',
t->weekbits & ACL_MONDAY ? 'M' : '-',
t->weekbits & ACL_TUESDAY ? 'T' : '-',
t->weekbits & ACL_FRIDAY ? 'F' : '-',
t->weekbits & ACL_SATURDAY ? 'A' : '-',
t->start / 60, t->start % 60, t->stop / 60, t->stop % 60);
- wordlistAdd(&W, buf);
+ sl.push_back(s);
t = t->next;
}
- return W;
+ return sl;
}
void
ACLTimeData::parse()
{
ACLTimeData **Tail;
- long weekbits = 0;
+ long parsed_weekbits = 0;
for (Tail = &next; *Tail; Tail = &((*Tail)->next));
ACLTimeData *q = NULL;
switch (*t++) {
case 'S':
- weekbits |= ACL_SUNDAY;
+ parsed_weekbits |= ACL_SUNDAY;
break;
case 'M':
- weekbits |= ACL_MONDAY;
+ parsed_weekbits |= ACL_MONDAY;
break;
case 'T':
- weekbits |= ACL_TUESDAY;
+ parsed_weekbits |= ACL_TUESDAY;
break;
case 'W':
- weekbits |= ACL_WEDNESDAY;
+ parsed_weekbits |= ACL_WEDNESDAY;
break;
case 'H':
- weekbits |= ACL_THURSDAY;
+ parsed_weekbits |= ACL_THURSDAY;
break;
case 'F':
- weekbits |= ACL_FRIDAY;
+ parsed_weekbits |= ACL_FRIDAY;
break;
case 'A':
- weekbits |= ACL_SATURDAY;
+ parsed_weekbits |= ACL_SATURDAY;
break;
case 'D':
- weekbits |= ACL_WEEKDAYS;
+ parsed_weekbits |= ACL_WEEKDAYS;
break;
case '-':
break;
default:
- debugs(28, 0, "" << cfg_filename << " line " << config_lineno <<
+ debugs(28, DBG_CRITICAL, "" << cfg_filename << " line " << config_lineno <<
": " << config_input_line);
- debugs(28, 0, "aclParseTimeSpec: Bad Day '" << *t << "'" );
+ debugs(28, DBG_CRITICAL, "aclParseTimeSpec: Bad Day '" << *t << "'" );
break;
}
}
/* assume its time-of-day spec */
if ((sscanf(t, "%d:%d-%d:%d", &h1, &m1, &h2, &m2) < 4) || (!((h1 >= 0 && h1 < 24) && ((h2 >= 0 && h2 < 24) || (h2 == 24 && m2 == 0)) && (m1 >= 0 && m1 < 60) && (m2 >= 0 && m2 < 60)))) {
- debugs(28, 0, "aclParseTimeSpec: Bad time range '" << t << "'");
+ debugs(28, DBG_CRITICAL, "aclParseTimeSpec: Bad time range '" << t << "'");
self_destruct();
if (q != this)
return;
}
- if ((weekbits == 0) && (start == 0) && (stop == 0))
+ if ((parsed_weekbits == 0) && (start == 0) && (stop == 0))
q = this;
else
q = new ACLTimeData;
q->stop = h2 * 60 + m2;
- q->weekbits = weekbits;
+ q->weekbits = parsed_weekbits;
- weekbits = 0;
+ parsed_weekbits = 0;
if (q->start > q->stop) {
- debugs(28, 0, "aclParseTimeSpec: Reversed time range");
+ debugs(28, DBG_CRITICAL, "aclParseTimeSpec: Reversed time range");
self_destruct();
if (q != this)
}
}
- if (weekbits) {
+ if (parsed_weekbits) {
- if ((weekbits == 0) && (start == 0) && (stop == 0))
- q = this;
- else
- q = new ACLTimeData;
+ q = new ACLTimeData;
q->start = 0 * 60 + 0;
q->stop = 24 * 60 + 0;
- q->weekbits = weekbits;
+ q->weekbits = parsed_weekbits;
- if (q != this) {
- *(Tail) = q;
- Tail = &q->next;
- }
+ *(Tail) = q;
+ Tail = &q->next;
}
}
{
return new ACLTimeData(*this);
}
+