]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
lib/string/strcpy/, lib/, src/, tests/: Move all copying APIs to a subdirectory
authorAlejandro Colomar <alx@kernel.org>
Thu, 27 Jun 2024 09:48:16 +0000 (11:48 +0200)
committerSerge Hallyn <serge@hallyn.com>
Tue, 2 Jul 2024 02:40:11 +0000 (21:40 -0500)
Signed-off-by: Alejandro Colomar <alx@kernel.org>
29 files changed:
lib/Makefile.am
lib/console.c
lib/failure.c
lib/log.c
lib/string/stpecpy.c [deleted file]
lib/string/strcpy/stpecpy.c [new file with mode: 0644]
lib/string/strcpy/stpecpy.h [moved from lib/string/stpecpy.h with 87% similarity]
lib/string/strcpy/strncpy.c [new file with mode: 0644]
lib/string/strcpy/strncpy.h [new file with mode: 0644]
lib/string/strcpy/strtcpy.c [moved from lib/string/strtcpy.c with 52% similarity]
lib/string/strcpy/strtcpy.h [moved from lib/string/strtcpy.h with 85% similarity]
lib/string/strcpy/zustr2stp.c [moved from lib/string/zustr2stp.c with 78% similarity]
lib/string/strcpy/zustr2stp.h [moved from lib/string/zustr2stp.h with 93% similarity]
lib/string/strncpy.h [deleted file]
lib/time/day_to_str.h
lib/utmp.c
src/chage.c
src/chfn.c
src/chsh.c
src/gpasswd.c
src/groupmod.c
src/login.c
src/logoutd.c
src/passwd.c
src/su.c
tests/unit/Makefile.am
tests/unit/test_strncpy.c
tests/unit/test_strtcpy.c
tests/unit/test_zustr2stp.c

index f6691d4c50359b2024234f6ec0edb04c0c3342de..aaee71672e93e3a017f3a53207d57249175ae811 100644 (file)
@@ -150,14 +150,16 @@ libshadow_la_SOURCES = \
        string/sprintf/stpeprintf.h \
        string/sprintf/xasprintf.c \
        string/sprintf/xasprintf.h \
-       string/stpecpy.c \
-       string/stpecpy.h \
+       string/strcpy/stpecpy.c \
+       string/strcpy/stpecpy.h \
+       string/strcpy/strncpy.c \
+       string/strcpy/strncpy.h \
+       string/strcpy/strtcpy.c \
+       string/strcpy/strtcpy.h \
+       string/strcpy/zustr2stp.c \
+       string/strcpy/zustr2stp.h \
        string/strftime.c \
        string/strftime.h \
-       string/strncpy.h \
-       string/strtcpy.c \
-       string/strtcpy.h \
-       string/zustr2stp.h \
        strtoday.c \
        sub.c \
        subordinateio.h \
index 92065d9b0a9314057b95801cb4af60ce587d3716..20e388ba5be1f7407655cb03b3d17f083ed1b48a 100644 (file)
@@ -13,7 +13,7 @@
 #include <stdio.h>
 #include "getdef.h"
 #include "prototypes.h"
-#include "string/strtcpy.h"
+#include "string/strcpy/strtcpy.h"
 
 #ident "$Id$"
 
index e42e7107396ec77698f36335718c07215612599b..55a10a71746c5bda5e8b0171030ba819ea06d83d 100644 (file)
@@ -21,7 +21,7 @@
 #include "memzero.h"
 #include "prototypes.h"
 #include "string/strftime.h"
-#include "string/strtcpy.h"
+#include "string/strcpy/strtcpy.h"
 
 
 #define        YEAR    (365L*DAY)
index 9f54d454743331a1f25815f2f6e617a3875baa18..fd78c6823b07ece4e3980f67208a22eaa11ab48b 100644 (file)
--- a/lib/log.c
+++ b/lib/log.c
@@ -19,8 +19,8 @@
 #include <lastlog.h>
 #include "memzero.h"
 #include "prototypes.h"
