home *** CD-ROM | disk | FTP | other *** search
/ Power Programming / powerprogramming1994.iso / progtool / pibterm / pibt41s1.arc / KFINSERV.MOD < prev    next >
Text File  |  1987-12-26  |  4KB  |  124 lines

  1. (*----------------------------------------------------------------------*)
  2. (*     Kermit_Finish_Server --- Finish server mode transfers            *)
  3. (*----------------------------------------------------------------------*)
  4.  
  5. PROCEDURE Kermit_Finish_Server( Finish_Type: CHAR );
  6.  
  7. (*----------------------------------------------------------------------*)
  8. (*                                                                      *)
  9. (*     Procedure:  Kermit_Finish_Server                                 *)
  10. (*                                                                      *)
  11. (*     Purpose:    Tells remote Kermit server to quit                   *)
  12. (*                                                                      *)
  13. (*     Calling Sequence:                                                *)
  14. (*                                                                      *)
  15. (*        Kermit_Finish_Server( Finish_Type : CHAR );                   *)
  16. (*                                                                      *)
  17. (*           Finish_Type --- 'F' to finish, 'L' to logout               *)
  18. (*                                                                      *)
  19. (*----------------------------------------------------------------------*)
  20.  
  21. VAR
  22.    Try       : INTEGER;
  23.    Ch        : CHAR;
  24.  
  25. BEGIN (* Kermit_Finish_Server *)
  26.                                    (* Hide cursor         *)
  27.    CursorOff;
  28.                                    (* Save current screen *)
  29.  
  30.    Save_Screen( Kermit_Local_Save );
  31.  
  32.                                    (* Initialize display  *)
  33.    IF Finish_Type = 'F' THEN
  34.       BEGIN
  35.          Send_Packet_Ptr^[4] := 'G';
  36.          Send_Packet_Ptr^[5] := 'F';
  37.          Send_Packet_Length  := 5;
  38.          Write_Log( 'FINISH remote server.', FALSE, FALSE );
  39.       END
  40.    ELSE
  41.       BEGIN
  42.          Send_Packet_Ptr^[4] := 'G';
  43.          Send_Packet_Ptr^[5] := 'L';
  44.          Send_Packet_Length  := 5;
  45.          Write_Log( 'LOGOUT remote server.', FALSE, FALSE );
  46.       END;
  47.  
  48.    Packet_Num          := 0;
  49.    Try                 := 0;
  50.    Packets_Received    := 0;
  51.    Packets_Sent        := 0;
  52.    Packets_Bad         := 0;
  53.    Kermit_MaxTry       := 5;
  54.    Kermit_Abort        := FALSE;
  55.    Kermit_Retry        := FALSE;
  56.    Kermit_Abort_Level  := No_Abort;
  57.    Kermit_Screen_Write := FALSE;
  58.    His_Chk_Type        := '1';
  59.  
  60.    Initialize_Logout_Display;
  61.  
  62.                                    (* Build FINISH packet *)
  63.    Build_Packet;
  64.                                    (* Don't update display     *)
  65.    Logging_Out_Server := TRUE;
  66.                                    (* Send FINISH packet until *)
  67.                                    (* acknowledged or too many *)
  68.                                    (* tries.                   *)
  69.    REPEAT
  70.  
  71.       Try := Try + 1;
  72.  
  73.       Send_Packet;
  74.  
  75.       Check_ACK;
  76.  
  77.       IF PibTerm_KeyPressed THEN
  78.          BEGIN
  79.  
  80.             Read_Kbd( Ch );
  81.  
  82.             IF ( ( Ch = CHR( ESC ) ) AND PibTerm_KeyPressed ) THEN
  83.                Read_Kbd( Ch )
  84.             ELSE
  85.                CASE Ch OF
  86.                   ^B,^F:  BEGIN    (* Cancel logout *)
  87.                              Kermit_Abort       := TRUE;
  88.                              Kermit_Abort_Level := No_Abort;
  89.                           END;
  90.  
  91.                      ^K:  BEGIN    (* Drop out of Kermit entirely *)
  92.                              Kermit_Abort       := TRUE;
  93.                              Kermit_Abort_Level := Entire_Protocol;
  94.                           END;
  95.  
  96.                      ^M:  BEGIN    (* Retry current packet *)
  97.                              Kermit_Retry       := TRUE;
  98.                              Async_Send( CHR( CR ) );
  99.                           END;
  100.  
  101.                    ELSE;
  102.  
  103.                END (* CASE *);
  104.  
  105.          END  (* If PibTerm_KeyPressed *);
  106.  
  107.    UNTIL ( Kermit_Abort OR ACK_OK OR ( Try > Kermit_MaxTry ) );
  108.  
  109.    IF ( Try > Kermit_MaxTry ) OR Kermit_Abort THEN
  110.       Display_Kermit_Message('Error -- could not stop remote server.')
  111.    ELSE
  112.       Display_Kermit_Message('Remote server stopped.');
  113.  
  114.    Window_Delay;
  115.  
  116.    Logging_Out_Server := FALSE;
  117.                                    (* Remove logout window *)
  118.  
  119.    Restore_Screen_And_Colors( Kermit_Local_Save );
  120.  
  121.    CursorOn;
  122.  
  123. END    (* Kermit_Finish_Server *);
  124.