From: Piotrek Zadroga Date: Mon, 26 Feb 2024 11:16:09 +0000 (+0100) Subject: [#3212] reorder namespaces X-Git-Tag: Kea-2.5.7~43 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=832f77d3d12a60943972a83aa24ef378a71e4637;p=thirdparty%2Fkea.git [#3212] reorder namespaces --- diff --git a/src/lib/dns/time_utils.cc b/src/lib/dns/time_utils.cc index eb8fdd5b93..0bccd68608 100644 --- a/src/lib/dns/time_utils.cc +++ b/src/lib/dns/time_utils.cc @@ -9,14 +9,14 @@ #include #include +#include +#include +#include #include #include #include -#include -#include #include #include -#include using namespace std; @@ -41,6 +41,45 @@ monthSecs(const int month, const int year) { namespace isc { namespace util { +namespace { +const size_t DATE_LEN = 14; // YYYYMMDDHHmmSS + +inline uint64_t +ull(const int c) { + return (static_cast(c)); +} + +inline void +checkRange(const unsigned min, const unsigned max, const unsigned value, const string& valname) { + if ((value >= min) && (value <= max)) { + return; + } + + isc_throw(InvalidTime, "Invalid " << valname << " value: " << value); +} +} // anonymous namespace + +namespace detail { +// timeToText32() below uses the current system time. To test it with +// unusual current time values we introduce the following function pointer; +// when it's non NULL, we call it to get the (normally faked) current time. +// Otherwise we use the standard gettimeofday(2). This hook is specifically +// intended for testing purposes, so, even if it's visible outside of this +// library, it's not even declared in a header file. +int64_t (*getTimeFunction)() = 0; + +int64_t +getTimeWrapper() { + if (getTimeFunction != 0) { + return (getTimeFunction()); + } + + struct timeval now; + gettimeofday(&now, 0); + + return (static_cast(now.tv_sec)); +} +} // namespace detail string timeToText64(uint64_t value) { @@ -90,28 +129,6 @@ timeToText64(uint64_t value) { return (oss.str()); } -// timeToText32() below uses the current system time. To test it with -// unusual current time values we introduce the following function pointer; -// when it's non NULL, we call it to get the (normally faked) current time. -// Otherwise we use the standard gettimeofday(2). This hook is specifically -// intended for testing purposes, so, even if it's visible outside of this -// library, it's not even declared in a header file. -namespace detail { -int64_t (*getTimeFunction)() = 0; - -int64_t -getTimeWrapper() { - if (getTimeFunction != 0) { - return (getTimeFunction()); - } - - struct timeval now; - gettimeofday(&now, 0); - - return (static_cast(now.tv_sec)); -} -} // namespace detail - string timeToText32(const uint32_t value) { // We first adjust the time to the closest epoch based on the current time. @@ -128,24 +145,6 @@ timeToText32(const uint32_t value) { return (timeToText64(t)); } -namespace { -const size_t DATE_LEN = 14; // YYYYMMDDHHmmSS - -inline uint64_t -ull(const int c) { - return (static_cast(c)); -} - -inline void -checkRange(const unsigned min, const unsigned max, const unsigned value, const string& valname) { - if ((value >= min) && (value <= max)) { - return; - } - - isc_throw(InvalidTime, "Invalid " << valname << " value: " << value); -} -} // anonymous namespace - uint64_t timeFromText64(const string& time_txt) { // Confirm the source only consists digits. sscanf() allows some