date and time created 83/02/11 15:44:35 by rrh
[unix-history] / usr / src / usr.bin / tip / log.c
/* log.c 4.3 81/11/29 */
#include "tip.h"
#ifdef ACULOG
static FILE *flog = NULL;
/*
* Log file maintenance routines
*/
logent(group, num, acu, message)
char *group, *num, *acu, *message;
{
char *user, *timestamp;
struct passwd *pwd;
long t;
if (flog == NULL)
return;
if (!lock(value(LOCK))) {
fprintf(stderr, "can't lock up accounting file\r\n");
return;
}
if ((user = getlogin()) == NOSTR)
if ((pwd = getpwuid(getuid())) == NOPWD)
user = "???";
else
user = pwd->pw_name;
t = time(0);
timestamp = ctime(&t);
timestamp[24] = '\0';
fprintf(flog, "%s (%s) <%s, %s, %s> %s\n",
user, timestamp, group,
#ifdef PRISTINE
"",
#else
num,
#endif
acu, message);
fflush(flog);
unlock();
}
loginit()
{
if ((flog = fopen(value(LOG), "a")) == NULL)
fprintf(stderr, "can't open log file\r\n");
}
#endif