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
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
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
*/
/*
* 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);
}
-
"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",
-/*
- * 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];
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 */