summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlejandro Colomar <alx@kernel.org>2024-01-29 13:43:07 +0100
committerAlejandro Colomar <alx@kernel.org>2024-03-24 00:16:00 +0100
commitb3affb29cff0b16e24a53e0b629daffb597c499c (patch)
tree6d8c887011222811dec808977b796f7504eee718
parent0b3d017276f3aeeb3697f994002fa730091ed783 (diff)
lib/string/strftime.[ch]: STRFTIME(): Add macro
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>
-rw-r--r--lib/Makefile.am2
-rw-r--r--lib/string/strftime.c7
-rw-r--r--lib/string/strftime.h19
3 files changed, 28 insertions, 0 deletions
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 58d9c142..0aa9d5ec 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -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
index 00000000..ea1deb3f
--- /dev/null
+++ b/lib/string/strftime.c
@@ -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
index 00000000..bebb31a4
--- /dev/null
+++ b/lib/string/strftime.h
@@ -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