]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
lib/: Move get_date() to lib/strtoday.c
authorAlejandro Colomar <alx@kernel.org>
Tue, 18 Feb 2025 14:38:35 +0000 (15:38 +0100)
committerIker Pedrosa <ikerpedrosam@gmail.com>
Mon, 2 Jun 2025 07:59:51 +0000 (09:59 +0200)
Signed-off-by: Alejandro Colomar <alx@kernel.org>
lib/Makefile.am
lib/getdate.c [deleted file]
lib/getdate.h [deleted file]
lib/strtoday.c

index e6a2cf2df4f6d4eef49fc2f5dbd2b89a990280ca..04e6c251c682554bbe02bf3d777a3b0025f29c39 100644 (file)
@@ -104,8 +104,6 @@ libshadow_la_SOURCES = \
        fs/readlink/readlinknul.c \
        fs/readlink/readlinknul.h \
        get_pid.c \
-       getdate.c \
-       getdate.h \
        getdef.c \
        getdef.h \
        getgr_nam_gid.c \
diff --git a/lib/getdate.c b/lib/getdate.c
deleted file mode 100644 (file)
index cc2c3f1..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-// SPDX-FileCopyrightText: 2025, Alejandro Colomar <alx@kernel.org>
-// SPDX-FileCopyrightText: 2025, "Haelwenn (lanodan) Monnier" <contact@hacktivis.me>
-// SPDX-License-Identifier: BSD-3-Clause
-
-
-#include <config.h>
-
-#include <stddef.h>
-#include <time.h>
-
-#include "getdate.h"
-#include "string/strcmp/streq.h"
-
-
-time_t
-get_date(const char *s)
-{
-       time_t      t;
-       struct tm   tm;
-       const char  *p;
-
-       t = 0;
-       if (gmtime_r(&t, &tm) == NULL)
-               return -1;
-
-       p = strptime(s, "%Y-%m-%d", &tm);
-       if (p == NULL || !streq(p, ""))
-               return -1;
-
-       return timegm(&tm);
-}
diff --git a/lib/getdate.h b/lib/getdate.h
deleted file mode 100644 (file)
index 7348559..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-/*
- * SPDX-FileCopyrightText: 1990 - 1994, Julianne Frances Haugh
- * SPDX-FileCopyrightText: 1997 - 2000, Marek Michałkiewicz
- * SPDX-FileCopyrightText: 2005       , Tomasz Kłoczko
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#ifndef _GETDATE_H_
-#define _GETDATE_H_
-
-#include <config.h>
-#include "defines.h"
-
-time_t get_date(const char *s);
-#endif
index 6e0e55c704d0c58871c795373be0223fc0d47faa..ea327faeeeb455b241edc1851d7b325eca03d1c0 100644 (file)
@@ -1,22 +1,26 @@
-/*
- * SPDX-FileCopyrightText: 1991 - 1994, Julianne Frances Haugh
- * SPDX-FileCopyrightText: 1996 - 1999, Marek Michałkiewicz
- * SPDX-FileCopyrightText: 2003 - 2005, Tomasz Kłoczko
- * SPDX-FileCopyrightText: 2008       , Nicolas François
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
+// SPDX-FileCopyrightText: 1991-1994, Julianne Frances Haugh
+// SPDX-FileCopyrightText: 1996-1999, Marek Michałkiewicz
+// SPDX-FileCopyrightText: 2003-2005, Tomasz Kłoczko
+// SPDX-FileCopyrightText: 2008, Nicolas François
+// SPDX-FileCopyrightText: 2025, Alejandro Colomar <alx@kernel.org>
+// SPDX-FileCopyrightText: 2025, "Haelwenn (lanodan) Monnier" <contact@hacktivis.me>
+// SPDX-License-Identifier: BSD-3-Clause
+
 
 #include <config.h>
 
-#include <ctype.h>
+#include <stddef.h>
+#include <time.h>
 
 #include "atoi/str2i.h"
-#include "getdate.h"
+#include "defines.h"
 #include "prototypes.h"
 #include "string/strcmp/streq.h"
 
 
+static time_t get_date(const char *s);
+
+
 // string parse-to day-since-Epoch
 long
 strtoday(const char *str)
@@ -39,3 +43,22 @@ strtoday(const char *str)
        }
        return t / DAY;
 }
+
+
+static time_t
+get_date(const char *s)
+{
+       time_t      t;
+       struct tm   tm;
+       const char  *p;
+
+       t = 0;
+       if (gmtime_r(&t, &tm) == NULL)
+               return -1;
+
+       p = strptime(s, "%Y-%m-%d", &tm);
+       if (p == NULL || !streq(p, ""))
+               return -1;
+
+       return timegm(&tm);
+}