{ PICS0G.INC  Pascal Integrated Communications System Overlays }
{ 5/25/87 ver 1.6 Copyright 1987 by Les Archambault}

Overlay Procedure Read_Section_File;

type
   Section_rec=
     record
       sdrive:char;
       suser:integer;
       saccs:integer;
       confnum:integer;
       sname:filename;
       sdesc:strpr;
       mode:char;
     end;
var
   Sect_File:file of section_rec;
   sect_rec:section_rec;
   found_file_secs,found_post,found_system:boolean;
   drive,user,i,artcount,rec:integer;
   ets,co,am,ll,r300,rp:char;
   areathis,arealast:areaptr;
   sectthis,sectlast:sectptr;
   artthis,artlast:artptr;

begin
  found_file_secs:=true; found_post:=false; found_system:=false; artcount:=0;
  Assign(Sect_file,Sect_name + Ext);
  {$I-} Reset(sect_file) {$I+};           { Build file and message section lists }
  OK := (IOresult = 0);
  if OK then
    begin
      rec:=0;
      seek(sect_file,0);
      while not EOF(sect_file) do
      with sect_rec do
        begin
          read(sect_file,sect_rec);
          if mode='M' then
            begin               {message areas}
              if trim(SName)='POST' then found_post:=true;
              if trim(SName)='SYSTEM' then found_system:=true;
              new(AreaThis);
              if AreaBase = nil then AreaBase := AreaThis
              else AreaLast^.next := AreaThis;
              AreaLast := AreaThis;
              AreaLast^.Area := SUser;
              if confnum>0 then AreaLast^.AreaConf:=confnum
                else AreaLast^.AreaConf:=0;
              if confnum>0 then
                begin
                  writeln;
                  writeln('Aktiviere Brief-Konferenz Nummer ',confnum);
                  delay(500);
                end;
              AreaLast^.AreaAccs := SAccs;
              AreaLast^.AreaName := trim(SName);
              AreaLast^.AreaRec := rec;
              AreaLast^.next := nil
            end
          else if mode='F' then
            begin
              new(SectThis);     {file sections}
              if SectBase = nil then SectBase := SectThis
              else SectLast^.next := SectThis;
              SectLast := SectThis;
              SectLast^.SectDrive := ord(SDrive) - ord('A');
              SectLast^.SectUser := SUser;
              if confnum>0 then SectLast^.SectConf:=confnum
                else SectLast^.SectConf:=0;
              if confnum>0 then
                begin
                  writeln;
                  writeln('Aktiviere Datei-Konferenz Nummer ',confnum);
                  delay(500);
                end;
              SectLast^.SectAccs := SAccs;
              SectLast^.SectName := trim(SName);
              SectLast^.SectRec := rec;
              SectLast^.next := nil;
            end
          else if mode='A' then
            begin
              New(Artthis);
              if artbase=nil then artbase:=artthis
              else artlast^.next:=artthis;
              artcount:=succ(artcount);
              artlast:=artthis;
              artlast^.artdrive:=ord(sdrive)-ord('A');
              artlast^.artuser:=suser;
              artlast^.artaccs:=saccs;
              artlast^.artnum:=artcount;
              artlast^.artname:=trim(sname);
              artlast^.artRec:=rec;
              artlast^.next:=nil;
            end;
          rec:=succ(rec);
        end;  {eof reached}
      Close(sect_file);
      Assign(Config_file,'CONFIG.BB#');
      {$I-}  Reset(config_file); {$I+}
      if ioresult=0 then
        begin
          read(config_file,maxfree_uplds,maxfree_logs,maxfree_mslimit,maxfree_lines,
          maxfree_abs,extra_time_start,extra_time_stop,extra_time_val,
          chatstart,chatend,sleepy_time,max_tries,auto_macro_start,
          max_msg_lines,start_restrict300,end_restrict300,
          up_down_ratio,val_time,uval_time,val_acc,uval_acc,
          val_days,unv_days,unr_days,rea_days);
          read(config_file,ets,ets,co,am,ll,r300,rp,macro); {first ets eats space}
          if ets='T' then extra_time_sw:=true else extra_time_sw:=false;
          if co='T' then chat_ok:=true else chat_ok:=false;
          if am='T' then auto_macro:=true else auto_macro:=false;
          if ll='T' then limit_lines:=true else limit_lines:=false;
          if r300='T' then restrict300:=true else restrict300:=false;
          if rp='T' then restrict_public:=true else restrict_public:=false;
          if macro='' then macro:=Deflt_macro;
          close(config_file);
        end;
      FindSect('NEWIN', RcvDrv, RcvUsr, OK);  {sets up area to recv. files}
      if not OK then Writeln(BEL, 'Dateibereich NEWIN nicht gefunden.');
      if not ok then found_file_secs:=false;
      Findsect('LOGIN',drive,user,ok);
      if not ok then
        begin
          Writeln(bel, 'Dateibereich LOGIN nicht gefunden.');
          found_file_secs:=false;
        end;
      findsect('SYSTEM',drive,user,ok);
      if not ok then
        begin
          Writeln(bel, 'Dateibereich SYSTEM nicht gefunden.');
          found_file_secs:=false;
        end;
      if not found_post then writeln('Briefkasten POST nicht gefunden.');
      if not found_system then writeln('Briefkasten SYSTEM nicht gefunden.');
      if (not found_file_secs) or (not found_post) or (not found_system) then
        begin
          writeln;
          writeln(bel, 'Weitermachen unmoeglich! Nochmal SETUP.COM benutzen');
          halt;
        end;
    end         {was able to read section.bb# file}
      else
        begin
         Writeln(BEL, 'Section-File nicht gefunden. Mit SETUP.COM anlegen.');
         Writeln(Bel, 'Weitermachen unmoeglich.');
         halt;
        end;
end;

overlay procedure change_settings(num:integer);
 var work:strstd;
     t:tad_array;
  begin
       case num of
         1  : begin
               work:=prompt('Minimaler Disk Platz fuer Uploads ',4,'EL');
               if work<>'' then maxfree_uplds:=strint(work);
               end;
         2  : begin
               work:=prompt('Minimaler Disk Platz fuer neue Benutzer ',4,'EL');
               if work<>'' then maxfree_logs:=strint(work);
               end;
         3  : begin
               work:=prompt('Minimaler Disk Platz fuer unbegrenzte Briefe ',4,'EL');
               if work<>'' then maxfree_mslimit:=strint(work);
               end;
         4  : begin
               work:=prompt('Zeilen/Brief wenn Disk Platz zu klein ',3,'EL');
               if work<>'' then maxfree_lines:=strint(work);
               end;
         5  : begin
               work:=prompt('Minimaler Disk Platz fuer volle Sperre ',4,'EL');
               if work<>'' then maxfree_abs:=strint(work);
               end;
         6  : extra_time_sw:=not extra_time_sw;
         7  : begin
               work:=prompt('Beginn fuer Sonder-Zeit ',2,'EL');
               if work<>'' then extra_time_start:=strint(work);
               work:=prompt('Ende fuer Sonder-Zeit   ',2,'EL');
               if work<>'' then extra_time_stop:=strint(work);
               end;
         8  : begin
               work:=prompt('Anzahl Minuten der Sonder-Zeit ',3,'EL');
               if work<>'' then extra_time_val:=strint(work);
               end;
         9  : chat_ok:=not chat_ok;
         10 : begin
               work:=prompt('Zeit fuer Chat Beginn (Std.) ',2,'EL');
               if work<>'' then chatstart:=strint(work);
               work:=prompt('Zeit fuer Chat Ende (Std.)   ',2,'EL');
               if work<>'' then chatend:=strint(work);
               end;
         11 : begin
               work:=prompt('Anzahl Sekunden fuer Anrufer-Timeout ',4,'EL');
               if work<>'' then
                 begin
                   sleepy_time:=strint(work);
                   timeout:=sleepy_time;
                 end;
              end;
         12 : begin
               work:=prompt('Maximum erlaubte Versuche fuer Namen, Passwort ',2,'EL');
               if work<>'' then max_tries:=strint(work);
               end;
         13 : auto_macro:=not auto_macro;
         14 : begin
               work:=prompt('Zeit (Std.) fuer Auto Makro Ausfuehrung ',2,'EL');
               if work<>'' then
                 begin
                   auto_macro_start:=strint(work);
                   gettad(t);
                   if (auto_macro_start>t[2]) and (macro_done=t[3]) then macro_done:=255;
                 end;
               end;
         15 : limit_lines:=not limit_lines;
         16 : begin
               work:=prompt('Maximum erlaubter Zeilen in Briefen ',3,'EL');
               if work<>'' then max_msg_lines:=strint(work);
               end;
         17 : restrict300:=not restrict300;
         18 : begin
               work:=prompt('300 Baud Sperre Beginn (Std.) ',2,'E');
               if work<>'' then start_restrict300:=strint(work);
               work:=prompt('300 Baud Sperre Ende (Std.)   ',2,'EL');
               if work<>'' then end_restrict300:=strint(work);
              end;
         19 : begin
               work:=prompt('Erlaubte Downloads pro Upload [ 0 = Keine Begrenzung] ',3,'EL');
               if work<>'' then up_down_ratio:=strint(work);
               end;
         20 : restrict_public:= not restrict_public;
         21 : begin
               work:=prompt('Neue Anrufer-Nummer ',5,'EL');
               if work<>'' then
                 begin
                   seek(logr_file,0);
                   logr_rec.user:=strint(work);
                   write(logr_file,logr_rec);
                 end;
               end;
       end;
  end;

Overlay Procedure Display_purge_settings;

  var i:integer;

  begin
      writeln(usr);
      writeln(usr,'1...System Zeit-Grenze:                Eingetr. Ben. ',val_time);
      writeln(usr,'2....................................  Gast-Benutzer ',uval_time);
      writeln(usr,'3...Zugriffs-Level:                    Eingetr. Ben. ',val_acc);
      writeln(usr,'4....................................  Gast-Benutzer ',uval_acc);
      writeln(usr,'5...Tage fuer Verbleib in User-Liste:  Eingetr. Ben. ',val_days);
      writeln(usr,'6....................................  Gast-Benutzer ',unv_days);
      writeln(usr);
      writeln(usr,'7...Tage fuer Verbleib ungel. Briefe in Msg-Liste    ',unr_days);
      writeln(usr,'8...Tage fuer Verbleib gelesener Briefe in Msg-Liste ',rea_days);
      for i:=9 to 20 do writeln(usr);
  end;

overlay procedure change_Purge_settings(num:integer);
 var work:strstd;
  begin
       case num of
         1  : begin
               work:=prompt('Zeit-Limit (Min.) eingetragene Benutzer ',3,'EL');
               if work<>'' then val_time:=strint(work);
               end;
         2  : begin
               work:=prompt('Zeit-Limit (Min.) nicht eingetragene Benutzer ',3,'EL');
               if work<>'' then uval_time:=strint(work);
               end;
         3  : begin
               work:=prompt('Access Level fuer eingetragene Benutzer ',3,'EL');
               if work<>'' then val_acc:=strint(work);
               end;
         4  : begin
               work:=prompt('Access Level fuer nicht eingetragene Benutzer ',3,'EL');
               if work<>'' then uval_acc:=strint(work);
               end;
         5  : begin
               work:=prompt('Tage fuer Verbleib inaktiver eingetr. Benutzer ',3,'EL');
               if work<>'' then val_days:=strint(work);
               end;
         6  : begin
               work:=prompt('Tage fuer Verbleib inaktiver Gast-Benutzer ',3,'EL');
               if work<>'' then unv_days:=strint(work);
               end;
         7  : begin
               work:=prompt('Tage fuer den Verbleib ungelesener Briefe ',3,'EL');
               if work<>'' then unr_days:=strint(work);
               end;
         8  : begin
               work:=prompt('Tage fuer den Verbleib gelesener Briefe ',3,'EL');
               if work<>'' then rea_days:=strint(work);
               end;
       end;
  end;

Overlay Procedure Record_msg;

   var  Tfile:text;
        i,x,n,first_line,last_line:integer;
        to_fn,fr_fn:firstname;
        to_ln,fr_ln:lastname;
        Tstr:strstd;
        Tname:filename;
        temp_user_rec:user_list;
        this:areaptr;

  begin
   repeat
    writeln(usr);
    ok:=false;
    Tname:=prompt('Dateiname fuer Brief-Speicherung ',12,'ESU');
    if Tname<>' ' then
      begin
        Assign(Tfile,Tname);
        {$I-} Reset(Tfile); {$I+}
        if ioresult<>0 then ok:=true;
        if ok then
          begin
            {$I-} Rewrite(Tfile); {$I+}
            ok:=(ioresult=0);
          end
        else
          begin
            writeln(usr);
            if ask('Datei existiert bereits...ueberschreiben') then
              begin
                {$I-} Rewrite(Tfile); {$I+}
                ok:=(ioresult=0);
              end;
          end;
      end;
   until ok or (not online) or (tname=' ');
   if ok and online then
     begin
       Writeln(usr);
       write(usr,'Schreibe Datei...');
       with summ_rec do
         begin
           if user_to=0 then
             begin
               to_fn:='ALLE';
               to_ln:='';
             end
           else if user_to=user_loc then
             begin
               to_fn:=user_rec.fn;
               to_ln:=user_rec.ln;
             end
           else
             begin
               getrec(datf,user_to,temp_user_rec);
               to_fn:=temp_user_rec.fn;
               to_ln:=temp_user_rec.ln;
             end;
           if user_from=user_loc then
             begin
               fr_fn:=user_rec.fn;
               fr_ln:=user_rec.ln;
             end
           else
             begin
               getrec(datf,user_from,temp_user_rec);
               fr_fn:=temp_user_rec.fn;
               fr_ln:=temp_user_rec.ln;
             end;
           Tstr:=formtad(date);
           this:=areabase;
           while (this<>nil) and (this^.area<>area) do this:=this^.next;
           writeln(tfile);
           if num_prev=255 then write(tfile,'<P>');
           case status of
             deleted    : Write(tfile,'Geloeschter');
             read       : Write(tfile,'Gelesener');
             private    : Write(tfile,'Privater');
             public     : Write(tfile,'Oeffentlicher');
             restricted : Write(tfile,'Gesperrter');
           end;
           writeln(tfile,' Brief #',num,'  [',this^.areaname,']  vom: ',Tstr);
           writeln(tfile,'  Von: ',fr_fn,' ',fr_ln);
           writeln(tfile,'   An: ',to_fn,' ',to_ln);
           writeln(tfile,'Betr.: ',subject);
           first_line:=st_rec;
           last_line:=size;
         end;  {with sum_rec}
       i:=1;
       seek(mesg_file,first_line);
       writeln(tfile);
       while (i<=last_line) and online do
         begin
           read(mesg_file,mesg_rec);
           writeln(tfile,mesg_rec);
           i:=succ(i);
         end;
       close(tfile);
       writeln(usr,'Fertig...');
     end;      {ok and online}
  end;         {procedure}

{End of PICS0G.inc }


