/*
- * readlog.c
- * v1.5
+ * $Id$
+ *
+ * A simple program to parse citadel.log
*/
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <stdio.h>
-#include <time.h>
+
+#if TIME_WITH_SYS_TIME
+# include <sys/time.h>
+# include <time.h>
+#else
+# if HAVE_SYS_TIME_H
+# include <sys/time.h>
+# else
+# include <time.h>
+# endif
+#endif
+
+#include <string.h>
+#include <errno.h>
#include "citadel.h"
-void get_config ();
+void get_config (void);
struct config config;
-void
-main (argc, argv)
- int argc;
- char *argv[];
+int
+main (int argc, char **argv)
{
time_t LogTime;
unsigned int LogType;
- char LogName[256];
+ char LogName[SIZ];
- char buf[256];
- int a, b;
+ char buf[SIZ];
char aaa[100];
struct tm *tm;
char *tstring;
perror ("Could not open citadel.log");
exit (errno);
}
- if (argc >= 2)
- {
- if (!strcmp (argv[1], "-t"))
- last20 (file, (long) pos);
- else
- fprintf (stderr, "%s: usage: %s [-t]\n", argv[0], argv[0]);
- close (file);
- exit (0);
- }
else
{
- while (fgets (buf, 256, logfp) != NULL)
+ while (fgets (buf, sizeof buf, logfp) != NULL)
{
buf[strlen (buf) - 1] = 0;
+ strcat(buf, " ");
- LogTime = atol (buf);
- strcpy (buf, index (buf, '|'));
- LogType = atoi (buf);
- strcpy (buf, index (buf, '|'));
- strcpy (LogName, buf);
-
+ LogTime = atol (strtok(buf, "|"));
+ LogType = atol (strtok(NULL, "|"));
+ strcpy(LogName, strtok(NULL, "|"));
if (LogType != 0)
{