2 * readlog.c (a simple program to parse citadel.log)
15 void get_config (void);
19 main (int argc, char **argv)
33 logfp = fopen ("citadel.log", "r");
36 perror ("Could not open citadel.log");
41 while (fgets (buf, 256, logfp) != NULL)
43 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);