]> code.citadel.org Git - citadel.git/commitdiff
Changed logging mechanism from a circular binary file to a text file. The
authorArt Cancro <ajc@citadel.org>
Sun, 12 Jul 1998 21:38:11 +0000 (21:38 +0000)
committerArt Cancro <ajc@citadel.org>
Sun, 12 Jul 1998 21:38:11 +0000 (21:38 +0000)
file is still intended to be read by other programs, not by humans, but the
format should be more straightforward at this time.

citadel/Makefile.in
citadel/citadel.h
citadel/citserver.c
citadel/readlog.c
citadel/setup.c

index de28dad84668c95d2c88b8d4bc46f571cdee2662..060cc911da954108d83e924558d1cb3355d69e7e 100644 (file)
@@ -61,10 +61,10 @@ client_chat.o: client_chat.c citadel.h
 
 citserver: citserver.o user_ops.o support.o room_ops.o file_ops.o \
        msgbase.o config.o sysdep.o locate_host.o serv_chat.o \
-       hooks.o housekeeping.o database.o control.o
+       hooks.o housekeeping.o database.o control.o logging.o
        $(CC) $(CFLAGS) citserver.o user_ops.o room_ops.o file_ops.o support.o \
                msgbase.o config.o sysdep.o locate_host.o serv_chat.o \
-               hooks.o housekeeping.o database.o control.o \
+               hooks.o housekeeping.o database.o control.o logging.o \
                $(LFLAGS) $(SERVER_LFLAGS) -o citserver
 
 citserver.o: citserver.c citadel.h
@@ -103,6 +103,9 @@ database.o: database.c citadel.h
 control.o: control.c citadel.h
        $(CC) $(CFLAGS) -D_REENTRANT -c control.c
 
+logging.o: logging.c citadel.h
+       $(CC) $(CFLAGS) -D_REENTRANT -c logging.c
+
 config.o: config.c citadel.h axdefs.h
        $(CC) -O $(CFLAGS) -D_REENTRANT -c config.c
 
index 2ed5733293b5d3fd1a447d7d8b337265cdd05a50..7f8bca5681a20d56377ed450f344d9d44621d75d 100644 (file)
@@ -151,20 +151,12 @@ struct quickroom {
 
 struct fullroom {
        long FRnum[MSGSPERRM];          /* Message NUMBERS                  */
-       long FRpos[MSGSPERRM];          /* Message POSITIONS in master file */
                };
 
-/* This structure is not 'circular'. When scrolling, each message moves
- * down a slot, and the oldest one falls off the bottom. A null message is 
- * represented by the value 0L in both fields.
- */
-
-struct calllog {
-       char CLfullname[30];            /* Name of user                     */
-       long CLtime;                    /* Date/time of record              */
-       unsigned CLflags;               /* Info on record                   */
-       };
 
+/*
+ * Events which might show up in the Citadel Log
+ */
 #define CL_CONNECT     8               /* Connect to server                */
 #define CL_LOGIN       16              /* CLfullname logged in             */
 #define CL_NEWUSER     32              /* CLfullname is a new user         */
index bdd477b892a7b33763de9004975d1c902fd2f964..d3cd6ed3d576c305b023372a071b1659ecd7fb7a 100644 (file)
@@ -19,37 +19,6 @@ struct CitContext *ContextList = NULL;
 int ScheduledShutdown = 0;
 
        
-/*
- * record an entry in the call log
- */
-void rec_log(unsigned int lrtype, char *name)
-{
-       struct calllog record;
-       int file,file2,a,b;
-
-
-       time(&record.CLtime);
-       record.CLflags = lrtype;
-       strncpy(record.CLfullname,name,29);
-
-       begin_critical_section(S_CALLLOG);
-       file=open("calllog.pos",O_RDWR);
-
-       read(file,&a,sizeof(int));
-       b=a; ++a; if (a>=CALLLOG) a=0;
-       lseek(file,0L,0);
-       write(file,&a,sizeof(int));
-
-       file2=open("calllog",O_RDWR);
-       lseek(file2,(long)(b*sizeof(struct calllog)),0);
-       write(file2,(char *)&record,sizeof(struct calllog));
-       close(file2);
-
-       close(file);
-       end_critical_section(S_CALLLOG);
-       }
-
-
 /*
  * Various things that need to be initialized at startup
  */
index 91e196f04686dde4e3baaac081feba8051d140fb..e4fd7dd88f3cfe10d5729f0032c3f2b846f45ff1 100644 (file)
@@ -1,6 +1,6 @@
 /* 
  * readlog.c
- * v1.4
+ * v1.5
  */
 
 #include <stdlib.h>
 #include <time.h>
 #include "citadel.h"
 
-void get_config();
+void get_config ();
 struct config config;
 
-void last20(file,pos)
-int file;
-long pos;
+void 
+main (argc, argv)
+     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;
+  FILE *logfp;
+
+  get_config ();
+
+  logfp = fopen ("citadel.log", "r");
+  if (logfp == NULL)
+    {
+      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)
        {
-       int a,count;
-       long aa;
-       struct calllog calllog;
-       struct calllog listing[20];
-       struct tm *tm;
-       char *tstring;
-       
-       count=0;
-       for (a=0; a<20; ++a) {
-               listing[a].CLfullname[0]=0;
-               listing[a].CLtime=0L;
-               listing[a].CLflags=0;
-               }
-       aa=pos-1;
-       while(count<20) {
-               if (aa<0L) aa=CALLLOG;
-               lseek(file,(aa*sizeof(struct calllog)),0);
-               a=read(file,(char *)&calllog,sizeof(struct calllog));
-               if (calllog.CLflags==CL_LOGIN) {
-                       strcpy(listing[count].CLfullname,calllog.CLfullname);
-                       listing[count].CLtime=calllog.CLtime;
-                       listing[count].CLflags=calllog.CLflags;
-                       ++count;
-                       }
-               if (aa==pos) break;
-               aa=aa-1;
-               }
-       for (a=19; a>=0; --a) {
-               tm=(struct tm *)localtime(&listing[a].CLtime);
-               tstring=(char *)asctime(tm);
-               printf("%30s %s",listing[a].CLfullname,tstring);
-               }
-       }
+         buf[strlen (buf) - 1] = 0;
 
-void main(argc,argv)
-int argc;
-char *argv[]; {
-       struct calllog calllog;
-       int file,pos,a,b;
-       char aaa[100];
-       struct tm *tm;
-       char *tstring;
+         LogTime = atol (buf);
+         strcpy (buf, index (buf, '|'));
+         LogType = atoi (buf);
+         strcpy (buf, index (buf, '|'));
+         strcpy (LogName, buf);
 
-       get_config();
-       file=open("calllog.pos",O_RDONLY);
-       a=read(file,(char *)&pos,sizeof(int));
-       close(file);
 
-       file=open("calllog",O_RDONLY);
-       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 {
-       lseek(file,(long)(pos*sizeof(struct calllog)),0);
-       for (a=0; a<CALLLOG; ++a) {
-               if ((a+pos)==CALLLOG) lseek(file,0L,0);
-               b=read(file,(char *)&calllog,sizeof(struct calllog));
-       if (calllog.CLflags!=0) {
-               strcpy(aaa,"");
-               if (calllog.CLflags&CL_CONNECT) strcpy(aaa,"Connect");
-               if (calllog.CLflags&CL_LOGIN)   strcpy(aaa,"Login");
-               if (calllog.CLflags&CL_NEWUSER) strcpy(aaa,"New User");
-               if (calllog.CLflags&CL_BADPW)   strcpy(aaa,"Bad PW Attempt");
-               if (calllog.CLflags&CL_TERMINATE) strcpy(aaa,"Terminate");
-               if (calllog.CLflags&CL_DROPCARR) strcpy(aaa,"Dropped Carrier");
-               if (calllog.CLflags&CL_SLEEPING) strcpy(aaa,"Sleeping");
-               if (calllog.CLflags&CL_PWCHANGE) strcpy(aaa,"Changed Passwd");
-               tm=(struct tm *)localtime(&calllog.CLtime);
-               tstring=(char *)asctime(tm);
-               printf("%30s %20s %s",calllog.CLfullname,aaa,tstring);
-               }
-               }
+         if (LogType != 0)
+           {
+             strcpy (aaa, "");
+             if (LogType & CL_CONNECT)
+               strcpy (aaa, "Connect");
+             if (LogType & CL_LOGIN)
+               strcpy (aaa, "Login");
+             if (LogType & CL_NEWUSER)
+               strcpy (aaa, "New User");
+             if (LogType & CL_BADPW)
+               strcpy (aaa, "Bad PW Attempt");
+             if (LogType & CL_TERMINATE)
+               strcpy (aaa, "Terminate");
+             if (LogType & CL_DROPCARR)
+               strcpy (aaa, "Dropped Carrier");
+             if (LogType & CL_SLEEPING)
+               strcpy (aaa, "Sleeping");
+             if (LogType & CL_PWCHANGE)
+               strcpy (aaa, "Changed Passwd");
+             tm = (struct tm *) localtime (&LogTime);
+             tstring = (char *) asctime (tm);
+             printf ("%30s %20s %s", LogName, aaa, tstring);
+           }
        }
-       close(file);
-       exit(0);
+    }
+  fclose(logfp);
+  exit (0);
 }
