]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Move timestamp() function to misc.cc
authorOtto Moerbeek <otto.moerbeek@open-xchange.com>
Wed, 10 Sep 2025 12:44:13 +0000 (14:44 +0200)
committerOtto Moerbeek <otto.moerbeek@open-xchange.com>
Wed, 10 Sep 2025 12:44:13 +0000 (14:44 +0200)
Signed-off-by: Otto Moerbeek <otto.moerbeek@open-xchange.com>
pdns/misc.cc
pdns/misc.hh
pdns/recursordist/rec-cookiestore.cc
pdns/recursordist/syncres.cc

index 8b662c5af80394bcb5ba338f4f5cf8ca08a7e274..4f1e5c482b9ce7f63813751e64b77ddfb12cedb5 100644 (file)
@@ -1796,3 +1796,17 @@ UniqueFilePtr openFileForWriting(const std::string& filePath, mode_t permissions
 }
 
 }
+
+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();
+}
index 482df37b2e7bdf3c465e240211b22714118dd3f4..34377a8d6a0a59e2b885242b9bc8120c4c0cda88 100644 (file)
@@ -895,3 +895,6 @@ using UniqueFilePtr = std::unique_ptr<FILE, FilePtrDeleter>;
 
 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);
index 885315cb0f22a1ffe1bfb05ca8821081295e74bd..98ece82147c72a5847668dd739831fd6e34dc5c8 100644 (file)
 #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>();
index 38bfb0646718f5b2336c4cb085e8d26e37b56f97..e7c8ae1ffaca7ac3dc809d4234e92040fb2cd940 100644 (file)
@@ -1014,20 +1014,6 @@ const char* isoDateTimeMillis(const struct timeval& tval, timebuf_t& buf)
   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>>,