diff options
author | Alejandro Colomar <alx@kernel.org> | 2024-01-29 15:11:04 +0100 |
---|---|---|
committer | Serge Hallyn <serge@hallyn.com> | 2024-03-14 16:30:46 -0500 |
commit | be05c62bd7e146a54e6b54b1dc10c1e145e48381 (patch) | |
tree | 35605296e4bcaa7fb2d080e3de39e0c064285f1d | |
parent | 88760598f079f945fc7b6c72786e3101fd4f45b1 (diff) |
lib/, src/, po/: date_to_str(): Move function to header, and make inline
BTW, there's no translatable string in there.
Signed-off-by: Alejandro Colomar <alx@kernel.org>
-rw-r--r-- | lib/Makefile.am | 3 | ||||
-rw-r--r-- | lib/prototypes.h | 3 | ||||
-rw-r--r-- | lib/time/day_to_str.c | 10 | ||||
-rw-r--r-- | lib/time/day_to_str.h (renamed from lib/date_to_str.c) | 16 | ||||
-rw-r--r-- | po/POTFILES.in | 1 | ||||
-rw-r--r-- | src/chage.c | 8 | ||||
-rw-r--r-- | src/passwd.c | 2 | ||||
-rw-r--r-- | src/usermod.c | 1 |
8 files changed, 31 insertions, 13 deletions
diff --git a/lib/Makefile.am b/lib/Makefile.am index 86c6be73..58d9c142 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -53,7 +53,6 @@ libshadow_la_SOURCES = \ console.c \ copydir.c \ csrand.c \ - date_to_str.c \ defines.h \ encrypt.c \ env.c \ @@ -159,6 +158,8 @@ libshadow_la_SOURCES = \ subordinateio.h \ subordinateio.c \ sulog.c \ + time/day_to_str.c \ + time/day_to_str.h \ ttytype.c \ tz.c \ ulimit.c \ diff --git a/lib/prototypes.h b/lib/prototypes.h index ff4f7f99..0838884b 100644 --- a/lib/prototypes.h +++ b/lib/prototypes.h @@ -108,9 +108,6 @@ extern int copy_tree (const char *src_root, const char *dst_root, uid_t old_uid, uid_t new_uid, gid_t old_gid, gid_t new_gid); -/* date_to_str.c */ -extern void date_to_str (size_t size, char buf[size], long date); - /* encrypt.c */ extern /*@exposed@*//*@null@*/char *pw_encrypt (const char *, const char *); diff --git a/lib/time/day_to_str.c b/lib/time/day_to_str.c new file mode 100644 index 00000000..4acfe907 --- /dev/null +++ b/lib/time/day_to_str.c @@ -0,0 +1,10 @@ +// SPDX-FileCopyrightText: 2021-2024, Alejandro Colomar <alx@kernel.org> +// SPDX-License-Identifier: BSD-3-Clause + + +#include <config.h> + +#include "time/day_to_str.h" + + +extern inline void date_to_str(size_t size, char buf[size], long date); diff --git a/lib/date_to_str.c b/lib/time/day_to_str.h index cbba0e46..65601c96 100644 --- a/lib/date_to_str.c +++ b/lib/time/day_to_str.h @@ -4,18 +4,21 @@ */ +#ifndef SHADOW_INCLUDE_LIB_TIME_DAY_TO_STR_H_ +#define SHADOW_INCLUDE_LIB_TIME_DAY_TO_STR_H_ + + #include <config.h> -#include <string.h> #include <time.h> -#ident "$Id$" - #include "string/strtcpy.h" -#include "prototypes.h" -void +inline void date_to_str(size_t size, char buf[size], long date); + + +inline void date_to_str(size_t size, char buf[size], long date) { time_t t; @@ -36,3 +39,6 @@ date_to_str(size_t size, char buf[size], long date) if (strftime(buf, size, "%Y-%m-%d", tm) == 0) (void) strtcpy(buf, "future", size); } + + +#endif // include guard diff --git a/po/POTFILES.in b/po/POTFILES.in index d49a5460..ce610d1a 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -13,7 +13,6 @@ lib/cleanup_user.c lib/commonio.c lib/console.c lib/copydir.c -lib/date_to_str.c lib/encrypt.c lib/env.c lib/failure.c diff --git a/src/chage.c b/src/chage.c index c29ef99e..5788a190 100644 --- a/src/chage.c +++ b/src/chage.c @@ -27,19 +27,21 @@ #include <pwd.h> #include "alloc.h" -#include "prototypes.h" #include "defines.h" #include "memzero.h" +#include "prototypes.h" #include "pwio.h" #include "shadowio.h" #include "shadowlog.h" #include "string/sprintf.h" #include "string/strtcpy.h" +#include "time/day_to_str.h" +/*@-exitarg@*/ +#include "exitcodes.h" + #ifdef WITH_TCB #include "tcbfuncs.h" #endif -/*@-exitarg@*/ -#include "exitcodes.h" /* diff --git a/src/passwd.c b/src/passwd.c index 5a421937..1b797892 100644 --- a/src/passwd.c +++ b/src/passwd.c @@ -33,6 +33,8 @@ #include "shadowio.h" #include "shadowlog.h" #include "string/strtcpy.h" +#include "time/day_to_str.h" + /* * exit status values diff --git a/src/usermod.c b/src/usermod.c index 7f0393b6..63fb996d 100644 --- a/src/usermod.c +++ b/src/usermod.c @@ -59,6 +59,7 @@ #endif #include "shadowlog.h" #include "string/sprintf.h" +#include "time/day_to_str.h" /* |