home *** CD-ROM | disk | FTP | other *** search
/ Power Programming / powerprogramming1994.iso / progtool / pibterm / pibt41s3.arc / PIBUPDOW.MOD < prev    next >
Text File  |  1987-12-24  |  5KB  |  121 lines

  1. (*----------------------------------------------------------------------*)
  2. (*           PibUpDown --- Control routine for uploads/downloads        *)
  3. (*----------------------------------------------------------------------*)
  4.  
  5. PROCEDURE PibUpDown( Transfer_Protocol  : Transfer_Type;
  6.                      Transfer_Direction : CHAR );
  7.  
  8. (*----------------------------------------------------------------------*)
  9. (*                                                                      *)
  10. (*     Procedure:  PibUpDown                                            *)
  11. (*                                                                      *)
  12. (*     Purpose:    Controls uploading of files to remote hosts.         *)
  13. (*                                                                      *)
  14. (*     Calling Sequence:                                                *)
  15. (*                                                                      *)
  16. (*        PibUpDown( Transfer_Protocol  : Transfer_Type;                *)
  17. (*                   Transfer_Direction : CHAR );                       *)
  18. (*                                                                      *)
  19. (*           Transfer_Protocol  --- type of transfer to do              *)
  20. (*           Transfer_Direction --- direction of transfer               *)
  21. (*                                  'R' = receive                       *)
  22. (*                                  'S' = send                          *)
  23. (*                                                                      *)
  24. (*      Calls:   MyLoadOverLay                                          *)
  25. (*               Get_Upload_Protocol                                    *)
  26. (*               Get_Download_Protocol                                  *)
  27. (*               Send_Ascii_File                                        *)
  28. (*               Do_Xmodem_Upload                                       *)
  29. (*               Do_Kermit                                              *)
  30. (*               Receive_Ascii_File                                     *)
  31. (*               Receive_Xmodem_File                                    *)
  32. (*               Transfer_Through_Batch_File                            *)
  33. (*                                                                      *)
  34. (*----------------------------------------------------------------------*)
  35.  
  36. VAR
  37.    Save_Close : BOOLEAN;
  38.    I          : INTEGER;
  39.    TName      : String12;
  40.  
  41. BEGIN (* PibUpDown *)
  42.                                    (* Use file time provided by sender *)
  43.                                    (* by default.                      *)
  44.    Use_Time_Sent   := TRUE;
  45.                                    (* Get protocol for transfer   *)
  46.  
  47.    IF ( Transfer_Protocol = None ) THEN
  48.       CASE Transfer_Direction OF
  49.          'R': Transfer_Protocol := Get_Download_Protocol;
  50.          'S': Transfer_Protocol := Get_Upload_Protocol;
  51.       END (* CASE *);
  52.                                    (* Reset default transfer type *)
  53.  
  54.    IF ( Transfer_Protocol <> None ) THEN
  55.       Default_Transfer_Type := Transfer_Protocol;
  56.  
  57.                                    (* No batch window to start  *)
  58.    Batch_Screen_Ptr := NIL;
  59.                                    (* Display transfer status   *)
  60.    Display_Status := TRUE;
  61.                                    (* No upload path yet        *)
  62.    IF ( NOT Host_Mode ) THEN
  63.       Upload_Dir_Path := '';
  64.                                    (* Get script name for transfer if any *)
  65.    CASE Transfer_Direction OF
  66.       'R': TName := Receive_Script_Names[Transfer_Protocol];
  67.       'S': TName := Send_Script_Names[Transfer_Protocol];
  68.    END (* CASE *);
  69.                                    (* If script defined, then ... *)
  70.    IF ( LENGTH( TName ) > 0 ) THEN
  71.       IF ( POS( '.BAT', TName ) = 0 ) THEN
  72.  
  73.          BEGIN                     (* ... do transfer via script, else *)
  74.             Save_Close         := Close_Comm_For_Dos;
  75.             Close_Comm_For_Dos := TRUE;
  76.             Process_Script( TName , 'E' );
  77.             Close_Comm_For_Dos := Save_Close;
  78.          END
  79.       ELSE
  80.                                    (* ... if .BAT in script name, then *)
  81.                                    (* transfer via batch file          *)
  82.  
  83.          Transfer_Through_Batch_File( Transfer_Protocol ,
  84.                                       TName , Transfer_Direction )
  85.  
  86.    ELSE
  87.       BEGIN                        (* Else do transfer via built-in code *)
  88.  
  89.          CASE Transfer_Protocol OF
  90.  
  91.             Ascii        : CASE Transfer_Direction OF
  92.                               'R': Receive_Ascii_File;
  93.                               'S': Send_Ascii_File;
  94.                            END (* CASE *);
  95.  
  96.             Ymodem_Batch,
  97.             Ymodem_G,
  98.             Xmodem_1K,
  99.             Xmodem_1KG,
  100.             Xmodem_Crc,
  101.             Xmodem_Chk,
  102.             Modem7_CRC,
  103.             Telink,
  104.             Modem7_Chk:    CASE Transfer_Direction OF
  105.                               'R': Do_Xmodem_Download( Transfer_Protocol );
  106.                               'S': Do_Xmodem_Upload  ( Transfer_Protocol );
  107.                            END (* CASE *);
  108.  
  109.             Kermit:        Do_Kermit( Transfer_Direction );
  110.  
  111.             ELSE ;
  112.  
  113.          END  (* CASE *);
  114.                                    (* Indicate end of transfer *)
  115.  
  116.          Signal_End_Of_Transfer( Transfer_Protocol );
  117.  
  118.       END;
  119.  
  120. END   (* PibUpDown *);
  121.