-#include "string/strncpy.h"
-#include "string/strtcpy.h"
+#include "string/strcpy/strncpy.h"
+#include "string/strcpy/strtcpy.h"
 
 
 /*
diff --git a/lib/string/stpecpy.c b/lib/string/stpecpy.c
deleted file mode 100644 (file)
index 9759388..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * SPDX-FileCopyrightText:  2022 - 2023, Alejandro Colomar <alx@kernel.org>
- *
- * SPDX-License-Identifier:  BSD-3-Clause
- */
-
-
-#include <config.h>
-
-#if !defined(HAVE_STPECPY)
-
-#ident "$Id$"
-
-#include "string/stpecpy.h"
-
-
-extern inline char *stpecpy(char *dst, char *end, const char *restrict src);
-
-
-#endif  // !HAVE_STPECPY
diff --git a/lib/string/strcpy/stpecpy.c b/lib/string/strcpy/stpecpy.c
new file mode 100644 (file)
index 0000000..3268663
--- /dev/null
@@ -0,0 +1,12 @@
+// SPDX-FileCopyrightText: 2022-2024, Alejandro Colomar <alx@kernel.org>
+// SPDX-License-Identifier: BSD-3-Clause
+
+
+#include <config.h>
+
+#include "string/strcpy/stpecpy.h"
+
+
+#if !defined(HAVE_STPECPY)
+extern inline char *stpecpy(char *dst, char *end, const char *restrict src);
+#endif
similarity index 87%
rename from lib/string/stpecpy.h
rename to lib/string/strcpy/stpecpy.h
index 2324baa56fdc91d8d25049348d1101f738aed04d..e9debe4ec191b1ab3380ea5cfe691f3718a2c1e2 100644 (file)
@@ -1,18 +1,13 @@
-/*
- * SPDX-FileCopyrightText:  2022 - 2023, Alejandro Colomar <alx@kernel.org>
- *
- * SPDX-License-Identifier:  BSD-3-Clause
- */
+// SPDX-FileCopyrightText: 2022-2024, Alejandro Colomar <alx@kernel.org>
+// SPDX-License-Identifier: BSD-3-Clause
 
 
-#ifndef SHADOW_INCLUDE_LIB_STPECPY_H_
-#define SHADOW_INCLUDE_LIB_STPECPY_H_
+#ifndef SHADOW_INCLUDE_LIB_STRING_STRCPY_STPECPY_H_
+#define SHADOW_INCLUDE_LIB_STRING_STRCPY_STPECPY_H_
 
 
 #include <config.h>
 
-#if !defined(HAVE_STPECPY)
-
 #include <stdbool.h>
 #include <stddef.h>
 #include <string.h>
 #include "attr.h"
 
 
+#if !defined(HAVE_STPECPY)
 ATTR_STRING(3)
 inline char *stpecpy(char *dst, char *end, const char *restrict src);
+#endif
 
 
 /*
@@ -66,6 +63,7 @@ inline char *stpecpy(char *dst, char *end, const char *restrict src);
  */
 
 
+#if !defined(HAVE_STPECPY)
 inline char *
 stpecpy(char *dst, char *end, const char *restrict src)
 {
@@ -84,7 +82,7 @@ stpecpy(char *dst, char *end, const char *restrict src)
 
        return stpcpy(mempcpy(dst, src, dlen), "") + trunc;
 }
+#endif
 
 
-#endif  // !HAVE_STPECPY
 #endif  // include guard
