PROGRAM NLookup;

USES Database,
     Fido,
     Ramon,
     Cfg,
     Nodelist;

VAR FAddr : FidoAddrType;
    {
    StartTimer,
    ToDo,
    Found,
    NotFound,
    Lp    : LONGINT;
    Z,N,F : WORD;
    }
    Found : BOOLEAN;

BEGIN
     WriteLn ('NODELIST.TDB Verification / Lookup Utility');
     WriteLn ('Written by Ramon van der Winkel');
     WriteLn;

     IF (ParamCount = 0) THEN
     BEGIN
          WriteLn ('Usage: NLOOKUP 2:200/111');
          Exit;
     END;

     (*
     IF (UpCaseString (ParamStr (1)) = 'SPEED') THEN
     BEGIN
          Found:=0;
          NotFound:=0;
          ToDo:=1000;

          WriteLn ('Doing ',ToDo,' random lookups, please wait..');

          StartTimer:=GetTimer;
          FOR Lp:=1 TO ToDo DO
          BEGIN
               Z:=Random (5);
               N:=Random (8000);
               F:=Random (8000);
               IF NodeList_Verify (Z,N,F) THEN
               BEGIN
                    WriteLn (Z,':',N,':',F);
                    Inc (Found);
               END ELSE
                  Inc (NotFound);
          END;

          WriteLn (ToDo,' lookups with ',
                   Found,' found and ',
                   NotFound,' not found in ',
                   GetTimer-StartTimer,' ticks');
     END ELSE
     *)

     FidoSplit (ParamStr (1),FAddr);
     WriteLn ('Searching for ',FAddr.Zone,':',FAddr.Net,'/',FAddr.Node);
     WriteLn;

     Found:=TRUE;

     Config.SystemDir:='';

     CASE NodeList_Verify (FAddr.Zone,FAddr.Net,FAddr.Node) OF
          0 : WriteLn ('NODELIST.TDB not accesible -> Found');
          1 : WriteLn ('Found!');
          2 : BEGIN
                   WriteLn ('Not found');
                   Found:=FALSE;
              END;
     END;

     IF Found THEN
        Halt (1)
     ELSE
         Halt (2);
END.
