home *** CD-ROM | disk | FTP | other *** search
/ Oakland CPM Archive / oakcpm.iso / cpm / bbs / pics16.ark / PICS0A.INC < prev    next >
Encoding:
Text File  |  1987-05-25  |  13.9 KB  |  419 lines

  1. { PICS0A.INC - Pascal Integrated Communications System Overlays}
  2. { 5/25/87 VER. 1.6  Copyright 1987 by les archambault }
  3.  
  4. overlay function correct_fn(str: FileName): FileName;
  5. { Correct possible errors in file name }
  6.   var
  7.     i, j: integer;
  8.   begin
  9.     i := 1;                                 { Remove blanks and invalid characters }
  10.     while i <= length(str) do
  11.       if str[i] in [' ', '*', ',', ':', ';', '=', '?', '_']
  12.         then delete(str, i, 1)
  13.         else i := succ(i);
  14.     while (str <> '') and (str[1] = '.') do { Remove leading '.' }
  15.       delete(str, 1, 1);
  16.     i := pos('.', str);                     { Remove redundant '.' }
  17.     j := 1;
  18.     while j <= length(str) do
  19.       if (str[j] = '.') and (j > i)
  20.         then delete(str, j, 1)
  21.         else j := succ(j);
  22.     i := pos('.', str);
  23.     if i = 0                                { Ensure name has '.' }
  24.       then
  25.         begin
  26.           str := copy(str, 1, 8);           { Ensure file name <= 8 characters }
  27.           if length(str) > 0
  28.             then str := str + '.'
  29.         end
  30.       else str := copy(str, 1, min(8, pred(i))) + '.' +
  31.                   copy(str, succ(i), min(3, length(str) - i));
  32.     correct_fn := str
  33.   end;
  34.  
  35. overlay function compress_fn(name: FileName): FileName;
  36. { Strip hi bits and remove all blanks from file name }
  37.   var
  38.     i: integer;
  39.   begin
  40.     for i := 1 to length(name) do
  41.       name[i] := chr($7F and ord(name[i]));
  42.     i := pos(' ', name);
  43.     while i > 0 do
  44.       begin
  45.         delete(name, i, 1);
  46.         i := pos(' ', name)
  47.       end;
  48.     compress_fn := name
  49.   end;
  50.  
  51. overlay procedure get_old_password(pr: StrPr; var valid: boolean);
  52. { Accept and validate old password.  Only 'Max_Tries' will be allowed. }
  53.   var
  54.     tries: integer;
  55.   begin
  56.     tries := 0;
  57.     repeat
  58.       valid := (user_rec.pw = prompt(pr, len_pw, 'S'));
  59.       tries := succ(tries)
  60.     until (not online) or valid or (tries > Max_Tries);
  61.     if not valid
  62.       then writeln(USR, 'Only ', Max_Tries, ' tries allowed.')
  63.   end;
  64.  
  65. overlay procedure get_new_password;
  66. { Accept and validate new password. }
  67.   var
  68.     i,x: integer;
  69.     trial_pw: password;
  70.   begin
  71.     writeln(USR);
  72.     writeln(USR, 'Please select and enter a password of 4-', len_pw, ' characters');
  73.     writeln(USR, 'to ensure that no one else uses your name on the system.');
  74.     writeln(USR);
  75.     repeat
  76.       repeat
  77.         trial_pw := prompt('Password (will NOT display as you type)', len_pw, 'SL');
  78.         i := length(trial_pw);
  79.         if (i < 4) or (i > len_pw)
  80.           then writeln(USR, 'Length must be 4-', len_pw, ' characters.')
  81.         else
  82.           begin
  83.             for x:=1 to length(trial_pw) do
  84.               if (not(ord(trial_pw[x]) in [48..57])) and (not(ord(trial_pw[x]) in [65..90]))
  85.                  then i:=0;
  86.             if i=0 then writeln(usr,'Only characters A-Z and numbers 0-9 allowed.');
  87.           end;
  88.       until (not online) or ((4 <= i) and (i <= len_pw));
  89.       user_rec.pw := prompt(' Please enter it again for verification', len_pw, 'SL');
  90.       if user_rec.pw <> trial_pw
  91.         then writeln(USR, 'No match.  Try again.')
  92.     until (not online) or (user_rec.pw = trial_pw);
  93.     writeln(USR);
  94.     writeln(USR, 'Please remember your password.');
  95.     writeln(USR, 'It will be required for all future calls.')
  96.   end;
  97.  
  98. overlay procedure get_case;
  99. { Get case switch from user }
  100.   begin
  101.     user_rec.shift_lock := not ask('Can your terminal display lower case')
  102.   end;
  103.  
  104. overlay procedure get_nulls;
  105. { Get nulls from user }
  106.   begin
  107.     if online then
  108.     user_rec.nulls := strint(prompt('How many nulls do you need [0-9]?', 1, 'ES'))
  109.   end;
  110.  
  111. overlay function mesg_start(pr: StrPr): integer;
  112. { Get starting message number from user }
  113.   var
  114.     i,last: integer;
  115.   begin
  116.     repeat
  117.       writeln(usr); last:=user_rec.lasthi;
  118.       i:= strint(prompt(pr +' (last mesg you read is '+intstr(last,1)+') '+
  119.       ' [' + intstr(msg_lo, 1) + '-' + intstr(msg_hi, 1) + ']?',5,'E'));
  120.       if (i <msg_lo) or (i >msg_hi)
  121.         then Writeln(usr,'Invalid message number, try again.');
  122.     until ((i>=msg_lo) and (i<=msg_hi)) or (not online);
  123.    mesg_start := i
  124.   end;
  125.  
  126. Overlay procedure mesg_header_list(loc:integer; var first_line,
  127.   last_line:integer; var Fr_fn:firstname; var Fr_ln:lastname);
  128. { Display message header }
  129.   var
  130.     to_fn: firstname;
  131.     to_ln: lastname;
  132.     str: StrTAD;
  133.     temp_user_rec: user_list;
  134.     this: areaptr;
  135.   begin
  136.     seek(summ_file, loc);
  137.     read(summ_file, summ_rec);
  138.     with summ_rec do
  139.       begin
  140.         if user_to = 0
  141.           then
  142.             begin
  143.               to_fn := 'ALL';
  144.               to_ln := ''
  145.             end
  146.         else if user_to = user_loc
  147.           then
  148.             begin
  149.               to_fn := user_rec.fn;
  150.               to_ln := user_rec.ln
  151.             end
  152.           else
  153.             begin
  154.               if user_to<>-1 then
  155.                 begin
  156.                   GetRec(DatF, user_to, temp_user_rec);
  157.                   to_fn := temp_user_rec.fn;
  158.                   to_ln := temp_user_rec.ln;
  159.                 end
  160.               else
  161.                 begin
  162.                   to_fn:='Deleted User';
  163.                   to_ln:='';
  164.                 end;
  165.             end;
  166.         if user_from = user_loc
  167.           then
  168.             begin
  169.               fr_fn := user_rec.fn;
  170.               fr_ln := user_rec.ln
  171.             end
  172.           else
  173.             begin
  174.               if user_from<>-1 then
  175.                 begin
  176.                   GetRec(DatF, user_from, temp_user_rec);
  177.                   fr_fn := temp_user_rec.fn;
  178.                   fr_ln := temp_user_rec.ln;
  179.                 end
  180.               else
  181.                 begin
  182.                   fr_fn:='Deleted User';
  183.                   fr_ln:='';
  184.                 end;
  185.             end;
  186.         str := FormTAD(date);
  187.         this:=areabase;
  188.         while (this<>nil) and (this^.area<>area) do this:=this^.next;
  189.         writeln(USR);
  190.         if num_prev=255 then write(usr,'<P>');
  191.         case status of
  192.           deleted: write(USR, 'Deleted');
  193.           read:    write(USR, 'Read');
  194.           private: write(USR, 'Private');
  195.           public:  write(USR, 'Public');
  196.           restricted: write(usr,'Restricted');
  197.         end;
  198.      writeln(USR,' message # ',num,'    ',this^.areaname,
  199.                  ' AREA ','   Entered ',str);
  200.         writeln(USR, 'From: ', fr_fn, ' ', fr_ln);
  201.         writeln(USR, '  To: ', to_fn, ' ', to_ln);
  202.         writeln(USR, '  Re: ', subject);
  203.         if audit_on
  204.           then
  205.             begin
  206.               setsect(AudDrv,AudUsr);
  207.               writeln(AuditFile);
  208.               if num_prev=255 then write(auditfile,'<P>');
  209.               case status of
  210.                 deleted: write(AuditFile, 'Deleted');
  211.                 read:    write(AuditFile, 'Read');
  212.                 private: write(AuditFile, 'Private');
  213.                 public:  write(AuditFile, 'Public');
  214.                 restricted: write(Auditfile,'Restricted');
  215.               end;
  216.               writeln(AuditFile, ' message # ', num, ' entered ', str);
  217.               writeln(AuditFile, 'From: ', fr_fn, ' ', fr_ln);
  218.               writeln(AuditFile, '  To: ', to_fn, ' ', to_ln);
  219.               writeln(AuditFile, '  Re: ', subject);
  220.               setsect(homdrv,homusr);
  221.             end;
  222.         first_line := st_rec;
  223.         last_line := size
  224.       end
  225.   end;   {message header list}
  226.  
  227. overlay procedure mesg_delete;
  228. { Delete the current message }
  229.   var
  230.     this: MesgPtr;
  231.   begin
  232.     summ_rec.status := deleted;
  233.     seek(summ_file, pred(FilePos(summ_file)));
  234.     write(summ_file, summ_rec);
  235.     this := MesgCurr;
  236.     if MesgCurr = MesgBase
  237.       then
  238.         begin
  239.           MesgCurr := MesgBase^.next;
  240.           MesgBase := MesgBase^.next;
  241.           dispose(this)
  242.         end
  243.     else if MesgCurr <> nil
  244.       then
  245.         begin
  246.           MesgCurr := MesgBase;             { Find previous record }
  247.           while MesgCurr^.next <> this do
  248.             MesgCurr := MesgCurr^.next;
  249.           MesgCurr^.next := this^.next;     { Make it point to next record }
  250.           if MesgLast = this
  251.             then MesgLast := MesgCurr;
  252.           MesgCurr := MesgCurr^.next;
  253.           dispose(this)
  254.         end;
  255.     writeln(USR, 'Message #', summ_rec.num, ' deleted.')
  256.   end;  {mesg_delete}
  257.  
  258. overlay procedure mesg_build_index(mesg_area: byte);
  259. { Scan summary file and build message index list.  Messages are tied
  260.   to the current message area.
  261.   All messages are accessible in mesg_area #0 (SYSTEM). }
  262.   var
  263.     this: MesgPtr;
  264.   begin
  265.     while MesgBase <> nil do                { Delete old messages }
  266.       begin
  267.         this := MesgBase;
  268.         MesgBase := MesgBase^.next;         { Go to next on list }
  269.         dispose(this)                       { Reclaim space }
  270.       end;
  271.     msg_all := 0;
  272.     msg_ind := 0;
  273.     msg_aut := 0;
  274.     msg_sys := 0;
  275.     msg_hi:=0;
  276.     msg_lo:=30000;
  277.     seek(summ_file, 1);
  278.     while not EOF(summ_file) do
  279.       with summ_rec do
  280.         begin
  281.           read(summ_file, summ_rec);
  282.           if ((status<>deleted) and (status<>restricted) and (area=mesg_area))
  283.           or (mesg_area=0) then
  284.             begin
  285.               if msg_lo>num then msg_lo:=num;
  286.               if num>msg_hi then msg_hi:=num;
  287.             end;
  288.           if (status=public) and ((area=mesg_area) or (mesg_area=0))  {Public message}
  289.             then
  290.             If user_loc=user_to then
  291.               begin
  292.                 msg_ind:=succ(msg_ind);
  293.                 msg_all:=succ(msg_all);    {add to public count too}
  294.                 mesg_insert(1);
  295.               end
  296.             else
  297.             If user_loc=user_from then
  298.               begin
  299.               msg_aut:=succ(msg_aut);
  300.               msg_all:=succ(msg_all);
  301.               mesg_insert(2);
  302.               end
  303.             else
  304.               begin
  305.                 msg_all := succ(msg_all);
  306.                 mesg_insert(0)
  307.               end
  308.           else if (status <> deleted) and (user_loc = user_to)
  309.                   and ((area=mesg_area) or (mesg_area=0))
  310.             then
  311.               begin                         { Private message }
  312.                 msg_ind := succ(msg_ind);
  313.                 mesg_insert(1)
  314.               end
  315.           else if (status <> deleted) and (user_loc = user_from)
  316.                   and ((area=mesg_area) or (mesg_area=0))
  317.             then
  318.               begin                         { Author of message }
  319.                 msg_aut := succ(msg_aut);
  320.                 mesg_insert(2)
  321.               end
  322.           else if mesg_area = 0
  323.             then
  324.               begin                         { Sysop can view all messages }
  325.                 msg_sys := succ(msg_sys);
  326.                 mesg_insert(3)
  327.               end
  328.         end;
  329.     if msg_lo>=29999 then msg_lo:=0;
  330.     summ_rec.user_from := 0
  331.   end;
  332.  
  333. overlay procedure mesg_directory;
  334. { Display directory of messages }
  335.  
  336.   var
  337.     col_width, col_count, col_limit,conf_num: integer;
  338.     this:areaptr;
  339.     temstr:string[160];
  340.     found:boolean;
  341.  
  342.   begin  {msg_directory}
  343.     col_width:=6;
  344.     col_limit := max(1, user_rec.columns div col_width);
  345.     writeln(USR, 'Message numbers, this area  : ',msg_lo,'-',msg_hi);
  346.     writeln(USR, 'Public messages, this area  : ', msg_all);
  347.     writeln(USR);
  348.     if msg_ind = 0
  349.       then writeln(USR, user_rec.fn, ', no messages for you in this area.')
  350.       else
  351.         begin
  352.           writeln(USR, user_rec.fn, ', the following messages are addressed to you:');
  353.           col_count := 0;
  354.           MesgCurr := MesgBase;
  355.           while (not brk) and (MesgCurr <> nil) do
  356.             begin
  357.               if MesgCurr^.TypMsg = 1
  358.                 then
  359.                   begin
  360.                     write(USR, MesgCurr^.MesgNo:col_width);
  361.                     col_count := succ(col_count);
  362.                     if (0 = col_count mod col_limit)
  363.                       then writeln(USR)
  364.                   end;
  365.               MesgCurr := MesgCurr^.next
  366.             end;
  367.           writeln(USR)
  368.         end;
  369.     if msg_aut > 0
  370.       then
  371.         begin
  372.           writeln(USR, user_rec.fn, ', the following messages were sent by you:');
  373.           col_count := 0;
  374.           MesgCurr := MesgBase;
  375.           while (not brk) and (MesgCurr <> nil) do
  376.             begin
  377.               if MesgCurr^.TypMsg = 2
  378.                 then
  379.                   begin
  380.                     write(USR, MesgCurr^.MesgNo:col_width);
  381.                     col_count := succ(col_count);
  382.                     if (0 = col_count mod col_limit)
  383.                       then writeln(USR)
  384.                   end;
  385.               MesgCurr := MesgCurr^.next
  386.             end;
  387.           writeln(USR);
  388.         end;
  389.     Seek(summ_file,1);                  {look for msgs in other areas}
  390.     col_count:=0;  col_width:=12; temstr:=''; Writeln(usr);
  391.     col_limit:=max(1,user_rec.columns div col_width);
  392.     found:=false;
  393.     While not EOF(summ_file) do
  394.       with summ_rec do
  395.         begin
  396.         read(summ_file,summ_rec);
  397.         if (status<>deleted) and (area<>areaset) and (user_loc=user_to) then
  398.           begin
  399.             this:=areabase;
  400.             while (this<>nil) and (this^.area<>area) do this:=this^.next;
  401.             conf_num:=this^.Areaconf;
  402.             if (pos(this^.areaname,temstr)=0) and (this<>nil)
  403.                 and ((user_rec.access>=this^.areaaccs)
  404.                 or (test_bit(user_rec.conf_flags,conf_num))) then
  405.               begin
  406.                 found:=true;
  407.                 Write(usr,this^.areaname:col_width);
  408.                 col_count:=succ(col_count); temstr:=temstr+this^.areaname;
  409.                 if (0=col_count mod col_limit) then writeln(usr);
  410.               end;
  411.           end;
  412.         end;   {reading summary file}
  413.     writeln(usr);
  414.     if found then Writeln(usr,user_rec.fn,', Above are other Areas with messages for you.');
  415.     writeln(usr);
  416.   end;
  417.  
  418. {END OF PICS0A.INC }
  419.