|
|
1.1 ! root 1: /* SLOG.C */ ! 2: ! 3: /* Developed 1990-1997 by Rob Swindell; PO Box 501, Yorba Linda, CA 92885 */ ! 4: ! 5: #include <stdio.h> ! 6: #include <stdlib.h> ! 7: #include <fcntl.h> ! 8: #include <sys/stat.h> ! 9: #include <time.h> ! 10: #include <errno.h> ! 11: ! 12: #include "sbbsdefs.h" ! 13: #include "nopen.h" ! 14: #include "dirwrap.h" ! 15: ! 16: /****************************************************************************/ ! 17: /* Lists system statistics for everyday the bbs has been running. */ ! 18: /* Either for the current node (node=1) or the system (node=0) */ ! 19: /****************************************************************************/ ! 20: int main(int argc, char **argv) ! 21: { ! 22: char str[256],dir[256]={""},*p; ! 23: uchar *buf; ! 24: int i,file,pause=0,lncntr=0; ! 25: time_t timestamp; ! 26: long l; ! 27: ulong length, ! 28: logons, ! 29: timeon, ! 30: posts, ! 31: emails, ! 32: fbacks, ! 33: ulb, ! 34: uls, ! 35: dlb, ! 36: dls; ! 37: time_t yesterday; ! 38: struct tm *curdate; ! 39: ! 40: ! 41: printf("\nSynchronet System/Node Statistics Log Viewer v1.02\n\n"); ! 42: ! 43: for(i=1;i<argc;i++) ! 44: if(!stricmp(argv[i],"/P")) ! 45: pause=1; ! 46: else ! 47: strcpy(dir,argv[1]); ! 48: if(!dir[0]) { ! 49: p=getenv("SBBSCTRL"); ! 50: if(p!=NULL) ! 51: strcpy(dir,p); } ! 52: ! 53: backslash(dir); ! 54: ! 55: sprintf(str,"%scsts.dab",dir); ! 56: if(!fexistcase(str)) { ! 57: printf("%s does not exist\r\n",str); ! 58: return(1); } ! 59: if((file=nopen(str,O_RDONLY))==-1) { ! 60: printf("Error opening %s\r\n",str); ! 61: return(1); } ! 62: length=filelength(file); ! 63: if(length<40) { ! 64: close(file); ! 65: return(1); } ! 66: if((buf=(char *)malloc(length))==0) { ! 67: close(file); ! 68: printf("error allocating %lu bytes\r\n",length); ! 69: return(1); } ! 70: read(file,buf,length); ! 71: close(file); ! 72: l=length-4; ! 73: while(l>-1L) { ! 74: fbacks=buf[l]|((long)buf[l+1]<<8)|((long)buf[l+2]<<16) ! 75: |((long)buf[l+3]<<24); ! 76: l-=4; ! 77: emails=buf[l]|((long)buf[l+1]<<8)|((long)buf[l+2]<<16) ! 78: |((long)buf[l+3]<<24); ! 79: l-=4; ! 80: posts=buf[l]|((long)buf[l+1]<<8)|((long)buf[l+2]<<16) ! 81: |((long)buf[l+3]<<24); ! 82: l-=4; ! 83: dlb=buf[l]|((long)buf[l+1]<<8)|((long)buf[l+2]<<16) ! 84: |((long)buf[l+3]<<24); ! 85: l-=4; ! 86: dls=buf[l]|((long)buf[l+1]<<8)|((long)buf[l+2]<<16) ! 87: |((long)buf[l+3]<<24); ! 88: l-=4; ! 89: ulb=buf[l]|((long)buf[l+1]<<8)|((long)buf[l+2]<<16) ! 90: |((long)buf[l+3]<<24); ! 91: l-=4; ! 92: uls=buf[l]|((long)buf[l+1]<<8)|((long)buf[l+2]<<16) ! 93: |((long)buf[l+3]<<24); ! 94: l-=4; ! 95: timeon=buf[l]|((long)buf[l+1]<<8)|((long)buf[l+2]<<16) ! 96: |((long)buf[l+3]<<24); ! 97: l-=4; ! 98: logons=buf[l]|((long)buf[l+1]<<8)|((long)buf[l+2]<<16) ! 99: |((long)buf[l+3]<<24); ! 100: l-=4; ! 101: timestamp=buf[l]|((long)buf[l+1]<<8)|((long)buf[l+2]<<16) ! 102: |((long)buf[l+3]<<24); ! 103: l-=4; ! 104: yesterday=timestamp-(24*60*60); /* 1 day less than stamp */ ! 105: curdate=localtime(&yesterday); ! 106: printf("%2.2d/%2.2d/%2.2d T:%5lu L:%3lu P:%3lu " ! 107: "E:%3lu F:%3lu U:%6luk %3lu D:%6luk %3lu\n" ! 108: ,curdate->tm_mon+1,curdate->tm_mday,curdate->tm_year%100,timeon,logons,posts,emails ! 109: ,fbacks,ulb/1024,uls,dlb/1024,dls); ! 110: lncntr++; ! 111: if(pause && lncntr>=20) { ! 112: printf("[Hit a key]"); ! 113: if(getch()==3) ! 114: break; ! 115: printf("\r"); ! 116: lncntr=0; } } ! 117: free(buf); ! 118: return(0); ! 119: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.