Annotation of sbbs/src/sbbs3/slog.c, revision 1.1.1.2

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

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.