{
 $Id$
}

 {opus 2.70}

Procedure Bbs13;

type
  _filesys = record
    Area_Name     : array [0..31] of char;     { Area's Name }
    Area_Number   : word;                      { Area's Number }
    Area_Menu     : word;                      { Which menu number for this area }
    Total_Size    : word;                      { Total size in SYSFILE.DAT for this area }
    Area_Priv     : byte;                      { Access privilege for this area }
    Down_Priv     : byte;                      { Download privilege for this area }
    Up_Priv       : byte;                      { Upload privilege for this area }
    Priv_Up       : byte;                      { Privilege for Private uploads }
    Ratio_Priv    : byte;                      { if (Priv <= Ratio_Priv) Ratios count }
    New_Priv      : byte;                      { Default privilege for new files uploaded here }
    fill_byte1    : array [0..1] of byte;      { Empty }
    Attrib        : word;                      { This area's attribute }
    Status        : word;                      { The status of area. (always 0, used internally) }
    Start_Pos     : Longint;                   { Where this area starts in SYSFILE.DAT }
    Area_Lock     : Longint;                   { Access lock }
    Up_Lock       : Longint;                   { Lock on upload command }
    Down_Lock     : Longint;                   { Lock on download command }
    Priv_Key      : Longint;                   { Private upload key }
    Section       : Longint;                   { This areas Section flag(s) }
    fill_long     : array[0..1] of Longint;    { Empty }
    Title_Len     : byte;                      { Length of title for this area }
    Prefiles_Len  : byte;                      { File shown before F)iles command }
    Downpath_Len  : byte;                      { Default download path }
    Uppath_Len    : byte;                      { Default upload path }
    Barricade_Len : byte;                      { Barricade path }
    Rules_Len     : byte;                      { RULES file name }
    Privkey_Len   : byte;                      { Private upload path if Keys and Priv_Key }
    PrivUp_Len    : byte;                      { Private upload path if Priv>Priv_Up }
    Menu_Len      : byte;                      { ASCII menu path }
    Vol_Len       : byte;                      { Drive VOLUME id }
    Help_Len      : byte;                      { Help for this area path }
    fill_byte2    : array[0..4] of byte;       { Empty }
    Other_Len     : word;                      { Other programs can stick something here }
    Def_Upload    : word;                      { Default upload area number }
    Priv_Upload   : word;                      { Priv upload area number }
    Key_Upload    : word;                      { Keyed upload area number }
    fill_word     : array[0..9] of word;       { Empty }
  end;

var
   afile    : _filesys;
   j        : integer;
   fh       : integer;
   now      : LongInt;
   Reg      : Registers;
   Names    : String;
   FileName : String;

   { After the _filesys structure, Strings are arranged like this }
   Title     : array[0..49] of char;
   Prefiles  : array[0..49] of char;
   Downpath  : array[0..49] of char;
   Barricade : array[0..49] of char;
   Rules     : array[0..49] of char;
   Menu      : array[0..49] of char;
   Upload    : array[0..49] of char;
   PUpload   : array[0..49] of char;
   KUpload   : array[0..49] of char;
   Help      : array[0..49] of char;
   Vol       : array[0..49] of char;
   Other     : array[0..49] of char;

Var
  Tel     : Word;
  X       : Integer;
  Writeok : boolean;

Begin

   Writeln('Converting Opus 2.70 file areas.',#10#13);
   AddToFile(false);
   Tel := 0;

   FileName := bbspath + 'SysFile.Dat';
   FileName := FileName + #00;

   Reg.AH := $3D;
   Reg.AL := $0;
   Reg.DS := Seg(FileName[1]);
   Reg.DX := Ofs(FileName[1]);
   MsDos(Reg);
   fh := Reg.AX;
   j := 1;
   Reg.Flags := 0;

   repeat
     FillChar(Bbs,sizeof(bbs),#0);
     Inc(tel);

     Reg.AX := $3F00;  { Read in the Structure }
     Reg.BX := fh;
     Reg.CX := sizeof(_filesys);
     Reg.DS := Seg(afile);
     Reg.DX := Ofs(afile);
     MsDos(Reg);
     if (Reg.AX <> sizeof(_filesys)) then j := 0 else
       begin

        X := 0;
        While (aFile.area_Name[x] <> #0) and (X < 32) do
          Begin
            Bbs.Name := Bbs.name + afile.area_name[x];
            Inc(x);
          End;

         if strip('B',' ',bbs.name) <> '' then writeok := true else
         writeok := false;

         if writeok then
           begin
             Inc(Number);
             Bbs.on   := false;
             Bbs.nr   := tel;
           end;

             Reg.AH := $3F;  { Read in the Title }
             Reg.BX := fh;
             Reg.CX := afile.Title_Len;
             Reg.DS := Seg(Title);
             Reg.DX := Ofs(Title);
             MsDos(Reg);

             Reg.AH := $3F;  { Read in the Prefiles File }
             Reg.BX := fh;
             Reg.CX := afile.Prefiles_Len;
             Reg.DS := Seg(Prefiles);
             Reg.DX := Ofs(Prefiles);
             MsDos(Reg);

             FillChar(Downpath,60,#00);

             Reg.AH := $3F;  { Read in the Download path }
             Reg.BX := fh;
             Reg.CX := afile.Downpath_Len;
             Reg.DS := Seg(Downpath);
             Reg.DX := Ofs(Downpath);
             MsDos(Reg);

             Reg.AH := $3F;  { Read in the Barricade file }
             Reg.BX := fh;
             Reg.CX := afile.Barricade_Len;
             Reg.DS := Seg(Barricade);
             Reg.DX := Ofs(Barricade);
             MsDos(Reg);

             Reg.AH := $3F;  { Read in the Rules file }
             Reg.BX := fh;
             Reg.CX := afile.Rules_Len;
             Reg.DS := Seg(Rules);
             Reg.DX := Ofs(Rules);
             MsDos(Reg);

             Reg.AH := $3F;  { Read in the Menu file }
             Reg.BX := fh;
             Reg.CX := afile.Menu_Len;
             Reg.DS := Seg(Menu);
             Reg.DX := Ofs(Menu);
             MsDos(Reg);

             Reg.AH := $3F;  { Read in the Help file }
             Reg.BX := fh;
             Reg.CX := afile.Help_Len;
             Reg.DS := Seg(Help);
             Reg.DX := Ofs(Help);
             MsDos(Reg);

             FillChar(Upload,60,#00);
             Reg.AH := $3F;  { Read in the Upload path }
             Reg.BX := fh;
             Reg.CX := afile.Uppath_Len;
             Reg.DS := Seg(Upload);
             Reg.DX := Ofs(Upload);
             MsDos(Reg);

             Reg.AH := $3F;  { Read in the Private Priv upload path }
             Reg.BX := fh;
             Reg.CX := afile.PrivUp_Len;
             Reg.DS := Seg(PUpload);
             Reg.DX := Ofs(PUpload);
             MsDos(Reg);

             Reg.AH := $3F;  { Read in the Private Key upload path }
             Reg.BX := fh;
             Reg.CX := afile.Privkey_Len;
             Reg.DS := Seg(KUpload);
             Reg.DX := Ofs(KUpload);
             MsDos(Reg);

             Reg.AH := $3F;  { Read in the Volume ID string }
             Reg.BX := fh;
             Reg.CX := afile.Vol_Len;
             Reg.DS := Seg(Vol);
             Reg.DX := Ofs(Vol);
             MsDos(Reg);

             Reg.AH := $3F;  { Read in the External program stuff }
             Reg.BX := fh;
             Reg.CX := afile.Other_Len;
             Reg.DS := Seg(Other);
             Reg.DX := Ofs(Other);
             MsDos(Reg);
             Names := downpath;

             bbs.path := downpath;
             if writeok then
               begin
                 bbs.path := downpath;
                 addtofile(saveset);
               end;

       end;
   until (j = 0);

   Reg.AX := $3E00;
   Reg.BX := fh;
   MsDos(Reg);
end;

