pw_log.c (50479) | pw_log.c (61957) |
---|---|
1/*- 2 * Copyright (C) 1996 3 * David L. Nugent. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 12 unchanged lines hidden (view full) --- 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 */ 26 27#ifndef lint 28static const char rcsid[] = | 1/*- 2 * Copyright (C) 1996 3 * David L. Nugent. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 12 unchanged lines hidden (view full) --- 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 */ 26 27#ifndef lint 28static const char rcsid[] = |
29 "$FreeBSD: head/usr.sbin/pw/pw_log.c 50479 1999-08-28 01:35:59Z peter $"; | 29 "$FreeBSD: head/usr.sbin/pw/pw_log.c 61957 2000-06-22 16:48:41Z ache $"; |
30#endif /* not lint */ 31 32#include <fcntl.h> 33 34#include "pw.h" 35 36static FILE *logfile = NULL; 37 --- 12 unchanged lines hidden (view full) --- 50 int l; 51 time_t now = time(NULL); 52 struct tm *t = localtime(&now); 53 char nfmt[256]; 54 char *name; 55 56 if ((name = getenv("LOGNAME")) == NULL && (name = getenv("USER")) == NULL) 57 name = "unknown"; | 30#endif /* not lint */ 31 32#include <fcntl.h> 33 34#include "pw.h" 35 36static FILE *logfile = NULL; 37 --- 12 unchanged lines hidden (view full) --- 50 int l; 51 time_t now = time(NULL); 52 struct tm *t = localtime(&now); 53 char nfmt[256]; 54 char *name; 55 56 if ((name = getenv("LOGNAME")) == NULL && (name = getenv("USER")) == NULL) 57 name = "unknown"; |
58 strftime(nfmt, sizeof nfmt, "%d-%b-%Y %R ", t); | 58 /* ISO 8601 International Standard Date format */ 59 strftime(nfmt, sizeof nfmt, "%Y-%m-%d %T ", t); |
59 l = strlen(nfmt); 60 sprintf(nfmt + strlen(nfmt), "[%s:%s%s] %s\n", name, Which[which], Modes[mode], fmt); 61 va_start(argp, fmt); 62 vfprintf(logfile, nfmt, argp); 63 va_end(argp); 64 fflush(logfile); 65 } 66 } 67} | 60 l = strlen(nfmt); 61 sprintf(nfmt + strlen(nfmt), "[%s:%s%s] %s\n", name, Which[which], Modes[mode], fmt); 62 va_start(argp, fmt); 63 vfprintf(logfile, nfmt, argp); 64 va_end(argp); 65 fflush(logfile); 66 } 67 } 68} |