]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
lib/string/strftime.[ch]: STRFTIME(): Add macro
authorAlejandro Colomar <alx@kernel.org>
Mon, 29 Jan 2024 12:43:07 +0000 (13:43 +0100)
committerAlejandro Colomar <alx@kernel.org>
Sat, 23 Mar 2024 23:16:00 +0000 (00:16 +0100)
This macro makes sure that the first argument is an array, and
calculates its size.

Reviewed-by: "Serge E. Hallyn" <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
lib/Makefile.am
lib/string/strftime.c [new file with mode: 0644]
lib/string/strftime.h [new file with mode: 0644]

index 58d9c14278fa5ca69c79f1beba81aad2e96b6a0d..0aa9d5ec569632bce56450a1117ec78a8483f7d7 100644 (file)
@@ -149,6 +149,8 @@ libshadow_la_SOURCES = \
        string/stpecpy.h \
        string/stpeprintf.c \
        string/stpeprintf.h \
+       string/strftime.c \
+       string/strftime.h \
        string/strncpy.h \
        string/strtcpy.c \
        string/strtcpy.h \
diff --git a/lib/string/strftime.c b/lib/string/strftime.c
new file mode 100644 (file)
index 0000000..ea1deb3
--- /dev/null
@@ -0,0 +1,7 @@
+// SPDX-FileCopyrightText: 2024, Alejandro Colomar <alx@kernel.org>
+// SPDX-License-Identifier: BSD-3-Clause
+
+
+#include <config.h>
+
+#include "strftime.h"
diff --git a/lib/string/strftime.h b/lib/string/strftime.h
new file mode 100644 (file)
index 0000000..bebb31a
--- /dev/null
@@ -0,0 +1,19 @@
+// SPDX-FileCopyrightText: 2024, Alejandro Colomar <alx@kernel.org>
+// SPDX-License-Identifier: BSD-3-Clause
+
+
+#ifndef SHADOW_INCLUDE_LIB_STRFTIME_H_
+#define SHADOW_INCLUDE_LIB_STRFTIME_H_
+
+
+#include <config.h>
+
+#include <time.h>
+
+#include "sizeof.h"
+
+
+#define STRFTIME(dst, fmt, ...)  strftime(dst, NITEMS(dst), fmt, __VA_ARGS__)
+
+
+#endif  // include guard