home *** CD-ROM | disk | FTP | other *** search
- #include <sys/types.h>
- #include <stdio.h>
- #include <time.h>
- #include <string.h>
- #include "config.h"
-
- 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
- }
-