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