#include /* module logs9b */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include /*****************************************************************************/ getlog(void) /* log no. 1 oldest log at beginning of file */ { int fail=0; long offset; offset=((long)nb+80L)*(long)(logno-1); /* find desired log offset */ if(fail=!(stream=fopen("logs.723","rb"))) /* open file */ { warn("COULD NOT OPEN LOGS.723"); goto abort; } if(fail=fseek(stream,offset,SEEK_SET)) /* move pointer to offset from beginning of file */ { warn("COULD NOT MOVE LOGS.723 POINTER"); goto abort; } if(fail=load(tyme,8)) { warn("UNABLE TO READ LOGGED TIME"); goto leave; } if(fail=load(dayt,8)) { warn("UNABLE TO READ LOGGED DATE"); goto leave; } if(fail=uload(status,nb)) { warn("UNABLE TO READ LOGGED STATUS"); goto leave; } if(fail=iload(avmet,32)) { warn("UNABLE TO READ LOGGED METERING"); goto leave; } leave: fclose(stream); abort: return(fail); } /*****************************************************************************/ getblock(n,block) /* log no. 1 oldest log at beginning of file */ /* n = first log in block, block = total logs */ { int fail; long offset; offset=((long)nb+80L)*(long)(n-1); /* find desired log offset */ if(fail=!(stream=fopen("logs.723","rb"))) /* open file */ { warn("could not open LOGS.723"); goto abort; } if(fail=fseek(stream,offset,SEEK_SET)) /* move pointer to offset from beginning of file */ { warn("COULD NOT MOVE LOGS.723 POINTER"); goto abort; } if(fail=uload(utemp,(nb+80)*block)) warn("UNABLE TO READ LOGS"); fclose(stream); abort: return(fail); } /*****************************************************************************/ storelog(void) /* store a log */ { int i,fail; if(fail=(inlog()||inhist())) goto abort; if(fail=status[35]&0x80) goto abort; /* simulation mode */ if(counter[0]17) goto await; /* page full */ if(index>=nb*8-1) goto loop3; /* get next log */ else goto loop; /* next change */ await: if(flag&&!pact) /* (RS) */ { pause(2); goto abort; } if(pact&&pflag) fprintf(stdprn,"\f"); k=caps(); if(k==PUP) { logno=logno-40; if(logno<1) logno=1; if(fail=getlog()) goto abort; goto loop2; } if(k!=PDN) goto rupt; if(logno!=counter[0]) { if(index==nb*8) /* last change for this log */ goto loop2; /* display another 20 lines */ else { rect(BLACK,0,420,639,0);/* clear data area */ line=0; goto loop4; /* finish current log */ } } k=0; rupt: keyboard[0]=k; if(pact&&(!pflag)) fprintf(stdprn,"\f"); if(k<128) prompt(keyboard); abort: logno=tempno; /* recover original log no. */ restdata(); /* recover original status */ if(logno) fail=getlog(); /* recover original log */ refresh=1; return(fail); } /*****************************************************************************/ compare(buf1,buf2) /* compare n bytes bit by bit */ unsigned char *buf1,*buf2; { unsigned char mask; int i,j,index,shift; shift=next; for(i=shift/8;inb*8) index=nb*8; /* no change */ return(index); } /****************************************************************************/ backdata(void) /* save real-time status */ { int i; for(i=0;i