Commit 3d097b6f authored by deuce's avatar deuce
Browse files

Port of slog (used by str_cmds)

parent dff73896
......@@ -221,3 +221,7 @@ $(QWKNODES): $(QWKNODES_OBJS)
@echo Linking $@
$(QUIET)$(CC) $(UTIL_LDFLAGS) -o $@ $(QWKNODES_OBJS) $(SMBLIB_LIBS) $(XPDEV_LIBS)
# SLOG
$(SLOG): $(SLOG_OBJS)
@echo Linking $@
$(QUIET)$(CC) $(UTIL_LDFLAGS) -o $@ $(SLOG_OBJS) $(XPDEV_LIBS)
......@@ -206,3 +206,8 @@ $(QWKNODES): $(QWKNODES_OBJS)
@echo Linking $@
$(QUIET)$(CC) $(UTIL_LDFLAGS) -e$@ $** $(SMBLIB_LIBS) $(XPDEV_LIBS)
# SLOG
$(SLOG): $(SLOG_OBJS)
@echo Linking $@
$(QUIET)$(CC) $(UTIL_LDFLAGS) -e$@ $** $(XPDEV_LIBS)
......@@ -239,4 +239,8 @@ QWKNODES_OBJS = \
$(OBJODIR)$(DIRSEP)scfglib1$(OFILE) \
$(OBJODIR)$(DIRSEP)scfglib2$(OFILE) \
$(OBJODIR)$(DIRSEP)str_util$(OFILE) \
$(OBJODIR)$(DIRSEP)ars$(OFILE) \
$(OBJODIR)$(DIRSEP)ars$(OFILE)
SLOG_OBJS = \
$(OBJODIR)$(DIRSEP)slog$(OFILE) \
$(OBJODIR)$(DIRSEP)nopen$(OFILE)
/* SLOG.C */
/* Developed 1990-1997 by Rob Swindell; PO Box 501, Yorba Linda, CA 92885 */
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <time.h>
#include <errno.h>
#include "sbbsdefs.h"
#include "nopen.h"
#include "dirwrap.h"
/****************************************************************************/
/* Lists system statistics for everyday the bbs has been running. */
/* Either for the current node (node=1) or the system (node=0) */
/****************************************************************************/
int main(int argc, char **argv)
{
char str[256],dir[256]={""},*p;
uchar *buf;
int i,file,pause=0,lncntr=0;
time_t timestamp;
long l;
ulong length,
logons,
timeon,
posts,
emails,
fbacks,
ulb,
uls,
dlb,
dls;
time_t yesterday;
struct tm *curdate;
printf("\nSynchronet System/Node Statistics Log Viewer v1.02\n\n");
for(i=1;i<argc;i++)
if(!stricmp(argv[i],"/P"))
pause=1;
else
strcpy(dir,argv[1]);
if(!dir[0]) {
p=getenv("SBBSCTRL");
if(p!=NULL)
strcpy(dir,p); }
backslash(dir);
sprintf(str,"%scsts.dab",dir);
if(!fexistcase(str)) {
printf("%s does not exist\r\n",str);
return(1); }
if((file=nopen(str,O_RDONLY))==-1) {
printf("Error opening %s\r\n",str);
return(1); }
length=filelength(file);
if(length<40) {
close(file);
return(1); }
if((buf=(char *)malloc(length))==0) {
close(file);
printf("error allocating %lu bytes\r\n",length);
return(1); }
read(file,buf,length);
close(file);
l=length-4;
while(l>-1L) {
fbacks=buf[l]|((long)buf[l+1]<<8)|((long)buf[l+2]<<16)
|((long)buf[l+3]<<24);
l-=4;
emails=buf[l]|((long)buf[l+1]<<8)|((long)buf[l+2]<<16)
|((long)buf[l+3]<<24);
l-=4;
posts=buf[l]|((long)buf[l+1]<<8)|((long)buf[l+2]<<16)
|((long)buf[l+3]<<24);
l-=4;
dlb=buf[l]|((long)buf[l+1]<<8)|((long)buf[l+2]<<16)
|((long)buf[l+3]<<24);
l-=4;
dls=buf[l]|((long)buf[l+1]<<8)|((long)buf[l+2]<<16)
|((long)buf[l+3]<<24);
l-=4;
ulb=buf[l]|((long)buf[l+1]<<8)|((long)buf[l+2]<<16)
|((long)buf[l+3]<<24);
l-=4;
uls=buf[l]|((long)buf[l+1]<<8)|((long)buf[l+2]<<16)
|((long)buf[l+3]<<24);
l-=4;
timeon=buf[l]|((long)buf[l+1]<<8)|((long)buf[l+2]<<16)
|((long)buf[l+3]<<24);
l-=4;
logons=buf[l]|((long)buf[l+1]<<8)|((long)buf[l+2]<<16)
|((long)buf[l+3]<<24);
l-=4;
timestamp=buf[l]|((long)buf[l+1]<<8)|((long)buf[l+2]<<16)
|((long)buf[l+3]<<24);
l-=4;
yesterday=timestamp-(24*60*60); /* 1 day less than stamp */
curdate=localtime(&yesterday);
printf("%2.2d/%2.2d/%2.2d T:%5lu L:%3lu P:%3lu "
"E:%3lu F:%3lu U:%6luk %3lu D:%6luk %3lu\n"
,curdate->tm_mon+1,curdate->tm_mday,curdate->tm_year%100,timeon,logons,posts,emails
,fbacks,ulb/1024,uls,dlb/1024,dls);
lncntr++;
if(pause && lncntr>=20) {
printf("[Hit a key]");
if(getch()==3)
break;
printf("\r");
lncntr=0; } }
free(buf);
return(0);
}
......@@ -29,13 +29,14 @@ ANS2ASC = $(EXEODIR)$(DIRSEP)ans2asc$(EXEFILE)
ASC2ANS = $(EXEODIR)$(DIRSEP)asc2ans$(EXEFILE)
SEXYZ = $(EXEODIR)$(DIRSEP)sexyz$(EXEFILE)
QWKNODES = $(EXEODIR)$(DIRSEP)qwknodes$(EXEFILE)
SLOG = $(EXEODIR)$(DIRSEP)slog$(EXEFILE)
UTILS = $(BUILD_DEPENDS)$(FIXSMB) $(BUILD_DEPENDS)$(CHKSMB) \
$(BUILD_DEPENDS)$(SMBUTIL) $(BUILD_DEPENDS)$(BAJA) $(BUILD_DEPENDS)$(NODE) \
$(BUILD_DEPENDS)$(SBBSECHO) $(BUILD_DEPENDS)$(ECHOCFG) $(BUILD_DEPENDS) \
$(BUILD_DEPENDS)$(ADDFILES) $(BUILD_DEPENDS)$(FILELIST) $(BUILD_DEPENDS)$(MAKEUSER) \
$(BUILD_DEPENDS)$(ANS2ASC) $(BUILD_DEPENDS)$(ASC2ANS) $(BUILD_DEPENDS)$(UNBAJA) \
$(BUILD_DEPENDS)$(QWKNODES)
$(BUILD_DEPENDS)$(QWKNODES) $(BUILD_DEPENDS)$(SLOG)
all: dlls utils console mono
......@@ -81,3 +82,4 @@ $(ANS2ASC):
$(ASC2ANS):
$(SEXYZ): $(XPDEV-MT_LIB) $(SMBLIB)
$(QWKNODES): $(XPDEV_LIB)
$(SLOG): $(XPDEV_LIB)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment