[Git][NTPsec/ntpsec][master] Move humanlogtime() to msyslog.c since it's only used there
Matt Selsky
gitlab at mg.gitlab.com
Wed Oct 18 03:02:29 UTC 2017
Matt Selsky pushed to branch master at NTPsec / ntpsec
Commits:
3dcda0e9 by Matt Selsky at 2017-10-17T22:55:37-04:00
Move humanlogtime() to msyslog.c since it's only used there
- - - - -
4 changed files:
- include/ntp_stdlib.h
- − libntp/humandate.c
- libntp/msyslog.c
- libntp/wscript
Changes:
=====================================
include/ntp_stdlib.h
=====================================
--- a/include/ntp_stdlib.h
+++ b/include/ntp_stdlib.h
@@ -109,7 +109,6 @@ extern char * estrdup_impl(const char *, const char *, int);
#endif
-extern const char * humanlogtime (void);
extern const char * eventstr (int);
extern const char * ceventstr (int);
extern const char * res_match_flags(unsigned short);
=====================================
libntp/humandate.c deleted
=====================================
--- a/libntp/humandate.c
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * humandate.c - convert an NTP (or the current) time to something readable
- */
-#include "config.h"
-#include <stdio.h>
-
-#include "ntp_fp.h"
-#include "lib_strbuf.h"
-#include "ntp_stdlib.h"
-
-
-/* This is used in msyslog.c; we don't want to clutter up the log with
- the year and day of the week, etc.; just the minimal date and time. */
-
-const char *
-humanlogtime(void)
-{
- char * bp;
- time_t cursec;
- struct tm tmbuf, *tm;
-
- cursec = time(NULL);
- tm = localtime_r(&cursec, &tmbuf);
- if (!tm)
- return "-- --- --:--:--";
-
- bp = lib_getbuf();
-
-#ifdef ENABLE_CLASSIC_MODE
- const char * const months[12] = {
- "Jan", "Feb", "Mar", "Apr", "May", "Jun",
- "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
- };
-
- snprintf(bp, LIB_BUFLENGTH, "%2d %s %02d:%02d:%02d",
- tm->tm_mday, months[tm->tm_mon],
- tm->tm_hour, tm->tm_min, tm->tm_sec);
-#else
- /* ISO 8601 is a better format, sort order equals time order */
- snprintf(bp, LIB_BUFLENGTH, "%02d-%02dT%02d:%02d:%02d",
- tm->tm_mon+1, tm->tm_mday,
- tm->tm_hour, tm->tm_min, tm->tm_sec);
-#endif /* ENABLE_CLASSIC_MODE */
-
- return bp;
-}
\ No newline at end of file
=====================================
libntp/msyslog.c
=====================================
--- a/libntp/msyslog.c
+++ b/libntp/msyslog.c
@@ -14,6 +14,7 @@
#include "ntp.h"
#include "ntp_debug.h"
#include "ntp_syslog.h"
+#include "lib_strbuf.h"
/* Use XSI-compliant strerror_r(3), prototype in string.h.
* Don't try moving this further up, else hilarity will ensue...
@@ -38,6 +39,7 @@ extern char * progname;
/* Declare the local functions */
static int mvfprintf(FILE *, const char *, va_list) NTP_PRINTF(2, 0);
+const char * humanlogtime(void);
static void addto_syslog (int, const char *);
#ifndef VSNPRINTF_PERCENT_M
static void errno_to_str(int, char *, size_t);
@@ -106,6 +108,42 @@ errno_to_str(
#endif /* VSNPRINTF_PERCENT_M */
+/* We don't want to clutter up the log with the year and day of the week,
+ etc.; just the minimal date and time. */
+const char *
+humanlogtime(void)
+{
+ char * bp;
+ time_t cursec;
+ struct tm tmbuf, *tm;
+
+ cursec = time(NULL);
+ tm = localtime_r(&cursec, &tmbuf);
+ if (!tm)
+ return "-- --- --:--:--";
+
+ bp = lib_getbuf();
+
+#ifdef ENABLE_CLASSIC_MODE
+ const char * const months[12] = {
+ "Jan", "Feb", "Mar", "Apr", "May", "Jun",
+ "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
+ };
+
+ snprintf(bp, LIB_BUFLENGTH, "%2d %s %02d:%02d:%02d",
+ tm->tm_mday, months[tm->tm_mon],
+ tm->tm_hour, tm->tm_min, tm->tm_sec);
+#else
+ /* ISO 8601 is a better format, sort order equals time order */
+ snprintf(bp, LIB_BUFLENGTH, "%02d-%02dT%02d:%02d:%02d",
+ tm->tm_mon+1, tm->tm_mday,
+ tm->tm_hour, tm->tm_min, tm->tm_sec);
+#endif /* ENABLE_CLASSIC_MODE */
+
+ return bp;
+}
+
+
/*
* addto_syslog()
* This routine adds the contents of a buffer to the syslog or an
=====================================
libntp/wscript
=====================================
--- a/libntp/wscript
+++ b/libntp/wscript
@@ -30,7 +30,6 @@ def build(ctx):
"clockwork.c",
"emalloc.c",
"hextolfp.c",
- "humandate.c",
"lib_strbuf.c",
"msyslog.c",
"ntp_calendar.c",
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/3dcda0e90b066ea6b9007d221479018c0416e668
---
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/3dcda0e90b066ea6b9007d221479018c0416e668
You're receiving this email because of your account on gitlab.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ntpsec.org/pipermail/vc/attachments/20171018/44128121/attachment.html>
More information about the vc
mailing list