home *** CD-ROM | disk | FTP | other *** search
/ Power Programming / powerprogramming1994.iso / progtool / pibterm / pibt41s2.arc / PIBHOSTA.MOD < prev    next >
Text File  |  1988-02-19  |  40KB  |  828 lines

  1. PROCEDURE Emulate_Host;
  2.  
  3. (*----------------------------------------------------------------------*)
  4. (*               PibHost --- Host mode (mini-BBS) for PibTerm           *)
  5. (*----------------------------------------------------------------------*)
  6. (*                                                                      *)
  7. (*  Author:   Philip R. Burns                                           *)
  8. (*  Date:     February, 1986                                            *)
  9. (*  Version:  1.0  (July, 1985)                                         *)
  10. (*            1.1  (July, 1985)                                         *)
  11. (*            1.2  (August, 1985)                                       *)
  12. (*            2.0  (August, 1985)                                       *)
  13. (*            3.0  (October, 1985)                                      *)
  14. (*            3.2  (November, 1985)                                     *)
  15. (*            4.0  (June, 1987)                                         *)
  16. (*            4.1  (December, 1987)                                     *)
  17. (*                                                                      *)
  18. (*  Systems:  For MS-DOS on IBM PCs and close compatibles only.         *)
  19. (*            Note:  I have checked these on Zenith 151s under          *)
  20. (*                   MSDOS 2.1 and IBM PCs under PCDOS 2.0.             *)
  21. (*                                                                      *)
  22. (*  Overview: This overlay provides a simple host mode for use with     *)
  23. (*            PibTerm.  Facilities are provided for message leaving     *)
  24. (*            and file transfer.  This code can be used as a very       *)
  25. (*            simple remote bulletin board.  However, it lacks the      *)
  26. (*            security provisions needed for a genuine BBS, and is      *)
  27. (*            really intended to cover the need for a simple remote     *)
  28. (*            facility for a small private group of users.              *)
  29. (*                                                                      *)
  30. (*            Beginning with version 4.0, it is also possible for       *)
  31. (*            designated users to jump to DOS and thus run DOS commands *)
  32. (*            from the remote system.                                   *)
  33. (*                                                                      *)
  34. (*  Use:      This code assumes a Hayes-compatible modem.  You may need *)
  35. (*            to modify the code if your modem doesn't return verbal    *)
  36. (*            codes sufficient to determine the baud rate of the caller.*)
  37. (*            The modem is assumed to be set to answer the phone        *)
  38. (*            automatically.                                            *)
  39. (*                                                                      *)
  40. (*            To invoke host mode after entering PibTerm, enter Alt-W.  *)
  41. (*                                                                      *)
  42. (*            If you want the remote session echoed to the printer or   *)
  43. (*            captured to disk, then use the Alt-L and Alt-O commands   *)
  44. (*            before using Alt-W to invoke host mode.                   *)
  45. (*                                                                      *)
  46. (*            The following files are required above those normally     *)
  47. (*            used with PibTerm:                                        *)
  48. (*                                                                      *)
  49. (*              PIBTERM.USF  --- the user file.  A simple text file     *)
  50. (*                               containing the first name, last name,  *)
  51. (*                               and password for each authorized user. *)
  52. (*                               This file can be created using any     *)
  53. (*                               text editor that produces ascii files. *)
  54. (*                               The format is simply:                  *)
  55. (*                                                                      *)
  56. (*                                  firstname;lastname;password;priv    *)
  57. (*                                                                      *)
  58. (*                               i.e., semicolons separating the first  *)
  59. (*                               name, last name, password, and         *)
  60. (*                               privilege level.  At present, the only *)
  61. (*                               privilege levels are 'N' for normal    *)
  62. (*                               users and 'S' for special users.       *)
  63. (*                                                                      *)
  64. (*                               This file MUST be created outside of   *)
  65. (*                               PibTerm;  there are no provisions for  *)
  66. (*                               a remote caller to get added to the    *)
  67. (*                               user file.                             *)
  68. (*                                                                      *)
  69. (*              PIBTERM.MSG ---  The message file.  This file is also   *)
  70. (*                               a simple ascii text file.  Message     *)
  71. (*                               header information is flagged by '=='  *)
  72. (*                               in columns one and two.  The end of a  *)
  73. (*                               message is marked by '== End' in       *)
  74. (*                               column one.  This file will be created *)
  75. (*                               by PibTerm if it doesn't exist when a  *)
  76. (*                               host session requires its presence.    *)
  77. (*                                                                      *)
  78. (*                               To remove messages, use a text editor  *)
  79. (*                               and just delete the header lines and   *)
  80. (*                               text for a message.  There are no      *)
  81. (*                               provisions for deleting messages       *)
  82. (*                               remotely.                              *)
  83. (*                                                                      *)
  84. (*              PIBTERM.XFR ---  The file transfer list.  This file     *)
  85. (*                               contains a list of files which may be  *)
  86. (*                               downloaded by a remote user.  Files    *)
  87. (*                               NOT on the transfer list cannot be     *)
  88. (*                               downloaded.                            *)
  89. (*                                                                      *)
  90. (*                               Also, a file with the same name as a   *)
  91. (*                               file on this list cannot be uploaded   *)
  92. (*                               by a remote user.                      *)
  93. (*                                                                      *)
  94. (*                               If the file name begins with an '*',   *)
  95. (*                               then that file is protected, and it    *)
  96. (*                               can neither be uploaded nor downloaded.*)
  97. (*                               All the PibTerm files should be placed *)
  98. (*                               in PIBTERM.XFR with an '*' preceding   *)
  99. (*                               the name.  For example:                *)
  100. (*                                                                      *)
  101. (*                                   *PIBTERM.XFR                       *)
  102. (*                                                                      *)
  103. (*              PIBTERM.CMT ---  private comments file -- only readable *)
  104. (*                               by you.  The format is the same as the *)
  105. (*                               message file.                          *)
  106. (*                                                                      *)
  107. (*              PIBTERM.LOG ---  log file telling who logged on and     *)
  108. (*                               when they logged off.                  *)
  109. (*                                                                      *)
  110. (*              PIBTERM.WEL ---  Welcome message file issued after a    *)
  111. (*                               sucessful login.                       *)
  112. (*                                                                      *)
  113. (*            Note that all these files are simple sequential ascii     *)
  114. (*            files. This implies that they should be kept small for    *)
  115. (*            reasonable performance -- which is fine for a small group *)
  116. (*            of users.  This implementation does not provide good      *)
  117. (*            performance for a large group of users;  if you need that,*)
  118. (*            you should obtain a real BBS program designed to handle   *)
  119. (*            large numbers of users.                                   *)
  120. (*                                                                      *)
  121. (*                                                                      *)
  122. (*----------------------------------------------------------------------*)
  123. (*                                                                      *)
  124. (*                            Restriction                               *)
  125. (*                            -----------                               *)
  126. (*                                                                      *)
  127. (*           You may use this code only for NON COMMERCIAL purposes     *)
  128. (*           unless you explicitly obtain my permission.  I take a dim  *)
  129. (*           view of others making money on my work and those of other  *)
  130. (*           people whose code I've inserted here.                      *)
  131. (*                                                                      *)
  132. (*           Please feel free to add new features.  I wrote this        *)
  133. (*           program to give people a useful and usable basic terminal  *)
  134. (*           facility, and to show how Turbo Pascal can be used for     *)
  135. (*           asynchronous communications, menu display, windowing, and  *)
  136. (*           so on.  I hope that you find this program useful -- and,   *)
  137. (*           if you expand upon it, please upload your extensions so    *)
  138. (*           that all of us can enjoy them!                             *)
  139. (*                                                                      *)
  140. (*----------------------------------------------------------------------*)
  141. (*                                                                      *)
  142. (*           Suggestions for improvements or corrections are welcome.   *)
  143. (*           Please leave messages on Gene Plantz's BBS (312) 882 4145  *)
  144. (*           or Ron Fox's BBS (312) 940 6496.                           *)
  145. (*                                                                      *)
  146. (*----------------------------------------------------------------------*)
  147.  
  148. (*----------------------------------------------------------------------*)
  149. (*                    Global host mode variables                        *)
  150. (*----------------------------------------------------------------------*)
  151.  
  152. CONST
  153.    MaxUsers      = 100             (* Maximum number of users supported *);
  154.    Page_Size     = 23              (* No. lines per screen for display  *);
  155.    Max_Login_Try = 3               (* Max. number of tries for login    *);
  156.  
  157. TYPE                               (* Information about a user *)
  158.  
  159.    User_Record = RECORD
  160.                     First_Name: STRING[20];
  161.                     Last_Name : STRING[20];
  162.                     Password  : STRING[10];
  163.                     Privilege : STRING[1];
  164.                  END;
  165.  
  166.    User_List_Type     = ARRAY[1 .. MaxUsers] OF User_Record;
  167.    User_List_Ptr_Type = ^User_List_Type;
  168.  
  169. VAR
  170.  
  171.    Done              : BOOLEAN     (* If session complete        *);
  172.    Really_Done       : BOOLEAN     (* To leave host mode         *);
  173.  
  174.    Kbd_Input         : BOOLEAN     (* Input found at host keybrd *);
  175.    Fname             : ShortStr    (* First name of caller       *);
  176.    Lname             : ShortStr    (* Last name of caller        *);
  177.    PassWord          : ShortStr    (* Password to access system  *);
  178.    First_Time        : BOOLEAN     (* If first time host mode up *);
  179.    Recipient_Name    : FileStr     (* Name for message reception *);
  180.    Message_Subject   : AnyStr      (* Subject of message         *);
  181.    Message_Line      : AnyStr      (* Text line for message      *);
  182.  
  183.    CR_LF_Host        : STRING[2]   (* CR or CR+LF                *);
  184.    Expert_On         : BOOLEAN     (* TRUE to use short menus    *);
  185.  
  186.    Message_File      : Text_File   (* Message file               *);
  187.  
  188.                                    (* User list *)
  189.  
  190.    User_List         : User_List_Ptr_Type;
  191.  
  192.    One_User          : User_Record (* User list for one-user mode*);
  193.  
  194.    NUsers            : INTEGER     (* Number of active users     *);
  195.  
  196.    User_File_Size    : INTEGER     (* # of lines in user file    *);
  197.  
  198.    Cur_User          : INTEGER     (* Current user               *);
  199.    Cur_User_Name     : FileStr     (* Current user's name        *);
  200.  
  201.    NMessages         : INTEGER     (* Number of messages         *);
  202.  
  203.    Local_Host        : BOOLEAN     (* TRUE if local host session *);
  204.    Host_Section      : CHAR        (* Which section are we in?   *);
  205.    Last_Host_Sect    : CHAR        (* Section we were in before  *);
  206.                                    (* gossip mode started        *)
  207.    Blank_Time        : LONGINT     (* Time between sessions      *);
  208.  
  209.    Save_Upload       : FileStr     (* Save emul. mode upload path   *);
  210.    Save_Download     : FileStr     (* Save emul. mode download path *);
  211.    Save_Review       : BOOLEAN     (* Save review mode              *);
  212.    Save_Logging      : BOOLEAN     (* Save logging status           *);
  213.    Ierr              : INTEGER     (* I/O error flag                *);
  214.    New_Baud          : WORD        (* New baud rate                 *);
  215.    Save_H_Parity     : CHAR        (* Saves parity                  *);
  216.    Save_H_Data_Bits  : INTEGER     (* Saves data bits               *);
  217.    Save_H_Stop_Bits  : INTEGER     (* Saves stop bits               *);
  218.    Save_H_Baud_Rate  : WORD        (* Saves baud rate               *);
  219.    Cur_Host_Status   : ShortStr    (* Current host status for disp. *);
  220.    Host_IO_Error     : INTEGER     (* General I/O error check var   *);
  221.  
  222. (*----------------------------------------------------------------------*)
  223. (*        Host_Carrier_Detect --- Check for carrier or local mode       *)
  224. (*----------------------------------------------------------------------*)
  225.  
  226. FUNCTION Host_Carrier_Detect : BOOLEAN;
  227.  
  228. (*----------------------------------------------------------------------*)
  229. (*                                                                      *)
  230. (*     Function:  Host_Carrier_Detect                                   *)
  231. (*                                                                      *)
  232. (*     Purpose:   Reports on carrier detect/local host mode status      *)
  233. (*                                                                      *)
  234. (*     Calling sequence:                                                *)
  235. (*                                                                      *)
  236. (*        Carrier := Host_Carrier_Detect : BOOLEAN;                     *)
  237. (*                                                                      *)
  238. (*           Carrier --- set TRUE if local host session, or if          *)
  239. (*                       carrier detected for remote session.           *)
  240. (*                                                                      *)
  241. (*----------------------------------------------------------------------*)
  242.  
  243. BEGIN (* Host_Carrier_Detect *)
  244.  
  245.    Host_Carrier_Detect := FALSE;
  246.  
  247.    IF Local_Host THEN
  248.       Host_Carrier_Detect := TRUE
  249.    ELSE
  250.       Host_Carrier_Detect := Async_Carrier_Detect;
  251.  
  252. END   (* Host_Carrier_Detect *);
  253.  
  254. (*----------------------------------------------------------------------*)
  255. (*        Host_Send  ---  Send character to port/screen in host mode    *)
  256. (*----------------------------------------------------------------------*)
  257.  
  258. PROCEDURE Host_Send( Ch : CHAR );
  259.  
  260. (*----------------------------------------------------------------------*)
  261. (*                                                                      *)
  262. (*     Procedure:  Host_Send                                            *)
  263. (*                                                                      *)
  264. (*     Purpose:    Sends character to comm port and/or screen           *)
  265. (*                                                                      *)
  266. (*     Calling sequence:                                                *)
  267. (*                                                                      *)
  268. (*        Host_Send( Ch : CHAR );                                       *)
  269. (*                                                                      *)
  270. (*           Ch --- character to be sent out                            *)
  271. (*                                                                      *)
  272. (*     Remarks:  If local host session, character is NOT sent out port. *)
  273. (*                                                                      *)
  274. (*----------------------------------------------------------------------*)
  275.  
  276. BEGIN (* Host_Send *)
  277.  
  278.    IF ( NOT Local_Host ) THEN
  279.       Async_Send( Ch );
  280.  
  281.    WRITE( Ch );
  282.  
  283. END   (* Host_Send *);
  284.  
  285. (*----------------------------------------------------------------------*)
  286. (*   Host_Send_String  ---  Send string to port/screen in host mode     *)
  287. (*----------------------------------------------------------------------*)
  288.  
  289. PROCEDURE Host_Send_String( S : AnyStr );
  290.  
  291. (*----------------------------------------------------------------------*)
  292. (*                                                                      *)
  293. (*     Procedure:  Host_Send_String                                     *)
  294. (*                                                                      *)
  295. (*     Purpose:    Sends string to comm port and/or screen              *)
  296. (*                                                                      *)
  297. (*     Calling sequence:                                                *)
  298. (*                                                                      *)
  299. (*        Host_Send_String( S : AnyStr );                               *)
  300. (*                                                                      *)
  301. (*           S --- character to be sent out                             *)
  302. (*                                                                      *)
  303. (*     Remarks:  If local host session, string is NOT sent out port.    *)
  304. (*                                                                      *)
  305. (*----------------------------------------------------------------------*)
  306.  
  307. BEGIN (* Host_Send_String *)
  308.  
  309.    IF ( NOT Local_Host ) THEN
  310.       Async_Send_String( S );
  311.  
  312.    WRITE( S );
  313.  
  314.    IF Printer_On THEN
  315.       Write_Prt_Str( S );
  316.  
  317.    IF Capture_On THEN
  318.       WRITE( Capture_File , S );
  319.  
  320. END   (* Host_Send_String *);
  321.  
  322. (*----------------------------------------------------------------------*)
  323. (*   Host_Send_String_With_CR --- Append CR or CR+LF and send string    *)
  324. (*----------------------------------------------------------------------*)
  325.  
  326. PROCEDURE Host_Send_String_With_CR( S : AnyStr );
  327.  
  328. (*----------------------------------------------------------------------*)
  329. (*                                                                      *)
  330. (*     Procedure: Host_Send_String_With_CR                              *)
  331. (*                                                                      *)
  332. (*     Purpose:   Appends end-of-line characters to string and sends    *)
  333. (*                it out over communications port.                      *)
  334. (*                                                                      *)
  335. (*     Calling sequence:                                                *)
  336. (*                                                                      *)
  337. (*        Host_Send_String_With_CR( S: AnyStr );                        *)
  338. (*                                                                      *)
  339. (*           S --- string to be sent out.                               *)
  340. (*                                                                      *)
  341. (*     Remarks:                                                         *)
  342. (*                                                                      *)
  343. (*        The end-of-line characters are either a CR or a CR+LF,        *)
  344. (*        depending upon the choice made by the user at login time.     *)
  345. (*                                                                      *)
  346. (*----------------------------------------------------------------------*)
  347.  
  348. BEGIN (* Host_Send_String_With_CR *)
  349.  
  350.    IF ( NOT Local_Host ) THEN
  351.       Async_Send_String( S + CR_LF_Host );
  352.  
  353.    WRITELN( S );
  354.  
  355.    IF Printer_On THEN
  356.       BEGIN
  357.          Write_Prt_Str( S );
  358.          Write_Prt_Str( CRLF_String );
  359.       END;
  360.  
  361.    IF Capture_On THEN
  362.       WRITELN( Capture_File , S );
  363.  
  364. END   (* Host_Send_String_With_CR *);
  365.  
  366. (*----------------------------------------------------------------------*)
  367. (*    Host_Send_String_And_Echo --- Send string and echo it to screen   *)
  368. (*----------------------------------------------------------------------*)
  369.  
  370. PROCEDURE Host_Send_String_And_Echo( S : AnyStr );
  371.  
  372. (*----------------------------------------------------------------------*)
  373. (*                                                                      *)
  374. (*     Procedure: Host_Send_String_And_Echo                             *)
  375. (*                                                                      *)
  376. (*     Purpose:   Send string out com port and echo to screen           *)
  377. (*                                                                      *)
  378. (*     Calling sequence:                                                *)
  379. (*                                                                      *)
  380. (*        Host_Send_String_And_Echo( S: AnyStr );                       *)
  381. (*                                                                      *)
  382. (*           S --- string to be sent out and echoed.                    *)
  383. (*                                                                      *)
  384. (*----------------------------------------------------------------------*)
  385.  
  386. BEGIN (* Host_Send_String_And_Echo *)
  387.  
  388.    IF ( NOT Local_Host ) THEN
  389.       Async_Send_String( S );
  390.  
  391.    WRITE( S );
  392.  
  393.    IF Printer_On THEN
  394.       Write_Prt_Str( S );
  395.  
  396.    IF Capture_On THEN
  397.       WRITE( Capture_File , S );
  398.  
  399. END   (* Host_Send_String_And_Echo *);
  400.  
  401. (*----------------------------------------------------------------------*)
  402. (*    Host_Prompt_And_Read_String --- Get string from remote and echo   *)
  403. (*----------------------------------------------------------------------*)
  404.  
  405. PROCEDURE Host_Prompt_And_Read_String(      Prompt : AnyStr;
  406.                                         VAR S      : AnyStr;
  407.                                             Echo   : BOOLEAN );
  408.  
  409. (*----------------------------------------------------------------------*)
  410. (*                                                                      *)
  411. (*     Procedure: Host_Prompt_And_Read_String                           *)
  412. (*                                                                      *)
  413. (*     Purpose:   Issues prompt to remote user, reads response, and     *)
  414. (*                echos response.                                       *)
  415. (*                                                                      *)
  416. (*     Calling sequence:                                                *)
  417. (*                                                                      *)
  418. (*        Host_Prompt_And_Read_String(      Prompt : AnyStr;            *)
  419. (*                                      VAR S      : AnyStr;            *)
  420. (*                                          Echo   : BOOLEAN );         *)
  421. (*                                                                      *)
  422. (*           Prompt --- prompt string to be issued.                     *)
  423. (*                      If null, no prompt is issued.                   *)
  424. (*           S      --- resulting string received from remote user.     *)
  425. (*           Echo   --- TRUE to echo characters as they are read;       *)
  426. (*                      FALSE to echo characters as '.'s.  This is      *)
  427. (*                      useful for getting passwords.                   *)
  428. (*                                                                      *)
  429. (*----------------------------------------------------------------------*)
  430.  
  431. VAR
  432.    Ch      : CHAR;
  433.    GotChar : BOOLEAN;
  434.    XPos    : INTEGER;
  435.    Rem_Ch  : CHAR;
  436.  
  437. BEGIN (* Host_Prompt_And_Read_String *)
  438.  
  439.                                    (* Send prompt to remote user *)
  440.    IF LENGTH( Prompt ) > 0 THEN
  441.       Host_Send_String_And_Echo( Prompt );
  442.  
  443.    Ch      := CHR( 0 );
  444.    S       := '';
  445.    XPos    := WhereX;
  446.                                    (* Get response string        *)
  447.    REPEAT
  448.  
  449.       GotChar := FALSE;
  450.  
  451.       IF PibTerm_KeyPressed THEN
  452.          BEGIN
  453.             Read_Kbd( Ch );
  454.             GotChar := TRUE;
  455.          END;
  456.  
  457.       IF Async_Receive( Rem_Ch ) THEN
  458.          BEGIN
  459.             Ch      := Rem_Ch;
  460.             GotChar := TRUE;
  461.          END;
  462.  
  463.       IF ( NOT GotChar ) THEN
  464.          GiveAwayTime( 2 )
  465.       ELSE
  466.          IF Ch <> CHR( CR ) THEN
  467.             IF Ch = ^H THEN
  468.                BEGIN  (* Backspace *)
  469.                   IF WhereX > Xpos THEN
  470.                      BEGIN
  471.                         Host_Send( Ch  );
  472.                         Host_Send( ' ' );
  473.                         Host_Send( Ch  );
  474.                         S := COPY( S, 1, PRED( LENGTH( S ) ) );
  475.                      END;
  476.                END   (* Backspace *)
  477.             ELSE
  478.                IF ( Ch <> ^X ) THEN
  479.                   BEGIN
  480.                      S := S + Ch;
  481.                      IF Echo THEN
  482.                         Host_Send( Ch )
  483.                      ELSE
  484.                         Host_Send( '.' );
  485.                   END;
  486.  
  487.    UNTIL ( Ch = CHR( CR ) ) OR
  488.          ( Ch = ^X        ) OR
  489.          ( NOT Host_Carrier_Detect );
  490.  
  491.                                    (* CR ends line *)
  492.    IF ( Ch = ^X ) THEN
  493.       BEGIN
  494.          S := ^X;
  495.          Host_Send_String_And_Echo(' *** Cancelled');
  496.          WRITELN;
  497.       END
  498.    ELSE IF Host_Carrier_Detect THEN
  499.       BEGIN
  500.  
  501.          WRITELN;
  502.  
  503.          IF Printer_On THEN
  504.             BEGIN
  505.                Write_Prt_Str( Write_Ctrls( S ) );
  506.                Write_Prt_Str( CRLF_String );
  507.             END;
  508.  
  509.          IF Capture_On THEN
  510.             WRITELN( Capture_File , S );
  511.  
  512.       END;
  513.  
  514. END   (* Host_Prompt_And_Read_String *);
  515.  
  516. (*----------------------------------------------------------------------*)
  517. (*           Host_Status --- update status line in host mode            *)
  518. (*----------------------------------------------------------------------*)
  519.  
  520. PROCEDURE Host_Status( Message : ShortStr );
  521.  
  522. (*----------------------------------------------------------------------*)
  523. (*                                                                      *)
  524. (*     Procedure:  Host_Status                                          *)
  525. (*                                                                      *)
  526. (*     Purpose:    Update status line in host mode                      *)
  527. (*                                                                      *)
  528. (*     Calling Sequence:                                                *)
  529. (*                                                                      *)
  530. (*        Host_Status( Message : ShortStr );                            *)
  531. (*                                                                      *)
  532. (*           Message    --- Text to display on status line              *)
  533. (*                                                                      *)
  534. (*----------------------------------------------------------------------*)
  535.  
  536. BEGIN (* Host_Status *)
  537.  
  538.    IF ( LENGTH( Message ) < 15 ) THEN
  539.       Write_To_Status_Line( Message + DUPL( ' ' , 15 - LENGTH( Message ) ) , 65 )
  540.    ELSE
  541.       Write_To_Status_Line( COPY( Message, 1, 15 ) , 65 );
  542.  
  543. END   (* Host_Status *);
  544.  
  545. (*----------------------------------------------------------------------*)
  546. (*           List_Prompt --- prompt for end-of-screen                   *)
  547. (*----------------------------------------------------------------------*)
  548.  
  549. PROCEDURE List_Prompt( VAR List_Count : INTEGER; VAR List_Done : BOOLEAN );
  550.  
  551. (*----------------------------------------------------------------------*)
  552. (*                                                                      *)
  553. (*     Procedure:  List_Prompt                                          *)
  554. (*                                                                      *)
  555. (*     Purpose:    Issues end-of-screen prompt for view routines        *)
  556. (*                                                                      *)
  557. (*     Calling Sequence:                                                *)
  558. (*                                                                      *)
  559. (*        List_Prompt( VAR List_Count : INTEGER;                        *)
  560. (*                     VAR List_Done  : BOOLEAN );                      *)
  561. (*                                                                      *)
  562. (*           List_Done  --- TRUE if Stop option selected here           *)
  563. (*           List_Count --- Count of lines per panel.  May be changed   *)
  564. (*                          here if C option selected.                  *)
  565. (*                                                                      *)
  566. (*     Calls:   RvsVideoOn                                              *)
  567. (*              RvsVideoOff                                             *)
  568. (*                                                                      *)
  569. (*     Called by:                                                       *)
  570. (*                                                                      *)
  571. (*        List_Files_For_Transfer                                       *)
  572. (*        Read_Messages                                                 *)
  573. (*                                                                      *)
  574. (*----------------------------------------------------------------------*)
  575.  
  576. VAR
  577.    List_Char : CHAR;
  578.    Found_Char: BOOLEAN;
  579.  
  580. CONST
  581.    List_Prompt_String : STRING[59] =
  582.                         'Enter <CR> to continue, S to stop, C to continue non-stop: ';
  583.  
  584. BEGIN (* List_Prompt *)
  585.  
  586.    INC( List_Count );
  587.  
  588.    IF List_Count > Page_Size THEN
  589.       BEGIN (* Do end of screen prompt *)
  590.  
  591.          REPEAT
  592.  
  593.             Host_Send_String_And_Echo( List_Prompt_String );
  594.  
  595.             REPEAT
  596.                Found_Char := Async_Receive( List_Char ) OR PibTerm_KeyPressed;
  597.                IF ( NOT Found_Char ) THEN
  598.                   GiveAwayTime( 2 );
  599.                Update_Status_Line;
  600.             UNTIL ( Found_Char OR ( NOT Host_Carrier_Detect ) );
  601.  
  602.             IF PibTerm_KeyPressed THEN
  603.                Read_Kbd( List_Char );
  604.  
  605.             IF List_Char = CHR( CR ) THEN
  606.                List_Char := ' ';
  607. {
  608.             Host_Send_String( List_Char );
  609.             Host_Send_String( CHR( CR ) );
  610. }
  611.             Host_Send_String_With_CR( List_Char );
  612.  
  613.             IF Printer_On THEN
  614.                Write_Prt_Str( List_Char + CRLF_String );
  615.  
  616.             IF Capture_On THEN
  617.                WRITELN( Capture_File , List_Char );
  618.  
  619.             List_Char := UpCase( List_Char );
  620.  
  621.          UNTIL ( List_Char IN ['S', 'C', ' '] ) OR ( NOT Host_Carrier_Detect );
  622.  
  623.          CASE List_Char Of
  624.             'C':  List_Count := -MaxInt;
  625.             'S':  List_Done  := TRUE;
  626.             ' ':  List_Count := 1;
  627.             ELSE
  628.                   ;
  629.          END (* CASE *);
  630.  
  631.       END (* Do end of screen prompt *);
  632.  
  633. END  (* List_Prompt *);
  634.  
  635. (*----------------------------------------------------------------------*)
  636. (*            End_Prompt --- prompt for end of message batch            *)
  637. (*----------------------------------------------------------------------*)
  638.  
  639. PROCEDURE End_Prompt( Mess: AnyStr );
  640.  
  641. (*----------------------------------------------------------------------*)
  642. (*                                                                      *)
  643. (*     Procedure:  End_Prompt                                           *)
  644. (*                                                                      *)
  645. (*     Purpose:    Issues prompt at end of message batch                *)
  646. (*                                                                      *)
  647. (*     Calling Sequence:                                                *)
  648. (*                                                                      *)
  649. (*        End_Prompt( Mess : AnyStr );                                  *)
  650. (*                                                                      *)
  651. (*           Mess --- Message to issue                                  *)
  652. (*                                                                      *)
  653. (*     Calls:   RvsVideoOn                                              *)
  654. (*              RvsVideoOff                                             *)
  655. (*                                                                      *)
  656. (*----------------------------------------------------------------------*)
  657.  
  658. VAR
  659.    List_Char : CHAR;
  660.    Found_Char: BOOLEAN;
  661.  
  662. BEGIN (* List_Prompt *)
  663.  
  664.    Host_Send_String_With_CR(' ');
  665.    Host_Send_String_And_Echo( Mess );
  666.  
  667.    REPEAT
  668.       Found_Char := Async_Receive( List_Char ) OR PibTerm_KeyPressed;
  669.       IF ( NOT Found_Char ) THEN
  670.          GiveAwayTime( 2 );
  671.    UNTIL ( Found_Char OR ( NOT Host_Carrier_Detect ) );
  672.  
  673.    IF PibTerm_KeyPressed THEN
  674.       Read_Kbd( List_Char );
  675.  
  676.    IF List_Char = CHR( CR ) THEN
  677.       List_Char := ' ';
  678.  
  679.    Host_Send_String_With_CR( List_Char );
  680.  
  681.    IF Printer_On THEN
  682.       Write_Prt_Str( List_Char + CRLF_String );
  683.    IF Capture_On THEN
  684.       WRITELN( Capture_File , List_Char );
  685.  
  686. END  (* List_Prompt *);
  687.  
  688. (*----------------------------------------------------------------------*)
  689. (*                   Gossip_Mode --- Enter PibTerm gossip mode          *)
  690. (*----------------------------------------------------------------------*)
  691.  
  692. PROCEDURE Gossip_Mode;
  693.  
  694. (*----------------------------------------------------------------------*)
  695. (*                                                                      *)
  696. (*     Procedure:  Gossip_Mode                                          *)
  697. (*                                                                      *)
  698. (*     Purpose:    Allows "conversation" with remote user.              *)
  699. (*                                                                      *)
  700. (*     Calling Sequence:                                                *)
  701. (*                                                                      *)
  702. (*        Gossip_Mode;                                                  *)
  703. (*                                                                      *)
  704. (*     Remarks:                                                         *)
  705. (*                                                                      *)
  706. (*         This gossip mode feature does not use a split screen.        *)
  707. (*                                                                      *)
  708. (*----------------------------------------------------------------------*)
  709.  
  710. VAR
  711.    Gossip_Done : BOOLEAN           (* TRUE to exit back to host mode       *);
  712.    Ch          : CHAR              (* Character read/written               *);
  713.    Bozo        : BOOLEAN;
  714.  
  715. BEGIN (* Gossip_Mode *)
  716.  
  717.    Write_Log( 'Entered gossip mode.', FALSE, FALSE );
  718.  
  719.    Host_Status('Gossip mode');
  720.  
  721.    Host_Send_String_With_CR(' ');
  722.    Host_Send_String_With_CR('Entering gossip mode, hit ^X to exit ... ');
  723.    WRITELN('Hit ^X to exit gossip mode.');
  724.  
  725.    Gossip_Done := FALSE;
  726.                                    (* Loop over input until done *)
  727.    WHILE ( NOT Gossip_Done ) DO
  728.       BEGIN
  729.                                    (* Check for character typed at keyboard *)
  730.          IF PibTerm_KeyPressed THEN
  731.             BEGIN
  732.  
  733.                Read_Kbd( Ch );
  734.  
  735.                IF ( ORD( Ch ) = ESC ) AND PibTerm_KeyPressed THEN
  736.                   BEGIN
  737.                      Read_Kbd( Ch );
  738.                      CASE ORD( Ch ) OF
  739.                         F1 : Ch := CHR( 3 );
  740.                         F2 : BEGIN
  741.                                 Ch   := CHR( 3 );
  742.                                 Done := TRUE;
  743.                              END;
  744.                         F3 : BEGIN
  745.                                 DosJump('');
  746.                                 Ch := CHR( 0 );
  747.                              END;
  748.                         F5 : BEGIN
  749.                                 WRITELN;
  750.                                 WRITELN('Current caller is ',Cur_User_Name);
  751.                                 Ch := CHR( 0 );
  752.                              END;
  753.                      END (* CASE *);
  754.                   END;
  755.  
  756.                CASE ORD( Ch ) OF
  757.  
  758.                    0:   ;
  759.  
  760.                    3,
  761.                    24:  Gossip_Done := TRUE;
  762.  
  763.                    BS:  BEGIN
  764.                            Host_Send_String( BS_String );
  765.                            IF Printer_On THEN
  766.                               Write_Prt( Ch );
  767.                            IF Capture_On THEN
  768.                               WRITE( Capture_File , Ch );
  769.                         END;
  770.  
  771.                   DEL:  BEGIN
  772.                            Host_Send_String( Ctrl_BS_String );
  773.                            IF Printer_On THEN
  774.                               Write_Prt( Ch );
  775.                            IF Capture_On THEN
  776.                               WRITE( Capture_File , Ch );
  777.                         END;
  778.  
  779.                   CR:   BEGIN
  780.                            Host_Send_String( CR_LF_Host );
  781.                            IF Printer_On THEN
  782.                               Write_Prt_Str( CRLF_String );
  783.                            IF Capture_On THEN
  784.                               WRITELN( Capture_File );
  785.                         END;
  786.  
  787.                   ELSE
  788.                         BEGIN
  789.                            Host_Send( Ch );
  790.                            IF Printer_On THEN
  791.                               Write_Prt( Ch );
  792.                            IF Capture_On THEN
  793.                               WRITE( Capture_File , Ch );
  794.                         END;
  795.  
  796.                END (* CASE ORD( Ch ) *);
  797.  
  798.             END;
  799.  
  800.          IF Async_Receive( Ch ) THEN
  801.             BEGIN
  802.                IF ( Ch = ^X ) THEN
  803.                   Gossip_Done := TRUE
  804.                ELSE IF Ch = CHR( CR ) THEN
  805.                   BEGIN
  806.                      IF Printer_On THEN
  807.                         Write_Prt_Str( CRLF_String );
  808.                      IF Capture_On THEN
  809.                         WRITELN( Capture_File );
  810.                      Host_Send_String( CR_LF_Host );
  811.                   END
  812.                ELSE
  813.                   Host_Send( Ch );
  814.             END
  815.          ELSE
  816.             IF ( NOT PibTerm_KeyPressed ) THEN
  817.                GiveAwayTime( 2 );
  818.  
  819.       END;
  820.  
  821.    Host_Section := Last_Host_Sect;
  822.  
  823.    Host_Status( Cur_Host_Status );
  824.    Write_Log( 'Exited gossip mode.', FALSE, FALSE );
  825.  
  826. END   (* Gossip_Mode *);
  827.  
  828.