| 1 | /* log.c 4.3 81/11/29 */ |
| 2 | #include "tip.h" |
| 3 | |
| 4 | #ifdef ACULOG |
| 5 | static FILE *flog = NULL; |
| 6 | |
| 7 | /* |
| 8 | * Log file maintenance routines |
| 9 | */ |
| 10 | |
| 11 | logent(group, num, acu, message) |
| 12 | char *group, *num, *acu, *message; |
| 13 | { |
| 14 | char *user, *timestamp; |
| 15 | struct passwd *pwd; |
| 16 | long t; |
| 17 | |
| 18 | if (flog == NULL) |
| 19 | return; |
| 20 | if (!lock(value(LOCK))) { |
| 21 | fprintf(stderr, "can't lock up accounting file\r\n"); |
| 22 | return; |
| 23 | } |
| 24 | if ((user = getlogin()) == NOSTR) |
| 25 | if ((pwd = getpwuid(getuid())) == NOPWD) |
| 26 | user = "???"; |
| 27 | else |
| 28 | user = pwd->pw_name; |
| 29 | t = time(0); |
| 30 | timestamp = ctime(&t); |
| 31 | timestamp[24] = '\0'; |
| 32 | fprintf(flog, "%s (%s) <%s, %s, %s> %s\n", |
| 33 | user, timestamp, group, |
| 34 | #ifdef PRISTINE |
| 35 | "", |
| 36 | #else |
| 37 | num, |
| 38 | #endif |
| 39 | acu, message); |
| 40 | fflush(flog); |
| 41 | unlock(); |
| 42 | } |
| 43 | |
| 44 | loginit() |
| 45 | { |
| 46 | if ((flog = fopen(value(LOG), "a")) == NULL) |
| 47 | fprintf(stderr, "can't open log file\r\n"); |
| 48 | } |
| 49 | #endif |