-/*
- * Return an ascii string with the current date + time
- * Uses strftime() if available, else falls back to ctime().
- */
-static char *
-get_timestr()
-{
- char *s;
- time_t now = time((time_t) 0);
-#ifdef HAVE_STRFTIME
- static char buf[128];
- struct tm *timeptr;
-
- timeptr = localtime(&now);
- if (def_log_year)
- s = "%h %e %T %Y";
- else
- s = "%h %e %T";
-
- /* strftime() does not guarantee to NUL-terminate so we must check. */
- buf[sizeof(buf) - 1] = '\0';
- if (strftime(buf, sizeof(buf), s, timeptr) && buf[sizeof(buf) - 1] == '\0')
- return(buf);
-
-#endif /* HAVE_STRFTIME */
-
- s = ctime(&now) + 4; /* skip day of the week */
- if (def_log_year)
- s[20] = '\0'; /* avoid the newline */
- else
- s[15] = '\0'; /* don't care about year */
-
- return(s);
-}
-