]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
lib/io/: fgets_a(): Add macro
authorAlejandro Colomar <alx@kernel.org>
Mon, 12 Aug 2024 01:20:46 +0000 (03:20 +0200)
committerAlejandro Colomar <foss+github@alejandro-colomar.es>
Mon, 16 Mar 2026 11:12:58 +0000 (12:12 +0100)
Reviewed-by: Iker Pedrosa <ipedrosa@redhat.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
lib/Makefile.am
lib/io/fgets/fgets.c [new file with mode: 0644]
lib/io/fgets/fgets.h [new file with mode: 0644]

index 0727548192715a352a7684de51a2554936ef34d8..0257c76055850ad1cf1fc2af91789cf6c5a6415a 100644 (file)
@@ -103,6 +103,8 @@ libshadow_la_SOURCES = \
        hushed.c \
        idmapping.h \
        idmapping.c \
+       io/fgets/fgets.c \
+       io/fgets/fgets.h \
        io/syslog.c \
        io/syslog.h \
        isexpired.c \
diff --git a/lib/io/fgets/fgets.c b/lib/io/fgets/fgets.c
new file mode 100644 (file)
index 0000000..1d9dec4
--- /dev/null
@@ -0,0 +1,7 @@
+// SPDX-FileCopyrightText: 2024, Alejandro Colomar <alx@kernel.org>
+// SPDX-License-Identifier: BSD-3-Clause
+
+
+#include "config.h"
+
+#include "io/fgets/fgets.h"
diff --git a/lib/io/fgets/fgets.h b/lib/io/fgets/fgets.h
new file mode 100644 (file)
index 0000000..5dc27d8
--- /dev/null
@@ -0,0 +1,20 @@
+// SPDX-FileCopyrightText: 2024-2025, Alejandro Colomar <alx@kernel.org>
+// SPDX-License-Identifier: BSD-3-Clause
+
+
+#ifndef SHADOW_INCLUDE_LIB_IO_FGETS_FGETS_H_
+#define SHADOW_INCLUDE_LIB_IO_FGETS_FGETS_H_
+
+
+#include "config.h"
+
+#include <stdio.h>
+
+#include "sizeof.h"
+
+
+// fgets_a - FILE get string array-safe
+#define fgets_a(buf, stream)  fgets(buf, countof(buf), stream)
+
+
+#endif  // include guard