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;
44 LogTime = atol (strtok(buf, "|"));
45 LogType = atol (strtok(NULL, "|"));
46 strcpy(LogName, strtok(NULL, "|"));
51 if (LogType & CL_CONNECT)
52 strcpy (aaa, "Connect");
53 if (LogType & CL_LOGIN)
54 strcpy (aaa, "Login");
55 if (LogType & CL_NEWUSER)
56 strcpy (aaa, "New User");
57 if (LogType & CL_BADPW)
58 strcpy (aaa, "Bad PW Attempt");
59 if (LogType & CL_TERMINATE)
60 strcpy (aaa, "Terminate");
61 if (LogType & CL_DROPCARR)
62 strcpy (aaa, "Dropped Carrier");
63 if (LogType & CL_SLEEPING)
64 strcpy (aaa, "Sleeping");
65 if (LogType & CL_PWCHANGE)
66 strcpy (aaa, "Changed Passwd");
67 tm = (struct tm *) localtime (&LogTime);
68 tstring = (char *) asctime (tm);
69 printf ("%30s %20s %s", LogName, aaa, tstring);