And make them inline.
Signed-off-by: Alejandro Colomar <alx@kernel.org>
agetpass.h \
alloc.c \
alloc.h \
+ atoi/str2i.c \
+ atoi/str2i.h \
atoi/strtoi.c \
atoi/strtoi.h \
atoi/strtou_noneg.c \
getdate.y \
getdef.c \
getdef.h \
- getlong.c \
getgr_nam_gid.c \
getrange.c \
gettime.c \
- getulong.c \
groupio.c \
groupmem.c \
groupio.h \
--- /dev/null
+// SPDX-FileCopyrightText: 2007-2009, Nicolas François
+// SPDX-FileCopyrightText: 2023-2024, Alejandro Colomar <alx@kernel.org>
+// SPDX-License-Identifier: BSD-3-Clause
+
+
+#include <config.h>
+
+#include "atoi/str2i.h"
+
+
+extern inline int getlong(const char *restrict s, long *restrict n);
+extern inline int getulong(const char *restrict s, unsigned long *restrict n);
--- /dev/null
+// SPDX-FileCopyrightText: 2007-2009, Nicolas François
+// SPDX-FileCopyrightText: 2023-2024, Alejandro Colomar <alx@kernel.org>
+// SPDX-License-Identifier: BSD-3-Clause
+
+
+#ifndef SHADOW_INCLUDE_LIB_ATOI_STR2I_H_
+#define SHADOW_INCLUDE_LIB_ATOI_STR2I_H_
+
+
+#include <config.h>
+
+#include <stdlib.h>
+#include <errno.h>
+
+#include "atoi/str2i.h"
+#include "atoi/strtou_noneg.h"
+#include "attr.h"
+
+
+ATTR_ACCESS(write_only, 2)
+inline int getlong(const char *restrict s, long *restrict n);
+ATTR_ACCESS(write_only, 2)
+inline int getulong(const char *restrict s, unsigned long *restrict n);
+
+
+inline int
+getlong(const char *restrict s, long *restrict n)
+{
+ char *endp;
+ long val;
+
+ errno = 0;
+ val = strtol(s, &endp, 0);
+ if (('\0' == *s) || ('\0' != *endp) || (0 != errno))
+ return -1;
+
+ *n = val;
+ return 0;
+}
+
+
+inline int
+getulong(const char *restrict s, unsigned long *restrict n)
+{
+ char *endp;
+ unsigned long val;
+
+ errno = 0;
+ val = strtoul_noneg(s, &endp, 0);
+ if (('\0' == *s) || ('\0' != *endp) || (0 != errno))
+ return -1;
+
+ *n = val;
+ return 0;
+}
+
+
+#endif // include guard
#endif
#include "alloc.h"
+#include "atoi/str2i.h"
#include "getdef.h"
#include "shadowlog_internal.h"
#include "string/sprintf.h"
+++ /dev/null
-/*
- * SPDX-FileCopyrightText: 2007 - 2009, Nicolas François
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-
-#include <config.h>
-
-#ident "$Id$"
-
-#include <stdlib.h>
-#include <errno.h>
-
-#include "prototypes.h"
-
-
-/*
- * getlong - extract a long integer provided by the numstr string in *result
- *
- * It supports decimal, hexadecimal or octal representations.
- */
-int
-getlong(const char *restrict numstr, long *restrict result)
-{
- char *endptr;
- long val;
-
- errno = 0;
- val = strtol(numstr, &endptr, 0);
- if (('\0' == *numstr) || ('\0' != *endptr) || (0 != errno))
- return -1;
-
- *result = val;
- return 0;
-}
+++ /dev/null
-/*
- * SPDX-FileCopyrightText: 2007 - 2009, Nicolas François
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-
-#include <config.h>
-
-#ident "$Id: getlong.c 2763 2009-04-23 09:57:03Z nekral-guest $"
-
-#include <stdlib.h>
-#include <errno.h>
-
-#include "atoi/strtou_noneg.h"
-#include "prototypes.h"
-
-
-/*
- * getulong - extract an unsigned long integer provided by the numstr string in *result
- *
- * It supports decimal, hexadecimal or octal representations.
- */
-int
-getulong(const char *restrict numstr, unsigned long *restrict result)
-{
- char *endptr;
- unsigned long val;
-
- errno = 0;
- val = strtoul_noneg(numstr, &endptr, 0);
- if (('\0' == *numstr) || ('\0' != *endptr) || (0 != errno))
- return -1;
-
- *result = val;
- return 0;
-}
#include <strings.h>
#include "alloc.h"
+#include "atoi/str2i.h"
#include "prototypes.h"
#include "string/stpeprintf.h"
#include "idmapping.h"
#include "shadowlog.h"
#include "sizeof.h"
+
struct map_range *get_map_ranges(int ranges, int argc, char **argv)
{
struct map_range *mappings, *mapping;
#include "getdef.h"
#include "shadowlog.h"
#include <sys/resource.h>
+
+#include "atoi/str2i.h"
#include "memzero.h"
+
+
#ifndef LIMITS_FILE
#define LIMITS_FILE "/etc/limits"
#endif
/* getgr_nam_gid.c */
extern /*@only@*//*@null@*/struct group *getgr_nam_gid (/*@null@*/const char *grname);
-/* getlong.c */
-ATTR_ACCESS(write_only, 2)
-extern int getlong(const char *restrict numstr, long *restrict result);
-
/* get_pid.c */
extern int get_pid (const char *pidstr, pid_t *pid);
extern int get_pidfd_from_fd(const char *pidfdstr);
/* get_uid.c */
extern int get_uid (const char *uidstr, uid_t *uid);
-/* getulong.c */
-ATTR_ACCESS(write_only, 2)
-extern int getulong(const char *restrict numstr, unsigned long *restrict result);
-
/* fputsx.c */
ATTR_ACCESS(write_only, 1, 2)
extern /*@null@*/char *fgetsx(/*@returned@*/char *restrict, int, FILE *restrict);
#include <stdio.h>
#include <pwd.h>
#include <netdb.h>
+
+#include "atoi/str2i.h"
+
+
static struct {
int spd_name;
int spd_baud;
#include <sys/types.h>
#include <string.h>
+#include "atoi/str2i.h"
#include "prototypes.h"
#include "shadowlog_internal.h"
#include "defines.h"
#include "defines.h"
#include <stdio.h>
+#include "atoi/str2i.h"
+
static FILE *shadow;
#ident "$Id$"
+#include "atoi/str2i.h"
#include "prototypes.h"
#include "getdate.h"
+
/*
* strtoday() now uses get_date() (borrowed from GNU shellutils)
* which can handle many date formats, for example:
#include <string.h>
#include "alloc.h"
+#include "atoi/str2i.h"
#include "string/sprintf.h"
lib/get_gid.c
lib/get_uid.c
lib/getdef.c
-lib/getlong.c
lib/getgr_nam_gid.c
lib/getrange.c
lib/groupio.c
#include <pwd.h>
#include "alloc.h"
+#include "atoi/str2i.h"
#include "defines.h"
#include "memzero.h"
#include "prototypes.h"
#include <pwd.h>
#include <stdio.h>
#include <stdlib.h>
+
#ifdef ACCT_TOOLS_SETUID
#ifdef USE_PAM
#include "pam_defs.h"
#endif /* USE_PAM */
#endif /* ACCT_TOOLS_SETUID */
+#include "atoi/str2i.h"
#include "defines.h"
#include "nscd.h"
#include "sssd.h"
#include "exitcodes.h"
#include "shadowlog.h"
+
/*
* Global variables
*/
#include <pwd.h>
#include <stdio.h>
#include <stdlib.h>
+
#ifdef USE_PAM
#include "pam_defs.h"
#endif /* USE_PAM */
+#include "atoi/str2i.h"
#include "defines.h"
#include "nscd.h"
#include "sssd.h"
#include "exitcodes.h"
#include "shadowlog.h"
+
#define IS_CRYPT_METHOD(str) ((crypt_method != NULL && strcmp(crypt_method, str) == 0) ? true : false)
/*
#include <time.h>
#include <assert.h>
+#include "atoi/str2i.h"
#include "defines.h"
#include "faillog.h"
#include "memzero.h"
#include "string/strftime.h"
+
/* local function prototypes */
NORETURN static void usage (int status);
static void print_one (/*@null@*/const struct passwd *pw, bool force);
#include <net/if.h>
#endif
+#include "atoi/str2i.h"
#include "defines.h"
#include "prototypes.h"
#include "getdef.h"
#include "string/strftime.h"
+
/*
* Needed for MkLinux DR1/2/2.1 - J.
*/
#include <string.h>
#include "alloc.h"
+#include "atoi/str2i.h"
#ifdef ACCT_TOOLS_SETUID
#ifdef USE_PAM
#include "pam_defs.h"
#include "agetpass.h"
#include "alloc.h"
+#include "atoi/str2i.h"
#include "defines.h"
#include "getdef.h"
#include "memzero.h"
#include "time/day_to_str.h"
+
/*
* exit status values
*/
#include <unistd.h>
#include "alloc.h"
+#include "atoi/str2i.h"
#include "chkname.h"
#include "defines.h"
#include "faillog.h"
#include <time.h>
#include "alloc.h"
+#include "atoi/str2i.h"
#include "chkname.h"
#include "defines.h"
#include "faillog.h"