char *get_timestr(time_t, int);
/*
- * Return an ascii string with the current date + time
+ * Return a static buffer with the current date + time.
* Uses strftime() if available, else falls back to ctime().
*/
char *
struct tm *timeptr;
timeptr = localtime(&tstamp);
- if (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')
+ if (strftime(buf, sizeof(buf), log_year ? "%h %e %T %Y" : "%h %e %T",
+ timeptr) != 0 && buf[sizeof(buf) - 1] == '\0')
return buf;
#endif /* HAVE_STRFTIME */
alias_put(a);
} else {
if (!quiet) {
- char *fmt;
if (errno == ELOOP) {
- fmt = strict ?
+ warningx(strict ?
_("Error: cycle in %s_Alias `%s'") :
- _("Warning: cycle in %s_Alias `%s'");
+ _("Warning: cycle in %s_Alias `%s'"),
+ type == HOSTALIAS ? "Host" : type == CMNDALIAS ? "Cmnd" :
+ type == USERALIAS ? "User" : type == RUNASALIAS ? "Runas" :
+ "Unknown", name);
} else {
- fmt = strict ?
+ warningx(strict ?
_("Error: %s_Alias `%s' referenced but not defined") :
- _("Warning: %s_Alias `%s' referenced but not defined");
+ _("Warning: %s_Alias `%s' referenced but not defined"),
+ type == HOSTALIAS ? "Host" : type == CMNDALIAS ? "Cmnd" :
+ type == USERALIAS ? "User" : type == RUNASALIAS ? "Runas" :
+ "Unknown", name);
}
- warningx(fmt,
- type == HOSTALIAS ? "Host" : type == CMNDALIAS ? "Cmnd" :
- type == USERALIAS ? "User" : type == RUNASALIAS ? "Runas" :
- "Unknown", name);
}
errors++;
}