{
 ßßßßßßßß  ßßßßßß    ßß   ßß
   ßß     ßß   ßß   ßß  ßß
  ßß     ßß   ßßß  ßßßßß  The DoorKit!
 ßß     ßß   ßß   ßß  ßß
ßß     ßßßßßß    ßß    ßß
The BBS Door Development Kit By The People - For The People!


   Feel free to modify or optimize this code at will. All I ask is that if
   find a better way to do things (and you will), please send me a copy of
   your modifications. Thanks in advance!....Larry L. Athey....}

{$F+,I-,O-,N-}
{$D-,L-,R- }

UNIT GENOVR;

INTERFACE

USES OVERLAY,OVERXMS,DOS;

IMPLEMENTATION

FUNCTION OvrName : STRING;
VAR
  ofd     : DirStr;
  ofb     : NameStr;
  ofx     : ExtStr;
  DirInfo : SEARCHREC;
BEGIN
  IF PARAMSTR(0) = '' THEN BEGIN
    WRITELN('This program requires DOS 3.0 or higher');
    RunError(1000);
  END;
  FSplit(PARAMSTR(0),ofd,ofb,ofx);
  FINDFIRST(ofd + ofb + '.OVR',AnyFile - Directory - VolumeID,DirInfo);
  IF DOSERROR = 0 THEN OvrName := ofd + ofb + '.OVR'
                ELSE OvrName := ofd + ofb + '.EXE';
END;
   
PROCEDURE IncreaseBuffer(ofn : STRING; minfree : LONGINT);
VAR
  Size : LONGINT;
  ofl  : FILE;
BEGIN
  ASSIGN(ofl,ofn);
  RESET(ofl,1);
  Size := FILESIZE(ofl);
  CLOSE(ofl);
  IF Size > MAXAVAIL - MinFree THEN Size := MAXAVAIL - MinFree;
  IF (Size > OvrGetBuf) THEN OvrSetBuf(size)
END;
   
BEGIN
  OvrInit(OvrName);
  IF OvrResult <> 0 THEN RunError(OvrResult);
  OvrInitXMS;
  IF (OvrResult <> 0) THEN BEGIN
    OvrInitEMS;
    IF (OvrResult <> 0) THEN IncreaseBuffer(OvrName,128000);
  END;
END.
