home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / mbug / mbug184.arc / ROS34.LBR / ROSFIL.IZC / ROSFIL.INC
Text File  |  1979-12-31  |  9KB  |  267 lines

  1. { ROSFIL.INC - Remote Operating System: File Sub-system }
  2.  
  3. overlay procedure toggle_st_switch;
  4. { Toggle file size display }
  5.   begin
  6.     writeln(USR);
  7.     st_switch := not st_switch;
  8.     write(USR, 'File sizes will be shown in ');
  9.     if st_switch
  10.       then writeln(USR, 'bytes, where "k" is 1024.')
  11.       else writeln(USR, 'minutes and seconds of transfer time.')
  12.   end;
  13.  
  14. overlay procedure newin_list;
  15. { List new uploads }
  16.   var
  17.     i, line_count: integer;
  18.     str: StrTAD;
  19.     temp_user_rec: user_list;
  20.   begin
  21.     line_count := 0;
  22.     i := pred(FileSize(nwin_file));
  23.     while (not brk) and (i >= 0) do
  24.       begin
  25.         seek(nwin_file, i);
  26.         read(nwin_file, nwin_rec);
  27.         with nwin_rec do
  28.           begin
  29.             if status = public
  30.               then
  31.                 begin
  32.                   str := FormTAD(date);
  33.                   GetRec(DatF, user, temp_user_rec);
  34.                   writeln(USR);
  35.                   writeln(USR, pad(name, 15), descr);
  36.                   writeln(USR, '   ', pad(str, 30),
  37.                     temp_user_rec.fn, ' ', temp_user_rec.ln);
  38.                   if user_rec.lines <> 99
  39.                     then
  40.                       begin
  41.                         line_count := succ(line_count);
  42.                         if line_count mod (user_rec.lines div 3) = 0
  43.                         then pause
  44.                       end
  45.                 end
  46.           end;
  47.         i := pred(i)
  48.       end
  49.   end;
  50.  
  51. overlay procedure file_area_change(req: Str10);
  52. { View and set up file area for use }
  53.   const
  54.     col_width = 12;
  55.   var
  56.     col_count, col_limit, Drive, User: integer;
  57.     this: SectPtr;
  58.     pr: StrPr;
  59.   begin
  60.     col_limit := max(1, user_rec.columns div col_width);
  61.     if req = ''
  62.       then
  63.         begin
  64.           pr := 'File area';
  65.           if user_rec.help_level > 1
  66.             then pr := pr + ' [press "?" for menu]';
  67.           req := prompt(pr, 10, 'ES?')
  68.         end;
  69.     while (not new_dir) and (req <> '') do
  70.       begin
  71.         this := SectBase;
  72.         if req = '?'
  73.           then
  74.             begin
  75.               writeln(USR, 'Available file areas:');
  76.               writeln(USR);
  77.               while (not brk) and (this <> nil) do
  78.                 begin
  79.                   if user_rec.access >= this^.SectAccs
  80.                     then writeln(USR, pad(this^.SectName, 14), this^.SectDesc);
  81.                   this := this^.next
  82.                 end;
  83.               writeln(USR);
  84.               req := prompt(pr, 10, 'ES?')
  85.             end
  86.         else if req <> ''
  87.           then
  88.             begin
  89.               FindSect(req, Drive, User, OK);
  90.               if OK
  91.                 then
  92.                   begin
  93.                     SectReq := req;
  94.                     SetDrv  := Drive;
  95.                     SetUsr  := User;
  96.                     ReadDir(DirEntries, DirSpace, DirBase)
  97.                   end
  98.                 else
  99.                   begin
  100.                     writeln(USR, '"', req, '" not found.  Available file areas:');
  101.                     writeln(USR);
  102.                     col_count := 0;
  103.                     this := SectBase;
  104.                     while (not brk) and (this <> nil) do
  105.                       begin
  106.                         if user_rec.access >= this^.SectAccs
  107.                           then
  108.                             begin
  109.                               write(USR, pad(this^.SectName, col_width));
  110.                               col_count := succ(col_count);
  111.                               if 0 = col_count mod col_limit
  112.                                 then writeln(USR)
  113.                             end;
  114.                         this := this^.next
  115.                       end;
  116.                     if 0 <> col_count mod col_limit
  117.                       then writeln(USR);
  118.                     writeln(USR);
  119.                     req := prompt(pr, 10, 'ES?')
  120.                   end
  121.             end
  122.       end
  123.   end;
  124.  
  125. overlay procedure library;
  126. { Open and close a library }
  127.   var
  128.     i: integer;
  129.     this: FilePtr;
  130.   begin { library }
  131.     if in_library
  132.       then
  133.         begin
  134.           SetSect(SetDrv, SetUsr);          { Close file }
  135.           Close(libr_file);
  136.           SetSect(HomDrv, HomUsr);
  137.           while LibBase <> nil do           { Clean out old list }
  138.             begin
  139.               this := LibBase;
  140.               LibBase := LibBase^.Next;     { Go to next on chain }
  141.               dispose(this)                 { Reclaim space }
  142.             end;
  143.           in_library := FALSE;
  144.           writeln(USR, 'Library ', LibReq, ' closed.')
  145.         end
  146.       else
  147.         begin
  148.           LibReq := prompt('Library', 12, 'ES');
  149.           delete(LibReq, 1, pos(':', LibReq));
  150.           if LibReq <> ''
  151.             then
  152.               begin
  153.                 if pos('.', LibReq) = 0
  154.                   then LibReq := LibReq + '.LBR';
  155.                 if copy(LibReq, succ(pos('.', LibReq)), 3) = 'LBR'
  156.                   then LibReadDir(LibEntries, LibSpace, LibBase);
  157.                 if not in_library
  158.                   then writeln(USR, 'Cannot open ', LibReq, '.')
  159.               end
  160.         end
  161.   end;
  162.  
  163. overlay procedure directory;
  164. { Display file area or library directory }
  165.   const
  166.     col_width = 19;
  167.   var
  168.     i, j, k, entries, rows, mm, ss, size, col_count, col_limit, line_count: integer;
  169.     this: FilePtr;
  170.     nodes: array[1..4] of FilePtr;
  171.     st: Str10;
  172.     fn: FileName;
  173.   begin
  174.     col_limit := max(1, user_rec.columns div col_width);
  175.     writeln(USR);
  176.     new_dir := FALSE;
  177.     if in_library
  178.       then
  179.         begin
  180.           this := LibBase;
  181.           entries := LibEntries;
  182.           if entries = 0
  183.             then writeln(USR, '   Library: ', LibReq, ' is empty.')
  184.             else writeln(USR, '   Library: ', LibReq, '   Files: ', entries,
  185.                  '   Space used: ', LibSpace, 'k')
  186.         end
  187.       else
  188.         begin
  189.           this := DirBase;
  190.           entries := DirEntries;
  191.           if entries = 0
  192.             then writeln(USR, '   File area: ', SectReq, ' is empty.')
  193.             else write(USR, '   File area: ', SectReq, '   Files: ', entries,
  194.                  '   Space used: ', DirSpace, 'k');
  195.           if user_rec.access >= 250
  196.             then writeln(USR, '   Free: ', free_space, 'k')
  197.             else writeln(USR)
  198.         end;
  199.     line_count := 2;
  200.     if entries > 0
  201.       then
  202.         begin
  203.           rows := entries div col_limit;
  204.           if 0 <> entries mod col_limit
  205.             then rows := succ(rows);
  206.           nodes[1] := this;
  207.           for i := 2 to col_limit do
  208.             begin
  209.               for j := 1 to rows do
  210.                 this := this^.next;
  211.               nodes[i] := this
  212.             end;
  213.           i := 1;
  214.           while (not brk) and (i <= rows) do
  215.             begin
  216.               for j := 1 to col_limit do
  217.                 begin
  218.                   this := nodes[j];
  219.                   if (i + rows * pred(j)) <= entries
  220.                     then
  221.                       begin
  222.                         if st_switch
  223.                           then
  224.                             begin
  225.                               size := this^.fsize shr 3;
  226.                               if (this^.fsize mod 8) <> 0
  227.                                 then size := succ(size);
  228.                               st := intstr(size, 4) + 'k '
  229.                             end
  230.                           else
  231.                             begin
  232.                               send_time(this^.fsize, mm, ss);
  233.                               st := intstr(mm, 3) + ':' + intstr(ss, 2);
  234.                               for k := 3 to length(st) do
  235.                                 if st[k] = ' '
  236.                                   then st[k] := '0'
  237.                             end;
  238.                         fn := this^.fname;
  239.                         if ($80 and ord(fn[11])) <> 0
  240.                           then
  241.                             begin
  242.                               fn[9] := '*'; { Indicate $SYS file }
  243.                               fn[11] := chr($7F and ord(fn[11]))
  244.                             end;
  245.                         write(USR, fn, st);
  246.                         if j < col_limit
  247.                           then write(USR, fence, ' ')
  248.                           else writeln(USR)
  249.                       end
  250.                     else writeln(USR);
  251.                   nodes[j] := nodes[j]^.next   { Go to next on list }
  252.                 end;
  253.               if user_rec.lines <> 99
  254.                 then
  255.                   begin
  256.                     line_count := succ(line_count);
  257.                     if line_count mod user_rec.lines = 0
  258.                       then pause
  259.                   end;
  260.               i := succ(i)
  261.             end
  262.         end;
  263.     if j <> col_limit
  264.       then writeln(USR)
  265.   end;
  266.  
  267.