-       
index 16ab9a9b64f62b063dd4bbe2708f45ea6150cb69..3cead512d706f3850e640006eba1ab6ef191e773 100644 (file)
@@ -223,10 +223,6 @@ char *setup_text[] = {
 "28",
 "29",
 "30",
-"DO NOT re-create files that you wish to keep intact!",
-"They will be permanently ERASED if you do so!",
-"(Obviously, if this is the first time you are setting up the BBS,",
-"then you will want to create all of the files.)",
 
 "31",
 "Setup has detected that you currently have data files from a Citadel/UX",
@@ -664,36 +660,6 @@ void check_inittab_entry() {
 
 
 
-/*
- * Create a blank call log
- */
-void cre8clog() {
-       int file,a;
-       struct calllog calllog;
-
-       calllog.CLfullname[0]=0;
-       calllog.CLtime=0L;
-       calllog.CLflags=0;
-       a=0;
-
-       file=creat("calllog.pos",0666);
-       chmod("calllog.pos",0666);
-       write(file,&a,sizeof(int));
-       close(file);
-
-       file=creat("calllog",0666);
-       chmod("calllog",0666);
-       for (a=0; a<CALLLOG; ++a) {
-               progress("Creating call log file",
-                       (long)a,
-                       (long)CALLLOG-1
-                       );
-               write(file,&calllog,sizeof(struct calllog));
-               }
-       close(file);
-       }
-
-
 void set_str_val(int msgpos, char str[]) {
        char buf[4096];
        char setupmsg[4096];
@@ -1142,19 +1108,6 @@ NEW_INST:
        system("rm -fr ./expressmsgs 2>/dev/null");
        unlink("sessions");
 
-       important_msgnum(30);
-
-
-       a=0;
-       fp=fopen("calllog","r");
-       if (fp==NULL) {
-               cre8clog();
-               }
-       else {
-               fclose(fp);
-               if (yesno_s("Create call log?")==1) cre8clog();
-               }
-
        check_services_entry();         /* Check /etc/services */
        check_inittab_entry();          /* Check /etc/inittab */