diff --git a/lib/string/strcpy/strncpy.c b/lib/string/strcpy/strncpy.c
new file mode 100644 (file)
index 0000000..5544fed
--- /dev/null
@@ -0,0 +1,7 @@
+// SPDX-FileCopyrightText: 2024, Alejandro Colomar <alx@kernel.org>
+// SPDX-License-Identifier: BSD-3-Clause
+
+
+#include <config.h>
+
+#include "string/strcpy/strncpy.h"
diff --git a/lib/string/strcpy/strncpy.h b/lib/string/strcpy/strncpy.h
new file mode 100644 (file)
index 0000000..fcb8720
--- /dev/null
@@ -0,0 +1,19 @@
+// SPDX-FileCopyrightText: 2024, Alejandro Colomar <alx@kernel.org>
+// SPDX-License-Identifier: BSD-3-Clause
+
+
+#ifndef SHADOW_INCLUDE_LIB_STRING_STRCPY_STRNCPY_H_
+#define SHADOW_INCLUDE_LIB_STRING_STRCPY_STRNCPY_H_
+
+
+#include <config.h>
+
+#include <string.h>
+
+#include "sizeof.h"
+
+
+#define STRNCPY(dst, src)  strncpy(dst, src, NITEMS(dst))
+
+
+#endif  // include guard
similarity index 52%
rename from lib/string/strtcpy.c
rename to lib/string/strcpy/strtcpy.c
index 74de4fc4b5c687e8d02dad8ee210c6b8856ec6e5..28e3d056b76e5f5975b5c4cbeb2ef3c7af3e96d0 100644 (file)
@@ -1,7 +1,5 @@
-/*
- * SPDX-FileCopyrightText: 2022-2023, Alejandro Colomar <alx@kernel.org>
- * SPDX-License-Identifier: BSD-3-Clause
- */
+// SPDX-FileCopyrightText: 2022-2024, Alejandro Colomar <alx@kernel.org>
+// SPDX-License-Identifier: BSD-3-Clause
 
 
 #include <config.h>
@@ -9,9 +7,7 @@
 #include <stddef.h>
 #include <sys/types.h>
 
