]> code.citadel.org Git - citadel.git/blobdiff - citadel/readlog.c
* Changed the comments at the beginning of each file to a consistent format
[citadel.git] / citadel / readlog.c
index e4fd7dd88f3cfe10d5729f0032c3f2b846f45ff1..1964f9dc386a404fb46f4f42f020f398035939e4 100644 (file)
@@ -1,6 +1,7 @@
 /* 
- * readlog.c
- * v1.5
+ * $Id$
+ *
+ * A simple program to parse citadel.log
  */
 
 #include <stdlib.h>
@@ -8,22 +9,21 @@
 #include <fcntl.h>
 #include <stdio.h>
 #include <time.h>
+#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 buf[256];
-  int a, b;
   char aaa[100];
   struct tm *tm;
   char *tstring;
@@ -37,27 +37,16 @@ main (argc, argv)
       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)
        {
          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)
            {