home *** CD-ROM | disk | FTP | other *** search
- /*
- * Copyright 1989, 1990, John F. Haugh II
- * All rights reserved.
- *
- * Use, duplication, and disclosure prohibited without
- * the express written permission of the author.
- */
-
- #include <sys/types.h>
- #include <stdio.h>
- #include <time.h>
- #ifndef BSD
- #include <string.h>
- #include <memory.h>
- #else
- #include <strings.h>
- #define strchr index
- #define strrchr rindex
- #endif
- #include "config.h"
-
- #ifndef lint
- static char sccsid[] = "@(#)sulog.c 2.2.1.1 09:09:55 11/26/90";
- #endif
-
- extern char name[];
- extern char oldname[];
-
- time_t time ();
-
- void sulog (success)
- int success;
- {
- #ifdef SULOG
- char *tty;
- char *cp;
- char *ttyname ();
- time_t clock;
- struct tm *tm;
- struct tm *localtime ();
- FILE *fp;
-
- if ((fp = fopen (SULOG, "a+")) == (FILE *) 0)
- return; /* can't open or create logfile */
-
- (void) time (&clock);
- tm = localtime (&clock);
-
- if (isatty (0) && (cp = ttyname (0))) {
- if (tty = strrchr (cp, '/'))
- tty++;
- else
- tty = cp;
- } else
- tty = "???";
-
- (void) fprintf (fp, "SU %.02d/%0.2d %.02d:%.02d %c %.6s %s-%s\n",
- tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min,
- success ? '+':'-', tty, oldname, name);
-
- fflush (fp);
- fclose (fp);
- #endif
- }
-