-#ident "$Id$"
-
-#include "string/strtcpy.h"
+#include "string/strcpy/strtcpy.h"
 
 
 extern inline ssize_t strtcpy(char *restrict dst, const char *restrict src,
similarity index 85%
rename from lib/string/strtcpy.h
rename to lib/string/strcpy/strtcpy.h
index 4ff6e1110690b0ed4313fae64fb3869a0ef0dc18..4d35e1b81189183e29326a68d0e4c6e80ca0112b 100644 (file)
@@ -1,11 +1,9 @@
-/*
- * SPDX-FileCopyrightText: 2023, Alejandro Colomar <alx@kernel.org>
- * SPDX-License-Identifier: BSD-3-Clause
- */
+// SPDX-FileCopyrightText: 2023-2024, Alejandro Colomar <alx@kernel.org>
+// SPDX-License-Identifier: BSD-3-Clause
 
 
-#ifndef SHADOW_INCLUDE_LIB_STRTCPY_H_
-#define SHADOW_INCLUDE_LIB_STRTCPY_H_
+#ifndef SHADOW_INCLUDE_LIB_STRING_STRCPY_STRTCPY_H_
+#define SHADOW_INCLUDE_LIB_STRING_STRCPY_STRTCPY_H_
 
 
 #include <config.h>
@@ -16,7 +14,6 @@
 #include <sys/types.h>
 
 #include "attr.h"
-#include "defines.h"
 #include "sizeof.h"
 
 
similarity index 78%
rename from lib/string/zustr2stp.c
rename to lib/string/strcpy/zustr2stp.c
index c98b60601573b333e188eb2923f6b5b649e47c3f..9f4c789a0633e11ef8269bfc55626617ecb98d69 100644 (file)
@@ -4,4 +4,4 @@
 
 #include <config.h>
 
-#include "string/zustr2stp.h"
+#include "string/strcpy/zustr2stp.h"
similarity index 93%
rename from lib/string/zustr2stp.h
rename to lib/string/strcpy/zustr2stp.h
index 152102b7a3e8a21919588ed8a3840db0c86a0a57..3064ce98112678da279ee9378c3f0abcf87306d8 100644 (file)
@@ -2,8 +2,8 @@
 // SPDX-License-Identifier: BSD-3-Clause
 
 
-#ifndef SHADOW_INCLUDE_LIB_STRING_ZUSTR2STP_H_
-#define SHADOW_INCLUDE_LIB_STRING_ZUSTR2STP_H_
+#ifndef SHADOW_INCLUDE_LIB_STRING_STRCPY_ZUSTR2STP_H_
+#define SHADOW_INCLUDE_LIB_STRING_STRCPY_ZUSTR2STP_H_
 
 
 #include <config.h>
diff --git a/lib/string/strncpy.h b/lib/string/strncpy.h
deleted file mode 100644 (file)
index fc6fcc9..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * SPDX-FileCopyrightText: 2023, Alejandro Colomar <alx@kernel.org>
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-
-#ifndef SHADOW_INCLUDE_LIB_STRNCPY_H_
-#define SHADOW_INCLUDE_LIB_STRNCPY_H_
-
-
-#include <config.h>
-
-#include <string.h>
-
-#include "sizeof.h"
-
-
-#define STRNCPY(dst, src)  strncpy(dst, src, NITEMS(dst))
-
-
-#endif  // include guard
index 96cec6e1fe878a6824330db2d84fd4a82e0535a8..374240f55ae4791b621f2206d232ff4b9d8991e7 100644 (file)
@@ -13,7 +13,7 @@
 
 #include "defines.h"
 #include "sizeof.h"
-#include "string/strtcpy.h"
+#include "string/strcpy/strtcpy.h"
 
 
 #define DAY_TO_STR(str, day)   day_to_str(NITEMS(str), str, day)
index 08e9b62503b71475e67ff8b3c2313f96aef6e6e4..d01a31166851494540323e2969b93e81bef55c33 100644 (file)
@@ -24,9 +24,9 @@
 
 #include "alloc.h"
 #include "sizeof.h"
-#include "string/strncpy.h"
-#include "string/strtcpy.h"
-#include "string/zustr2stp.h"
+#include "string/strcpy/strncpy.h"
+#include "string/strcpy/strtcpy.h"
+#include "string/strcpy/zustr2stp.h"
 
 #ident "$Id$"
 
index 57228972a1fcc48971bd3429b66c747adb049e31..b8af89cfafe228141f23ea2b3544096b32f452e3 100644 (file)
@@ -35,8 +35,8 @@
 #include "shadowio.h"
 #include "shadowlog.h"
 #include "string/sprintf/snprintf.h"
+#include "string/strcpy/strtcpy.h"
 #include "string/strftime.h"
-#include "string/strtcpy.h"
 #include "time/day_to_str.h"
 /*@-exitarg@*/
 #include "exitcodes.h"
index 663710648996f04fed864cf00817d982278a1d32..3c182e63e6abb5a55464cb087c87071cf4dd7dc4 100644 (file)
@@ -33,7 +33,7 @@
 #include "exitcodes.h"
 #include "shadowlog.h"
 #include "string/sprintf/snprintf.h"
-#include "string/strtcpy.h"
+#include "string/strcpy/strtcpy.h"
 
 
 /*
index c4918c1b1d6a353b0e2225ac6be13102ae15f474..c211c7a0fa3a287f84309f8536bd5b9e31a1d5b5 100644 (file)
@@ -31,7 +31,7 @@
 /*@-exitarg@*/
 #include "exitcodes.h"
 #include "shadowlog.h"
-#include "string/strtcpy.h"
+#include "string/strcpy/strtcpy.h"
 
 #ifndef SHELLS_FILE
 #define SHELLS_FILE "/etc/shells"
@@ -43,6 +43,7 @@
 #define ETCDIR "/etc"
 #endif
 
+
 /*
  * Global variables
  */
index 9983b314a32bd848bf13cd7602b2f094b320746d..0f00118b02934b750b1ce26dd90803e49e058ee2 100644 (file)
@@ -36,7 +36,7 @@
 #include "exitcodes.h"
 #include "shadowlog.h"
 #include "string/sprintf/snprintf.h"
-#include "string/strtcpy.h"
+#include "string/strcpy/strtcpy.h"
 
 
 /*
index 5c13d066f05ef513d9a80f919ad47e89cd4dd9f1..e39b76b899f9e79e0389dac8d739666fe8adaea5 100644 (file)
@@ -40,7 +40,7 @@
 #endif
 #include "shadowlog.h"
 #include "string/sprintf/stpeprintf.h"
-#include "string/stpecpy.h"
+#include "string/strcpy/stpecpy.h"
 
 
 /*
index 0342e8e8a17803950066035ddbafe2a7f4b6c247..cdfa132941a394e186319f58246397dc13b12d35 100644 (file)
@@ -39,8 +39,8 @@
 #include "exitcodes.h"
 #include "shadowlog.h"
 #include "string/sprintf/snprintf.h"
+#include "string/strcpy/strtcpy.h"
 #include "string/strftime.h"
-#include "string/strtcpy.h"
 
 
 #ifdef USE_PAM
index c8705101ded0bb22a43a68556a56c60ca3ac8f06..19bcb7457a9603737b03535e971effc122507116 100644 (file)
@@ -20,7 +20,9 @@
 #include "prototypes.h"
 #include "shadowlog.h"
 #include "sizeof.h"
-#include "string/zustr2stp.h"
+#include "string/strcpy/zustr2stp.h"
+
+
 /*
  * Global variables
  */
index 2999a3c88f84c5d3a62e7f8f4701bead3c80f9e2..e3291d08de6c9adc2bf0158cc5d1ba6dc58cc903 100644 (file)
@@ -33,7 +33,7 @@
 #include "pwio.h"
 #include "shadowio.h"
 #include "shadowlog.h"
-#include "string/strtcpy.h"
+#include "string/strcpy/strtcpy.h"
 #include "time/day_to_str.h"
 
 
index 42a72247c9b62c0955e0efdbf3f055749c7bf4af..428d9149d4c3243a04d09d3e6865b68ae323d5ca 100644 (file)
--- a/src/su.c
+++ b/src/su.c
@@ -60,7 +60,7 @@
 #include "exitcodes.h"
 #include "shadowlog.h"
 #include "string/sprintf/snprintf.h"
-#include "string/strtcpy.h"
+#include "string/strcpy/strtcpy.h"
 
 
 /*
index 17538776ad925f66aa8fe7abed4b87e188ba9efc..b73d70368878d16e14d0e674653791001beb1c65 100644 (file)
@@ -104,7 +104,7 @@ test_strncpy_LDADD = \
     $(NULL)
 
 test_strtcpy_SOURCES = \
-    ../../lib/string/strtcpy.c \
+    ../../lib/string/strcpy/strtcpy.c \
     test_strtcpy.c \
     $(NULL)
 test_strtcpy_CFLAGS = \
index 968765bb15511e35ba61a9353545a1b59f77edce..dedd4e2b4e1568e56c527b5a6e34eaeb6651322a 100644 (file)
@@ -15,7 +15,7 @@
 #include <cmocka.h>
 
 #include "sizeof.h"
-#include "string/strncpy.h"
+#include "string/strcpy/strncpy.h"
 
 
 static void test_STRNCPY_trunc(void **state);
index 12351a5372f99dbc3d0853103c510f98e305fcb9..c27d7c9dbe5005363d96e9ae90a3184f13bdfd62 100644 (file)
@@ -15,7 +15,7 @@
 #include <cmocka.h>
 
 #include "sizeof.h"
-#include "string/strtcpy.h"
+#include "string/strcpy/strtcpy.h"
 
 
 static void test_STRTCPY_trunc(void **state);
index 198d2eb658590619292274caa8579e1daeb17fbb..3072ce408c01f28eab012fe535320709f90a9c91 100644 (file)
@@ -13,7 +13,7 @@
 #include <stdint.h>  // Required by <cmocka.h>
 #include <cmocka.h>
 
-#include "string/zustr2stp.h"
+#include "string/strcpy/zustr2stp.h"
 
 
 static void test_ZUSTR2STP(void **state);