2 * readlog.c (a simple program to parse citadel.log)
34 logfp = fopen ("citadel.log", "r");
37 perror ("Could not open citadel.log");
42 while (fgets (buf, 256, logfp) != NULL)
44 buf[strlen (buf) - 1] = 0;
46 LogTime = atol (strtok(buf, "|"));
47 LogType = atol (strtok(NULL, "|"));
48 strcpy(LogName, strtok(NULL, "|"));
53 if (LogType & CL_CONNECT)
54 strcpy (aaa, "Connect");
55 if (LogType & CL_LOGIN)
56 strcpy (aaa, "Login");
57 if (LogType & CL_NEWUSER)
58 strcpy (aaa, "New User");
59 if (LogType & CL_BADPW)
60 strcpy (aaa, "Bad PW Attempt");
61 if (LogType & CL_TERMINATE)
62 strcpy (aaa, "Terminate");
63 if (LogType & CL_DROPCARR)
64 strcpy (aaa, "Dropped Carrier");
65 if (LogType & CL_SLEEPING)
66 strcpy (aaa, "Sleeping");
67 if (LogType & CL_PWCHANGE)
68 strcpy (aaa, "Changed Passwd");
69 tm = (struct tm *) localtime (&LogTime);
70 tstring = (char *) asctime (tm);
71 printf ("%30s %20s %s", LogName, aaa, tstring);