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