Just code moves and documentation.
Solves the occasional build issues of copying time.cc for linking to
pinger and tools/ binaries. Which now link to the library.
src/store/Makefile
src/store/id_rewriters/Makefile
src/store/id_rewriters/file/Makefile
+ src/time/Makefile
test-suite/Makefile
tools/Makefile
tools/apparmor/Makefile
+++ /dev/null
-/*
- * Copyright (C) 1996-2022 The Squid Software Foundation and contributors
- *
- * Squid software is distributed under GPLv2+ license and includes
- * contributions from numerous individuals and organizations.
- * Please see the COPYING and CONTRIBUTORS files for details.
- */
-
-#ifndef _SQUID_RFC1123_H
-#define _SQUID_RFC1123_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-extern const char *mkhttpdlogtime(const time_t *);
-extern const char *mkrfc1123(time_t);
-extern time_t parse_rfc1123(const char *str);
-
-#ifdef __cplusplus
-}
-#endif
-#endif /* _SQUID_RFC1123_H */
-
#ifndef SQUID_UTIL_H
#define SQUID_UTIL_H
-#if HAVE_TIME_H
-#include <time.h>
-#endif
#if HAVE_ARPA_INET_H
#include <arpa/inet.h>
#endif
-SQUIDCEXTERN int tvSubUsec(struct timeval, struct timeval);
-SQUIDCEXTERN double tvSubDsec(struct timeval, struct timeval);
SQUIDCEXTERN void Tolower(char *);
-SQUIDCEXTERN time_t parse_iso3307_time(const char *buf);
-
SQUIDCEXTERN double xpercent(double part, double whole);
SQUIDCEXTERN int xpercentInt(double part, double whole);
SQUIDCEXTERN double xdiv(double nom, double denom);
Splay.cc \
getfullhostname.c \
heap.c \
- iso3307.c \
radix.c \
- rfc1123.c \
stub_memaccount.c \
util.c \
xusleep.c
}
}
-int
-tvSubUsec(struct timeval t1, struct timeval t2)
-{
- return (t2.tv_sec - t1.tv_sec) * 1000000 +
- (t2.tv_usec - t1.tv_usec);
-}
-
-double
-tvSubDsec(struct timeval t1, struct timeval t2)
-{
- return (double) (t2.tv_sec - t1.tv_sec) +
- (double) (t2.tv_usec - t1.tv_usec) / 1000000.0;
-}
-
/* somewhat safer calculation of %s */
double
xpercent(double part, double whole)
#include "fd.h"
#include "SquidConfig.h"
#include "SquidIpc.h"
-#include "SquidTime.h"
#include "StatCounters.h"
#include "Store.h"
#include "unlinkd.h"
diomsg.h
diskd_SOURCES = diskd.cc
-nodist_diskd_SOURCES = time.cc
diskd_LDADD = \
+ $(top_builddir)/src/time/libtime.la \
$(top_builddir)/lib/libmisccontainers.la \
$(top_builddir)/lib/libmiscencoding.la \
$(top_builddir)/lib/libmiscutil.la \
$(COMPAT_LIB) \
$(XTRA_LIBS)
-
-time.cc: $(top_srcdir)/src/time.cc
- cp $(top_srcdir)/src/time.cc time.cc
-
-CLEANFILES += time.cc
#define SQUID_DISKFILE_H
#include "base/RefCount.h"
-#include "SquidTime.h"
+#include "time/gadgets.h"
class IORequestor;
#include "DiskIO/DiskThreads/CommIO.h"
#include "DiskThreads.h"
#include "SquidConfig.h"
-#include "SquidTime.h"
#include "Store.h"
/*
#include "fd.h"
#include "mem/Pool.h"
#include "SquidConfig.h"
-#include "SquidTime.h"
#include "Store.h"
#include <cerrno>
#include "ipc/UdsOp.h"
#include "sbuf/SBuf.h"
#include "SquidConfig.h"
-#include "SquidTime.h"
#include "StatCounters.h"
#include "tools.h"
#include "debug/Stream.h"
#include "EventLoop.h"
#include "fatal.h"
-#include "SquidTime.h"
+#include "time/Engine.h"
EventLoop *EventLoop::Running = NULL;
}
void
-EventLoop::setTimeService(TimeEngine *engine)
+EventLoop::setTimeService(Time::Engine *engine)
{
timeService = engine;
}
#ifndef SQUID_EVENTLOOP_H
#define SQUID_EVENTLOOP_H
+#include "time/forward.h"
+
#include <vector>
#define EVENT_LOOP_TIMEOUT 1000 /* 1s timeout */
class AsyncEngine;
-class TimeEngine;
/** An event loop. An event loop is the core inner loop of squid.
* The event loop can be run until exit, or once. After it finishes control
/** set the time service. There can be only one time service set at any
* time. The time service is invoked on each loop
*/
- void setTimeService(TimeEngine *engine);
+ void setTimeService(Time::Engine *);
/** stop the event loop - it will finish the current loop and then return to the
* caller of run().
bool last_loop;
typedef std::vector<AsyncEngine *> engine_vector;
engine_vector engines;
- TimeEngine * timeService;
+ Time::Engine *timeService;
AsyncEngine * primaryEngine;
int loop_delay; /**< the delay to be given to the primary engine */
bool error; /**< has an error occurred in this loop */
#include "squid.h"
#include "ExternalACLEntry.h"
-#include "SquidTime.h"
+#include "time/gadgets.h"
/******************************************************************
* external_acl cache
#include "base/TextException.h"
#include "debug/Stream.h"
#include "FadingCounter.h"
-#include "SquidTime.h"
+#include "time/gadgets.h"
#include <cmath>
#include "ResolvedPeers.h"
#include "security/BlindPeerConnector.h"
#include "SquidConfig.h"
-#include "SquidTime.h"
#include "ssl/PeekingPeerConnector.h"
#include "Store.h"
#include "StoreClient.h"
#include "MemBuf.h"
#include "mgr/Registration.h"
#include "mime_header.h"
-#include "rfc1123.h"
#include "sbuf/StringConvert.h"
#include "SquidConfig.h"
#include "StatHist.h"
#include "Store.h"
#include "StrList.h"
#include "TimeOrTag.h"
+#include "time/gadgets.h"
#include "util.h"
#include <algorithm>
assert(any_registered_header(id));
assert(Http::HeaderLookupTable.lookup(id).type == Http::HdrFieldType::ftDate_1123); /* must be of an appropriate type */
assert(htime >= 0);
- addEntry(new HttpHeaderEntry(id, SBuf(), mkrfc1123(htime)));
+ addEntry(new HttpHeaderEntry(id, SBuf(), Time::FormatRfc1123(htime)));
}
void
assert(Http::HeaderLookupTable.lookup(id).type == Http::HdrFieldType::ftDate_1123); /* must be of an appropriate type */
if ((e = findEntry(id))) {
- value = parse_rfc1123(e->value.termedBuf());
+ value = Time::ParseRfc1123(e->value.termedBuf());
httpHeaderNoteParsedEntry(e->id, e->value, value < 0);
}
tot.time = -1;
} else {
/* or maybe it is time? */
- tot.time = parse_rfc1123(str);
+ tot.time = Time::ParseRfc1123(str);
tot.valid = tot.time >= 0;
tot.tag.str = NULL;
}
#include "HttpRequest.h"
#include "MemBuf.h"
#include "SquidConfig.h"
-#include "SquidTime.h"
#include "Store.h"
#include "StrList.h"
// found warn-text
String warnDate;
warnDate.append(warnDateBeg, warnDateEnd - warnDateBeg);
- const time_t time = parse_rfc1123(warnDate.termedBuf());
+ const time_t time = Time::ParseRfc1123(warnDate.termedBuf());
keep = (time > 0 && time == date); // keep valid and matching date
}
}
LoadableModules.cc \
LoadableModules.h
-SUBDIRS = mem debug base anyp helper dns ftp parser comm error eui acl format clients sbuf servers fs repl store DiskIO proxyp
-DIST_SUBDIRS = mem debug base anyp helper dns ftp parser comm error eui acl format clients sbuf servers fs repl store DiskIO proxyp
+SUBDIRS = mem time debug base anyp helper dns ftp parser comm error eui acl format clients sbuf servers fs repl store DiskIO proxyp
+DIST_SUBDIRS = mem time debug base anyp helper dns ftp parser comm error eui acl format clients sbuf servers fs repl store DiskIO proxyp
if ENABLE_AUTH
SUBDIRS += auth
store_swapmeta.cc \
store_swapout.cc \
swap_log_op.h \
- time.cc \
tools.cc \
tools.h \
tunnel.cc \
noinst_HEADERS = \
MemBuf.h \
- SquidString.h \
- SquidTime.h
+ SquidString.h
BUILT_SOURCES = \
cf_gen_defines.cci \
$(SNMP_LIBS) \
mem/libmem.la \
store/libstore.la \
+ time/libtime.la \
$(top_builddir)/lib/libmisccontainers.la \
$(top_builddir)/lib/libmiscencoding.la \
$(top_builddir)/lib/libmiscutil.la \
tests/testMem.cc \
tests/testMem.h
nodist_tests_testMem_SOURCES = \
- tests/stub_time.cc
+ tests/stub_libtime.cc
tests_testMem_LDADD = \
mem/libmem.la \
$(top_builddir)/lib/libmiscutil.la \
tests/stub_store_stats.cc \
store_swapmeta.cc \
store_swapout.cc \
- time.cc \
tests/stub_tools.cc \
tools.h \
wordlist.cc \
store/libstore.la \
$(ADAPTATION_LIBS) \
sbuf/libsbuf.la \
+ time/libtime.la \
$(top_builddir)/lib/libmisccontainers.la \
$(top_builddir)/lib/libmiscencoding.la \
$(top_builddir)/lib/libmiscutil.la \
tests/stub_store_stats.cc \
store_swapmeta.cc \
store_swapout.cc \
- time.cc \
tests/stub_tools.cc \
tools.h \
wordlist.cc \
store/libstore.la \
$(ADAPTATION_LIBS) \
sbuf/libsbuf.la \
+ time/libtime.la \
$(top_builddir)/lib/libmisccontainers.la \
$(top_builddir)/lib/libmiscencoding.la \
$(top_builddir)/lib/libmiscutil.la \
tests/CapturingStoreEntry.h \
tests/TestSwapDir.cc \
tests/TestSwapDir.h \
- tests/stub_time.cc \
tests/stub_tools.cc \
tools.h \
wordlist.cc \
$(TESTSOURCES) \
SquidMath.cc \
SquidMath.h \
+ tests/stub_libtime.cc \
swap_log_op.cc
tests_testStore_LDADD= \
libsquid.la \
tests/stub_store_stats.cc \
store_swapmeta.cc \
store_swapout.cc \
- tests/stub_time.cc \
tests/stub_tools.cc \
tools.h \
wordlist.cc \
SquidMath.cc \
SquidMath.h \
hier_code.cc \
+ tests/stub_libtime.cc \
swap_log_op.cc
tests_testDiskIO_LDADD = \
libsquid.la \
store_swapin.h \
store_swapmeta.cc \
store_swapout.cc \
- time.cc \
tools.cc \
tools.h \
tests/stub_tunnel.cc \
wordlist.cc \
wordlist.h
nodist_tests_test_http_range_SOURCES = \
- $(BUILT_SOURCES)
+ $(BUILT_SOURCES) \
+ tests/stub_libtime.cc
tests_test_http_range_LDADD = \
libsquid.la \
clients/libclients.la \
tests/stub_stmem.cc \
tests/stub_store.cc \
tests/stub_store_stats.cc \
- tests/stub_time.cc \
tests/stub_tools.cc \
tools.h \
wordlist.cc \
wordlist.h
nodist_tests_testHttp1Parser_SOURCES = \
- $(TESTSOURCES)
+ $(TESTSOURCES) \
+ tests/stub_libtime.cc
tests_testHttp1Parser_LDADD= \
http/libhttp.la \
parser/libparser.la \
Notes.cc \
Notes.h \
SquidString.h \
- SquidTime.h \
StatCounters.cc \
StatCounters.h \
tests/stub_StatHist.cc \
repl_modules.h \
tests/stub_store.cc \
tests/stub_store_stats.cc \
- tests/stub_time.cc \
tests/stub_tools.cc \
tools.h \
wordlist.cc \
wordlist.h
nodist_tests_testHttpReply_SOURCES = \
$(TESTSOURCES) \
- hier_code.cc
+ hier_code.cc \
+ tests/stub_libtime.cc
tests_testHttpReply_LDADD=\
CommCalls.o \
http/libhttp.la \
store_swapin.h \
store_swapmeta.cc \
store_swapout.cc \
- time.cc \
tools.cc \
tools.h \
tests/stub_tunnel.cc \
wordlist.cc \
wordlist.h
nodist_tests_testHttpRequest_SOURCES = \
- $(BUILT_SOURCES)
+ $(BUILT_SOURCES) \
+ tests/stub_libtime.cc
tests_testHttpRequest_LDADD = \
libsquid.la \
clients/libclients.la \
tests/testIcmp.h
nodist_tests_testIcmp_SOURCES = \
tests/stub_SBuf.cc \
- SquidTime.h \
tests/stub_debug.cc \
icmp/Icmp.h \
tests/stub_libmem.cc \
- time.cc
+ tests/stub_libtime.cc
tests_testIcmp_LDADD=\
icmp/libicmpcore.la \
ip/libip.la \
tests/testNetDb.h
nodist_tests_testNetDb_SOURCES = \
tests/stub_SBuf.cc \
- SquidTime.h \
tests/stub_debug.cc \
tests/stub_libmem.cc \
- time.cc
+ tests/stub_libtime.cc
tests_testNetDb_LDADD = \
icmp/libicmp.la \
ip/libip.la \
store_swapin.h \
store_swapmeta.cc \
store_swapout.cc \
- time.cc \
tools.cc \
tools.h \
tests/stub_tunnel.cc \
wordlist.cc \
wordlist.h
nodist_tests_testCacheManager_SOURCES = \
- $(BUILT_SOURCES)
+ $(BUILT_SOURCES) \
+ tests/stub_libtime.cc
# comm.cc only requires comm/libcomm.la until fdc_table is dead.
tests_testCacheManager_LDADD = \
libsquid.la \
tests/stub_stmem.cc \
tests/stub_store.cc \
tests/stub_store_stats.cc \
- time.cc \
tests/stub_tools.cc \
tools.h
nodist_tests_testStatHist_SOURCES = \
- $(TESTSOURCES)
+ $(TESTSOURCES) \
+ tests/stub_libtime.cc
tests_testStatHist_LDADD = \
sbuf/libsbuf.la \
base/libbase.la \
tests/stub_debug.cc \
event.cc \
tests/stub_libmem.cc \
- tests/stub_time.cc \
+ tests/stub_libtime.cc \
tests/stub_tools.cc
tests_testEvent_LDADD = \
base/libbase.la \
EventLoop.cc \
tests/stub_debug.cc \
tests/stub_fatal.cc \
- tests/stub_time.cc
+ tests/stub_libtime.cc
tests_testEventLoop_LDADD = \
base/libbase.la \
$(LIBCPPUNIT_LIBS) \
#include "MessageBucket.h"
#include "MessageDelayPools.h"
#include "Parsing.h"
-#include "SquidTime.h"
#include "Store.h"
#include <algorithm>
#include "PeerPoolMgr.h"
#include "security/BlindPeerConnector.h"
#include "SquidConfig.h"
-#include "SquidTime.h"
CBDATA_CLASS_INIT(PeerPoolMgr);
#endif
#include "Notes.h"
#include "security/forward.h"
-#include "SquidTime.h"
#if USE_OPENSSL
#include "ssl/support.h"
#endif
#include "store/Disk.h"
#include "store/forward.h"
+#include "time/gadgets.h"
#include <chrono>
#include "squid.h"
#include "acl/Time.h"
#include "acl/TimeData.h"
-#include "SquidTime.h"
int
ACLTimeStrategy::match(ACLData<MatchType> * &data, ACLFilledChecklist *)
*/
#include "squid.h"
-#include "util.h"
+
+#include <ctime>
#if HAVE_LDAP && HAVE_KRB5
#include "base/TextException.h"
#include "debug/Stream.h"
#include "globals.h"
-#include "SquidTime.h"
+#include "time/gadgets.h"
/// impossible services value to identify unset theNextServices
const static char *TheNullServices = ",null,";
#include "HttpReply.h"
#include "HttpRequest.h"
#include "MasterXaction.h"
-#include "SquidTime.h"
CBDATA_NAMESPACED_CLASS_INIT(Adaptation::Ecap::XactionRep, XactionRep);
#include "adaptation/icap/History.h"
#include "debug/Stream.h"
#include "globals.h"
-#include "SquidTime.h"
+#include "time/gadgets.h"
Adaptation::Icap::History::History():
req_sz(0),
#include "MasterXaction.h"
#include "parser/Tokenizer.h"
#include "sbuf/Stream.h"
-#include "SquidTime.h"
// flow and terminology:
// HTTP| --> receive --> encode --> write --> |network
const Adaptation::ServiceConfig &s = service().cfg();
buf.appendf("%s " SQUIDSTRINGPH " ICAP/1.0\r\n", s.methodStr(), SQUIDSTRINGPRINT(s.uri));
buf.appendf("Host: " SQUIDSTRINGPH ":%d\r\n", SQUIDSTRINGPRINT(s.host), s.port);
- buf.appendf("Date: %s\r\n", mkrfc1123(squid_curtime));
+ buf.appendf("Date: %s\r\n", Time::FormatRfc1123(squid_curtime));
if (!TheConfig.reuse_connections)
buf.appendf("Connection: close\r\n");
#include "HttpHeaderTools.h"
#include "HttpReply.h"
#include "HttpRequest.h"
-#include "SquidTime.h"
CBDATA_NAMESPACED_CLASS_INIT(Adaptation::Icap, OptXact);
CBDATA_NAMESPACED_CLASS_INIT(Adaptation::Icap, OptXactLauncher);
#include "adaptation/icap/Options.h"
#include "base/TextException.h"
#include "HttpReply.h"
-#include "SquidTime.h"
#include "StrList.h"
#include "wordlist.h"
#include "HttpReply.h"
#include "ip/tools.h"
#include "SquidConfig.h"
-#include "SquidTime.h"
#define DEFAULT_ICAP_PORT 1344
#define DEFAULT_ICAPS_PORT 11344
#include "pconn.h"
#include "security/PeerConnector.h"
#include "SquidConfig.h"
-#include "SquidTime.h"
/// Gives Security::PeerConnector access to Answer in the PeerPoolMgr callback dialer.
class MyIcapAnswerDialer: public UnaryMemFunT<Adaptation::Icap::Xaction, Security::EncryptorAnswer, Security::EncryptorAnswer&>,
#include "auth/UserRequest.h"
#include "event.h"
#include "globals.h"
-#include "SquidTime.h"
#include "Store.h"
Auth::User::User(Auth::SchemeConfig *aConfig, const char *aRequestRealm) :
#include "mgr/Registration.h"
#include "rfc1738.h"
#include "sbuf/SBuf.h"
-#include "SquidTime.h"
#include "Store.h"
#include "util.h"
#include "wordlist.h"
#include "HttpRequest.h"
#include "MemBuf.h"
#include "rfc1738.h"
-#include "SquidTime.h"
#if !defined(HELPER_INPUT_BUFFER)
#define HELPER_INPUT_BUFFER 8192
#include "rfc2617.h"
#include "sbuf/SBuf.h"
#include "sbuf/StringConvert.h"
-#include "SquidTime.h"
#include "Store.h"
#include "StrList.h"
#include "wordlist.h"
#include "HttpReply.h"
#include "HttpRequest.h"
#include "MemBuf.h"
-#include "SquidTime.h"
Auth::Digest::UserRequest::UserRequest() :
noncehex(NULL),
#include "HttpReply.h"
#include "HttpRequest.h"
#include "mgr/Registration.h"
-#include "SquidTime.h"
#include "Store.h"
#include "wordlist.h"
#include "HttpReply.h"
#include "HttpRequest.h"
#include "MemBuf.h"
-#include "SquidTime.h"
Auth::Negotiate::UserRequest::UserRequest() :
server_blob(nullptr),
#include "HttpReply.h"
#include "HttpRequest.h"
#include "mgr/Registration.h"
-#include "SquidTime.h"
#include "Store.h"
#include "wordlist.h"
#include "http/Stream.h"
#include "HttpRequest.h"
#include "MemBuf.h"
-#include "SquidTime.h"
Auth::Ntlm::UserRequest::UserRequest() :
server_blob(nullptr),
#include "base/Optional.h"
#include "mem/PoolingAllocator.h"
#include "SquidMath.h"
-#include "SquidTime.h"
+#include "time/gadgets.h"
#include <functional>
#include <limits>
#include "sbuf/Stream.h"
#include "sbuf/StringConvert.h"
#include "SquidConfig.h"
-#include "SquidTime.h"
#include "Store.h"
#include "tools.h"
#include "wordlist.h"
#include "mgr/Registration.h"
#include "SquidConfig.h"
#include "SquidMath.h"
-#include "SquidTime.h"
#include "StatCounters.h"
#include "Store.h"
#include "tools.h"
#include "security/NegotiationHistory.h"
#include "servers/forward.h"
#include "SquidConfig.h"
-#include "SquidTime.h"
#include "StatCounters.h"
#include "StatHist.h"
#include "Store.h"
#include "ssl/support.h"
#endif
-// for tvSubUsec() which should be in SquidTime.h
-#include "util.h"
-
#include <climits>
#include <cmath>
#include <limits>
#include "refresh.h"
#include "RequestFlags.h"
#include "SquidConfig.h"
-#include "SquidTime.h"
#include "Store.h"
#include "StrList.h"
#include "tools.h"
#include "rfc1738.h"
#include "sbuf/StringConvert.h"
#include "SquidConfig.h"
-#include "SquidTime.h"
#include "Store.h"
#include "StrList.h"
#include "tools.h"
#include "HttpReply.h"
#include "HttpRequest.h"
#include "SquidConfig.h"
-#include "SquidTime.h"
#include "StatCounters.h"
#include "Store.h"
#include "tools.h"
#include "rfc1738.h"
#include "SquidConfig.h"
#include "SquidString.h"
-#include "SquidTime.h"
#include "StatCounters.h"
#include "Store.h"
#include "tools.h"
debugs(9, 3, MYNAME);
if (code == 213) {
- ftpState->mdtm = parse_iso3307_time(ftpState->ctrl.last_reply);
+ ftpState->mdtm = Time::ParseIso3307(ftpState->ctrl.last_reply);
ftpState->unhack();
} else if (code < 0) {
ftpFail(ftpState);
#include "HttpRequest.h"
#include "sbuf/SBuf.h"
#include "servers/FtpServer.h"
-#include "SquidTime.h"
#include "Store.h"
#include "wordlist.h"
#include "ip/tools.h"
#include "ipcache.h"
#include "SquidConfig.h"
-#include "SquidTime.h"
#include <cerrno>
#include "neighbors.h"
#include "security/NegotiationHistory.h"
#include "SquidConfig.h"
-#include "SquidTime.h"
+
#include <ostream>
InstanceIdDefinitions(Comm::Connection, "conn", uint64_t);
#include "ip/Address.h"
#include "ip/forward.h"
#include "mem/forward.h"
-#include "SquidTime.h"
+#include "time/gadgets.h"
#include <iosfwd>
#include <ostream>
#include "fd.h"
#include "fde.h"
#include "mgr/Registration.h"
-#include "SquidTime.h"
#include "StatCounters.h"
#include "StatHist.h"
#include "Store.h"
#include "fde.h"
#include "globals.h"
#include "mgr/Registration.h"
-#include "SquidTime.h"
#include "StatCounters.h"
#include "StatHist.h"
#include "Store.h"
#include "comm/Loops.h"
#include "fde.h"
#include "globals.h"
-#include "SquidTime.h"
#include "StatCounters.h"
#include "Store.h"
#include "ICP.h"
#include "mgr/Registration.h"
#include "SquidConfig.h"
-#include "SquidTime.h"
#include "StatCounters.h"
#include "Store.h"
#include "ICP.h"
#include "mgr/Registration.h"
#include "SquidConfig.h"
-#include "SquidTime.h"
#include "StatCounters.h"
#include "StatHist.h"
#include "Store.h"
#include "fde.h"
#include "ICP.h"
#include "mgr/Registration.h"
-#include "SquidTime.h"
#include "StatCounters.h"
#include "StatHist.h"
#include "Store.h"
#include "log/access_log.h"
#include "MasterXaction.h"
#include "SquidConfig.h"
-#include "SquidTime.h"
#include "StatCounters.h"
#include <cerrno>
#include "fde.h"
#include "globals.h"
#include "MemBuf.h"
-#include "SquidTime.h"
#include "StatCounters.h"
#if USE_DELAY_POOLS
#include "ClientInfo.h"
#include "debug/Stream.h"
#include "fd.h"
#include "ipc/Kids.h"
-#include "SquidTime.h"
+#include "time/gadgets.h"
#include "util.h"
#include <algorithm>
#include "mgr/Registration.h"
#include "NullDelayId.h"
#include "SquidString.h"
-#include "SquidTime.h"
#include "Store.h"
#include "StoreClient.h"
#include "mgr/Registration.h"
#include "snmp_agent.h"
#include "SquidConfig.h"
-#include "SquidTime.h"
#include "Store.h"
#include "tools.h"
#include "util.h"
#include "rfc1738.h"
#include "sbuf/Stream.h"
#include "SquidConfig.h"
-#include "SquidTime.h"
#include "Store.h"
#include "tools.h"
#include "wordlist.h"
str.appendf("DNS ErrMsg: %s\r\n", dnsError.termedBuf());
/* - TimeStamp */
- str.appendf("TimeStamp: %s\r\n\r\n", mkrfc1123(squid_curtime));
+ str.appendf("TimeStamp: %s\r\n\r\n", Time::FormatRfc1123(squid_curtime));
/* - IP stuff */
str.appendf("ClientIP: %s\r\n", src_addr.toStr(ntoabuf,MAX_IPSTRLEN));
break;
case 'T':
- mb.appendf("%s", mkrfc1123(squid_curtime));
+ mb.appendf("%s", Time::FormatRfc1123(squid_curtime));
break;
case 'U':
#include "squid.h"
#include "event.h"
#include "mgr/Registration.h"
-#include "SquidTime.h"
#include "Store.h"
#include "tools.h"
#include "rfc1738.h"
#include "SquidConfig.h"
#include "SquidString.h"
-#include "SquidTime.h"
#include "Store.h"
#include "tools.h"
#include "wordlist.h"
#include "fd.h"
#include "fde.h"
#include "globals.h"
-#include "SquidTime.h"
// Solaris and possibly others lack MSG_NOSIGNAL optimization
// TODO: move this into compat/? Use a dedicated compat file to avoid dragging
#include "fd.h"
#include "fde.h"
#include "globals.h"
-#include "SquidTime.h"
#include "Store.h"
fde *fde::Table = nullptr;
#include "sbuf/StringConvert.h"
#include "security/CertError.h"
#include "security/NegotiationHistory.h"
-#include "SquidTime.h"
#include "Store.h"
#include "tools.h"
#if USE_OPENSSL
#include "mgr/Registration.h"
#include "snmp_agent.h"
#include "SquidConfig.h"
-#include "SquidTime.h"
#include "StatCounters.h"
#include "Store.h"
#include "util.h"
#include "globals.h"
#include "md5.h"
#include "sbuf/Stream.h"
-#include "SquidTime.h"
#include "Store.h"
#include "tools.h"
#include "globals.h"
#include "RebuildState.h"
#include "SquidConfig.h"
-#include "SquidTime.h"
#include "store/Disks.h"
#include "store_key_md5.h"
#include "store_rebuild.h"
#include "RebuildState.h"
#include "SquidConfig.h"
#include "SquidMath.h"
-#include "SquidTime.h"
#include "StatCounters.h"
#include "store_key_md5.h"
#include "StoreSearchUFS.h"
#include "parser/Tokenizer.h"
#include "rfc1738.h"
#include "SquidConfig.h"
-#include "SquidTime.h"
#include "StatCounters.h"
#include "Store.h"
#include "tools.h"
storeAppendPrintf(e, "<HR noshade size=\"1px\">\n");
storeAppendPrintf(e, "<ADDRESS>\n");
storeAppendPrintf(e, "Generated %s by %s (%s)\n",
- mkrfc1123(squid_curtime),
+ Time::FormatRfc1123(squid_curtime),
getMyHostname(),
visible_appname_string);
storeAppendPrintf(e, "</ADDRESS></BODY></HTML>\n");
#include "SquidConfig.h"
#include "SquidIpc.h"
#include "SquidMath.h"
-#include "SquidTime.h"
#include "Store.h"
#include "wordlist.h"
#define _SQUID_SRC_HELPER_REQUEST_H
#include "helper/forward.h"
-#include "SquidTime.h"
+#include "time/gadgets.h"
namespace Helper
{
#include "MemBuf.h"
#include "refresh.h"
#include "SquidConfig.h"
-#include "SquidTime.h"
#include "StatCounters.h"
#include "Store.h"
#include "store_key_md5.h"
#include "RefreshPattern.h"
#include "rfc1738.h"
#include "SquidConfig.h"
-#include "SquidTime.h"
#include "StatCounters.h"
#include "Store.h"
#include "StrList.h"
#include "squid.h"
#include "debug/Stream.h"
#include "Icmp.h"
-#include "SquidTime.h"
+#include "time/gadgets.h"
Icmp::Icmp()
{
#include "debug/Stream.h"
#include "Icmp4.h"
#include "IcmpPinger.h"
-#include "SquidTime.h"
+#include "time/gadgets.h"
static const char *
IcmpPacketType(uint8_t v)
#include "debug/Stream.h"
#include "Icmp6.h"
#include "IcmpPinger.h"
-#include "SquidTime.h"
+#include "time/gadgets.h"
// Some system headers are only neeed internally here.
// They should not be included via the header.
#include "Icmp4.h"
#include "Icmp6.h"
#include "IcmpPinger.h"
-#include "SquidTime.h"
#include <cerrno>
#include "ip/tools.h"
#include "SquidConfig.h"
#include "SquidIpc.h"
-#include "SquidTime.h"
#include <cerrno>
globals.cc \
SquidConfig.cc \
tests/stub_HelperChildConfig.cc \
- tests/STUB.h \
- time.cc
+ tests/STUB.h
# ICMP lookup helper
pinger_SOURCES = \
$(top_builddir)/src/sbuf/libsbuf.la \
$(top_builddir)/src/debug/libdebug.la \
$(top_builddir)/src/comm/libminimal.la \
+ $(top_builddir)/src/time/libtime.la \
$(top_builddir)/src/base/libbase.la \
$(top_builddir)/src/mem/libminimal.la \
$(COMPAT_LIB) \
globals.cc: $(top_srcdir)/src/globals.h
cp $(top_builddir)/src/globals.cc $@
-time.cc: $(top_srcdir)/src/time.cc
- cp $(top_srcdir)/src/time.cc $@
-
SquidConfig.cc: $(top_srcdir)/src/SquidConfig.cc
cp $(top_srcdir)/src/SquidConfig.cc $@
#include "neighbors.h"
#include "PeerSelectState.h"
#include "SquidConfig.h"
-#include "SquidTime.h"
#include "Store.h"
#include "StoreClient.h"
#include "tools.h"
#include "squid.h"
#include "debug/Stream.h"
-#include "SquidTime.h"
#if USE_ICMP
#include "Icmp6.h"
#include "IcmpPinger.h"
#include "ip/tools.h"
+#include "time/gadgets.h"
#if _SQUID_WINDOWS_
#include "refresh.h"
#include "rfc1738.h"
#include "SquidConfig.h"
-#include "SquidTime.h"
#include "StatCounters.h"
#include "Store.h"
#include "store_key_md5.h"
#include "tools.h"
#include "wordlist.h"
-// for tvSubUsec() which should be in SquidTime.h
-#include "util.h"
-
#include <cerrno>
/// a delayed icpUdpSend() call
#include "internal.h"
#include "MemBuf.h"
#include "SquidConfig.h"
-#include "SquidTime.h"
#include "Store.h"
#include "tools.h"
#include "util.h"
#include "rfc1738.h"
#include "SquidConfig.h"
#include "SquidIpc.h"
-#include "SquidTime.h"
#include "tools.h"
#include <cerrno>
#include "mgr/Registration.h"
#include "snmp_agent.h"
#include "SquidConfig.h"
-#include "SquidTime.h"
#include "StatCounters.h"
#include "Store.h"
#include "util.h"
#include "log/File.h"
#include "log/Formats.h"
#include "SquidConfig.h"
-#include "SquidTime.h"
void
Log::Format::HttpdCombined(const AccessLogEntry::Pointer &al, Logfile * logfile)
#include "log/File.h"
#include "log/Formats.h"
#include "SquidConfig.h"
-#include "SquidTime.h"
void
Log::Format::HttpdCommon(const AccessLogEntry::Pointer &al, Logfile * logfile)
#include "log/File.h"
#include "log/Formats.h"
#include "SquidConfig.h"
-#include "SquidTime.h"
void
Log::Format::SquidIcap(const AccessLogEntry::Pointer &al, Logfile * logfile)
#include "log/File.h"
#include "log/Formats.h"
#include "SquidConfig.h"
-#include "SquidTime.h"
void
Log::Format::SquidNative(const AccessLogEntry::Pointer &al, Logfile * logfile)
#include "HttpRequest.h"
#include "log/File.h"
#include "log/Formats.h"
-#include "SquidTime.h"
void
Log::Format::SquidReferer(const AccessLogEntry::Pointer &al, Logfile *logfile)
#include "HttpRequest.h"
#include "log/File.h"
#include "log/Formats.h"
-#include "SquidTime.h"
void
Log::Format::SquidUserAgent(const AccessLogEntry::Pointer &al, Logfile * logfile)
#include "log/ModDaemon.h"
#include "SquidConfig.h"
#include "SquidIpc.h"
-#include "SquidTime.h"
#include <cerrno>
#include "Parsing.h"
#include "sbuf/MemBlob.h"
#include "SquidConfig.h"
-#include "SquidTime.h"
// a single I/O buffer should be large enough to store any access.log record
const size_t Log::TcpLogger::IoBufSize = 2*MAX_URL;
#include "rfc1738.h"
#include "sbuf/SBuf.h"
#include "SquidConfig.h"
-#include "SquidTime.h"
#include "Store.h"
#if USE_SQUID_EUI
#include "SBufStatsAction.h"
#include "send-announce.h"
#include "SquidConfig.h"
-#include "SquidTime.h"
#include "stat.h"
#include "StatCounters.h"
#include "Store.h"
#include "store/Disks.h"
#include "store_log.h"
#include "StoreFileSystem.h"
+#include "time/Engine.h"
#include "tools.h"
#include "unlinkd.h"
#include "wccp.h"
mainLoop.setPrimaryEngine(&comm_engine);
/* use the standard time service */
- TimeEngine time_engine;
+ Time::Engine time_engine;
mainLoop.setTimeService(&time_engine);
#ifndef SQUID_SRC_MEM_METER_H
#define SQUID_SRC_MEM_METER_H
-#include "SquidTime.h"
+#include "time/gadgets.h"
namespace Mem
{
#include "MemBuf.h"
#include "mgr/Registration.h"
#include "SquidConfig.h"
-#include "SquidTime.h"
#include "Store.h"
#include <iomanip>
#include "mgr/Command.h"
#include "mgr/Request.h"
#include "mgr/Response.h"
-#include "SquidTime.h"
#include "Store.h"
Mgr::Action::Action(const Command::Pointer &aCmd): cmd(aCmd)
#include "ipc/Messages.h"
#include "ipc/TypedMsgHdr.h"
#include "mgr/CountersAction.h"
-#include "SquidTime.h"
#include "Store.h"
#include "tools.h"
#include "ipc/Port.h"
#include "mgr/Forwarder.h"
#include "mgr/Request.h"
-#include "SquidTime.h"
#include "Store.h"
CBDATA_NAMESPACED_CLASS_INIT(Mgr, Forwarder);
#include "mgr/InfoAction.h"
#include "mgr/Request.h"
#include "mgr/Response.h"
-#include "SquidTime.h"
#include "Store.h"
#include "tools.h"
#include "mgr/IntParam.h"
#include "mgr/Request.h"
#include "mgr/Response.h"
-#include "SquidTime.h"
+
#include <memory>
#include <algorithm>
#include "RequestFlags.h"
#include "SquidConfig.h"
#include "SquidMath.h"
-#include "SquidTime.h"
#include "stat.h"
#include "Store.h"
#include "store_key_md5.h"
#include "mime_header.h"
#include "neighbors.h"
#include "PeerDigest.h"
-#include "SquidTime.h"
#include "Store.h"
#include "store_key_md5.h"
#include "StoreClient.h"
#include "peer_userhash.h"
#include "PeerSelectState.h"
#include "SquidConfig.h"
-#include "SquidTime.h"
#include "Store.h"
-#include "util.h" // for tvSubDsec() which should be in SquidTime.h
+#include "time/gadgets.h"
/**
* A CachePeer which has been selected as a possible destination.
#include "refresh.h"
#include "RefreshPattern.h"
#include "SquidConfig.h"
-#include "SquidTime.h"
#include "Store.h"
#include "util.h"
debugs(22, 3, "\tage:\t" << age);
- debugs(22, 3, "\tcheck_time:\t" << mkrfc1123(check_time));
+ debugs(22, 3, "\tcheck_time:\t" << Time::FormatRfc1123(check_time));
- debugs(22, 3, "\tentry->timestamp:\t" << mkrfc1123(entry->timestamp));
+ debugs(22, 3, "\tentry->timestamp:\t" << Time::FormatRfc1123(entry->timestamp));
if (request && !request->flags.ignoreCc) {
const HttpHdrCc *const cc = request->cache_control;
minFresh << " = " << age + minFresh);
debugs(22, 3, "\tcheck_time + min-fresh:\t" << check_time << " + "
<< minFresh << " = " <<
- mkrfc1123(check_time + minFresh));
+ Time::FormatRfc1123(check_time + minFresh));
age += minFresh;
check_time += minFresh;
}
#include "squid.h"
#include "heap.h"
#include "MemObject.h"
-#include "SquidTime.h"
#include "Store.h"
#include "store_heap_replacement.h"
#include "squid.h"
#include "MemObject.h"
-#include "SquidTime.h"
#include "Store.h"
/* because LruNode use explicit memory alloc()/freeOne() calls.
security_file_certgen_LDADD = \
$(top_builddir)/src/ssl/libsslutil.la \
+ $(top_builddir)/src/time/libtime.la \
$(SSLLIB) \
$(COMPAT_LIB)
#include "squid.h"
#include "helper/protocol_defines.h"
#include "security/cert_generators/file/certificate_db.h"
-#include "SquidTime.h"
#include "ssl/crtd_message.h"
+#include "time/gadgets.h"
#include <cstring>
#include <iostream>
static const char *const B_GBYTES_STR = "GB";
static const char *const B_BYTES_STR = "B";
-/// Get current time.
-time_t getCurrentTime(void)
-{
- struct timeval currentTime;
-#if GETTIMEOFDAY_NO_TZP
- gettimeofday(¤tTime);
-#else
- gettimeofday(¤tTime, nullptr);
-#endif
- return currentTime.tv_sec;
-}
-
/**
* Parse bytes unit. It would be one of the next value: MB, GB, KB or B.
* This function is caseinsensitive.
#include "ipcache.h"
#include "send-announce.h"
#include "SquidConfig.h"
-#include "SquidTime.h"
#include "tools.h"
static IPH send_announce;
#include "snmp_core.h"
#include "SquidConfig.h"
#include "SquidMath.h"
-#include "SquidTime.h"
#include "stat.h"
#include "StatCounters.h"
#include "StatHist.h"
#include "Store.h"
#include "tools.h"
-// for tvSubDsec() which should be in SquidTime.h
#include "util.h"
/************************************************************************
#include "globals.h"
#include "ip/Address.h"
#include "parser/BinaryTokenizer.h"
-#include "SquidTime.h"
#include "ssl/bio.h"
#if _SQUID_WINDOWS_
#include "mgr/Action.h"
#include "mgr/Command.h"
#include "security/forward.h"
-#include "SquidTime.h"
#include "ssl/gadgets.h"
#include <list>
#include "sbuf/Stream.h"
#include "SquidConfig.h"
#include "SquidString.h"
-#include "SquidTime.h"
#include "ssl/cert_validate_message.h"
#include "ssl/Config.h"
#include "ssl/helper.h"
#include "security/ErrorDetail.h"
#include "security/Session.h"
#include "SquidConfig.h"
-#include "SquidTime.h"
#include "ssl/bio.h"
#include "ssl/Config.h"
#include "ssl/ErrorDetail.h"
#include "PeerDigest.h"
#include "SquidConfig.h"
#include "SquidMath.h"
-#include "SquidTime.h"
#include "stat.h"
#include "StatCounters.h"
#include "Store.h"
#include "store_digest.h"
#include "StoreClient.h"
#include "tools.h"
-// for tvSubDsec() which should be in SquidTime.h
-#include "util.h"
#if USE_AUTH
#include "auth/UserRequest.h"
#endif
#endif
storeAppendPrintf(sentry, "Start Time:\t%s\n",
- mkrfc1123(stats.squid_start.tv_sec));
+ Time::FormatRfc1123(stats.squid_start.tv_sec));
storeAppendPrintf(sentry, "Current Time:\t%s\n",
- mkrfc1123(stats.current_time.tv_sec));
+ Time::FormatRfc1123(stats.current_time.tv_sec));
storeAppendPrintf(sentry, "Connection information for %s:\n",APP_SHORTNAME);
storeAppendPrintf(sentry, "sample_start_time = %d.%d (%s)\n",
(int)stats.sample_start_time.tv_sec,
(int)stats.sample_start_time.tv_usec,
- mkrfc1123(stats.sample_start_time.tv_sec));
+ Time::FormatRfc1123(stats.sample_start_time.tv_sec));
storeAppendPrintf(sentry, "sample_end_time = %d.%d (%s)\n",
(int)stats.sample_end_time.tv_sec,
(int)stats.sample_end_time.tv_usec,
- mkrfc1123(stats.sample_end_time.tv_sec));
+ Time::FormatRfc1123(stats.sample_end_time.tv_sec));
storeAppendPrintf(sentry, "client_http.requests = %f/sec\n",
stats.client_http_requests);
storeAppendPrintf(sentry, "sample_time = %d.%d (%s)\n",
(int) stats.sample_time.tv_sec,
(int) stats.sample_time.tv_usec,
- mkrfc1123(stats.sample_time.tv_sec));
+ Time::FormatRfc1123(stats.sample_time.tv_sec));
storeAppendPrintf(sentry, "client_http.requests = %.0f\n",
stats.client_http_requests);
storeAppendPrintf(sentry, "client_http.hits = %.0f\n",
#include "repl_modules.h"
#include "RequestFlags.h"
#include "SquidConfig.h"
-#include "SquidTime.h"
#include "StatCounters.h"
#include "stmem.h"
#include "Store.h"
#include "StoreFileSystem.h"
#include "swap_log_op.h"
#include "tools.h"
-#include "util.h" // for tvSubDsec() which should be in SquidTime.h
typedef SwapDir *STDIRSELECT(const StoreEntry *e);
#include "PeerDigest.h"
#include "refresh.h"
#include "SquidConfig.h"
-#include "SquidTime.h"
#include "Store.h"
#include "StoreSearch.h"
#include "util.h"
#include "MemObject.h"
#include "mgr/Registration.h"
#include "SquidConfig.h"
-#include "SquidTime.h"
#include "Store.h"
#include "store_log.h"
#include "globals.h"
#include "md5.h"
#include "SquidConfig.h"
-#include "SquidTime.h"
#include "StatCounters.h"
#include "Store.h"
#include "store/Disk.h"
#include "store_key_md5.h"
#include "store_rebuild.h"
#include "StoreSearch.h"
-// for tvSubDsec() which should be in SquidTime.h
-#include "util.h"
+#include "time/gadgets.h"
#include <cerrno>
tests/stub_libsecurity.cc \
tests/stub_libsslsquid.cc \
tests/stub_libstore.cc \
+ tests/stub_libtime.cc \
tests/stub_main_cc.cc \
tests/stub_MemBuf.cc \
tests/stub_mem_node.cc \
tests/stub_store_rebuild.cc \
tests/stub_store_stats.cc \
tests/stub_store_swapout.cc \
- tests/stub_time.cc \
tests/stub_tools.cc \
tests/stub_tunnel.cc \
tests/stub_UdsOp.cc \
--- /dev/null
+/*
+ * Copyright (C) 1996-2022 The Squid Software Foundation and contributors
+ *
+ * Squid software is distributed under GPLv2+ license and includes
+ * contributions from numerous individuals and organizations.
+ * Please see the COPYING and CONTRIBUTORS files for details.
+ */
+
+#include "squid.h"
+
+#define STUB_API "time/libtime.la"
+#include "tests/STUB.h"
+
+#include "time/Engine.h"
+void Time::Engine::tick() STUB
+
+#include "time/gadgets.h"
+struct timeval current_time = {};
+double current_dtime = 0.0;
+time_t squid_curtime = 0;
+time_t getCurrentTime() STUB_RETVAL(0)
+int tvSubUsec(struct timeval, struct timeval) STUB_RETVAL(0)
+double tvSubDsec(struct timeval, struct timeval) STUB_RETVAL(0.0)
+int tvSubMsec(struct timeval, struct timeval) STUB_RETVAL(0)
+void tvSub(struct timeval &, struct timeval const &, struct timeval const &) STUB
+void tvAdd(struct timeval &, struct timeval const &, struct timeval const &) STUB
+void tvAssignAdd(struct timeval &, struct timeval const &) STUB
+std::ostream &operator <<(std::ostream &os, const timeval &) STUB_RETVAL(os)
+namespace Time
+{
+time_t ParseIso3307(const char *) STUB_RETVAL(0)
+const char *FormatRfc1123(time_t) STUB_RETVAL("")
+time_t ParseRfc1123(const char *) STUB_RETVAL(0)
+const char *FormatStrf(time_t) STUB_RETVAL("")
+const char *FormatHttpd(time_t) STUB_RETVAL("")
+}
+
#include "squid.h"
#include "MemBuf.h"
-#include "SquidTime.h"
#include "store/Controller.h"
#include "store_rebuild.h"
+#include "time/gadgets.h"
#include <cstring>
+++ /dev/null
-/*
- * Copyright (C) 1996-2022 The Squid Software Foundation and contributors
- *
- * Squid software is distributed under GPLv2+ license and includes
- * contributions from numerous individuals and organizations.
- * Please see the COPYING and CONTRIBUTORS files for details.
- */
-
-#include "squid.h"
-#include "SquidTime.h"
-
-#define STUB_API "time.cc"
-#include "tests/STUB.h"
-
-struct timeval current_time;
-double current_dtime;
-time_t squid_curtime = 0;
-
-time_t getCurrentTime(void) STUB_RETVAL(0)
-int tvSubMsec(struct timeval, struct timeval) STUB_RETVAL(0)
-void tvSub(timeval&, timeval const&, timeval const&) STUB
-void tvAssignAdd(timeval&, timeval const&) STUB
-
-const char * Time::FormatStrf(time_t ) STUB_RETVAL("")
-const char * Time::FormatHttpd(time_t ) STUB_RETVAL("")
-
-void TimeEngine::tick() STUB
-TimeEngine::~TimeEngine() {STUB_NOP}
-
-std::ostream &operator <<(std::ostream &os, const timeval &) STUB_RETVAL(os)
-
#include "squid.h"
#include "AsyncEngine.h"
#include "EventLoop.h"
-#include "SquidTime.h"
#include "tests/testEventLoop.h"
+#include "time/Engine.h"
#include "unitTestMain.h"
#include <cppunit/TestAssert.h>
/* An event loop has a time service which is like an async engine but never
* generates events and there can only be one such service.
*/
-
-class StubTime : public TimeEngine
+class StubTime : public Time::Engine
{
-
public:
StubTime() : calls(0) {}
#include "squid.h"
#include "MemObject.h"
#include "SquidConfig.h"
-#include "SquidTime.h"
#include "Store.h"
#include "store/Disks.h"
#include "StoreSearch.h"
#include "squid.h"
#include "MemObject.h"
#include "SquidConfig.h"
-#include "SquidTime.h"
#include "Store.h"
#include "store/Disks.h"
#include "StoreSearch.h"
#include "squid.h"
#include "event.h"
#include "EventLoop.h"
-#include "SquidTime.h"
#include "testStoreSupport.h"
/* construct a stock loop with event dispatching, a time service that advances
* 1 second a tick
*/
-StockEventLoop::StockEventLoop() : default_time_engine(TimeEngine())
+StockEventLoop::StockEventLoop() : default_time_engine(Time::Engine())
{
registerEngine(EventScheduler::GetInstance());
setTimeService(&default_time_engine);
#define SQUID_TESTSTORESUPPORT_H
#include "EventLoop.h"
-#include "SquidTime.h"
+#include "time/Engine.h"
/* construct a stock loop with event dispatching, a time service that advances
* 1 second a tick
public:
StockEventLoop();
- TimeEngine default_time_engine;
+ Time::Engine default_time_engine;
};
#endif /* SQUID_TESTSTORESUPPORT_H */
--- /dev/null
+/*
+ * Copyright (C) 1996-2022 The Squid Software Foundation and contributors
+ *
+ * Squid software is distributed under GPLv2+ license and includes
+ * contributions from numerous individuals and organizations.
+ * Please see the COPYING and CONTRIBUTORS files for details.
+ */
+
+#include "squid.h"
+#include "time/Engine.h"
+#include "time/gadgets.h"
+
+void
+Time::Engine::tick()
+{
+ getCurrentTime();
+}
+
--- /dev/null
+/*
+ * Copyright (C) 1996-2022 The Squid Software Foundation and contributors
+ *
+ * Squid software is distributed under GPLv2+ license and includes
+ * contributions from numerous individuals and organizations.
+ * Please see the COPYING and CONTRIBUTORS files for details.
+ */
+
+#ifndef SQUID__SRC_TIME_ENGINE_H
+#define SQUID__SRC_TIME_ENGINE_H
+
+namespace Time {
+
+/// event class for doing synthetic time etc
+class Engine
+{
+public:
+ virtual ~Engine() {}
+
+ // tick the clock - update from the OS or other time source
+ virtual void tick();
+};
+
+} // namespace Time
+
+#endif /* SQUID__SRC_TIME_ENGINE_H */
+
--- /dev/null
+## Copyright (C) 1996-2022 The Squid Software Foundation and contributors
+##
+## Squid software is distributed under GPLv2+ license and includes
+## contributions from numerous individuals and organizations.
+## Please see the COPYING and CONTRIBUTORS files for details.
+##
+
+include $(top_srcdir)/src/Common.am
+include $(top_srcdir)/src/TestHeaders.am
+
+noinst_LTLIBRARIES = libtime.la
+
+libtime_la_SOURCES = \
+ Engine.cc \
+ Engine.h \
+ forward.h \
+ gadgets.cc \
+ gadgets.h \
+ iso3307.cc \
+ rfc1123.cc
--- /dev/null
+/*
+ * Copyright (C) 1996-2022 The Squid Software Foundation and contributors
+ *
+ * Squid software is distributed under GPLv2+ license and includes
+ * contributions from numerous individuals and organizations.
+ * Please see the COPYING and CONTRIBUTORS files for details.
+ */
+
+#ifndef SQUID__SRC_TIME_FORWARD_H
+#define SQUID__SRC_TIME_FORWARD_H
+
+/// Time and Date handling tools
+namespace Time
+{
+
+class Engine;
+
+} // namespace Time
+
+#endif /* SQUID__SRC_TIME_FORWARD_H */
+
/* DEBUG: section 21 Time Functions */
#include "squid.h"
-#include "SquidTime.h"
+#include "time/gadgets.h"
#include <iomanip>
#include <ostream>
time_t squid_curtime = 0;
time_t
-getCurrentTime(void)
+getCurrentTime()
{
#if GETTIMEOFDAY_NO_TZP
gettimeofday(¤t_time);
return squid_curtime = current_time.tv_sec;
}
+int
+tvSubUsec(struct timeval t1, struct timeval t2)
+{
+ return (t2.tv_sec - t1.tv_sec) * 1000000 +
+ (t2.tv_usec - t1.tv_usec);
+}
+
+double
+tvSubDsec(struct timeval t1, struct timeval t2)
+{
+ return (double) (t2.tv_sec - t1.tv_sec) +
+ (double) (t2.tv_usec - t1.tv_usec) / 1000000.0;
+}
+
int
tvSubMsec(struct timeval t1, struct timeval t2)
{
}
}
-TimeEngine::~TimeEngine()
-{}
-
-void
-TimeEngine::tick()
-{
- getCurrentTime();
-}
-
std::ostream &
operator <<(std::ostream &os, const timeval &t)
{
* Please see the COPYING and CONTRIBUTORS files for details.
*/
-/* DEBUG: section 21 Time Functions */
-
-#ifndef SQUID_TIME_H
-#define SQUID_TIME_H
-
-#include "rfc1123.h"
+#ifndef SQUID__SRC_TIME_GADGETS_H
+#define SQUID__SRC_TIME_GADGETS_H
#include <ctime>
#include <iosfwd>
-/* NP: sys/time.h is provided by libcompat */
/* Use uint64_t to store milliseconds */
typedef uint64_t time_msec_t;
-/* globals for accessing time */
-extern struct timeval current_time;
+/// the current UNIX time in seconds (with microsecond precision)
extern double current_dtime;
+
+/// the current UNIX time in seconds
extern time_t squid_curtime;
-time_t getCurrentTime(void);
-int tvSubMsec(struct timeval, struct timeval);
+/// Update squid_curtime (also current_time, and current_dtime)
+/// \returns new value of squid_curtime
+time_t getCurrentTime();
+
+namespace Time {
+
+/// Convert from ISO 3307 style time: YYYYMMDDHHMMSS or YYYYMMDDHHMMSS.xxx
+time_t ParseIso3307(const char *);
+
+/** Display time as a formatted human-readable string.
+ * Time string syntax used is from RFC 1123
+ * "www, DD MMM YYYY hh:mm:ss GMT"
+ *
+ * Output is only valid until next call to this function.
+ */
+const char *FormatRfc1123(time_t);
+
+/// Convert from RFC 1123 style time: "www, DD MMM YYYY hh:mm:ss ZZZ"
+time_t ParseRfc1123(const char *);
+
+/** Display time as a formatted human-readable string.
+ * Time syntax is
+ * "YYYY/MM/DD hh:mm:ss"
+ *
+ * Output is only valid until next call to this function.
+ */
+const char *FormatStrf(time_t);
+
+/** Display time as a formatted human-readable string.
+ * Time string syntax used is that of Apache httpd.
+ * "DD/MMM/YYYY:hh:mm:ss zzzz"
+ *
+ * Output is only valid until next call to this function.
+*/
+const char *FormatHttpd(time_t);
+
+} // namespace Time
+
+/// the current UNIX time in timeval {seconds, microseconds} format
+extern struct timeval current_time;
+
+/// timeval subtraction operation.
+/// \returns (A-B) in whole microseconds
+/// XXX: result is not compatible with time_msec_t millisecond storage
+int tvSubUsec(struct timeval A, struct timeval B);
+
+/// timeval subtraction operation.
+/// \returns (A-B) in seconds (with microsecond precision)
+double tvSubDsec(struct timeval A, struct timeval B);
+
+/// timeval subtraction operation.
+/// \returns (A-B) in whole milliseconds
+/// XXX: result is not compatible with time_msec_t millisecond storage
+int tvSubMsec(struct timeval A, struct timeval B);
/// timeval subtraction operation
/// \param[out] res = t2 - t1
void tvAssignAdd(struct timeval &t, struct timeval const &add);
/// Convert timeval to milliseconds
+/// XXX: result is not compatible with time_msec_t millisecond storage
inline long int tvToMsec(struct timeval &t)
{
return t.tv_sec * 1000 + t.tv_usec / 1000;
}
-/** event class for doing synthetic time etc */
-class TimeEngine
-{
-
-public:
- virtual ~TimeEngine();
-
- /** tick the clock - update from the OS or other time source, */
- virtual void tick();
-};
+/// prints <seconds>.<microseconds>
+std::ostream &operator <<(std::ostream &, const timeval &);
// TODO: Remove direct timercmp() calls in legacy code.
return !(a != b);
}
-/// prints <seconds>.<microseconds>
-std::ostream &operator <<(std::ostream &, const timeval &);
-
-namespace Time
-{
-
-/** Display time as a formatted human-readable string.
- * Time syntax is
- * "YYYY/MM/DD hh:mm:ss"
- *
- * Output is only valid until next call to this function.
- */
-const char *FormatStrf(time_t t);
-
-/** Display time as a formatted human-readable string.
- * Time string syntax used is that of Apache httpd.
- * "DD/MMM/YYYY:hh:mm:ss zzzz"
- *
- * Output is only valid until next call to this function.
- */
-const char *FormatHttpd(time_t t);
-
-} // namespace Time
-
-#endif /* SQUID_TIME_H */
+#endif /* SQUID__SRC_TIME_GADGETS_H */
*/
#include "squid.h"
-#include "util.h"
+#include "time/gadgets.h"
#if HAVE_STRING_H
#include <string.h>
#if HAVE_CTYPE_H
#include <ctype.h>
#endif
-#if HAVE_TIME_H
-#include <time.h>
-#endif
#define ASCII_DIGIT(c) ((c)-48)
time_t
-parse_iso3307_time(const char *buf)
+Time::ParseIso3307(const char *buf)
{
/* buf is an ISO 3307 style time: YYYYMMDDHHMMSS or YYYYMMDDHHMMSS.xxx */
struct tm tms;
*/
#include "squid.h"
-#include "rfc1123.h"
+#include "time/gadgets.h"
/*
* Adapted from HTSUtils.c in CERN httpd 3.0 (http://info.cern.ch/httpd/)
parse_date_elements(const char *day, const char *month, const char *year,
const char *aTime, const char *zone) {
static struct tm tm;
- char *t;
+ const char *t;
memset(&tm, 0, sizeof(tm));
if (!day || !month || !year || !aTime || (zone && strcmp(zone, "GMT")))
}
time_t
-parse_rfc1123(const char *str)
+Time::ParseRfc1123(const char *str)
{
struct tm *tm;
time_t t;
}
const char *
-mkrfc1123(time_t t)
+Time::FormatRfc1123(time_t t)
{
static char buf[128];
#include "sbuf/Stream.h"
#include "SquidConfig.h"
#include "SquidMath.h"
-#include "SquidTime.h"
#include "store/Disks.h"
#include "tools.h"
#include "wordlist.h"
#include "sbuf/SBuf.h"
#include "security/BlindPeerConnector.h"
#include "SquidConfig.h"
-#include "SquidTime.h"
#include "StatCounters.h"
#if USE_OPENSSL
#include "ssl/bio.h"
#include "globals.h"
#include "SquidConfig.h"
#include "SquidIpc.h"
-#include "SquidTime.h"
#include "StatCounters.h"
#include "store/Disk.h"
#include "tools.h"
#include "MemBuf.h"
#include "mime_header.h"
#include "RequestFlags.h"
-#include "SquidTime.h"
#include "Store.h"
#include "StoreClient.h"
#include "tools.h"
LDADD = \
$(top_builddir)/src/base/libbase.la \
$(top_builddir)/src/globals.o \
- $(top_builddir)/src/time.o \
+ $(top_builddir)/src/time/libtime.la \
$(top_builddir)/lib/libmiscutil.la \
$(COMPAT_LIB) \
$(XTRA_LIBS)
LDADD= \
$(top_builddir)/src/ip/libip.la \
$(top_builddir)/src/mem/libminimal.la \
+ $(top_builddir)/src/time/libtime.la \
$(top_builddir)/lib/libmiscencoding.la \
$(top_builddir)/lib/libmiscutil.la \
$(COMPAT_LIB) \
MemBuf.cc: $(top_srcdir)/src/MemBuf.cc
cp $(top_srcdir)/src/MemBuf.cc $@
-time.cc: $(top_srcdir)/src/time.cc
- cp $(top_srcdir)/src/time.cc $@
-
tests/stub_cbdata.cc: $(top_srcdir)/src/tests/stub_cbdata.cc | tests
cp $(top_srcdir)/src/tests/stub_cbdata.cc $@
# globals.cc is needed by test_tools.cc.
# Neither of these should be disted from here.
TESTSOURCES= test_tools.cc
-CLEANFILES += test_tools.cc Here.cc CharacterSet.cc MemBuf.cc tests/stub_debug.cc time.cc tests/stub_cbdata.cc tests/STUB.h
+CLEANFILES += test_tools.cc Here.cc CharacterSet.cc MemBuf.cc tests/stub_debug.cc tests/stub_cbdata.cc tests/STUB.h
## Test Scripts
EXTRA_DIST += helper-ok-dying.pl helper-ok.pl
Here.cc \
MemBuf.cc \
cachemgr.cc \
- test_tools.cc \
- time.cc
+ test_tools.cc
nodist_cachemgr__CGIEXT__SOURCES = \
tests/stub_cbdata.cc \
#include "html_quote.h"
#include "ip/Address.h"
#include "MemBuf.h"
-#include "rfc1123.h"
#include "rfc1738.h"
+#include "time/gadgets.h"
#include "util.h"
#include <cctype>
printf("<HR noshade size=\"1px\">\n");
printf("<ADDRESS>\n");
printf("Generated %s, by %s/%s@%s\n",
- mkrfc1123(now), progname, VERSION, getfullhostname());
+ Time::FormatRfc1123(now), progname, VERSION, getfullhostname());
printf("</ADDRESS></BODY></HTML>\n");
}
LDADD = \
$(top_builddir)/src/ip/libip.la \
$(top_builddir)/src/mem/libminimal.la \
+ $(top_builddir)/src/time/libtime.la \
$(top_builddir)/src/base/libbase.la \
$(top_builddir)/lib/libmiscencoding.la \
$(top_builddir)/lib/libmiscutil.la \
tests/stub_debug.cc: $(top_srcdir)/src/tests/stub_debug.cc | tests
cp $(top_srcdir)/src/tests/stub_debug.cc $@
-time.cc: $(top_srcdir)/src/time.cc
- cp $(top_srcdir)/src/time.cc $@
-
tests/STUB.h: $(top_srcdir)/src/tests/STUB.h | tests
cp $(top_srcdir)/src/tests/STUB.h $@
# globals.cc is needed by test_tools.cc.
# Neither of these should be disted from here.
TESTSOURCES= test_tools.cc
-CLEANFILES += test_tools.cc tests/stub_debug.cc time.cc tests/STUB.h
+CLEANFILES += test_tools.cc tests/stub_debug.cc tests/STUB.h
## ##### squidclient #####
gssapi_support.cc \
gssapi_support.h \
squidclient.cc \
- test_tools.cc \
- time.cc
+ test_tools.cc
nodist_squidclient_SOURCES = \
tests/stub_debug.cc \
*/
#include "squid.h"
-#include "SquidTime.h"
+#include "time/gadgets.h"
#include "tools/squidclient/Parameters.h"
#include "tools/squidclient/Ping.h"
#include "base64.h"
#include "ip/Address.h"
#include "ip/tools.h"
-#include "rfc1123.h"
+#include "time/gadgets.h"
#include "tools/squidclient/gssapi_support.h"
#include "tools/squidclient/Parameters.h"
#include "tools/squidclient/Ping.h"
msg << "Accept: */*\r\n";
}
if (ims) {
- msg << "If-Modified-Since: " << mkrfc1123(ims) << "\r\n";
+ msg << "If-Modified-Since: " << Time::FormatRfc1123(ims) << "\r\n";
}
if (max_forwards > -1) {
msg << "Max-Forwards: " << max_forwards << "\r\n";