Program ACCT;

{ Example for the NwAcct unit / NWTP 0.6, (c) 1995, R. Spronk }
{ Displays all login/logout account notes in the HET$ACCT.DAT file. }

uses nwMisc,nwAcct;

LABEL q;

{$I-}
Var f:File of byte;

    b,b2 :Byte;
    t,w  :word;
    s    :string;
    nTime:TnovTime;

    buf      :Array[1..4096] of byte;
    NoteAKA  :TNoteRecord   ABSOLUTE buf;
    ChargeAKA:TChargeRecord ABSOLUTE buf;

Begin
FileMode:=0; {open file read-only }
assign(f,'F:\system\net$acct.dat');
reset(f);
IF Ioresult<>0
 then begin
      writeln('Accounting file couldn''t be found..');
      halt(1);
      end;

REPEAT
 read(f,b); {length of record}
 read(f,b2);
 If IOresult<>0 then goto q;
 buf[1]:=b2;
 buf[2]:=b;
 for t:=1 to NoteAKA.Length
  do begin
     read(f,buf[t+2]);
     if IOresult>0 then goto q;
     end;
 IF (NoteAKA.RecType=RT_ACCOUNT_NOTE) and (swap(NoteAKA.CommentType) IN [3,4])
  then with NoteAKA
        do begin
           If swap(CommentType)=3
            then write('Logon  of ')
            else write('Logoff of ');
           write(HexStr(Lswap(ClientObjId),8));
           write(' from address ',HexDumpStr(Comment.Net,8),':',
                                  HexDumpStr(Comment.Node,12));
           Move(TimeStamp,ntime.year,6);
           ntime.dayOfWeek:=0;
           NovTime2String(ntime,s);delete(s,1,4);
           write(' at: ',s);

           writeln;
           end;
UNTIL eof(f);

q: ;
close(f);
end.
