}
}
+
+const char* timestamp(time_t arg, timebuf_t& buf)
+{
+ const std::string s_timestampFormat = "%Y-%m-%dT%T";
+ struct tm tmval{};
+ size_t len = strftime(buf.data(), buf.size(), s_timestampFormat.c_str(), localtime_r(&arg, &tmval));
+ if (len == 0) {
+ int ret = snprintf(buf.data(), buf.size(), "%lld", static_cast<long long>(arg));
+ if (ret < 0 || static_cast<size_t>(ret) >= buf.size()) {
+ buf[0] = '\0';
+ }
+ }
+ return buf.data();
+}
UniqueFilePtr openFileForWriting(const std::string& filePath, mode_t permissions, bool mustNotExist = true, bool appendIfExists = false);
}
+
+using timebuf_t = std::array<char, 64>;
+const char* timestamp(time_t arg, timebuf_t& buf);
#include "misc.hh"
#include "rec-cookiestore.hh"
-using timebuf_t = std::array<char, 64>;
-
-extern const char* timestamp(time_t arg, timebuf_t& buf); // XXX
-
void CookieStore::prune(time_t cutoff)
{
auto& ind = get<time_t>();
return buf.data();
}
-const char* timestamp(time_t arg, timebuf_t& buf)
-{
- const std::string s_timestampFormat = "%Y-%m-%dT%T";
- struct tm tmval{};
- size_t len = strftime(buf.data(), buf.size(), s_timestampFormat.c_str(), localtime_r(&arg, &tmval));
- if (len == 0) {
- int ret = snprintf(buf.data(), buf.size(), "%lld", static_cast<long long>(arg));
- if (ret < 0 || static_cast<size_t>(ret) >= buf.size()) {
- buf[0] = '\0';
- }
- }
- return buf.data();
-}
-
struct ednsstatus_t : public multi_index_container<SyncRes::EDNSStatus,
indexed_by<
ordered_unique<tag<ComboAddress>, member<SyncRes::EDNSStatus, ComboAddress, &SyncRes::EDNSStatus::address>>,