home *** CD-ROM | disk | FTP | other *** search
/ Programmer's ROM - The Computer Language Library / programmersrom.iso / ada / defdata / ftp.src < prev    next >
Encoding:
Text File  |  1988-05-03  |  366.5 KB  |  9,367 lines

  1. --::::::::::::::
  2. --vt100_.ada
  3. --::::::::::::::
  4. -----------------------------------------------------------------------
  5. --
  6. --         DoD Protocols    NA-00005-200       80-01126-100(-)
  7. --         E-Systems, Inc.  August 07, 1985
  8. --
  9. --         VT100_.ADA       Author : Mark Volpe
  10. --
  11. -----------------------------------------------------------------------
  12. -- FILE : VT100         AUTHOR : MARK VOLPE
  13.  
  14. -- 5/13/85    10:05 AM : REVISED FOR USE WITH DEC COMPILER  
  15. --                       OLD CODE (TELESOFT) MARKED WITH --&MT
  16.  
  17. -- 5/22/85    2:55 PM  : REVISED FOR USE WITH TELESOFT COMPILER
  18. --                       OLD CODE (DEC) MARKED WITH --&MT
  19.  
  20. --&MT WITH ASCII, TEXT_IO; 
  21. WITH TEXT_IO;
  22.  
  23. --&MT USE  ASCII, TEXT_IO; 
  24. USE TEXT_IO; 
  25.  
  26. PACKAGE Vt100 IS
  27.     PROCEDURE Reverse_video;
  28.         --
  29.         -- This procedure selects a VT-100 like terminal into reverse video
  30.         -- mode.
  31.         --
  32.     PROCEDURE Attributes_off;
  33.         --
  34.         -- This procedure returns a VT-100 like terminal to its normal mode.
  35.         --
  36.     PROCEDURE Clear_screen;
  37.         --
  38.         -- This procedure selects a VT-100 like terminal to clear the screen.
  39.         --
  40.     PROCEDURE Bold;
  41.         --
  42.         -- This procedure selects a VT-100 like terminal to turn-on the bold
  43.         -- attribute.
  44.         --
  45.     PROCEDURE Blink;
  46.         --  
  47.         -- This procedure selects a VT-100 like terminal to turn-on the 
  48.         -- blinking attribute
  49.         --
  50.     PROCEDURE Home_position;
  51.         --
  52.         -- This procedure places the cursor in the home position.
  53.         --
  54. END Vt100 ;
  55.  
  56. --::::::::::::::
  57. --vt100.ada
  58. --::::::::::::::
  59. -----------------------------------------------------------------------
  60. --
  61. --         DoD Protocols    NA-00005-200       80-01127-100(-)
  62. --         E-Systems, Inc.  August 07, 1985
  63. --
  64. --         VT100.ADA       Author : Mark Volpe
  65. --
  66. -----------------------------------------------------------------------
  67. -- FILE : VT100         AUTHOR : MARK VOLPE
  68.  
  69. -- 5/13/85    10:05 AM : REVISED FOR USE WITH DEC COMPILER  
  70. --                       OLD CODE (TELESOFT) MARKED WITH --&MT
  71.  
  72. -- 5/22/85    2:55 PM  : REVISED FOR USE WITH TELESOFT COMPILER
  73. --                       OLD CODE (DEC) MARKED WITH --&MT
  74.  
  75. PACKAGE BODY Vt100 IS
  76.     PROCEDURE Reverse_video IS
  77.             Reversevideo : STRING(1..4);
  78.         BEGIN
  79.             Reversevideo(1) := ASCII.ESC;
  80.             Reversevideo(2..4) := "[7m";
  81.             PUT( Reversevideo );
  82.         END Reverse_video;
  83.     PROCEDURE Attributes_off IS
  84.             Attributesoff : STRING(1..3);
  85.         BEGIN
  86.             Attributesoff(1) := ASCII.ESC;
  87.             Attributesoff(2..3) := "[m";
  88.             PUT( Attributesoff );
  89.         END Attributes_off;
  90.     PROCEDURE Clear_screen IS
  91.             Clearscreen : STRING(1..4);
  92.         BEGIN
  93.             Clearscreen(1) := ASCII.ESC;
  94.             Clearscreen(2..4) := "[2J";
  95.             PUT( Clearscreen );
  96.         END Clear_screen;
  97.     PROCEDURE Bold IS
  98.             Bold_char : STRING(1..4);
  99.         BEGIN
  100.             Bold_char(1) := ASCII.ESC;
  101.             Bold_char(2..4) := "[1m";
  102.             PUT( Bold_char );
  103.         END Bold;
  104.     PROCEDURE Blink IS
  105.             Blink_char : STRING(1..4);
  106.         BEGIN
  107.             Blink_char(1) := ASCII.ESC;
  108.             Blink_char(2..4) := "[5m";
  109.             PUT( Blink_char );
  110.         END Blink;
  111.     PROCEDURE Home_position IS
  112.             Homeposition : STRING(1..4);
  113.         BEGIN
  114.             Homeposition(1) := ASCII.ESC;
  115.             Homeposition(2) := 'H';
  116.             PUT( Homeposition );
  117.             END Home_position;
  118. END Vt100 ;
  119. --::::::::::::::
  120. --mydebugio_.ada
  121. --::::::::::::::
  122. -----------------------------------------------------------------------
  123. --
  124. --         DoD Protocols    NA-00005-200       80-01122-100(-)
  125. --         E-Systems, Inc.  August 07, 1985
  126. --
  127. --         MYDEBUGIO_.ADA       Author : Mark Volpe
  128. --
  129. -----------------------------------------------------------------------
  130. -- FILE : MYDEBUGIO               AUTHOR : MARK VOLPE 
  131.  
  132. -- 5/13/85    1:20 PM  : REVISED FOR USE WITH DEC COMPILER 
  133. --                       OLD CODE (TELESOFT) MARKED WITH &MT  
  134.  
  135. -- 5/23/85    10:00 AM  : REVISED FOR USE WITH TELESOFT COMPILER
  136. --                        OLD CODE (DEC) MARKED WITH --&MT
  137.  
  138. -- 5/23/85    10:20 AM  : REVISED FOR USE WITH THE DEC COMPILER
  139. --                        OLD CODE (TELESOFT) MARKED WITH --&MT
  140.  
  141. --&MT THE FOLLOWING LINES ARE INCLUDED WHEN USING TELESOFT :
  142. --&MT WITH Vt100, TEXT_IO;  
  143. --&MT USE Vt100, TEXT_IO, INTEGER_IO; 
  144.  
  145. --&MT THE FOLLOWING LINES ARE INCLUDED WHEN USING DEC ADA :
  146.   WITH VT100, TEXT_IO;
  147.   USE VT100, TEXT_IO;
  148.  
  149. PACKAGE My_debug_io IS
  150.  
  151. --&MT SUBTYPE BIT_COUNT_16_TYPE IS INTEGER;
  152.       SUBTYPE BIT_COUNT_16_TYPE IS SHORT_INTEGER;
  153.  
  154.     PROCEDURE Put      ( Output_string  : IN STRING );
  155.     PROCEDURE Put_line ( Output_string  : IN STRING );
  156.     PROCEDURE Put      ( Output_integer : IN BIT_COUNT_16_TYPE );
  157.     PROCEDURE Put_line ( Output_integer : IN BIT_COUNT_16_TYPE );
  158. END My_debug_io;
  159.  
  160. --::::::::::::::
  161. --mydebugio.ada
  162. --::::::::::::::
  163. -----------------------------------------------------------------------
  164. --
  165. --         DoD Protocols    NA-00005-200       80-01123-100(-)
  166. --         E-Systems, Inc.  August 07, 1985
  167. --
  168. --         MYDEBUGIO.ADA       Author : Mark Volpe
  169. --
  170. -----------------------------------------------------------------------
  171. -- FILE : MYDEBUGIO               AUTHOR : MARK VOLPE 
  172.  
  173. -- 5/13/85    1:20 PM : REVISED FOR USE WITH DEC COMPILER 
  174. --                      OLD CODE MARKED WITH &MT  
  175.  
  176. -- 5/23/85    1:30 PM  : REVISED FOR USE WITH TELESOFT COMPILER
  177. --                       OLD CODE (DEC) MARKED WITH --&MT
  178.  
  179. -- 5/23/85    1:50 PM  : REVISED FOR USE WITH THE DEC COMPILER
  180. --                       OLD CODE (TELESOFT) MARKED WITH --&MT
  181.  
  182. PACKAGE BODY My_debug_io IS
  183.  
  184. --&MT THE FOLLOWING LINE IS DELETED WHEN USING TELESOFT :
  185. PACKAGE Integer_io IS NEW TEXT_IO.INTEGER_IO(BIT_COUNT_16_TYPE);
  186.  
  187.   PROCEDURE Put      ( Output_string  : IN STRING ) IS
  188.     BEGIN
  189.         Reverse_video;
  190.         TEXT_IO.PUT ( Output_string );
  191.         Attributes_off;
  192.     END PUT;
  193.   PROCEDURE Put_line ( Output_string  : IN STRING ) IS
  194.     BEGIN
  195.         Reverse_video;
  196.         TEXT_IO.PUT_LINE ( Output_string );
  197.         Attributes_off;
  198.     END Put_line;
  199.   PROCEDURE Put      ( Output_integer : IN BIT_COUNT_16_TYPE ) IS
  200.     BEGIN
  201.         Reverse_video;
  202.         INTEGER_IO.PUT ( Output_integer );
  203.         Attributes_off;
  204.     END Put;
  205.   PROCEDURE Put_line ( Output_integer : IN BIT_COUNT_16_TYPE ) IS
  206.     BEGIN
  207.         Reverse_video;
  208.         INTEGER_IO.PUT ( Output_integer );
  209.         TEXT_IO.NEW_LINE;
  210.         Attributes_off;
  211.     END Put_line;
  212. END My_debug_io;
  213. --::::::::::::::
  214. --myutils_.ada
  215. --::::::::::::::
  216. -----------------------------------------------------------------------
  217. --
  218. --         DoD Protocols    NA-00005-200       80-01124-100(-)
  219. --         E-Systems, Inc.  August 07, 1985
  220. --
  221. --         MYUTILS_.ADA       Author : Mark Volpe
  222. --
  223. -----------------------------------------------------------------------
  224.  
  225. -- FILE : MYUTILS               AUTHOR : MARK VOLPE 
  226.  
  227. -- 5/13/85    2:10 PM  : REVISED FOR USE WITH DEC COMPILER  
  228. --                       OLD CODE (TELESOFT) MARKED WITH --&MT
  229.  
  230. -- 5/23/85    2:35 PM  : REVISED FOR USE WITH TELESOFT COMPILER
  231. --                       OLD CODE (DEC) MARKED WITH --&MT
  232.  
  233. -- 5/23/85    2:55 PM  : REVISED FOR USE WITH THE DEC COMPILER
  234. --                       OLD CODE (TELESOFT) MARKED WITH --&MT
  235.  
  236. --&MT WITH ASCII, TEXT_IO, SYSTEM, UNCHECKED_CONVERSION;  
  237. --&MT INCLUDE THE FOLLOWING LINE WHEN USING DEC ADA :
  238. WITH TEXT_IO, SYSTEM, UNCHECKED_CONVERSION;
  239.  
  240. PACKAGE My_utilities IS
  241.  
  242. --&MT SUBTYPE BIT_COUNT_16_TYPE IS INTEGER;
  243.       SUBTYPE BIT_COUNT_16_TYPE IS SHORT_INTEGER;
  244.  
  245. --&MT SUBTYPE BIT_COUNT_8_TYPE IS SYSTEM.BYTE;
  246.       SUBTYPE BIT_COUNT_8_TYPE IS SYSTEM.UNSIGNED_BYTE;
  247.  
  248. --&MT INCLUDE THE FOLLOWING LINES WHEN USING DEC ADA :    
  249.     PACKAGE Integer_io IS NEW TEXT_IO.INTEGER_IO(BIT_COUNT_16_TYPE);
  250.     PACKAGE System_byte_io IS NEW TEXT_IO.INTEGER_IO(BIT_COUNT_8_TYPE);
  251.  
  252.     FUNCTION Char ( In_integer : BIT_COUNT_16_TYPE ) RETURN CHARACTER;
  253.     FUNCTION Byte IS NEW Unchecked_conversion ( CHARACTER, BIT_COUNT_16_TYPE );
  254.     PROCEDURE Output_byte_to_screen ( In_byte : IN BIT_COUNT_8_TYPE := 16#00# );
  255.     PROCEDURE Sound_keyboard_bell ( Number_of_rings : IN BIT_COUNT_16_TYPE := 1 );
  256. END My_utilities;
  257.  
  258. --::::::::::::::
  259. --myutils.ada
  260. --::::::::::::::
  261. -----------------------------------------------------------------------
  262. --
  263. --         DoD Protocols    NA-00005-200       80-01125-100(-)
  264. --         E-Systems, Inc.  August 07, 1985
  265. --
  266. --         MYUTILS.ADA       Author : Mark Volpe
  267. --
  268. -----------------------------------------------------------------------
  269.  
  270. -- FILE : MYUTILS               AUTHOR : MARK VOLPE 
  271.  
  272. -- 5/13/85    3:20 PM  : REVISED FOR USE WITH DEC COMPILER  
  273. --                       OLD CODE (TELESOFT) MARKED WITH --&MT
  274.  
  275. -- 5/23/85    2:40 PM  : REVISED FOR USE WITH TELESOFT COMPILER
  276. --                       OLD CODE (DEC) MARKED WITH --&MT
  277.  
  278. -- 5/23/85    3:03 PM  : REVISED FOR USE WITH THE DEC COMPILER
  279. --                       OLD CODE (TELESOFT) MARKED WITH --&MT
  280.  
  281. PACKAGE BODY My_utilities IS
  282.     FUNCTION Convert_integer_to_character IS 
  283.             NEW Unchecked_conversion ( BIT_COUNT_16_TYPE, CHARACTER );
  284.     FUNCTION Char ( In_integer : BIT_COUNT_16_TYPE ) RETURN CHARACTER IS
  285.             Byte_string : STRING (1..2);
  286.         BEGIN
  287.             Byte_string(1) := Convert_integer_to_character ( In_integer );
  288.             RETURN Byte_string(1);
  289.         END CHAR;
  290.     PROCEDURE Output_byte_to_screen ( In_byte : IN BIT_COUNT_8_TYPE := 16#00# ) IS
  291.         BEGIN
  292.             IF BIT_COUNT_16_TYPE( In_byte ) < 32 THEN
  293.                 CASE Char( BIT_COUNT_16_TYPE(In_byte) ) IS
  294.                     WHEN ASCII.NUL => TEXT_IO.PUT ("<NUL>");
  295.                     WHEN ASCII.SOH => TEXT_IO.PUT ("<SOH>");
  296.                     WHEN ASCII.STX => TEXT_IO.PUT ("<STX>");
  297.                     WHEN ASCII.ETX => TEXT_IO.PUT ("<ETX>");
  298.                     WHEN ASCII.EOT => TEXT_IO.PUT ("<EOT>");
  299.                     WHEN ASCII.ENQ => TEXT_IO.PUT ("<ENQ>");
  300.                     WHEN ASCII.ACK => TEXT_IO.PUT ("<ACK>");
  301.                     WHEN ASCII.BEL => TEXT_IO.PUT ("<BEL>");
  302.                     WHEN ASCII.BS  => TEXT_IO.PUT ("<BS>");
  303.                     WHEN ASCII.HT  => TEXT_IO.PUT ("<HT>");
  304.                     WHEN ASCII.LF  => TEXT_IO.PUT ("<LF>");
  305.                     WHEN ASCII.VT  => TEXT_IO.PUT ("<VT>");
  306.                     WHEN ASCII.FF  => TEXT_IO.PUT ("<FF>");
  307.                     WHEN ASCII.CR  => TEXT_IO.PUT ("<CR>");
  308.                                       TEXT_IO.NEW_LINE;
  309.                     WHEN ASCII.SO  => TEXT_IO.PUT ("<SO>");
  310.                     WHEN ASCII.SI  => TEXT_IO.PUT ("<SI>");
  311.                     WHEN ASCII.DLE => TEXT_IO.PUT ("<DLE>");
  312.                     WHEN ASCII.DC1 => TEXT_IO.PUT ("<DC1>");
  313.                     WHEN ASCII.DC2 => TEXT_IO.PUT ("<DC2>");
  314.                     WHEN ASCII.DC3 => TEXT_IO.PUT ("<DC3>");
  315.                     WHEN ASCII.DC4 => TEXT_IO.PUT ("<DC4>");
  316.                     WHEN ASCII.NAK => TEXT_IO.PUT ("<NAK>");
  317.                     WHEN ASCII.SYN => TEXT_IO.PUT ("<SYN>");
  318.                     WHEN ASCII.ETB => TEXT_IO.PUT ("<ETB>");
  319.                     WHEN ASCII.CAN => TEXT_IO.PUT ("<CAN>");
  320.                     WHEN ASCII.EM  => TEXT_IO.PUT ("<EM>");
  321.                     WHEN ASCII.SUB => TEXT_IO.PUT ("<SUB>");
  322.                     WHEN ASCII.ESC => TEXT_IO.PUT ("<ESC>");
  323.                     WHEN ASCII.FS  => TEXT_IO.PUT ("<FS>");
  324.                     WHEN ASCII.GS  => TEXT_IO.PUT ("<GS>");
  325.                     WHEN ASCII.RS  => TEXT_IO.PUT ("<RS>");
  326.                     WHEN ASCII.US  => TEXT_IO.PUT ("<US>");
  327.                     WHEN ASCII.DEL => TEXT_IO.PUT ("<DEL>");
  328.                     WHEN OTHERS    => TEXT_IO.PUT ("<BAD>");
  329.                 END CASE;
  330.             ELSE
  331.                 TEXT_IO.PUT ( CHAR( BIT_COUNT_16_TYPE(IN_BYTE) ));
  332.             END IF;
  333.     EXCEPTION
  334.         WHEN OTHERS => TEXT_IO.PUT ("<BAD>");
  335.     END Output_byte_to_screen ;
  336.     PROCEDURE Sound_keyboard_bell ( Number_of_rings : IN BIT_COUNT_16_TYPE := 1 ) IS
  337.         BEGIN
  338.             IF Number_of_rings < 1 THEN 
  339.                 TEXT_IO.PUT ( ASCII.NUL ); 
  340.             ELSE 
  341.                 FOR Bell_count IN 1..Number_of_rings LOOP
  342.                     TEXT_IO.PUT ( ASCII.NUL );
  343.                 END LOOP;
  344.             END IF;
  345.         END Sound_keyboard_bell;
  346. END My_utilities;
  347. --::::::::::::::
  348. --ftpcmd_.ada
  349. --::::::::::::::
  350. -----------------------------------------------------------------------
  351. --
  352. --         DoD Protocols    NA-00005-200       80-01072-100(-)
  353. --         E-Systems, Inc.  August 07, 1985
  354. --
  355. --         FTPCMD_.ADA       Author : Mark Volpe
  356. --
  357. -----------------------------------------------------------------------
  358.  
  359. -- FILE : FTPCMD               AUTHOR : MARK VOLPE
  360.  
  361. -- 5/13/85    3:40 PM  : REVISED FOR USE WITH DEC COMPILER  
  362. --                       OLD CODE (TELESOFT) MARKED WITH --&MT
  363.  
  364. -- 5/23/85    3:48 PM  : REVISED FOR USE WITH TELESOFT COMPILER
  365. --                       OLD CODE (DEC) MARKED WITH --&MT
  366.  
  367. -- 5/24/85    12:14 PM  : REVISED FOR USE WITH THE DEC COMPILER
  368. --                        OLD CODE (TELESOFT) MARKED WITH --&MT
  369.  
  370. --&MT REMOVE THE FOLLOWING LINES WHEN USING DEC ADA :
  371. --&MT  PRAGMA SOURCE_INFO ( ON );
  372. --&MT  WITH ASCII;
  373.  
  374. WITH TEXT_IO;         USE TEXT_IO;
  375.  
  376. PACKAGE Command_types IS
  377.  
  378. --&MT SUBTYPE BIT_COUNT_32_TYPE IS LONG_INTEGER;
  379.       SUBTYPE BIT_COUNT_32_TYPE IS INTEGER;
  380.  
  381. --&MT SUBTYPE BIT_COUNT_16_TYPE IS INTEGER;
  382.       SUBTYPE BIT_COUNT_16_TYPE IS SHORT_INTEGER;
  383.  
  384.     --
  385.     -- The following paramters are used in interfacing to the environment
  386.     -- either through the keyboard or telnet.
  387.     --
  388.     Max_command_string_length : CONSTANT BIT_COUNT_16_TYPE := 132; 
  389.                                         -- RFC 765 does not specify a length;
  390.                                         -- therefore this is arbitrary.
  391.     Max_command_abbreviation_length : CONSTANT BIT_COUNT_16_TYPE := 4;
  392.                                         -- This length is specified in the 
  393.                                         -- RFC 765 spec. p. 42
  394.     Max_command_size : CONSTANT BIT_COUNT_16_TYPE := 4;
  395.                                         -- This length is not specified in 
  396.                                         -- the RFC 765 spec.
  397.     SUBTYPE Command_string_spec IS 
  398.  
  399.      STRING (1 ..BIT_COUNT_32_TYPE( Max_command_string_length));
  400.                                         -- The format of data coming from 
  401.                                         -- telnet or the keyboard is
  402.                                         -- a string of characters.
  403. --&MT the following lines was deleted because the telesoft compiler wouldn't
  404. --&MT  handle it.
  405. --&MT STRING (1 ..BIT_COUNT_16_TYPE( Max_command_string_length));
  406. --&MT STRING (1 .. 132) ;
  407.  
  408.     Null_command_string : Command_string_spec;
  409.                                         -- Holds null characters; 
  410.                                         -- necessary because telesoft
  411.                                         -- does not support packed aggregate 
  412.                                         -- initialization
  413.  
  414. --&MT THE FOLLOWING LINES SHOULD BE OMITTED WHEN USING TELESOFT
  415.     PACKAGE Long_Int_IO IS NEW TEXT_IO.INTEGER_IO(bit_count_32_type);
  416.     PACKAGE Int_IO IS NEW TEXT_IO.INTEGER_IO(bit_count_16_type);
  417.  
  418.     FUNCTION End_of_command ( Cmd_character : IN CHARACTER ) RETURN BOOLEAN;
  419. END COMMAND_TYPES;
  420.  
  421. --::::::::::::::
  422. --ftpcmd.ada
  423. --::::::::::::::
  424. -----------------------------------------------------------------------
  425. --
  426. --         DoD Protocols    NA-00005-200       80-01073-100(-)
  427. --         E-Systems, Inc.  August 07, 1985
  428. --
  429. --         FTPCMD.ADA       Author : Mark Volpe
  430. --
  431. -----------------------------------------------------------------------
  432.  
  433. -- FILE : FTPCMD               AUTHOR : MARK VOLPE
  434.  
  435. -- 5/13/85    3:40 PM  : REVISED FOR USE WITH DEC COMPILER  
  436. --                       OLD CODE (TELESOFT) MARKED WITH --&MT
  437.  
  438. -- 5/23/85    3:48 PM  : REVISED FOR USE WITH TELESOFT COMPILER
  439. --                       OLD CODE (DEC) MARKED WITH --&MT
  440.  
  441. -- 5/24/85    12:17 PM  : REVISED FOR USE WITH THE DEC COMPILER
  442. --                        OLD CODE (TELESOFT) MARKED WITH --&MT
  443.  
  444. PACKAGE BODY COMMAND_TYPES IS
  445.   End_of_command_delimeter : CONSTANT CHARACTER := ASCII.NUL;
  446.  
  447.   FUNCTION End_of_command ( Cmd_character : IN CHARACTER ) RETURN BOOLEAN IS
  448.     BEGIN
  449.         IF Cmd_character = End_of_command_delimeter THEN
  450.             RETURN TRUE;
  451.         ELSE
  452.             RETURN FALSE;
  453.         END IF;
  454.     END End_of_command;
  455. BEGIN
  456.     FOR Index IN Null_command_string'RANGE LOOP
  457.         Null_command_string ( Index ) := End_of_command_delimeter;
  458.     END LOOP;
  459. EXCEPTION
  460.     WHEN OTHERS =>
  461.         TEXT_IO.NEW_LINE;
  462.         TEXT_IO.PUT_LINE("***** Error in Command_TYPES *****");
  463.     RAISE;
  464. END Command_types;
  465. --::::::::::::::
  466. --ftptypes_.ada
  467. --::::::::::::::
  468. -----------------------------------------------------------------------
  469. --
  470. --         DoD Protocols    NA-00005-200       80-01109-100(-)
  471. --         E-Systems, Inc.  August 07, 1985
  472. --
  473. --         FTPTYPES_.ADA       Author : Mark Volpe
  474. --
  475. -----------------------------------------------------------------------
  476. -- FILE : FTPTYPES               AUTHOR : MARK VOLPE
  477.  
  478. -- 5/13/85    4:00 PM  : REVISED FOR USE WITH DEC COMPILER  
  479. --                       OLD CODE (TELESOFT) MARKED WITH --&MT
  480.  
  481. -- 5/23/85    4:10 PM  : REVISED FOR USE WITH TELESOFT COMPILER
  482. --                       OLD CODE (DEC) MARKED WITH --&MT
  483.  
  484. -- 5/24/85    12:20 PM  : REVISED FOR USE WITH THE DEC COMPILER
  485. --                        OLD CODE (TELESOFT) MARKED WITH --&MT
  486.  
  487. --&MT THE FOLLOWING LINES SHOULD BE OMITTED WHEN USING DEC ADA :
  488. --&MT PRAGMA SOURCE_INFO ( ON );
  489. --&MT WITH ASCII,  TEXT_IO;
  490.  
  491. --&MT THE FOLLOWING LINE SHOULD BE INCLUDED WHEN USING DEC ADA :
  492. WITH TEXT_IO;
  493.  
  494. WITH Command_types;                USE Command_types;
  495.  
  496. PACKAGE Ftp_types IS
  497.     ----------------------------------------------------------------------
  498.     --
  499.     -- This package contains global type declarations used throughout
  500.     -- FTP.  It also contains system parameters that are used by
  501.     -- the server side or user side in a mutually exclusive manner.
  502.     --
  503.     ----------------------------------------------------------------------
  504.  
  505. --&MT SUBTYPE BIT_COUNT_16_TYPE IS INTEGER;
  506.       SUBTYPE BIT_COUNT_16_TYPE IS SHORT_INTEGER;
  507.  
  508.     Conversion_error : EXCEPTION;
  509.  
  510.     --
  511.     -- These are the return status' that are used in this implementation.
  512.     -- They are not exhaustive and can be modified as required.
  513.     --
  514.     -- TYPE RETURN_STATUS_SPEC IS 
  515.                  -- ( SUCCESS, 
  516.                  --   UNKNOWN_FAILURE, 
  517.                  --   TELNET_FAILURE,
  518.                  --   ABORT_COMMMAND, 
  519.                  --   TCP_FAILURE, 
  520.                  --   USER_FAILED, 
  521.                  --   SERVER_FAILED,
  522.                  --   COMMAND_VALID,
  523.                  --   COMMAND_INVALID );
  524.  
  525.    -- These are the standard FTP commands which can be transmitted
  526.    -- to other ftp sites in addition to a few 'in house' commands.
  527.    --
  528.    TYPE VALID_COMMAND_SPEC IS 
  529.                    ( CALL_COMMAND, -- establish a telnet connection
  530.                      CLOS_COMMAND, -- close a telnet connection
  531.                            EXIT_COMMAND, -- exit from ftp
  532.                            NOOP_COMMAND, -- send a noop to the server
  533.                            HELP_COMMAND, -- get help from the server
  534.                            STRU_COMMAND, -- set the xmit struc (f,r)
  535.                            TYPE_COMMAND, -- set the xmit type (a)
  536.                            MODE_COMMAND, -- set the xmit mode (s)
  537.                            PORT_COMMAND, -- set user listen port
  538.                            QUIT_COMMAND, -- logout from server pi
  539.                            USER_COMMAND, -- username for server pi
  540.                            PASS_COMMAND, -- password for server pi
  541.                            STOR_COMMAND, -- store file on server
  542.                            RETR_COMMAND, -- retrieve file from server
  543.                   REPLY_COMMAND, -- the argument is a reply
  544.                      INVALID_COMMAND); -- any other command string
  545.  
  546.    -- The following parameters specify the format for identifying a port.
  547.    --
  548.    SUBTYPE Valid_port_identifier IS CHARACTER; -- RFC 765 pp. 24
  549.    TYPE Port_id IS ARRAY(1..11) OF Valid_port_identifier;
  550.            -- RFC 765 pp.  23-4
  551.            -- The actual argument is 6 characters separated by 5 commas.
  552.  
  553.     -- The following paramters specify the format of the arguments
  554.     -- This length is not specified in the RFC 765 spec.
  555.     -- However, since all commands must fit on one line,
  556.     -- the max argument length is max_length - command size - 1;
  557.     --
  558.  
  559.               Max_argument_size : CONSTANT BIT_COUNT_16_TYPE := 
  560.                Max_command_string_length - max_command_size - 1;
  561.         --&MT Max_argument_size : CONSTANT bit_count_16_type := 127 ;
  562.  
  563.     SUBTYPE Argument_list_unit IS CHARACTER; -- RFC 765 p. 32
  564.                 -- use a separate type to enforce data abstraction
  565.  
  566.     TYPE Argument_list IS ARRAY( 1 .. Max_argument_size ) OF Argument_list_unit;
  567.                 -- RFC 765 p. 32
  568.                 -- The necessary arguments are passed as characters
  569.                 -- because of file names.
  570.  
  571.     Null_argument : Argument_list;
  572.                 -- This is necessary to initialize argument strings to all
  573.                 -- null characters since telesoft does not support
  574.                 -- packed aggregate initialization yet.
  575.  
  576. --&MT THE FOLLOWING LINE SHOULD BE DELETED WHEN USING TELESOFT;
  577.     PACKAGE Int_IO IS NEW TEXT_IO.INTEGER_IO(bit_count_16_type);
  578.  
  579.     FUNCTION End_of_argument ( Argument_element : IN Argument_list_unit )
  580.                                                                 RETURN BOOLEAN;
  581.  
  582.     PROCEDURE Convert_string_to_argument
  583.                 ( Input_string : IN STRING; Argument : OUT ARGUMENT_LIST );
  584.  
  585.     PROCEDURE Convert_argument_to_string
  586.                 ( Argument     : IN  Argument_list ;
  587.                   Output_string    : OUT String;
  588.                   String_length    : OUT BIT_COUNT_16_TYPE );
  589.  
  590.     --
  591.     -- These are the default system paramters used by a server or user pi.
  592.     --
  593.     Default_file_mode        : Argument_list_unit := 'S'; -- RFC 765 p 25
  594.     Default_file_structure   : Argument_list_unit := 'F'; -- RFC 765 p 25
  595.     Default_file_type        : Argument_list_unit := 'A'; -- RFC 765 p 24
  596.     Default_carriage_control : Argument_list_unit := 'N'; -- RFC 765 p 24
  597.     Default_port_id          : Port_id;
  598. END FTP_TYPES;
  599.  
  600. --::::::::::::::
  601. --ftptypes.ada
  602. --::::::::::::::
  603. -----------------------------------------------------------------------
  604. --
  605. --         DoD Protocols    NA-00005-200       80-01110-100(-)
  606. --         E-Systems, Inc.  August 07, 1985
  607. --
  608. --         FTPTYPES.ADA       Author : Mark Volpe
  609. --
  610. -----------------------------------------------------------------------
  611. -- FILE : FTPTYPES               AUTHOR : MARK VOLPE
  612.  
  613. -- 5/13/85    4:00 PM  : REVISED FOR USE WITH DEC COMPILER  
  614. --                       OLD CODE (TELESOFT) MARKED WITH --&MT
  615.  
  616. -- 5/23/85    4:10 PM  : REVISED FOR USE WITH TELESOFT COMPILER
  617. --                       OLD CODE (DEC) MARKED WITH --&MT
  618.  
  619. -- 5/24/85    12:30 PM  : REVISED FOR USE WITH THE DEC COMPILER
  620. --                        OLD CODE (TELESOFT) MARKED WITH --&MT
  621.  
  622. PACKAGE BODY FTP_TYPES IS
  623.  
  624. --&MT SUBTYPE BIT_COUNT_32_TYPE IS LONG_INTEGER;
  625.       SUBTYPE BIT_COUNT_32_TYPE IS INTEGER;
  626.  
  627. --&MT THE FOLLOWING LINE SHOULD BE INCLUDED WHEN USING DEC ADA :
  628.   PACKAGE LONG_INT IS NEW TEXT_IO.INTEGER_IO(BIT_COUNT_32_TYPE);
  629.  
  630.   FUNCTION End_of_argument ( Argument_element : IN Argument_list_unit )
  631.                                                         RETURN BOOLEAN IS
  632.     BEGIN
  633.         IF ARGUMENT_ELEMENT = ASCII.NUL THEN
  634.             RETURN TRUE;
  635.         ELSE 
  636.             RETURN FALSE;
  637.         END IF;
  638.     END END_OF_ARGUMENT;
  639.  
  640.   PROCEDURE Convert_argument_to_string
  641.             ( Argument       : IN Argument_list ;
  642.               Output_string  : OUT STRING;
  643.               String_length  : OUT BIT_COUNT_16_TYPE) IS
  644.  
  645.         temp_string_length : bit_count_16_type;
  646.         Argument_index     : BIT_COUNT_16_TYPE := Argument_list'first;
  647.     BEGIN
  648.         temp_string_length := 0;
  649.         FOR Index IN Output_string'RANGE LOOP
  650.             IF End_of_argument ( Argument( ARGument_index ) ) THEN
  651.                 EXIT;
  652.             ELSE
  653.                 temp_string_length := temp_string_length + 1;
  654.                 Output_string(Index) := CHARACTER'( Argument( Argument_index ));
  655.                 Argument_index := Argument_index + 1;
  656.             END IF;
  657.         END LOOP;
  658.     string_length := temp_string_length;
  659.     EXCEPTION
  660.         WHEN OTHERS => RAISE Conversion_error;
  661.     END Convert_argument_to_string;
  662.     
  663.   PROCEDURE Convert_string_to_argument
  664.                 ( Input_string : IN STRING; Argument : OUT Argument_list ) IS
  665.             Argument_index : BIT_COUNT_16_TYPE := Argument'FIRST;
  666.     BEGIN
  667.         Argument := Null_argument;
  668.         FOR Index IN Input_string'RANGE LOOP
  669.           Argument(Argument_index) := Argument_list_unit'(Input_string(Index));
  670.           Argument_index := Argument_index + 1;
  671.         END LOOP;
  672.     EXCEPTION
  673.         WHEN OTHERS => RAISE Conversion_error;
  674.     END Convert_string_to_argument;
  675. BEGIN
  676.     FOR Index IN Null_argument'RANGE LOOP
  677.         Null_argument ( Index ) := Ascii.nul;
  678.     END LOOP;
  679.     DECLARE 
  680.  
  681.             Index : bit_count_32_type := bit_count_32_type(Port_id'FIRST);
  682. --&MT       Index : bit_count_16_type := bit_count_16_type(Port_id'FIRST);             
  683.  
  684.         BEGIN
  685.             Default_port_id( Index      ) := Valid_port_identifier'('1');
  686.             Default_port_id( Index +  1 ) := Valid_port_identifier'(',');
  687.             Default_port_id( Index +  2 ) := Valid_port_identifier'('2');
  688.             Default_port_id( Index +  3 ) := Valid_port_identifier'(',');
  689.             Default_port_id( Index +  4 ) := Valid_port_identifier'('3');
  690.             Default_port_id( Index +  5 ) := Valid_port_identifier'(',');
  691.             Default_port_id( Index +  6 ) := Valid_port_identifier'('4');
  692.             Default_port_id( Index +  7 ) := Valid_port_identifier'(',');
  693.             Default_port_id( Index +  8 ) := Valid_port_identifier'('5');
  694.             Default_port_id( Index +  9 ) := Valid_port_identifier'(',');
  695.             Default_port_id( Index + 10 ) := Valid_port_identifier'('6');
  696.         END;
  697. EXCEPTION
  698.     WHEN OTHERS =>
  699.         TEXT_IO.NEW_LINE;
  700.         TEXT_IO.PUT_LINE("***** Error in FTP_TYPES *****");
  701.         RAISE;
  702. END Ftp_types;
  703. --::::::::::::::
  704. --ftprpl_.ada
  705. --::::::::::::::
  706. -----------------------------------------------------------------------
  707. --
  708. --         DoD Protocols    NA-00005-200       80-01084-100(-)
  709. --         E-Systems, Inc.  August 07, 1985
  710. --
  711. --         FTPRPL_.ADA       Author : Mark Volpe
  712. --
  713. -----------------------------------------------------------------------
  714. -- FILE : FTPRPL               AUTHOR : MARK VOLPE
  715.  
  716. -- 5/14/85    9:00 AM  : REVISED FOR USE WITH DEC COMPILER  
  717. --                       OLD CODE (TELESOFT) MARKED WITH --&MT
  718.  
  719. -- 5/24/85    8:30 AM  : REVISED FOR USE WITH TELESOFT COMPILER
  720. --                       OLD CODE (DEC) MARKED WITH --&MT
  721.  
  722. -- 5/24/85    12:50 PM  : REVISED FOR USE WITH THE DEC COMPILER
  723. --                        OLD CODE (TELESOFT) MARKED WITH --&MT
  724.  
  725. --&MT THE FOLLOWING LINES SHOULD BE DELETED WHEN USING DEC ADA :
  726. --&MT PRAGMA SOURCE_INFO ( ON );
  727. --&MT WITH Ftp_types, TEXT_IO, ASCII;
  728.  
  729. WITH Ftp_types, TEXT_IO;
  730.  
  731. PACKAGE Reply_types IS
  732.  
  733. --&MT SUBTYPE BIT_COUNT_32_TYPE IS LONG_INTEGER;
  734.       SUBTYPE BIT_COUNT_32_TYPE IS INTEGER;
  735.  
  736. --&MT SUBTYPE BIT_COUNT_16_TYPE IS INTEGER;
  737.       SUBTYPE BIT_COUNT_16_TYPE IS SHORT_INTEGER;
  738.  
  739.    --
  740.    -- The following parameters specify the format of replys sent over telnet.
  741.    --
  742.    Max_reply_code_length    : CONSTANT BIT_COUNT_16_TYPE := 3; -- RFC 765  p. 32
  743.  
  744.       Max_reply_message_length : CONSTANT BIT_COUNT_16_TYPE := Ftp_types.max_argument_size;
  745.                                         -- RFC 765 does not specify a length
  746.                                         -- Therefore this is arbitrary.
  747.        
  748.    SUBTYPE Valid_reply_code_character IS CHARACTER RANGE '0'..'9';
  749.                                         -- RFC 765 p. 32
  750.    TYPE Telnet_reply_code_spec IS ARRAY ( 1 .. Max_reply_code_length )
  751.                                                 OF Valid_reply_code_character;
  752.                                         -- RFC 765 p. 32
  753.                                         -- 3 digits; where a digit is a 
  754.                                         -- character in '0'..'9'
  755.    SUBTYPE Message_spec IS 
  756.  
  757.          STRING( 1 .. bit_count_32_type(Max_reply_message_length )) ;
  758. --&MT    STRING(1..127) ;
  759.  
  760.                                         -- Text from reply
  761.    TYPE Reply_status_spec IS (     positive_preliminary_reply_code,
  762.                     Positive_completion_reply_code,
  763.                     Positive_intermediate_reply_code,
  764.                     Transient_negative_completion_reply_code,
  765.                     Permanent_negative_completion_reply_code ,
  766.                     Reply_code_error );
  767.    TYPE Message_type_spec IS (    Syntax,
  768.                     Information,
  769.                     Connections,
  770.                     Authentication,
  771.                     Unspecified ,
  772.                                 File_system,
  773.                     Message_type_error );
  774.  
  775.    TYPE Reply_code_spec IS RECORD
  776.                 Code                : Reply_status_spec;
  777.                 Message_type        : Message_type_spec;
  778.                 Multiline_message   : BOOLEAN;
  779.                 message : message_spec ;
  780.  
  781.         END RECORD;
  782.     --
  783.     -- Codes which indicate status of reply
  784.     --
  785.     Code_for_positive_preliminary_reply
  786.                     : CONSTANT Valid_reply_code_character := '1';
  787.     Code_for_positive_completion_reply
  788.                     : CONSTANT Valid_reply_code_character := '2';
  789.     Code_for_positive_intermediate_reply
  790.                     : CONSTANT Valid_reply_code_character := '3';
  791.     Code_for_transient_negative_completion_reply
  792.                     : CONSTANT Valid_reply_code_character := '4';
  793.     Code_for_permanent_negative_completion_reply
  794.                     : CONSTANT Valid_reply_code_character := '5';
  795.     --
  796.     -- Codes which qualify reply
  797.     --
  798.     Code_for_syntax_qualifier
  799.                     : CONSTANT Valid_reply_code_character := '0';
  800.     Code_for_information_qualifier
  801.                     : CONSTANT Valid_reply_code_character := '1';
  802.     Code_for_connection_qualifier
  803.                     : CONSTANT Valid_reply_code_character := '2';
  804.     Code_for_authentication_qualifier
  805.                     : CONSTANT Valid_reply_code_character := '3';
  806.     Code_for_unspecified_qualifier
  807.                     : CONSTANT Valid_reply_code_character := '4';
  808.     Code_for_file_system_qualifier
  809.                     : CONSTANT Valid_reply_code_character := '5';
  810.     --
  811.     Null_reply_message : Message_spec;
  812.  
  813. --&MT THE FOLLOWING LINES SHOULD BE DELETED WHEN USING TELESOFT
  814.    PACKAGE Long_Int_IO IS NEW TEXT_IO.INTEGER_IO (bit_count_32_type);
  815.    
  816.     --
  817.     -- Reply functions
  818.     --
  819.     FUNCTION Positive_preliminary_reply 
  820.             ( Reply : IN Reply_code_spec ) RETURN BOOLEAN;
  821.     FUNCTION Positive_completion_reply 
  822.             ( Reply : IN Reply_code_spec ) RETURN BOOLEAN;
  823.     FUNCTION Positive_intermediate_reply 
  824.             ( Reply : IN Reply_code_spec ) RETURN BOOLEAN;
  825.     FUNCTION Transient_negative_completion_reply 
  826.             ( Reply : IN Reply_code_spec ) RETURN BOOLEAN;
  827.     FUNCTION Permanent_negative_completion_reply 
  828.               ( Reply : IN Reply_code_spec ) RETURN BOOLEAN;
  829.     FUNCTION End_of_reply 
  830.               ( Reply_element : IN Valid_reply_code_character ) RETURN BOOLEAN ;
  831.     FUNCTION Syntax_related 
  832.             ( Reply : IN Reply_code_spec ) RETURN BOOLEAN;
  833.     FUNCTION Information_related
  834.             ( Reply : IN Reply_code_spec ) RETURN BOOLEAN;
  835.     FUNCTION Connection_related
  836.             ( Reply : IN Reply_code_spec ) RETURN BOOLEAN;
  837.     FUNCTION Authentication_related
  838.             ( Reply : IN Reply_code_spec ) RETURN BOOLEAN;
  839.     FUNCTION File_system_related
  840.             ( Reply : IN Reply_code_spec ) RETURN BOOLEAN;
  841. END Reply_types;
  842.  
  843. --::::::::::::::
  844. --ftprpl.ada
  845. --::::::::::::::
  846. -----------------------------------------------------------------------
  847. --
  848. --         DoD Protocols    NA-00005-200       80-01085-100(-)
  849. --         E-Systems, Inc.  August 07, 1985
  850. --
  851. --         FTPRPL.ADA       Author : Mark Volpe
  852. --
  853. -----------------------------------------------------------------------
  854. -- FILE : FTPRPL               AUTHOR : MARK VOLPE
  855.  
  856. -- 5/14/85    9:00 AM  : REVISED FOR USE WITH DEC COMPILER  
  857. --                       OLD CODE (TELESOFT) MARKED WITH --&MT
  858.  
  859. -- 5/24/85    8:30 AM  : REVISED FOR USE WITH TELESOFT COMPILER
  860. --                       OLD CODE (DEC) MARKED WITH --&MT
  861.  
  862. -- 5/24/85    12:55 PM  : REVISED FOR USE WITH THE DEC COMPILER
  863. --                        OLD CODE (TELESOFT) MARKED WITH --&MT
  864.  
  865. PACKAGE BODY REPLY_TYPES IS
  866.   End_of_reply_delimeter : CONSTANT CHARACTER := ASCII.NUL;
  867.  
  868.   FUNCTION Positive_preliminary_reply 
  869.             ( Reply : IN Reply_code_spec ) RETURN BOOLEAN IS
  870.     BEGIN
  871.         IF Reply.code = Positive_preliminary_reply_code THEN
  872.             RETURN TRUE;
  873.         ELSE
  874.             RETURN FALSE;
  875.         END IF;
  876.     End POSITIVE_PRELIMINARY_REPLY ;
  877.   FUNCTION Positive_completion_reply
  878.             ( Reply : IN Reply_code_spec ) RETURN BOOLEAN IS
  879.     BEGIN
  880.         IF Reply.code = Positive_completion_reply_code THEN
  881.             RETURN TRUE;
  882.         ELSE
  883.             RETURN FALSE;
  884.         END IF;
  885.     END Positive_completion_reply;
  886.   FUNCTION Positive_intermediate_reply 
  887.             ( Reply : IN Reply_code_spec ) RETURN BOOLEAN IS
  888.     BEGIN
  889.         IF Reply.code = Positive_intermediate_reply_code THEN
  890.             RETURN TRUE;
  891.         ELSE
  892.             RETURN FALSE;
  893.         END IF;
  894.     END Positive_intermediate_reply;
  895.   FUNCTION Transient_negative_completion_reply 
  896.             ( Reply : IN Reply_code_spec ) RETURN BOOLEAN IS
  897.     BEGIN
  898.         IF Reply.code = Transient_negative_completion_reply_code THEN
  899.             RETURN TRUE;
  900.         ELSE
  901.             RETURN FALSE;
  902.         END IF;
  903.     END Transient_negative_completion_reply;
  904.   FUNCTION Permanent_negative_completion_reply 
  905.             ( Reply : IN Reply_code_spec ) RETURN BOOLEAN IS
  906.     BEGIN
  907.         IF Reply.code =  Permanent_negative_completion_reply_code THEN
  908.             RETURN TRUE;
  909.         ELSE
  910.             RETURN FALSE;
  911.         END IF;
  912.     END Permanent_negative_completion_reply;
  913.   FUNCTION End_of_reply
  914.             ( Reply_element : IN Valid_reply_code_character ) RETURN BOOLEAN IS
  915.     BEGIN
  916.         IF Reply_element = End_of_reply_delimeter THEN
  917.             RETURN TRUE;
  918.         ELSE
  919.             RETURN FALSE;
  920.         END IF;
  921.     END End_of_reply;
  922.   FUNCTION Syntax_related
  923.             ( Reply : IN Reply_code_spec ) RETURN BOOLEAN IS
  924.     BEGIN
  925.         IF Reply.message_type = Message_type_spec'( Syntax ) THEN
  926.             RETURN TRUE;
  927.         ELSE
  928.             RETURN FALSE;
  929.         END IF;
  930.     END Syntax_related;
  931.   FUNCTION Information_related
  932.             ( Reply : IN Reply_code_spec ) RETURN BOOLEAN IS
  933.     BEGIN
  934.         IF Reply.message_type = Message_type_spec'( Information ) THEN
  935.             RETURN TRUE;
  936.         ELSE
  937.             RETURN FALSE;
  938.         END IF;
  939.     END Information_related;
  940.   FUNCTION Connection_related
  941.             ( Reply : IN Reply_code_spec ) RETURN BOOLEAN IS
  942.     BEGIN
  943.         IF Reply.message_type = Message_type_spec'( Connections ) THEN
  944.             RETURN TRUE;
  945.         ELSE
  946.             RETURN FALSE;
  947.         END IF;
  948.     END Connection_related;
  949.   FUNCTION Authentication_related
  950.             ( Reply : IN Reply_code_spec ) RETURN BOOLEAN IS
  951.     BEGIN
  952.         IF Reply.message_type = Message_type_spec'( Authentication ) THEN
  953.             RETURN TRUE;
  954.         ELSE
  955.             RETURN FALSE;
  956.         END IF;
  957.     END Authentication_related;
  958.   FUNCTION File_system_related
  959.             ( Reply : In Reply_code_spec ) RETURN BOOLEAN IS
  960.     BEGIN
  961.         IF Reply.message_type = Message_type_spec'( File_system ) THEN
  962.             RETURN TRUE;
  963.         ELSE
  964.             RETURN FALSE;
  965.         END IF;
  966.     END File_system_related;
  967. BEGIN
  968.     FOR Index IN Null_reply_message'RANGE LOOP
  969.         Null_reply_message( Index ) := End_of_reply_delimeter;
  970.     END LOOP;
  971. EXCEPTION
  972.     WHEN OTHERS =>
  973.         TEXT_IO.PUT_LINE (" Error in reply_types initialization");
  974.         RAISE;
  975. END Reply_types;
  976. --::::::::::::::
  977. --ftpterm_.ada
  978. --::::::::::::::
  979. -----------------------------------------------------------------------
  980. --
  981. --         DoD Protocols    NA-00005-200       80-01107-100(-)
  982. --         E-Systems, Inc.  August 07, 1985
  983. --
  984. --         FTPTERM_.ADA       Author : Mark Volpe
  985. --
  986. -----------------------------------------------------------------------
  987. -- FILE : Ftpterm               AUTHOR : MARK VOLPE
  988.  
  989. -- 5/14/85    9:20 AM : REVISED FOR USE WITH DEC COMPILER  
  990. --                      OLD CODE (TELESOFT) MARKED WITH --&MT
  991.  
  992. -- 5/24/85    9:00 AM : REVISED FOR USE WITH TELESOFT COMPILER
  993. --                      OLD CODE (DEC) MARKED WITH --&MT
  994.  
  995. -- 5/24/85    12:58 PM  : REVISED FOR USE WITH THE DEC COMPILER
  996. --                        OLD CODE (TELESOFT) MARKED WITH --&MT
  997.  
  998. --&MT THE FOLLOWING LINES SHOULD BE DELETED WHEN USING DEC ADA :
  999. --&MT PRAGMA SOURCE_INFO ( ON );
  1000. --&MT WITH TEXT_IO, ASCII;
  1001.  
  1002.       WITH TEXT_IO;
  1003.       WITH Command_types, Ftp_types, Reply_types;
  1004.  
  1005. PACKAGE Ftp_terminal_driver IS
  1006.     ----------------------------------------------------------------------
  1007.     --
  1008.     -- This package contains procedures to interface to the users' terminal
  1009.     -- A separate I/O package was used to increase portability to systems
  1010.     -- where text_io is not supported.
  1011.     -- I/O will be slower, but very little time is spent doing I/O versus
  1012.     -- actual file transfers.
  1013.     --
  1014.     ----------------------------------------------------------------------
  1015.     PROCEDURE New_line;
  1016.     PROCEDURE Get_command_from_keyboard
  1017.                 ( Keyboard_data : OUT Command_types.command_string_spec );
  1018.         -- 
  1019.         -- This procedure is responsible for getting data from the
  1020.         -- user's keyboard.
  1021.         --
  1022.     PROCEDURE Output_message ( Error_message : IN CHARACTER );
  1023.     PROCEDURE Output_message ( Error_message : IN STRING );
  1024.     PROCEDURE Output_message_with_new_line ( Error_message : IN CHARACTER );
  1025.     PROCEDURE Output_message_with_new_line ( Error_message : IN STRING );
  1026. END Ftp_terminal_driver;
  1027.  
  1028. --::::::::::::::
  1029. --ftpterm.ada
  1030. --::::::::::::::
  1031. -----------------------------------------------------------------------
  1032. --
  1033. --         DoD Protocols    NA-00005-200       80-01108-100(-)
  1034. --         E-Systems, Inc.  August 07, 1985
  1035. --
  1036. --         FTPTERM.ADA       Author : Mark Volpe
  1037. --
  1038. -----------------------------------------------------------------------
  1039. -- FILE : Ftpterm               AUTHOR : MARK VOLPE
  1040.  
  1041. -- 5/14/85    9:20 AM : REVISED FOR USE WITH DEC COMPILER  
  1042. --                      OLD CODE (TELESOFT) MARKED WITH --&MT
  1043.  
  1044. -- 5/24/85    9:00 AM : REVISED FOR USE WITH TELESOFT COMPILER
  1045. --                      OLD CODE (DEC) MARKED WITH --&MT
  1046.  
  1047. -- 5/24/85    1:01 PM  : REVISED FOR USE WITH THE DEC COMPILER
  1048. --                       OLD CODE (TELESOFT) MARKED WITH --&MT
  1049.  
  1050. PACKAGE BODY Ftp_terminal_driver IS
  1051.  
  1052. --&MT SUBTYPE BIT_COUNT_32_TYPE IS LONG_INTEGER;
  1053.       SUBTYPE BIT_COUNT_32_TYPE IS INTEGER;
  1054.  
  1055. --&MT SUBTYPE BIT_COUNT_16_TYPE IS INTEGER;
  1056.       SUBTYPE BIT_COUNT_16_TYPE IS SHORT_INTEGER;
  1057.  
  1058. --&MT THE FOLLOWING LINES SHOULD BE DELETED WHEN USING TELESOFT
  1059.   PACKAGE Int_IO IS NEW TEXT_IO.INTEGER_IO(BIT_COUNT_16_TYPE);
  1060.   PACKAGE Long_Int_IO IS NEW TEXT_IO.INTEGER_IO(bit_count_32_type);
  1061.  
  1062.   PROCEDURE Get_command_from_keyboard
  1063.                 ( Keyboard_data : OUT Command_types.command_string_spec ) IS
  1064.  
  1065.         Keyboard_data_length : BIT_COUNT_32_TYPE := 0;
  1066. --&MT   Keyboard_data_length : BIT_COUNT_16_TYPE := 0;
  1067.  
  1068.     BEGIN
  1069.         Keyboard_data := Command_types.null_command_string;
  1070.         TEXT_IO.PUT ("FTP> ");
  1071.         TEXT_IO.GET_LINE ( Keyboard_data, Keyboard_data_length );
  1072.         Keyboard_data( Keyboard_data_length + 1 ) := ' ';
  1073.             --
  1074.             -- Make last char a ' ' or get next word will bomb!
  1075.             --
  1076.         Keyboard_data( Keyboard_data_length + 1) := ' ';
  1077.     EXCEPTION
  1078.         WHEN OTHERS => RAISE;
  1079.     END Get_command_from_keyboard;
  1080.   PROCEDURE NEW_LINE IS
  1081.     BEGIN
  1082.         TEXT_IO.NEW_LINE;
  1083.     END New_line;
  1084.   PROCEDURE Output_message ( Error_message : IN CHARACTER ) IS
  1085.     BEGIN
  1086.         TEXT_IO.PUT ( Error_message );
  1087.     END Output_message;
  1088.   PROCEDURE Output_message( Error_message : IN STRING ) IS
  1089.     BEGIN
  1090.         FOR Index IN Error_message'RANGE LOOP
  1091.             IF Error_message( Index ) = ASCII.NUL THEN
  1092.                 EXIT;
  1093.             ELSE
  1094.                 Output_message( CHARACTER'( Error_message( Index )));
  1095.             END IF;
  1096.         END LOOP;
  1097.     EXCEPTION
  1098.         WHEN OTHERS => RAISE;
  1099.     END Output_message ;
  1100.   PROCEDURE Output_message_with_new_line( Error_message : IN CHARACTER ) IS
  1101.     BEGIN
  1102.         Output_message ( Error_message );
  1103.         New_line;
  1104.     EXCEPTION
  1105.         WHEN OTHERS => RAISE;
  1106.     END Output_message_with_new_line;
  1107.   PROCEDURE Output_message_with_new_line( Error_message : IN STRING ) IS
  1108.     BEGIN
  1109.         Output_message ( Error_message );
  1110.         New_line;
  1111.     EXCEPTION
  1112.         WHEN OTHERS => RAISE;
  1113.     END Output_message_with_new_line;
  1114. BEGIN
  1115.     NULL;
  1116. EXCEPTION
  1117.     WHEN OTHERS =>RAISE;
  1118. END Ftp_terminal_driver;
  1119. --::::::::::::::
  1120. --ftptcp_.ada
  1121. --::::::::::::::
  1122. -----------------------------------------------------------------------
  1123. --
  1124. --         DoD Protocols    NA-00005-200       80-01103-100(-)
  1125. --         E-Systems, Inc.  August 07, 1985
  1126. --
  1127. --         FTPTCP_.ADA       Author : Mark Volpe
  1128. --
  1129. -----------------------------------------------------------------------
  1130. -- FILE : FTPTCP                AUTHOR : MARK VOLPE
  1131. --                                     : Mike Thomas (post 7-4-84 modifications)
  1132. -- 5/28/85    2:49 PM  : REVISED FOR USE WITH THE DEC COMPILER
  1133. --                       OLD CODE (TELESOFT) MARKED WITH --&MT
  1134. --  7/5/85    1:50 PM  : modifications for new tcp interface
  1135. -- 7/10/85    4:53 PM  : make tcp_identifier_spec public
  1136. -- 7/21/85    5:23 PM  : buffer_size to 0 ; time_out to 15
  1137.  
  1138. --&MT THE FOLLOWING LINE SHOULD BE DELETED WHEN USING DEC ADA :
  1139. --&MT PRAGMA SOURCE_INFO ( ON );
  1140.  
  1141. WITH SYSTEM ;
  1142. WITH with_ulp_communicate ;
  1143. USE SYSTEM ;
  1144.  
  1145. PACKAGE FTP_TCP IS
  1146.         -------
  1147.  
  1148.    ----------------------------------------------------------------------
  1149.    -- 
  1150.    -- This package contains the procedures used by ftp to interface to tcp.
  1151.    -- These procedures may be implementation dependent depending on which
  1152.    -- tcp program is being used.
  1153.    --
  1154.    ----------------------------------------------------------------------
  1155.  
  1156. --&MT SUBTYPE BIT_COUNT_16_TYPE IS INTEGER;
  1157.       SUBTYPE BIT_COUNT_16_TYPE IS SHORT_INTEGER;
  1158.  
  1159. --&MT SUBTYPE BIT_COUNT_8_TYPE IS SYSTEM.BYTE;
  1160.       SUBTYPE BIT_COUNT_8_TYPE IS SYSTEM.UNSIGNED_BYTE;
  1161.  
  1162.   TYPE Tcp_connection_status_spec IS ( Open, Closed ) ;
  1163.   TYPE Tcp_identifier_spec IS RECORD
  1164.     Connection_id     : with_ulp_communicate.lcn_ptr_type ;
  1165.     Connection_status : Tcp_connection_status_spec := CLOSED ;
  1166.     Local_port_id     : BIT_COUNT_16_TYPE ;
  1167.   END RECORD ;
  1168.  
  1169.   No_more_tcp_data          : EXCEPTION ;
  1170.   Tcp_aborted               : EXCEPTION ;
  1171.   Tcp_buffer_access_error   : EXCEPTION ;
  1172.   Tcp_connection_closed     : EXCEPTION ;
  1173.   Tcp_request_failed        : EXCEPTION ;
  1174.   Unexpected_reply          : EXCEPTION ;
  1175.  
  1176.   FUNCTION Tcp_connection_is_open
  1177.            ----------------------
  1178.    (Tcp_identifier : IN Tcp_identifier_spec ) RETURN BOOLEAN ;
  1179.     ----------------------------------------------------------------------
  1180.     --
  1181.     -- This function is used to determine if a TCP connection is already open
  1182.     --
  1183.     -- Exceptions: Tcp_request_failed.
  1184.     ----------------------------------------------------------------------
  1185.  
  1186.  
  1187.   PROCEDURE Initialize_tcp (Tcp_identifier : IN OUT Tcp_identifier_spec) ;
  1188.             --------------
  1189.  
  1190.   PROCEDURE Wait_for_tcp_connection_to_close
  1191.             --------------------------------
  1192.    (Tcp_identifier : IN OUT Tcp_identifier_spec) ;
  1193.  
  1194.  
  1195.   PROCEDURE Open_tcp_data_link
  1196.             ------------------
  1197.    (Tcp_identifier  : IN OUT Tcp_identifier_spec ;
  1198.     buffer_size     : IN     BIT_COUNT_16_TYPE := 0 ;
  1199.     timeout         : IN     BIT_COUNT_16_TYPE := 15 ;
  1200.     security        : IN     BIT_COUNT_16_TYPE := 0 ;
  1201.     precedence      : IN     BIT_COUNT_16_TYPE := 0);
  1202.     ----------------------------------------------------------------------
  1203.     --
  1204.     -- This procedure is used to open a tcp connection.  If a connection
  1205.     -- is already open then a new one is not opened.
  1206.     --
  1207.     -- Exceptions: Tcp_request_failed.
  1208.     ----------------------------------------------------------------------
  1209.  
  1210.  
  1211.   PROCEDURE Close_tcp_data_link (Tcp_identifier : IN OUT Tcp_identifier_spec) ;
  1212.             -------------------
  1213.    
  1214.     ----------------------------------------------------------------------
  1215.     --
  1216.     -- This procedure is used to close a TCP connection.  If a connection
  1217.     -- does not exist then nothing is done.
  1218.     --
  1219.     -- Exceptions: Tcp_request_failed.
  1220.     ----------------------------------------------------------------------
  1221.  
  1222.  
  1223.   PROCEDURE Load_byte_into_tcp_buffer
  1224.             -------------------------
  1225.    (Tcp_identifier : IN OUT Tcp_identifier_spec ;
  1226.     Tcp_data       : IN     CHARACTER ) ;
  1227.     ----------------------------------------------------------------------
  1228.     --
  1229.     -- This procedure loads a byte into the next avaliable buffer location.
  1230.     -- If the buffer is full,  the current buffer is transmitted 
  1231.     -- and the byte is then added at the start of a new buffer.
  1232.     --
  1233.     -- Exceptions: Tcp_buffer_access_error.
  1234.     ----------------------------------------------------------------------
  1235.  
  1236.  
  1237.   PROCEDURE Load_byte_into_tcp_buffer
  1238.             -------------------------
  1239.    (Tcp_identifier : IN OUT Tcp_identifier_spec ;
  1240.     Tcp_data       : IN     BIT_COUNT_8_TYPE ) ;
  1241.     ----------------------------------------------------------------------
  1242.     --
  1243.     -- This procedure loads a byte into the next avaliable buffer location.
  1244.     -- If the buffer is full,  the current buffer is transmitted 
  1245.     -- and the byte is then added at the start of a new buffer.
  1246.     --
  1247.     -- Exceptions: Tcp_buffer_access_error.
  1248.     ----------------------------------------------------------------------
  1249.  
  1250.  
  1251.   PROCEDURE Get_byte_from_tcp_buffer
  1252.             ------------------------
  1253.    (Tcp_identifier : IN OUT Tcp_identifier_spec ;
  1254.     Tcp_data       :    OUT CHARACTER) ;
  1255.     ----------------------------------------------------------------------
  1256.     --
  1257.     -- This procedure is used to get the next byte from a tcp buffer.
  1258.     -- If there are no more bytes in the buffer then another buffer is
  1259.     -- retreived.
  1260.     --
  1261.     -- Exceptions: Tcp_buffer_access_error.
  1262.     ----------------------------------------------------------------------
  1263.  
  1264.  
  1265.   PROCEDURE Get_byte_from_tcp_buffer
  1266.             ------------------------
  1267.    (Tcp_identifier : IN OUT Tcp_identifier_spec ;
  1268.     Tcp_data       :    OUT BIT_COUNT_8_TYPE ) ;
  1269.     ----------------------------------------------------------------------
  1270.     --
  1271.     -- This procedure is used to get the next byte from a tcp buffer.
  1272.     -- If there are no more bytes in the buffer then another buffer is
  1273.     -- retreived.
  1274.     --
  1275.     -- Exceptions: Tcp_buffer_access_error.
  1276.     ----------------------------------------------------------------------
  1277.  
  1278.  
  1279.   PROCEDURE Listen_on_current_tcp_port_for_an_active_open
  1280.             ---------------------------------------------
  1281.    (Tcp_identifier : IN OUT Tcp_identifier_spec) ;
  1282.     ----------------------------------------------------------------------
  1283.     --
  1284.     -- This procedure waits for the passive port to be opened actively.
  1285.     --
  1286.     -- Exceptions: Tcp_request_failed.
  1287.     ----------------------------------------------------------------------
  1288.  
  1289.  
  1290.   PROCEDURE Indicate_that_all_of_tcp_data_has_been_used ;
  1291.             -------------------------------------------
  1292.  
  1293.     ----------------------------------------------------------------------
  1294.     --
  1295.     -- This procedure tells tcp that the current buffer is no longer 
  1296.     -- required and may be freed up.
  1297.     --
  1298.     ----------------------------------------------------------------------
  1299.  
  1300.  
  1301.   PROCEDURE Push_tcp_buffer (Tcp_identifier : IN OUT Tcp_identifier_spec) ;
  1302.             ---------------
  1303.  
  1304.     ----------------------------------------------------------------------
  1305.     --
  1306.     -- This procedure pushes ( transmitts ) the current tcp buffer
  1307.     --
  1308.     -- Exceptions:
  1309.     ----------------------------------------------------------------------
  1310.  
  1311.  
  1312.   PROCEDURE Abort_tcp (Tcp_identifier : IN OUT Tcp_identifier_spec) ;
  1313.             ---------
  1314.    
  1315.     ----------------------------------------------------------------------
  1316.     --
  1317.     -- This procedure aborts tcp.
  1318.     --
  1319.     -- Exceptions: None
  1320.     ----------------------------------------------------------------------
  1321.  
  1322.  
  1323.   END FTP_TCP ;
  1324.  
  1325. --::::::::::::::
  1326. --ftptcp.ada
  1327. --::::::::::::::
  1328. -----------------------------------------------------------------------
  1329. --
  1330. --         DoD Protocols    NA-00005-200       80-01104-100(-)
  1331. --         E-Systems, Inc.  August 07, 1985
  1332. --
  1333. --         FTPTCP.ADA       Author : Mark Volpe
  1334. --
  1335. -----------------------------------------------------------------------
  1336. -- FILE : FTPTCP                AUTHOR : MARK VOLPE
  1337. --                                     : Mike Thomas (post 7/4/85 mods)
  1338.  
  1339. -- 5/28/85  3:02 PM : revised for use with the dec compiler
  1340. --                    old code (telesoft) marked with --&MT
  1341. --  7/5/85  4:46 PM : mods for new tcp interface
  1342. -- 7/11/85 11:33 AM : have init_tcp not do passive open for user (port #=-1)
  1343. --                  : so.. don't do abort before an open
  1344. --          6:06 PM : allow for 0's after open request
  1345. -- 7/12/85 10:00 AM : save lcn after open requests
  1346. -- 7/18/85 11:54 AM : fix problen saving lcn after getting #14 on pass open
  1347. -- 7/19/85 11:05 AM : have listen for active open do a passive open first
  1348. --                  : hard wire assign port parameters procedure
  1349. --                  : don't do passive open during initialize_tcp
  1350. --          6:20 PM : fix for active open parameters
  1351. -- 7/21/85  4:57 PM : buffer_size to 0, time_out to 15, set lcn before 
  1352. --                  : wait_for_tcp_message
  1353. --          6:12    : change loop location in listen_for active open
  1354. -- 7/22/85 11:38 AM : save lcn_ptr after #14 not #23
  1355. --          3:41 PM : put debug in for monitoring actual transfer
  1356. -- 7/23/85  9:53 AM : remove some debug 
  1357. --          7:03 PM : size of ftp buffer made a constant
  1358. -- 7/24/85  2:20 AM : comment out debug code
  1359. -- 7/29/85 11:36 AM : put in ten sec delay on open to give other side time to passive
  1360.  
  1361. WITH TEXT_IO ;
  1362. WITH My_debug_io ;
  1363. WITH UNCHECKED_CONVERSION ;
  1364. WITH Buffer_data ;
  1365. USE  buffer_data ; -- need for access to equality operator on one of its data types
  1366. WITH My_debug_io ;
  1367. WITH My_utilities ;
  1368. WITH vt100 ;
  1369.  
  1370. PACKAGE BODY FTP_TCP IS
  1371.  
  1372. --&MT SUBTYPE BIT_COUNT_32_TYPE IS LONG_INTEGER ;
  1373.       SUBTYPE BIT_COUNT_32_TYPE IS INTEGER ;
  1374.  
  1375. --&MT THE FOLLOWING LINES SHOULD BE DELETED WHEN USING TELESOFT
  1376.   PACKAGE LONG_INT IS NEW TEXT_IO.INTEGER_IO(BIT_COUNT_32_TYPE) ;
  1377.   PACKAGE INT_IO IS NEW TEXT_IO.INTEGER_IO(BIT_COUNT_16_TYPE) ;
  1378.   PACKAGE SYSTEM_BYTE IS NEW TEXT_IO.INTEGER_IO(BIT_COUNT_8_TYPE) ;
  1379.  
  1380.   SUBTYPE Transfer_byte IS BIT_COUNT_8_TYPE ;
  1381.  
  1382.   Dummy_character     : CHARACTER ;
  1383.   End_of_ftp_buffer   : CONSTANT BIT_COUNT_16_TYPE := buffer_data.Telnet_size ;
  1384.   size_of_ftp_buffer  : CONSTANT bit_count_16_type := 128 ;
  1385.   Max_tcp_timeout     : CONSTANT BIT_COUNT_16_TYPE := 255 ;
  1386.   Precedence_value    : CONSTANT BIT_COUNT_16_TYPE := 0 ;
  1387.   Security_value      : CONSTANT BIT_COUNT_16_TYPE := 0 ;
  1388.   Start_of_ftp_buffer : CONSTANT BIT_COUNT_16_TYPE := 1 ;
  1389.  
  1390.   Bytes_loaded_into_buffer      : BIT_COUNT_16_TYPE := 0 ;
  1391.   Bytes_removed_from_tcp_buffer : BIT_COUNT_16_TYPE := 0 ;
  1392.   Ftp_buffer_offset             : BIT_COUNT_16_TYPE := Start_of_ftp_buffer - 1 ;
  1393.   Ftp_buffer_pointer            : buffer_data.Tcp_ptr_type ;
  1394.   Push_flag_value               : BIT_COUNT_16_TYPE := 0 ; 
  1395.   Tcp_buffer_count              : BIT_COUNT_16_TYPE := 0 ;
  1396.   Tcp_buffer_pointer            : buffer_data.packed_buffer_ptr := NULL ;
  1397.   Timeout_value                 : BIT_COUNT_16_TYPE := Max_tcp_timeout ;
  1398.   Type_of_buffer                : BIT_COUNT_16_TYPE := 0 ;
  1399.   Urgent_flag_value             : BIT_COUNT_16_TYPE := 0 ;
  1400.     --
  1401.     -- Ftp_buffer_pointer points to start of ftp data which is located in 
  1402.     -- packed_buffer.byte which is pointed to by Tcp_buffer_pointer.
  1403.     -- Access a byte as:
  1404.     --     Tcp_buffer_pointer.Byte( Ftp_buffer_pointer + Ftp_buffer_offset)
  1405.     --
  1406.  
  1407.   FUNCTION Character_to_byte IS 
  1408.            -----------------
  1409.    NEW UNCHECKED_CONVERSION(CHARACTER, BIT_COUNT_16_TYPE) ;
  1410.  
  1411.  
  1412.   FUNCTION Convert_integer_to_character IS 
  1413.            ----------------------------
  1414.    NEW UNCHECKED_CONVERSION(BIT_COUNT_16_TYPE, CHARACTER) ;
  1415.  
  1416.  
  1417.   FUNCTION Byte_to_character (In_byte : IN BIT_COUNT_16_TYPE) RETURN CHARACTER IS
  1418.            -----------------
  1419.     Byte_string : STRING(1..2) ;
  1420.   BEGIN
  1421.     Byte_string(1) := Convert_integer_to_character (In_byte) ;
  1422.     RETURN Byte_string(1) ;
  1423.   END Byte_to_character ;
  1424.  
  1425.  
  1426. --&MT  PROCEDURE Cycle IS ----------------- may use in TeleSoft T B D
  1427. --&MT            -----
  1428. --&MT    BEGIN -- cycle other protocals here too?? T B D
  1429. --&MT      --&MT -- My_debug_io.PUT_LINE ("  Cycling ") ;
  1430. --&MT      --&MT FOR Index IN 1..1 LOOP
  1431. --&MT      --&MT Tcp_controller ;
  1432. --&MT      --&MT Ip_controller ;
  1433. --&MT      --&MT END LOOP ;
  1434. --&MT      NULL ;
  1435. --&MT    END CYCLE  ;
  1436.  
  1437.  
  1438.   PROCEDURE Indicate_that_all_of_tcp_data_has_been_used IS
  1439.             -------------------------------------------
  1440.   BEGIN
  1441.     Ftp_buffer_offset := Tcp_buffer_count ;
  1442.   END Indicate_that_all_of_tcp_data_has_been_used  ;
  1443.  
  1444.  
  1445.   PROCEDURE Initialize_tcp_receive_queue (Tcp_identifier:Tcp_identifier_spec) IS
  1446.             ----------------------------
  1447.     BUFFER       : buffer_data.packed_buffer_ptr ;
  1448.     RECEIVE_DATA : with_ulp_communicate.RECEIVE_PARAMS ;
  1449.     TASK_MESSAGE : with_ulp_communicate.MESSAGE ;
  1450.     request_ok   : BOOLEAN ;
  1451.  
  1452.   BEGIN
  1453.     buffer_data.Buffget(Buffer, 1) ;
  1454.     Receive_data := (tcp_identifier.connection_id, Buffer, 190) ;
  1455.     Task_message := (with_ulp_communicate.receive, Receive_data) ;
  1456.     --&MT Cycle ;
  1457.     with_ulp_communicate.message_for_tcp(Task_message, request_ok) ;
  1458.     --MT& Cycle ;
  1459.   END Initialize_tcp_receive_queue ;
  1460.  
  1461.  
  1462.   FUNCTION Tcp_connection_is_open
  1463.            ----------------------
  1464.    (Tcp_identifier : IN Tcp_identifier_spec) RETURN BOOLEAN IS
  1465.   BEGIN
  1466.     RETURN Tcp_identifier.connection_status = Open ;
  1467.   EXCEPTION
  1468.     WHEN OTHERS => RAISE Tcp_request_failed ;
  1469.   END Tcp_connection_is_open ;
  1470.  
  1471.  
  1472.   PROCEDURE Output_tcp_response 
  1473.             -------------------
  1474.     (Tcp_response : IN With_ulp_communicate.user_message) IS
  1475.   BEGIN
  1476.     My_debug_io.PUT("  Tcp response was ") ;
  1477.     My_debug_io.PUT_LINE (Tcp_response.message_number) ;
  1478.   END Output_tcp_response ;
  1479.  
  1480.  
  1481.   PROCEDURE Set_the_port_up_to_allow_for_another_transfer
  1482.             ---------------------------------------------
  1483.     (Tcp_identifier : IN OUT Tcp_identifier_spec) IS
  1484.  
  1485.     Open_parameters : with_ulp_communicate.OPEN_PARAMS ;
  1486.     Tcp_message     : with_ulp_communicate.MESSAGE ;
  1487.     Tcp_option      : with_ulp_communicate.TCP_OPTION_TYPE ;
  1488.     Tcp_response    : WITH_ULP_COMMUNICATE.USER_MESSAGE ;
  1489.     request_ok      : BOOLEAN ;
  1490.  
  1491.   BEGIN
  1492.     FOR i IN 1..50 LOOP tcp_option(i) := 0 ; END LOOP ;
  1493.     OPEN_PARAMETERS := (Tcp_identifier.local_port_id, 0, 0,
  1494.      with_ulp_communicate.passive, 0, 60, tcp_identifier.connection_id, 0, 0,
  1495.      tcp_option) ;
  1496.     tcp_message := (with_ulp_communicate.open, open_parameters) ;
  1497.     with_ulp_communicate.message_for_tcp(tcp_message, request_ok) ;
  1498.     tcp_response.local_connection_name := 
  1499.      tcp_message.open_parameters.local_connection_name ;
  1500.     tcp_identifier.connection_id :=
  1501.      tcp_message.open_parameters.local_connection_name ;
  1502.     LOOP
  1503.       my_debug_io.put_line("set the port up") ;
  1504.       --&MT Cycle ;
  1505.       with_ulp_communicate.Wait_for_tcp_message (Tcp_response) ;
  1506.       --&MT Cycle ;
  1507.       Output_tcp_response(Tcp_response) ;
  1508.       CASE Tcp_response.message_number IS
  1509.         WHEN -1 | 0 =>
  1510.          NULL ;
  1511.         WHEN 14 => 
  1512.           tcp_identifier.connection_id.lcn_ptr := 
  1513.            tcp_response.local_connection_name.lcn_ptr ;
  1514.           tcp_identifier.connection_status := closed ; -- this ok?
  1515.           EXIT ;
  1516.         WHEN OTHERS =>
  1517.           RAISE Tcp_request_failed ;
  1518.       END CASE ;
  1519.     END LOOP ;
  1520.   END Set_the_port_up_to_allow_for_another_transfer ;
  1521.                 
  1522.  
  1523.   PROCEDURE Wait_for_tcp_connection_to_close
  1524.             --------------------------------
  1525.    (Tcp_identifier : IN OUT Tcp_identifier_spec) IS
  1526.  
  1527.     Tcp_response : With_ulp_communicate.user_message ;
  1528.  
  1529.   BEGIN
  1530.     tcp_response.local_connection_name := tcp_identifier.connection_id ;
  1531.     LOOP
  1532.       --&MT Cycle ;
  1533.       with_ulp_communicate.Wait_for_tcp_message (Tcp_response) ;
  1534.       --&MT Cycle ;
  1535.       Output_tcp_response(Tcp_response) ;
  1536.       CASE Tcp_response.message_number IS
  1537.         WHEN -1 | 0 =>
  1538.           NULL ;
  1539.         WHEN 6 =>
  1540.           Close_tcp_data_link(Tcp_identifier) ;
  1541.           EXIT ;
  1542.         WHEN 18 =>
  1543.           EXIT ;
  1544.         WHEN OTHERS =>
  1545.           RAISE Tcp_request_failed ;
  1546.       END CASE ;
  1547.     END LOOP ;
  1548.   END Wait_for_tcp_connection_to_close ;
  1549.  
  1550.  
  1551.   PROCEDURE Initialize_tcp (Tcp_identifier : IN OUT Tcp_identifier_spec) IS
  1552.             --------------
  1553.  
  1554. --    Tcp_response    : WITH_ULP_COMMUNICATE.USER_MESSAGE ;
  1555. -- can omit tcp_identifier parameter and above line
  1556.   BEGIN
  1557.     buffer_data.init ;
  1558.   EXCEPTION
  1559.     WHEN OTHERS =>
  1560.       My_debug_io.PUT_LINE("  Unknown exception in Initialize tcp ") ;
  1561.       vt100.Attributes_off ;
  1562.   END Initialize_tcp ;
  1563.  
  1564.  
  1565.   PROCEDURE Open_tcp_data_link -- Does an active open
  1566.             ------------------
  1567.     (Tcp_identifier : IN OUT Tcp_identifier_spec ;
  1568.      buffer_size    : IN     BIT_COUNT_16_TYPE := 0 ;
  1569.      timeout        : IN     BIT_COUNT_16_TYPE := 15 ;
  1570.      security       : IN     BIT_COUNT_16_TYPE := 0 ;
  1571.      precedence     : IN     BIT_COUNT_16_TYPE := 0) IS
  1572.  
  1573.     -- These parameters are used to do a tcp open
  1574.     -- They must all be assigned values before the open request
  1575.     Open_parameters        : with_ulp_communicate.OPEN_PARAMS ;
  1576.     Foreign_port_id        : BIT_COUNT_16_TYPE ;  -- ID OF PORT TO OPEN
  1577.     Trash_foreign_net_host : BIT_COUNT_16_TYPE ;  -- ID FOR FOREIGN HOST
  1578.     Foreign_net_host       : BIT_COUNT_32_TYPE ;  -- ID FOR FOREIGN HOST
  1579.     Options                : with_ulp_communicate.TCP_OPTION_TYPE ; -- set to 0
  1580.  
  1581.     Tcp_response           : WITH_ULP_COMMUNICATE.USER_MESSAGE ;
  1582.     tcp_request            : with_ulp_communicate.message ;
  1583.     abort_parameters       : with_ulp_communicate.abort_close_params ;
  1584.     request_ok             : BOOLEAN ;
  1585.  
  1586.     PROCEDURE Assign_open_parameters IS
  1587.               ----------------------
  1588.     BEGIN
  1589.  
  1590. --&MT THIS IS FOR DEMO, IN FUTURE...
  1591. --    HAVE SERVER ALWAYS DO PASSIVE OPENS AND USER ALWAYS DO ACTIVE OPENS
  1592.  
  1593.       foreign_net_host := 1 ;
  1594.       IF tcp_identifier.local_port_id = 5 THEN -- user ftp
  1595.         foreign_port_id  := 6 ;
  1596.       ELSIF tcp_identifier.local_port_id = 6 THEN -- server ftp
  1597.         foreign_port_id  := 5 ;
  1598.       END IF ;
  1599.       FOR i IN 1..50 LOOP options(i) := 0 ; END LOOP ;
  1600.       open_parameters := (tcp_identifier.local_port_id, foreign_port_id,
  1601.        foreign_net_host, with_ulp_communicate.active, buffer_size, timeout, 
  1602.        tcp_identifier.connection_id, security, precedence, options) ;
  1603.  
  1604.     END Assign_open_parameters ;
  1605.  
  1606.     PROCEDURE Get_tcp_response_to_open_request IS
  1607.               --------------------------------
  1608.     BEGIN
  1609.       LOOP
  1610.         --&MT Cycle ;
  1611.         tcp_response.local_connection_name := tcp_identifier.connection_id ;
  1612.         with_ulp_communicate.Wait_for_tcp_message (Tcp_response) ;
  1613.         --&MT Cycle ;
  1614.         Output_tcp_response(Tcp_response) ;
  1615.         CASE Tcp_response.message_number IS
  1616.           WHEN -1 | 0 => -- noop
  1617.             NULL ;
  1618.           WHEN 12 => -- connection already exists
  1619.             Tcp_identifier.connection_status := Open ;
  1620.             EXIT ;
  1621.           WHEN 14 => -- return lcn from tcp
  1622.             tcp_identifier.connection_id.lcn_ptr := 
  1623.              tcp_response.local_connection_name.lcn_ptr ;
  1624.           WHEN 8 | 16 => -- abort request response (when passive open aborted)
  1625.             NULL ;
  1626.           WHEN 23 => -- OPEN
  1627.             My_debug_io.PUT_LINE ("  Connection Opened") ;
  1628.             Tcp_identifier.connection_status := Open ;
  1629.             EXIT ;
  1630.           WHEN OTHERS =>
  1631.             My_debug_io.PUT_LINE ("  Open request failed ") ;
  1632.             Tcp_identifier.connection_status := Closed ;
  1633.             RAISE Tcp_request_failed ;
  1634.         END CASE ;
  1635.       END LOOP ;
  1636.     END Get_tcp_response_to_open_request ;
  1637.  
  1638.     BEGIN -- open_tcp_data_link
  1639. --MT      size_of_ftp_buffer := buffer_size ;
  1640.       Assign_open_parameters ;
  1641.   
  1642. --      -- abort passive open
  1643. --      abort_parameters := (local_connection_name => 
  1644. --       tcp_identifier.connection_id) ;
  1645. --      tcp_request := (with_ulp_communicate.abor_t, abort_parameters) ;
  1646. --      --&MT cycle
  1647. --      with_ulp_communicate.message_for_tcp(tcp_request, request_ok) ;
  1648. --      --&MT cycle
  1649.  
  1650.       -- request active open
  1651.       DELAY(DURATION(10)) ; -- allow other side to do passive open
  1652.       tcp_request := (with_ulp_communicate.open, open_parameters) ;
  1653.       --&MT cycle
  1654.       with_ulp_communicate.message_for_tcp(tcp_request, request_ok) ;
  1655.       --&MT cycle
  1656.       tcp_identifier.connection_id := 
  1657.        tcp_request.open_parameters.local_connection_name ;
  1658.       Get_tcp_response_to_open_request ;
  1659.       Initialize_tcp_receive_queue(Tcp_identifier) ;
  1660.     EXCEPTION
  1661.       WHEN OTHERS =>
  1662.         My_debug_io.PUT_LINE ("  OPEN_TCP_DATA_LINK FAILED ") ;
  1663.         Tcp_identifier.connection_status := Closed ;
  1664.         RAISE Tcp_request_failed ;
  1665.     END OPEN_TCP_DATA_LINK ;
  1666.  
  1667.   
  1668.   PROCEDURE Close_tcp_data_link (Tcp_identifier : IN OUT Tcp_identifier_spec) IS
  1669.             -------------------
  1670.     
  1671.     -- The node that performs the close request will receive an 18
  1672.     -- reply.
  1673.     -- The node that receives the close request will receive a 6
  1674.     -- reply and must then send a close request which results in an 18.
  1675.  
  1676.     Tcp_request      : with_ulp_communicate.MESSAGE ;
  1677.     Close_parameters : with_ulp_communicate.abort_close_params ;
  1678.     Tcp_response     : WITH_ULP_COMMUNICATE.USER_MESSAGE ;
  1679.     request_ok       : BOOLEAN ;
  1680.  
  1681.   BEGIN
  1682.     IF Tcp_connection_is_open (Tcp_identifier) THEN
  1683.       My_debug_io.PUT_LINE("  Closing tcp link ") ;
  1684.  
  1685.       close_parameters.local_connection_name := tcp_identifier.connection_id ;
  1686.       tcp_request := (with_ulp_communicate.close, close_parameters) ;
  1687.       --&MT cycle ;
  1688.       DELAY(DURATION(10)) ; -- allow last data packet to be delivered
  1689.       with_ulp_communicate.message_for_tcp(tcp_request, request_ok) ;
  1690.       --&MT cycle ;
  1691.       LOOP 
  1692.         --&MT cycle ;
  1693.         tcp_response.local_connection_name := tcp_identifier.connection_id ;
  1694.         with_ulp_communicate.Wait_for_tcp_message(tcp_response) ;
  1695.         --&MT cycle ;
  1696.         output_tcp_response(tcp_response) ;
  1697.         CASE tcp_response.message_number IS
  1698.           WHEN -1 => -- noop
  1699.             NULL ;
  1700.           WHEN 3 => -- connection does not exist
  1701.             my_debug_io.put_line("connection does not exist") ;
  1702.             tcp_identifier.connection_status := closed ;
  1703.             RAISE tcp_connection_closed ;
  1704.           WHEN 6 => -- SHOULD NEVER GET THIS
  1705.             NULL ;
  1706.           WHEN 8 | 16 => -- connection abort/reset
  1707.             my_debug_io.put_line("connection abort/reset") ;
  1708.             tcp_identifier.connection_status := closed ;
  1709.             EXIT ;
  1710.           WHEN  18 => -- closed
  1711.             my_debug_io.put_line("connection closed") ;
  1712.             tcp_identifier.connection_status := closed ;
  1713.             EXIT ;
  1714.           WHEN OTHERS =>
  1715.             my_debug_io.put_line("TCP CLOSE REQUEST FAILED") ;
  1716.             RAISE tcp_request_failed ;
  1717.         END CASE ;                        
  1718.       END LOOP ;
  1719.       Set_the_port_up_to_allow_for_another_transfer(Tcp_identifier) ;
  1720.     ELSE
  1721.       My_debug_io.PUT_LINE ("  Tcp connection not open ") ;
  1722.     END IF ;
  1723.   EXCEPTION
  1724.     WHEN TCP_REQUEST_FAILED =>
  1725.             MY_DEBUG_IO.PUT_LINE (" Tcp request failed ") ;
  1726.             RAISE ;
  1727.     WHEN TCP_CONNECTION_CLOSED =>
  1728.             MY_DEBUG_IO.PUT_LINE (" tcp connection closed ") ;
  1729.             RAISE ;
  1730.     WHEN OTHERS =>
  1731.             My_debug_io.PUT_LINE (" Unknown exception in Close_tcp_data_link") ;
  1732.             RAISE Tcp_request_failed ;
  1733.   END Close_tcp_data_link ;
  1734.  
  1735.  
  1736.   PROCEDURE Load_byte_into_tcp_buffer
  1737.             -------------------------
  1738.    (Tcp_identifier : IN OUT Tcp_identifier_spec ;
  1739.     Tcp_data       : IN     BIT_COUNT_8_TYPE) IS
  1740.  
  1741.  
  1742.     PROCEDURE Get_a_tcp_buffer IS
  1743.               ----------------
  1744.     BEGIN
  1745. --dmt      my_debug_io.put_line("get a tcp_buffer") ;
  1746.       buffer_data.Buffget (Tcp_buffer_pointer, Type_of_buffer) ;
  1747.       Ftp_buffer_pointer := Tcp_buffer_pointer.telnet_ptr ;
  1748.       Ftp_buffer_offset := 0 ; -- No offset from ftp_buffer_pointer
  1749.       Bytes_loaded_into_buffer := 0 ;
  1750.     END Get_a_tcp_buffer ;
  1751.  
  1752.   BEGIN -- load_byte_into_tcp_buffer
  1753. --dmt    my_debug_io.put_line("load_byte_into_tcp_buffer") ;
  1754.     IF Tcp_buffer_pointer = NULL THEN 
  1755.       Get_a_tcp_buffer ;
  1756.     ELSIF Bytes_loaded_into_buffer >= size_of_ftp_buffer THEN
  1757.       Push_tcp_buffer (Tcp_identifier) ;
  1758.       Get_a_tcp_buffer ;
  1759.     END IF ;
  1760.         --
  1761.         -- Data is loaded inwards ; first byte comes in at telnet_ptr,
  1762.         -- the next byte is at telnet_ptr - 1.
  1763.         --
  1764.         Tcp_buffer_pointer.byte
  1765.             (Ftp_buffer_pointer - Ftp_buffer_offset) := Tcp_data ;
  1766.         Bytes_loaded_into_buffer := Bytes_loaded_into_buffer + 1 ;
  1767.  
  1768. --My_debug_io.PUT (" Bytes_loaded_into_buffer  = ") ;
  1769. --My_debug_io.put_line (Bytes_loaded_into_buffer) ;
  1770. --My_debug_io.PUT ("  Ftp_buffer_pointer = ") ;
  1771. --My_debug_io.put_line (Ftp_buffer_pointer) ;
  1772. --My_debug_io.PUT ("  Ftp_buffer_offset = ") ;
  1773. --My_debug_io.put_line (Ftp_buffer_offset) ;
  1774. --my_debug_io.put("tcp_data is >") ;
  1775. --IF tcp_data in 0..127 THEN
  1776. --  My_utilities.output_byte_to_screen (Tcp_data) ;
  1777. --  my_debug_io.put_line(" ") ;
  1778. --ELSE
  1779. --  my_debug_io.put_line("uprintable") ;
  1780. --END IF ;
  1781.  
  1782.         Ftp_buffer_offset := Ftp_buffer_offset + 1 ;
  1783.  
  1784.   EXCEPTION
  1785.     WHEN OTHERS =>
  1786.       My_debug_io.PUT_LINE("  Load_byte_into_tcp_buffer FAILED ") ;
  1787.       RAISE Tcp_buffer_access_error ;
  1788.   END Load_byte_into_tcp_buffer ;
  1789.  
  1790.  
  1791.   PROCEDURE Load_byte_into_tcp_buffer
  1792.             -------------------------
  1793.    (Tcp_identifier : IN OUT Tcp_identifier_spec  ;
  1794.     Tcp_data       : IN     CHARACTER) IS
  1795.   BEGIN
  1796.     Load_byte_into_tcp_buffer
  1797.      (Tcp_identifier,bit_count_8_type(Character_to_byte(Tcp_data))) ;
  1798.   EXCEPTION
  1799.     WHEN OTHERS => 
  1800.       My_debug_io.PUT_LINE("  Load_byte_into_tcp_buffer failed ") ;
  1801.       My_debug_io.PUT_LINE("  Raising Tcp_buffer_access_error ") ;
  1802.       RAISE Tcp_buffer_access_error ;
  1803.   END Load_byte_into_tcp_buffer ;
  1804.  
  1805.  
  1806.   PROCEDURE Get_byte_from_tcp_buffer
  1807.             ------------------------
  1808.    (Tcp_identifier : IN OUT Tcp_identifier_spec ;
  1809.     Tcp_data       :    OUT BIT_COUNT_8_TYPE) IS
  1810.  
  1811.     TEMP_TCP_DATA : BIT_COUNT_8_TYPE ; --&MT FOR DEBUG
  1812.     Receive_parameters : with_ulp_communicate.RECEIVE_PARAMS ;
  1813.     Tcp_request        : with_ulp_communicate.MESSAGE :=
  1814.      (with_ulp_communicate.receive, receive_parameters) ;
  1815.     Tcp_response       : with_ulp_communicate.User_message ;
  1816.  
  1817.  
  1818.     PROCEDURE Get_a_data_buffer_from_tcp IS
  1819.               --------------------------
  1820.   
  1821.       PROCEDURE Dump_the_received_buffer_to_the_screen IS
  1822.                 --------------------------------------
  1823.         Temp_byte : BIT_COUNT_8_TYPE ;
  1824.   
  1825.       BEGIN -- Dump_the_received_buffer_to_the_screen 
  1826.         My_debug_io.put_Line (" Output the buffer to the screen ") ;
  1827.          FOR Offset IN 0..(Tcp_buffer_count - 1) LOOP
  1828.            My_debug_io.put (" Character location = ") ;
  1829.            My_debug_io.put_line (Ftp_buffer_pointer - Offset) ;
  1830.            My_debug_io.put_line (" Assigning byte ") ;
  1831.            Temp_byte := Tcp_buffer_pointer.byte(Ftp_buffer_pointer - Offset) ;
  1832.            My_debug_io.put (" Byte = ") ;
  1833. IF temp_byte in 0..127 THEN
  1834.   My_utilities.output_byte_to_screen (TEMP_BYTE) ;
  1835.   my_debug_io.put_line(" ") ;
  1836. ELSE
  1837.   my_debug_io.put_line("uprintable") ;
  1838. END IF ;
  1839.            TEXT_IO.NEW_LINE ;
  1840.          END LOOP ;
  1841.          My_debug_io.put_Line (" Buffer has been output to the screen ") ;
  1842.       END Dump_the_received_buffer_to_the_screen ;
  1843.   
  1844.   
  1845.       PROCEDURE prepare_buffer_for_processing IS
  1846.                  -----------------------------
  1847.       BEGIN
  1848.         tcp_buffer_pointer := tcp_response.data_buffer ;
  1849.         tcp_buffer_count := 
  1850.          tcp_buffer_pointer.telnet_ptr - tcp_buffer_pointer.tcp_ptr ;
  1851.         ftp_buffer_offset := 0 ;
  1852.         ftp_buffer_pointer := tcp_buffer_pointer.telnet_ptr ;
  1853.         initialize_tcp_receive_queue(tcp_identifier) ;
  1854.         bytes_removed_from_tcp_buffer := 0 ;
  1855.       END prepare_buffer_for_processing ;
  1856.   
  1857.   
  1858.     BEGIN -- Get_a_data_buffer_from_tcp 
  1859.       LOOP
  1860. --dmt        my_debug_io.put_line("Get_a_data_buffer_from_tcp ") ;
  1861.         tcp_response.local_connection_name := tcp_identifier.connection_id ;
  1862.          --&MT Cycle ;
  1863.         with_ulp_communicate.Wait_for_tcp_message (Tcp_response) ;    -- Get response
  1864.         --&MT Cycle ;
  1865.         Output_tcp_response(Tcp_response) ;
  1866.         CASE Tcp_response.message_number IS   -- Test response
  1867.           WHEN -1 => -- no user action
  1868.             NULL ;
  1869.           WHEN 3 => -- Connection does not exist
  1870.             Tcp_identifier.connection_status := Closed ;
  1871.             RAISE Tcp_connection_closed ;
  1872.           WHEN 6 => -- Connection closing
  1873.             Close_tcp_data_link(Tcp_identifier) ;
  1874.           WHEN 10 | 19 => -- Buffer avaliable
  1875.             Prepare_buffer_for_processing ;
  1876.             --D dump_the_received_buffer_to_the_screen ; --&MT debug
  1877.             EXIT ;
  1878.           WHEN 24 | 8 | 16 => -- time out, abort, aborted on
  1879.             Tcp_identifier.connection_status := Closed ;
  1880.             RAISE Tcp_connection_closed ;
  1881.           WHEN OTHERS =>
  1882.             RAISE Tcp_request_failed ;
  1883.         END CASE ;
  1884.       END LOOP ;
  1885.     EXCEPTION
  1886.       WHEN Tcp_connection_closed => 
  1887.         My_debug_io.PUT_LINE("  Get_a_tcp_data_buffer failed ") ;
  1888.         My_debug_io.PUT_LINE("  Raising Tcp_connection_closed ") ;
  1889.         RAISE Tcp_connection_closed ;
  1890.       WHEN OTHERS => 
  1891.         My_debug_io.PUT_LINE("  Get_a_tcp_data_buffer failed ") ;
  1892.         My_debug_io.PUT_LINE("  Raising tcp_request_failed ") ;
  1893.         RAISE Tcp_request_failed ;
  1894.     END Get_a_data_buffer_from_tcp ;
  1895.  
  1896.   BEGIN -- get_byte_from_tcp_buffer
  1897.     IF Tcp_buffer_pointer = NULL THEN
  1898.       get_a_data_buffer_from_tcp ;
  1899.     ELSIF Bytes_removed_from_tcp_buffer >= Tcp_buffer_count THEN
  1900.       buffer_data.Buffree (Tcp_buffer_pointer, Type_of_buffer) ;
  1901.       get_a_data_buffer_from_tcp ;
  1902.     END IF ;
  1903.     Tcp_data := Tcp_buffer_pointer.byte
  1904.      (Ftp_buffer_pointer - Ftp_buffer_offset) ;
  1905.  
  1906. --&MT debug
  1907. --dmt    TEMP_Tcp_data := Tcp_buffer_pointer.byte
  1908. --dmt     (Ftp_buffer_pointer - Ftp_buffer_offset) ;
  1909. --dmt
  1910. --dmt    IF TEMP_tcp_data IN 32..126 THEN
  1911. --dmt      my_debug_io.put("get_byte_from_tcp_buffer.tcp_data=") ;
  1912. --dmt      TEXT_io.put(CHARACTER'VAL(integer(TEMP_tcp_data))) ;
  1913. --dmt      TEXT_IO.NEW_LINE ;
  1914. --dmt    ELSE 
  1915. --dmt      my_debug_io.put("get_byte_from_tcp_buffer.tcp_data NUMBER =") ;
  1916. --dmt      my_debug_io.put_line(bit_count_16_type(TEMP_tcp_data)) ;
  1917. --dmt    END IF ;
  1918. --&MT DEBUG
  1919.  
  1920.     Ftp_buffer_offset := Ftp_buffer_offset + 1 ;
  1921.     Bytes_removed_from_tcp_buffer := Bytes_removed_from_tcp_buffer + 1 ;
  1922.   EXCEPTION
  1923.     WHEN Tcp_connection_closed => 
  1924.       My_debug_io.PUT_LINE("  Get_byte_from_tcp_buffer failed ") ;
  1925.       My_debug_io.PUT_LINE("  Raising No_more_tcp_data ") ;
  1926.       RAISE No_more_tcp_data ;
  1927.     WHEN Tcp_request_failed    => 
  1928.       My_debug_io.PUT_LINE("  Get_byte_from_tcp_buffer failed ") ;
  1929.       My_debug_io.PUT_LINE("  Raising Tcp_request_failed ") ;
  1930.       RAISE Tcp_request_failed ;
  1931.     WHEN OTHERS =>
  1932.       My_debug_io.PUT_LINE("  Get_byte_from_tcp_buffer failed ") ;
  1933.       My_debug_io.PUT_LINE("  Raising Tcp_buffer_access_error ") ;
  1934.       RAISE Tcp_buffer_access_error ;
  1935.   END Get_byte_from_tcp_buffer  ;
  1936.  
  1937.  
  1938.  
  1939.   PROCEDURE Get_byte_from_tcp_buffer 
  1940.             ------------------------
  1941.    (TCP_IDENTIFIER : IN OUT TCP_IDENTIFIER_SPEC  ;
  1942.     TCP_DATA       :    OUT CHARACTER) IS
  1943.  
  1944.     Temp_tcp_data : BIT_COUNT_8_TYPE ;
  1945.  
  1946.   BEGIN
  1947.     Get_byte_from_tcp_buffer (Tcp_identifier, Temp_tcp_data) ;
  1948.     Tcp_data := Byte_to_character (bit_count_16_type(Temp_tcp_data)) ;
  1949.   EXCEPTION
  1950.     WHEN Tcp_connection_closed => 
  1951.       My_debug_io.PUT_LINE("  Get_byte_from_tcp_buffer ;failed ") ;
  1952.       My_debug_io.PUT_LINE("  Raising No_more_tcp_data ; ") ;
  1953.       RAISE No_more_tcp_data ;
  1954.     WHEN Tcp_request_failed    => 
  1955.       My_debug_io.PUT_LINE("  Get_byte_from_tcp_buffer ;failed ") ;
  1956.       My_debug_io.PUT_LINE("  Raising Tcp_request_failed ; ") ;
  1957.       RAISE Tcp_request_failed ;
  1958.     WHEN OTHERS =>
  1959.       My_debug_io.PUT_LINE("  Get_byte_from_tcp_buffer ;failed ") ;
  1960.       My_debug_io.PUT_LINE("  Raising Tcp_buffer_access_error ; ") ;
  1961.       RAISE Tcp_buffer_access_error ;
  1962.   END Get_byte_from_tcp_buffer ;
  1963.  
  1964.  
  1965.   PROCEDURE Listen_on_current_tcp_port_for_an_active_open
  1966.             ---------------------------------------------
  1967.    (Tcp_identifier : IN OUT Tcp_identifier_spec) IS
  1968.  
  1969.     Tcp_response : WITH_ULP_COMMUNICATE.USER_MESSAGE ;
  1970.  
  1971.   BEGIN
  1972.     My_debug_io.PUT_LINE ("  Waiting for an active open ") ;
  1973.     set_the_port_up_to_allow_for_another_transfer(tcp_identifier) ;
  1974.     --&MT Cycle ;
  1975.     tcp_response.local_connection_name := tcp_identifier.connection_id ;
  1976.     LOOP
  1977.       my_debug_io.put_line("listen for active") ;
  1978.       with_ulp_communicate.Wait_for_tcp_message (Tcp_response) ;    -- Get response
  1979.       --&MT Cycle ;
  1980.       Output_tcp_response(Tcp_response) ;
  1981.       CASE Tcp_response.message_number IS   -- Test response
  1982.         WHEN -1 | 0 => -- no user action ; keep on waiting
  1983.           NULL ;
  1984.         WHEN 23 => -- Connection exists
  1985.           My_debug_io.PUT_LINE ("  Active open received ") ;
  1986.           Tcp_identifier.connection_status := open ;
  1987.           Initialize_tcp_receive_queue (Tcp_identifier) ;
  1988.           EXIT ; -- Get out of loop!
  1989.         WHEN OTHERS =>
  1990.           RAISE Tcp_request_failed ;
  1991.       END CASE ;
  1992.     END LOOP ;
  1993.   END Listen_on_current_tcp_port_for_an_active_open ;
  1994.  
  1995.  
  1996.   PROCEDURE Push_tcp_buffer
  1997.             ---------------
  1998.    (Tcp_identifier : IN OUT Tcp_identifier_spec) IS
  1999.  
  2000.     Send_parameters : with_ulp_communicate.Send_params  ;
  2001.     Tcp_request     : with_ulp_communicate.MESSAGE ;
  2002.     Tcp_response    : with_ulp_communicate.User_message ;
  2003.     request_ok      : BOOLEAN  ;
  2004.  
  2005.     PROCEDURE Dump_the_buffer_to_be_pushed_to_the_screen IS
  2006.               ------------------------------------------
  2007.       Temp_byte : BIT_COUNT_8_TYPE  ;
  2008.  
  2009.     BEGIN
  2010.       My_debug_io.put_Line (" Output the push buffer to the screen ") ;
  2011.       FOR Offset IN 0 .. (Tcp_buffer_count - 1) LOOP
  2012.         My_debug_io.put (" Character location = ") ;
  2013.         My_debug_io.put_line (Ftp_buffer_pointer - Offset) ;
  2014.         My_debug_io.put_line (" Assigning byte ") ;
  2015.         Temp_byte := Tcp_buffer_pointer.byte(Ftp_buffer_pointer - Offset) ;
  2016.         My_debug_io.put (" Next byte is ") ;
  2017.         IF temp_byte in 0..127 THEN
  2018.           MY_UTILITIES.OUTPUT_BYTE_TO_SCREEN(Temp_byte ) ;
  2019.           TEXT_IO.NEW_LINE ;
  2020.         ELSE
  2021.           my_debug_io.put_line("unprintable") ;
  2022.         END IF ;
  2023.       END LOOP ;
  2024.       My_debug_io.put_Line (" Buffer has been output to the screen ") ;
  2025.     END Dump_the_buffer_to_be_pushed_to_the_screen  ;
  2026.  
  2027.  
  2028.   BEGIN -- push_tcp_buffer
  2029. --dmt    my_debug_io.put_line("pushing tcp buffer") ;
  2030.  
  2031.     Tcp_buffer_count := Bytes_loaded_into_buffer ;
  2032.     Tcp_buffer_pointer.Telnet_ptr := 
  2033.      Tcp_buffer_pointer.Telnet_ptr - Tcp_buffer_count ;
  2034.     Tcp_buffer_pointer.Tcp_ptr := Tcp_buffer_pointer.Telnet_ptr - 1 ;
  2035.  
  2036. --D    my_debug_io.put("tcp_buffer_count=") ;
  2037. --    my_debug_io.put_line(tcp_buffer_count) ;
  2038. --    my_debug_io.put_line("telnet_pionter=") ;
  2039. --    my_debug_io.put_line(Tcp_buffer_pointer.Telnet_ptr ) ;
  2040. --    my_debug_io.put_line("tcp_ptr=") ;
  2041. --    my_debug_io.put_line(Tcp_buffer_pointer.Tcp_ptr ) ;
  2042.     --D Dump_the_buffer_to_be_pushed_to_the_screen ; --&MT debug
  2043.  
  2044.        
  2045.     Send_parameters := (Tcp_identifier.connection_id, Tcp_buffer_pointer,
  2046.      Tcp_buffer_count, Push_flag_value, Urgent_flag_value, Timeout_value) ;
  2047.     Tcp_request  := (with_ulp_communicate.Send, Send_parameters) ;
  2048.     --&MT Cycle ;
  2049.     with_ulp_communicate.message_for_tcp (Tcp_request, request_ok) ;
  2050.     --&MT Cycle ;
  2051.     Tcp_buffer_pointer := NULL ;
  2052.     --&MT     Give_tcp_time_to_deliver ; -- this looped 50,000 times
  2053.   EXCEPTION
  2054.     WHEN OTHERS => 
  2055.       My_debug_io.PUT_LINE ("  Push failed ") ;
  2056.       My_debug_io.put_line ("  Raising tcp_request_failed ") ;
  2057.       RAISE Tcp_request_failed ;
  2058.   END Push_tcp_buffer ;
  2059.  
  2060.  
  2061.   PROCEDURE abort_tcp (tcp_identifier : IN OUT tcp_identifier_spec) IS
  2062.             --------
  2063.            
  2064.     -----------------------------------------------------------------
  2065.     --
  2066.     -- This procedure is used to abort a tcp data transfer and close
  2067.     -- a tcp connection.
  2068.     -----------------------------------------------------------------
  2069.  
  2070.     Abort_parameters : with_ulp_communicate.abort_close_params ;
  2071.     Tcp_request      : with_ulp_communicate.MESSAGE :=
  2072.      (with_ulp_communicate.Abor_t, Abort_parameters) ;
  2073.     Tcp_response     : with_ulp_communicate.User_message ;
  2074.     request_ok       : BOOLEAN ;
  2075.  
  2076.     PROCEDURE Get_tcp_response_to_abort_request IS
  2077.     BEGIN
  2078.       tcp_response.local_connection_name := tcp_identifier.connection_id ;
  2079.       LOOP
  2080.         --&MT cycle
  2081.         with_ulp_communicate.Wait_for_tcp_message (Tcp_response) ;
  2082.         --&MT cycle
  2083.         Output_tcp_response(Tcp_response) ;
  2084.         CASE Tcp_response.message_number IS
  2085.           WHEN -1 | 0 => 
  2086.             NULL ;
  2087.           WHEN 8 =>
  2088.             Tcp_identifier.connection_status := CLOSED ;
  2089.             RAISE Tcp_aborted ;
  2090.           WHEN OTHERS =>
  2091.             RAISE Tcp_request_failed ;
  2092.         END CASE ;
  2093.       END LOOP ;
  2094.     END Get_tcp_response_to_abort_request ;
  2095.     
  2096.   BEGIN -- abort_tcp
  2097.     Abort_parameters.local_connection_name := Tcp_identifier.connection_id ;
  2098.     with_ulp_communicate.message_for_tcp (Tcp_request, request_ok) ;
  2099.     Get_tcp_response_to_abort_request ;
  2100.   EXCEPTION
  2101.     WHEN OTHERS =>
  2102.       My_debug_io.PUT_LINE ("  ABORT_TCP FAILED ") ;
  2103.       My_debug_io.PUT_LINE ("  raising tcp_request_failed ") ;
  2104.       RAISE Tcp_request_failed ;
  2105.   END abort_tcp ;
  2106.  
  2107.  
  2108. BEGIN -- ftp_tcp 
  2109.     NULL ;
  2110. EXCEPTION
  2111.     WHEN OTHERS =>
  2112.         My_debug_io.PUT_LINE ("  FTP_TCP FAILED ") ;
  2113.         RAISE Tcp_request_failed ;
  2114. END FTP_TCP ;
  2115.  
  2116. --::::::::::::::
  2117. --ftptelnet_.ada
  2118. --::::::::::::::
  2119. -----------------------------------------------------------------------
  2120. --
  2121. --         DoD Protocols    NA-00005-200       80-01105-100(-)
  2122. --         E-Systems, Inc.  August 07, 1985
  2123. --
  2124. --         FTPTELNET_.ADA       Author : Mark Volpe
  2125. --
  2126. -----------------------------------------------------------------------
  2127. -- FILE : FTPTELNET               AUTHOR : MARK VOLPE
  2128. --                                       : Mike Thomas (post 7-8-85 mods)
  2129. -- 5/15/85    3:10 PM : REVISED FOR USE WITH DEC COMPILER 
  2130. --                      OLD CODE (TELESOFT) MARKED WITH --&MT  
  2131.  
  2132. -- 5/29/85   12:36 PM : REVISED FOR USE WITH TELESOFT COMPILER
  2133. --                      OLD CODE (DEC) MARKED WITH --&MT
  2134.  
  2135. -- 5/30/85    8:16 AM : REVISED FOR USE WITH THE DEC COMPILER
  2136. --                      OLD CODE (TELESOFT) MARKED WITH --&MT
  2137. --  7/9/85    5:38 PM : mods for new tcp interface and dec version
  2138.  
  2139. --&MT THE FOLLOWING LINE SHOULD BE DELETED WHEN USING DEC ADA :
  2140. --&MT PRAGMA SOURCE_INFO ( ON ) ;
  2141.  
  2142. WITH TEXT_IO ;
  2143. WITH SYSTEM ;
  2144. USE  SYSTEM ;
  2145. --&MT THE FOLLOWING LINE SHOULD BE DELETED WHEN USING DEC ADA :
  2146. --&MT WITH ASCII ;
  2147.  
  2148. WITH Command_types ;
  2149. WITH Ftp_types ;
  2150.  
  2151. PACKAGE FTP_TELNET IS
  2152.    ----------------------------------------------------------------------
  2153.    --
  2154.    -- This package contains the necessary procedures to interface to 
  2155.    -- a particular telnet implementation.  All these procedures are 
  2156.    -- implementation dependent.
  2157.    --
  2158.    ----------------------------------------------------------------------
  2159.  
  2160. --&MT SUBTYPE BIT_COUNT_32_TYPE IS LONG_INTEGER ;
  2161.       SUBTYPE BIT_COUNT_32_TYPE IS INTEGER ;
  2162.  
  2163. --&MT SUBTYPE BIT_COUNT_16_TYPE IS INTEGER ;
  2164.       SUBTYPE BIT_COUNT_16_TYPE IS SHORT_INTEGER ;
  2165.  
  2166. --&MT THE FOLLOWING LINES SHOULD BE DELETED WHEN USING TELESOFT
  2167.     PACKAGE LONG_INT IS NEW TEXT_IO.INTEGER_IO(BIT_COUNT_32_TYPE) ;
  2168.     PACKAGE INT_IO IS NEW TEXT_IO.INTEGER_IO(BIT_COUNT_16_TYPE) ;
  2169.  
  2170.     TYPE TELNET_STATUS_SPEC IS PRIVATE ;
  2171.  
  2172.     FUNCTION TELNET_FAILED
  2173.                 ( STATUS : IN TELNET_STATUS_SPEC ) RETURN BOOLEAN  ;
  2174.     FUNCTION TELNET_WAS_SUCCESSFUL
  2175.                 ( STATUS : IN TELNET_STATUS_SPEC ) RETURN BOOLEAN  ;
  2176.  
  2177.     PROCEDURE Wait_for_telnet_close( STATUS     : OUT TELNET_STATUS_SPEC) ;
  2178.     PROCEDURE Wait_for_telnet_open( STATUS     : OUT TELNET_STATUS_SPEC) ;
  2179.  
  2180.     PROCEDURE LOAD_TELNET_TRANSMISSION_BUFFER
  2181.            ( STATUS     : OUT TELNET_STATUS_SPEC ;
  2182.               INPUT_LENGTH    : IN BIT_COUNT_32_TYPE ;
  2183.              INPUT_STRING     : IN COMMAND_TYPES.COMMAND_STRING_SPEC  ;
  2184.               ARGUMENT    : IN FTP_TYPES.ARGUMENT_LIST ) ;
  2185.            -- 
  2186.            -- This procedure is responsible for giving data to telnet
  2187.            -- for transmission to either a server- or user- pi.
  2188.            --
  2189.  
  2190.     PROCEDURE GET_DATA_FROM_TELNET_BUFFER
  2191.                ( STATUS : OUT TELNET_STATUS_SPEC ;
  2192.                  TELNET_DATA : OUT COMMAND_TYPES.COMMAND_STRING_SPEC) ;
  2193.            -- 
  2194.            -- This procedure is responsible for getting data from telnet 
  2195.            -- for either a user- or server- pi.
  2196.            -- 
  2197.  
  2198.     PROCEDURE OPEN_TELNET_LINK 
  2199.         ( STATUS : OUT TELNET_STATUS_SPEC ;
  2200.           ARGUMENT : IN FTP_TYPES.ARGUMENT_LIST ) ;
  2201.             --
  2202.             -- This procedure requests that a telnet connection be 
  2203.             -- established between the user- and server- pi.
  2204.             --
  2205.  
  2206.     PROCEDURE CLOSE_TELNET_LINK 
  2207.         ( STATUS : OUT TELNET_STATUS_SPEC ;
  2208.           ARGUMENT : IN FTP_TYPES.ARGUMENT_LIST ) ;
  2209.             --
  2210.             -- This procedure is used by the server system to close a 
  2211.             -- telnet link.  It is initiated at the request of the user
  2212.             -- system. 
  2213.             -- 
  2214.     PRIVATE
  2215.        TYPE TELNET_STATUS_SPEC IS (    TELNET_LINK_FAILED,
  2216.                         TELNET_LINK_SUCCESSFUL ) ;
  2217. END FTP_TELNET  ;
  2218.  
  2219. --::::::::::::::
  2220. --ftptelnet.ada
  2221. --::::::::::::::
  2222. -----------------------------------------------------------------------
  2223. --
  2224. --         DoD Protocols    NA-00005-200       80-01106-100(-)
  2225. --         E-Systems, Inc.  August 07, 1985
  2226. --
  2227. --         FTPTELNET.ADA       Author : Mark Volpe
  2228. --
  2229. -----------------------------------------------------------------------
  2230. -- FILE : FTPTELNET               AUTHOR : MARK VOLPE
  2231. --                                       : Mike Thomas (post 7/8/85 mods)
  2232.  
  2233. -- 5/15/85     3:10 PM : REVISED FOR USE WITH DEC COMPILER 
  2234. --                      OLD CODE (TELESOFT) MARKED WITH --&MT  
  2235.  
  2236. -- 5/29/85    12:36 PM : REVISED FOR USE WITH TELESOFT COMPILER
  2237. --                       OLD CODE (DEC) MARKED WITH --&MT
  2238.  
  2239. -- 5/30/85     8:21 AM : REVISED FOR USE WITH THE DEC COMPILER
  2240. --                       OLD CODE (TELESOFT) MARKED WITH --&MT
  2241. --  7/9/85     5:44 PM : mods for new tcp interface and dec 
  2242. -- 7/12/85     5:18 PM : add dec_tn_tasks.tn.go after sending to telnet
  2243. -- 7/17/85     2:31 PM : make option responce test for either string
  2244. --             6:09 PM : don't look for more characters after "connection open"
  2245. -- 7/18/85    11:57 AM : on active open too ; option responce has lfcr at end
  2246.  
  2247. WITH dec_tn_tasks ; --&MT
  2248. WITH user_data ;
  2249. WITH telnet_package ;
  2250. WITH virtual_terminal ;
  2251. WITH my_debug_io ;
  2252. WITH my_utilities ;
  2253.  
  2254. PACKAGE BODY FTP_TELNET IS
  2255.  
  2256. --&MT SUBTYPE BIT_COUNT_8_TYPE IS SYSTEM.BYTE;
  2257.       SUBTYPE BIT_COUNT_8_TYPE IS SYSTEM.UNSIGNED_BYTE;
  2258.  
  2259. --&MT THE FOLLOWING LINE SHOULD BE DELETED WHEN USING TELESOFT
  2260.    PACKAGE SYSTEM_BYTE IS NEW TEXT_IO.INTEGER_IO(BIT_COUNT_8_TYPE);
  2261.  
  2262.    Next_telnet_character : BIT_COUNT_8_TYPE;
  2263.    Telnet_is_idle        : BOOLEAN := FALSE;
  2264.    Telnet_index          : BIT_COUNT_16_TYPE := 0;
  2265.    User_control_block    : Telnet_package.User_info_type;
  2266.  
  2267. --&MT  PROCEDURE Cycle IS  --- may need this for wicat
  2268. --&MT     BEGIN
  2269. --&MT         -- My_debug_io.PUT_LINE ("  Cycling ");
  2270. --&MT FOR Index IN 1..1 LOOP
  2271. --&MT         Tcp_controller;
  2272. --&MT         Ip_controller;
  2273. --&MT END LOOP;
  2274. --&MT       null;
  2275. --&MT     END Cycle;
  2276. --&MT
  2277. --&MT   PROCEDURE Cycle_telnet IS -- may need this for wicat
  2278. --&MT     BEGIN
  2279. --&MT         -- DEBUG_IO.PUT_LINE (" In cycle telnet");
  2280. --&MT         Telnet_is_idle  := FALSE;
  2281. --&MT         WHILE NOT Telnet_is_idle LOOP
  2282. --&MT             -- MY_DEBUG_IO.PUT_LINE (" Cycling telnet ");
  2283. --&MT             Telnet_package.telnet ( User_control_block, Telnet_is_idle  );
  2284. --&MT             -- Dump_all( User_control_block );
  2285. --&MT     FOR Index_2 IN 1..4 LOOP
  2286. --&MT                 -- MY_DEBUG_IO.PUT_LINE (" Cycling TCP ");
  2287. --&MT         Tcp_controller;
  2288. --&MT         Ip_controller;
  2289. --&MT     END LOOP;
  2290. --&MT         END LOOP;
  2291. --&MT         -- DEBUG_IO.PUT_LINE (" Exiting  cycle telnet");
  2292. --&MT     END Cycle_telnet;
  2293.  
  2294.   PROCEDURE Output_next_telnet_character IS
  2295.             ----------------------------
  2296.     BEGIN
  2297.         MY_DEBUG_IO.PUT (" Next_telnet_character = ");
  2298.         TEXT_IO.PUT(my_utilities.Char(BIT_COUNT_16_TYPE(Next_telnet_character)));
  2299.         TEXT_IO.NEW_LINE;
  2300.     END Output_next_telnet_character;
  2301.  
  2302.  
  2303.   PROCEDURE Wait_for_telnet_to_receive_a_character IS
  2304.             --------------------------------------
  2305.     BEGIN
  2306.         -- Text_io.new_line;
  2307.         LOOP
  2308.             -- My_debug_io.put_line (" Waiting to get a character");
  2309.             IF virtual_terminal.There_are_characters_in_printer_buffer(1) THEN
  2310.                 -- MY_DEBUG_IO.PUT_LINE (" Character received");
  2311.                 EXIT;
  2312.             ELSE
  2313.                 --&MT Cycle_telnet;
  2314.               NULL ; --&MT
  2315.             END IF;
  2316.         END LOOP;
  2317.     END Wait_for_telnet_to_receive_a_character;
  2318.  
  2319.  
  2320.   PROCEDURE Process_echoed_data IS
  2321.            --------------------
  2322.     BEGIN
  2323.         -- MY_DEBUG_IO.PUT_LINE (" Process local echo");
  2324.         LOOP
  2325.             Wait_for_telnet_to_receive_a_character;
  2326.             virtual_terminal.Get_next_character_from_telnet(1, Next_telnet_character );
  2327.             -- my_utilities.Output_byte_to_screen ( Next_telnet_character );
  2328.             IF BIT_COUNT_16_TYPE(Next_telnet_character) =
  2329.              BIT_COUNT_16_TYPE(my_utilities.Byte( ASCII.CR )) THEN
  2330.                 -- MY_DEBUG_IO.PUT_LINE (" <CR> after echoed data found");
  2331.                 EXIT;
  2332.             END IF;
  2333.         END LOOP;
  2334.         -- TEXT_IO.NEW_LINE;
  2335.     END Process_echoed_data;
  2336.  
  2337.  
  2338.   PROCEDURE Verify_suppress_telnet_go_ahead_request 
  2339.             ---------------------------------------
  2340.     (Status : OUT Telnet_status_spec) IS
  2341.  
  2342.     --&MT str_length_1 : CONSTANT bit_count_16_type := 44 ;
  2343.     --&MT str_length_2 : CONSTANT bit_count_32_type := 45 ;
  2344.     str_length_1 : CONSTANT bit_count_32_type := 44 ;
  2345.     str_length_2 : CONSTANT bit_count_32_type := 45 ;
  2346.     eol : STRING(1..2) ;
  2347.  
  2348.     Verification_string_1 : STRING(1..str_length_1) ;
  2349.     Verification_string_2 : STRING(1..str_length_2) ;
  2350.      
  2351.     string_1_found : BOOLEAN := FALSE ;
  2352.     string_2_found : BOOLEAN := FALSE ;
  2353.  
  2354.     --&MT string_length : bit_count_16_type ;
  2355.     string_length : bit_count_32_type ;
  2356.     tn_input_string : STRING (1..80) ;
  2357.     char : CHARACTER ;
  2358.  
  2359.   BEGIN
  2360.     eol(1) := ASCII.LF ;
  2361.     eol(2) := ASCII.CR ;
  2362.     Verification_string_1 := 
  2363.      "$@$ local suppress_ga option in effect $@$" & eol ;
  2364.     Verification_string_2 :=
  2365.      "$@$ remote suppress_ga option in effect $@$" & eol ;
  2366.  
  2367.     FOR index in 1..2 LOOP
  2368.       char := ASCII.NUL ;
  2369.       string_length := 0 ;
  2370.       WHILE char /= ASCII.CR LOOP
  2371.         Wait_for_telnet_to_receive_a_character ;
  2372.         virtual_terminal.Get_next_character_from_telnet(1, next_telnet_character) ;
  2373.         string_length := string_length + 1 ;
  2374.         char := CHARACTER'VAL(INTEGER(next_telnet_character)) ;
  2375.         tn_input_string(string_length) := char ;
  2376.       END LOOP ;
  2377.       IF string_length = str_length_1 AND THEN
  2378.        tn_input_string(1..string_length) = 
  2379.        verification_string_1(1..str_length_1) THEN
  2380.         string_1_found := TRUE ;
  2381.       ELSIF string_length = str_length_2 AND THEN
  2382.        tn_input_string(1..string_length) = 
  2383.        verification_string_2(1..str_length_2) THEN
  2384.         string_2_found := TRUE ;
  2385.       END IF ;
  2386.     END LOOP ;
  2387. --d    IF string_1_found AND string_2_found THEN
  2388. --      status := Telnet_link_successful ;
  2389. --      my_debug_io.put_line("both strings found") ;
  2390. --    ELSE
  2391. --      status := Telnet_link_failed ;
  2392. --      my_debug_io.put_line("both strings NOT found") ;
  2393. --d    END IF ;  
  2394.   END Verify_suppress_telnet_go_ahead_request;
  2395.  
  2396.  
  2397.   PROCEDURE Wait_for_telnet_open ( STATUS : OUT TELNET_STATUS_SPEC ) IS
  2398.             --------------------
  2399.         Open_verification     : CONSTANT STRING (1..15) := "connection open";
  2400.         Temp_Status : Telnet_Status_Spec;
  2401.     BEGIN
  2402.         -- My_debug_io.put_line (" Waiting for a telnet open");
  2403.  
  2404.         Temp_Status := Telnet_link_successful;
  2405.  
  2406.         Telnet_package.telnet_request_to_do_option
  2407.                 ( User_data.suppress_ga, User_control_block);
  2408.         Telnet_package.telnet_request_remote_to_do_option
  2409.                 ( User_data.suppress_ga, User_control_block);
  2410.  
  2411.         FOR Index IN Open_verification'RANGE LOOP
  2412.             Wait_for_telnet_to_receive_a_character;
  2413.             virtual_terminal.Get_next_character_from_telnet ( 1, Next_telnet_character );
  2414.             IF BIT_COUNT_16_TYPE(Next_telnet_character) /= 
  2415.              BIT_COUNT_16_TYPE(my_utilities.Byte( Open_verification( Index ))) THEN
  2416.                 -- MY_DEBUG_IO.PUT (" Testing against ");
  2417.                 -- my_utilities.Output_byte_to_screen ( Byte ( Open_verification( Index ))); 
  2418.                 -- TEXT_IO.NEW_LINE;
  2419.                 MY_DEBUG_IO.PUT_LINE (" Bad verification of telnet open");
  2420.                 Temp_Status := Telnet_link_failed;
  2421.                 EXIT;
  2422.             END IF;
  2423.         END LOOP;
  2424.         IF Temp_Status = Telnet_link_successful THEN
  2425.             Wait_for_telnet_to_receive_a_character;
  2426.             virtual_terminal.Get_next_character_from_telnet ( 1, Next_telnet_character );
  2427.             -- Output_next_telnet_character ;
  2428.             IF BIT_COUNT_16_TYPE(Next_telnet_character) /= 
  2429.              BIT_COUNT_16_TYPE(my_utilities.Byte( ASCII.CR )) THEN
  2430.                 MY_DEBUG_IO.PUT_LINE (" Bad verification of telnet open");
  2431.                 Temp_Status := Telnet_link_failed;
  2432.             END IF;
  2433.         END IF;
  2434.         -- My_debug_io.put_line (" Finished waiting for telnet open");
  2435.         IF Temp_Status = Telnet_link_successful THEN
  2436.             -- My_debug_io.put_line (" Open was ok");
  2437.             Verify_suppress_telnet_go_ahead_request( Temp_Status );
  2438.         ELSE
  2439.             NULL; -- My_debug_io.put_line (" Open was bad");
  2440.         END IF;
  2441.       Status := Temp_Status; 
  2442.     END Wait_for_telnet_open;
  2443.  
  2444.  
  2445.   PROCEDURE Wait_for_telnet_close( STATUS : OUT TELNET_STATUS_SPEC ) IS
  2446.             ---------------------
  2447.             Close_verification : CONSTANT STRING(1..17) := "connection closed";
  2448.             Temp_Status : Telnet_Status_Spec;
  2449.     BEGIN
  2450.         -- My_debug_io.put_line (" Waiting for close");
  2451.         FOR Index IN Close_verification'RANGE LOOP
  2452.             Wait_for_telnet_to_receive_a_character;
  2453.             virtual_terminal.Get_next_character_from_telnet ( 1, Next_telnet_character );
  2454.             -- My_debug_io.put (" Good data is ");
  2455.             -- my_utilities.Output_byte_to_screen ( my_utilities.Byte( Close_verification( Index )));
  2456.             -- My_debug_io.put (" Received data is ");
  2457.             -- my_utilities.Output_byte_to_screen ( Next_telnet_character );
  2458.             -- TEXT_IO.NEW_LINE;
  2459.             IF BIT_COUNT_16_TYPE(Next_telnet_character) /= 
  2460.              BIT_COUNT_16_TYPE(my_utilities.Byte( Close_verification( Index ))) THEN
  2461.                 MY_DEBUG_IO.PUT_LINE (" Comparison failed");
  2462.                 Temp_Status := Telnet_link_failed;
  2463.                 EXIT;
  2464.             END IF;
  2465.         END LOOP;
  2466.         IF virtual_terminal.There_are_characters_in_printer_buffer(1) THEN 
  2467.             virtual_terminal.Get_next_character_from_telnet ( 1, Next_telnet_character );
  2468.             IF BIT_COUNT_16_TYPE(Next_telnet_character) /= 
  2469.              BIT_COUNT_16_TYPE(my_utilities.Byte( ASCII.CR )) THEN
  2470.                 Temp_Status := Telnet_link_failed;
  2471.             END IF;
  2472.         END IF;
  2473.         -- My_debug_io.put_line (" Checking for extra data");
  2474.         IF virtual_terminal.There_are_characters_in_printer_buffer(1) THEN 
  2475.             MY_DEBUG_IO.PUT_LINE (" Extra data found");
  2476.             Temp_Status := Telnet_link_failed;
  2477.         END IF;
  2478.         -- IF Temp_Status = Telnet_link_successful THEN
  2479.             -- My_debug_io.put_line (" Close was ok");
  2480.         -- ELSE
  2481.             -- My_debug_io.put_line (" Close was bad");
  2482.         -- END IF;
  2483.       Status := Temp_Status;
  2484.     END Wait_for_telnet_close;
  2485.  
  2486.  
  2487.   PROCEDURE Open_telnet_link 
  2488.             ----------------
  2489.         ( Status   : OUT Telnet_status_spec;
  2490.           Argument : IN  Ftp_types.argument_list ) IS
  2491.     -----------------------------------------------------------------
  2492.     --
  2493.     -- RFC 765 Spec References:
  2494.     --    p. 6: The user pi initiates the telnet connection.
  2495.     --    p. 21:The connection is established by a tcp connection
  2496.     --          from the user to the standard server port.
  2497.     --
  2498.     -- This procedure is responsible for opening a telnet connection
  2499.     -- to the server pi.
  2500.     --
  2501.     -----------------------------------------------------------------
  2502.         Open_verification     : CONSTANT STRING (1..15) := "connection open";
  2503.         Temp_Status : Telnet_Status_Spec;
  2504.  
  2505.     BEGIN -- telnet dependent
  2506.         -- My_debug_io.put_line (" Opening telnet connection");
  2507.         Temp_Status := Telnet_link_successful;
  2508.  
  2509.         Telnet_package.telnet_request_to_do_option
  2510.                 ( User_data.suppress_ga, User_control_block);
  2511.         Telnet_package.telnet_request_remote_to_do_option
  2512.                 ( User_data.suppress_ga, User_control_block);
  2513.  
  2514.         -- Do the open
  2515.         -- My_debug_io.put_line (" Loading the open request");
  2516.         -- My_debug_io.put( "@" );
  2517.         virtual_terminal.Send_char_to_telnet( 1, BIT_COUNT_8_TYPE(my_utilities.Byte( '@' ))); 
  2518.         -- My_debug_io.put( "O" );
  2519.         virtual_terminal.Send_char_to_telnet( 1, BIT_COUNT_8_TYPE(my_utilities.Byte( 'o' ))); 
  2520.         virtual_terminal.Send_char_to_telnet( 1, BIT_COUNT_8_TYPE(my_utilities.Byte( ' ' ))); 
  2521.         FOR Index IN Argument'RANGE LOOP
  2522.             -- My_debug_io.put (" Sending ");
  2523.             -- my_utilities.Output_byte_to_screen (my_utilities.Byte( Argument( Index )));
  2524.             -- My_debug_io.put_line (" to telnet");
  2525.             IF Argument( Index ) = Ftp_types.argument_list_unit'(ASCII.NUL) 
  2526.             THEN
  2527.                 -- My_debug_io.put_line( " End of command found " );
  2528.                 EXIT;
  2529.             ELSE
  2530.                 -- My_debug_io.put( "-" );
  2531.               virtual_terminal.Send_char_to_telnet( 1, BIT_COUNT_8_TYPE(my_utilities.Byte( Argument( Index ))));
  2532.                 -- My_debug_io.put( "-" );
  2533.             END IF;
  2534.         END LOOP;
  2535.         -- My_debug_io.put_line (" Sending a <CR> to telnet");
  2536.         virtual_terminal.Send_char_to_telnet
  2537.          (1, BIT_COUNT_8_TYPE(my_utilities.Byte(Ascii.cr))); 
  2538.         dec_tn_tasks.tn.go ; -- tell telnet it has input to process
  2539.         -- MY_DEBUG_IO.PUT_LINE (" Cycle telnet to get open out");
  2540.         --&MT Cycle_telnet;
  2541.  
  2542.         Process_echoed_data;
  2543.         --&MT Cycle_telnet;
  2544.  
  2545.         -- Verify the open
  2546.         -- My_debug_io.put_line(" Data has been sent. Waiting to verify the open");
  2547.         TEXT_IO.NEW_LINE;
  2548.         FOR Index IN Open_verification'RANGE LOOP
  2549.             Wait_for_telnet_to_receive_a_character;
  2550.             virtual_terminal.Get_next_character_from_telnet ( 1, Next_telnet_character );
  2551.             -- My_debug_io.put (" Correct data is ");
  2552.             -- my_utilities.Output_byte_to_screen( my_utilities.Byte( Open_verification( Index )));
  2553.             -- My_debug_io.put (" Received data was ");
  2554.             my_utilities.Output_byte_to_screen ( Next_telnet_character );
  2555.             -- TEXT_IO.NEW_LINE; 
  2556.  
  2557.             IF BIT_COUNT_16_TYPE(Next_telnet_character) /= 
  2558.              BIT_COUNT_16_TYPE(my_utilities.Byte( Open_verification( Index ))) THEN
  2559.                 My_debug_io.put_line (" Bad comparison ");
  2560.                 Temp_Status := Telnet_link_failed;
  2561.             END IF;
  2562.         END LOOP;
  2563.         TEXT_IO.NEW_LINE;
  2564.         IF Temp_Status = Telnet_link_successful THEN
  2565.             virtual_terminal.Get_next_character_from_telnet ( 1, Next_telnet_character );
  2566.             IF BIT_COUNT_16_TYPE(Next_telnet_character) /= 
  2567.              BIT_COUNT_16_TYPE(my_utilities.Byte( ASCII.CR )) THEN
  2568.                 My_debug_io.put_line (" <CR> not found");
  2569.                 Temp_Status := Telnet_link_failed;
  2570.             ELSE
  2571.                 NULL; -- My_debug_io.put_line (" <CR> was found");
  2572.             END IF;
  2573.  
  2574.         END IF;
  2575.         -- My_debug_io.put_line (" Done with open");
  2576.         IF Temp_Status = Telnet_link_successful THEN
  2577.             -- My_debug_io.put_line (" Open was ok");
  2578.             Verify_suppress_telnet_go_ahead_request( Temp_Status );
  2579.         ELSE
  2580.             NULL; -- My_debug_io.put_line (" Open was bad");
  2581.         END IF;
  2582.       STATUS := TEMP_STATUS ;
  2583.  
  2584.     EXCEPTION
  2585.         WHEN OTHERS =>
  2586.             MY_DEBUG_IO.PUT_LINE (" UNKNOWN ERROR IN OPEN_TELNET_LINK");
  2587.             RAISE;
  2588.     END OPEN_TELNET_LINK;
  2589.  
  2590.   PROCEDURE Close_telnet_link 
  2591.             -----------------
  2592.         ( Status   : OUT Telnet_status_spec;
  2593.           Argument : IN  Ftp_types.argument_list ) IS
  2594.     -----------------------------------------------------------------
  2595.     --
  2596.     -- RFC 765 Spec References:
  2597.     --    p. 7: It is the responsibility of the server to close
  2598.     --          the telnet connection at the request of the user.
  2599.     --
  2600.     -- This procedure closes the telnet connection between the user-
  2601.     -- and server-pi.
  2602.     --
  2603.     -----------------------------------------------------------------
  2604.             Close_request      : CONSTANT STRING(1..2)  := "@c";
  2605.             Close_verification : CONSTANT STRING(1..17) := "connection closed";
  2606.             Temp_Status : Telnet_Status_Spec;
  2607.     BEGIN
  2608.         Temp_Status := Telnet_link_successful;
  2609.  
  2610.         -- Send the close request
  2611.         -- My_debug_io.put_line (" Loading the close request");
  2612.         FOR Index IN Close_request'RANGE LOOP
  2613.           virtual_terminal.Send_char_to_telnet( 1, BIT_COUNT_8_TYPE(my_utilities.Byte( Close_request( Index ))));
  2614.         END LOOP;
  2615.         -- My_debug_io.put_line (" Sending a <CR> to telnet");
  2616.         virtual_terminal.Send_char_to_telnet
  2617.          (1, BIT_COUNT_8_TYPE(my_utilities.Byte(Ascii.cr))); 
  2618.         dec_tn_tasks.tn.go ; -- tell telnet it has input to process
  2619.         --&MT Cycle_telnet;
  2620.  
  2621.         -- Verify the close
  2622.         Process_echoed_data;
  2623.         -- My_debug_io.put_line (" Verifing the close request");
  2624.         FOR Index IN Close_verification'RANGE LOOP
  2625.             virtual_terminal.Get_next_character_from_telnet ( 1, Next_telnet_character );
  2626.             IF BIT_COUNT_16_TYPE(Next_telnet_character) /= 
  2627.              BIT_COUNT_16_TYPE(my_utilities.Byte( Close_verification( Index ))) THEN
  2628.                     My_debug_io.put_line (" Bad comparison during close");
  2629.                     Temp_Status := Telnet_link_failed;
  2630.             END IF;
  2631.         END LOOP;
  2632.         virtual_terminal.Get_next_character_from_telnet ( 1, Next_telnet_character );
  2633.         IF BIT_COUNT_16_TYPE(Next_telnet_character) /= 
  2634.          BIT_COUNT_16_TYPE(my_utilities.Byte( ASCII.CR )) THEN
  2635.             Temp_Status := Telnet_link_failed;
  2636.         END IF;
  2637.  
  2638.         -- Test for dangling data
  2639.         -- My_debug_io.put_line (" Checking for extra data");
  2640.         IF virtual_terminal.There_are_characters_in_printer_buffer(1) THEN 
  2641.             Temp_Status := Telnet_link_failed;
  2642.         END IF;
  2643.         -- My_debug_io.put_line (" Done with close request");
  2644.         -- IF Temp_Status = Telnet_link_successful THEN
  2645.             -- My_debug_io.put_line (" Close was ok");
  2646.         -- ELSE
  2647.             -- My_debug_io.put_line (" Close was bad");
  2648.         -- END IF;
  2649.       Status := Temp_Status;
  2650.     EXCEPTION
  2651.         WHEN OTHERS => 
  2652.             My_debug_io.put_line (" Unknown error in Close_telnet_Link ");
  2653.             RAISE;
  2654.     END Close_telnet_link;
  2655.  
  2656.  
  2657.   PROCEDURE LOAD_TELNET_TRANSMISSION_BUFFER
  2658.             -------------------------------
  2659.            ( Status     : OUT Telnet_status_spec;
  2660.               Input_length    : IN  Bit_Count_32_Type;
  2661.              Input_string     : IN  Command_types.command_string_spec ;
  2662.               Argument    : IN  Ftp_types.argument_list ) IS
  2663.     ------------------------------------------------------------
  2664.     --
  2665.     -- This procedure transfers a string to the telnet queue
  2666.     -- returns to the caller when a null character is encountered.
  2667.     --
  2668.     -- It may be used by either the user or server ftp system
  2669.     -- because the respective telnets will know the location
  2670.     -- of their transmission buffers.
  2671.     --
  2672.     -- Input_string has the 4 letter command string;
  2673.     -- Argument has the required arguments for the command;
  2674.     -- Input_length has length of command at beginning of Input_string
  2675.     --
  2676.     ------------------------------------------------------------
  2677.         Temp_Status : Telnet_Status_Spec;
  2678.         Argument_index    : BIT_COUNT_16_TYPE    := Argument'FIRST;
  2679.  
  2680. --&MT   My_input_length : BIT_COUNT_16_TYPE     := BIT_COUNT_16_TYPE(Input_length) ;
  2681.     My_input_length    : BIT_COUNT_32_TYPE    := Input_length ;
  2682.  
  2683.        My_input_string : Command_types.command_string_spec := Input_string;
  2684.         -- My_input_string is a local data field for building the data stream
  2685.         -- to be send to telnet.
  2686.  
  2687.         PROCEDURE Load_argument_into_telnet_string_without_command IS
  2688.           BEGIN
  2689.             -- MY_DEBUG_IO.PUT_LINE (" Loading argument only");
  2690.             FOR Index IN My_input_string'RANGE LOOP
  2691.                 IF Ftp_types.end_of_argument( Argument( Argument_index )) THEN
  2692.                 My_input_string( Index ) := ' ';
  2693.                     -- Make last char a ' ' or get cmd dies!
  2694.                 EXIT;
  2695.                 ELSE -- Get the next byte from the argument
  2696.                     My_input_string( Index ) := Argument( Argument_index );
  2697.                     Argument_index := Argument_index + 1; --pnts to nxt chr
  2698.                 END IF;
  2699.             END LOOP;
  2700.           END Load_argument_into_telnet_string_without_command;
  2701.  
  2702.         PROCEDURE Load_argument_into_telnet_string_after_command IS
  2703.           BEGIN
  2704.             -- MY_DEBUG_IO.PUT_LINE (" Loading argument after command");
  2705.             -- Load a ' ' after the command and before the argument
  2706.             My_input_string( My_input_length + 1) := ' ';
  2707.             FOR Index IN ( My_input_length + 2)..Input_string'LAST LOOP
  2708.                 IF Ftp_types.end_of_argument( Argument( Argument_index )) THEN
  2709.                 My_input_string( Index ) := ' ';
  2710.                     -- Make last char a ' ' or get cmd dies!
  2711.                     EXIT;
  2712.                 ELSE
  2713.                     My_input_string( Index ) := Argument( Argument_index );
  2714.                     Argument_index := Argument_index + 1;
  2715.                 END IF;
  2716.             END LOOP;
  2717.           END Load_argument_into_telnet_string_after_command;
  2718.     BEGIN
  2719.         -- My_debug_io.put_line (" Setting up the telnet command string");
  2720.         Temp_Status := Telnet_link_successful;
  2721.         IF Input_length = 0 THEN -- No command was sent; just an argument!
  2722.             Load_argument_into_telnet_string_without_command;
  2723.         ELSE -- A command was in input_string; load after command !
  2724.             Load_argument_into_telnet_string_after_command;
  2725.         END IF;
  2726.         --
  2727.         -- Command and argument in My_input_string; so load the telnet buffer
  2728.         --
  2729.         -- TEXT_IO.NEW_LINE;
  2730.         -- FOR INDEX IN My_input_string'RANGE LOOP
  2731.             -- my_utilities.Output_byte_to_screen( my_utilities.Byte( My_input_string( Index ))); 
  2732.         -- END LOOP;
  2733.         -- TEXT_IO.NEW_LINE;
  2734.  
  2735.         -- My_debug_io.put_line (" Loading the telnet buffer");
  2736.         -- My_debug_io.put ("*");
  2737.         FOR Index IN My_input_string'RANGE LOOP
  2738.             IF My_input_string ( INDEX ) = ASCII.NUL THEN
  2739.                 -- Send the <CR> terminator
  2740.                 virtual_terminal.Send_char_to_telnet( 1, BIT_COUNT_8_TYPE(my_utilities.Byte( Ascii.cr ))); 
  2741.                 dec_tn_tasks.tn.go ; -- tell telnet it has input to process
  2742.                 EXIT;
  2743.             ELSE
  2744.               virtual_terminal.Send_char_to_telnet( 1, BIT_COUNT_8_TYPE(my_utilities.Byte( My_input_string( Index )))); 
  2745.                 -- my_utilities.Output_byte_to_screen( my_utilities.Byte( My_input_string( Index ))); 
  2746.             END IF;
  2747.         END LOOP;
  2748.         -- My_debug_io.put_line ("*");
  2749.         -- My_debug_io.put_line (" Done loading the buffer");
  2750.         --&MT Cycle_telnet;
  2751.         Process_echoed_data;
  2752.         --&MT Cycle_telnet;
  2753.       STATUS := TEMP_STATUS ;
  2754.     EXCEPTION
  2755.         WHEN OTHERS =>
  2756.             MY_DEBUG_IO.PUT_LINE (" Unknown error in Load_telnet_xmit_buffer");
  2757.             RAISE;
  2758.     END LOAD_TELNET_TRANSMISSION_BUFFER;
  2759.  
  2760.  
  2761. PROCEDURE GET_DATA_FROM_TELNET_BUFFER
  2762.           ---------------------------
  2763.     ( STATUS : OUT TELNET_STATUS_SPEC;
  2764.       TELNET_DATA : OUT COMMAND_TYPES.COMMAND_STRING_SPEC )IS
  2765.    -----------------------------------------------------------------
  2766.    --
  2767.    -- This procedure gets telnet data from telnet,
  2768.    -- performs any required transformations, and then passes it back
  2769.    -- as a fixed length string; null padding if necessary.
  2770.    --
  2771.    -----------------------------------------------------------------
  2772.   Temp_Status : Telnet_Status_Spec;
  2773.  
  2774.   BEGIN
  2775.     -- My_debug_io.put_line (" Getting data from telnet buffer");
  2776.     -- My_debug_io.put ("*");
  2777.     Temp_Status := Telnet_link_successful;
  2778.     FOR Index IN Telnet_data'RANGE LOOP
  2779.         Wait_for_telnet_to_receive_a_character;
  2780.         virtual_terminal.Get_next_character_from_telnet( 1, Next_telnet_character );
  2781.         IF BIT_COUNT_16_TYPE(next_telnet_character) = 
  2782.          BIT_COUNT_16_TYPE(my_utilities.Byte( ASCII.CR )) THEN
  2783.             -- MY_DEBUG_IO.PUT_LINE (" <CR> found");
  2784.             Telnet_data( Index ) := ' ';
  2785.             EXIT;
  2786.         ELSE
  2787.             -- MY_DEBUG_IO.PUT_LINE (" Loading byte into telnet data");
  2788.             Telnet_data( Index ) := 
  2789.              my_utilities.Char( BIT_COUNT_16_TYPE(Next_telnet_character ));
  2790.         END IF;
  2791.         -- text_io.new_line;
  2792.         -- my_utilities.Output_byte_to_screen( my_utilities.Byte( Telnet_data( Index )));
  2793.         -- MY_DEBUG_IO.PUT_LINE(" was the last character received");
  2794.     END LOOP;
  2795.     -- My_debug_io.put_line ("*");
  2796.     -- My_debug_io.put_line (" Done getting data");
  2797.     --&MT Cycle_telnet; -- Let the telnet go aheads get through
  2798.     Status := Temp_Status;
  2799.   EXCEPTION
  2800.         WHEN OTHERS =>
  2801.           My_debug_io.put_line(" Unknown error in Get_data_from_telnet_buffer");
  2802.           RAISE;
  2803.   END GET_DATA_FROM_TELNET_BUFFER;
  2804.  
  2805.  
  2806.    FUNCTION TELNET_FAILED
  2807.             -------------
  2808.             ( STATUS : IN TELNET_STATUS_SPEC ) RETURN BOOLEAN IS
  2809.     --
  2810.     --    This function is used to test the return status of a telnet command.
  2811.     --
  2812.     BEGIN
  2813.         IF STATUS = TELNET_LINK_FAILED THEN
  2814.             RETURN TRUE;
  2815.         ELSE
  2816.             RETURN FALSE;
  2817.         END IF;
  2818.     END TELNET_FAILED;
  2819.  
  2820.  
  2821.    FUNCTION TELNET_WAS_SUCCESSFUL
  2822.             ---------------------
  2823.             ( STATUS : IN TELNET_STATUS_SPEC ) RETURN BOOLEAN IS
  2824.     --
  2825.     --    This function is used to test the return status of a telnet command.
  2826.     --
  2827.     BEGIN
  2828.         IF STATUS = TELNET_LINK_SUCCESSFUL THEN
  2829.             RETURN TRUE;
  2830.         ELSE
  2831.             RETURN FALSE;
  2832.         END IF;
  2833.     END TELNET_WAS_SUCCESSFUL;
  2834. BEGIN
  2835.     NULL;
  2836. EXCEPTION
  2837.     WHEN OTHERS =>
  2838.         MY_DEBUG_IO.PUT_LINE(" Unknown exception in ftp_telnet");
  2839.         RAISE;
  2840. END FTP_TELNET ;
  2841. --::::::::::::::
  2842. --ftpcnvcmd_.ada
  2843. --::::::::::::::
  2844. -----------------------------------------------------------------------
  2845. --
  2846. --         DoD Protocols    NA-00005-200       80-01076-100(-)
  2847. --         E-Systems, Inc.  August 07, 1985
  2848. --
  2849. --         FTPCNVCMD_.ADA       Author : Mark Volpe
  2850. --
  2851. -----------------------------------------------------------------------
  2852. -- FILE : FTPCNVCMD               AUTHOR : MARK VOLPE
  2853.  
  2854. -- 5/16/85    9:50 AM : REVISED FOR USE WITH DEC COMPILER 
  2855. --                      OLD CODE (TELESOFT) MARKED WITH --&MT  
  2856.  
  2857. -- 5/30/85    8:27 AM : REVISED FOR USE WITH TELESOFT COMPILER
  2858. --                      OLD CODE (DEC) MARKED WITH --&MT
  2859.  
  2860. -- 5/30/85    9:55 AM : REVISED FOR USE WITH THE DEC COMPILER
  2861. --                      OLD CODE (TELESOFT) MARKED WITH --&MT
  2862.  
  2863. --&MT THE FOLLOWING LINE SHOULD BE DELETED WHEN USING DEC ADA :
  2864. --&MT PRAGMA SOURCE_INFO ( ON );
  2865.  
  2866. WITH TEXT_IO;
  2867. WITH Command_types, Ftp_types, Ftp_terminal_driver;
  2868.  
  2869. PACKAGE Ftp_convert_command IS
  2870.     TYPE Return_status_spec IS PRIVATE;
  2871.         --
  2872.         -- Specifies completion status of convert_command_to_enumerated_type
  2873.         --
  2874.     PROCEDURE Convert_command_to_enumerated_type
  2875.               ( STATUS   : OUT Return_status_spec ;
  2876.                 Word     : IN  Command_types.command_string_spec;
  2877.                 Command  : OUT Ftp_types.valid_command_spec ) ;
  2878.         --
  2879.         -- This procedure converts the input string to an enumerated type
  2880.         --
  2881.     FUNCTION Command_found ( Status : IN Return_status_spec ) RETURN BOOLEAN;
  2882.         --
  2883.         -- This function tests the completion status of 
  2884.         -- convert_command_to_enumerated_type
  2885.         --
  2886. PRIVATE
  2887.     TYPE Return_status_spec IS ( Conversion_found, No_conversion_found );
  2888. END Ftp_convert_command;
  2889.  
  2890. --::::::::::::::
  2891. --ftpcnvcmd.ada
  2892. --::::::::::::::
  2893. -----------------------------------------------------------------------
  2894. --
  2895. --         DoD Protocols    NA-00005-200       80-01077-100(-)
  2896. --         E-Systems, Inc.  August 07, 1985
  2897. --
  2898. --         FTPCNVCMD.ADA       Author : Mark Volpe
  2899. --
  2900. -----------------------------------------------------------------------
  2901. -- FILE : FTPCNVCMD               AUTHOR : MARK VOLPE
  2902.  
  2903. -- 5/16/85    9:50 AM : REVISED FOR USE WITH DEC COMPILER 
  2904. --                      OLD CODE (TELESOFT) MARKED WITH --&MT  
  2905.  
  2906. -- 5/30/85    8:27 AM : REVISED FOR USE WITH TELESOFT COMPILER
  2907. --                      OLD CODE (DEC) MARKED WITH --&MT
  2908.  
  2909. -- 5/30/85    10:04 AM : REVISED FOR USE WITH THE DEC COMPILER
  2910. --                       OLD CODE (TELESOFT) MARKED WITH --&MT
  2911.  
  2912. PACKAGE BODY Ftp_convert_command IS
  2913.  
  2914. --&MT SUBTYPE BIT_COUNT_16_TYPE IS INTEGER;
  2915.       SUBTYPE BIT_COUNT_16_TYPE IS SHORT_INTEGER;
  2916.  
  2917. --&MT THE FOLLOWING LINES SHOULD BE DELETED WHEN USING TELESOFT
  2918. PACKAGE INT_IO IS NEW TEXT_IO.INTEGER_IO(BIT_COUNT_16_TYPE);
  2919.  
  2920.     Array_start : CONSTANT BIT_COUNT_16_TYPE :=
  2921.         Ftp_types.valid_command_spec'POS( Ftp_types.valid_command_spec'FIRST );
  2922.     Array_end : CONSTANT BIT_COUNT_16_TYPE :=
  2923.         Ftp_types.valid_command_spec'POS( Ftp_types.valid_command_spec'LAST );
  2924.  
  2925.     TYPE Conversion_array_spec IS RECORD
  2926.                     Command_string : Command_types.command_string_spec;
  2927.                     Command_type   : Ftp_types.valid_command_spec;
  2928.                 END RECORD;
  2929.     Conversion_array : ARRAY(Array_start .. Array_end) OF Conversion_array_spec;
  2930.  
  2931.   PROCEDURE Convert_command_to_enumerated_type
  2932.               ( Status    : OUT Return_status_spec ;
  2933.                 Word      : IN  Command_types.command_string_spec;
  2934.                 Command   : OUT Ftp_types.valid_command_spec ) IS
  2935.     BEGIN
  2936.         Status := No_conversion_found;        
  2937.         Command := Ftp_types.invalid_command;    
  2938.         FOR Index IN Conversion_array'RANGE LOOP
  2939.             IF Conversion_array( Index ).command_string(1..4) = Word(1..4) THEN
  2940.                 Command := Conversion_array( Index ).command_type;
  2941.                 Status := Conversion_found;
  2942.                 EXIT;
  2943.             END IF;
  2944.         END LOOP;
  2945.     EXCEPTION
  2946.         WHEN OTHERS =>
  2947.             Ftp_terminal_driver.output_message_with_new_line
  2948.             (" Unknown exception in Convert_command_to_enumerated_type");
  2949.             RAISE;
  2950.     END Convert_command_to_enumerated_type;
  2951.   FUNCTION Command_found ( Status : IN Return_status_spec ) RETURN BOOLEAN IS
  2952.     BEGIN
  2953.         IF Status = Conversion_found THEN
  2954.             RETURN TRUE;
  2955.         ELSE
  2956.             RETURN FALSE;
  2957.         END IF;
  2958.     EXCEPTION
  2959.         WHEN OTHERS =>
  2960.             Ftp_terminal_driver.output_message_with_new_line
  2961.                     (" Unknown exception in Command_found");
  2962.             RAISE;
  2963.     END Command_found;
  2964. BEGIN
  2965.     FOR Index IN Conversion_array'RANGE LOOP
  2966.         Conversion_array( Index ).command_string := 
  2967.             COMMAND_TYPES.NULL_COMMAND_STRING ;
  2968.         CONVERSION_ARRAY( Index ).command_type := 
  2969.             Ftp_types.valid_command_spec'VAL( Index );
  2970.     END LOOP;
  2971.     Conversion_array( Array_start + 0 ).command_string(1..5) := "CALL ";
  2972.     Conversion_array( Array_start + 1 ).command_string(1..5) := "CLOS ";
  2973.     Conversion_array( Array_start + 2 ).command_string(1..5) := "EXIT ";
  2974.     Conversion_array( Array_start + 3 ).command_string(1..5) := "NOOP ";
  2975.     Conversion_array( Array_start + 4 ).command_string(1..5) := "HELP ";
  2976.     Conversion_array( Array_start + 5 ).command_string(1..5) := "STRU ";
  2977.     Conversion_array( Array_start + 6 ).command_string(1..5) := "TYPE ";
  2978.     Conversion_array( Array_start + 7 ).command_string(1..5) := "MODE ";
  2979.     Conversion_array( Array_start + 8 ).command_string(1..5) := "PORT ";
  2980.     Conversion_array( Array_start + 9 ).command_string(1..5) := "QUIT ";
  2981.     Conversion_array( Array_start +10 ).command_string(1..5) := "USER ";
  2982.     Conversion_array( Array_start +11 ).command_string(1..5) := "PASS ";
  2983.     Conversion_array( Array_start +12 ).command_string(1..5) := "STOR ";
  2984.     Conversion_array( Array_start +13 ).command_string(1..5) := "RETR ";
  2985.     Conversion_array( Array_start +14 ).COMMAND_STRING(1..5) := "REPL ";
  2986. EXCEPTION
  2987.     WHEN OTHERS =>
  2988.         Ftp_terminal_driver.output_message_with_new_line
  2989.             (" Unknown exception in FTP_convert_command");
  2990.         RAISE;
  2991. END Ftp_convert_command;
  2992. --::::::::::::::
  2993. --ftprcvutl_.ada
  2994. --::::::::::::::
  2995. -----------------------------------------------------------------------
  2996. --
  2997. --         DoD Protocols    NA-00005-200       80-01082-100(-)
  2998. --         E-Systems, Inc.  August 07, 1985
  2999. --
  3000. --         FTPRCVUTL_.ADA       Author : Mark Volpe
  3001. --
  3002. -----------------------------------------------------------------------
  3003. -- FILE : Ftprcvutl               AUTHOR : MARK VOLPE
  3004.  
  3005. -- 5/16/85    10:10 AM : REVISED FOR USE WITH DEC COMPILER 
  3006. --                       OLD CODE (TELESOFT) MARKED WITH --&MT  
  3007.  
  3008. -- 5/30/85    8:36 AM : REVISED FOR USE WITH TELESOFT COMPILER
  3009. --                      OLD CODE (DEC) MARKED WITH --&MT
  3010.  
  3011. -- 5/30/85    10:34 : REVISED FOR USE WITH THE DEC COMPILER
  3012. --                    OLD CODE (TELESOFT) MARKED WITH --&MT
  3013.  
  3014. --&MT THE FOLLOWING LINE SHOULD BE DELETED WHEN USING DEC ADA :
  3015. --&MT PRAGMA SOURCE_INFO ( ON );
  3016.  
  3017. --&MT The following line was added to support the use of integer_io
  3018. WITH TEXT_IO;
  3019.  
  3020. WITH My_debug_io;
  3021. WITH Command_types, Ftp_types, Ftp_terminal_driver, Ftp_convert_command;
  3022.  
  3023. PACKAGE Ftp_rcv_utils IS
  3024.  
  3025.     Logic_error      : EXCEPTION;
  3026.     TYPE Return_status_spec IS PRIVATE;
  3027.  
  3028.     FUNCTION Valid_command_found
  3029.         ( Status : IN Return_status_spec ) RETURN BOOLEAN;
  3030.  
  3031.     PROCEDURE Get_command_from_command_string
  3032.         ( Return_status  : OUT Return_status_spec;
  3033.           Command_string : IN  Command_types.command_string_spec;
  3034.           Output_command : OUT Ftp_types.valid_command_spec;
  3035.           Argument       : OUT Ftp_types.argument_list );
  3036.         -----------------------------------------------------------------
  3037.         --
  3038.         -- This procedure checks the command string for syntax
  3039.         -- and returns an enummerated_value for the command. After the
  3040.         -- command has been determined, any arguements that are present
  3041.         -- are checked in addition to checking for required arguments.
  3042.         -- If an unrecognized command has been entered or invalid arguments
  3043.         -- were entered then 'COMMAND_INVALID' is returned.  Arguments are
  3044.         -- returned as character strings.  Abbreviated predefined parameters
  3045.         -- are translated into unique character strings so that upper level
  3046.         -- procedures do not need to test for shortened forms of these
  3047.         -- parameters.
  3048.         --
  3049.         -----------------------------------------------------------------
  3050.  
  3051.     FUNCTION Argument_list_is_valid
  3052.                 ( Status : IN Return_status_spec ) RETURN BOOLEAN;
  3053.  
  3054.     FUNCTION Argument_list_is_invalid
  3055.                 ( Status : IN Return_status_spec ) RETURN BOOLEAN;
  3056.  
  3057.     FUNCTION One_parameter_is_missing
  3058.                 ( Status : IN Return_status_spec ) RETURN BOOLEAN;
  3059.  
  3060.     FUNCTION Two_parameters_are_missing
  3061.                 ( Status : IN Return_status_spec ) RETURN BOOLEAN;
  3062.  
  3063.     FUNCTION Optional_parameter_was_omitted
  3064.                 ( Status : IN Return_status_spec ) RETURN BOOLEAN;
  3065.  
  3066. PRIVATE
  3067.     TYPE RETURN_STATUS_SPEC IS (
  3068.             Word_found,
  3069.             No_more_data_in_command_string,
  3070.             Parameter_found,
  3071.             Parameter_expected ,
  3072.             Valid_argument_list,
  3073.             Invalid_argument_list ,
  3074.             One_parameter_missing,
  3075.             Two_parameters_missing,
  3076.             Optional_parameter_omitted,
  3077.             Invalid_reply,
  3078.             Valid_command,
  3079.             Command_invalid );
  3080. END Ftp_rcv_utils;
  3081.  
  3082. --::::::::::::::
  3083. --ftprcvutl.ada
  3084. --::::::::::::::
  3085. -----------------------------------------------------------------------
  3086. --
  3087. --         DoD Protocols    NA-00005-200       80-01083-100(-)
  3088. --         E-Systems, Inc.  August 07, 1985
  3089. --
  3090. --         FTPRCVUTL.ADA       Author : Mark Volpe
  3091. --
  3092. -----------------------------------------------------------------------
  3093. -- FILE : Ftprcvutl               AUTHOR : MARK VOLPE
  3094.  
  3095. -- 5/16/85    10:10 AM : REVISED FOR USE WITH DEC COMPILER 
  3096. --                       OLD CODE (TELESOFT) MARKED WITH --&MT  
  3097.  
  3098. -- 5/30/85    8:36 AM : REVISED FOR USE WITH TELESOFT COMPILER
  3099. --                      OLD CODE (DEC) MARKED WITH --&MT
  3100.  
  3101. -- 5/30/85    10:45 AM : REVISED FOR USE WITH THE DEC COMPILER
  3102. --                       OLD CODE (TELESOFT) MARKED WITH --&MT
  3103.  
  3104. PACKAGE BODY Ftp_rcv_utils IS
  3105.  
  3106. --&MT SUBTYPE BIT_COUNT_32_TYPE IS LONG_INTEGER;
  3107.       SUBTYPE BIT_COUNT_32_TYPE IS INTEGER;
  3108.  
  3109. --&MT SUBTYPE BIT_COUNT_16_TYPE IS INTEGER;
  3110.       SUBTYPE BIT_COUNT_16_TYPE IS SHORT_INTEGER;
  3111.  
  3112. --&MT THE FOLLOWING LINES SHOULD BE DELETED WHEN USING TELESOFT
  3113.   PACKAGE LONG_INT IS NEW TEXT_IO.INTEGER_IO(BIT_COUNT_32_TYPE);
  3114.   PACKAGE INT_IO IS NEW TEXT_IO.INTEGER_IO(BIT_COUNT_16_TYPE);
  3115.  
  3116.   FUNCTION Argument_list_is_valid
  3117.                 ( Status : IN Return_status_spec ) RETURN BOOLEAN IS
  3118.     BEGIN
  3119.         IF Status = Valid_argument_list THEN
  3120.             RETURN TRUE;
  3121.         ELSE
  3122.             RETURN FALSE;
  3123.         END IF;
  3124.     EXCEPTION
  3125.         WHEN OTHERS => RAISE;
  3126.     END Argument_list_is_valid ;
  3127.  
  3128.   FUNCTION Argument_list_is_invalid
  3129.                 ( Status : IN Return_status_spec ) RETURN BOOLEAN IS
  3130.     BEGIN
  3131.         IF Status = Invalid_argument_list THEN
  3132.             RETURN TRUE;
  3133.         ELSE
  3134.             RETURN FALSE;
  3135.         END IF;
  3136.     EXCEPTION
  3137.         WHEN OTHERS => RAISE;
  3138.     END Argument_list_is_invalid ;
  3139.  
  3140.   FUNCTION One_parameter_is_missing
  3141.                 ( Status : IN Return_status_spec ) RETURN BOOLEAN IS
  3142.     BEGIN
  3143.         IF Status = One_parameter_missing THEN
  3144.             RETURN TRUE;
  3145.         ELSE
  3146.             RETURN FALSE;
  3147.         END IF;
  3148.     EXCEPTION
  3149.         WHEN OTHERS => RAISE;
  3150.     END One_parameter_is_missing;
  3151.  
  3152.   FUNCTION Two_parameters_are_missing
  3153.                 ( Status : IN Return_status_spec ) RETURN BOOLEAN IS
  3154.     BEGIN
  3155.         IF Status = Two_parameters_missing THEN
  3156.             RETURN TRUE;
  3157.         ELSE
  3158.             RETURN FALSE;
  3159.         END IF;
  3160.     EXCEPTION
  3161.         WHEN OTHERS => RAISE;
  3162.     END Two_parameters_are_missing;
  3163.  
  3164.   FUNCTION Optional_parameter_was_omitted
  3165.                 ( Status : IN Return_status_spec ) RETURN BOOLEAN IS
  3166.     BEGIN
  3167.         IF Status = Optional_parameter_omitted THEN
  3168.             RETURN TRUE;
  3169.         ELSE
  3170.             RETURN FALSE;
  3171.         END IF;
  3172.     EXCEPTION
  3173.         WHEN OTHERS => RAISE;
  3174.     END Optional_parameter_was_omitted;
  3175.  
  3176.   FUNCTION Valid_command_found ( Status : IN Return_status_spec ) 
  3177.                 RETURN BOOLEAN IS
  3178.     BEGIN
  3179.         IF Status = Valid_command THEN
  3180.             RETURN TRUE;
  3181.         ELSE
  3182.             RETURN FALSE;
  3183.         END IF;
  3184.     EXCEPTION
  3185.         WHEN OTHERS =>
  3186.             Ftp_terminal_driver.output_message_with_new_line
  3187.                 (" Unknown exception in Valid_command_found");
  3188.             RAISE;
  3189.     END Valid_command_found;
  3190.  
  3191.   PROCEDURE Get_next_word_from_command_string
  3192.             ( Status           : OUT    Return_status_spec;
  3193.               Command_string   : IN     Command_types.command_string_spec;
  3194.               Next_word        : OUT    Command_types.command_string_spec;
  3195.  
  3196.         --&MT Word_length      : OUT    BIT_COUNT_16_TYPE;
  3197.               Word_length      : OUT    BIT_COUNT_32_TYPE;
  3198.  
  3199.         --&MT Location_pointer : IN OUT BIT_COUNT_16_TYPE ) IS
  3200.               Location_pointer : IN OUT BIT_COUNT_32_TYPE ) IS
  3201.       
  3202.   --&MT Initial_location : BIT_COUNT_16_TYPE := Location_pointer;
  3203.         Initial_location : BIT_COUNT_32_TYPE := Location_pointer;
  3204.  
  3205.   --&MT End_location     : BIT_COUNT_16_TYPE ;
  3206.         End_location     : BIT_COUNT_32_TYPE ;
  3207.  
  3208.   --&MT temp_word_length : BIT_COUNT_16_TYPE;
  3209.         temp_word_length : BIT_COUNT_32_TYPE;
  3210.  
  3211.     BEGIN
  3212.         --
  3213.         -- Scan the input string for a nonblank char, this indicates
  3214.         -- the start of actual data
  3215.         --
  3216.         WHILE 
  3217.            (NOT Command_types.end_of_command( Command_string(Location_pointer)))
  3218.                                 AND THEN
  3219.            (bit_count_16_type(Location_pointer) <= 
  3220.             Command_types.max_command_string_length)
  3221.                                 AND THEN
  3222.            (Command_string( Location_pointer ) = ' ' ) LOOP
  3223.                             Location_pointer := Location_pointer + 1;
  3224.         END LOOP;
  3225.         --
  3226.         -- Test for end of line. (Ex. no data on line )
  3227.         --
  3228.         IF Command_types.end_of_command( Command_string ( Location_pointer ) ) 
  3229.                                 OR ELSE
  3230.            bit_count_16_type(Location_pointer) = 
  3231.             Command_types.max_command_string_length 
  3232.         THEN
  3233.             Status := No_more_data_in_command_string;
  3234.                 -- My_debug_io.put_line ( " Normal end of command found ");
  3235.             RETURN;
  3236.         END IF;
  3237.         --
  3238.         -- Save the new location_pointer as the starting position
  3239.         --
  3240.         Initial_location := Location_pointer;
  3241.         --
  3242.         -- Scan the characters from the initial_location
  3243.         --  towards the end of the string until a delimeter is
  3244.         --  found.
  3245.         WHILE
  3246.           (NOT Command_types.end_of_command( Command_string( Location_pointer)))
  3247.                                 AND THEN
  3248.           (bit_count_16_type(Location_pointer) <
  3249.             Command_types.max_command_string_length )
  3250.                                 AND THEN
  3251.           ( Command_string( Location_pointer ) /= ' ' ) LOOP
  3252.                     Location_pointer := Location_pointer + 1;
  3253.         END LOOP;
  3254.         --
  3255.         -- See what caused us to fall out of the loop
  3256.         --
  3257.         IF Command_string( Location_pointer ) = ' '
  3258.             THEN
  3259.                 --
  3260.                 -- SAVE END POINTER FOR LATER
  3261.                 --
  3262.                 End_location := Location_pointer - 1;
  3263.                 --
  3264.                 -- How big was the word we found?
  3265.                 --
  3266.                 Temp_Word_length := End_location - Initial_location + 1;
  3267.                 Next_word( Command_types.command_string_spec'FIRST..
  3268.                      Command_types.command_string_spec'FIRST + TEMP_WORD_LENGTH-1) :=
  3269.                             Command_string( INITIAL_LOCATION .. End_location );
  3270.                 Status := Word_found;
  3271.         ELSIF Command_types.end_of_command(command_string( Location_pointer )) 
  3272.             THEN
  3273.                 Status := No_more_data_in_command_string;
  3274.                 -- My_debug_io.put_line( " 2 No more data in command string");
  3275.         ELSIF bit_count_16_type(Location_pointer) >= 
  3276.          Command_types.max_command_string_length
  3277.             THEN
  3278.                 Status := No_more_data_in_command_string;
  3279.                 -- My_debug_io.put_line( " 3 No more data in command string");
  3280.         ELSE
  3281.                 -- It better never get here or I goofed up really bad!
  3282.                 --
  3283.                 RAISE Logic_error;
  3284.         END IF;
  3285.         -- Save the word just found
  3286.         -- Update the location_pointer.
  3287.     word_length := temp_word_length ;
  3288.     EXCEPTION
  3289.         WHEN Logic_error =>
  3290.                 Ftp_terminal_driver.output_message_with_new_line
  3291.                      (" ***** LOGIC ERROR in Get_next_word *****");
  3292.                 RAISE;
  3293.         WHEN OTHERS =>
  3294.                 Ftp_terminal_driver.output_message_with_new_line
  3295.                     (" Unknown error in Get_Next_word");
  3296.                 RAISE;
  3297.     END ;
  3298.  
  3299.   PROCEDURE Get_parameter
  3300.         ( Status                  : OUT Return_status_spec;
  3301.           Command                 : IN Ftp_types.valid_command_spec;
  3302.           Command_string          : IN Command_types.command_string_spec;
  3303.           Argument                : OUT Ftp_types.argument_list ;
  3304.  
  3305.     --&MT Length                  : OUT BIT_COUNT_16_TYPE;
  3306.           Length                  : OUT BIT_COUNT_32_TYPE;
  3307.  
  3308.     --&MT Command_string_location : IN OUT BIT_COUNT_16_TYPE ) IS
  3309.           Command_string_location : IN OUT BIT_COUNT_32_TYPE ) IS
  3310.  
  3311.         -----------------------------------------------------------------
  3312.         --
  3313.         -- This procedure gets a parameter from the command_string and stores
  3314.         -- it in the argument list array
  3315.         --
  3316.         -- Return_status = PARAMETER_FOUND OR
  3317.         --                 PARAMETER_EXPECTED
  3318.         -----------------------------------------------------------------
  3319.         Argument_index: BIT_COUNT_16_TYPE := Argument'FIRST;
  3320.         Word        : Command_types.command_string_spec :=
  3321.                                             Command_types.null_command_string;
  3322.         temp_status : return_status_spec;
  3323.  
  3324.   --&MT temp_length : bit_count_16_type;
  3325.         temp_length : bit_count_32_type;
  3326.  
  3327.     BEGIN
  3328.         --
  3329.         -- Get a parameter from the command string
  3330.         --
  3331.         Get_next_word_from_command_string
  3332.             ( temp_status,
  3333.               Command_string,
  3334.               Word,
  3335.               temp_length,
  3336.               Command_string_location);
  3337.         IF temp_status = Word_found THEN
  3338.             temp_status := Parameter_found;
  3339.             FOR Index IN Word'FIRST .. ( Word'FIRST + temp_length - 1) LOOP
  3340.                 --
  3341.                 -- This HAS to be a loop because of
  3342.                 -- the type conversion !!!
  3343.                 --
  3344.                 Argument ( Argument_index ) :=
  3345.                                 Ftp_types.argument_list_unit'( Word( Index ));
  3346.                 Argument_index := Argument_index + 1;
  3347.             END LOOP;
  3348.         ELSE
  3349.             temp_status := Parameter_expected;
  3350.             RETURN;
  3351.         END IF;
  3352.     status := temp_status;
  3353.     length := temp_length;
  3354.     EXCEPTION
  3355.         WHEN OTHERS =>
  3356.             Ftp_terminal_driver.output_message_with_new_line
  3357.                 (" Unknown exception in Get_Parameter");
  3358.             RAISE;
  3359.     END Get_parameter;
  3360.  
  3361.   PROCEDURE Process_argument_list
  3362.         ( Status         : OUT Return_status_spec;
  3363.           Command        : IN Ftp_types.valid_command_spec;
  3364.           Command_string : IN Command_types.command_string_spec;
  3365.           Argument       : OUT Ftp_types.argument_list;
  3366.  
  3367.     --&MT Location       : IN OUT BIT_COUNT_16_TYPE ) IS
  3368.           Location       : IN OUT BIT_COUNT_32_TYPE ) IS
  3369.  
  3370.         -----------------------------------------------------------------
  3371.         --
  3372.         -- This procedure processes the parameter list for the different
  3373.         -- commands.
  3374.         --
  3375.         -- Status = VALID_ARGUMENT_LIST OR
  3376.         --          INVALID_ARGUMENT_LIST
  3377.         -----------------------------------------------------------------
  3378.  
  3379.   --&MT Start_location  : BIT_COUNT_16_TYPE := Location;
  3380.         Start_location  : BIT_COUNT_32_TYPE := Location;
  3381.  
  3382.   --&MT End_location    : BIT_COUNT_16_TYPE := Location;
  3383.         End_location    : BIT_COUNT_32_TYPE := Location;
  3384.  
  3385.   --&MT Argument_length : BIT_COUNT_16_TYPE ;
  3386.         Argument_length : BIT_COUNT_32_TYPE ;
  3387.  
  3388.   --&MT Temp_argument_length: BIT_COUNT_16_TYPE ;
  3389.         Temp_argument_length: BIT_COUNT_32_TYPE ;
  3390.  
  3391.         Temp_argument   : Ftp_types.argument_list := Ftp_types.null_argument;
  3392.         temp_status : return_status_spec;
  3393.         temp_arg : ftp_types.argument_list;
  3394.     BEGIN
  3395.         temp_arg:= Ftp_types.null_argument;
  3396.         --
  3397.         -- Location is pointing to the first character after
  3398.         -- the end of the command.  It may be a null or a ' ',
  3399.         -- and location may = max_command_length.
  3400.         --
  3401.         CASE Command IS
  3402.            WHEN Ftp_types.stor_command |
  3403.                 Ftp_types.retr_command =>
  3404.                 --
  3405.                 -- Takes 2 arguments
  3406.                 --
  3407.                 Get_parameter
  3408.                     ( temp_status,
  3409.                       Command,
  3410.                       Command_string,
  3411.                       temp_arg,
  3412.                       Argument_length,
  3413.                       Location );
  3414.                 IF temp_status = Parameter_found THEN
  3415.                     Get_parameter
  3416.                         ( temp_status,
  3417.                           Command,
  3418.                           Command_string,
  3419.                           Temp_argument,
  3420.                           Temp_argument_length,
  3421.                           Location );
  3422.                     IF temp_status = Parameter_found THEN
  3423.                         temp_status := Valid_argument_list;
  3424.                         temp_arg( temp_arg'FIRST + 
  3425.                          bit_count_16_type(Argument_length)) := 
  3426.                           Ftp_types.argument_list_unit'(' ');
  3427.                         temp_arg( temp_arg'FIRST + 
  3428.                          bit_count_16_type(Argument_length) + 1 ..
  3429.                           temp_arg'FIRST + bit_count_16_type(Argument_length) +
  3430.                                      bit_count_16_type(Temp_argument_length  )) :=
  3431.                                              Temp_argument
  3432.                                                ( Temp_argument'first..
  3433.                                                 Temp_argument'first
  3434.                                                  + bit_count_16_type(Temp_argument_length)
  3435.                                                      - 1);
  3436.                     ELSE
  3437.                         temp_status := One_parameter_missing;
  3438.                         -- My_debug_io.put_line
  3439.                             -- (" ~~ Second parameter expected ~~");
  3440.                     END IF;
  3441.                 ELSE
  3442.                     temp_status := Two_parameters_missing;
  3443.                     -- My_debug_io.PUT_LINE(" ~~ Parameter expected ~~");
  3444.                 END IF;
  3445.              WHEN Ftp_types.type_command =>
  3446.                 --
  3447.                 -- Takes 1 or 2 arguments
  3448.                 --
  3449.                 Get_parameter
  3450.                     ( temp_status,
  3451.                       Command,
  3452.                       Command_string,
  3453.                       temp_arg,
  3454.                       Argument_length,
  3455.                       Location );
  3456.                 IF temp_status = Parameter_found THEN
  3457.                      --
  3458.                      -- Next parameter in argument
  3459.                      -- store it for later
  3460.                      --
  3461.                      -- Remember: Only the first character
  3462.                      --
  3463.                      Temp_argument( Temp_argument'FIRST) :=
  3464.                                             temp_arg( temp_arg'FIRST);
  3465.                      Temp_argument( Temp_argument'FIRST + 1) :=
  3466.                                             Ftp_types.argument_list_unit'(' ');
  3467.                      --
  3468.                      -- Get the carriage control field if there
  3469.                      --
  3470.                      Get_parameter
  3471.                         ( temp_status,
  3472.                           Command,
  3473.                           Command_string,
  3474.                           temp_arg,
  3475.                           Argument_length,
  3476.                           Location);
  3477.                     IF temp_status = Parameter_found THEN
  3478.                         --
  3479.                         -- Next parameter in argument
  3480.                         -- store it for later
  3481.                         --
  3482.                         -- Remember: Only the first character
  3483.                         --
  3484.                         temp_status := Valid_argument_list;
  3485.                         Temp_argument( Temp_argument'FIRST + 2) :=
  3486.                                                 temp_arg( temp_arg'FIRST);
  3487.                     ELSE
  3488.                         --
  3489.                         -- Use the default carriage control
  3490.                         --
  3491.                         temp_status := Optional_parameter_omitted;
  3492.                         Temp_argument( Temp_argument'FIRST + 2):=
  3493.                                             Ftp_types.default_carriage_control;
  3494.                         -- My_debug_io.Put_line
  3495.                                 -- (" ~~ Using default carriage control ~~");
  3496.                     END IF;
  3497.                 ELSE
  3498.                     temp_status := Invalid_argument_list;
  3499.                     -- My_debug_io.Put_line(" ~~ Parameter list expected ~~");
  3500.                 END IF;
  3501.                 --
  3502.                 -- Store the new argument list
  3503.                 --
  3504.                 temp_arg := Temp_argument;
  3505.            WHEN Ftp_types.stru_command |
  3506.                 Ftp_types.mode_command =>
  3507.                 --
  3508.                 -- Takes 1 argument ( 1st character only )
  3509.                 --
  3510.                 Get_parameter
  3511.                     ( temp_status,
  3512.                       Command,
  3513.                       Command_string,
  3514.                       temp_arg,
  3515.                       Argument_length,
  3516.                       Location);
  3517.                 IF temp_status = Parameter_found THEN
  3518.                     temp_status := Valid_argument_list;
  3519.                     temp_arg( bit_count_16_type(Argument_length) + 1 ) := 
  3520.                      (' ');
  3521.                     Temp_argument( Temp_argument'FIRST) :=
  3522.                                                 temp_arg( temp_arg'FIRST);
  3523.                     temp_arg := Temp_argument;
  3524.                 ELSE
  3525.                     temp_status := One_parameter_missing;
  3526.                     -- My_debug_io.PUT_LINE(" ~~ Parameter expected ~~");
  3527.                 END IF;
  3528.            WHEN Ftp_types.call_command |
  3529.                 Ftp_types.clos_command |
  3530.                 Ftp_types.port_command |
  3531.                 Ftp_types.pass_command =>
  3532.                 --
  3533.                 -- Takes 1 argument
  3534.                 --
  3535.                 Get_parameter
  3536.                     ( temp_status,
  3537.                       Command,
  3538.                       Command_string,
  3539.                       temp_arg,
  3540.                       Argument_length,
  3541.                       Location);
  3542.                 IF temp_status = Parameter_found THEN
  3543.                     temp_status := Valid_argument_list;
  3544.                     temp_arg( bit_count_16_type(Argument_length) + 1) := 
  3545.                      (' '); 
  3546.                 ELSE
  3547.                     temp_status := One_parameter_missing;
  3548.                     -- My_debug_io.PUT_LINE(" ~~ Parameter expected ~~");
  3549.                 END IF;
  3550.            WHEN Ftp_types.noop_command |
  3551.                 Ftp_types.exit_command |
  3552.                 Ftp_types.quit_command =>
  3553.                 --
  3554.                 -- Takes 0 arguments
  3555.                 --
  3556.                 temp_status := Valid_argument_list; -- force extra parameters test
  3557.            WHEN Ftp_types.user_command |
  3558.                 Ftp_types.help_command =>
  3559.                 --
  3560.                 -- Takes 0 or 1 arguments
  3561.                 --
  3562.                 Get_parameter
  3563.                     ( temp_status,
  3564.                       Command,
  3565.                       Command_string,
  3566.                       temp_arg,
  3567.                       Argument_length,
  3568.                       Location);
  3569.                 IF temp_status = Parameter_found THEN
  3570.                     temp_status := Valid_argument_list;
  3571.                 ELSE
  3572.                     temp_status := Optional_parameter_omitted;
  3573.                     -- MY_DEBUG_IO.PUT_LINE
  3574.                             -- (" ~~ Optional parameter list excluded ~~");
  3575.                 END IF;
  3576.            WHEN Ftp_types.reply_command =>
  3577.                 temp_status := Valid_argument_list;
  3578.                     -- Force test for extra parameters.
  3579.            WHEN OTHERS =>
  3580.              temp_status := Invalid_argument_list;
  3581.              -- MY_DEBUG_IO.PUT_LINE
  3582.                      -- (" Illegal command passed to Process_parameter_List");
  3583.         END CASE;
  3584.         --
  3585.         -- All expected parameters have been processed;
  3586.         -- Test for extra parameters.
  3587.         --
  3588.         IF temp_status = Valid_argument_list THEN
  3589.             DECLARE
  3590.                 Local_status : Return_status_spec;
  3591.             BEGIN
  3592.                 Get_parameter
  3593.                     ( Local_status,
  3594.                       Command,
  3595.                       Command_string,
  3596.                       Temp_argument,
  3597.                       Argument_length,
  3598.                       Location);
  3599.                 IF Local_status = Parameter_expected THEN
  3600.                     NULL;
  3601.                 ELSE
  3602.                     Status := Invalid_argument_list;
  3603.                     -- My_debug_io.PUT_LINE(" ~~ Extra parameters ignored ~~");
  3604.                 END IF;
  3605.             END;
  3606.         ELSE
  3607.             NULL;    -- Leave the status code as it was
  3608.         END IF;
  3609.     status := temp_status;
  3610.     argument := temp_arg;
  3611.     EXCEPTION
  3612.         WHEN OTHERS =>
  3613.             Ftp_terminal_driver.output_message_with_new_line
  3614.                 (" Unknown error in Process_Argument_List");
  3615.             RAISE;
  3616.     END Process_argument_list;
  3617.  
  3618.   PROCEDURE Get_command_from_command_string
  3619.         ( Return_status        : OUT Return_status_spec;
  3620.           Command_string       : IN Command_types.command_string_spec;
  3621.           Output_command       : OUT Ftp_types.valid_command_spec;
  3622.           Argument             : OUT Ftp_types.argument_list ) IS
  3623.         -----------------------------------------------------------------
  3624.         --
  3625.         -- This procedure checks the command string for syntax
  3626.         -- and returns an enummerated_value for the command. After the
  3627.         -- command has been determined, any arguements that are present
  3628.         -- are checked in addition to checking for required arguments.
  3629.         -- If an unrecognized command has been entered or invalid arguments
  3630.         -- were entered then 'COMMAND_INVALID' is returned.  Arguments are
  3631.         -- returned as character strings.  Abbreviated predefined parameters
  3632.         -- are translated into unique character strings so that upper level
  3633.         -- procedures do not need to test for shortened forms of these
  3634.         -- parameters.
  3635.         --
  3636.         -----------------------------------------------------------------
  3637.         Word        : Command_types.command_string_spec :=
  3638.                                         Command_types.null_command_string;
  3639.  
  3640.   --&MT Word_length : BIT_COUNT_16_TYPE := 0;
  3641.         Word_length : BIT_COUNT_32_TYPE := 0;
  3642.  
  3643.   --&MT Location    : BIT_COUNT_16_TYPE := 1;
  3644.         Location    : BIT_COUNT_32_TYPE := 1;
  3645.  
  3646.         Conversion_status: Ftp_convert_command.return_status_spec;
  3647.         temp_return_status : return_status_spec;
  3648.         temp_output_command : ftp_types.valid_command_spec;
  3649.    BEGIN
  3650.         Get_next_word_from_command_string
  3651.             ( temp_return_status,
  3652.               Command_string,
  3653.               Word,
  3654.               Word_length,
  3655.               Location);
  3656.         IF temp_return_status = Word_found THEN
  3657.             --
  3658.             -- CONVERT TO ENUMERATED TYPE
  3659.             --
  3660.             Ftp_convert_command.convert_command_to_enumerated_type
  3661.                 ( Conversion_status,
  3662.                   Word,
  3663.                   temp_output_command );
  3664.             IF Ftp_convert_command.command_found( Conversion_status ) THEN
  3665.                 temp_return_status := Valid_command;
  3666.                 Process_argument_list
  3667.                         ( temp_return_status,
  3668.                           temp_output_command,
  3669.                           Command_string,
  3670.                           Argument,
  3671.                           Location);
  3672.             ELSE
  3673.                 temp_return_status := Command_invalid;
  3674.                 -- MY_DEBUG_IO.PUT_LINE (" Invalid command");
  3675.             END IF;
  3676.         ELSE
  3677.             temp_return_status := Command_invalid;
  3678.             -- MY_DEBUG_IO.PUT_LINE(" No command found");
  3679.         END IF;
  3680.     return_status := temp_return_status;
  3681.     output_command := temp_output_command;
  3682.     EXCEPTION
  3683.         WHEN OTHERS =>
  3684.            Ftp_terminal_driver.output_message_with_new_line
  3685.              (" Unknown exception in Get_Command_From_Command_String");
  3686.             RAISE;
  3687.    END Get_command_from_command_string;
  3688.  
  3689. BEGIN
  3690.     NULL;
  3691. EXCEPTION
  3692.     WHEN OTHERS =>
  3693.         Ftp_terminal_driver.output_message_with_new_line
  3694.                 (" Unknown exception in ftp_rcv_utils");
  3695.         RAISE;
  3696. END Ftp_rcv_utils;
  3697.  
  3698. --::::::::::::::
  3699. --ftpcmdutl_.ada
  3700. --::::::::::::::
  3701. -----------------------------------------------------------------------
  3702. --
  3703. --         DoD Protocols    NA-00005-200       80-01074-100(-)
  3704. --         E-Systems, Inc.  August 07, 1985
  3705. --
  3706. --         FTPCMDUTL_.ADA       Author : Mark Volpe
  3707. --
  3708. -----------------------------------------------------------------------
  3709. -- FILE : Ftpcmdutl               AUTHOR : MARK VOLPE
  3710.  
  3711. -- 5/16/85    2:35 PM : REVISED FOR USE WITH DEC COMPILER 
  3712. --                      OLD CODE (TELESOFT) MARKED WITH --&MT  
  3713.  
  3714. -- 5/30/85    10:26 AM : REVISED FOR USE WITH TELESOFT COMPILER
  3715. --                       OLD CODE (DEC) MARKED WITH --&MT
  3716.  
  3717. -- 5/30/85    11:17 AM : REVISED FOR USE WITH THE DEC COMPILER
  3718. --                       OLD CODE (TELESOFT) MARKED WITH --&MT
  3719.  
  3720. --&MT THE FOLLOWING LINE SHOULD BE DELETED WHEN USING DEC ADA :
  3721. --&MT PRAGMA SOURCE_INFO ( ON );
  3722.  
  3723. with My_debug_io, 
  3724.      Command_types, Ftp_types, Ftp_terminal_driver, 
  3725.      Ftp_rcv_utils, Ftp_telnet;
  3726.  
  3727. --&MT THE FOLLOWING LINE WAS ADDED TO PERMIT CALLING TO INTEGER_IO IN BODY PART
  3728. with TEXT_IO;
  3729.  
  3730. --&MT THE FOLLOWING LINE WAS ADDED TO ENABLE THE DEC COMPILER TO CHECK FOR 
  3731. --&MT  EQUALITY BETWEEN TWO ENUMERATED TYPES FOUND IN FTP_TYPES 
  3732. use ftp_types;
  3733.   
  3734. PACKAGE Ftp_command_utilities IS
  3735.     ----------------------------------------------------------------------
  3736.     --
  3737.     -- This package contains procedures that are used to get a command or reply
  3738.     -- and its arguments from telnet, or the keyboard.
  3739.     --
  3740.     ----------------------------------------------------------------------
  3741.     TYPE Command_status_spec IS PRIVATE;
  3742.     TYPE Transmission_status_spec Is PRIVATE;
  3743.  
  3744.     FUNCTION Transmission_successful 
  3745.             ( Xmit_status : IN Transmission_status_spec ) RETURN BOOLEAN;
  3746.  
  3747.     PROCEDURE Send_command_over_telnet 
  3748.             ( Status   : OUT Transmission_status_spec;
  3749.               Command  : IN Ftp_types.valid_command_spec;
  3750.               Argument : IN Ftp_types.argument_list ) ;
  3751.         ----------------------------------------------------------------------
  3752.         --
  3753.         -- This procedure transmitts a command and its arguments,
  3754.         -- via telnet, from the user system to the server system 
  3755.         --
  3756.         ----------------------------------------------------------------------
  3757.  
  3758.     PROCEDURE Get_command_from_telnet 
  3759.                         ( Command_status : OUT Command_status_spec;
  3760.                  Command        : OUT Ftp_types.valid_command_spec;
  3761.                  Argument       : OUT Ftp_types.argument_list );
  3762.         ----------------------------------------------------------------------
  3763.         --
  3764.         -- This procedure gets a command and any arguments from the 
  3765.         -- user pi via telnet and returns them to the calling program.
  3766.         --
  3767.         ----------------------------------------------------------------------
  3768.  
  3769.     PROCEDURE Get_command_from_keyboard
  3770.                 ( Command_status : OUT Command_status_spec;
  3771.                   Command        : OUT Ftp_types.valid_command_spec;
  3772.                   Argument       : OUT Ftp_types.argument_list );
  3773.         ----------------------------------------------------------------------
  3774.         --
  3775.         -- This procedure gets a command and any arguments from the 
  3776.         -- user via the keyboard and returns them to the calling 
  3777.         -- program.
  3778.         --
  3779.         ----------------------------------------------------------------------
  3780.  
  3781.     PROCEDURE Get_first_argument_from_argument_list
  3782.                 ( Argument    : IN Ftp_types.argument_list ;
  3783.                   Parameter   : OUT Ftp_types.argument_list);
  3784.         ----------------------------------------------------------------------
  3785.         --
  3786.         -- This procedure gets the first argument from the argument
  3787.         -- list. No status is returned because the argument list
  3788.         -- has already been validated when it was built.
  3789.         --
  3790.         ----------------------------------------------------------------------
  3791.  
  3792.     PROCEDURE Get_second_argument_from_argument_list
  3793.                 ( Argument  : IN Ftp_types.argument_list ;
  3794.                   Parameter : OUT Ftp_types.argument_list );
  3795.         ----------------------------------------------------------------------
  3796.         --
  3797.         -- This procedure gets the second argument from the argument
  3798.         -- list. No status is returned because the argument list
  3799.         -- has already been validated when it was built.
  3800.         --
  3801.         ----------------------------------------------------------------------
  3802.  
  3803.     FUNCTION Command_is_valid
  3804.                 ( Status : IN Command_status_spec ) RETURN BOOLEAN;
  3805.         ----------------------------------------------------------------------
  3806.         --
  3807.         -- This function tests to see if a valid command was returned
  3808.         --
  3809.         ----------------------------------------------------------------------
  3810.  
  3811.     FUNCTION Argument_list_is_valid
  3812.                 ( Status : IN Command_status_spec ) RETURN BOOLEAN;
  3813.         ----------------------------------------------------------------------
  3814.         --
  3815.         -- This function tests to see if the received argument list was valid
  3816.         --
  3817.         ----------------------------------------------------------------------
  3818.  
  3819.     FUNCTION Argument_list_is_invalid
  3820.                 ( Status : IN Command_status_spec ) RETURN BOOLEAN;
  3821.         ----------------------------------------------------------------------
  3822.         --
  3823.         -- This function tests to see if the received argument list was invalid
  3824.         --
  3825.         ----------------------------------------------------------------------
  3826.  
  3827.     FUNCTION One_parameter_is_missing
  3828.             ( Status : IN Command_status_spec ) RETURN BOOLEAN;
  3829.         ----------------------------------------------------------------------
  3830.         --
  3831.         -- This function tests to see if one parameter was missing
  3832.         --
  3833.         ----------------------------------------------------------------------
  3834.  
  3835.     FUNCTION Two_parameters_are_missing
  3836.                 ( Status : IN Command_status_spec ) RETURN BOOLEAN;
  3837.         ----------------------------------------------------------------------
  3838.         --
  3839.         -- This function tests to see if two paramters are missing
  3840.         --
  3841.         ----------------------------------------------------------------------
  3842.  
  3843. PRIVATE
  3844.     TYPE Transmission_status_spec IS ( Xmit_successful, Xmit_failed );
  3845.     TYPE Command_status_spec IS ( 
  3846.                         Valid_command,
  3847.                         Invalid_command,
  3848.                         Valid_argument_list,
  3849.                         Invalid_argument_list,
  3850.                         One_parameter_missing,
  3851.                         Two_parameters_missing,
  3852.                         Optional_parameter_omitted,
  3853.                         Extra_parameters_received );
  3854. END Ftp_command_utilities ;
  3855.  
  3856. --::::::::::::::
  3857. --ftpcmdutl.ada
  3858. --::::::::::::::
  3859. -----------------------------------------------------------------------
  3860. --
  3861. --         DoD Protocols    NA-00005-200       80-01075-100(-)
  3862. --         E-Systems, Inc.  August 07, 1985
  3863. --
  3864. --         FTPCMDUTL.ADA       Author : Mark Volpe
  3865. --
  3866. -----------------------------------------------------------------------
  3867. -- FILE : Ftpcmdutl               AUTHOR : MARK VOLPE
  3868.  
  3869. -- 5/16/85    2:35 PM : REVISED FOR USE WITH DEC COMPILER 
  3870. --                      OLD CODE (TELESOFT) MARKED WITH --&MT  
  3871.  
  3872. -- 5/30/85    10:26 AM : REVISED FOR USE WITH TELESOFT COMPILER
  3873. --                       OLD CODE (DEC) MARKED WITH --&MT
  3874.  
  3875. -- 5/30/85    11:26 AM : REVISED FOR USE WITH THE DEC COMPILER
  3876. --                       OLD CODE (TELESOFT) MARKED WITH --&MT
  3877.  
  3878. PACKAGE BODY Ftp_command_utilities IS
  3879.  
  3880. --&MT SUBTYPE BIT_COUNT_32_TYPE IS LONG_INTEGER;
  3881.       SUBTYPE BIT_COUNT_32_TYPE IS INTEGER;
  3882.  
  3883. --&MT SUBTYPE BIT_COUNT_16_TYPE IS INTEGER;
  3884.       SUBTYPE BIT_COUNT_16_TYPE IS SHORT_INTEGER;
  3885.  
  3886. --&MT THE FOLLOWING LINES SHOULD BE DELETED WHEN USING TELESOFT
  3887.   PACKAGE LONG_INT IS NEW TEXT_IO.INTEGER_IO(BIT_COUNT_32_TYPE);
  3888.   PACKAGE INT_IO IS NEW TEXT_IO.INTEGER_IO(BIT_COUNT_16_TYPE);
  3889.  
  3890.   FUNCTION Transmission_successful 
  3891.                 ( Xmit_status : IN Transmission_status_spec ) RETURN BOOLEAN IS
  3892.     BEGIN
  3893.         IF Xmit_status = Xmit_successful THEN
  3894.             RETURN TRUE;
  3895.         ELSE
  3896.             RETURN FALSE;
  3897.         END IF;
  3898.     EXCEPTION
  3899.         WHEN OTHERS =>
  3900.                 Ftp_terminal_driver.output_message_with_new_line
  3901.                     (" Unknown exception in Transmission_successful");
  3902.         RAISE;
  3903.     END Transmission_successful;
  3904.  
  3905.   PROCEDURE Send_command_over_telnet 
  3906.         ( Status   : OUT Transmission_status_spec;
  3907.           Command  : IN Ftp_types.valid_command_spec;
  3908.           Argument : IN Ftp_types.argument_list ) IS
  3909.     ------------------------------------------------------------
  3910.     --
  3911.     -- This procedure is used by the user ftp system and is responsible 
  3912.     -- for interfacing to telnet.
  3913.     --
  3914.     -- It accepts a command and an argument.  The command is an 
  3915.     -- enumerated type.  The argument is a string and may be a null
  3916.     -- string if the command does not require any arguments.
  3917.     -- Using a case statement to determine the command, the correct
  3918.     -- character sequence is loaded into the telnet buffer and then sent
  3919.     -- to the listening server or host.
  3920.     -- Null characters are not transmitted and indicate the end of data.
  3921.     --
  3922.     ------------------------------------------------------------
  3923.         Start           : BIT_COUNT_16_TYPE := 5;
  3924.         Command_length  : BIT_COUNT_32_TYPE;
  3925.         Argument_index  : BIT_COUNT_16_TYPE := Argument'FIRST;
  3926.         Telnet_status    : Ftp_telnet.telnet_status_spec;
  3927.         Command_string    : Command_types.command_string_spec := 
  3928.                                     Command_types.null_command_string;
  3929.     BEGIN
  3930.         Command_length := 4;
  3931.         CASE Ftp_types.valid_command_spec'( Command ) IS
  3932.             WHEN Ftp_types.noop_command => 
  3933.                 Command_string(1..4) := "NOOP";
  3934.             WHEN Ftp_types.help_command => 
  3935.                 Command_string(1..4) := "HELP";
  3936.             WHEN Ftp_types.stru_command => 
  3937.                 Command_string(1..4) := "STRU";
  3938.             WHEN Ftp_types.type_command => 
  3939.                 Command_string(1..4) := "TYPE";
  3940.             WHEN Ftp_types.mode_command => 
  3941.                 Command_string(1..4) := "MODE";
  3942.             WHEN FTP_TYPES.PORT_COMMAND => 
  3943.                 Command_string(1..4) := "PORT";
  3944.             WHEN Ftp_types.quit_command => 
  3945.                 Command_string(1..4) := "QUIT";
  3946.             WHEN Ftp_types.user_command => 
  3947.                 Command_string(1..4) := "USER";
  3948.             WHEN FTP_TYPES.PASS_COMMAND => 
  3949.                 Command_string(1..4) := "PASS";
  3950.             WHEN Ftp_types.stor_command => 
  3951.                 Command_string(1..4) := "STOR";
  3952.             WHEN FTP_TYPES.RETR_COMMAND => 
  3953.                 Command_string(1..4) := "RETR";
  3954.             WHEN Ftp_types.reply_command =>
  3955.                 Start := 1;
  3956.                 Command_length := 0;
  3957.             WHEN OTHERS => 
  3958.                 Ftp_terminal_driver.output_message_with_new_line
  3959.                     (" Can't send that command over telnet");
  3960.                 Status := Xmit_failed;
  3961.                 Return;
  3962.         END CASE;
  3963.         -- My_debug_io.put_line (" ~~ Sending command ~~");
  3964.         -- My_debug_io.put('*');
  3965.         -- My_debug_io.put( Command_string );
  3966.         -- My_debug_io.put_line ("*");
  3967.         Ftp_telnet.load_telnet_transmission_buffer
  3968.             ( Telnet_status, 
  3969.               Command_length,
  3970.               Command_string,
  3971.               Argument );
  3972.         IF Ftp_telnet.telnet_was_successful ( Telnet_status ) THEN
  3973.             -- My_debug_io.put_line (" ~~ Command send successful ~~");
  3974.             Status := Xmit_successful;
  3975.         ELSE
  3976.             -- My_debug_io.put_line (" ~~ Command send failed ~~");
  3977.             Status := Xmit_failed;
  3978.         END IF;
  3979.     EXCEPTION
  3980.         WHEN OTHERS =>
  3981.             Ftp_terminal_driver.output_message_with_new_line
  3982.                 (" Unknown exception in Send_command_over_telnet");
  3983.             RAISE;
  3984.     END Send_command_over_telnet;
  3985.  
  3986.   PROCEDURE Set_command_status
  3987.                 ( Input_status : IN Ftp_rcv_utils.return_status_spec;
  3988.                   Output_status: OUT Command_status_spec ) IS
  3989.     BEGIN
  3990.         IF Ftp_rcv_utils.argument_list_is_valid( Input_status ) THEN
  3991.             Output_status := Valid_argument_list;
  3992.         ELSIF Ftp_rcv_utils.one_parameter_is_missing( Input_status ) THEN
  3993.             Output_status := One_parameter_missing;
  3994.         ELSIF Ftp_rcv_utils.two_parameters_are_missing( Input_status ) THEN
  3995.             Output_status := Two_parameters_missing;
  3996.         ELSIF Ftp_rcv_utils.optional_parameter_was_omitted( Input_status ) THEN
  3997.             Output_status := Optional_parameter_omitted;
  3998.         ELSE
  3999.             OUTPUT_STATUS := INVALID_ARGUMENT_LIST;
  4000.         END IF;
  4001.     EXCEPTION
  4002.         WHEN OTHERS => RAISE;
  4003.     END Set_command_status;
  4004.  
  4005.   PROCEDURE Get_first_argument_from_argument_list
  4006.                 ( Argument    : IN Ftp_types.argument_list ;
  4007.                   Parameter   : OUT Ftp_types.argument_list ) IS
  4008.         Offset : BIT_COUNT_16_TYPE := Parameter'FIRST;
  4009.     BEGIN
  4010.         FOR Index IN Argument'RANGE LOOP
  4011.             IF Argument( Index ) = Ftp_types.argument_list_unit'(' ') THEN
  4012.                 EXIT;
  4013.             ELSE
  4014.                 Parameter( Offset ) := Argument( Index );
  4015.                 Offset := Offset + 1;
  4016.             END IF;
  4017.         END LOOP;
  4018.     EXCEPTION
  4019.         WHEN OTHERS =>
  4020.             Ftp_terminal_driver.output_message_with_new_line
  4021.                     (" Unknown error in get_first_parameter");
  4022.             RAISE;
  4023.     END Get_first_argument_from_argument_list;
  4024.  
  4025.   PROCEDURE Get_second_argument_from_argument_list
  4026.             ( Argument : IN Ftp_types.argument_list ;
  4027.               Parameter: OUT Ftp_types.argument_list) is
  4028.         Offset : BIT_COUNT_16_TYPE := Parameter'FIRST;
  4029.         Start  : BIT_COUNT_16_TYPE := 0;
  4030.     BEGIN
  4031.         --
  4032.         -- SKIP FIRST PARAMETER
  4033.         --
  4034.         FOR Index IN Argument'RANGE LOOP
  4035.             IF Argument( Index ) = ' ' THEN
  4036.                 EXIT;
  4037.             ELSE
  4038.                 Start := Index ;
  4039.             END IF;
  4040.         END LOOP;
  4041.         Start := Start + 2;
  4042.         --
  4043.         -- GET THE SECOND PARAMETER
  4044.         --
  4045.         FOR Index IN Start .. Argument'LAST LOOP
  4046.             IF Argument( Index ) = ' ' THEN
  4047.                 EXIT;
  4048.             ELSE
  4049.                 Parameter( Offset ) := Argument( Index );
  4050.                 Offset := Offset + 1;
  4051.             END IF;
  4052.         END LOOP;
  4053.     EXCEPTION
  4054.         WHEN OTHERS =>
  4055.             Ftp_terminal_driver.output_message_with_new_line
  4056.                 (" Unknown error in GET_SECOND_PARAMETER");
  4057.             RAISE;
  4058.     END Get_second_argument_from_argument_list;
  4059.  
  4060.   PROCEDURE Validate_server_command
  4061.                     ( Local_status   : IN Ftp_rcv_utils.return_status_spec;
  4062.                       Command_status : OUT Command_status_spec;
  4063.                       Command        : IN OUT Ftp_types.valid_command_spec ) IS
  4064.     BEGIN
  4065.         IF Ftp_rcv_utils.argument_list_is_valid( Local_status ) THEN 
  4066.             Command_status := Valid_argument_list;
  4067.         ELSIF ( Command = Ftp_types.user_command)
  4068.                             AND THEN
  4069.               ( Ftp_rcv_utils.optional_parameter_was_omitted( Local_status ))
  4070.             THEN
  4071.                 Command_status := Valid_argument_list;
  4072.         ELSIF ( Command =  Ftp_types.type_command )
  4073.                             AND THEN
  4074.               ( Ftp_rcv_utils.optional_parameter_was_omitted( Local_status ))
  4075.             THEN
  4076.                 Command_status := Valid_argument_list;
  4077.         ELSIF ( Command = Ftp_types.help_command )
  4078.                             AND THEN
  4079.               ( Ftp_rcv_utils.optional_parameter_was_omitted( Local_status ))
  4080.             THEN
  4081.                 Command_status := Valid_argument_list;
  4082.         ELSIF    ( ( Command = Ftp_types.stor_command )
  4083.                         OR ELSE
  4084.                    ( Command = Ftp_types.retr_command ) )
  4085.                         AND THEN
  4086.                    ( Ftp_rcv_utils.one_parameter_is_missing( Local_status ))
  4087.             THEN
  4088.                 Command_status := Valid_argument_list;
  4089.         ELSE
  4090.                 Command_status := Invalid_argument_list; 
  4091.         END IF;
  4092.     EXCEPTION
  4093.         WHEN OTHERS =>
  4094.             Ftp_terminal_driver.output_message_with_new_line
  4095.                         (" Unknown error in Validate_server_command");
  4096.             RAISE;
  4097.     END Validate_server_command;
  4098.  
  4099.   PROCEDURE Get_command_from_telnet 
  4100.                         ( Command_status : OUT Command_status_spec;
  4101.                  Command        : OUT Ftp_types.valid_command_spec;
  4102.                  Argument       : OUT Ftp_types.argument_list ) IS
  4103.         Input_data_length : BIT_COUNT_16_TYPE ;
  4104.         Local_status      : Ftp_rcv_utils.return_status_spec;
  4105.         Ftp_telnet_status : Ftp_telnet.telnet_status_spec;
  4106.         Input_data        : Command_types.command_string_spec :=
  4107.                                 Command_types.null_command_string;
  4108.         temp_command : ftp_types.valid_command_spec;
  4109.     BEGIN
  4110.         Ftp_telnet.get_data_from_telnet_buffer( Ftp_telnet_status, Input_data);
  4111.         -- My_debug_io.PUT_LINE (" Data from telnet is ");
  4112.         -- My_debug_io.PUT ('*');
  4113.         -- My_debug_io.PUT ( INPUT_DATA );
  4114.         -- My_debug_io.PUT_LINE ("*");
  4115.         Ftp_rcv_utils.get_command_from_command_string
  4116.                     ( Local_status, Input_data, temp_command, Argument );
  4117.         Validate_server_command ( Local_status, Command_status, temp_command);
  4118.         command := temp_command;
  4119.     EXCEPTION
  4120.         WHEN OTHERS =>
  4121.              Ftp_terminal_driver.output_message_with_new_line
  4122.                 (" Unknown exception in Get_Command_From_Telnet");
  4123.             Temp_command := Ftp_types.invalid_command;
  4124.             Command := Temp_command;
  4125.             RAISE;
  4126.           END Get_command_from_telnet;
  4127.  
  4128.   PROCEDURE Get_command_from_keyboard
  4129.               ( Command_status : OUT Command_status_spec;
  4130.                 Command        : OUT Ftp_types.valid_command_spec;
  4131.                 Argument       : OUT Ftp_types.argument_list ) IS
  4132.         Local_status    : Ftp_rcv_utils.return_status_spec;
  4133.         Input_data      : Command_types.command_string_spec :=
  4134.                         Command_types.null_command_string;
  4135.     BEGIN
  4136.         Ftp_terminal_driver.get_command_from_keyboard ( Input_data );
  4137.         Ftp_rcv_utils.get_command_from_command_string
  4138.                 ( Local_status, Input_data, Command, Argument );
  4139.         Set_command_status ( Local_status, Command_status );
  4140.     EXCEPTION
  4141.         WHEN OTHERS =>
  4142.             Ftp_terminal_driver.output_message_with_new_line
  4143.                   (" Unknown exception in Get_Command_From_Keyboard");
  4144.             RAISE;
  4145.     END Get_command_from_keyboard;
  4146.  
  4147.   FUNCTION Command_is_valid( Status : IN Command_status_spec ) RETURN BOOLEAN IS
  4148.     BEGIN
  4149.         IF Status = Valid_command THEN
  4150.                 RETURN TRUE;
  4151.         ELSE
  4152.                 RETURN FALSE;
  4153.         END IF;
  4154.     EXCEPTION
  4155.             WHEN OTHERS => RAISE;
  4156.     END Command_is_valid;
  4157.  
  4158.   FUNCTION Argument_list_is_valid
  4159.                 ( Status : IN Command_status_spec ) RETURN BOOLEAN IS
  4160.     BEGIN
  4161.         IF Status = Valid_argument_list THEN
  4162.             RETURN TRUE;
  4163.         ELSE
  4164.             RETURN FALSE;
  4165.         END IF;
  4166.     EXCEPTION
  4167.         WHEN OTHERS => RAISE;
  4168.     END Argument_list_is_valid;
  4169.  
  4170.   FUNCTION One_parameter_is_missing
  4171.                 ( Status : IN Command_status_spec ) RETURN BOOLEAN IS
  4172.     BEGIN
  4173.             IF Status = One_parameter_missing THEN
  4174.                 RETURN TRUE;
  4175.             ELSE
  4176.                 RETURN FALSE;
  4177.             END IF;
  4178.     EXCEPTION
  4179.         WHEN OTHERS => RAISE;
  4180.     END One_parameter_is_missing;
  4181.  
  4182.   FUNCTION Two_parameters_are_missing
  4183.                 ( Status : IN Command_status_spec ) RETURN BOOLEAN IS
  4184.     BEGIN
  4185.             IF Status = Two_parameters_missing THEN
  4186.                 RETURN TRUE;
  4187.             ELSE
  4188.                 RETURN FALSE;
  4189.             END IF;
  4190.     EXCEPTION
  4191.             WHEN OTHERS => RAISE;
  4192.     END TWO_PARAMETERS_ARE_MISSING;
  4193.  
  4194.   FUNCTION Argument_list_is_invalid
  4195.                 ( Status : IN Command_status_spec ) RETURN BOOLEAN IS
  4196.     BEGIN
  4197.             IF Status = Valid_argument_list 
  4198.                     OR ELSE
  4199.                Status = Optional_parameter_omitted THEN
  4200.                 RETURN FALSE;
  4201.             ELSE
  4202.                 RETURN TRUE;
  4203.             END IF;
  4204.     EXCEPTION
  4205.             WHEN OTHERS => RAISE;
  4206.     END Argument_list_is_invalid;
  4207.  
  4208. BEGIN
  4209.     NULL;
  4210. EXCEPTION
  4211.         WHEN OTHERS =>
  4212.             Ftp_terminal_driver.output_message_with_new_line
  4213.                 (" Unknown exception in FTP_COMMAND_UTILITIES");
  4214.             RAISE;
  4215. END Ftp_command_utilities ;
  4216. --::::::::::::::
  4217. --mycnvt_.ada
  4218. --::::::::::::::
  4219. -----------------------------------------------------------------------
  4220. --
  4221. --         DoD Protocols    NA-00005-200       80-01120-100(-)
  4222. --         E-Systems, Inc.  August 07, 1985
  4223. --
  4224. --         MYCNVT_.ADA       Author : Mark Volpe
  4225. --
  4226. -----------------------------------------------------------------------
  4227. -- FILE : MYCNVT               AUTHOR : MIKE THOMAS
  4228.  
  4229. -- 5/17/85    8:06 AM : REVISED FOR USE WITH DEC COMPILER 
  4230. --                       OLD CODE (TELESOFT) MARKED WITH --&MT
  4231.  
  4232. -- 5/30/85    10:55 AM : REVISED FOR USE WITH TELESOFT COMPILER
  4233. --                       OLD CODE (DEC) MARKED WITH --&MT
  4234.  
  4235. -- 5/30/85    11:45 AM : REVISED FOR USE WITH THE DEC COMPILER
  4236. --                       OLD CODE (TELESOFT) MARKED WITH --&MT
  4237.  
  4238. WITH SYSTEM, UNCHECKED_CONVERSION;
  4239.  
  4240. --&MT THE FOLLOWING LINE WAS ADDED TO ALLOW PACKAGE MYCNVT TO ACCESS TEXT_IO.
  4241. WITH TEXT_IO;
  4242.  
  4243. PACKAGE MY_CONVERSIONS IS
  4244.  
  4245. --&MT SUBTYPE BIT_COUNT_16_TYPE IS INTEGER;
  4246.       SUBTYPE BIT_COUNT_16_TYPE IS SHORT_INTEGER;
  4247.  
  4248. --&MT THE FOLLOWING LINE SHOULD BE DELETED WHEN USING TELESOFT :
  4249. PACKAGE INT_IO IS NEW TEXT_IO.INTEGER_IO(BIT_COUNT_16_TYPE);
  4250.  
  4251.     FUNCTION Char ( In_integer : BIT_COUNT_16_TYPE ) RETURN CHARACTER;
  4252.     FUNCTION Byte IS NEW Unchecked_conversion ( CHARACTER, BIT_COUNT_16_TYPE );
  4253. END MY_CONVERSIONS;
  4254.  
  4255. --::::::::::::::
  4256. --mycnvt.ada
  4257. --::::::::::::::
  4258. -----------------------------------------------------------------------
  4259. --
  4260. --         DoD Protocols    NA-00005-200       80-01121-100(-)
  4261. --         E-Systems, Inc.  August 07, 1985
  4262. --
  4263. --         MYCNVT.ADA       Author : Mark Volpe
  4264. --
  4265. -----------------------------------------------------------------------
  4266. -- FILE : MYCNVT               AUTHOR : MIKE THOMAS
  4267.  
  4268. -- 5/17/85    8:06 AM : REVISED FOR USE WITH DEC COMPILER 
  4269. --                       OLD CODE (TELESOFT) MARKED WITH --&MT
  4270.  
  4271. -- 5/30/85    10:55 AM : REVISED FOR USE WITH TELESOFT COMPILER
  4272. --                       OLD CODE (DEC) MARKED WITH --&MT
  4273.  
  4274. -- 5/30/85    11:48 AM : REVISED FOR USE WITH THE DEC COMPILER
  4275. --                       OLD CODE (TELESOFT) MARKED WITH --&MT
  4276.  
  4277. PACKAGE BODY MY_CONVERSIONS IS
  4278.  
  4279.     FUNCTION Convert_integer_to_character IS 
  4280.             NEW Unchecked_conversion ( BIT_COUNT_16_TYPE, CHARACTER );
  4281.  
  4282.     FUNCTION Char ( In_integer : BIT_COUNT_16_TYPE ) RETURN CHARACTER IS
  4283.             Byte_string : STRING (1..2);
  4284.  
  4285.         BEGIN
  4286.             Byte_string(1) := Convert_integer_to_character ( In_integer );
  4287.             RETURN Byte_string(1);
  4288.         END CHAR;
  4289.  
  4290. END MY_CONVERSIONS;
  4291. --::::::::::::::
  4292. --ftplowio_.ada
  4293. --::::::::::::::
  4294. -----------------------------------------------------------------------
  4295. --
  4296. --         DoD Protocols    NA-00005-200       80-01080-100(-)
  4297. --         E-Systems, Inc.  August 07, 1985
  4298. --
  4299. --         FTPLOWIO_.ADA       Author : Mark Volpe
  4300. --
  4301. -----------------------------------------------------------------------
  4302. -- FILE : FTPLOWIO               AUTHOR : MARK VOLPE
  4303.  
  4304. -- 5/30/85    2:40 PM  : REVISED FOR USE WITH THE DEC COMPILER
  4305. --                       OLD CODE (TELESOFT) MARKED WITH --&MT
  4306. -- 7/23/85    3:52 PM  : mods to global variables
  4307.  
  4308. --&MT THE FOLLOWING LINE SHOULD BE DELETED WHEN USING DEC ADA :
  4309. --&MT PRAGMA SOURCE_INFO ( ON );
  4310.  
  4311. WITH My_debug_io, My_utilities;
  4312. WITH Ftp_terminal_driver, Command_types;
  4313.  
  4314. --&MT THE FOLLOWING LINE SHOULD BE INCLUDED WHEN USING TELESOFT :
  4315. --&MT WITH ASCII;
  4316.  
  4317. WITH SYSTEM, SEQUENTIAL_IO, TEXT_IO, MY_CONVERSIONS;
  4318.  
  4319. USE SYSTEM,TEXT_IO;
  4320.  
  4321. --&MT THE FOLLOWING LINE SHOULD BE INCLUDED WHEN USING TELESOFT :
  4322. --&MT USE INTEGER_IO;
  4323.  
  4324. PACKAGE Ftp_low_level_io IS
  4325.  
  4326. --&MT SUBTYPE BIT_COUNT_32_TYPE IS LONG_INTEGER;
  4327.       SUBTYPE BIT_COUNT_32_TYPE IS INTEGER;
  4328.  
  4329. --&MT SUBTYPE BIT_COUNT_16_TYPE IS INTEGER;
  4330.       SUBTYPE BIT_COUNT_16_TYPE IS SHORT_INTEGER;
  4331.  
  4332. --&MT SUBTYPE BIT_COUNT_8_TYPE IS SYSTEM.BYTE;
  4333.       SUBTYPE BIT_COUNT_8_TYPE IS SYSTEM.UNSIGNED_BYTE;
  4334.  
  4335. --&MT THE FOLLOWING LINES SHOULD BE DELETED WHEN USING TELESOFT :
  4336.   PACKAGE LONG_INT IS NEW TEXT_IO.INTEGER_IO(BIT_COUNT_32_TYPE);
  4337.   PACKAGE INT_IO IS NEW TEXT_IO.INTEGER_IO(BIT_COUNT_16_TYPE);
  4338.   PACKAGE SYSTEM_BYTE IS NEW TEXT_IO.INTEGER_IO(BIT_COUNT_8_TYPE);
  4339.  
  4340.   End_of_file           : EXCEPTION;
  4341.   Error_closing_file    : EXCEPTION;
  4342.   Error_creating_file   : EXCEPTION;
  4343.   Error_opening_file    : EXCEPTION;
  4344.   File_read_error       : EXCEPTION;
  4345.   File_size_error       : EXCEPTION; -- Couldn't get # of blks in file
  4346.   File_write_error      : EXCEPTION;
  4347.   Record_size_error     : EXCEPTION; -- Record too big
  4348.  
  4349. --&MT SUBTYPE Block_index_spec IS BIT_COUNT_16_TYPE;
  4350.       SUBTYPE Block_index_spec IS BIT_COUNT_32_TYPE;
  4351.  
  4352.   TYPE Block_spec IS ARRAY(1..128) OF BIT_COUNT_8_TYPE;
  4353.   Block_size            : CONSTANT BIT_COUNT_16_TYPE := Block_spec'LENGTH;
  4354.  
  4355. --&MT   Start_of_block        : CONSTANT BIT_COUNT_16_TYPE := Block_spec'FIRST;
  4356.   Start_of_block        : CONSTANT BIT_COUNT_32_TYPE := Block_spec'FIRST;
  4357.  
  4358. --&MT End_of_block          : BIT_COUNT_16_TYPE ;
  4359.   End_of_block          : BIT_COUNT_32_TYPE ;
  4360.  
  4361.   Output_block          : Block_spec;
  4362.   Input_block           : Block_spec;
  4363.  
  4364.   TYPE Record_SPEC IS ARRAY (0..132) OF BIT_COUNT_8_TYPE ; -- contains record data
  4365.  
  4366. --&MT Start_of_record      : CONSTANT BIT_COUNT_16_TYPE := Record_spec'FIRST;
  4367.   Start_of_record      : CONSTANT BIT_COUNT_32_TYPE := Record_spec'FIRST;
  4368.  
  4369. --&MT End_of_record        : BIT_COUNT_16_TYPE ;
  4370.   End_of_record        : BIT_COUNT_32_TYPE ;
  4371.  
  4372.   Record_size          : CONSTANT BIT_COUNT_16_TYPE := Record_spec'LENGTH;
  4373.   Input_record         : Record_SPEC;
  4374.   Output_record        : Record_SPEC;
  4375.  
  4376.   FUNCTION Current_data_is_eof_marker 
  4377.             ( Data_byte : IN BIT_COUNT_8_TYPE ) RETURN BOOLEAN;
  4378.  
  4379.   FUNCTION Current_data_is_eor_marker 
  4380.             ( Data_byte : IN BIT_COUNT_8_TYPE ) RETURN BOOLEAN;
  4381.  
  4382.   PROCEDURE Find_out_if_user_wants_data_echoed_to_screen_during_transfer;
  4383.  
  4384.   PROCEDURE Open_input_file ( File_name : IN STRING );
  4385.     ----------------------------------------------------------------------
  4386.     --
  4387.     -- This procedure opens the file and sets the system up ready to get 
  4388.     -- the first record
  4389.     --
  4390.     -- Exceptions: Error_opening_file.
  4391.     -- NOTE: May raise Error_closing_file if an exception occurs while 
  4392.     --       accessing the file after it has been opened but before the
  4393.     --       procedure returns to the calling routine.
  4394.     ----------------------------------------------------------------------
  4395.  
  4396.   PROCEDURE Create_output_file ( File_name : IN STRING );
  4397.     ----------------------------------------------------------------------
  4398.     --
  4399.     -- This procedure creates the file and sets the system up ready to 
  4400.     -- store data.
  4401.     --
  4402.     -- Exceptions: Error_creating_file.
  4403.     ----------------------------------------------------------------------
  4404.  
  4405.   PROCEDURE Close_output_file;
  4406.     ----------------------------------------------------------------------
  4407.     --
  4408.     -- This procedure closes the output file
  4409.     --
  4410.     -- Exceptions: Error_closing_file.
  4411.     ----------------------------------------------------------------------
  4412.  
  4413.   PROCEDURE Close_input_file;
  4414.     ----------------------------------------------------------------------
  4415.     --
  4416.     -- This procedure closes a file
  4417.     --
  4418.     -- Exceptions: Error_closing_file.
  4419.     ----------------------------------------------------------------------
  4420.  
  4421.   PROCEDURE Write_record_to_output_file;
  4422.     ----------------------------------------------------------------------
  4423.     --
  4424.     -- This procedure writes the next record to the output file from 
  4425.     -- output_record.
  4426.     --
  4427.     -- Exceptions: End_of_file, File_write_error.
  4428.     ----------------------------------------------------------------------
  4429.  
  4430.   PROCEDURE Read_record_from_input_file;
  4431.     ----------------------------------------------------------------------
  4432.     --
  4433.     -- This procedure gets the next record from the input file and stores 
  4434.     -- it in Input_record.
  4435.     --
  4436.     -- Exceptions: End_of_file, File_read_error.
  4437.     ----------------------------------------------------------------------
  4438.  
  4439.   PROCEDURE Read_block_from_input_file;
  4440.     ----------------------------------------------------------------------
  4441.     --
  4442.     -- This procedure gets the next block from the specified file and stores
  4443.     -- it in Input_block.
  4444.     --
  4445.     -- Exceptions: End_of_file, File_read_error.
  4446.     ----------------------------------------------------------------------
  4447.  
  4448.   PROCEDURE Write_block_to_output_file;
  4449.     ----------------------------------------------------------------------
  4450.     --
  4451.     -- This procedure writes Output_block as the next block in the output_file
  4452.     --
  4453.     -- Exceptions: File_write_error.
  4454.     ----------------------------------------------------------------------
  4455.  
  4456. END Ftp_low_level_io;
  4457.  
  4458. --::::::::::::::
  4459. --ftplowio.ada
  4460. --::::::::::::::
  4461. -----------------------------------------------------------------------
  4462. --
  4463. --         DoD Protocols    NA-00005-200       80-01081-100(-)
  4464. --         E-Systems, Inc.  August 07, 1985
  4465. --
  4466. --         FTPLOWIO.ADA       Author : Mark Volpe
  4467. --
  4468. -----------------------------------------------------------------------
  4469. -- FILE : FTPLOWIO               AUTHOR : MARK VOLPE
  4470.  
  4471. -- 5/20/85    2:51 PM  : REVISED FOR USE WITH THE DEC COMPILER
  4472. --                       OLD CODE (TELESOFT) MARKED WITH --&MT
  4473. -- 7/23/85    10:47 AM : mods for text_io from sequential_io
  4474. -- 7/23/85    3:15 PM  : mods for global variables
  4475. --            7:03 PM  : changes to read record and read block
  4476. --           10:00 PM  : look for cr in write block
  4477. -- 7/24/85    1:45 AM  : don't do new_line in write block, just the CR
  4478. --            2:32 AM  : remove some debug stm
  4479.  
  4480. PACKAGE BODY Ftp_low_level_io IS
  4481. --    PACKAGE Ftp_io is new SEQUENTIAL_IO( BIT_COUNT_8_TYPE );
  4482.     -- PACKAGE Ftp_io renames text_io;
  4483.  
  4484. --&MT Block_index             : BIT_COUNT_16_TYPE    := Start_of_block;
  4485.     Block_index             : BIT_COUNT_32_TYPE    := Start_of_block;
  4486.  
  4487.     Data_echoing_is_desired : BOOLEAN              := TRUE; -- Debugging
  4488.     Ending_index            : BIT_COUNT_16_TYPE;
  4489.     Eof_indicator           : BIT_COUNT_8_TYPE     := 16#FF#;
  4490.     Eor_indicator           : BIT_COUNT_8_TYPE     := 16#0D#;
  4491.     Horizontal_tab          : CONSTANT BIT_COUNT_8_TYPE := 16#09#;
  4492.     Input_file              : TEXT_io.file_type;
  4493.     Input_record_index      : BIT_COUNT_16_TYPE    := 1;
  4494.     Next_byte               : BIT_COUNT_8_TYPE;
  4495.     Null_byte               : BIT_COUNT_8_TYPE     := 16#00#;
  4496.     Null_line_indicator     : BIT_COUNT_8_TYPE     := 16#00#;
  4497.     Number_of_bytes_in_buffer           : BIT_COUNT_16_TYPE;
  4498.     Number_of_bytes_in_line             : BIT_COUNT_16_TYPE;
  4499.     Number_of_header_blocks             : BIT_COUNT_16_TYPE  := 0;
  4500.     Number_of_trailing_carriage_returns : BIT_COUNT_16_TYPE  := 0;
  4501.     Output_file                         : Text_io.file_type;
  4502.     Ready_to_move_to_next_line          : BOOLEAN           := TRUE;
  4503.     Starting_index                      : BIT_COUNT_16_TYPE;
  4504.  
  4505.   FUNCTION Current_data_is_eof_marker 
  4506.             ( Data_byte : IN BIT_COUNT_8_TYPE ) RETURN BOOLEAN IS
  4507.   BEGIN
  4508.     RETURN data_byte = eof_indicator ;
  4509.   END Current_data_is_eof_marker ;
  4510.  
  4511.   FUNCTION Current_data_is_eor_marker 
  4512.             ( Data_byte : IN BIT_COUNT_8_TYPE ) RETURN BOOLEAN IS
  4513.   BEGIN
  4514.     RETURN data_byte = eor_indicator ;
  4515.   END Current_data_is_eor_marker ;
  4516.  
  4517.  
  4518.   PROCEDURE Find_out_if_user_wants_data_echoed_to_screen_during_transfer IS
  4519.         Reply : STRING (1..3);
  4520.  
  4521.   --&MT Reply_length : BIT_COUNT_16_TYPE;
  4522.         Reply_length : BIT_COUNT_32_TYPE;
  4523.  
  4524.     BEGIN
  4525.         Ftp_terminal_driver.output_message (" Echo data (Y/N)? ");
  4526.         TEXT_IO.GET_LINE ( Reply, Reply_length );
  4527.         IF Reply ( Reply'FIRST ) = 'Y'
  4528.                      OR ELSE
  4529.            Reply ( Reply'FIRST ) = 'y'
  4530.         THEN 
  4531.             Data_echoing_is_desired := TRUE;
  4532.         ELSE
  4533.             Data_echoing_is_desired := FALSE;
  4534.         END IF;
  4535.         Ftp_terminal_driver.new_line;
  4536.     END Find_out_if_user_wants_data_echoed_to_screen_during_transfer;
  4537.  
  4538.  
  4539.  
  4540.  
  4541. --MT   PROCEDURE Null_fill_input_block IS
  4542. --MT     BEGIN
  4543. --MT         -- MY_DEBUG_IO.PUT_LINE (" ~~ Null filling input block ~~");
  4544. --MT         FOR Index IN 1..Input_Block_Size LOOP
  4545. --MT             Input_block ( Index ) := 16#00#;
  4546. --MT         END LOOP;
  4547. --MT         -- MY_DEBUG_IO.PUT_LINE (" ~~ Input block has been null filled ~~");
  4548. --MT     EXCEPTION
  4549. --MT         WHEN OTHERS => RAISE;
  4550. --MT     END Null_fill_input_block ;
  4551.  
  4552. --MT   PROCEDURE Null_fill_input_record IS
  4553. --MT     BEGIN
  4554. --MT         FOR Index IN 1..Input_Record_Size LOOP
  4555. --MT             Input_record ( Index ) := Null_byte;
  4556. --MT         END LOOP;
  4557. --MT     EXCEPTION
  4558. --MT         WHEN OTHERS => RAISE;
  4559. --MT     END Null_fill_input_record ;
  4560.  
  4561. --MT   PROCEDURE Skip_header_blocks IS
  4562. --MT         Blocks_skipped : BIT_COUNT_16_TYPE := 0;
  4563. --MT     BEGIN
  4564. --MT         WHILE Blocks_skipped < Number_of_header_blocks LOOP
  4565. --MT             Read_block_from_input_file;
  4566. --MT             Blocks_skipped := Blocks_skipped + 1;
  4567. --MT         END LOOP;
  4568. --MT     END Skip_header_blocks;
  4569.  
  4570.  
  4571.  
  4572.   PROCEDURE Open_input_file ( File_name : IN STRING ) IS
  4573.     BEGIN
  4574.         My_debug_io.put_line (" ~~ Opening file ~~");
  4575.         my_debug_io.put("open_input_file.file_name =") ;
  4576.         my_debug_io.put_line(file_name) ;
  4577.         TEXT_io.OPEN ( Input_file, TEXT_io.in_file, File_name );
  4578.         --Skip_header_blocks;
  4579.     EXCEPTION
  4580.         WHEN OTHERS => RAISE Error_opening_file;
  4581.     END Open_input_file;
  4582.  
  4583.  
  4584.  
  4585.  
  4586.   PROCEDURE Create_output_file ( File_name : IN STRING ) IS
  4587.     BEGIN
  4588.         IF Text_io.is_open ( Output_file ) THEN
  4589.             RAISE Error_creating_file;
  4590.         END IF;
  4591.         Text_io.create ( Output_file, Text_io.out_file, File_name );
  4592.     EXCEPTION
  4593.         WHEN OTHERS => RAISE Error_creating_file;
  4594.     END Create_output_file;
  4595.  
  4596.  
  4597.  
  4598.  
  4599.   PROCEDURE Close_output_file IS
  4600.     BEGIN
  4601.         IF Text_io.is_open ( Output_file ) THEN
  4602.             Text_io.close ( Output_file );
  4603.         END IF;
  4604.     EXCEPTION
  4605.         WHEN OTHERS => RAISE Error_closing_file;
  4606.     END Close_output_file;
  4607.  
  4608.  
  4609.  
  4610.  
  4611.   PROCEDURE Close_input_file IS
  4612.     BEGIN
  4613.       TEXT_io.close ( Input_file );
  4614.     EXCEPTION
  4615.         WHEN OTHERS => RAISE Error_closing_file;
  4616.     END Close_input_file;
  4617.  
  4618.  
  4619.  
  4620.  
  4621.   PROCEDURE Write_record_to_output_file IS
  4622.     Temp_byte : BIT_COUNT_8_TYPE ;
  4623.     Ch : Character;
  4624.   BEGIN
  4625.     FOR Index IN record_spec'RANGE LOOP
  4626.       Temp_byte := Output_record( Index );
  4627.       if Data_echoing_is_desired AND temp_byte /= eof_indicator THEN
  4628.         My_utilities.output_byte_to_screen ( Temp_byte );
  4629.       END IF;
  4630.       if temp_byte = eor_indicator then
  4631.         text_io.new_line(output_file) ;
  4632.         IF data_echoing_is_desired THEN
  4633.           text_io.new_line ;
  4634.         END IF ;
  4635.         Exit;
  4636.       elsif temp_byte = eof_indicator THEN 
  4637.         EXIT;
  4638.       else
  4639.         Ch := character'val(integer(temp_byte));
  4640.         Text_io.put( Output_file, Ch);
  4641.       end if;
  4642.     END LOOP;
  4643.   EXCEPTION
  4644.     WHEN OTHERS => RAISE File_write_error;
  4645.   END Write_record_to_output_file;
  4646.  
  4647.  
  4648.  
  4649.  
  4650.  
  4651.   PROCEDURE Read_record_from_input_file IS
  4652.     CH : CHARACTER ;
  4653.   BEGIN
  4654.     end_of_record := -1 ;
  4655.     IF TEXT_IO.END_OF_FILE(INPUT_FILE) THEN
  4656. --dMT      my_debug_io.put_line("end of FILE detected") ;
  4657.       end_of_record := end_of_record + 1 ;
  4658.       INPUT_RECORD(end_of_record) := Eof_indicator ; 
  4659.       RAISE End_of_file;
  4660.     END IF ;
  4661.     FOR INDEX IN record_spec'RANGE LOOP
  4662.       TEXT_IO.GET ( Input_file, CH);
  4663.       NEXT_BYTE := BIT_COUNT_8_TYPE(CHARACTER'POS(CH)) ;
  4664.  
  4665. --dMT my_debug_io.put("read_RECORD_from_input_file.next_byte=") ;
  4666. --dMT my_utilities.output_byte_to_screen(next_byte) ;
  4667. --dMT my_debug_io.put_line(" ") ;
  4668.  
  4669.       end_of_record := end_of_record + 1 ;
  4670.       Input_record ( end_of_record ) := Next_byte;
  4671.       IF Data_echoing_is_desired THEN
  4672.         My_utilities.output_byte_to_screen ( Next_byte );
  4673.       END IF;
  4674.       IF TEXT_IO.END_OF_LINE(INPUT_FILE) THEN
  4675. --dMT        my_debug_io.put_line("end of record detected") ;
  4676.         end_of_record := end_of_record + 1 ;
  4677.         INPUT_RECORD(end_of_record) := Eor_indicator ; 
  4678.         EXIT;
  4679.       END IF ;
  4680.     END LOOP;
  4681.   EXCEPTION
  4682.     WHEN OTHERS => RAISE File_read_error;
  4683.   END Read_record_from_input_file;
  4684.  
  4685.  
  4686.  
  4687.  
  4688.   PROCEDURE Read_block_from_input_file IS
  4689.     CH : CHARACTER ;
  4690.   BEGIN
  4691.     end_of_block := 0 ;
  4692.     IF TEXT_IO.END_OF_FILE(INPUT_FILE) THEN 
  4693. --dMT      MY_DEBUG_IO.PUT_LINE("END OF FILE RAISED") ;
  4694.       end_of_block := end_of_block + 1 ;
  4695.       input_block(end_of_block) := eof_indicator ;
  4696.       RAISE End_of_file; 
  4697.     END IF ;
  4698.     for Index in BLOCK_SPEC'RANGE LOOP
  4699.       TEXT_io.GET ( Input_file, CH );
  4700.       NEXT_BYTE := BIT_COUNT_8_TYPE(CHARACTER'POS(CH)) ;
  4701.  
  4702. --dMT my_debug_io.put("read_block_from_input_file.next_byte=") ;
  4703. --dMT my_utilities.output_byte_to_screen(next_byte) ;
  4704. --dMT my_debug_io.put_line(" ") ;
  4705.  
  4706.       end_of_block := end_of_block + 1 ;
  4707.       Input_block ( end_of_block ) := Next_byte;
  4708.  
  4709.       IF TEXT_IO.END_OF_LINE(INPUT_FILE) THEN
  4710. --dMT        my_debug_io.put_line("end of record detected") ;
  4711.         end_of_block := end_of_block + 1 ;
  4712.         input_block(end_of_block) := eor_indicator ;
  4713.       END IF;
  4714.       IF TEXT_IO.END_OF_FILE(INPUT_FILE) THEN
  4715.         EXIT ;
  4716.       END IF ;
  4717.     END LOOP;
  4718.   END Read_block_from_input_file;
  4719.  
  4720.  
  4721.  
  4722.  
  4723.  
  4724.  
  4725.   PROCEDURE Write_block_to_output_file is
  4726.     Temp_byte : BIT_COUNT_8_TYPE ;
  4727.     Ch : Character; 
  4728.   BEGIN
  4729.     FOR Index IN start_of_block..end_of_block LOOP
  4730.       Temp_byte := Output_block( Index );
  4731.       IF temp_byte = eof_indicator THEN 
  4732.         EXIT;
  4733.       ELSIF temp_byte = eor_indicator THEN
  4734.         text_io.new_line(output_file) ;
  4735.         IF data_echoing_is_desired THEN
  4736.           My_utilities.output_byte_to_screen ( Temp_byte );
  4737.         END IF ;
  4738.       ELSE
  4739.         Ch := character'val(integer(Temp_byte));  
  4740.         Text_io.put ( Output_file, Ch);
  4741.         IF Data_echoing_is_desired THEN
  4742.           My_utilities.output_byte_to_screen ( Temp_byte );
  4743.         END IF;
  4744.       END IF ;
  4745.     END LOOP;
  4746.   EXCEPTION
  4747.     WHEN OTHERS => RAISE File_write_error;
  4748.   END Write_block_to_output_file;
  4749.  
  4750. BEGIN
  4751.     NULL; 
  4752. END Ftp_low_level_io;
  4753. --::::::::::::::
  4754. --ftpfileio_.ada
  4755. --::::::::::::::
  4756. -----------------------------------------------------------------------
  4757. --
  4758. --         DoD Protocols    NA-00005-200       80-01078-100(-)
  4759. --         E-Systems, Inc.  August 07, 1985
  4760. --
  4761. --         FTPFILEIO_.ADA       Author : Mark Volpe
  4762. --
  4763. -----------------------------------------------------------------------
  4764. -- FILE : FTPFILEIO               AUTHOR : MARK VOLPE
  4765.  
  4766. -- 5/17/85    9:17 AM : REVISED FOR USE WITH DEC COMPILER 
  4767. --                      OLD CODE (TELESOFT) MARKED WITH --&MT  
  4768.  
  4769. -- 5/30/85    1:10 PM  : REVISED FOR USE WITH TELESOFT COMPILER
  4770. --                       OLD CODE (DEC) MARKED WITH --&MT
  4771.  
  4772. -- 5/30/85    3:12 PM  : REVISED FOR USE WITH THE DEC COMPILER
  4773. --                       OLD CODE (TELESOFT) MARKED WITH --&MT
  4774.  
  4775. WITH Ftp_low_level_io;    USE  Ftp_low_level_io;
  4776. WITH 
  4777.     My_utilities, My_debug_io, Vt100,
  4778.     SYSTEM, 
  4779.     Ftp_tcp;
  4780. USE My_utilities, Ftp_tcp;
  4781.  
  4782. PACKAGE Ftp_file_io IS
  4783.   Buffer_access_error                : EXCEPTION;
  4784.   Close_request_failed               : EXCEPTION;
  4785.   Create_request_failed              : EXCEPTION;
  4786.   Fatal_error                        : EXCEPTION;
  4787.   File_Receive_error                 : EXCEPTION;
  4788.   File_send_error                    : EXCEPTION;
  4789.   Open_request_failed                : EXCEPTION;
  4790.   Tcp_request_failed                 : EXCEPTION;
  4791.  
  4792.   PROCEDURE Find_out_if_user_wants_data_echoed_to_screen;
  4793.  
  4794.   PROCEDURE Open_input_file  ( File_name   : IN STRING );
  4795.     ----------------------------------------------------------------------
  4796.     --
  4797.     -- This procedure opens the specified file as an input file.
  4798.     --
  4799.     -- Exceptions: Open_request_failed, Error_closing_file.
  4800.     ----------------------------------------------------------------------
  4801.  
  4802.   PROCEDURE Open_output_file ( File_name   : IN STRING );
  4803.     ----------------------------------------------------------------------
  4804.     --
  4805.     -- This procedure creates the specified file as an output file.
  4806.     --
  4807.     -- Exceptions: Create_request_failed.
  4808.     ----------------------------------------------------------------------
  4809.  
  4810.   PROCEDURE Close_input_file;
  4811.     ----------------------------------------------------------------------
  4812.     --
  4813.     -- This procedure closes the input file.
  4814.     --
  4815.     -- Exceptions: Close_request_failed.
  4816.     ----------------------------------------------------------------------
  4817.  
  4818.   PROCEDURE Close_output_file;
  4819.     ----------------------------------------------------------------------
  4820.     --
  4821.     -- This procedure closes the output file.
  4822.     --
  4823.     -- Exceptions: Close_request_failed.
  4824.     ----------------------------------------------------------------------
  4825.  
  4826.   PROCEDURE Send_file_as_records
  4827.                 ( Tcp_identifier : IN OUT Ftp_tcp.tcp_identifier_spec );
  4828.     ----------------------------------------------------------------------
  4829.     --
  4830.     -- This procedure reads the current input file and loads the data
  4831.     -- into tcp buffers where they are transmitted.
  4832.     --
  4833.     -- Exceptions: File_send_error, tcp_request_failed.
  4834.     ----------------------------------------------------------------------
  4835.  
  4836.   PROCEDURE Send_file_as_stream
  4837.                 ( Tcp_identifier : IN OUT Ftp_tcp.tcp_identifier_spec );
  4838.     ----------------------------------------------------------------------
  4839.     --
  4840.     -- This procedure reads the current input file and loads the data
  4841.     -- into tcp buffers where they are transmitted.
  4842.     --
  4843.     -- Exceptions: File_send_error, tcp_request_failed.
  4844.     ----------------------------------------------------------------------
  4845.  
  4846.   PROCEDURE Receive_file_as_records
  4847.                 ( Tcp_identifier : IN OUT Ftp_tcp.tcp_identifier_spec );
  4848.     ----------------------------------------------------------------------
  4849.     --
  4850.     -- This procedure reads tcp buffers and stores them into the
  4851.     -- current output file.
  4852.     --
  4853.     -- Exceptions: Tcp_request_failed, File_receive_error.
  4854.     ----------------------------------------------------------------------
  4855.  
  4856.   PROCEDURE Receive_file_as_stream
  4857.                 ( Tcp_identifier : IN OUT Ftp_tcp.tcp_identifier_spec );
  4858.     ----------------------------------------------------------------------
  4859.     --
  4860.     -- This procedure reads the current input file and loads the data
  4861.     -- into tcp buffers where they are transmitted.
  4862.     --
  4863.     -- Exceptions: Tcp_request_failed, File_receive_error.
  4864.     ----------------------------------------------------------------------
  4865.  
  4866. END FTP_FILE_IO ;
  4867.  
  4868. --::::::::::::::
  4869. --ftpfileio.ada
  4870. --::::::::::::::
  4871. -----------------------------------------------------------------------
  4872. --
  4873. --         DoD Protocols    NA-00005-200       80-01079-100(-)
  4874. --         E-Systems, Inc.  August 07, 1985
  4875. --
  4876. --         FTPFILEIO.ADA       Author : Mark Volpe
  4877. --
  4878. -----------------------------------------------------------------------
  4879. -- FILE : FTPFILEIO               AUTHOR : MARK VOLPE
  4880.  
  4881. -- 5/30/85    3:20 PM  : REVISED FOR USE WITH THE DEC COMPILER
  4882. --                     ; OLD CODE (TELESOFT) MARKED WITH --&MT
  4883. -- 7/22/85    3:52 PM  : ENABLE DEBUG OUTPUTS
  4884. -- 7/23/85    3:09 PM  : use global data for file io
  4885. --            7:10 PM  : alter send_file_as_stream,load_record_from_tcp_buffer
  4886. --           10:10 PM  : in send_as_records load last record before push
  4887. -- 7/24/85    1:03 AM  : don't do push in send_file_as_records exc handler
  4888. --            3:08 AM  : remove some debug
  4889. --            4:44 AM  : ad delay statements after sending files to allow 
  4890. --                     ; tcp to get last data packet over
  4891.  
  4892. WITH TEXT_IO;
  4893.  
  4894. PACKAGE BODY Ftp_file_io IS
  4895.  
  4896. --&MT SUBTYPE BIT_COUNT_32_TYPE IS LONG_INTEGER;
  4897.       SUBTYPE BIT_COUNT_32_TYPE IS INTEGER;
  4898.  
  4899. --&MT SUBTYPE BIT_COUNT_16_TYPE IS INTEGER;
  4900.       SUBTYPE BIT_COUNT_16_TYPE IS SHORT_INTEGER;
  4901.  
  4902. --&MT SUBTYPE BIT_COUNT_8_TYPE IS SYSTEM.BYTE;
  4903.       SUBTYPE BIT_COUNT_8_TYPE IS SYSTEM.UNSIGNED_BYTE;
  4904.  
  4905. --&MT THE FOLLOWING LINES SHOULD BE DELETED WHEN USING TELESOFT
  4906. PACKAGE LONG_INT IS NEW TEXT_IO.INTEGER_IO(BIT_COUNT_32_TYPE);
  4907. PACKAGE INT_IO IS NEW TEXT_IO.INTEGER_IO(BIT_COUNT_16_TYPE);
  4908. PACKAGE SYSTEM_BYTE IS NEW TEXT_IO.INTEGER_IO(BIT_COUNT_8_TYPE);
  4909.  
  4910.   Null_byte               : CONSTANT BIT_COUNT_8_TYPE := 16#00#;
  4911.   Line_feed               : CONSTANT BIT_COUNT_8_TYPE := 16#0A#;
  4912.   Carriage_return         : CONSTANT BIT_COUNT_8_TYPE := 16#0D#;
  4913.   Block_index             : Block_index_spec := Start_of_block;
  4914.  
  4915. --&MT Record_index            : BIT_COUNT_16_TYPE := Start_of_record;
  4916.   Record_index            : BIT_COUNT_32_TYPE := Start_of_record;
  4917.  
  4918.   Eof_found               : EXCEPTION;
  4919.   Dummy_1                 : EXCEPTION;
  4920.   Dummy_2                 : EXCEPTION;
  4921.   Dummy_3                 : EXCEPTION;
  4922.   Dummy_4                 : EXCEPTION;
  4923.   Dummy_5                 : EXCEPTION;
  4924.   Dummy_6                 : EXCEPTION;
  4925.   Dummy_7                 : EXCEPTION;
  4926.  
  4927.   PROCEDURE Find_out_if_user_wants_data_echoed_to_screen IS
  4928.     BEGIN
  4929.         Find_out_if_user_wants_data_echoed_to_screen_during_transfer;
  4930.     END Find_out_if_user_wants_data_echoed_to_screen;
  4931.  
  4932.   PROCEDURE Open_input_file ( File_name   : IN STRING ) IS
  4933.     BEGIN
  4934.         MY_DEBUG_IO.PUT_LINE (" Opening file ");
  4935.         Ftp_low_level_io.Open_input_file ( File_name );
  4936.     EXCEPTION
  4937.         WHEN OTHERS => RAISE Open_request_failed;
  4938.     END Open_input_file;
  4939.  
  4940.   PROCEDURE Open_output_file ( File_name : IN STRING ) IS
  4941.     BEGIN
  4942.         My_debug_io.put_line (" ~~ Opening output file ~~");
  4943.         Ftp_low_level_io.Create_output_file ( File_name );
  4944.     EXCEPTION
  4945.         WHEN OTHERS => RAISE Create_request_failed; -- local error
  4946.     END Open_output_file ;
  4947.  
  4948.   PROCEDURE Close_input_file IS
  4949.     BEGIN
  4950.         MY_DEBUG_IO.PUT_LINE (" ~~ Closing input file ~~");
  4951.         Ftp_low_level_io.Close_input_file;
  4952.     EXCEPTION
  4953.         WHEN OTHERS => RAISE Close_request_failed; -- Local error
  4954.     END Close_input_file;
  4955.  
  4956.   PROCEDURE Close_output_file IS
  4957.     BEGIN
  4958.         MY_DEBUG_IO.PUT_LINE (" ~~ Closing output file ~~");
  4959.         Ftp_low_level_io.Close_output_file;
  4960.     EXCEPTION
  4961.         WHEN OTHERS => RAISE Close_request_failed; -- Local error
  4962.     END Close_output_file;
  4963.  
  4964.   PROCEDURE Load_end_of_record_indicator_into_tcp_buffer
  4965.                             ( Tcp_identifier : IN OUT Tcp_identifier_spec ) IS
  4966.     BEGIN
  4967. --MT      MY_DEBUG_IO.PUT_LINE (" Loading <EOR> ");
  4968. --MT      Load_byte_into_tcp_buffer(Tcp_identifier, Carraige_return);
  4969. --MT      Load_byte_into_tcp_buffer(Tcp_identifier, Line_feed);
  4970. --MT      Load_byte_into_tcp_buffer(Tcp_identifier, End_of_record_delimeter);
  4971.     NULL ;
  4972.     EXCEPTION
  4973.         WHEN OTHERS => RAISE Tcp_request_failed; -- local err
  4974.     END Load_end_of_record_indicator_into_tcp_buffer;
  4975.  
  4976.   PROCEDURE Load_end_of_file_indicator_into_tcp_buffer
  4977.                             ( Tcp_identifier : IN OUT Tcp_identifier_spec ) IS
  4978.     BEGIN
  4979.         MY_DEBUG_IO.PUT_LINE (" ~~ Loading <EOF> ~~");
  4980.         Load_byte_into_tcp_buffer(Tcp_identifier, BIT_COUNT_8_TYPE'( 16#F2# ));
  4981.     EXCEPTION
  4982.         WHEN OTHERS                  => RAISE Tcp_request_failed; -- local err
  4983.     END Load_end_of_file_indicator_into_tcp_buffer;
  4984.  
  4985.   PROCEDURE Load_next_record_into_tcp_buffer 
  4986.                             ( Tcp_identifier : IN OUT Tcp_identifier_spec ) IS
  4987.     BEGIN
  4988.         MY_DEBUG_IO.PUT_LINE (" Loading next record into tcp buffer ");
  4989.         FOR Local_record_index IN Start_of_record..End_of_record loop
  4990.             FTP_TCP.Load_byte_into_tcp_buffer
  4991.                     ( Tcp_identifier, Input_record( Local_record_index ));
  4992.             IF Current_data_is_eor_marker(Input_record(Local_record_index)) THEN
  4993.                 EXIT;
  4994.             END IF;
  4995.         END LOOP;
  4996. --MT        Load_end_of_record_indicator_into_tcp_buffer( Tcp_identifier );
  4997.         MY_DEBUG_IO.PUT_LINE (" Fileio requested push ");
  4998.         Push_tcp_buffer ( Tcp_identifier );
  4999.     EXCEPTION
  5000.         WHEN OTHERS => RAISE Tcp_request_failed;
  5001.     END Load_next_record_into_tcp_buffer;
  5002.  
  5003.   PROCEDURE Send_file_as_records
  5004.                     ( Tcp_identifier : IN OUT Ftp_tcp.tcp_identifier_spec ) IS
  5005.     BEGIN
  5006.         MY_DEBUG_IO.put_line (" Sending file as records ");
  5007.         LOOP
  5008.             Ftp_low_level_io.Read_record_from_input_file; -- Loads input_record
  5009.             Load_next_record_into_tcp_buffer( Tcp_identifier );
  5010.         END LOOP;
  5011.     EXCEPTION
  5012.         WHEN FTP_TCP.Tcp_request_failed =>
  5013.                 MY_DEBUG_IO.PUT_LINE (" ~~ Tcp request failed ~~");
  5014.                 RAISE Tcp_request_failed;
  5015.         WHEN Ftp_low_level_io.End_of_file |
  5016.              Ftp_low_level_io.file_read_error => 
  5017.                 MY_DEBUG_IO.PUT_LINE (" ~~ End of file found ~~");
  5018.                 Load_next_record_into_tcp_buffer( Tcp_identifier );
  5019.                 DELAY(DURATION(6)) ; -- allow time for last packet to arrive
  5020.         WHEN OTHERS =>
  5021.                 My_debug_io.put_line(" Unknown error in send file as records ");
  5022.                 RAISE File_send_error;
  5023.     END Send_file_as_records;
  5024.  
  5025.  
  5026.  
  5027.   PROCEDURE Load_next_block_into_tcp_buffer
  5028.                 ( Tcp_identifier : IN OUT Ftp_tcp.tcp_identifier_spec ) IS
  5029.     BEGIN
  5030.         MY_DEBUG_IO.PUT_LINE (" Load next block into tcp buffer ");
  5031.         FOR Local_index IN Start_of_block..End_of_block loop
  5032.             Load_byte_into_tcp_buffer
  5033.                 ( Tcp_identifier, Input_block( Local_index ));
  5034.             IF Current_data_is_eof_marker( Input_block( Local_index )) THEN
  5035.                 EXIT;
  5036.             END IF;
  5037.         END LOOP;
  5038.     EXCEPTION
  5039.         WHEN OTHERS =>
  5040.             RAISE Tcp_request_failed;
  5041.     END Load_next_block_into_tcp_buffer;
  5042.  
  5043.   PROCEDURE Send_file_as_stream
  5044.                 ( Tcp_identifier : IN OUT Ftp_tcp.tcp_identifier_spec ) IS
  5045.     BEGIN
  5046.         MY_DEBUG_IO.PUT_LINE (" Send file as stream ");
  5047.         LOOP
  5048.             Read_block_from_input_file;
  5049.             Load_next_block_into_tcp_buffer( Tcp_identifier ); 
  5050.         END LOOP;
  5051.         -- Can only exit through an exception handler
  5052.     EXCEPTION
  5053.         WHEN Ftp_low_level_io.End_of_file |
  5054.              Ftp_low_level_io.File_read_error =>
  5055.                 MY_DEBUG_IO.PUT_LINE (" ~~ End of file found ~~");
  5056.                 Load_next_block_into_tcp_buffer( Tcp_identifier ); 
  5057. --MT                Load_end_of_file_indicator_into_tcp_buffer(Tcp_identifier );
  5058.                 Push_tcp_buffer ( Tcp_identifier );
  5059.                 DELAY(DURATION(6)) ; -- allow last packet to arrive
  5060.         WHEN Tcp_request_failed =>
  5061.                 RAISE Tcp_request_failed;
  5062.         WHEN OTHERS =>
  5063.                 RAISE File_send_error;
  5064.     END Send_file_as_stream;
  5065.  
  5066. --&MT   PROCEDURE Null_fill_remainder_of_output_block IS
  5067. --&MT     BEGIN
  5068. --&MT         FOR Local_block_index IN Block_index..End_of_block LOOP
  5069. --&MT             Output_block ( Local_block_index ) := Null_byte;
  5070. --&MT         END LOOP;
  5071. --&MT     EXCEPTION
  5072. --&MT         WHEN OTHERS => RAISE;
  5073. --&MT     End Null_fill_remainder_of_output_block;
  5074.  
  5075.   PROCEDURE Load_next_block_from_tcp_buffer
  5076.    (Tcp_identifier : IN OUT Ftp_tcp.tcp_identifier_spec) IS
  5077.     Temp_byte : BIT_COUNT_8_TYPE;
  5078.   BEGIN
  5079.     end_of_block := 0 ;
  5080. --dMT    MY_DEBUG_IO.put_line (" Load next block from tcp buffer ");
  5081.     FOR Local_block_index IN block_spec'range LOOP
  5082.       Get_byte_from_tcp_buffer(Tcp_identifier, Temp_byte);
  5083.       end_of_block := end_of_block + 1 ;
  5084.       Output_block ( Local_block_index ) := Temp_byte;
  5085.       Block_index := Local_block_index; -- Save for exception handlers
  5086.       IF Current_data_is_eof_marker ( Temp_byte ) THEN
  5087.         RAISE Eof_found;
  5088.       END IF;
  5089.     END LOOP;
  5090.   EXCEPTION
  5091.     WHEN Eof_found => RAISE Eof_found;
  5092.     WHEN No_more_tcp_data => RAISE ; -- Blk index pnts to last byte of data
  5093.     WHEN OTHERS => RAISE Tcp_request_failed;
  5094.   END Load_next_block_from_tcp_buffer;
  5095.  
  5096.   PROCEDURE Receive_file_as_stream
  5097.                 ( Tcp_identifier : IN OUT Ftp_tcp.tcp_identifier_spec ) IS
  5098.     BEGIN
  5099.         MY_DEBUG_IO.put_line (" ~~ Receive file as stream ~~");
  5100.         LOOP
  5101.             Load_next_block_from_tcp_buffer( Tcp_identifier );
  5102.             Write_block_to_output_file;
  5103.         END LOOP;
  5104.     EXCEPTION
  5105.         WHEN Eof_found =>
  5106.             Write_block_to_output_file;
  5107.             Wait_for_tcp_connection_to_close ( Tcp_identifier );
  5108.         WHEN No_more_tcp_data |
  5109.              Tcp_connection_closed =>
  5110.              NULL ;
  5111.                --MT Null_fill_remainder_of_output_block;
  5112.                 -- Write_block_to_output_file;
  5113.         WHEN Tcp_request_failed => RAISE Tcp_request_failed;
  5114.         WHEN OTHERS             => RAISE File_receive_error;
  5115.     END Receive_file_as_stream;
  5116.  
  5117.   PROCEDURE Load_record_from_tcp_buffer
  5118.                 ( Tcp_identifier : IN OUT Ftp_tcp.tcp_identifier_spec ) IS
  5119.         Temp_byte : BIT_COUNT_8_TYPE;
  5120.     BEGIN
  5121. --dMT        my_debug_io.put_line (" Load record from tcp buffer ");
  5122. --dMT        my_debug_io.put (" Start of record = ");
  5123. --dMT        my_debug_io.put_Line (bit_count_16_type(Start_of_record));
  5124. --dMT        my_debug_io.put (" End of record = ");
  5125. --dMT        my_debug_io.put_Line ( bit_count_16_type(end_of_record));
  5126.         FOR Local_record_index IN record_spec'range LOOP
  5127.             Get_byte_from_tcp_buffer
  5128.                 ( Tcp_identifier, Temp_byte );
  5129.             Output_record( Local_record_index ) := Temp_byte;
  5130.             Record_index := Local_record_index;
  5131. --dMT            IF temp_byte IN 0..127 THEN
  5132. --dMT              My_debug_io.put (" Byte = ");
  5133. --dMT              My_utilities.output_byte_to_screen ( Temp_byte );
  5134. --dMT            END IF ;
  5135. --dMT            TEXT_IO.new_line;
  5136. --dMT            my_debug_io.put (" Local_record_index = ");
  5137. --dMT            my_debug_io.put (BIT_COUNT_16_TYPE(Local_record_index));
  5138.             IF Current_data_is_eor_marker( Temp_byte ) THEN
  5139. --dMT                My_debug_io.put_line(" <EOR> detected; Done with buffer ");
  5140.                 EXIT;
  5141.             ELSIF Current_data_is_eof_marker( Temp_byte ) THEN
  5142. --dMT                My_debug_io.put_line(" <EOF> detected; Done with buffer ");
  5143.                 RAISE Eof_found;
  5144.             END IF;
  5145.         END LOOP; -- Record_index points to last byte in output_record
  5146.     EXCEPTION
  5147.         WHEN Eof_found =>
  5148.                 MY_DEBUG_IO.PUT_LINE (" <EOF> exception propagating up ");
  5149.                 RAISE Eof_found;
  5150.         WHEN No_more_tcp_data => 
  5151.                 MY_DEBUG_IO.PUT_LINE (" Load_record_from_tcp_buffer failed");
  5152.                 MY_DEBUG_IO.PUT_LINE (" Raising No_more_tcp_data");
  5153.                 RAISE No_more_tcp_data;
  5154.         WHEN Tcp_request_failed  => 
  5155.                 MY_DEBUG_IO.PUT_LINE (" Load_record_from_tcp_buffer failed");
  5156.                 MY_DEBUG_IO.PUT_LINE (" Raising Tcp_request_failed ");
  5157.                 RAISE Tcp_request_failed;
  5158.         WHEN OTHERS              => 
  5159.                 MY_DEBUG_IO.PUT_LINE (" Load_record_from_tcp_buffer failed");
  5160.                 MY_DEBUG_IO.PUT_LINE (" Raising File receive error");
  5161.                 RAISE File_receive_error;
  5162.     END Load_record_from_tcp_buffer;
  5163.  
  5164.   PROCEDURE Receive_file_as_records
  5165.                 ( Tcp_identifier : IN OUT Ftp_tcp.tcp_identifier_spec ) IS
  5166.     BEGIN
  5167.         My_debug_io.put_line (" ~~ Receive file as records ~~");
  5168.         LOOP
  5169.             Load_record_from_tcp_buffer( Tcp_identifier );
  5170.             Write_record_to_output_file;
  5171.         END LOOP;
  5172.     EXCEPTION
  5173.         WHEN Eof_found =>
  5174.                 Write_record_to_output_file;
  5175.                 Wait_for_tcp_connection_to_close ( Tcp_identifier );
  5176.         WHEN No_more_tcp_data |
  5177.              Tcp_connection_closed =>
  5178.                 My_debug_io.put_line (" Receive file as records failed");
  5179.                 My_debug_io.put_line (" No more tcp data; connection closed ");
  5180.         WHEN tcp_request_failed => 
  5181.                 My_debug_io.put_line (" Receive file as records failed");
  5182.                 My_debug_io.put_line (" Raising tcp_request failed");
  5183.                 RAISE tcp_request_failed ;
  5184.         WHEN OTHERS             => 
  5185.                 My_debug_io.put_line (" Receive file as records failed");
  5186.                 My_debug_io.put_line (" Raise file receive error ");
  5187.                 RAISE File_receive_error;
  5188.     END Receive_file_as_records;
  5189.  
  5190. END Ftp_file_io ;
  5191. --::::::::::::::
  5192. --ftpsite_.ada
  5193. --::::::::::::::
  5194. -----------------------------------------------------------------------
  5195. --
  5196. --         DoD Protocols    NA-00005-200       80-01091-100(-)
  5197. --         E-Systems, Inc.  August 07, 1985
  5198. --
  5199. --         FTPSITE_.ADA       Author : Mark Volpe
  5200. --
  5201. -----------------------------------------------------------------------
  5202. -- FILE : FTPSITE               AUTHOR : MARK VOLPE
  5203.  
  5204. -- 5/17/85    10:47 AM : REVISED FOR USE WITH DEC COMPILER 
  5205. --                       OLD CODE (TELESOFT) MARKED WITH --&MT  
  5206.  
  5207. -- 5/30/85    2:35 PM  : REVISED FOR USE WITH TELESOFT COMPILER
  5208. --                       OLD CODE (DEC) MARKED WITH --&MT
  5209.  
  5210. -- 5/31/85    8 :41 AM : REVISED FOR USE WITH THE DEC COMPILER
  5211. --                       OLD CODE (TELESOFT) MARKED WITH --&MT
  5212.  
  5213. --&MT THE FOLLOWING LINE SHOULD BE DELETED WHEN USING DEC ADA :
  5214. --&MT PRAGMA SOURCE_INFO ( ON );
  5215.  
  5216. WITH Ftp_types, Ftp_terminal_driver;
  5217.  
  5218. PACKAGE Site_details IS
  5219.  
  5220.     FUNCTION Type_supported 
  5221.             ( Argument : IN FTP_TYPES.ARGUMENT_LIST ) RETURN BOOLEAN ;
  5222.         ----------------------------------------------------------------------
  5223.         --
  5224.         -- This function indicates if the specified type is implemented
  5225.         --
  5226.         ----------------------------------------------------------------------
  5227.  
  5228.     FUNCTION Print_type_supported 
  5229.             ( Argument : IN Ftp_types.argument_list ) RETURN BOOLEAN ;
  5230.         ----------------------------------------------------------------------
  5231.         --
  5232.         -- This function indicates if the specified carriage control
  5233.         --  is implemented
  5234.         --
  5235.         ----------------------------------------------------------------------
  5236.  
  5237.     FUNCTION Mode_supported 
  5238.             ( Argument : IN Ftp_types.argument_list ) RETURN BOOLEAN ;
  5239.         ----------------------------------------------------------------------
  5240.         --
  5241.         -- This function indicates if the specified mode is implemented
  5242.         --
  5243.         ----------------------------------------------------------------------
  5244.  
  5245.     FUNCTION Structure_supported 
  5246.             ( Argument : IN Ftp_types.argument_list ) RETURN BOOLEAN ;
  5247.         ----------------------------------------------------------------------
  5248.         --
  5249.         -- This function indicates if the specified structure is implemented
  5250.         --
  5251.         ----------------------------------------------------------------------
  5252.  
  5253.    FUNCTION Specified_host_is_this_host
  5254.             ( Argument : IN Ftp_types.argument_list ) RETURN BOOLEAN ;
  5255.         ----------------------------------------------------------------------
  5256.         --
  5257.         -- This function indicates if the specified host is this host
  5258.         --
  5259.         ----------------------------------------------------------------------
  5260.  
  5261. END Site_details;
  5262.  
  5263. --::::::::::::::
  5264. --ftpsite.ada
  5265. --::::::::::::::
  5266. -----------------------------------------------------------------------
  5267. --
  5268. --         DoD Protocols    NA-00005-200       80-01092-100(-)
  5269. --         E-Systems, Inc.  August 07, 1985
  5270. --
  5271. --         FTPSITE.ADA       Author : Mark Volpe
  5272. --
  5273. -----------------------------------------------------------------------
  5274. -- FILE : FTPSITE               AUTHOR : MARK VOLPE
  5275.  
  5276. -- 5/17/85    10:47 AM : REVISED FOR USE WITH DEC COMPILER 
  5277. --                       OLD CODE (TELESOFT) MARKED WITH --&MT  
  5278.  
  5279. -- 5/30/85    2:35 PM  : REVISED FOR USE WITH TELESOFT COMPILER
  5280. --                       OLD CODE (DEC) MARKED WITH --&MT
  5281.  
  5282. -- 5/31/85    8:45 AM : REVISED FOR USE WITH THE DEC COMPILER
  5283. --                      OLD CODE (TELESOFT) MARKED WITH --&MT
  5284.  
  5285. --&MT THE FOLLOWING STATEMENT WAS ADDED TO ALLOW PACKAGE FTPSITE ACCES TO
  5286. --&MT  TEXT_IO :
  5287. WITH TEXT_IO;
  5288.  
  5289. PACKAGE BODY Site_details IS
  5290.  
  5291. --&MT SUBTYPE BIT_COUNT_16_TYPE IS INTEGER;
  5292.       SUBTYPE BIT_COUNT_16_TYPE IS SHORT_INTEGER;
  5293.  
  5294. --&MT THE FOLLOWING LINES SHOULD BE DELETED WHEN USING TELESOFT
  5295.  PACKAGE INT_IO IS NEW TEXT_IO.INTEGER_IO(BIT_COUNT_16_TYPE);
  5296.  
  5297.     Ascii_type_supported    : CONSTANT BOOLEAN    := TRUE;
  5298.     Ebcdic_type_supported    : CONSTANT BOOLEAN    := FALSE;
  5299.     Image_type_supported    : CONSTANT BOOLEAN    := FALSE;
  5300.     Local_byte_type_supported    : CONSTANT BOOLEAN    := FALSE;
  5301.     Non_print_supported        : CONSTANT BOOLEAN    := TRUE;
  5302.     Telnet_supported        : CONSTANT BOOLEAN    := FALSE;
  5303.     Asa_supported        : CONSTANT BOOLEAN    := FALSE;
  5304.     File_structure_supported    : CONSTANT BOOLEAN    := TRUE;
  5305.     Record_structure_supported    : CONSTANT BOOLEAN    := TRUE;
  5306.     Page_structure_supported    : CONSTANT BOOLEAN    := FALSE;
  5307.     Stream_mode_supported    : CONSTANT BOOLEAN    := TRUE;
  5308.     Block_mode_supported    : CONSTANT BOOLEAN    := FALSE;
  5309.     Compressed_mode_supported    : CONSTANT BOOLEAN    := FALSE;
  5310.     Host_id            : CONSTANT STRING(1..8) := "1,2,3,4,";
  5311.  
  5312.   FUNCTION Specified_host_is_this_host
  5313.             ( Argument : IN Ftp_types.argument_list ) RETURN BOOLEAN  IS
  5314.         Argument_index : BIT_COUNT_16_TYPE := Argument'FIRST;
  5315.     BEGIN
  5316.         FOR Index IN Host_id'RANGE LOOP
  5317.             IF Host_id( Index ) /= Argument( Argument_index ) THEN
  5318.                 RETURN FALSE;
  5319.             ELSE
  5320.                 Argument_index := Argument_index + 1;
  5321.             END IF;
  5322.         END LOOP;
  5323.         RETURN TRUE;
  5324.     EXCEPTION
  5325.         WHEN OTHERS =>
  5326.             Ftp_terminal_driver.output_message_with_new_line
  5327.                  (" Unknown exception in Specified_Host_Is_This_Host");
  5328.             RAISE;
  5329.     END Specified_host_is_this_host;
  5330.  
  5331.   FUNCTION Type_supported 
  5332.             ( Argument : IN Ftp_types.argument_list ) RETURN BOOLEAN IS
  5333.         Return_status : BOOLEAN    := FALSE;
  5334.     BEGIN
  5335.         IF Argument( Argument'FIRST ) = 'A' THEN
  5336.                 Return_status := Ascii_type_supported;
  5337.         ELSIF Argument( Argument'first ) = 'E' THEN
  5338.                 Return_status := Ebcdic_type_supported;
  5339.         ELSIF Argument( Argument'first ) = 'I' THEN
  5340.                 Return_status := Image_type_supported;
  5341.         ELSIF Argument( Argument'first ) = 'L' THEN
  5342.                 Return_status := Local_byte_type_supported;
  5343.         ELSE
  5344.                 Return_status := FALSE;
  5345.         END IF;
  5346.         RETURN Return_status;
  5347.     EXCEPTION
  5348.         WHEN OTHERS =>
  5349.             Ftp_terminal_driver.output_message_with_new_line
  5350.                  (" Unknown exception in Type_supported");
  5351.             RAISE;
  5352.     END Type_supported;
  5353.  
  5354.   FUNCTION Print_type_supported
  5355.             ( Argument : IN Ftp_types.argument_list ) RETURN BOOLEAN IS
  5356.         Return_status : BOOLEAN    := FALSE;
  5357.     BEGIN
  5358.         IF Argument( Argument'first ) = 'N' THEN
  5359.                 Return_status := Non_print_supported;
  5360.         ELSIF Argument( Argument'first ) = 'T' THEN
  5361.                 Return_status := Telnet_supported;
  5362.         ELSIF Argument( Argument'first ) = 'C' THEN
  5363.                 Return_status := Asa_supported;
  5364.         ELSE
  5365.                 Return_status := FALSE;
  5366.         END IF;
  5367.         RETURN Return_status;
  5368.     EXCEPTION
  5369.         WHEN OTHERS =>
  5370.             Ftp_terminal_driver.output_message_with_new_line
  5371.                  (" Unknown exception in print_type_supported");
  5372.             RAISE;
  5373.     END Print_type_supported;
  5374.  
  5375.   FUNCTION Structure_supported
  5376.             ( Argument : IN Ftp_types.argument_list )  RETURN BOOLEAN IS
  5377.         Return_status    : BOOLEAN    := FALSE;
  5378.     BEGIN
  5379.             IF Argument( Argument'first ) = 'F' THEN
  5380.                 Return_status := File_structure_supported;
  5381.             ELSIF Argument( Argument'first ) = 'P' THEN
  5382.                 Return_status := Page_structure_supported;
  5383.             ELSIF Argument( Argument'first ) = 'R' THEN
  5384.                 Return_status := Record_structure_supported;
  5385.             ELSE
  5386.                 Return_status := FALSE;
  5387.             END IF;
  5388.             RETURN Return_status;
  5389.     EXCEPTION
  5390.         WHEN OTHERS =>
  5391.             Ftp_terminal_driver.output_message_with_new_line
  5392.                  (" Unknown exception in Structure_supported");
  5393.             RAISE;
  5394.     END Structure_supported;
  5395.  
  5396.   FUNCTION Mode_supported
  5397.             ( Argument : IN Ftp_types.argument_list ) RETURN BOOLEAN IS
  5398.         Return_status : BOOLEAN    := FALSE;
  5399.     BEGIN
  5400.             IF Argument( Argument'first ) = 'S' THEN
  5401.                 Return_status := Stream_mode_supported;
  5402.             ELSIF Argument( Argument'first ) = 'B' THEN
  5403.                 Return_status := Block_mode_supported;
  5404.             ELSIF Argument( Argument'first ) = 'C' THEN
  5405.                 Return_status := Compressed_mode_supported;
  5406.             ELSE
  5407.                 Return_status := FALSE;
  5408.             END IF;
  5409.             RETURN Return_status;
  5410.     EXCEPTION
  5411.         WHEN OTHERS =>
  5412.             Ftp_terminal_driver.output_message_with_new_line
  5413.                  (" Unknown exception in Mode_supported");
  5414.         RAISE;
  5415.     END Mode_supported;
  5416.  
  5417. BEGIN
  5418.     NULL;
  5419. EXCEPTION
  5420.     WHEN OTHERS =>
  5421.             Ftp_terminal_driver.output_message_with_new_line
  5422.                  (" Unknown exception in Site_details");
  5423.             RAISE;
  5424.  
  5425. END Site_details;
  5426. --::::::::::::::
  5427. --ftprpldat_.ada
  5428. --::::::::::::::
  5429. -----------------------------------------------------------------------
  5430. --
  5431. --         DoD Protocols    NA-00005-200       80-01086-100(-)
  5432. --         E-Systems, Inc.  August 07, 1985
  5433. --
  5434. --         FTPRPLDAT_.ADA       Author : Mark Volpe
  5435. --
  5436. -----------------------------------------------------------------------
  5437. -- FILE : FTPRPLDAT               AUTHOR : MARK VOLPE
  5438.  
  5439. -- 5/17/85    11:10 AM : REVISED FOR USE WITH DEC COMPILER 
  5440. --                       OLD CODE (TELESOFT) MARKED WITH --&MT  
  5441.  
  5442. -- 5/30/85    3:02 PM  : REVISED FOR USE WITH TELESOFT COMPILER
  5443. --                       OLD CODE (DEC) MARKED WITH --&MT
  5444.  
  5445. -- 5/31/85    8:55 AM : REVISED FOR USE WITH THE DEC COMPILER
  5446. --                      OLD CODE (TELESOFT) MARKED WITH --&MT
  5447.  
  5448. --&MT THE FOLLOWING LINE SHOULD BE DELETED WHEN USING DEC ADA :
  5449. --&MT PRAGMA SOURCE_INFO ( ON );
  5450.  
  5451. WITH My_debug_io, Ftp_types, Reply_types, Command_types;
  5452.  
  5453. --&MT THE FOLLOWING LINE WAS ADDED TO IMPROVE VISIBILITY OF FTP_TYPES TO
  5454. --&MT  FTPRPLDAT.
  5455. USE Ftp_types;
  5456.   
  5457. PACKAGE Ftp_reply_data IS
  5458.     ----------------------------------------------------------------------
  5459.     --
  5460.     -- This package contains the procedures necessary to find the
  5461.     -- appropriate reply message for a given reply code
  5462.     --
  5463.     ----------------------------------------------------------------------
  5464.  
  5465.     PROCEDURE Get_reply_message_for_this_reply
  5466.             ( Reply : IN Reply_types.telnet_reply_code_spec;
  5467.               Message : OUT Ftp_types.argument_list );
  5468.         ----------------------------------------------------------------------
  5469.         --
  5470.         -- This procedure gets the message for a given reply
  5471.         --
  5472.         ----------------------------------------------------------------------
  5473.  
  5474. PRIVATE
  5475.     SUBTYPE Reply_array_element IS Ftp_types.argument_list;
  5476.     Reply_array : ARRAY (1..42) OF Reply_array_element;
  5477.  
  5478. END Ftp_reply_data;
  5479.  
  5480. --::::::::::::::
  5481. --ftprpldat.ada
  5482. --::::::::::::::
  5483. -----------------------------------------------------------------------
  5484. --
  5485. --         DoD Protocols    NA-00005-200       80-01087-100(-)
  5486. --         E-Systems, Inc.  August 07, 1985
  5487. --
  5488. --         FTPRPLDAT.ADA       Author : Mark Volpe
  5489. --
  5490. -----------------------------------------------------------------------
  5491. -- FILE : FTPRPLDAT               AUTHOR : MARK VOLPE
  5492.  
  5493.  
  5494. -- 5/17/85    11:15 AM : REVISED FOR USE WITH DEC COMPILER 
  5495. --                       OLD CODE (TELESOFT) MARKED WITH --&MT  
  5496.  
  5497. -- 5/30/85    3:02 PM  : REVISED FOR USE WITH TELESOFT COMPILER
  5498. --                       OLD CODE (DEC) MARKED WITH --&MT
  5499.  
  5500. -- 5/31/85    8:59 AM : REVISED FOR USE WITH THE DEC COMPILER
  5501. --                      OLD CODE (TELESOFT) MARKED WITH --&MT
  5502.  
  5503. --&MT THE FOLLOWING LINE WAS ADDED TO PROVIDE PACKAGE FTPRPLDAT ACCESS TO 
  5504. --&MT  TEXT_IO :
  5505. WITH TEXT_IO;
  5506.  
  5507. PACKAGE BODY Ftp_reply_data IS
  5508.  
  5509. --&MT SUBTYPE BIT_COUNT_32_TYPE IS LONG_INTEGER;
  5510.       SUBTYPE BIT_COUNT_32_TYPE IS INTEGER;
  5511.  
  5512. --&MT SUBTYPE BIT_COUNT_16_TYPE IS INTEGER;
  5513.       SUBTYPE BIT_COUNT_16_TYPE IS SHORT_INTEGER;
  5514.  
  5515. --&MT THE FOLLOWING LINES SHOULD BE DELETED WHEN USING TELESOFT
  5516. PACKAGE LONG_INT IS NEW TEXT_IO.INTEGER_IO(BIT_COUNT_32_TYPE);
  5517. PACKAGE INT_IO IS NEW TEXT_IO.INTEGER_IO(BIT_COUNT_16_TYPE);
  5518.  
  5519.   PROCEDURE Get_reply_message_for_this_reply
  5520.             ( Reply : IN Reply_types.telnet_reply_code_spec;
  5521.               Message : OUT Ftp_types.argument_list ) IS
  5522.         Message_error    : EXCEPTION;
  5523.         Reply_found    : BOOLEAN := TRUE;
  5524.         Temp_message    : Ftp_types.argument_list;
  5525.     BEGIN
  5526.         Temp_message := Ftp_types.null_argument;
  5527.         FOR Index IN Reply_array'range LOOP
  5528.             FOR Offset IN 1..3 LOOP
  5529.                 IF Reply_array( Index )( bit_count_16_type(Offset) ) = 
  5530.                          Reply( bit_count_16_type(Offset)) THEN
  5531.                     NULL;
  5532.                 ELSE
  5533.                     Reply_found := FALSE;
  5534.                 END IF;
  5535.             END LOOP;
  5536.             IF Reply_found THEN
  5537.                 Temp_message := Reply_array( Index );
  5538.                 EXIT;
  5539.             ELSE
  5540.                 Reply_found := TRUE;
  5541.             END IF;
  5542.         END LOOP;
  5543.         IF Temp_message = Ftp_types.null_argument THEN
  5544.             RAISE Message_error;
  5545.         END IF;
  5546.       Message := Temp_message;
  5547.     EXCEPTION
  5548.         WHEN Message_error =>
  5549.             my_debug_io.PUT_LINE(" Illegal reply code passed to " &
  5550.                      " Get_Reply_Message_For_This_Reply");
  5551.             RAISE;
  5552.         WHEN OTHERS =>
  5553.             my_debug_io.PUT_LINE
  5554.                 (" Unknown error in Get_Reply_Message_For_This_Reply");
  5555.             RAISE;
  5556.     END Get_reply_message_for_this_reply;
  5557.  
  5558.   PROCEDURE Assign
  5559.             ( Reply        : OUT Ftp_types.argument_list;
  5560.               Message_text    : IN STRING ) IS
  5561.         Reply_index : BIT_COUNT_16_TYPE := Reply'first;
  5562.         Null_start  : BIT_COUNT_16_TYPE := Reply'first;
  5563.     BEGIN
  5564.         FOR Index IN Message_text'range LOOP
  5565.             Reply( Reply_index ) := 
  5566.                 Ftp_types.argument_list_unit'( Message_text(index));
  5567.             Reply_index := Reply_index + 1;
  5568.             Null_start  := Null_start + 1;
  5569.         END LOOP;
  5570.         FOR Index IN Null_start..reply'last LOOP
  5571.             Reply( Index ) := 
  5572.                 Ftp_types.argument_list_unit'( ASCII.NUL );
  5573.         END LOOP;
  5574.     EXCEPTION
  5575.         WHEN OTHERS =>
  5576.             my_debug_io.PUT_LINE
  5577.                 (" Unknown error in assign");
  5578.             RAISE;
  5579.     END ASSIGN;
  5580.  
  5581. BEGIN
  5582. ASSIGN(REPLY_ARRAY(1), "110 Restart marker reply");
  5583. ASSIGN(REPLY_ARRAY(2), "119 Terminal not avaliable, will try mailbox" );
  5584. ASSIGN(REPLY_ARRAY(3), "120 Service ready in nnn minutes");
  5585. ASSIGN(REPLY_ARRAY(4), "125 Data connection already open; transfer starting");
  5586. ASSIGN(REPLY_ARRAY(5), "150 File status ok, about to open data connection");
  5587. ASSIGN(REPLY_ARRAY(6), "151 User not local; will try formward");
  5588. ASSIGN(REPLY_ARRAY(7), "152 User unknown; Mail will be forwarded by operator");
  5589. ASSIGN(REPLY_ARRAY(8), "200 Command okay");
  5590. ASSIGN(REPLY_ARRAY(9), "202 Command not implemented, superflous at this site");
  5591. ASSIGN(REPLY_ARRAY(10), "211 System status, or system help reply");
  5592. ASSIGN(REPLY_ARRAY(11), "212 Directory status");
  5593. ASSIGN(REPLY_ARRAY(12), "213 File status");
  5594. ASSIGN(REPLY_ARRAY(13), "214 Help message");
  5595. ASSIGN(REPLY_ARRAY(14), "215 <scheme> is the preferred scheme");
  5596. ASSIGN(REPLY_ARRAY(15), "220 Service ready for new user");
  5597. ASSIGN(REPLY_ARRAY(16), "221 Service closing telnet connection");
  5598. ASSIGN(REPLY_ARRAY(17), "225 Data connection open, no transfer in progress");
  5599. ASSIGN(REPLY_ARRAY(18), 
  5600.     "226 Closing data connection; requested file action successful");
  5601. ASSIGN(REPLY_ARRAY(19), "227 Entering passive mode");
  5602. ASSIGN(REPLY_ARRAY(20), "230 User logged in, proceed");
  5603. ASSIGN(REPLY_ARRAY(21), "250 Requested file action ok, completed");
  5604. ASSIGN(REPLY_ARRAY(22), "331 User name ok, need password");
  5605. ASSIGN(REPLY_ARRAY(23), "332 Need account for login");
  5606. ASSIGN(REPLY_ARRAY(24), 
  5607.     "350 Requested file action pending further information");
  5608. ASSIGN(REPLY_ARRAY(25), "354 Start mail input; end with <CR><LF>.<CR><LF>");
  5609. ASSIGN(REPLY_ARRAY(26), 
  5610.     "421 Service not avaliable, closing TELNET connection");
  5611. ASSIGN(REPLY_ARRAY(27), "425 Can't open data connection");
  5612. ASSIGN(REPLY_ARRAY(28), "426 Connection closed, transfer aborted");
  5613. ASSIGN(REPLY_ARRAY(29), 
  5614.         "450 Requested file action not taken: file unavailable");
  5615. ASSIGN(REPLY_ARRAY(30), 
  5616.     "451 Requested action aborted, local error in processing");
  5617. ASSIGN(REPLY_ARRAY(31), 
  5618.     "452 Requested action not taken: insuffecient storage space in system");
  5619. ASSIGN(REPLY_ARRAY(32), "500 Syntax error, command unrecognized");
  5620. ASSIGN(REPLY_ARRAY(33), "501 Syntax error in parameters or arguments");
  5621. ASSIGN(REPLY_ARRAY(34), "502 Command not implemented");
  5622. ASSIGN(REPLY_ARRAY(35), "503 Bad sequence of commands");
  5623. ASSIGN(REPLY_ARRAY(36), "504 Command not implemented for that parameter");
  5624. ASSIGN(REPLY_ARRAY(37), "530 Not logged in");
  5625. ASSIGN(REPLY_ARRAY(38), "532 Need account for storing files");
  5626. ASSIGN(REPLY_ARRAY(39), "550 Requested action not taken: file unavailable");
  5627. ASSIGN(REPLY_ARRAY(40), "551 Requested action aborted: page type unknown");
  5628. ASSIGN(REPLY_ARRAY(41), 
  5629.     "552 Requested file action aborted: exceeded storage allocation");
  5630. ASSIGN(REPLY_ARRAY(42), 
  5631.     "553 Requested file action not taken: file name not allowed");
  5632.  
  5633. EXCEPTION
  5634.     WHEN OTHERS =>
  5635.         my_debug_io.PUT_LINE ("Illegal reply code passed to Ftp_Reply_Data");
  5636.         RAISE;
  5637.  
  5638. END FTP_REPLY_DATA;
  5639. --::::::::::::::
  5640. --ftprplutl_.ada
  5641. --::::::::::::::
  5642. -----------------------------------------------------------------------
  5643. --
  5644. --         DoD Protocols    NA-00005-200       80-01088-100(-)
  5645. --         E-Systems, Inc.  August 07, 1985
  5646. --
  5647. --         FTPRPLUTL_.ADA       Author : Mark Volpe
  5648. --
  5649. -----------------------------------------------------------------------
  5650.  
  5651. -- FILE : FTPRPLUTL               AUTHOR : MARK VOLPE
  5652.  
  5653. -- 5/17/85    2:27 PM : REVISED FOR USE WITH DEC COMPILER 
  5654. --                      OLD CODE (TELESOFT) MARKED WITH --&MT  
  5655.  
  5656. -- 5/31/85    8:49 AM : REVISED FOR USE WITH TELESOFT COMPILER
  5657. --                      OLD CODE (DEC) MARKED WITH --&MT
  5658.  
  5659. -- 5/31/85    9:19 AM : REVISED FOR USE WITH THE DEC COMPILER
  5660. --                      OLD CODE (TELESOFT) MARKED WITH --&MT
  5661.  
  5662. --&MT THE FOLLOWING LINE SHOULD BE DELETED WHEN USING DEC ADA :
  5663. --&MT PRAGMA SOURCE_INFO ( ON );
  5664.  
  5665. WITH Ftp_types;
  5666. WITH Reply_types;          USE Reply_types;
  5667. WITH Command_types;
  5668. WITH Ftp_reply_data;
  5669. WITH Ftp_telnet;
  5670. WITH Ftp_terminal_driver;
  5671. WITH My_debug_io;
  5672.  
  5673. --&MT THE FOLLOWING LINE WAS ADDED TO PROVIDE FTPRPLUTL WITH ACCESS TO
  5674. --&MT  TEXT_IO:
  5675. WITH TEXT_IO;
  5676.  
  5677. PACKAGE Reply_utilities IS
  5678.     ----------------------------------------------------------------------
  5679.     --
  5680.     -- This package contains utilities for processing replys
  5681.     --
  5682.     ----------------------------------------------------------------------
  5683.  
  5684.   PROCEDURE Get_reply_from_telnet( Reply : OUT reply_code_spec);
  5685.     ----------------------------------------------------------------------
  5686.     --
  5687.     -- This procedure accepts a 3 digit reply code and message
  5688.     -- text from a server pi.  The text is output to the nvt
  5689.     -- printer. The reply code is used for processing.
  5690.     --
  5691.     ----------------------------------------------------------------------
  5692.  
  5693.   PROCEDURE Add_text_to_reply
  5694.     ( Input_reply_code : IN  telnet_reply_code_spec ;
  5695.       Message          : OUT Ftp_types.argument_list ) ;
  5696.     ----------------------------------------------------------------------
  5697.     --
  5698.     -- This procedure accepts a reply code and adds the 
  5699.     -- appropriate message text.
  5700.     --
  5701.     ----------------------------------------------------------------------
  5702.  
  5703.   PROCEDURE Indicate_multiline_reply
  5704.     ( Reply_message : IN OUT Ftp_types.argument_list );
  5705.     ----------------------------------------------------------------------
  5706.     --
  5707.     -- This procedure indicates that the reply message is part of a 
  5708.     -- multiline reply
  5709.     --
  5710.     ----------------------------------------------------------------------
  5711.  
  5712. END Reply_utilities;
  5713.  
  5714. --::::::::::::::
  5715. --ftprplutl.ada
  5716. --::::::::::::::
  5717. -----------------------------------------------------------------------
  5718. --
  5719. --         DoD Protocols    NA-00005-200       80-01089-100(-)
  5720. --         E-Systems, Inc.  August 07, 1985
  5721. --
  5722. --         FTPRPLUTL.ADA       Author : Mark Volpe
  5723. --
  5724. -----------------------------------------------------------------------
  5725.  
  5726. -- FILE : Ftprplutl               AUTHOR : MARK VOLPE
  5727.  
  5728. -- 5/17/85    2:55 PM : REVISED FOR USE WITH DEC COMPILER 
  5729. --                      OLD CODE (TELESOFT) MARKED WITH --&MT  
  5730.  
  5731. -- 5/31/85    8:49 AM : REVISED FOR USE WITH TELESOFT COMPILER
  5732. --                      OLD CODE (DEC) MARKED WITH --&MT
  5733.  
  5734. -- 5/31/85    9:29 AM : REVISED FOR USE WITH THE DEC COMPILER
  5735. --                      OLD CODE (TELESOFT) MARKED WITH --&MT
  5736.  
  5737. PACKAGE BODY Reply_utilities IS
  5738.  
  5739. --&MT SUBTYPE BIT_COUNT_32_TYPE IS LONG_INTEGER;
  5740.       SUBTYPE BIT_COUNT_32_TYPE IS INTEGER;
  5741.  
  5742. --&MT SUBTYPE BIT_COUNT_16_TYPE IS INTEGER;
  5743.       SUBTYPE BIT_COUNT_16_TYPE IS SHORT_INTEGER;
  5744.  
  5745. --&MT THE FOLLOWING LINES SHOULD BE DELETED WHEN USING TELESOFT
  5746.   PACKAGE LONG_INT IS NEW TEXT_IO.INTEGER_IO(BIT_COUNT_32_TYPE);
  5747.   PACKAGE INT_IO IS NEW TEXT_IO.INTEGER_IO(BIT_COUNT_16_TYPE);
  5748.  
  5749.   PROCEDURE RECORD_THE_REPLY_CODE
  5750.     ( Telnet_reply : IN OUT Command_types.command_string_spec;
  5751.       REPLY        : IN OUT reply_code_spec) IS
  5752.     ----------------------------------------------------------------------
  5753.     --
  5754.     -- This procedure converts the 3 digit reply that was received from
  5755.     -- telnet into an enumerated type.
  5756.     --
  5757.     ----------------------------------------------------------------------
  5758.         Temp_char : CHARACTER ;
  5759.         Temp_reply_code : valid_reply_code_character;
  5760.     BEGIN
  5761.       Temp_reply_code := Telnet_reply( Telnet_reply'FIRST);
  5762.       IF Temp_reply_code = Code_for_positive_preliminary_reply THEN
  5763.             Reply.code := Positive_preliminary_reply_code;
  5764.       ELSIF Temp_reply_code =  Code_for_positive_completion_reply THEN
  5765.             Reply.code := Positive_completion_reply_code;
  5766.       ELSIF Temp_reply_code = Code_for_positive_intermediate_reply THEN
  5767.             Reply.code := Positive_intermediate_reply_code;
  5768.       ELSIF Temp_reply_code = Code_for_transient_negative_completion_reply THEN
  5769.             Reply.code := Transient_negative_completion_reply_code;
  5770.       ELSIF Temp_reply_code = Code_for_permanent_negative_completion_reply THEN
  5771.             Reply.code := Permanent_negative_completion_reply_code;
  5772.       ELSE
  5773.             Reply.code := Permanent_negative_completion_reply_code;
  5774.       END IF;
  5775.     EXCEPTION
  5776.         WHEN OTHERS =>
  5777.             Ftp_terminal_driver.output_message_with_new_line
  5778.                 ("Unknown exception in Record_the_reply_code");
  5779.         RAISE;
  5780.     END Record_the_reply_code;
  5781.  
  5782.   PROCEDURE Record_the_reply_type
  5783.     ( Telnet_reply : IN OUT Command_types.command_string_spec;
  5784.       Reply     : IN OUT Reply_code_spec ) IS
  5785.     ----------------------------------------------------------------------
  5786.     --
  5787.     -- This procedure records the qualifier for the type of reply that
  5788.     -- was received
  5789.     --
  5790.     ----------------------------------------------------------------------
  5791.         Temp_char : CHARACTER ;
  5792.         Temp_reply_code : Valid_reply_code_character;
  5793.     BEGIN
  5794.         Temp_reply_code := Telnet_reply( Telnet_reply'FIRST);
  5795.         Temp_reply_code := Valid_reply_code_character'SUCC( Temp_reply_code );
  5796.         IF Temp_reply_code =  Code_for_syntax_qualifier THEN
  5797.             Reply.message_type := Syntax;
  5798.         ELSIF Temp_reply_code = Code_for_information_qualifier THEN
  5799.             Reply.message_type := Information;
  5800.         ELSIF Temp_reply_code = Code_for_connection_qualifier THEN
  5801.             Reply.message_type := Connections;
  5802.         ELSIF Temp_reply_code = Code_for_authentication_qualifier THEN
  5803.             Reply.message_type := Authentication;
  5804.         ELSIF Temp_reply_code = Code_for_unspecified_qualifier THEN
  5805.             Reply.message_type := Unspecified;
  5806.         ELSIF Temp_reply_code = Code_for_file_system_qualifier THEN
  5807.             Reply.message_type := File_system;
  5808.         ELSE
  5809.             Reply.message_type := Message_type_error;
  5810.         END IF;
  5811.     EXCEPTION
  5812.         WHEN OTHERS =>
  5813.             Ftp_terminal_driver.output_message_with_new_line
  5814.                 ("Unknown exception in Record_the_reply_type");
  5815.         RAISE;
  5816.     END Record_the_reply_type;
  5817.  
  5818.   PROCEDURE Record_the_three_digit_reply_code
  5819.     ( Telnet_reply : IN OUT Command_types.command_string_spec;
  5820.       Reply_digits : OUT    Telnet_reply_code_spec ) IS
  5821.     ----------------------------------------------------------------------
  5822.     --
  5823.     -- This procedure saves the three digit code 
  5824.     -- in case this is a multiline reply
  5825.     --
  5826.     ----------------------------------------------------------------------
  5827.  
  5828.   --&MT Telnet_index : BIT_COUNT_16_TYPE := Telnet_reply'FIRST;
  5829.         Telnet_index : BIT_COUNT_32_TYPE := Telnet_reply'FIRST;
  5830.  
  5831.     BEGIN
  5832.         FOR Index IN Reply_digits'RANGE LOOP
  5833.             Reply_digits ( Index ) := 
  5834.                 Valid_reply_code_character'( Telnet_reply( Telnet_index ));
  5835.             Telnet_index := Telnet_index + 1;
  5836.         END LOOP;
  5837.     EXCEPTION
  5838.         WHEN OTHERS =>
  5839.             Ftp_terminal_driver.output_message_with_new_line
  5840.                     ("Unknown exception in Record_the_three_digit_reply_code");
  5841.             RAISE;
  5842.     END Record_the_three_digit_reply_code;
  5843.  
  5844.   FUNCTION The_end_of_the_reply 
  5845.     ( Telnet_reply : IN Command_types.command_string_spec;
  5846.       REPLY_DIGITS : IN Telnet_reply_code_spec ) RETURN BOOLEAN IS
  5847.  
  5848.           --&MT Telnet_index  : BIT_COUNT_16_TYPE := Telnet_reply'FIRST;
  5849.                 Telnet_index  : BIT_COUNT_32_TYPE := Telnet_reply'FIRST;
  5850.  
  5851.                 Return_status : BOOLEAN := TRUE;
  5852.     BEGIN
  5853.         FOR Index IN Reply_digits'RANGE LOOP
  5854.             IF Reply_digits( Index ) = Telnet_reply( Telnet_index ) THEN
  5855.                 NULL;
  5856.             ELSE
  5857.                 Return_status := FALSE;
  5858.                 EXIT;
  5859.             END IF;
  5860.             Telnet_index := Telnet_index + 1;
  5861.         END LOOP;
  5862.         RETURN Return_status;
  5863.     EXCEPTION
  5864.         WHEN OTHERS =>
  5865.             Ftp_terminal_driver.output_message_with_new_line
  5866.                 ("Unknown exception in The_end_of_the_reply");
  5867.             RAISE;
  5868.     END The_end_of_the_reply;
  5869.  
  5870.   PROCEDURE OUTPUT_THE_REPLY_MESSAGE    
  5871.     ( Telnet_reply : IN OUT Command_types.command_string_spec;
  5872.       Reply_digits : IN     Telnet_reply_code_spec ) IS
  5873.         Telnet_status  : Ftp_telnet.telnet_status_spec;
  5874.     BEGIN
  5875.         Ftp_terminal_driver.output_message_with_new_line
  5876.             ( Telnet_reply( 5 .. Telnet_reply'LENGTH ));
  5877.                 -- 5 IS THE 1ST CHARACTER IN MESSAGE
  5878.         IF Telnet_reply(4) = '-'  THEN 
  5879.           LOOP
  5880.             Telnet_reply := Command_types.null_command_string;
  5881.             Ftp_telnet.get_data_from_telnet_buffer(Telnet_status,Telnet_reply);
  5882.             IF Telnet_reply ( Telnet_reply'first ) IN '0'..'9' THEN
  5883.                 Ftp_terminal_driver.output_message_with_new_line
  5884.                     ( Telnet_reply( 5 .. Telnet_reply'LENGTH ));
  5885.                         -- 5 IS THE 1ST CHARACTER IN MESSAGE
  5886.             ELSE
  5887.                 Ftp_terminal_driver.output_message_with_new_line(Telnet_reply);
  5888.             END IF;
  5889.             IF The_end_of_the_reply( Telnet_reply, Reply_digits ) THEN
  5890.                 EXIT; 
  5891.             END IF;
  5892.           END LOOP;
  5893.         ELSE
  5894.             NULL;
  5895.             -- FTP_TERMINAL_DRIVER.OUTPUT_MESSAGE_WITH_NEW_LINE
  5896.             -- (TELNET_REPLY(5..TELNET_REPLY'LENGTH));
  5897.             -- 5 IS THE 1ST CHARACTER IN MESSAGE
  5898.         END IF;
  5899.     EXCEPTION
  5900.         WHEN OTHERS =>
  5901.             Ftp_terminal_driver.output_message_with_new_line
  5902.                 ("Unknown exception in Output_the_reply_message");
  5903.             RAISE;
  5904.     END Output_the_reply_message;
  5905.  
  5906.   PROCEDURE Get_reply_from_telnet ( Reply : OUT reply_code_spec) IS
  5907.         Telnet_reply  : Command_types.command_string_spec;
  5908.         Telnet_status : Ftp_telnet.telnet_status_spec;
  5909.         Reply_digits  : Telnet_reply_code_spec;
  5910.         Temp_reply    : Reply_code_spec; 
  5911.     BEGIN
  5912.         Temp_reply.message := Null_reply_message;
  5913.         Temp_reply.multiline_message := FALSE;
  5914.         My_debug_io.put_line (" Getting reply");
  5915.         Ftp_telnet.get_data_from_telnet_buffer( Telnet_status, Telnet_reply );
  5916.         My_debug_io.put_line (" Reply received ");
  5917.         Record_the_reply_code ( Telnet_reply, Temp_reply );
  5918.         Record_the_reply_type ( Telnet_reply, Temp_reply );
  5919.         Record_the_three_digit_reply_code( Telnet_reply, Reply_digits );
  5920.         Output_the_reply_message ( Telnet_reply, Reply_digits );
  5921.         Reply := Temp_reply;
  5922.     EXCEPTION
  5923.         WHEN OTHERS =>
  5924.             -- Don't raise the exception.
  5925.             -- Handle it here by setting a bad return status
  5926.             Temp_reply.code := Reply_code_error;
  5927.             Temp_reply.message_type := Message_type_error;
  5928.             Reply := Temp_reply;
  5929.             Ftp_terminal_driver.output_message_with_new_line
  5930.                 ("Unknown exception in Get_Reply_From_Telnet");
  5931.     END Get_reply_from_telnet;
  5932.  
  5933.   PROCEDURE Add_text_to_reply
  5934.     ( Input_reply_code : IN Telnet_reply_code_spec ;
  5935.       Message          : OUT    Ftp_types.argument_list ) IS
  5936.     BEGIN
  5937.         IF Input_reply_code( Input_reply_code'FIRST ) = 
  5938.                                 Valid_reply_code_character'('0') THEN
  5939.             NULL;
  5940.         ELSE
  5941.             Ftp_reply_data.get_reply_message_for_this_reply
  5942.                                             ( Input_reply_code, Message );
  5943.         END IF;
  5944.     EXCEPTION
  5945.         WHEN OTHERS =>
  5946.             Ftp_terminal_driver.output_message_with_new_line
  5947.                 ("Unknown exception in Add_text_to_reply");
  5948.             RAISE;
  5949.     END Add_text_to_reply;
  5950.  
  5951.   PROCEDURE Indicate_multiline_reply
  5952.      ( Reply_message : IN OUT Ftp_types.argument_list ) is
  5953.      BEGIN
  5954.          Reply_message(4) := Ftp_types.argument_list_unit'('-');
  5955.      EXCEPTION
  5956.          WHEN OTHERS => RAISE;
  5957.      END Indicate_multiline_reply;
  5958.  
  5959. BEGIN
  5960.     NULL;
  5961. EXCEPTION
  5962.     WHEN OTHERS =>
  5963.         FTP_TERMINAL_DRIVER.OUTPUT_MESSAGE_WITH_NEW_LINE
  5964.             ("Unknown exception in Reply_utilities");
  5965.         RAISE;
  5966.  
  5967. END Reply_utilities;
  5968. --::::::::::::::
  5969. --ftputl_.ada
  5970. --::::::::::::::
  5971. -----------------------------------------------------------------------
  5972. --
  5973. --         DoD Protocols    NA-00005-200       80-01118-100(-)
  5974. --         E-Systems, Inc.  August 07, 1985
  5975. --
  5976. --         FTPUTL_.ADA       Author : Mark Volpe
  5977. --
  5978. -----------------------------------------------------------------------
  5979. -- FILE : FTPUTL               AUTHOR : MARK VOLPE
  5980.  
  5981. -- 5/17/85    4:05 PM : REVISED FOR USE WITH DEC COMPILER 
  5982. --                      OLD CODE (TELESOFT) MARKED WITH --&MT  
  5983.  
  5984. -- 5/31/85    9:14 AM : REVISED FOR USE WITH TELESOFT COMPILER
  5985. --                      OLD CODE (DEC) MARKED WITH --&MT
  5986.  
  5987. -- 5/31/85    9:51 AM : REVISED FOR USE WITH THE DEC COMPILER
  5988. --                      OLD CODE (TELESOFT) MARKED WITH --&MT
  5989.  
  5990. --&MT THE FOLLOWING LINE SHOULD BE DELETED WHEN USING DEC ADA :
  5991. --&MT PRAGMA SOURCE_INFO ( ON );
  5992.  
  5993. WITH My_debug_io, Ftp_types, Ftp_telnet,
  5994.     Ftp_terminal_driver, Ftp_command_utilities, Site_details;
  5995.  
  5996. PACKAGE Ftp_utilities IS
  5997.    ----------------------------------------------------------------------
  5998.    --
  5999.    -- This package contains FTP utility procedures
  6000.    --
  6001.    ----------------------------------------------------------------------
  6002.         -- These types, procedures and functions are used to process the
  6003.         -- status of an ftp command
  6004.     TYPE  COMMAND_STATUS_SPEC IS PRIVATE;
  6005.  
  6006.     FUNCTION  COMMAND_WAS_SUCCESSFUL
  6007.          ( COMMAND_STATUS : IN  COMMAND_STATUS_SPEC ) RETURN BOOLEAN;
  6008.  
  6009.     PROCEDURE INDICATE_COMMAND_WAS_SUCCESSFUL
  6010.          ( COMMAND_STATUS : OUT  COMMAND_STATUS_SPEC ) ;
  6011.  
  6012.     PROCEDURE  INDICATE_COMMAND_WAS_NOT_SUCCESSFUL
  6013.          ( COMMAND_STATUS : OUT  COMMAND_STATUS_SPEC ) ;
  6014.  
  6015.         -- These types are used to record parameter information for the
  6016.         -- current ftp system
  6017.     TYPE LOGIN_STATUS_SPEC IS PRIVATE;
  6018.     TYPE TELNET_STATUS_SPEC IS PRIVATE;
  6019.     TYPE FTP_PARAMETERS_SPEC IS PRIVATE;
  6020.  
  6021.         -- These types, procedures and functions are used to process the
  6022.         -- status of telnet_data_links and the users login status
  6023.  
  6024.     PROCEDURE INDICATE_USER_IS_LOGGED_IN 
  6025.                 ( FTP_PARAMETERS : IN OUT FTP_PARAMETERS_SPEC );
  6026.  
  6027.     PROCEDURE INDICATE_USER_IS_LOGGED_OUT
  6028.                 ( FTP_PARAMETERS : IN OUT FTP_PARAMETERS_SPEC );
  6029.  
  6030.     FUNCTION  USER_IS_LOGGED_IN 
  6031.                 ( FTP_PARAMETERS : IN FTP_PARAMETERS_SPEC ) RETURN BOOLEAN;
  6032.  
  6033.     PROCEDURE INDICATE_TELNET_LINK_OPEN
  6034.                 ( FTP_PARAMETERS : IN OUT FTP_PARAMETERS_SPEC );
  6035.  
  6036.     PROCEDURE INDICATE_TELNET_LINK_CLOSED
  6037.                 ( FTP_PARAMETERS : IN OUT FTP_PARAMETERS_SPEC );
  6038.  
  6039.     FUNCTION  TELNET_LINK_IS_OPEN 
  6040.                 ( FTP_PARAMETERS : IN FTP_PARAMETERS_SPEC ) RETURN BOOLEAN;
  6041.  
  6042.         -- These procedures are used to access the
  6043.         -- file transfer parameters
  6044.  
  6045.     FUNCTION GET_CURRENT_PORT
  6046.             ( FTP_PARAMETERS : IN FTP_PARAMETERS_SPEC ) 
  6047.                 RETURN FTP_TYPES.ARGUMENT_LIST;
  6048.  
  6049.     FUNCTION GET_CURRENT_TYPE
  6050.             ( FTP_PARAMETERS : IN FTP_PARAMETERS_SPEC ) 
  6051.                 RETURN FTP_TYPES.ARGUMENT_LIST;
  6052.  
  6053.     FUNCTION GET_CURRENT_CARRIAGE_CONTROL
  6054.             ( FTP_PARAMETERS : IN FTP_PARAMETERS_SPEC ) 
  6055.                 RETURN FTP_TYPES.ARGUMENT_LIST;
  6056.  
  6057.     FUNCTION GET_CURRENT_STRUCTURE
  6058.             ( FTP_PARAMETERS : IN FTP_PARAMETERS_SPEC ) 
  6059.                 RETURN FTP_TYPES.ARGUMENT_LIST;
  6060.  
  6061.     FUNCTION GET_CURRENT_MODE
  6062.             ( FTP_PARAMETERS : IN FTP_PARAMETERS_SPEC ) 
  6063.                 RETURN FTP_TYPES.ARGUMENT_LIST;
  6064.  
  6065.     PROCEDURE CHANGE_FILE_STRUCTURE 
  6066.         ( STATUS         : OUT COMMAND_STATUS_SPEC;
  6067.                   FTP_PARAMETERS : IN OUT FTP_PARAMETERS_SPEC;
  6068.              ARGUMENT       : IN FTP_TYPES.ARGUMENT_LIST );
  6069.         ----------------------------------------------------------------------
  6070.         --
  6071.        -- This procedure changes the file structure to be used during
  6072.        -- file transfers which use tcp.
  6073.         --
  6074.         ----------------------------------------------------------------------
  6075.  
  6076.       PROCEDURE CHANGE_FILE_TYPE 
  6077.         ( STATUS         : OUT COMMAND_STATUS_SPEC;
  6078.                   FTP_PARAMETERS : IN OUT FTP_PARAMETERS_SPEC;
  6079.              ARGUMENT       : IN FTP_TYPES.ARGUMENT_LIST );
  6080.         ----------------------------------------------------------------------
  6081.         --
  6082.        -- This procedure changes the file type to be used during
  6083.        -- file transfers which use tcp.
  6084.         --
  6085.         ----------------------------------------------------------------------
  6086.  
  6087.       PROCEDURE CHANGE_FILE_MODE 
  6088.         ( STATUS         : OUT COMMAND_STATUS_SPEC;
  6089.                   FTP_PARAMETERS : IN OUT FTP_PARAMETERS_SPEC;
  6090.              ARGUMENT       : IN FTP_TYPES.ARGUMENT_LIST );
  6091.         ----------------------------------------------------------------------
  6092.         --
  6093.        -- This procedure changes the file mode to be used during
  6094.        -- file transfers which use tcp.
  6095.         --
  6096.         ----------------------------------------------------------------------
  6097.  
  6098.       PROCEDURE CHANGE_PORT
  6099.         ( STATUS         : OUT COMMAND_STATUS_SPEC;
  6100.                   FTP_PARAMETERS : IN OUT FTP_PARAMETERS_SPEC;
  6101.              ARGUMENT       : IN FTP_TYPES.ARGUMENT_LIST );
  6102.         ----------------------------------------------------------------------
  6103.         --
  6104.        -- This procedure changes the transmit port to be used during
  6105.        -- file transfers which use tcp.
  6106.         --
  6107.         ----------------------------------------------------------------------
  6108.  
  6109.     PROCEDURE OPEN_TELNET_LINK
  6110.         ( FTP_PARAMETERS : IN OUT FTP_PARAMETERS_SPEC;
  6111.           ARGUMENT       : IN     FTP_TYPES.ARGUMENT_LIST );
  6112.  
  6113.     PROCEDURE CLOSE_TELNET_LINK
  6114.         ( FTP_PARAMETERS : IN OUT FTP_PARAMETERS_SPEC;
  6115.           ARGUMENT       : IN     FTP_TYPES.ARGUMENT_LIST );
  6116.  
  6117. PRIVATE
  6118.     TYPE COMMAND_STATUS_SPEC IS
  6119.         ( SUCCESSFUL_COMMAND,
  6120.           COMMAND_FAILED );
  6121.  
  6122.     TYPE LOGIN_STATUS_SPEC IS ( LOGGED_IN, LOGGED_OUT );
  6123.     TYPE TELNET_STATUS_SPEC IS ( TELNET_LINK_OPEN, TELNET_LINK_CLOSED );
  6124.  
  6125.     TYPE FTP_PARAMETERS_SPEC IS RECORD
  6126.                 LOCAL_LOGIN_STATUS : LOGIN_STATUS_SPEC := LOGGED_OUT;
  6127.                 TELNET_STATUS      : TELNET_STATUS_SPEC := TELNET_LINK_CLOSED;
  6128.                 FILE_STRUCTURE     : FTP_TYPES.ARGUMENT_LIST_UNIT 
  6129.                                        := FTP_TYPES.DEFAULT_FILE_STRUCTURE;
  6130.                 FILE_MODE          : FTP_TYPES.ARGUMENT_LIST_UNIT 
  6131.                                        := FTP_TYPES.DEFAULT_FILE_MODE;
  6132.                 FILE_TYPE          : FTP_TYPES.ARGUMENT_LIST_UNIT 
  6133.                                        := FTP_TYPES.DEFAULT_FILE_TYPE;
  6134.                 CARRIAGE_CONTROL   : FTP_TYPES.ARGUMENT_LIST_UNIT 
  6135.                                        := FTP_TYPES.DEFAULT_CARRIAGE_CONTROL;
  6136.                 PORT_ID            : FTP_TYPES.PORT_ID 
  6137.                                        := FTP_TYPES.DEFAULT_PORT_ID;
  6138.             END RECORD;
  6139.  
  6140. END FTP_UTILITIES;
  6141.  
  6142. --::::::::::::::
  6143. --ftputl.ada
  6144. --::::::::::::::
  6145. -----------------------------------------------------------------------
  6146. --
  6147. --         DoD Protocols    NA-00005-200       80-01119-100(-)
  6148. --         E-Systems, Inc.  August 07, 1985
  6149. --
  6150. --         FTPUTL.ADA       Author : Mark Volpe
  6151. --
  6152. -----------------------------------------------------------------------
  6153. -- FILE : FTPUTL               AUTHOR : MARK VOLPE
  6154.  
  6155. -- 5/17/85    4:05 PM : REVISED FOR USE WITH DEC COMPILER 
  6156. --                      OLD CODE (TELESOFT) MARKED WITH --&MT  
  6157.  
  6158. -- 5/31/85    9:14 AM : REVISED FOR USE WITH TELESOFT COMPILER
  6159. --                      OLD CODE (DEC) MARKED WITH --&MT
  6160.  
  6161. -- 5/31/85    9:55 AM : REVISED FOR USE WITH THE DEC COMPILER
  6162. --                      OLD CODE (TELESOFT) MARKED WITH --&MT
  6163.  
  6164. --&MT THE FOLLOWING LINE WAS ADDED TO GIVE FTPUTL.ADA ACCESS TO TEXT_IO :
  6165. WITH TEXT_IO;
  6166.  
  6167. PACKAGE BODY FTP_UTILITIES IS
  6168.  
  6169. --&MT SUBTYPE BIT_COUNT_32_TYPE IS LONG_INTEGER;
  6170.       SUBTYPE BIT_COUNT_32_TYPE IS INTEGER;
  6171.  
  6172. --&MT SUBTYPE BIT_COUNT_16_TYPE IS INTEGER;
  6173.       SUBTYPE BIT_COUNT_16_TYPE IS SHORT_INTEGER;
  6174.  
  6175. --&MT THE FOLLOWING LINES SHOULD BE DELETED WHEN USING TELESOFT
  6176.   PACKAGE LONG_INT IS NEW TEXT_IO.INTEGER_IO(BIT_COUNT_32_TYPE);
  6177.   PACKAGE INT_IO IS NEW TEXT_IO.INTEGER_IO(BIT_COUNT_16_TYPE);
  6178.  
  6179.     PROCEDURE INDICATE_USER_IS_LOGGED_IN 
  6180.                 ( FTP_PARAMETERS : IN OUT FTP_PARAMETERS_SPEC ) IS
  6181.         BEGIN
  6182.             FTP_PARAMETERS.LOCAL_LOGIN_STATUS := LOGGED_IN;
  6183.             MY_DEBUG_IO.PUT_LINE(" ~~ User logged on to remote system ~~");
  6184.         EXCEPTION
  6185.             WHEN OTHERS =>
  6186.                 RAISE;
  6187.         END INDICATE_USER_IS_LOGGED_IN;
  6188.  
  6189.     PROCEDURE INDICATE_USER_IS_LOGGED_OUT
  6190.                 ( FTP_PARAMETERS : IN OUT FTP_PARAMETERS_SPEC ) IS
  6191.         BEGIN
  6192.             FTP_PARAMETERS.LOCAL_LOGIN_STATUS := LOGGED_OUT;
  6193.             FTP_TERMINAL_DRIVER.OUTPUT_MESSAGE_WITH_NEW_LINE
  6194.                 (" User logged off of remote system");
  6195.             RETURN;
  6196.         EXCEPTION
  6197.             WHEN OTHERS =>
  6198.                 RAISE;
  6199.         END INDICATE_USER_IS_LOGGED_OUT;
  6200.  
  6201.     FUNCTION  USER_IS_LOGGED_IN 
  6202.                 ( FTP_PARAMETERS : IN FTP_PARAMETERS_SPEC ) RETURN BOOLEAN IS
  6203.         BEGIN
  6204.             IF FTP_PARAMETERS.LOCAL_LOGIN_STATUS = LOGGED_IN THEN
  6205.                 RETURN TRUE;
  6206.             ELSE
  6207.                 RETURN FALSE;
  6208.             END IF;
  6209.         EXCEPTION
  6210.             WHEN OTHERS =>
  6211.                 RAISE;
  6212.         END USER_IS_LOGGED_IN;
  6213.  
  6214.     PROCEDURE INDICATE_TELNET_LINK_OPEN
  6215.                 ( FTP_PARAMETERS : IN OUT FTP_PARAMETERS_SPEC ) IS
  6216.         BEGIN
  6217.             FTP_PARAMETERS.TELNET_STATUS := TELNET_LINK_OPEN ;
  6218.             FTP_TERMINAL_DRIVER.OUTPUT_MESSAGE_WITH_NEW_LINE
  6219.                 (" Telnet link opened");
  6220.             RETURN;
  6221.         EXCEPTION
  6222.             WHEN OTHERS =>
  6223.                 RAISE;
  6224.         END INDICATE_TELNET_LINK_OPEN;
  6225.     
  6226.     PROCEDURE INDICATE_TELNET_LINK_CLOSED
  6227.                 ( FTP_PARAMETERS : IN OUT FTP_PARAMETERS_SPEC ) IS
  6228.         BEGIN
  6229.             FTP_PARAMETERS.TELNET_STATUS := TELNET_LINK_CLOSED ;
  6230.             FTP_TERMINAL_DRIVER.OUTPUT_MESSAGE_WITH_NEW_LINE
  6231.                 (" Telnet link closed");
  6232.             RETURN;
  6233.         EXCEPTION
  6234.             WHEN OTHERS =>
  6235.                 RAISE;
  6236.         END INDICATE_TELNET_LINK_CLOSED;
  6237.  
  6238.     FUNCTION  TELNET_LINK_IS_OPEN 
  6239.                 ( FTP_PARAMETERS : IN FTP_PARAMETERS_SPEC ) RETURN BOOLEAN IS
  6240.         BEGIN
  6241.             IF FTP_PARAMETERS.TELNET_STATUS = TELNET_LINK_OPEN THEN
  6242.                 RETURN TRUE;
  6243.             ELSE
  6244.                 RETURN FALSE;
  6245.             END IF;
  6246.         EXCEPTION
  6247.             WHEN OTHERS =>
  6248.                 RAISE;
  6249.         END TELNET_LINK_IS_OPEN;
  6250.  
  6251.     FUNCTION GET_CURRENT_PORT
  6252.             ( FTP_PARAMETERS : IN FTP_PARAMETERS_SPEC ) 
  6253.                 RETURN FTP_TYPES.ARGUMENT_LIST  IS
  6254.             ARGUMENT : FTP_TYPES.ARGUMENT_LIST := FTP_TYPES.NULL_ARGUMENT;
  6255.             ARGUMENT_INDEX : BIT_COUNT_16_TYPE := ARGUMENT'FIRST;
  6256.         BEGIN
  6257.  
  6258.             FOR INDEX IN FTP_TYPES.PORT_ID'RANGE LOOP
  6259.                 ARGUMENT( ARGUMENT_INDEX ) := 
  6260.                   FTP_TYPES.ARGUMENT_LIST_UNIT'(FTP_PARAMETERS.PORT_ID(INDEX));
  6261.                 ARGUMENT_INDEX := ARGUMENT_INDEX +1;
  6262.             END LOOP;
  6263.             RETURN ARGUMENT;
  6264.         EXCEPTION
  6265.             WHEN OTHERS =>
  6266.                 FTP_TERMINAL_DRIVER.OUTPUT_MESSAGE_WITH_NEW_LINE
  6267.                     (" GET_CURRENT_PORT failed");
  6268.                 RAISE;
  6269.         END GET_CURRENT_PORT;
  6270.  
  6271.     FUNCTION GET_CURRENT_TYPE
  6272.             ( FTP_PARAMETERS : IN FTP_PARAMETERS_SPEC ) 
  6273.                 RETURN FTP_TYPES.ARGUMENT_LIST IS
  6274.             ARGUMENT : FTP_TYPES.ARGUMENT_LIST := FTP_TYPES.NULL_ARGUMENT;
  6275.         BEGIN
  6276.             ARGUMENT( ARGUMENT'FIRST   ):= FTP_PARAMETERS.FILE_TYPE ;
  6277.             ARGUMENT( ARGUMENT'FIRST+1 ):= FTP_TYPES.ARGUMENT_LIST_UNIT'(' ');
  6278.             ARGUMENT( ARGUMENT'FIRST+2 ):= FTP_PARAMETERS.CARRIAGE_CONTROL ;
  6279.             RETURN ARGUMENT;
  6280.         EXCEPTION
  6281.             WHEN OTHERS =>
  6282.                 FTP_TERMINAL_DRIVER.OUTPUT_MESSAGE_WITH_NEW_LINE
  6283.                     (" GET_CURRENT_TYPE failed");
  6284.                 RAISE;
  6285.         END GET_CURRENT_TYPE;
  6286.  
  6287.     FUNCTION GET_CURRENT_CARRIAGE_CONTROL
  6288.             ( FTP_PARAMETERS : IN FTP_PARAMETERS_SPEC ) 
  6289.                 RETURN FTP_TYPES.ARGUMENT_LIST  IS
  6290.             ARGUMENT : FTP_TYPES.ARGUMENT_LIST := FTP_TYPES.NULL_ARGUMENT;
  6291.         BEGIN
  6292.             ARGUMENT ( ARGUMENT'FIRST ) := FTP_PARAMETERS.CARRIAGE_CONTROL ;
  6293.             RETURN ARGUMENT;
  6294.         EXCEPTION
  6295.             WHEN OTHERS =>
  6296.                 FTP_TERMINAL_DRIVER.OUTPUT_MESSAGE_WITH_NEW_LINE
  6297.                     (" GET_CURRENT_CARRIAGE_CONTROL failed");
  6298.                 RAISE;
  6299.         END  GET_CURRENT_CARRIAGE_CONTROL;
  6300.  
  6301.     FUNCTION GET_CURRENT_STRUCTURE
  6302.             ( FTP_PARAMETERS : IN FTP_PARAMETERS_SPEC ) 
  6303.                 RETURN FTP_TYPES.ARGUMENT_LIST  IS
  6304.             ARGUMENT : FTP_TYPES.ARGUMENT_LIST := FTP_TYPES.NULL_ARGUMENT;
  6305.         BEGIN
  6306.             ARGUMENT ( ARGUMENT'FIRST ) := FTP_PARAMETERS.FILE_STRUCTURE ;
  6307.             RETURN ARGUMENT;
  6308.         EXCEPTION
  6309.             WHEN OTHERS =>
  6310.                 FTP_TERMINAL_DRIVER.OUTPUT_MESSAGE_WITH_NEW_LINE
  6311.                     (" GET_CURRENT_STRUCTURE failed");
  6312.                 RAISE;
  6313.         END GET_CURRENT_STRUCTURE;
  6314.  
  6315.     FUNCTION GET_CURRENT_MODE
  6316.             ( FTP_PARAMETERS : IN FTP_PARAMETERS_SPEC ) 
  6317.                 RETURN FTP_TYPES.ARGUMENT_LIST  IS
  6318.             ARGUMENT : FTP_TYPES.ARGUMENT_LIST := FTP_TYPES.NULL_ARGUMENT;
  6319.         BEGIN
  6320.             ARGUMENT ( ARGUMENT'FIRST ) := FTP_PARAMETERS.FILE_MODE ;
  6321.             RETURN ARGUMENT;
  6322.         EXCEPTION
  6323.             WHEN OTHERS =>
  6324.                 FTP_TERMINAL_DRIVER.OUTPUT_MESSAGE_WITH_NEW_LINE
  6325.                     (" GET_CURRENT_MODE failed");
  6326.                 RAISE;
  6327.         END GET_CURRENT_MODE;
  6328.  
  6329.     PROCEDURE CHANGE_FILE_STRUCTURE 
  6330.         ( STATUS         : OUT COMMAND_STATUS_SPEC;
  6331.                   FTP_PARAMETERS : IN OUT FTP_PARAMETERS_SPEC;
  6332.              ARGUMENT       : IN FTP_TYPES.ARGUMENT_LIST )IS
  6333.  
  6334.             NEW_FILE_STRUCTURE : FTP_TYPES.ARGUMENT_LIST;
  6335.         BEGIN
  6336.             INDICATE_COMMAND_WAS_NOT_SUCCESSFUL ( STATUS );
  6337.             FTP_COMMAND_UTILITIES.GET_FIRST_ARGUMENT_FROM_ARGUMENT_LIST
  6338.                                         ( ARGUMENT, NEW_FILE_STRUCTURE );
  6339. --PUT (" ~~ Stru argument = ");
  6340. --PUT ( CHARACTER'(NEW_FILE_STRUCTURE(NEW_FILE_STRUCTURE'FIRST)));
  6341. --NEW_LINE;
  6342.             IF SITE_DETAILS.STRUCTURE_SUPPORTED ( NEW_FILE_STRUCTURE ) THEN
  6343.                 FTP_PARAMETERS.FILE_STRUCTURE :=
  6344.                         FTP_TYPES.ARGUMENT_LIST_UNIT'
  6345.                                 (NEW_FILE_STRUCTURE(NEW_FILE_STRUCTURE'FIRST));
  6346.  
  6347.                 INDICATE_COMMAND_WAS_SUCCESSFUL ( STATUS );
  6348.             END IF;
  6349. --PUT (" ~~ File stru is ");
  6350. --put ( character'(ftp_parameters.file_structure ) );
  6351. --new_line;
  6352.             RETURN;
  6353.         EXCEPTION
  6354.             WHEN OTHERS =>
  6355.                 -- MY_DEBUG_IO.PUT_LINE (" ~~ ERROR IN CHANGE_FILE_STRUCTURE ~~");
  6356.                 RAISE;
  6357.         END CHANGE_FILE_STRUCTURE ;
  6358.  
  6359.     PROCEDURE CHANGE_FILE_TYPE 
  6360.         ( STATUS         : OUT COMMAND_STATUS_SPEC;
  6361.                   FTP_PARAMETERS : IN OUT FTP_PARAMETERS_SPEC;
  6362.              ARGUMENT       : IN FTP_TYPES.ARGUMENT_LIST ) IS
  6363.  
  6364.             NEW_FILE_TYPE        : FTP_TYPES.ARGUMENT_LIST;
  6365.             NEW_CARRIAGE_CONTROL : FTP_TYPES.ARGUMENT_LIST;
  6366.         BEGIN
  6367.             INDICATE_COMMAND_WAS_NOT_SUCCESSFUL ( STATUS );
  6368.             FTP_COMMAND_UTILITIES.GET_FIRST_ARGUMENT_FROM_ARGUMENT_LIST
  6369.                                         ( ARGUMENT, NEW_FILE_TYPE );
  6370. --PUT (" ~~ Type argument = ");
  6371. --PUT ( CHARACTER'(NEW_FILE_TYPE(NEW_FILE_TYPE'FIRST)));
  6372. --NEW_LINE;
  6373.             FTP_COMMAND_UTILITIES.GET_SECOND_ARGUMENT_FROM_ARGUMENT_LIST
  6374.                                         ( ARGUMENT, NEW_CARRIAGE_CONTROL );
  6375. --PUT (" ~~ CC argument = ");
  6376. --PUT ( CHARACTER'(NEW_CARRIAGE_CONTROL(NEW_CARRIAGE_CONTROL'FIRST)));
  6377. --NEW_LINE;
  6378.             IF (SITE_DETAILS.TYPE_SUPPORTED ( NEW_FILE_TYPE ))
  6379.                             AND THEN 
  6380.                (SITE_DETAILS.PRINT_TYPE_SUPPORTED (NEW_CARRIAGE_CONTROL)) THEN
  6381.                     FTP_PARAMETERS.FILE_TYPE :=
  6382.                         FTP_TYPES.ARGUMENT_LIST_UNIT'
  6383.                                 (NEW_FILE_TYPE(NEW_FILE_TYPE'FIRST));
  6384.                     FTP_PARAMETERS.CARRIAGE_CONTROL :=
  6385.                         FTP_TYPES.ARGUMENT_LIST_UNIT'
  6386.                             (NEW_CARRIAGE_CONTROL(NEW_CARRIAGE_CONTROL'FIRST));
  6387.                     INDICATE_COMMAND_WAS_SUCCESSFUL ( STATUS );
  6388.             END IF;
  6389. --PUT (" ~~ New file type is ");
  6390. --put ( character'(ftp_parameters.file_type ) );
  6391. --new_line;
  6392. --PUT (" ~~ New carriage control is ");
  6393. --put ( character'(ftp_parameters.carriage_control ) );
  6394. --new_line;
  6395.             RETURN;
  6396.         EXCEPTION
  6397.             WHEN OTHERS =>
  6398.                 RAISE;
  6399.                 --PUT_LINE (" ~~ ERROR IN CHANGE_FILE_TYPE ~~");
  6400.         END CHANGE_FILE_TYPE ;
  6401.  
  6402.     PROCEDURE CHANGE_FILE_MODE 
  6403.         ( STATUS         : OUT COMMAND_STATUS_SPEC;
  6404.                   FTP_PARAMETERS : IN OUT FTP_PARAMETERS_SPEC;
  6405.              ARGUMENT       : IN FTP_TYPES.ARGUMENT_LIST ) IS
  6406.  
  6407.             NEW_FILE_MODE : FTP_TYPES.ARGUMENT_LIST;
  6408.  
  6409.         BEGIN
  6410.             INDICATE_COMMAND_WAS_NOT_SUCCESSFUL ( STATUS );
  6411.             FTP_COMMAND_UTILITIES.GET_FIRST_ARGUMENT_FROM_ARGUMENT_LIST
  6412.                                         ( ARGUMENT, NEW_FILE_MODE );
  6413. --PUT (" ~~ Mode argument = ");
  6414. --PUT ( CHARACTER'(NEW_FILE_MODE(NEW_FILE_MODE'FIRST)));
  6415. --NEW_LINE;
  6416.             IF SITE_DETAILS.MODE_SUPPORTED ( NEW_FILE_MODE ) THEN
  6417.                 FTP_PARAMETERS.FILE_MODE :=
  6418.                         FTP_TYPES.ARGUMENT_LIST_UNIT'
  6419.                                 (NEW_FILE_MODE(NEW_FILE_MODE'FIRST));
  6420.                 INDICATE_COMMAND_WAS_SUCCESSFUL ( STATUS );
  6421.             END IF;
  6422. --PUT (" ~~ File mode is ");
  6423. --put ( character'(ftp_parameters.file_mode ) );
  6424. --new_line;
  6425.             RETURN;
  6426.         EXCEPTION
  6427.             WHEN OTHERS =>
  6428.                 RAISE;
  6429.                 --PUT_LINE (" ~~ ERROR IN CHANGE_FILE_MODE ~~");
  6430.         END CHANGE_FILE_MODE ;
  6431.  
  6432.   PROCEDURE GET_PORT_ID_FROM_ARGUMENT
  6433.         ( STATUS         : OUT COMMAND_STATUS_SPEC;
  6434.              ARGUMENT       : IN FTP_TYPES.ARGUMENT_LIST;
  6435.                   NEW_PORT_ID    : OUT FTP_TYPES.PORT_ID ) IS
  6436.  
  6437.   --&MT PORT_OFFSET     : BIT_COUNT_16_TYPE := FTP_TYPES.PORT_ID'FIRST;
  6438.         PORT_OFFSET     : BIT_COUNT_32_TYPE := FTP_TYPES.PORT_ID'FIRST;
  6439.  
  6440.         ARGUMENT_OFFSET : BIT_COUNT_16_TYPE := FTP_TYPES.ARGUMENT_LIST'FIRST;
  6441.     BEGIN
  6442.         FOR INDEX IN NEW_PORT_ID'RANGE LOOP
  6443.             NEW_PORT_ID(INDEX) := FTP_TYPES.VALID_PORT_IDENTIFIER'(' ');
  6444.         END LOOP;
  6445.         INDICATE_COMMAND_WAS_SUCCESSFUL ( STATUS );
  6446.         FOR LOOP_CONTROL IN NEW_PORT_ID'RANGE LOOP
  6447.             IF FTP_TYPES.END_OF_ARGUMENT(ARGUMENT(ARGUMENT_OFFSET)) THEN
  6448.               INDICATE_COMMAND_WAS_NOT_SUCCESSFUL ( STATUS );
  6449.               EXIT;
  6450.             ELSE
  6451.               NEW_PORT_ID ( PORT_OFFSET ) := 
  6452.                    FTP_TYPES.VALID_PORT_IDENTIFIER'(ARGUMENT(ARGUMENT_OFFSET));
  6453.               PORT_OFFSET := PORT_OFFSET + 1;
  6454.               ARGUMENT_OFFSET := ARGUMENT_OFFSET + 1;
  6455.             END IF;
  6456.         END LOOP;
  6457.         RETURN;
  6458.     EXCEPTION
  6459.         WHEN OTHERS =>
  6460.             INDICATE_COMMAND_WAS_NOT_SUCCESSFUL ( STATUS );
  6461.     END GET_PORT_ID_FROM_ARGUMENT;
  6462.  
  6463.   PROCEDURE CHANGE_PORT
  6464.         ( STATUS         : OUT COMMAND_STATUS_SPEC;
  6465.                   FTP_PARAMETERS : IN OUT FTP_PARAMETERS_SPEC;
  6466.              ARGUMENT       : IN FTP_TYPES.ARGUMENT_LIST ) IS
  6467.         NEW_PORT_ID : FTP_TYPES.PORT_ID;
  6468.         TEMP_STATUS : COMMAND_STATUS_SPEC;
  6469.     BEGIN
  6470.         GET_PORT_ID_FROM_ARGUMENT ( TEMP_STATUS, ARGUMENT, NEW_PORT_ID );
  6471.         IF COMMAND_WAS_SUCCESSFUL ( TEMP_STATUS ) THEN
  6472.            FTP_PARAMETERS.PORT_ID := NEW_PORT_ID;
  6473.         END IF;
  6474.         RETURN;
  6475.       STATUS := TEMP_STATUS;
  6476.     EXCEPTION
  6477.         WHEN OTHERS =>
  6478.             INDICATE_COMMAND_WAS_NOT_SUCCESSFUL ( TEMP_STATUS );
  6479.             STATUS := TEMP_STATUS ;
  6480.             --PUT_LINE (" ~~ ERROR IN CHANGE_PORT~~");
  6481.   END CHANGE_PORT;
  6482.  
  6483.   PROCEDURE  INDICATE_COMMAND_WAS_SUCCESSFUL
  6484.          ( COMMAND_STATUS : OUT COMMAND_STATUS_SPEC ) IS
  6485.     BEGIN
  6486.             COMMAND_STATUS := SUCCESSFUL_COMMAND;
  6487.             RETURN;
  6488.     EXCEPTION
  6489.             WHEN OTHERS =>
  6490.                 RAISE;
  6491.                 --PUT_LINE (" ~~ ERROR IN INDICATE_COMMAND_WAS_SUCCESSFUL ~~");
  6492.   END INDICATE_COMMAND_WAS_SUCCESSFUL;
  6493.  
  6494.   PROCEDURE  INDICATE_COMMAND_WAS_NOT_SUCCESSFUL
  6495.          ( COMMAND_STATUS : OUT COMMAND_STATUS_SPEC ) IS
  6496.         BEGIN
  6497.             COMMAND_STATUS := COMMAND_FAILED;
  6498.             RETURN;
  6499.         EXCEPTION
  6500.             WHEN OTHERS =>
  6501.               RAISE;
  6502.               --PUT_LINE(" ~~ ERROR IN INDICATE_COMMAND_WAS_NOT_SUCCESSFUL~~");
  6503.         END INDICATE_COMMAND_WAS_NOT_SUCCESSFUL;
  6504.  
  6505.     FUNCTION COMMAND_WAS_SUCCESSFUL
  6506.          ( COMMAND_STATUS : IN COMMAND_STATUS_SPEC ) RETURN BOOLEAN IS
  6507.         BEGIN
  6508.             IF COMMAND_STATUS = SUCCESSFUL_COMMAND THEN
  6509.                 RETURN TRUE;
  6510.             ELSE
  6511.                 RETURN FALSE;
  6512.             END IF;
  6513.         EXCEPTION
  6514.             WHEN OTHERS =>
  6515.                 RAISE;
  6516.                 --PUT_LINE (" ~~ ERROR IN COMMAND_WAS_SUCCESSFUL ~~");
  6517.         END COMMAND_WAS_SUCCESSFUL;
  6518.  
  6519.     --
  6520.     -- The following procedures are used during file transfer
  6521.     -- to convert from one data format to another.  They are
  6522.     -- implementation dependent.
  6523.     --
  6524.    PROCEDURE CONVERT_TO_NON_PRINT_CARRIAGE_CONTROL IS
  6525.        BEGIN
  6526.            RETURN;
  6527.        END CONVERT_TO_NON_PRINT_CARRIAGE_CONTROL;
  6528.  
  6529.    PROCEDURE CONVERT_TO_ASA_CARRIAGE_CONTROL IS
  6530.        BEGIN
  6531.            RETURN;
  6532.        END CONVERT_TO_ASA_CARRIAGE_CONTROL ;
  6533.  
  6534.    PROCEDURE CONVERT_TO_TELNET_CARRIAGE_CONTROL IS
  6535.        BEGIN
  6536.            RETURN;
  6537.        END CONVERT_TO_TELNET_CARRIAGE_CONTROL ;
  6538.  
  6539.    PROCEDURE CONVERT_TO_RECORD_STRUCTURE IS
  6540.        BEGIN
  6541.            RETURN;
  6542.        END CONVERT_TO_RECORD_STRUCTURE ;
  6543.  
  6544.    PROCEDURE CONVERT_TO_FILE_STRUCTURE IS
  6545.        BEGIN
  6546.            RETURN;
  6547.        END CONVERT_TO_FILE_STRUCTURE;
  6548.  
  6549.    PROCEDURE CONVERT_FROM_NON_PRINT_CARRIAGE_CONTROL IS
  6550.        BEGIN
  6551.            RETURN;
  6552.        END CONVERT_FROM_NON_PRINT_CARRIAGE_CONTROL;
  6553.  
  6554.    PROCEDURE CONVERT_FROM_ASA_CARRIAGE_CONTROL IS
  6555.        BEGIN
  6556.            RETURN;
  6557.        END CONVERT_FROM_ASA_CARRIAGE_CONTROL ;
  6558.  
  6559.    PROCEDURE CONVERT_FROM_TELNET_CARRIAGE_CONTROL IS
  6560.        BEGIN
  6561.            RETURN;
  6562.        END CONVERT_FROM_TELNET_CARRIAGE_CONTROL ;
  6563.  
  6564.    PROCEDURE CONVERT_FROM_RECORD_STRUCTURE IS
  6565.        BEGIN
  6566.            RETURN;
  6567.        END CONVERT_FROM_RECORD_STRUCTURE ;
  6568.  
  6569.    PROCEDURE CONVERT_FROM_FILE_STRUCTURE IS
  6570.        BEGIN
  6571.            RETURN;
  6572.        END CONVERT_FROM_FILE_STRUCTURE;
  6573.  
  6574.     PROCEDURE OPEN_TELNET_LINK
  6575.         ( FTP_PARAMETERS : IN OUT FTP_PARAMETERS_SPEC;
  6576.           ARGUMENT       : IN     FTP_TYPES.ARGUMENT_LIST ) IS
  6577.  
  6578.         TELNET_STATUS : FTP_TELNET.TELNET_STATUS_SPEC;
  6579.       BEGIN
  6580.         FTP_TELNET.OPEN_TELNET_LINK ( TELNET_STATUS, ARGUMENT );
  6581.         IF FTP_TELNET.TELNET_WAS_SUCCESSFUL ( TELNET_STATUS ) THEN
  6582.             INDICATE_TELNET_LINK_OPEN ( FTP_PARAMETERS );
  6583.         ELSE
  6584.             INDICATE_TELNET_LINK_CLOSED ( FTP_PARAMETERS );
  6585.         END IF;
  6586.         RETURN;
  6587.       EXCEPTION
  6588.         WHEN OTHERS =>
  6589.             RAISE;
  6590.       END OPEN_TELNET_LINK;
  6591.  
  6592.     PROCEDURE CLOSE_TELNET_LINK
  6593.         ( FTP_PARAMETERS : IN OUT FTP_PARAMETERS_SPEC;
  6594.           ARGUMENT       : IN     FTP_TYPES.ARGUMENT_LIST ) IS
  6595.  
  6596.         TELNET_STATUS : FTP_TELNET.TELNET_STATUS_SPEC;
  6597.       BEGIN
  6598.         FTP_TELNET.CLOSE_TELNET_LINK ( TELNET_STATUS, ARGUMENT );
  6599.         IF FTP_TELNET.TELNET_WAS_SUCCESSFUL ( TELNET_STATUS ) THEN
  6600.             INDICATE_TELNET_LINK_CLOSED ( FTP_PARAMETERS );
  6601.         ELSE
  6602.             INDICATE_TELNET_LINK_OPEN ( FTP_PARAMETERS );
  6603.         END IF;
  6604.         RETURN;
  6605.       EXCEPTION
  6606.         WHEN OTHERS =>
  6607.             RAISE;
  6608.       END CLOSE_TELNET_LINK;
  6609.  
  6610. BEGIN
  6611.     NULL;
  6612. EXCEPTION
  6613.     WHEN OTHERS =>
  6614.         --PUT_LINE (" Error in Ftp_utils");
  6615.         RAISE;
  6616. END FTP_UTILITIES;
  6617. --::::::::::::::
  6618. --ftpsrvutl_.ada
  6619. --::::::::::::::
  6620. -----------------------------------------------------------------------
  6621. --
  6622. --         DoD Protocols    NA-00005-200       80-01099-100(-)
  6623. --         E-Systems, Inc.  August 07, 1985
  6624. --
  6625. --         FTPSRVUTL_.ADA       Author : Mark Volpe
  6626. --
  6627. -----------------------------------------------------------------------
  6628. -- FILE : FTPSRVUTL               AUTHOR : MARK VOLPE
  6629.  
  6630. -- 5/20/85    8:37 AM : REVISED FOR USE WITH DEC COMPILER 
  6631. --                      OLD CODE (TELESOFT) MARKED WITH --&MT  
  6632.  
  6633. -- 5/31/85    9:46 AM : REVISED FOR USE WITH TELESOFT COMPILER
  6634. --                      OLD CODE (DEC) MARKED WITH --&MT
  6635.  
  6636. -- 5/31/85    10:16 AM : REVISED FOR USE WITH THE DEC COMPILER
  6637. --                       OLD CODE (TELESOFT) MARKED WITH --&MT
  6638.  
  6639. --&MT THE FOLLOWING LINE SHOULD BE DELETED WHEN USING DEC ADA :
  6640. --&MT PRAGMA SOURCE_INFO ( ON );
  6641.  
  6642. WITH     My_debug_io, Ftp_types, Ftp_command_utilities, Reply_types, 
  6643.         Reply_utilities;
  6644.  
  6645. PACKAGE Server_utilities IS
  6646.  
  6647.     PROCEDURE Assign
  6648.                 ( Reply_code  : OUT Reply_types.telnet_reply_code_spec;
  6649.                   Code_string : IN STRING ) ;
  6650.     ----------------------------------------------------------------------
  6651.     --
  6652.     -- This procedure assigns a value to a reply_code 
  6653.     --
  6654.     ----------------------------------------------------------------------
  6655.  
  6656.   PROCEDURE Send_system_help_message;
  6657.     ----------------------------------------------------------------------
  6658.     --
  6659.     -- This procedure send the system help reply over telnet
  6660.     --
  6661.     ----------------------------------------------------------------------
  6662.  
  6663.   PROCEDURE Send_reply_over_telnet
  6664.         ( Reply_message : IN Ftp_types.argument_list );
  6665.     ----------------------------------------------------------------------
  6666.     --
  6667.     -- This procedure sends a reply over telnet
  6668.     --
  6669.     ----------------------------------------------------------------------
  6670.  
  6671.   PROCEDURE Send_reply_over_telnet
  6672.         ( Reply_code_string : IN STRING );
  6673.     ----------------------------------------------------------------------
  6674.     --
  6675.     -- This procedure sends a reply over telnet given only the code
  6676.     --
  6677.     ----------------------------------------------------------------------
  6678.  
  6679.   PROCEDURE Assign
  6680.         ( Reply_message : OUT Ftp_types.argument_list ;
  6681.           Message_text  : IN STRING ) ;
  6682.     ----------------------------------------------------------------------
  6683.     --
  6684.     -- This procedure assigns a reply message a certain text string
  6685.     --
  6686.     ----------------------------------------------------------------------
  6687.  
  6688.   PROCEDURE Send_message ( Reply_text : IN STRING );
  6689.     ----------------------------------------------------------------------
  6690.     --
  6691.     -- This procedure sends a reply message via telnet
  6692.     --
  6693.     ----------------------------------------------------------------------
  6694.  
  6695. END Server_utilities;
  6696.  
  6697. --::::::::::::::
  6698. --ftpsrvutl.ada
  6699. --::::::::::::::
  6700. -----------------------------------------------------------------------
  6701. --
  6702. --         DoD Protocols    NA-00005-200       80-01100-100(-)
  6703. --         E-Systems, Inc.  August 07, 1985
  6704. --
  6705. --         FTPSRVUTL.ADA       Author : Mark Volpe
  6706. --
  6707. -----------------------------------------------------------------------
  6708. -- FILE : FTPSRVUTL               AUTHOR : MARK VOLPE
  6709.  
  6710. -- 5/20/85    8:37 AM : REVISED FOR USE WITH DEC COMPILER 
  6711. --                      OLD CODE (TELESOFT) MARKED WITH --&MT  
  6712.  
  6713. -- 5/31/85    9:46 AM : REVISED FOR USE WITH TELESOFT COMPILER
  6714. --                      OLD CODE (DEC) MARKED WITH --&MT
  6715.  
  6716. -- 5/31/85    10:21 AM : REVISED FOR USE WITH THE DEC COMPILER
  6717. --                       OLD CODE (TELESOFT) MARKED WITH --&MT
  6718.  
  6719. --&MT THE FOLLOWING LINE WAS ADDED TO GIVE FTPSRVUTL.ADA ACCESS TO TEXT_IO :
  6720. WITH TEXT_IO;
  6721.  
  6722. PACKAGE BODY Server_utilities IS
  6723.  
  6724. --&MT SUBTYPE BIT_COUNT_32_TYPE IS LONG_INTEGER;
  6725.       SUBTYPE BIT_COUNT_32_TYPE IS INTEGER;
  6726.  
  6727. --&MT SUBTYPE BIT_COUNT_16_TYPE IS INTEGER;
  6728.       SUBTYPE BIT_COUNT_16_TYPE IS SHORT_INTEGER;
  6729.  
  6730. --&MT THE FOLLOWING LINES SHOULD BE DELETED WHEN USING TELESOFT
  6731. PACKAGE LONG_INT IS NEW TEXT_IO.INTEGER_IO(BIT_COUNT_32_TYPE);
  6732. PACKAGE INT_IO IS NEW TEXT_IO.INTEGER_IO(BIT_COUNT_16_TYPE);
  6733.  
  6734.   PROCEDURE Assign 
  6735.       ( Reply_code  : OUT Reply_types.telnet_reply_code_spec;
  6736.         Code_string : IN  STRING ) IS
  6737.  
  6738.   --&MT Code_string_index : BIT_COUNT_16_TYPE := Code_string'first;
  6739.         Code_string_index : BIT_COUNT_32_TYPE := Code_string'first;
  6740.  
  6741.     BEGIN
  6742.         -- My_debug_io.put_line(" Assigning(1)");
  6743.         FOR Index IN Reply_code'RANGE LOOP
  6744.             Reply_code( Index ) :=
  6745.                 Reply_types.valid_reply_code_character'
  6746.                     ( Code_string( Code_string_index ));
  6747.             Code_string_index := Code_string_index + 1;
  6748.         END LOOP;
  6749.         -- My_debug_io.put_line(" Finished assigning(1)");
  6750.     EXCEPTION
  6751.         WHEN OTHERS => RAISE;
  6752.     END Assign;
  6753.  
  6754.   PROCEDURE Assign( Reply_message : OUT Ftp_types.argument_list ;
  6755.         Message_text  : IN  STRING ) IS
  6756.         Reply_index         : BIT_COUNT_16_TYPE := Reply_message'FIRST;
  6757.     BEGIN
  6758.         -- My_debug_io.put_line(" Assigning(2)");
  6759.         Reply_message := Ftp_types.null_argument;
  6760.         FOR Index IN Message_text'RANGE LOOP
  6761.             Reply_message( Reply_index ) := Message_text( Index );
  6762.             Reply_index := Reply_index + 1;
  6763.         END LOOP;
  6764.         -- My_debug_io.put_line(" Finished assigning(2)");
  6765.     EXCEPTION
  6766.         WHEN OTHERS => RAISE ;
  6767.     END Assign;
  6768.  
  6769.   PROCEDURE Send_message ( Reply_text : IN STRING ) IS
  6770.         Reply_message : Ftp_types.argument_list ;
  6771.     BEGIN
  6772.         -- My_debug_io.put_line(" Sending message over telnet");
  6773.         Assign ( Reply_message, Reply_text );
  6774.         Send_reply_over_telnet ( Reply_message );
  6775.         -- My_debug_io.put_line(" Finished sending message over telnet");
  6776.     EXCEPTION
  6777.         WHEN OTHERS => Raise;
  6778.     END Send_message;
  6779.  
  6780.   PROCEDURE Send_system_help_message is
  6781.     BEGIN
  6782.       Send_message(" The following are recognized commands at this site" );
  6783.       Send_message(" USER - Logs the user onto this system (needs username)");
  6784.       Send_message(" PASS - Required after USER" );
  6785.       Send_message(" QUIT - Logs user off and closes telnet connection" );
  6786.       Send_message(" NOOP - Sends a noop command to the remote system" );
  6787.       Send_message(" PORT - Changes the data transfer port for this system" );
  6788.       Send_message(" TYPE - Changes the data transfer type and " &
  6789.                     "carriage control used in file transfer" );
  6790.       Send_message(" MODE - Changes the data transfer mode used " &
  6791.                     "in file transfer" );
  6792.       Send_message(" STRU - Changes the data transfer structure " &
  6793.                     "used in file transfer" );
  6794.       Send_message(" HELP - Outputs this message" );
  6795.       Send_message(" STOR - Copies a file from another system to this system");
  6796.       Send_message(" RETR - Sends a copy of a file to another system" );
  6797.     EXCEPTION
  6798.         WHEN OTHERS => RAISE;
  6799.     END Send_system_help_message;
  6800.  
  6801.   PROCEDURE Send_reply_over_telnet
  6802.         ( Reply_message : IN Ftp_types.argument_list ) IS
  6803.             Xmit_status : Ftp_command_utilities.transmission_status_spec;
  6804.             Xmit_failure: EXCEPTION;
  6805.     BEGIN
  6806.         -- My_debug_io.put_line(" Sending reply(1) over telnet");
  6807.         Ftp_command_utilities.send_command_over_telnet
  6808.             ( Xmit_status, Ftp_types.reply_command, Reply_message );
  6809.         IF NOT Ftp_command_utilities.transmission_successful(xmit_status) THEN
  6810.             RAISE Xmit_failure;
  6811.         END IF;
  6812.         -- My_debug_io.put_line(" Finished sending reply(1) over telnet");
  6813.     EXCEPTION
  6814.         WHEN OTHERS => RAISE;
  6815.     END Send_reply_over_telnet;
  6816.  
  6817.   PROCEDURE Send_reply_over_telnet ( Reply_code_string : IN STRING) IS
  6818.         Reply_code     : Reply_types.telnet_reply_code_spec;
  6819.         Reply_message  : Ftp_types.argument_list;
  6820.     BEGIN
  6821.         -- My_debug_io.put_line(" Sending reply(2) over telnet");
  6822.         Assign ( Reply_code, Reply_code_string );
  6823.         Reply_utilities.add_text_to_reply( Reply_code, Reply_message );
  6824.         Send_reply_over_telnet ( Reply_message );
  6825.         -- My_debug_io.put_line(" Finished sending reply(2) over telnet");
  6826.     EXCEPTION
  6827.         WHEN OTHERS => RAISE;
  6828.     END Send_reply_over_telnet;
  6829.  
  6830. BEGIN
  6831.     NULL;
  6832. EXCEPTION
  6833.         WHEN OTHERS => RAISE;
  6834. END Server_utilities;
  6835. --::::::::::::::
  6836. --ftpsrvlog_.ada
  6837. --::::::::::::::
  6838. -----------------------------------------------------------------------
  6839. --
  6840. --         DoD Protocols    NA-00005-200       80-01095-100(-)
  6841. --         E-Systems, Inc.  August 07, 1985
  6842. --
  6843. --         FTPSRVLOG_.ADA       Author : Mark Volpe
  6844. --
  6845. -----------------------------------------------------------------------
  6846. -- FILE : FTPSRVLOG               AUTHOR : MARK VOLPE
  6847.  
  6848. -- 5/20/85    9:08 AM : REVISED FOR USE WITH DEC COMPILER 
  6849. --                      OLD CODE (TELESOFT) MARKED WITH --&MT  
  6850.  
  6851. -- 5/31/85    10:10 AM : REVISED FOR USE WITH TELESOFT COMPILER
  6852. --                       OLD CODE (DEC) MARKED WITH --&MT
  6853.  
  6854. -- 5/31/85    10:37 AM : REVISED FOR USE WITH THE DEC COMPILER
  6855. --                       OLD CODE (TELESOFT) MARKED WITH --&MT
  6856.  
  6857. --&MT THE FOLLOWING LINE SHOULD BE DELETED WHEN USING DEC ADA :
  6858. --&MT PRAGMA SOURCE_INFO ( ON );
  6859.  
  6860. WITH My_debug_io, Ftp_types, Server_utilities, Ftp_telnet, Ftp_utilities;
  6861. USE  My_debug_io, Ftp_types, Server_utilities, Ftp_telnet, Ftp_utilities;
  6862.  
  6863. PACKAGE Server_login_commands IS
  6864.  
  6865.   PROCEDURE Logout 
  6866.             ( Ftp_parameters : IN OUT Ftp_utilities.ftp_parameters_spec ) ;
  6867.         ----------------------------------------------------------------------
  6868.         --
  6869.         -- This procedure logs the user out but leaves telnet open.
  6870.         -- No replies are sent over telnet.
  6871.         --
  6872.         ----------------------------------------------------------------------
  6873.  
  6874.   PROCEDURE Log_user_onto_system
  6875.         ( Status         :    OUT Ftp_utilities.command_status_spec;
  6876.           Ftp_parameters : IN OUT Ftp_utilities.ftp_parameters_spec;
  6877.           Argument       : IN     Ftp_types.argument_list );
  6878.     ----------------------------------------------------------------------
  6879.     --
  6880.     -- This procedure logs the user onto the system.
  6881.     -- If the user is already logged in then he is logged out and 
  6882.     -- re-logged in under the new user name.
  6883.     -- A reply is sent indicating the login status.
  6884.     --
  6885.     ----------------------------------------------------------------------
  6886.  
  6887.   PROCEDURE Log_user_off_of_system
  6888.         ( Status         :    OUT Ftp_utilities.command_status_spec;
  6889.           Ftp_parameters : IN OUT Ftp_utilities.ftp_parameters_spec;
  6890.           Argument       : IN     Ftp_types.argument_list );
  6891.     ----------------------------------------------------------------------
  6892.     --
  6893.     -- This procedure logs the user off of the system and closes the telnet
  6894.     -- connection. 
  6895.     -- A reply is sent indicating the login status.
  6896.     --
  6897.     ----------------------------------------------------------------------
  6898.  
  6899. END Server_login_commands;
  6900.  
  6901. --::::::::::::::
  6902. --ftpsrvlog.ada
  6903. --::::::::::::::
  6904. -----------------------------------------------------------------------
  6905. --
  6906. --         DoD Protocols    NA-00005-200       80-01096-100(-)
  6907. --         E-Systems, Inc.  August 07, 1985
  6908. --
  6909. --         FTPSRVLOG.ADA       Author : Mark Volpe
  6910. --
  6911. -----------------------------------------------------------------------
  6912. -- FILE : FTPSRVLOG               AUTHOR : MARK VOLPE
  6913.  
  6914. -- 5/20/85    9:08 AM : REVISED FOR USE WITH DEC COMPILER 
  6915. --                      OLD CODE (TELESOFT) MARKED WITH --&MT  
  6916.  
  6917. -- 5/31/85    10:10 AM : REVISED FOR USE WITH TELESOFT COMPILER
  6918. --                       OLD CODE (DEC) MARKED WITH --&MT
  6919.  
  6920. -- 5/31/85    10:40 AM : REVISED FOR USE WITH THE DEC COMPILER
  6921. --                       OLD CODE (TELESOFT) MARKED WITH --&MT
  6922. -- 7/18/85    4:46 PM : relpy_message => "xxx"  to  reply_code_string => "xxx"
  6923.  
  6924. PACKAGE BODY Server_login_commands IS
  6925.   Logout_error : EXCEPTION;
  6926.   PROCEDURE Logout 
  6927.             ( Ftp_parameters : IN OUT Ftp_utilities.ftp_parameters_spec ) IS
  6928.     BEGIN
  6929.         --D My_debug_io.put_line("  Logging user off of system ");
  6930.         Indicate_user_is_logged_out ( Ftp_parameters );
  6931.     EXCEPTION
  6932.         WHEN OTHERS => RAISE Logout_error;
  6933.     END Logout;
  6934.  
  6935.   PROCEDURE Log_user_onto_system 
  6936.         ( Status         : OUT    Ftp_utilities.command_status_spec;
  6937.           Ftp_parameters : IN OUT Ftp_utilities.ftp_parameters_spec;
  6938.           Argument       : IN     Ftp_types.argument_list ) IS
  6939.     BEGIN
  6940.         IF User_is_logged_in ( Ftp_parameters ) THEN
  6941.             Logout ( Ftp_parameters );
  6942.         END IF;
  6943.         NULL; -- log user in
  6944.         Indicate_user_is_logged_in ( Ftp_parameters );
  6945.         Indicate_command_was_successful ( Status );
  6946.  
  6947.   --&MT Send_reply_over_telnet("230");
  6948.         Send_reply_over_telnet(reply_code_string => "230");
  6949.  
  6950.     EXCEPTION
  6951.         WHEN Logout_error => -- Still logged in under old username
  6952.             --D My_debug_io.put_line(" Logout error in Log_user_onto_system ");
  6953.             Indicate_command_was_not_successful ( Status );
  6954.  
  6955.       --&MT Send_reply_over_telnet("500");
  6956.             Send_reply_over_telnet( reply_code_string => "500");
  6957.  
  6958.         WHEN OTHERS =>
  6959.             --D My_debug_io.put_line (" Unknown error in Log_user_onto_system");
  6960.             Indicate_command_was_not_successful ( Status );
  6961.  
  6962.       --&MT Send_reply_over_telnet("530");
  6963.             Send_reply_over_telnet( reply_code_string => "530");
  6964.  
  6965.             RAISE;
  6966.     END Log_user_onto_system;
  6967.  
  6968.   PROCEDURE Log_user_off_of_system
  6969.             ( Status         : OUT    Ftp_utilities.command_status_spec ;
  6970.               Ftp_parameters : IN OUT Ftp_utilities.ftp_parameters_spec ;
  6971.               Argument       : IN     Ftp_types.argument_list ) IS
  6972.         Telnet_status    : Ftp_telnet.telnet_status_spec;
  6973.     BEGIN
  6974.         --D My_debug_io.put_line (" Logging user off of system ");
  6975.         Logout ( Ftp_parameters );
  6976.         Indicate_command_was_successful ( Status );
  6977.  
  6978.   --&MT Send_reply_over_telnet("221");
  6979.         Send_reply_over_telnet( reply_code_string => "221" );
  6980.  
  6981.         Close_telnet_link ( Telnet_status, Argument );
  6982.         --D My_debug_io.put_line("  User logged off of system ");
  6983.     EXCEPTION
  6984.         WHEN OTHERS =>
  6985.             Indicate_command_was_not_successful ( Status );
  6986.             --D My_debug_io.put_line(" Unknown error - Log_user_off_of_system");
  6987.  
  6988.       --&MT Send_reply_over_telnet("421");  
  6989.             Send_reply_over_telnet( reply_code_string => "421");
  6990.  
  6991.             RAISE;
  6992.     END Log_user_off_of_system;
  6993.  
  6994. BEGIN
  6995.     NULL;
  6996. EXCEPTION
  6997.     WHEN OTHERS =>
  6998.         NULL;
  6999.         --D My_debug_io.put_line ("  Unknown error in SERVER_LOGIN ");
  7000. END Server_login_commands;
  7001. --::::::::::::::
  7002. --ftpsrvdtp_.ada
  7003. --::::::::::::::
  7004. -----------------------------------------------------------------------
  7005. --
  7006. --         DoD Protocols    NA-00005-200       80-01093-100(-)
  7007. --         E-Systems, Inc.  August 07, 1985
  7008. --
  7009. --         FTPSRVDTP_.ADA       Author : Mark Volpe
  7010. --
  7011. -----------------------------------------------------------------------
  7012. -- FILE : FTPSRVDTP               AUTHOR : MARK VOLPE
  7013.  
  7014. -- 5/20/85    9:39 AM : REVISED FOR USE WITH DEC COMPILER 
  7015. --                      OLD CODE (TELESOFT) MARKED WITH --&MT  
  7016.  
  7017. -- 5/31/85    10:29 AM : REVISED FOR USE WITH TELESOFT COMPILER
  7018. --                       OLD CODE (DEC) MARKED WITH --&MT
  7019.  
  7020. -- 5/31/85    10:50 AM : REVISED FOR USE WITH THE DEC COMPILER
  7021. --                       OLD CODE (TELESOFT) MARKED WITH --&MT
  7022.  
  7023. --&MT THE FOLLOWING LINE SHOULD BE DELETED WHEN USING DEC ADA :
  7024. --&MT PRAGMA SOURCE_INFO ( ON );
  7025.  
  7026. WITH     Ftp_types, Ftp_utilities, Site_details, Server_utilities;
  7027.  
  7028. PACKAGE Server_dtp_commands IS
  7029.    ----------------------------------------------------------------------
  7030.    --
  7031.    -- This package contains procedures to process comannds which
  7032.    -- effect the server's dtp.
  7033.    --
  7034.    ----------------------------------------------------------------------
  7035.  
  7036.     PROCEDURE Change_default_structure 
  7037.         ( status : out Ftp_utilities.command_status_spec;
  7038.                   Server_parameters : IN OUT Ftp_utilities.ftp_parameters_spec;
  7039.              Argument : IN Ftp_types.argument_list );
  7040.         ----------------------------------------------------------------------
  7041.         --
  7042.        -- This procedure changes the file structure to be used during
  7043.        -- file transfers which use tcp.
  7044.         --
  7045.         ----------------------------------------------------------------------
  7046.  
  7047.       PROCEDURE Change_default_type 
  7048.         ( status : out Ftp_utilities.command_status_spec;
  7049.                   Server_parameters : IN OUT Ftp_utilities.ftp_parameters_spec;
  7050.              Argument : IN Ftp_types.argument_list );
  7051.         ----------------------------------------------------------------------
  7052.         --
  7053.        -- This procedure changes the file type to be used during
  7054.        -- file transfers which use tcp.
  7055.         --
  7056.         ----------------------------------------------------------------------
  7057.  
  7058.       PROCEDURE Change_default_mode 
  7059.         ( Status : out Ftp_utilities.command_status_spec;
  7060.                   Server_parameters : IN OUT Ftp_utilities.ftp_parameters_spec;
  7061.              Argument : IN Ftp_types.argument_list );
  7062.         ----------------------------------------------------------------------
  7063.         --
  7064.        -- This procedure changes the file mode to be used during
  7065.        -- file transfers which use tcp.
  7066.         --
  7067.         ----------------------------------------------------------------------
  7068.  
  7069.       PROCEDURE Change_default_port
  7070.         ( Status : out Ftp_utilities.command_status_spec;
  7071.                   Server_parameters : IN OUT Ftp_utilities.ftp_parameters_spec;
  7072.              Argument : IN Ftp_types.argument_list );
  7073.         ----------------------------------------------------------------------
  7074.         --
  7075.        -- This procedure changes the transmit port to be used during
  7076.        -- file transfers which use tcp.
  7077.         --
  7078.         ----------------------------------------------------------------------
  7079.  
  7080. END Server_dtp_commands ;
  7081.  
  7082. --::::::::::::::
  7083. --ftpsrvdtp.ada
  7084. --::::::::::::::
  7085. -----------------------------------------------------------------------
  7086. --
  7087. --         DoD Protocols    NA-00005-200       80-01094-100(-)
  7088. --         E-Systems, Inc.  August 07, 1985
  7089. --
  7090. --         FTPSRVDTP.ADA       Author : Mark Volpe
  7091. --
  7092. -----------------------------------------------------------------------
  7093. -- FILE : FTPSRVDTP               AUTHOR : MARK VOLPE
  7094.  
  7095. -- 5/20/85    9:39 AM : REVISED FOR USE WITH DEC COMPILER 
  7096. --                      OLD CODE (TELESOFT) MARKED WITH --&MT  
  7097.  
  7098. -- 5/31/85    10:29 AM : REVISED FOR USE WITH TELESOFT COMPILER
  7099. --                       OLD CODE (DEC) MARKED WITH --&MT
  7100.  
  7101. -- 5/31/85    10:55 PM  : REVISED FOR USE WITH THE DEC COMPILER
  7102. --                        OLD CODE (TELESOFT) MARKED WITH --&MT
  7103. -- 7/18/85    4:54 PM  : relpy_message => "xxx"  to  reply_code_string => "xxx"
  7104.  
  7105. PACKAGE BODY Server_dtp_commands IS
  7106.  
  7107.   PROCEDURE Change_default_type 
  7108.            ( Status : out Ftp_utilities.command_status_spec;
  7109.                   Server_parameters : IN OUT Ftp_utilities.ftp_parameters_spec;
  7110.              Argument : IN Ftp_types.argument_list ) IS
  7111.         temp_status : Ftp_utilities.command_status_spec;
  7112.     BEGIN
  7113.         Ftp_utilities.change_file_type ( temp_status, Server_parameters, Argument );
  7114.         IF Ftp_utilities.command_was_successful ( temp_status ) THEN
  7115.  
  7116.        --&MT Server_utilities.send_reply_over_telnet ( "200");
  7117.              Server_utilities.send_reply_over_telnet ( reply_code_string => "200" );
  7118.  
  7119.         ELSE
  7120.             Ftp_utilities.indicate_command_was_not_successful ( temp_status );
  7121.  
  7122.       --&MT Server_utilities.send_reply_over_telnet ( "504");
  7123.             Server_utilities.send_reply_over_telnet ( reply_code_string => "504");
  7124.  
  7125.         END IF;
  7126.         status := temp_status;
  7127.     EXCEPTION
  7128.         WHEN OTHERS => 
  7129.             --D My_debug_io.put_line ("  CHANGE_DEFAULT_TYPE FAILED ");
  7130.             Ftp_utilities.indicate_command_was_not_successful ( temp_status );
  7131.  
  7132.       --&MT Server_utilities.send_reply_over_telnet( "500");
  7133.             Server_utilities.send_reply_over_telnet ( reply_code_string => "500");
  7134.  
  7135.             status := temp_status ;
  7136.     END Change_default_type;
  7137.  
  7138.   PROCEDURE Change_default_structure 
  7139.               ( Status : out Ftp_utilities.command_status_spec;
  7140.                   Server_parameters : IN OUT Ftp_utilities.ftp_parameters_spec;
  7141.              Argument : IN Ftp_types.argument_list ) IS
  7142.       temp_status : Ftp_utilities.command_status_spec;
  7143.     BEGIN
  7144.         Ftp_utilities.change_file_structure(temp_status,Server_parameters,Argument);
  7145.         IF Ftp_utilities.command_was_successful ( temp_status ) THEN
  7146.  
  7147.   --&MT Server_utilities.send_reply_over_telnet ( "200");
  7148.         Server_utilities.send_reply_over_telnet ( reply_code_string => "200");
  7149.             
  7150.         ELSE
  7151.             Ftp_utilities.indicate_command_was_not_successful( temp_status );
  7152.  
  7153.       --&MT Server_utilities.send_reply_over_telnet ( "504");
  7154.             Server_utilities.send_reply_over_telnet ( reply_code_string => "504");
  7155.  
  7156.         END IF;
  7157.       status := temp_status ;
  7158.     EXCEPTION
  7159.         WHEN OTHERS => 
  7160.             --D My_debug_io.put_line ("  CHANGE_DEFAULT_STRUCTURE FAILED ");
  7161.             Ftp_utilities.indicate_command_was_not_successful( temp_status );
  7162.  
  7163.       --&MT Server_utilities.send_reply_over_telnet ( "500");
  7164.             Server_utilities.send_reply_over_telnet ( reply_code_string => "500");
  7165.  
  7166.             status := temp_status ;
  7167.     END Change_default_structure;
  7168.  
  7169.   PROCEDURE Change_default_mode 
  7170.               ( Status : out Ftp_utilities.command_status_spec;
  7171.                   Server_parameters : IN OUT Ftp_utilities.ftp_parameters_spec;
  7172.              Argument : IN Ftp_types.argument_list  ) IS
  7173.       temp_status : Ftp_utilities.command_status_spec ;
  7174.     BEGIN
  7175.         Ftp_utilities.change_file_mode( temp_status, Server_parameters, Argument );
  7176.         IF Ftp_utilities.command_was_successful ( temp_status ) THEN
  7177.  
  7178.       --&MT Server_utilities.send_reply_over_telnet ( "200" );
  7179.             Server_utilities.send_reply_over_telnet ( reply_code_string => "200");
  7180.  
  7181.         ELSE
  7182.  
  7183.       --&MT Server_utilities.send_reply_over_telnet ( "504" );
  7184.             Server_utilities.send_reply_over_telnet ( reply_code_string => "504");
  7185.  
  7186.             Ftp_utilities.indicate_command_was_not_successful( temp_status );
  7187.         END IF;
  7188.       status := temp_status ; 
  7189.     EXCEPTION
  7190.         WHEN OTHERS => 
  7191.             --D My_debug_io.put_line ("  CHANGE_DEFAULT_MODE FAILED ");
  7192.             Ftp_utilities.indicate_command_was_not_successful( temp_status );
  7193.  
  7194.       --&MT Server_utilities.send_reply_over_telnet ( "500");
  7195.             Server_utilities.send_reply_over_telnet ( reply_code_string => "500");
  7196.  
  7197.             status := temp_status ;
  7198.     END Change_default_mode;
  7199.  
  7200.   PROCEDURE Change_default_port
  7201.         ( Status : out Ftp_utilities.command_status_spec;
  7202.                   Server_parameters : IN OUT Ftp_utilities.ftp_parameters_spec;
  7203.              Argument : IN Ftp_types.argument_list ) IS
  7204.       temp_status : Ftp_utilities.command_status_spec;
  7205.     BEGIN
  7206.         IF Site_details.specified_host_is_this_host ( Argument ) THEN
  7207.             Ftp_utilities.change_port( temp_status, Server_parameters, Argument );
  7208.             IF Ftp_utilities.command_was_successful ( temp_status ) THEN
  7209.  
  7210.           --&MT Server_utilities.send_reply_over_telnet( "200");
  7211.                 Server_utilities.send_reply_over_telnet ( reply_code_string => "200");          
  7212.  
  7213.             ELSE
  7214.  
  7215.           --&MT Server_utilities.send_reply_over_telnet( "501");
  7216.                 Server_utilities.send_reply_over_telnet ( reply_code_string => "501");
  7217.  
  7218.                 Ftp_utilities.indicate_command_was_not_successful( temp_status );
  7219.             END IF;
  7220.         ELSE
  7221.  
  7222.       --&MT Server_utilities.send_reply_over_telnet( "501");
  7223.             Server_utilities.send_reply_over_telnet ( reply_code_string => "501");
  7224.  
  7225.             Ftp_utilities.indicate_command_was_not_successful( temp_status );
  7226.         END IF;
  7227.       status := temp_status ;
  7228.     EXCEPTION
  7229.         WHEN OTHERS => 
  7230.             --D My_debug_io.put_line ("  CHANGE_DEFAULT_PORT FAILED ");
  7231.             Ftp_utilities.indicate_command_was_not_successful( temp_status );
  7232.  
  7233.       --&MT Server_utilities.send_reply_over_telnet ( "500");
  7234.             Server_utilities.send_reply_over_telnet ( reply_code_string => "500");  
  7235.  
  7236.         status := temp_status ;
  7237.     END Change_default_port;
  7238.  
  7239. BEGIN
  7240.     NULL;
  7241. EXCEPTION
  7242.     WHEN OTHERS => 
  7243.         NULL;
  7244.         --D My_debug_io.put_line (" Unknown error in Server_dtp_commands");
  7245. END Server_dtp_commands;
  7246. --::::::::::::::
  7247. --ftpsrvpi_.ada
  7248. --::::::::::::::
  7249. -----------------------------------------------------------------------
  7250. --
  7251. --         DoD Protocols    NA-00005-200       80-01097-100(-)
  7252. --         E-Systems, Inc.  August 07, 1985
  7253. --
  7254. --         FTPSRVPI_.ADA       Author : Mark Volpe
  7255. --
  7256. -----------------------------------------------------------------------
  7257. -- FILE : FTPSRVPI               AUTHOR : MARK VOLPE
  7258.  
  7259. -- 5/20/85    3:38 PM : REVISED FOR USE WITH DEC COMPILER 
  7260. --                      OLD CODE (TELESOFT) MARKED WITH --&MT  
  7261.  
  7262. -- 5/31/85    10:43 AM : REVISED FOR USE WITH TELESOFT COMPILER
  7263. --                       OLD CODE (DEC) MARKED WITH --&MT
  7264.  
  7265. -- 5/31/85    11:04 AM : REVISED FOR USE WITH THE DEC COMPILER
  7266. --                       OLD CODE (TELESOFT) MARKED WITH --&MT
  7267.  
  7268. --&MT THE FOLLOWING LINE SHOULD BE DELETED WHEN USING DEC ADA :
  7269. --&MT PRAGMA SOURCE_INFO ( ON );
  7270.  
  7271. WITH     Ftp_types, Reply_types,
  7272.         Reply_utilities, Server_utilities, Ftp_utilities;
  7273.  
  7274. PACKAGE Server_pi_commands IS
  7275.    ----------------------------------------------------------------------
  7276.    --
  7277.    --    This package contains procedures to procces commands which 
  7278.    --    effect the server pi.
  7279.    --
  7280.    ----------------------------------------------------------------------
  7281.  
  7282.    PROCEDURE Process_noop_from_user_pi
  7283.            ( status : out Ftp_utilities.command_status_spec );
  7284.         ----------------------------------------------------------------------
  7285.         --
  7286.        -- This procedure sends a reply code of '200' to
  7287.        -- the user's system.
  7288.         --
  7289.         ----------------------------------------------------------------------
  7290.  
  7291.    PROCEDURE Process_help_from_user_pi 
  7292.                ( status : out Ftp_utilities.command_status_spec;
  7293.                    Argument : IN Ftp_types.argument_list );
  7294.         ----------------------------------------------------------------------
  7295.        -- This procedure sends helpful information
  7296.        -- to the user via telnet.  The data is sent as
  7297.        -- a multiline reply.
  7298.         --
  7299.         ----------------------------------------------------------------------
  7300.  
  7301. END Server_pi_commands;
  7302.  
  7303. --::::::::::::::
  7304. --ftpsrvpi.ada
  7305. --::::::::::::::
  7306. -----------------------------------------------------------------------
  7307. --
  7308. --         DoD Protocols    NA-00005-200       80-01098-100(-)
  7309. --         E-Systems, Inc.  August 07, 1985
  7310. --
  7311. --         FTPSRVPI.ADA       Author : Mark Volpe
  7312. --
  7313. -----------------------------------------------------------------------
  7314. -- FILE : FTPSRVPI               AUTHOR : MARK VOLPE
  7315.  
  7316. -- 5/20/85    3:38 PM : REVISED FOR USE WITH DEC COMPILER 
  7317. --                      OLD CODE (TELESOFT) MARKED WITH --&MT  
  7318.  
  7319. -- 5/31/85    10:43 AM : REVISED FOR USE WITH TELESOFT COMPILER
  7320. --                       OLD CODE (DEC) MARKED WITH --&MT
  7321.  
  7322. -- 5/31/85    11:05 AM : REVISED FOR USE WITH THE DEC COMPILER
  7323. --                       OLD CODE (TELESOFT) MARKED WITH --&MT
  7324. -- 7/18/85     5:05 PM : relpy_message => "xxx"  to  reply_code_string => "xxx"
  7325.  
  7326. PACKAGE BODY Server_pi_commands IS
  7327.  
  7328.   PROCEDURE Process_noop_from_user_pi 
  7329.            ( status : out Ftp_utilities.command_status_spec ) IS
  7330.     BEGIN
  7331.         Ftp_utilities.indicate_command_was_successful( Status );
  7332.  
  7333.   --&MT Server_utilities.send_reply_over_telnet ( "200" );
  7334.         Server_utilities.send_replY_over_telnet ( reply_code_string => "200");
  7335.  
  7336.     EXCEPTION
  7337.         WHEN OTHERS =>
  7338.             --D My_debug_io.put_line ("  PROCESS_NOOP FAILED");
  7339.  
  7340.       --&MT Server_utilities.send_reply_over_telnet ( "200" );
  7341.             Server_utilities.send_replY_over_telnet ( reply_code_string => "200");
  7342.  
  7343.             Ftp_utilities.indicate_command_was_not_successful( Status );
  7344.     END Process_noop_from_user_pi;
  7345.  
  7346.   PROCEDURE Process_help_from_user_pi 
  7347.            ( status : out Ftp_utilities.command_status_spec;
  7348.              Argument : IN Ftp_types.argument_list ) IS
  7349.         Reply_message : Ftp_types.argument_list;   
  7350.           Reply_code    : Reply_types.telnet_reply_code_spec;
  7351.     BEGIN
  7352.         --
  7353.         -- Leave this in long form
  7354.         --
  7355.         Ftp_utilities.indicate_command_was_successful( Status);
  7356.         Server_utilities.assign ( Reply_code, "214");
  7357.         Reply_utilities.add_text_to_reply( Reply_code, Reply_message);
  7358.         Reply_utilities.indicate_multiline_reply( Reply_message );
  7359.         Server_utilities.send_reply_over_telnet( Reply_message );
  7360.         Server_utilities.send_system_help_message;
  7361.         Server_utilities.assign ( Reply_code, "214");
  7362.         Reply_utilities.add_text_to_reply( Reply_code, Reply_message);
  7363.         Server_utilities.send_reply_over_telnet( Reply_message );
  7364.   EXCEPTION
  7365.         WHEN OTHERS => 
  7366.             --D My_debug_io.put_line (" PROCESS_HELP FAILED");
  7367.  
  7368.       --&MT Server_utilities.send_reply_over_telnet ( "500" );
  7369.             Server_utilities.send_replY_over_telnet ( reply_code_string => "500");
  7370.  
  7371.             Ftp_utilities.indicate_command_was_not_successful( STATUS );
  7372.   END Process_help_from_user_pi;
  7373.  
  7374. BEGIN
  7375.     NULL;
  7376. EXCEPTION
  7377.     WHEN OTHERS =>
  7378.         --D My_debug_io.put_line ("  Error in server_pi_commands ");
  7379.         RAISE;
  7380. END Server_pi_commands ;
  7381. --::::::::::::::
  7382. --ftpsrvxfr_.ada
  7383. --::::::::::::::
  7384. -----------------------------------------------------------------------
  7385. --
  7386. --         DoD Protocols    NA-00005-200       80-01101-100(-)
  7387. --         E-Systems, Inc.  August 07, 1985
  7388. --
  7389. --         FTPSRVXFR_.ADA       Author : Mark Volpe
  7390. --
  7391. -----------------------------------------------------------------------
  7392. -- FILE : FTPSRVXFR               AUTHOR : MARK VOLPE
  7393.  
  7394. -- 5/21/85    8:16 AM : REVISED FOR USE WITH DEC COMPILER 
  7395. --                      OLD CODE (TELESOFT) MARKED WITH --&MT  
  7396.  
  7397. -- 5/31/85    10:51 AM : REVISED FOR USE WITH TELESOFT COMPILER
  7398. --                       OLD CODE (DEC) MARKED WITH --&MT
  7399.  
  7400. -- 5/31/85    1:35 PM  : REVISED FOR USE WITH THE DEC COMPILER
  7401. --                       OLD CODE (TELESOFT) MARKED WITH --&MT
  7402.  
  7403. --&MT THE FOLLOWING LINE SHOULD BE DELETED WHEN USING DEC ADA :
  7404. --&MT PRAGMA SOURCE_INFO ( ON );
  7405.  
  7406. WITH My_debug_io;
  7407. WITH Server_utilities;           USE Server_utilities;
  7408. WITH FTP_COMMAND_UTILITIES;      USE Ftp_command_utilities;
  7409. WITH Ftp_types;                  USE Ftp_types;
  7410. WITH Ftp_utilities;              USE Ftp_utilities;
  7411. WITH Ftp_file_io;                USE Ftp_file_io;
  7412. WITH Ftp_tcp;                    USE Ftp_tcp;
  7413.  
  7414. PACKAGE Server_xfer_commands IS
  7415.    ----------------------------------------------------------------------
  7416.    --
  7417.    -- This package contains procedures used by the server system during
  7418.    -- file transfers.
  7419.    --
  7420.    ----------------------------------------------------------------------
  7421.  
  7422.   PROCEDURE Accept_file_user_to_server 
  7423.            ( Status            : OUT FTP_UTILITIES.COMMAND_STATUS_SPEC;
  7424.                   Server_parameters : IN  FTP_UTILITIES.FTP_PARAMETERS_SPEC;
  7425.              Argument          : IN  FTP_TYPES.ARGUMENT_LIST );
  7426.         ----------------------------------------------------------------------
  7427.         --
  7428.        -- This procedure performs the handshaking required to accept
  7429.         -- a file from the user system via tcp.  The actual transfer is done 
  7430.         -- with a procedure call.
  7431.         -- ( STOR )
  7432.         ----------------------------------------------------------------------
  7433.  
  7434.    PROCEDURE Send_file_server_to_user 
  7435.            ( Status            : OUT FTP_UTILITIES.COMMAND_STATUS_SPEC;
  7436.                   Server_parameters : IN  FTP_UTILITIES.FTP_PARAMETERS_SPEC;
  7437.              Argument          : IN  FTP_TYPES.ARGUMENT_LIST );
  7438.         ----------------------------------------------------------------------
  7439.         --
  7440.        -- This procedure performs the handshaking required to send 
  7441.         -- a file from the server to the user system via tcp.
  7442.         -- The actual transfer is done with a procedure call.
  7443.         -- ( RETR )
  7444.         ----------------------------------------------------------------------
  7445.  
  7446. END Server_xfer_commands;
  7447.  
  7448. --::::::::::::::
  7449. --ftpsrvxfr.ada
  7450. --::::::::::::::
  7451. -----------------------------------------------------------------------
  7452. --
  7453. --         DoD Protocols    NA-00005-200       80-01102-100(-)
  7454. --         E-Systems, Inc.  August 07, 1985
  7455. --
  7456. --         FTPSRVXFR.ADA       Author : Mark Volpe
  7457. --
  7458. -----------------------------------------------------------------------
  7459. -- FILE : FTPSRVXFR               AUTHOR : MARK VOLPE
  7460.  
  7461. -- 5/21/85    8:16 AM : REVISED FOR USE WITH DEC COMPILER 
  7462. --                      OLD CODE (TELESOFT) MARKED WITH --&MT  
  7463.  
  7464. -- 5/31/85    10:51 AM : REVISED FOR USE WITH TELESOFT COMPILER
  7465. --                       OLD CODE (DEC) MARKED WITH --&MT
  7466. -- 7/10/85     6:30 PM : global_tcp_identifier added
  7467. -- 7/18/85     5:11 PM : relpy_message => "xxx"  to  reply_code_string => "xxx"
  7468. -- 7/19/85    11:31 AM : do send_the_file after opening connection in
  7469. --                     : set_up_tcp_and_send_file
  7470. --             4:22 PM : close data link in send_file_server_to user
  7471. -- 7/24/85     1:40 AM : don't close file in set_up_and_send_file
  7472.  
  7473. --&MT THE FOLLOWING LINE WAS ADDED TO GIVE FTPSRVXFR.ADA ACCESS TO TEXT_IO :
  7474. WITH TEXT_IO ;
  7475.  
  7476. PACKAGE BODY Server_xfer_commands IS
  7477.   Transfer_failed          : EXCEPTION;
  7478.   Transfer_failure_handled : EXCEPTION;
  7479.  
  7480. --&MT SUBTYPE BIT_COUNT_32_TYPE IS LONG_INTEGER;
  7481.       SUBTYPE BIT_COUNT_32_TYPE IS INTEGER;
  7482.  
  7483. --&MT SUBTYPE BIT_COUNT_16_TYPE IS INTEGER;
  7484.       SUBTYPE BIT_COUNT_16_TYPE IS SHORT_INTEGER;
  7485.  
  7486. --&MT THE FOLLOWING LINES SHOULD BE DELETED WHEN USING TELESOFT
  7487.   PACKAGE LONG_INT IS NEW TEXT_IO.INTEGER_IO(BIT_COUNT_32_TYPE);
  7488.   PACKAGE INT_IO IS NEW TEXT_IO.INTEGER_IO(BIT_COUNT_16_TYPE);
  7489.   global_tcp_identifier : FTP_TCP.TCP_IDENTIFIER_SPEC ;
  7490.  
  7491.   PROCEDURE Send_the_file 
  7492.             ( Tcp_identifier  : IN OUT FTP_TCP.TCP_IDENTIFIER_SPEC ;
  7493.               Server_parameters : IN FTP_UTILITIES.FTP_PARAMETERS_SPEC ) IS
  7494.         Current_file_structure : Argument_list := 
  7495.                                     Get_current_structure( Server_parameters );
  7496.     BEGIN
  7497.         IF Current_file_structure(1) = Argument_list_unit'('R') THEN
  7498.             My_debug_io.PUT_LINE ("  Sending the file as records ");
  7499.             Send_file_as_records ( Tcp_identifier );
  7500.             My_debug_io.PUT_LINE ("  File has been sent as records ");
  7501.         ELSE
  7502.             My_debug_io.PUT_LINE (" Sending the file as a stream ");
  7503.             Send_file_as_stream ( Tcp_identifier );
  7504.             My_debug_io.PUT_LINE (" File has been sent as a stream ");
  7505.         END IF;
  7506.     EXCEPTION
  7507.         WHEN OTHERS => -- Including tcp exceptions
  7508.                 My_debug_io.PUT_LINE ("  Send the file Failed ");
  7509.                 My_debug_io.PUT_LINE ("  Raising transfer failed ");
  7510.             My_debug_io.put_line (" Closing tcp (2)");
  7511.             Close_tcp_data_link ( Tcp_identifier );
  7512.                 RAISE ; -- Transfer_failed;
  7513.     END Send_the_file;
  7514.  
  7515.   PROCEDURE Accept_the_file
  7516.             ( Tcp_identifier    : IN OUT Ftp_tcp.tcp_identifier_spec ;
  7517.               Server_parameters : IN     Ftp_utilities.ftp_parameters_spec ) IS
  7518.         Current_file_structure : Argument_list := 
  7519.                                     Get_current_structure( Server_parameters );
  7520.  
  7521.         PROCEDURE Give_tcp_time_to_process_before_sending_reply IS
  7522.                 I : BIT_COUNT_16_TYPE := 0;
  7523.             BEGIN
  7524.                 FOR Time_delay IN 1..10 LOOP
  7525.                     FOR Time_delay_2 IN 1..10_000 LOOP
  7526.                         I := 0;
  7527.                     END LOOP;
  7528.                 END LOOP;
  7529.             END Give_tcp_time_to_process_before_sending_reply;
  7530.  
  7531.     BEGIN
  7532.  
  7533.   --&MT Send_reply_over_telnet( "150" );
  7534.         Send_reply_over_telnet( reply_code_string => "150");
  7535.  
  7536.         IF Tcp_connection_is_open( Tcp_identifier ) THEN
  7537.             NULL;
  7538.             My_debug_io.put_line(" Tcp already open; receiving the file");
  7539.         ELSE
  7540.             My_debug_io.put_line("  Opening TCP ");
  7541.             Open_tcp_data_link( Tcp_identifier );
  7542.             My_debug_io.put_line("  Receiveing the file ");
  7543.         END IF;
  7544.         IF Current_file_structure( Current_file_structure'FIRST ) = 
  7545.                                                 Argument_list_unit'('R') THEN
  7546.             My_debug_io.PUT_LINE ("  Receiving the file as records ");
  7547.             Receive_file_as_records ( Tcp_identifier );
  7548.             My_debug_io.PUT_LINE(" The file has been received as records");
  7549.         ELSE
  7550.             My_debug_io.PUT_LINE ("  Receiving the file as a stream ");
  7551.             Receive_file_as_stream ( Tcp_identifier );
  7552.             My_debug_io.PUT_LINE("  File has been received as a stream");
  7553.         END IF;
  7554.         My_debug_io.PUT_LINE ("  File received; sending reply ");
  7555.         Give_tcp_time_to_process_before_sending_reply;
  7556.  
  7557.   --&MT Send_reply_over_telnet( "226" );
  7558.         Send_reply_over_telnet( reply_code_string => "226");
  7559.  
  7560.         My_debug_io.PUT_LINE ("  Reply sent, Tcp data link closed ");
  7561.     EXCEPTION
  7562.         WHEN OTHERS =>
  7563.                 My_debug_io.PUT_LINE ("  Accept the file Failed ");
  7564.                 My_debug_io.PUT_LINE ("  Raising transfer failed ");
  7565.                 RAISE ; -- Transfer_failed;
  7566.     END Accept_the_file;
  7567.  
  7568.   PROCEDURE Accept_file_user_to_server 
  7569.         ( Status : OUT FTP_UTILITIES.COMMAND_STATUS_SPEC;
  7570.           Server_parameters : IN FTP_UTILITIES.FTP_PARAMETERS_SPEC;
  7571.           Argument : IN FTP_TYPES.ARGUMENT_LIST ) IS
  7572.  
  7573.         File_name_string        : 
  7574.  
  7575.    --&MT STRING( Argument'FIRST..Argument'LAST);
  7576.          STRING( bit_count_32_type(Argument'FIRST)..bit_count_32_type(Argument'LAST));
  7577.  
  7578.         File_name_length        : BIT_COUNT_16_TYPE;
  7579.         File_name_from_argument : Ftp_types.argument_list;
  7580.         Tcp_identifier          : Ftp_tcp.tcp_identifier_spec := 
  7581.          global_tcp_identifier ;
  7582.  
  7583.         PROCEDURE Create_output_file IS
  7584.             BEGIN
  7585.                 My_debug_io.put_line ("  Creating file");
  7586.                 Get_first_argument_from_argument_list
  7587.                    ( Argument, File_name_from_argument );
  7588.                 Convert_argument_to_string
  7589.                    (File_name_from_argument,File_name_string,File_name_length);
  7590.                 Open_output_file( File_name_string( 
  7591.                         File_name_string'FIRST ..
  7592.                         File_name_string'FIRST + 
  7593.  
  7594.                   --&MT File_name_length - 1 ));
  7595.                         bit_count_32_type(File_name_length) - 1 ));
  7596.  
  7597.                 My_debug_io.put_line ("  File created ");
  7598.             EXCEPTION
  7599.                 WHEN OTHERS => 
  7600.                 My_debug_io.PUT_LINE ("  create output file failed ");
  7601.                 My_debug_io.PUT_LINE ("  Raising ? ");
  7602.                 RAISE;
  7603.             END Create_output_file;
  7604.  
  7605.   BEGIN
  7606.     Indicate_command_was_not_successful( Status );
  7607.     Create_output_file;
  7608.       -- Initialize_tcp( Tcp_identifier ); -- Debug only 
  7609.     Accept_the_file( Tcp_identifier, Server_parameters );
  7610.     Close_output_file;
  7611.     -- Close_tcp_data_link ( Tcp_identifier );
  7612.     My_debug_io.PUT_LINE ("  Tcp closed, returning ");
  7613.     Indicate_command_was_successful( Status );
  7614.     global_tcp_identifier := tcp_identifier ;                  
  7615.   EXCEPTION
  7616.     --
  7617.     -- If any of these exception routines generate an exception then
  7618.     -- the exception is propagated up. This could be fatal. Consequently,
  7619.     -- send the replies last so that if an exception arises no reply will
  7620.     -- have been sent.
  7621.     --
  7622. --    WHEN Create_request_failed  => -- Couldn't create output file
  7623. --         My_debug_io.PUT_LINE("  Accept_file_user_to_server(0) failed");
  7624. --         My_debug_io.PUT_LINE ("  exception not propagated  ");
  7625. --         Send_reply_over_telnet( "450" ); -- File not avaliable
  7626. --         Send_reply_over_telnet( reply_code_string => "450");
  7627. --    WHEN FTP_TCP.Tcp_request_failed     |
  7628. --         Unexpected_reply               | 
  7629. --         Tcp_connection_closed          |
  7630. --         Tcp_aborted                    |
  7631. --         No_more_tcp_data                => 
  7632. --            My_debug_io.PUT_LINE("  Accept_file_user_to_server(1) failed ");
  7633. --            My_debug_io.put_line ("  Shutting down system ");
  7634. --            Close_output_file; -- Might raise error_closing_file
  7635. --            IF Tcp_connection_is_open ( Tcp_identifier ) THEN
  7636. --                Close_tcp_data_link ( Tcp_identifier ); -- Tcp_request_failed?
  7637. --            END IF;
  7638. --            Send_reply_over_telnet( "425" ); -- TCP failed
  7639. --            Send_reply_over_telnet( reply_code_string => "425");
  7640. --    WHEN Close_request_failed   =>  -- File is open
  7641. --            -- Transfer ok, but file still open
  7642. --            My_debug_io.PUT_LINE("  Accept_file_user_to_server(2) ");
  7643. --            My_debug_io.put_line ("  Shutting down system ");
  7644. --            Close_tcp_data_link ( Tcp_identifier );
  7645. --            Send_reply_over_telnet( "226" );
  7646. --            Send_reply_over_telnet( reply_code_string => "226");
  7647. --            Indicate_command_was_successful( Status );
  7648.     WHEN OTHERS => 
  7649.             My_debug_io.PUT_LINE("  Accept_file_user_to_server(3) ");
  7650.             My_debug_io.put_line ("  Shutting down system ");
  7651.             Close_output_file; -- Might raise error_closing_file
  7652.             Close_tcp_data_link ( Tcp_identifier ); -- Raise tcp_requst_failed?
  7653.  
  7654.       --&MT Send_reply_over_telnet( "426" );
  7655.             Send_reply_over_telnet( reply_code_string => "426");
  7656.  
  7657.   END Accept_file_user_to_server;
  7658.  
  7659.   PROCEDURE Send_file_server_to_user
  7660.         ( Status            : OUT FTP_UTILITIES.COMMAND_STATUS_SPEC;
  7661.           Server_parameters : IN  FTP_UTILITIES.FTP_PARAMETERS_SPEC;
  7662.           Argument          : IN  FTP_TYPES.ARGUMENT_LIST ) IS
  7663.  
  7664.         File_name_string        : 
  7665.  
  7666.    --&MT STRING( ARGUMENT'FIRST..ARGUMENT'LAST);
  7667.          STRING( bit_count_32_type(ARGUMENT'FIRST)..bit_count_32_type(ARGUMENT'LAST));
  7668.  
  7669.         File_name_length        : BIT_COUNT_16_TYPE;
  7670.         File_name_from_argument : FTP_TYPES.ARGUMENT_LIST;
  7671.         Tcp_identifier          : FTP_TCP.TCP_IDENTIFIER_SPEC :=
  7672.          global_tcp_identifier ;
  7673.  
  7674.         PROCEDURE Open_input_file IS
  7675.             BEGIN
  7676.                 My_debug_io.PUT_LINE ("  Opening file");
  7677.                 Get_first_argument_from_argument_list
  7678.                    ( Argument, File_name_from_argument );
  7679.                 Convert_argument_to_string
  7680.                    (File_name_from_argument,File_name_string,File_name_length);
  7681.                 Open_input_file( File_name_string( 
  7682.                             File_name_string'FIRST ..
  7683.                             File_name_string'FIRST + 
  7684.  
  7685.                       --&MT File_name_length - 1 ));
  7686.                             bit_count_32_type(File_name_length) - 1 ));
  7687.  
  7688.                 My_debug_io.PUT_LINE ("  File opened");
  7689.             EXCEPTION
  7690.                 WHEN OTHERS => 
  7691.                     My_debug_io.PUT_LINE ("  open input file Failed ");
  7692.                     My_debug_io.PUT_LINE (" Raising open request failed ");
  7693.                     RAISE Open_request_failed;
  7694.             END Open_input_file;
  7695.  
  7696.         PROCEDURE Set_up_tcp_and_send_file IS
  7697.             BEGIN
  7698.  
  7699.           --&MT Send_reply_over_telnet( "150" ); -- File ok
  7700.                 Send_reply_over_telnet( reply_code_string => "150");
  7701.  
  7702.                 IF Tcp_connection_is_open( Tcp_identifier ) THEN
  7703.                     My_debug_io.PUT_LINE ("  Connection already opened ");
  7704.                     Send_the_file( Tcp_identifier, Server_parameters );
  7705.                 ELSE
  7706. --&MT                    My_debug_io.PUT_LINE ("  Opening connection  ");
  7707. --                    DECLARE 
  7708. --                      length : integer ;
  7709. --                      st : string (1..80) ;
  7710. --                    begin
  7711. --                      text_io.put_line("wait for other side to do passive open") ;
  7712. --                      text_io.get_line(st, length) ;
  7713. --&MT                    end ;
  7714.                     Open_tcp_data_link( Tcp_identifier );
  7715.                     Send_the_file( Tcp_identifier , Server_parameters );
  7716.                 END IF;
  7717.  
  7718.           --&MT Send_reply_over_telnet( "226" );
  7719.                 Send_reply_over_telnet( reply_code_string => "226");
  7720.  
  7721.             EXCEPTION
  7722.                 WHEN OTHERS          => 
  7723.                     My_debug_io.PUT_LINE ("  set up tcp and send Failed ");
  7724.                     My_debug_io.PUT_LINE ("  Raising tcp request failed ");
  7725.                     RAISE FTP_TCP.Tcp_request_failed;
  7726.             END Set_up_tcp_and_send_file;
  7727.  
  7728.   BEGIN
  7729.     
  7730.     Indicate_command_was_not_successful ( Status );
  7731.     Open_input_file;
  7732.       -- Initialize_tcp( Tcp_identifier ); -- Debug only 
  7733.     Set_up_tcp_and_send_file;
  7734.     Close_input_file;
  7735.     My_debug_io.PUT_LINE ("  File closed ");
  7736.     Close_tcp_data_link ( Tcp_identifier );
  7737.     My_debug_io.PUT_LINE ("  Connection closed ");
  7738.     Indicate_command_was_successful ( Status );
  7739.     global_tcp_identifier := tcp_identifier ;
  7740.   EXCEPTION
  7741.     WHEN OTHERS => 
  7742.             My_debug_io.PUT_LINE ("  Send_file_server_to_user(4) Failed ");
  7743.  
  7744.       --&MT Send_reply_over_telnet ( "550"); 
  7745.             Send_reply_over_telnet( reply_code_string => "550");
  7746.  
  7747.   END Send_file_server_to_user;
  7748.  
  7749.  
  7750.  
  7751. BEGIN
  7752.   global_tcp_identifier.local_port_id := 6 ;
  7753.   global_tcp_identifier.connection_status := ftp_tcp.closed ;
  7754.   ftp_tcp.initialize_tcp(global_tcp_identifier) ;
  7755. EXCEPTION
  7756.     WHEN OTHERS => RAISE;
  7757. END Server_xfer_commands ;
  7758. --::::::::::::::
  7759. --ftpserver.ada
  7760. --::::::::::::::
  7761. -----------------------------------------------------------------------
  7762. --
  7763. --         DoD Protocols    NA-00005-200       80-01090-100(-)
  7764. --         E-Systems, Inc.  August 07, 1985
  7765. --
  7766. --         FTPSERVER.ADA       Author : Mark Volpe
  7767. --
  7768. -----------------------------------------------------------------------
  7769. -- FILE : FTPSERVER               AUTHOR : MARK VOLPE
  7770.  
  7771. -- 5/21/85    8:56 AM : REVISED FOR USE WITH DEC COMPILER 
  7772. --                      OLD CODE (TELESOFT) MARKED WITH --&MT  
  7773.  
  7774. -- 5/31/85   11:27 AM : REVISED FOR USE WITH TELESOFT COMPILER
  7775. --                       OLD CODE (DEC) MARKED WITH --&MT
  7776.  
  7777. -- 5/31/85    2:07 PM : REVISED FOR USE WITH THE DEC COMPILER
  7778. --                       OLD CODE (TELESOFT) MARKED WITH --&MT
  7779.  
  7780. -- 6/22/85    3:41 PM : converted PROCESS_FTP_COMMAND into a task
  7781. --                       added code appended with --&KJW
  7782.  
  7783. -- 6/24/85    2:30 PM : converted SERVER_TELNET into a task,
  7784. --                       added code appended with --&KJW
  7785. -- 7/10/85    4:03 PM : change name of server_telnet to server_telnet_package(MT)
  7786. -- 7/18/85    4:46 PM : relpy_message => "xxx"  to  reply_code_string => "xxx"
  7787.  
  7788. --&MT THE FOLLOWING LINE SHOULD BE DELETED WHEN USING DEC ADA :
  7789. --&MT PRAGMA SOURCE_INFO (ON);
  7790.  
  7791. WITH
  7792.    Server_telnet_package,    --&KJW
  7793.    My_debug_io,
  7794.    Server_login_commands,
  7795.    Server_pi_commands,    -- For pi commands
  7796.    Server_dtp_commands, -- For dtp commands
  7797.    Server_xfer_commands,-- For sending files
  7798.    Server_utilities,
  7799.    Ftp_utilities,
  7800.    Ftp_command_utilities,-- For getting commands from telnet
  7801.    Ftp_types,
  7802.    Ftp_telnet;  
  7803.  
  7804. PROCEDURE Server_ftp IS
  7805.    ----------------------------------------------------------------------
  7806.    --
  7807.    -- This procedure is the upper level of FTP on the server (remote) side.
  7808.    -- It is responsibe for interfacing between Telnet and the remote system.
  7809.    --
  7810.    -- The command is accepted from Telnet.
  7811.    -- The command is then verified and converted to an enumerated type.
  7812.    -- A command handler is then called, base on this enumerated type.
  7813.    -- During command processing, replies are sent back to the user's system
  7814.    -- via telnet.
  7815.    --
  7816.    ----------------------------------------------------------------------
  7817.   Server_parameters : Ftp_utilities.ftp_parameters_spec;
  7818.   TelNet_Server     : Server_telnet_package.TelNet_Controller;
  7819.   
  7820.   TASK  Process_FTP_Command  IS        --&KJW
  7821.     PRAGMA Priority(7);            --&KJW
  7822.   END Process_FTP_Command;        --&KJW
  7823.  
  7824.   TASK BODY  Process_FTP_Command  IS    --&KJW
  7825.   --PROCEDURE Process_ftp_command 
  7826.   --  ( Server_parameters : IN OUT Ftp_utilities.ftp_parameters_spec ) IS
  7827.   -- N O T I C E ::  What was once parameter "server_parameters"    --&KJW
  7828.   --                    is now global object "server_parameters"    --&KJW
  7829.     ----------------------------------------------------------------------
  7830.     --
  7831.     -- THIS PROCEDURE ACCEPTS THE COMMANDS FROM TELNET
  7832.     -- THEN CALLS THE APPROPRIATE COMMAND_HANDLER
  7833.     --
  7834.     ----------------------------------------------------------------------
  7835.     Command              : Ftp_types.valid_command_spec;
  7836.     Command_status       : Ftp_command_utilities.command_status_spec;
  7837.     Argument             : Ftp_types.argument_list;
  7838.     Server_command_status: Ftp_utilities.command_status_spec;
  7839.   BEGIN
  7840.     DECLARE
  7841.         Telnet_status : Ftp_telnet.telnet_status_spec;
  7842.     BEGIN
  7843.         Ftp_telnet.wait_for_telnet_open( Telnet_status );
  7844.     END ;
  7845.     LOOP
  7846.         --D My_debug_io.put_line (" Trying to get a command from telnet");
  7847.         Ftp_command_utilities.get_command_from_telnet
  7848.             ( Command_status, Command, Argument );
  7849.         IF Ftp_command_utilities.argument_list_is_valid ( Command_status ) THEN
  7850.           CASE Command IS
  7851.             WHEN  Ftp_types.user_command =>
  7852.                Server_login_commands.log_user_onto_system 
  7853.                         ( Server_command_status, Server_parameters, Argument );
  7854.             WHEN  Ftp_types.pass_command =>
  7855.  
  7856.          --&MT Server_utilities.send_reply_over_telnet ("503"); 
  7857.                Server_utilities.send_reply_over_telnet(reply_code_string => "503");
  7858.  
  7859.             WHEN  Ftp_types.quit_command =>
  7860.                Server_login_commands.log_user_off_of_system 
  7861.                   ( Server_command_status, 
  7862.                     Server_parameters, 
  7863.                     Ftp_types.null_argument);
  7864.                 EXIT; -- GET US OUT OF LOOP SO WE CAN QUIT
  7865.             WHEN  Ftp_types.noop_command =>
  7866.                 Server_pi_commands.process_noop_from_user_pi
  7867.                     ( Server_command_status );
  7868.             WHEN  Ftp_types.help_command =>
  7869.                 Server_pi_commands.process_help_from_user_pi
  7870.                     ( Server_command_status, Argument );
  7871.             WHEN  Ftp_types.stru_command =>
  7872.                 Server_dtp_commands.change_default_structure
  7873.                     ( Server_command_status, Server_parameters, Argument  );
  7874.             WHEN  Ftp_types.type_command =>
  7875.                  Server_dtp_commands.change_default_type
  7876.                     ( Server_command_status, Server_parameters, Argument  );
  7877.             WHEN  Ftp_types.mode_command =>
  7878.                  Server_dtp_commands.change_default_mode
  7879.                     ( Server_command_status, Server_parameters, Argument  );
  7880.             WHEN  Ftp_types.port_command =>
  7881.                  Server_dtp_commands.change_default_port
  7882.                     ( Server_command_status, Server_parameters, Argument );
  7883.             WHEN  Ftp_types.stor_command =>
  7884.                 Server_xfer_commands.accept_file_user_to_server
  7885.                     ( Server_command_status, Server_parameters, Argument );
  7886.             WHEN  Ftp_types.retr_command =>
  7887.                 Server_xfer_commands.send_file_server_to_user
  7888.                     ( Server_command_status, Server_parameters, Argument );
  7889.             WHEN  OTHERS =>
  7890.  
  7891.          --&MT Server_utilities.send_reply_over_telnet ("500");
  7892.                Server_utilities.send_reply_over_telnet(reply_code_string => "500");
  7893.  
  7894.           END CASE;
  7895.         ELSE
  7896.  
  7897.     --&MT Server_utilities.send_reply_over_telnet ("500");
  7898.           Server_utilities.send_reply_over_telnet ( reply_code_string => "500");
  7899.  
  7900.         END IF;            
  7901.         END LOOP;
  7902.   END Process_ftp_command;
  7903.   
  7904.    PROCEDURE Server_exception_abort 
  7905.         ( Server_parameters : IN OUT Ftp_utilities.ftp_parameters_spec ) IS
  7906.    ----------------------------------------------------------------------
  7907.    --
  7908.    -- This procedure shuts down the tcp connection between the server dtp
  7909.    -- and the user dtp; aborting any file transfers in progress.
  7910.    -- It then sends a reply of  "451" ( local error in processing ) and
  7911.    -- logs the server off its system.
  7912.    --
  7913.    ----------------------------------------------------------------------
  7914.    Server_command_status : Ftp_utilities.command_status_spec;
  7915.    Telnet_status : Ftp_telnet.telnet_status_spec;
  7916.   
  7917.    BEGIN
  7918.         Server_login_commands.logout( Server_parameters );
  7919.         Ftp_telnet.close_telnet_link( Telnet_status, Ftp_types.null_argument );
  7920.     EXCEPTION
  7921.         WHEN OTHERS =>
  7922.                 NULL; -- Don't raise it, kill all exceptions here!
  7923.    END Server_exception_abort;
  7924.  
  7925. BEGIN
  7926.     -- Process_ftp_command( Server_parameters );    --&KJW
  7927.     TelNet_Server.Connection_Assignments(8,0,0);    --&KJW
  7928.     EXCEPTION
  7929.         WHEN OTHERS =>
  7930.             Server_exception_abort( Server_parameters );
  7931. END Server_ftp;
  7932. --::::::::::::::
  7933. --ftpusrxfr_.ada
  7934. --::::::::::::::
  7935. -----------------------------------------------------------------------
  7936. --
  7937. --         DoD Protocols    NA-00005-200       80-01116-100(-)
  7938. --         E-Systems, Inc.  August 07, 1985
  7939. --
  7940. --         FTPUSRXFR_.ADA       Author : Mark Volpe
  7941. --
  7942. -----------------------------------------------------------------------
  7943. -- FILE : FTPUSRXFR               AUTHOR : MARK VOLPE
  7944.  
  7945. -- 5/21/85    9:12 AM : REVISED FOR USE WITH DEC COMPILER 
  7946. --                      OLD CODE (TELESOFT) MARKED WITH --&MT  
  7947.  
  7948. -- 5/31/85    1:30 PM  : REVISED FOR USE WITH TELESOFT COMPILER
  7949. --                       OLD CODE (DEC) MARKED WITH --&MT
  7950.  
  7951. -- 5/31/85    2:18 PM  : REVISED FOR USE WITH THE DEC COMPILER
  7952. --                       OLD CODE (TELESOFT) MARKED WITH --&MT
  7953.  
  7954. --&MT THE FOLLOWING LINE SHOULD BE DELETED WHEN USING DEC ADA :
  7955. --&MT PRAGMA SOURCE_INFO ( ON );
  7956.  
  7957. WITH My_debug_io;             USE My_debug_io;
  7958. WITH Ftp_types;               USE Ftp_types;
  7959. WITH Reply_types;             USE Reply_types;
  7960. WITH Ftp_tcp;                 USE Ftp_tcp;
  7961. WITH Reply_utilities;         USE Reply_utilities;
  7962. WITH FTP_COMMAND_UTILITIES;   USE FTP_COMMAND_UTILITIES;
  7963. WITH Ftp_terminal_driver;     USE Ftp_terminal_driver;
  7964. WITH Ftp_utilities;           USE Ftp_utilities;
  7965. WITH Ftp_file_io;             USE Ftp_file_io;             
  7966.  
  7967. PACKAGE User_xfer_commands IS
  7968.    ----------------------------------------------------------------------
  7969.    --
  7970.    -- This package contains the procedures used by the user ftp
  7971.    -- during data transfers.
  7972.    --
  7973.    ----------------------------------------------------------------------
  7974.  
  7975.    PROCEDURE Send_file_user_to_server 
  7976.         ( Status : OUT Ftp_utilities.command_status_spec;
  7977.           User_parameters : IN Ftp_utilities.ftp_parameters_spec;
  7978.       Argument : IN Ftp_types.argument_list );
  7979.             --
  7980.            -- This procedure sends the file specified in the argument
  7981.            -- list from the user system to the server system.
  7982.            -- Any data transformations that are required are handled
  7983.            -- internally.
  7984.             --
  7985.  
  7986.    PROCEDURE Accept_file_server_to_user 
  7987.         ( Status : OUT Ftp_utilities.command_status_spec;
  7988.           User_parameters : IN Ftp_utilities.ftp_parameters_spec;
  7989.       Argument : IN Ftp_types.argument_list );
  7990.             --
  7991.            -- This procedure accepts the file specified in the argument
  7992.            -- list from the server system.
  7993.            -- Any data transformations that are required are handled
  7994.            -- internally.
  7995.             --
  7996.  
  7997. END User_xfer_commands;
  7998.  
  7999. --::::::::::::::
  8000. --ftpusrxfr.ada
  8001. --::::::::::::::
  8002. -----------------------------------------------------------------------
  8003. --
  8004. --         DoD Protocols    NA-00005-200       80-01117-100(-)
  8005. --         E-Systems, Inc.  August 07, 1985
  8006. --
  8007. --         FTPUSRXFR.ADA       Author : Mark Volpe
  8008. --
  8009. -----------------------------------------------------------------------
  8010. -- FILE : FTPUSRXFR               AUTHOR : MARK VOLPE
  8011.  
  8012. -- 5/21/85    9:12 AM : REVISED FOR USE WITH DEC COMPILER 
  8013. --                      OLD CODE (TELESOFT) MARKED WITH --&MT  
  8014.  
  8015. -- 5/31/85    1:30 PM  : REVISED FOR USE WITH TELESOFT COMPILER
  8016. --                       OLD CODE (DEC) MARKED WITH --&MT
  8017.  
  8018. -- 5/31/85    2:23 PM  : REVISED FOR USE WITH THE DEC COMPILER
  8019. --                       OLD CODE (TELESOFT) MARKED WITH --&MT
  8020. -- 7/10/85    6:15 PM  : global tcp identifier added
  8021. -- 7/11/85   11:29 AM  : don't do passive open
  8022. -- 7/19/85   11:40 AM  : remove -1 port number from pack body init
  8023. --            4:33 PM  : uncomment debug output lines
  8024. -- 7/23/85   11:30 PM  : don't do close in accept_file_server_to_user
  8025. -- 7/29/85    1:39 PM  : undo above
  8026.  
  8027. --&MT THE FOLLOWING LINE WAS ADDED TO GIVE FTPUSRXFR.ADA ACCESS TO TEXT_IO :
  8028. WITH TEXT_IO ;
  8029.  
  8030. PACKAGE BODY User_xfer_commands IS
  8031.  
  8032. --&MT SUBTYPE BIT_COUNT_32_TYPE IS LONG_INTEGER;
  8033.       SUBTYPE BIT_COUNT_32_TYPE IS INTEGER;
  8034.  
  8035. --&MT SUBTYPE BIT_COUNT_16_TYPE IS INTEGER;
  8036.       SUBTYPE BIT_COUNT_16_TYPE IS SHORT_INTEGER;
  8037.  
  8038. --&MT THE FOLLOWING LINES SHOULD BE DELETED WHEN USING TELESOFT
  8039.   PACKAGE LONG_INT IS NEW TEXT_IO.INTEGER_IO(BIT_COUNT_32_TYPE);
  8040.   PACKAGE INT_IO IS NEW TEXT_IO.INTEGER_IO(BIT_COUNT_16_TYPE);
  8041.  
  8042.   global_tcp_identifier : Ftp_tcp.tcp_identifier_spec ;
  8043.  
  8044.   PROCEDURE Send_file_user_to_server 
  8045.         ( Status          : OUT Ftp_utilities.command_status_spec;
  8046.           User_parameters : IN  Ftp_utilities.ftp_parameters_spec;
  8047.       Argument        : IN  Ftp_types.argument_list ) IS
  8048.  
  8049.         Name_field        : Ftp_types.argument_list;
  8050.         File_name        : 
  8051.  
  8052.    --&MT STRING( Argument'first..argument'last );
  8053.          STRING( bit_count_32_type(Argument'first)..bit_count_32_type(argument'last) );
  8054.  
  8055.         File_name_length    : BIT_COUNT_16_TYPE := 0;
  8056.         Transmission_status : Ftp_command_utilities.transmission_status_spec;
  8057.         Reply               : Reply_types.reply_code_spec;
  8058.         Tcp_identifier      : Ftp_tcp.tcp_identifier_spec :=
  8059.          global_tcp_identifier ;
  8060.         Current_structure   : Argument_list;
  8061.  
  8062.     PROCEDURE Send_the_file IS
  8063.       BEGIN
  8064.         Output_message_with_new_line(" Remote file opened, starting transfer");
  8065.         Current_structure := Get_current_structure ( User_parameters );
  8066.         IF Current_structure(Current_structure'FIRST)=Argument_list_unit'('R') 
  8067.         THEN 
  8068.             My_debug_io.Put_line("  Sending file as records ");
  8069.             Send_file_as_records ( Tcp_identifier );
  8070.             My_debug_io.Put_line("  File sent as records ");
  8071.         ELSE 
  8072.             My_debug_io.Put_line("  Sending file as stream ");
  8073.             Send_file_as_stream  ( Tcp_identifier );
  8074.             My_debug_io.Put_line("  File sent as stream ");
  8075.         END IF;
  8076.         My_debug_io.Put_line("  File sent. Closing tcp connection now ");
  8077.  
  8078. --d        DECLARE --DMT
  8079. --          DUMMY : STRING(1..5) ;
  8080. --          L : INTEGER ;
  8081. --        BEGIN
  8082. --          text_io.put("press enter to continue") ;
  8083. --          text_io.get_line(DUMMY, L) ;
  8084. --d        END ;
  8085.  
  8086.         Close_tcp_data_link ( Tcp_identifier );
  8087.         My_debug_io.Put_line (" Tcp connection closed");
  8088.         Get_reply_from_telnet ( Reply );
  8089.         My_debug_io.Put_line("  Received reply ");
  8090.         IF Positive_preliminary_reply( Reply ) THEN
  8091.             Output_message_with_new_line(" Page markers not supported");
  8092.         ELSIF Positive_completion_reply( Reply ) THEN
  8093.             Indicate_command_was_successful( Status );
  8094.             Output_message_with_new_line(" Transmission successful");
  8095.         ELSIF Transient_negative_completion_reply( Reply ) THEN
  8096.             Output_message_with_new_line(" Please retry");
  8097.         ELSIF Permanent_negative_completion_reply( Reply ) THEN
  8098.             Output_message_with_new_line(" Transmisison failed");
  8099.         ELSE
  8100.             Output_message_with_new_line(" Invalid reply");
  8101.         END IF;
  8102.       END Send_the_file;
  8103.  
  8104.     PROCEDURE Open_input_file IS
  8105.       BEGIN
  8106.         Get_first_argument_from_argument_list( ARGUMENT, NAME_FIELD );
  8107.         Convert_argument_to_string( Name_field, File_name, File_name_length );
  8108.         Output_message (" Opening local inPut file ");
  8109.         Output_message_with_new_line
  8110.  
  8111.      --&MT (File_name(Argument'FIRST .. 
  8112.            (File_name(BIT_COUNT_32_TYPE(Argument'FIRST) .. 
  8113.  
  8114.      --&MT Argument'FIRST + 
  8115.            BIT_COUNT_32_TYPE(Argument'FIRST) + 
  8116.  
  8117.    --&MT  File_name_length - 1));
  8118.           BIT_COUNT_32_TYPE(File_name_length) - 1));
  8119.  
  8120.         Open_input_file
  8121.  
  8122.      --&MT (File_name(Argument'FIRST .. 
  8123.            (File_name(BIT_COUNT_32_TYPE(Argument'FIRST) .. 
  8124.  
  8125.      --&MT Argument'FIRST + 
  8126.            BIT_COUNT_32_TYPE(Argument'FIRST) + 
  8127.  
  8128.      --&MT File_name_length - 1));
  8129.            BIT_COUNT_32_TYPE(File_name_length) - 1));
  8130.  
  8131.         Get_second_argument_from_argument_list( Argument, Name_field );
  8132.         Convert_argument_to_string ( Name_field, File_name, File_name_length );
  8133.         Output_message(" Remote Output filename   ");
  8134.         Output_message_with_new_line
  8135.  
  8136.     --&MT (File_name(Argument'FIRST .. 
  8137.           (File_name(BIT_COUNT_32_TYPE(Argument'FIRST) .. 
  8138.  
  8139.      --&MT Argument'FIRST + 
  8140.            BIT_COUNT_32_TYPE(Argument'FIRST) + 
  8141.  
  8142.      --&MT File_name_length - 1));
  8143.            BIT_COUNT_32_TYPE(File_name_length) - 1));
  8144.  
  8145.       END Open_input_file;
  8146.  
  8147.     PROCEDURE Initiate_file_transfer IS
  8148.       BEGIN
  8149.         My_debug_io.Put_line("  Getting reply to stor command "); --debug
  8150.         Get_reply_from_telnet ( Reply );
  8151.         My_debug_io.Put_line("  Received reply to stor command "); --debug
  8152.         IF Transient_negative_completion_reply( Reply ) THEN
  8153.             Output_message_with_new_line (" Please retry");
  8154.         ELSIF Permanent_negative_completion_reply ( Reply ) THEN
  8155.             Output_message_with_new_line
  8156.                             (" Invalid request or bad remote filename");
  8157.         ELSIF Positive_preliminary_reply ( Reply ) THEN
  8158.             My_debug_io.Put_line ("  Listening for active open ");
  8159.             Listen_on_current_tcp_port_for_an_active_open( Tcp_identifier );
  8160.             My_debug_io.Put_line ("  Active open received ");
  8161.             Send_the_file;
  8162.         ELSE
  8163.             Output_message_with_new_line(" Invalid reply to STOR request");
  8164.         END IF; -- end test for initial reply
  8165.       END Initiate_file_transfer;
  8166.  
  8167.     BEGIN  -- Start of Send_file_user_to_server
  8168.         Indicate_command_was_not_successful ( Status );
  8169.         IF Telnet_link_is_open ( User_parameters ) THEN
  8170.             Find_out_if_user_wants_data_echoed_to_screen;
  8171.         Open_input_file;
  8172.         --D My_debug_io.Put_line ("  Initializing tcp ");
  8173.         -- Initialize_tcp ( Tcp_identifier );
  8174.             My_debug_io.Put_line ("  Sending stor command ");
  8175.             Send_command_over_telnet (
  8176.                     Transmission_status,
  8177.                     Ftp_types.stor_command,
  8178.                     Name_field );
  8179.             IF Transmission_successful( Transmission_status ) THEN
  8180.                 Initiate_file_transfer;
  8181.             ELSE -- Else clause for xmit status test
  8182.                 Output_message_with_new_line
  8183.                     (" Telnet failed; aborting file transfer");
  8184.             END IF; -- End test for transfer status
  8185.             My_debug_io.Put_line("  Closing inPut file ");
  8186.             Close_input_file;
  8187.             Output_message_with_new_line(" Local inPut file closed");
  8188.         ELSE -- else clause for telnet status test
  8189.             Output_message_with_new_line
  8190.                 (" No telnet link is open; aborting file transfer");
  8191.         END IF; -- end test for telnet status
  8192.         global_tcp_identifier := tcp_identifier ;
  8193.      EXCEPTION
  8194.         WHEN OTHERS =>
  8195.             Output_message_with_new_line
  8196.                 (" Unknown error in Send_file_user_to_server");
  8197.             RAISE;
  8198.     END Send_file_user_to_server;
  8199.  
  8200.   PROCEDURE Accept_file_server_to_user
  8201.         ( Status : OUT Ftp_utilities.command_status_spec;
  8202.           User_parameters : IN Ftp_utilities.ftp_parameters_spec;
  8203.       Argument : IN Ftp_types.argument_list ) IS
  8204.  
  8205.         Name_field    : Ftp_types.argument_list;
  8206.         File_name    : 
  8207.  
  8208.    --&MT STRING( Argument'first..argument'last );
  8209.          STRING( bit_count_32_type(Argument'first)..bit_count_32_type(argument'last) );
  8210.  
  8211.         File_name_length: BIT_COUNT_16_TYPE := 0;
  8212.         Transmission_status : Ftp_command_utilities.transmission_status_spec;
  8213.         Reply           : Reply_types.reply_code_spec;
  8214.         Tcp_identifier      : Ftp_tcp.tcp_identifier_spec :=
  8215.          global_tcp_identifier ;
  8216.  
  8217.     PROCEDURE Get_the_file IS
  8218.         Current_structure   : Argument_list;
  8219.         BEGIN
  8220.             Current_structure := Get_current_structure ( User_parameters );
  8221.             IF Current_structure ( Current_structure'FIRST ) = 
  8222.                                                 Argument_list_unit'('R') THEN
  8223.                 My_debug_io.Put_line ("  Receiving file as records ");
  8224.                 Receive_file_as_records ( Tcp_identifier );
  8225.             ELSE
  8226.                 My_debug_io.Put_line ("  Receiving file as stream ");
  8227.                 Receive_file_as_stream ( Tcp_identifier );
  8228.             END IF;
  8229.             My_debug_io.Put_line ("  getting reply ");
  8230.             Get_reply_from_telnet ( Reply );
  8231.             My_debug_io.Put_line ("  received reply ");
  8232.             IF Positive_preliminary_reply( Reply ) THEN
  8233.                    Output_message_with_new_line(" Page markers not supported");
  8234.             ELSIF Positive_completion_reply( Reply ) THEN
  8235.                    Indicate_command_was_successful( Status );
  8236.                    Output_message_with_new_line(" Transmission successful");
  8237.             ELSIF Transient_negative_completion_reply( Reply ) THEN
  8238.                    Output_message_with_new_line(" Please retry");
  8239.             ELSIF Permanent_negative_completion_reply( Reply ) THEN
  8240.                    Output_message_with_new_line(" Transmisison failed");
  8241.             ELSE
  8242.                    Output_message_with_new_line(" Invalid reply");
  8243.             END IF; -- end test for secondary reply
  8244.         END Get_the_file;
  8245.  
  8246.     PROCEDURE Create_output_file IS
  8247.       BEGIN
  8248.         Get_second_argument_from_argument_list( Argument, Name_field );
  8249.         Convert_argument_to_string( Name_field, File_name, File_name_length );
  8250.         Output_message(" Creating local Output file ");
  8251.         Output_message_with_new_line
  8252.  
  8253.       --&MT ( File_name( Argument'FIRST..
  8254.             ( File_name( BIT_COUNT_32_TYPE(Argument'FIRST)..
  8255.  
  8256.       --&MT Argument'FIRST + 
  8257.             BIT_COUNT_32_TYPE(Argument'FIRST) + 
  8258.  
  8259.       --&MT File_name_length - 1));
  8260.             BIT_COUNT_32_TYPE(File_name_length) - 1));
  8261.  
  8262.         Open_Output_file
  8263.  
  8264.       --&MT ( File_name( Argument'FIRST..
  8265.             ( File_name( BIT_COUNT_32_TYPE(Argument'FIRST)..
  8266.  
  8267.       --&MT Argument'FIRST + 
  8268.             BIT_COUNT_32_TYPE(Argument'FIRST) + 
  8269.  
  8270.       --&MT File_name_length - 1));
  8271.             BIT_COUNT_32_TYPE(File_name_length) - 1));
  8272.  
  8273.         My_debug_io.Put_line ("  Output file opened ");
  8274.         Get_first_argument_from_argument_list( Argument, Name_field );
  8275.         Convert_argument_to_string( Name_field, File_name, File_name_length );
  8276.         Output_message(" Remote inPut filename = ");
  8277.         Output_message_with_new_line 
  8278.  
  8279.       --&MT ( File_name( Argument'FIRST..
  8280.             ( File_name( BIT_COUNT_32_TYPE(Argument'FIRST)..
  8281.  
  8282.       --&MT Argument'FIRST + 
  8283.             BIT_COUNT_32_TYPE(Argument'FIRST) + 
  8284.  
  8285.       --&MT File_name_length - 1));
  8286.             BIT_COUNT_32_TYPE(File_name_length) - 1));
  8287.  
  8288.       END Create_output_file;
  8289.  
  8290.     PROCEDURE Initiate_file_transfer IS
  8291.       BEGIN
  8292.         My_debug_io.Put_line ("  getting reply ");
  8293.         Get_reply_from_telnet ( Reply );
  8294.         My_debug_io.Put_line ("  received reply ");
  8295.         IF Transient_negative_completion_reply( Reply ) THEN
  8296.             Output_message_with_new_line(" Please retry command");
  8297.         ELSIF Permanent_negative_completion_reply ( Reply ) THEN
  8298.             Output_message_with_new_line(" Invalid request");
  8299.         ELSIF Positive_preliminary_reply ( Reply ) THEN
  8300.             My_debug_io.put_line (" Waiting for tcp open ");
  8301.             Listen_on_current_tcp_port_for_an_active_open ( Tcp_identifier );
  8302.             My_debug_io.put_line (" Tcp port has been opened ");
  8303.             Output_message_with_new_line(" Starting file transfer");
  8304.             Get_the_file;
  8305.         ELSE
  8306.             Output_message_with_new_line(" Invalid reply");
  8307.         END IF; -- end test for initial reply
  8308.       END Initiate_file_transfer;
  8309.  
  8310.   BEGIN 
  8311.     Indicate_command_was_not_successful( Status );
  8312.     IF Telnet_link_is_open ( User_parameters ) THEN
  8313.         Find_out_if_user_wants_data_echoed_to_screen;
  8314.         Create_output_file;
  8315.     -- Initialize_tcp ( Tcp_identifier );
  8316.         My_debug_io.Put_line ("  sending retr command ");
  8317.         Send_command_over_telnet (
  8318.             Transmission_status, 
  8319.             Ftp_types.retr_command,
  8320.             Name_field );
  8321.         My_debug_io.Put_line ("  retr command sent ");
  8322.         IF Transmission_successful( Transmission_status ) THEN
  8323.             Initiate_file_transfer;
  8324.         END IF; -- end test for xmit status
  8325.         My_debug_io.put_line (" Closing output file ");
  8326.         Close_Output_file; -- already done in initiate_file_transfer
  8327.         Output_message_with_new_line(" Local Output file closed");
  8328.     ELSE
  8329.         Ftp_terminal_driver.Output_message_with_new_line
  8330.             (" No telnet connection open, please CALL remote host first");
  8331.     END IF; -- end test for telnet status
  8332.     global_tcp_identifier := tcp_identifier ;
  8333.   EXCEPTION
  8334.         WHEN OTHERS =>
  8335.             Ftp_terminal_driver.output_message_with_new_line
  8336.                    (" Unknown error in Accept_file_server_to_user");
  8337.             RAISE;
  8338.   END Accept_file_server_to_user;
  8339.  
  8340.  
  8341.  
  8342. BEGIN
  8343.   global_tcp_identifier.connection_status := ftp_tcp.closed ;
  8344.   global_tcp_identifier.local_port_id := 5 ; -- use this local port # for opens
  8345.   ftp_tcp.initialize_tcp(global_tcp_identifier) ;
  8346. EXCEPTION
  8347.     WHEN OTHERS =>
  8348.         My_debug_io.Put_line (" Unknown error in User_xfer_commands");
  8349.         RAISE;
  8350. END User_xfer_commands;   
  8351. --::::::::::::::
  8352. --ftpusrpi_.ada
  8353. --::::::::::::::
  8354. -----------------------------------------------------------------------
  8355. --
  8356. --         DoD Protocols    NA-00005-200       80-01114-100(-)
  8357. --         E-Systems, Inc.  August 07, 1985
  8358. --
  8359. --         FTPUSRPI_.ADA       Author : Mark Volpe
  8360. --
  8361. -----------------------------------------------------------------------
  8362. -- FILE : FTPUSRPI               AUTHOR : MARK VOLPE
  8363.  
  8364. -- 5/21/85    10:07 AM : REVISED FOR USE WITH DEC COMPILER 
  8365. --                       OLD CODE (TELESOFT) MARKED WITH --&MT  
  8366.  
  8367. -- 5/31/85    2:16 PM  : REVISED FOR USE WITH TELESOFT COMPILER
  8368. --                       OLD CODE (DEC) MARKED WITH --&MT
  8369.  
  8370. -- 5/31/85    2:44 PM  : REVISED FOR USE WITH THE DEC COMPILER
  8371. --                       OLD CODE (TELESOFT) MARKED WITH --&MT
  8372.  
  8373. --&MT THE FOLLOWING LINE SHOULD BE DELETED WHEN USING DEC ADA :
  8374. --&MT PRAGMA SOURCE_INFO ( ON );
  8375.  
  8376. WITH     
  8377.         Ftp_types,    -- Global variables.
  8378.         Reply_types,
  8379.         Ftp_terminal_driver,
  8380.         Ftp_utilities,
  8381.        Ftp_command_utilities,
  8382.         Site_details,
  8383.         Reply_utilities;
  8384.  
  8385. --&MT THE FOLLOWING LINE WAS ADDED TO GIVE FTPUSRPI BETTER ACCESS TO FTP_TYPES
  8386. --&MT  SO THAT COMPARISONS COULD BE MADE BETWEEN ENUMERATED TYPES :
  8387. USE FTP_TYPES ;
  8388.  
  8389. PACKAGE User_pi_commands IS
  8390. -------------------------------------------------------------------------------
  8391. --
  8392. -- This package contains the routines to process ftp commands which must be 
  8393. -- transmitted from the user pi to the server pi, and/or directly effect the 
  8394. -- user pi.
  8395. --
  8396. -------------------------------------------------------------------------------
  8397.  
  8398.    PROCEDURE Send_noop_to_server_pi
  8399.            ( Status : out Ftp_utilities.command_status_spec;
  8400.                   User_parameters : IN OUT Ftp_utilities.ftp_parameters_spec );
  8401.         ----------------------------------------------------------------------
  8402.         --
  8403.        -- This processes the 'noop' command on the user's side.
  8404.         -- It sends a noop command to the server system via telnet.
  8405.         --
  8406.         ----------------------------------------------------------------------
  8407.  
  8408.    PROCEDURE Send_help_to_server_pi
  8409.            ( Status : out Ftp_utilities.command_status_spec;
  8410.                   User_parameters : IN OUT Ftp_utilities.ftp_parameters_spec;
  8411.              Argument : IN Ftp_types.argument_list );
  8412.         ----------------------------------------------------------------------
  8413.         --
  8414.        -- This procedure processes the 'help' cmd on the user's side.
  8415.         -- It sends a help command to the server system via telnet.
  8416.         --
  8417.         ----------------------------------------------------------------------
  8418.  
  8419.    PROCEDURE Send_quit_to_server_pi 
  8420.            ( Status : out Ftp_utilities.command_status_spec;
  8421.                   User_parameters : IN OUT Ftp_utilities.ftp_parameters_spec );
  8422.         ----------------------------------------------------------------------
  8423.         --
  8424.        -- This procedure is used during the 'quit' command.
  8425.        -- It tells the server system to close the telnet connection.
  8426.        -- No reply is expected other than the close of the telnet link
  8427.         --
  8428.         ----------------------------------------------------------------------
  8429.  
  8430.    PROCEDURE Send_user_to_server_pi 
  8431.            ( Status : out Ftp_utilities.command_status_spec;
  8432.                   User_parameters : IN OUT Ftp_utilities.ftp_parameters_spec;
  8433.              Argument : IN Ftp_types.argument_list );
  8434.         ----------------------------------------------------------------------
  8435.         --
  8436.        -- This procedure is used during the login process.
  8437.        -- It is used to initiate the login sequence.
  8438.         --
  8439.         ----------------------------------------------------------------------
  8440.  
  8441.    PROCEDURE Call_server_pi 
  8442.            ( Status : out Ftp_utilities.command_status_spec;
  8443.                   User_parameters : IN OUT Ftp_utilities.ftp_parameters_spec;
  8444.              Argument : IN Ftp_types.argument_list );
  8445.         ----------------------------------------------------------------------
  8446.         --
  8447.         -- This procedure is used to establish a telnet link
  8448.         --
  8449.         ----------------------------------------------------------------------
  8450.  
  8451.    PROCEDURE Disconnect_from_server_pi 
  8452.            ( Status : out Ftp_utilities.command_status_spec;
  8453.                   User_parameters : IN OUT Ftp_utilities.ftp_parameters_spec;
  8454.              Argument : IN Ftp_types.argument_list );
  8455.         ----------------------------------------------------------------------
  8456.         --
  8457.         -- This procedure is used to close a telnet link
  8458.         --
  8459.         ----------------------------------------------------------------------
  8460.  
  8461. END User_pi_commands;
  8462.  
  8463. --::::::::::::::
  8464. --ftpusrpi.ada
  8465. --::::::::::::::
  8466. -----------------------------------------------------------------------
  8467. --
  8468. --         DoD Protocols    NA-00005-200       80-01115-100(-)
  8469. --         E-Systems, Inc.  August 07, 1985
  8470. --
  8471. --         FTPUSRPI.ADA       Author : Mark Volpe
  8472. --
  8473. -----------------------------------------------------------------------
  8474. -- FILE : FTPUSRPI               AUTHOR : MARK VOLPE
  8475.  
  8476. -- 5/21/85    10:07 AM : REVISED FOR USE WITH DEC COMPILER 
  8477. --                       OLD CODE (TELESOFT) MARKED WITH --&MT  
  8478.  
  8479. -- 5/31/85    2:16 PM  : REVISED FOR USE WITH TELESOFT COMPILER
  8480. --                       OLD CODE (DEC) MARKED WITH --&MT
  8481.  
  8482. -- 5/31/85    2:48 PM  : REVISED FOR USE WITH THE DEC COMPILER
  8483. --                       OLD CODE (TELESOFT) MARKED WITH --&MT
  8484.  
  8485. PACKAGE BODY User_pi_commands IS 
  8486.  
  8487.   PROCEDURE Call_server_pi 
  8488.     ( Status : out Ftp_utilities.command_status_spec;
  8489.       User_parameters : IN OUT Ftp_utilities.ftp_parameters_spec ;
  8490.       Argument : IN Ftp_types.argument_list ) IS
  8491.     BEGIN
  8492.         Ftp_utilities.indicate_command_was_not_successful ( Status );
  8493.         IF Ftp_utilities.telnet_link_is_open ( User_parameters ) THEN 
  8494.             Ftp_terminal_driver.output_message_with_new_line
  8495.                 (" Already a Telnet link open");
  8496.         ELSE
  8497.             Ftp_utilities.open_telnet_link ( User_parameters, Argument );
  8498.             IF Ftp_utilities.telnet_link_is_open ( User_parameters ) THEN
  8499.                 Ftp_utilities.indicate_command_was_successful ( Status );
  8500.             Ftp_terminal_driver.output_message_with_new_line
  8501.                 (" Telnet connection established");
  8502.             ELSE
  8503.             Ftp_terminal_driver.output_message_with_new_line
  8504.                 (" Request failed, no connection established");
  8505.             END IF;
  8506.         END IF;
  8507.     EXCEPTION
  8508.         WHEN OTHERS =>
  8509.             Ftp_terminal_driver.output_message_with_new_line
  8510.                 (" Unknown exception in Call_server_pi");
  8511.             RAISE;
  8512.     END Call_server_pi;
  8513.  
  8514.   PROCEDURE Disconnect_from_server_pi 
  8515.            ( Status : out Ftp_utilities.command_status_spec;
  8516.                   User_parameters : IN OUT Ftp_utilities.ftp_parameters_spec;
  8517.              Argument : IN Ftp_types.argument_list ) IS
  8518.       Temp_status : Ftp_utilities.command_status_spec ;
  8519.     BEGIN
  8520.         Ftp_utilities.indicate_command_was_not_successful ( Temp_status );
  8521.         IF NOT Ftp_utilities.telnet_link_is_open( User_parameters ) THEN 
  8522.             Ftp_terminal_driver.output_message_with_new_line
  8523.                                     (" No telnet connection open");
  8524.             Ftp_utilities.indicate_command_was_successful ( Temp_status );
  8525.         ELSE -- Telnet link open, user may or may not be logged in
  8526.             Send_quit_to_server_pi ( Temp_status, User_parameters );
  8527.             IF Ftp_utilities.command_was_successful ( Temp_status ) THEN
  8528.                 Ftp_utilities.indicate_command_was_successful ( Temp_status );
  8529.                 Ftp_terminal_driver.output_message_with_new_line
  8530.                                     (" Telnet connection closed");
  8531.             ELSE
  8532.                 Ftp_terminal_driver.output_message_with_new_line
  8533.                                     (" Telnet connection still open");
  8534.             END IF;
  8535.         END IF;
  8536.       Status := Temp_status ;
  8537.     EXCEPTION
  8538.         WHEN OTHERS =>
  8539.             Ftp_terminal_driver.output_message_with_new_line
  8540.                 (" Unknown exception in Disconnect_from_server_pi");
  8541.             RAISE;
  8542.     END Disconnect_from_server_pi;
  8543.  
  8544.   PROCEDURE Send_pass_to_server_pi 
  8545.         ( Status : out Ftp_utilities.command_status_spec ;
  8546.           User_parameters : IN OUT Ftp_utilities.ftp_parameters_spec ) IS
  8547.  
  8548.         Xmit_status    : Ftp_command_utilities.transmission_status_spec;
  8549.         Reply        : Reply_types.reply_code_spec;
  8550.         Password    : Ftp_types.argument_list := Ftp_types.null_argument;
  8551.         Keyboard_data    : Ftp_types.argument_list := Ftp_types.null_argument;
  8552.         Command        : Ftp_types.valid_command_spec;
  8553.         Command_status  : Ftp_command_utilities.command_status_spec;
  8554.         Temp_status     : Ftp_utilities.command_status_spec ; 
  8555.     BEGIN
  8556.         --
  8557.         -- Don't test connection or login status, already done in user
  8558.         --
  8559.         Ftp_utilities.indicate_command_was_not_successful ( Temp_status );
  8560.         Ftp_terminal_driver.output_message_with_new_line(" Password required");
  8561.         Ftp_command_utilities.get_command_from_keyboard 
  8562.                         ( Command_status, Command, Password );
  8563.         IF Command /= Ftp_types.pass_command THEN
  8564.             Ftp_terminal_driver.output_message_with_new_line
  8565.                     (" Invalid response, password was required");
  8566.         ELSIF Ftp_command_utilities.argument_list_is_invalid(command_status) 
  8567.             THEN
  8568.                     Ftp_terminal_driver.output_message_with_new_line
  8569.                        (" Invalid password command; please restart with USER");
  8570.         ELSE
  8571.             Ftp_command_utilities.send_command_over_telnet
  8572.                 ( Xmit_status, Ftp_types.pass_command, Password );
  8573.             IF Ftp_command_utilities.transmission_successful( Xmit_status ) THEN
  8574.                    Reply_utilities.get_reply_from_telnet( Reply );
  8575.                    IF Reply_types.positive_completion_reply ( Reply ) THEN
  8576.                         Ftp_utilities.indicate_command_was_successful (Temp_status);
  8577.                    ELSIF Reply_types.positive_intermediate_reply( Reply ) THEN
  8578.                 Ftp_terminal_driver.output_message_with_new_line
  8579.                      (" Accounting not implemented; please restart with USER");
  8580.                    ELSIF Reply_types.transient_negative_completion_reply(reply)
  8581.                      THEN
  8582.                 Ftp_terminal_driver.output_message_with_new_line
  8583.                     (" Please retry starting with USER");
  8584.                    ELSIF Reply_types.permanent_negative_completion_reply(reply)
  8585.                      THEN
  8586.                 Ftp_terminal_driver.output_message_with_new_line
  8587.                             (" Password failed at remote host;" &
  8588.                              " please retry starting with USER");
  8589.                    ELSE
  8590.                 Ftp_terminal_driver.output_message_with_new_line
  8591.                             (" Invalid reply to password;" &
  8592.                              " please retry starting with USER");
  8593.                    END IF;
  8594.                 END IF;    
  8595.             END IF;
  8596.             IF Ftp_utilities.command_was_successful ( Temp_status ) THEN
  8597.                 Ftp_utilities.indicate_user_is_logged_in( User_parameters );
  8598.             ELSE
  8599.                 Ftp_utilities.indicate_user_is_logged_out( User_parameters);
  8600.             END IF;
  8601.       Status := Temp_status ;
  8602.     EXCEPTION
  8603.         WHEN OTHERS =>
  8604.             Ftp_terminal_driver.output_message_with_new_line
  8605.                 (" Unknown exception in Send_pass_to_server_pi");
  8606.             RAISE;
  8607.     END Send_pass_to_server_pi ;
  8608.  
  8609.   PROCEDURE Send_user_to_server_pi 
  8610.            ( Status : out Ftp_utilities.command_status_spec ;
  8611.                   User_parameters : IN OUT Ftp_utilities.ftp_parameters_spec;
  8612.              Argument : IN Ftp_types.argument_list ) IS
  8613.         Xmit_status    : Ftp_command_utilities.transmission_status_spec;
  8614.         Reply        : Reply_types.reply_code_spec;
  8615.         Username    : Ftp_types.argument_list := Ftp_types.null_argument;
  8616.     BEGIN
  8617.         Ftp_utilities.indicate_command_was_not_successful ( Status );
  8618.         IF Ftp_utilities.telnet_link_is_open ( User_parameters ) THEN
  8619.             Ftp_command_utilities.get_first_argument_from_argument_list
  8620.                 ( Argument, Username );
  8621.             Ftp_command_utilities.send_command_over_telnet
  8622.                 ( Xmit_status , Ftp_types.user_command, Username );
  8623.             IF Ftp_command_utilities.transmission_successful( Xmit_status ) THEN
  8624.                Reply_utilities.get_reply_from_telnet( Reply );
  8625.                IF Reply_types.positive_completion_reply ( Reply ) THEN
  8626.                       Ftp_utilities.indicate_user_is_logged_in 
  8627.                                                         ( User_parameters );
  8628.                       Ftp_utilities.indicate_command_was_successful 
  8629.                                                         ( Status );
  8630.                ELSIF Reply_types.positive_intermediate_reply( Reply ) THEN
  8631.                         -- Return status set according to return status of 
  8632.                         -- send pass
  8633.                         Send_pass_to_server_pi 
  8634.                             ( Status, User_parameters );
  8635.                ELSIF Reply_types.transient_negative_completion_reply(reply)
  8636.                      THEN
  8637.                 Ftp_terminal_driver.output_message_with_new_line
  8638.                     (" Please retry the USER command");
  8639.                ELSIF Reply_types.permanent_negative_completion_reply(reply)
  8640.                      THEN
  8641.                 Ftp_terminal_driver.output_message_with_new_line
  8642.                     (" Command failed at remote host;" &
  8643.                                  " user is not logged in");
  8644.                ELSE
  8645.                 Ftp_terminal_driver.output_message_with_new_line
  8646.                     (" Invalid reply to command; please retry");
  8647.                END IF; -- End reply tests
  8648.             ELSE
  8649.                     Ftp_terminal_driver.output_message_with_new_line
  8650.                         (" User not logged in; TCp failed");
  8651.             END IF; -- END TEST FOR XMIT STATUS
  8652.         ELSE
  8653.             Ftp_terminal_driver.output_message_with_new_line
  8654.                 (" Please CALL the remote host first");
  8655.         END IF; -- End test to see if telnet link open
  8656.     EXCEPTION
  8657.         WHEN OTHERS =>
  8658.             Ftp_terminal_driver.output_message_with_new_line
  8659.                 (" Unknown exception in Send_user_to_server_pi");
  8660.             RAISE;
  8661.    END Send_user_to_server_pi ;
  8662.  
  8663.   PROCEDURE Send_noop_to_server_pi 
  8664.         ( Status : out Ftp_utilities.command_status_spec ;
  8665.           User_parameters : IN OUT Ftp_utilities.ftp_parameters_spec ) IS
  8666.         Reply        : Reply_types.reply_code_spec;
  8667.         Xmit_status    : Ftp_command_utilities.transmission_status_spec;
  8668.     BEGIN
  8669.             Ftp_utilities.indicate_command_was_not_successful ( Status );
  8670.             IF NOT Ftp_utilities.telnet_link_is_open ( User_parameters ) THEN
  8671.                 Ftp_terminal_driver.output_message_with_new_line
  8672.                     (" No telnet connection, " &
  8673.                      " please CALL remote_host first");
  8674.             ELSE
  8675.            Ftp_command_utilities.send_command_over_telnet
  8676.                     ( Xmit_status ,
  8677.                       Ftp_types.noop_command,
  8678.                       Ftp_types.null_argument );
  8679.             IF Ftp_command_utilities.transmission_successful( Xmit_status ) 
  8680.                   THEN
  8681.                    Reply_utilities.get_reply_from_telnet( Reply );
  8682.                    IF Reply_types.positive_completion_reply ( Reply ) THEN
  8683.                         Ftp_utilities.indicate_command_was_successful (status);
  8684.                    ELSIF Reply_types.transient_negative_completion_reply(reply)
  8685.                      THEN
  8686.                 Ftp_terminal_driver.output_message_with_new_line
  8687.                     (" Please retry");
  8688.                    ELSIF Reply_types.permanent_negative_completion_reply(reply)
  8689.                      THEN
  8690.                     Ftp_terminal_driver.output_message_with_new_line
  8691.                     (" Command failed at remote host");
  8692.                    ELSE
  8693.                 Ftp_terminal_driver.output_message_with_new_line
  8694.                     (" Invalid reply, please retry");
  8695.                    END IF;
  8696.             END IF;
  8697.             END IF;
  8698.     EXCEPTION
  8699.         WHEN OTHERS =>
  8700.             Ftp_terminal_driver.output_message_with_new_line
  8701.                 (" Unknown exception in Send_noop_to_server_pi");
  8702.             RAISE;
  8703.    END Send_noop_to_server_pi;
  8704.  
  8705.   PROCEDURE Send_help_to_server_pi 
  8706.            ( Status : out Ftp_utilities.command_status_spec;
  8707.                   User_parameters : IN OUT Ftp_utilities.ftp_parameters_spec;
  8708.              Argument : IN Ftp_types.argument_list ) IS
  8709.         Xmit_status    : Ftp_command_utilities.transmission_status_spec;
  8710.         Reply        : Reply_types.reply_code_spec;
  8711.     BEGIN
  8712.             Ftp_utilities.indicate_command_was_not_successful (status);
  8713.             IF NOT Ftp_utilities.telnet_link_is_open( User_parameters ) THEN
  8714.                 Ftp_terminal_driver.output_message_with_new_line
  8715.                     (" Local help not yet implemented");
  8716.                 Ftp_terminal_driver.output_message_with_new_line
  8717.                     (" Please call a remote host");
  8718.             ELSE
  8719.                 Ftp_command_utilities.send_command_over_telnet 
  8720.                 ( Xmit_status, Ftp_types.help_command, Argument );
  8721.             IF Ftp_command_utilities.transmission_successful( Xmit_status ) 
  8722.                  THEN
  8723.                    Reply_utilities.get_reply_from_telnet ( Reply );
  8724.                    IF Reply_types.positive_completion_reply( Reply ) THEN
  8725.                       Ftp_utilities.indicate_command_was_successful ( Status );
  8726.                    ELSIF Reply_types.transient_negative_completion_reply(reply)
  8727.                       THEN
  8728.                          Ftp_terminal_driver.output_message_with_new_line
  8729.                             (" Please retry");
  8730.                    ELSIF Reply_types.permanent_negative_completion_reply(reply)
  8731.                       THEN
  8732.                          Ftp_terminal_driver.output_message_with_new_line
  8733.                         (" Command failed at remote host");
  8734.                    ELSE
  8735.                          Ftp_terminal_driver.output_message_with_new_line
  8736.                               (" Invalid reply, please retry");
  8737.                    END IF;
  8738.             END IF;
  8739.             END IF;
  8740.     EXCEPTION
  8741.         WHEN OTHERS =>
  8742.             Ftp_terminal_driver.output_message_with_new_line
  8743.                 (" Unknown exception in Send_help_to_server_pi");
  8744.             RAISE;
  8745.    END Send_help_to_server_pi ;
  8746.  
  8747.   PROCEDURE Send_quit_to_server_pi 
  8748.     ( Status : out Ftp_utilities.command_status_spec;
  8749.       User_parameters : IN OUT Ftp_utilities.ftp_parameters_spec ) IS
  8750.         Xmit_status    : Ftp_command_utilities.transmission_status_spec;
  8751.         Reply        : Reply_types.reply_code_spec;
  8752.         Argument    : Ftp_types.argument_list := Ftp_types.null_argument;
  8753.     BEGIN
  8754.             Ftp_utilities.indicate_command_was_not_successful( Status );
  8755.             IF NOT Ftp_utilities.telnet_link_is_open( User_parameters ) THEN
  8756.                 Ftp_terminal_driver.output_message_with_new_line
  8757.                     (" No telnet connection open");
  8758.             ELSE
  8759.             Ftp_command_utilities.send_command_over_telnet 
  8760.                     ( Xmit_status,ftp_types.quit_command,argument);
  8761.             IF Ftp_command_utilities.transmission_successful ( Xmit_status )
  8762.                  THEN
  8763.                   Reply_utilities.get_reply_from_telnet ( Reply );
  8764.                   IF Reply_types.positive_completion_reply(reply) THEN
  8765.                     Ftp_utilities.indicate_user_is_logged_out(user_parameters);
  8766.                     Ftp_utilities.indicate_telnet_link_closed(user_parameters);
  8767.                     Ftp_utilities.indicate_command_was_successful (status);
  8768.                   ELSE
  8769.                     Ftp_terminal_driver.output_message_with_new_line
  8770.                                         (" User still logged");
  8771.                   END IF;
  8772.                 END IF;
  8773.             END IF;
  8774.     EXCEPTION
  8775.             WHEN OTHERS =>
  8776.                 Ftp_terminal_driver.output_message_with_new_line
  8777.                 (" Unknown exception in Send_quit_to_server_pi");
  8778.                 RAISE;
  8779.     END SEND_QUIT_TO_SERVER_PI;
  8780.  
  8781. BEGIN
  8782.     NULL;
  8783. EXCEPTION
  8784.         WHEN OTHERS =>
  8785.             Ftp_terminal_driver.output_message_with_new_line
  8786.                 (" Unknown exception in User_pi_commands");
  8787.             RAISE;
  8788. END User_pi_commands;
  8789. --::::::::::::::
  8790. --ftpusrdtp_.ada
  8791. --::::::::::::::
  8792. -----------------------------------------------------------------------
  8793. --
  8794. --         DoD Protocols    NA-00005-200       80-01112-100(-)
  8795. --         E-Systems, Inc.  August 07, 1985
  8796. --
  8797. --         FTPUSRDTP_.ADA       Author : Mark Volpe
  8798. --
  8799. -----------------------------------------------------------------------
  8800. -- FILE : FTPUSRDTP               AUTHOR : MARK VOLPE
  8801.  
  8802. -- 5/21/85    10:39 AM : REVISED FOR USE WITH DEC COMPILER 
  8803. --                       OLD CODE (TELESOFT) MARKED WITH --&MT  
  8804.  
  8805. -- 5/31/85    2:29 PM  : REVISED FOR USE WITH TELESOFT COMPILER
  8806. --                       OLD CODE (DEC) MARKED WITH --&MT
  8807.  
  8808. -- 5/31/85    2:58 PM  : REVISED FOR USE WITH THE DEC COMPILER
  8809. --                       OLD CODE (TELESOFT) MARKED WITH --&MT
  8810.  
  8811. --&MT THE FOLLOWING LINE SHOULD BE DELETED WHEN USING DEC ADA :
  8812. --&MT PRAGMA SOURCE_INFO ( ON );
  8813.  
  8814. WITH
  8815.     My_debug_io,
  8816.     Ftp_types,
  8817.     Reply_types,
  8818.     Ftp_terminal_driver,
  8819.     Ftp_command_utilities,
  8820.     Site_details,
  8821.     Ftp_utilities,
  8822.     Reply_utilities;
  8823.  
  8824. PACKAGE User_dtp_commands IS
  8825.    ----------------------------------------------------------------------
  8826.    --
  8827.    -- This package conatins procedures which effect the way files
  8828.    -- are sent between PI's.
  8829.    --
  8830.    ----------------------------------------------------------------------
  8831.  
  8832.    PROCEDURE Send_stru_to_server_pi 
  8833.         ( Status : out Ftp_utilities.command_status_spec ;
  8834.           User_parameters : IN OUT Ftp_utilities.ftp_parameters_spec;
  8835.           Argument : IN Ftp_types.argument_list );
  8836.         ----------------------------------------------------------------------
  8837.         --
  8838.        -- This procedure is used during the 'stru' command.
  8839.        -- It sends the new structure to the server system.
  8840.         --
  8841.         ----------------------------------------------------------------------
  8842.  
  8843.    PROCEDURE Send_type_to_server_pi 
  8844.         ( Status : out Ftp_utilities.command_status_spec ;
  8845.           User_parameters : IN OUT Ftp_utilities.ftp_parameters_spec;
  8846.           Argument : IN Ftp_types.argument_list );
  8847.         ----------------------------------------------------------------------
  8848.         --
  8849.        -- This procedure is used during the 'type' command.
  8850.        -- It sends the new type to the server system.
  8851.        -- 
  8852.         ----------------------------------------------------------------------
  8853.  
  8854.    PROCEDURE Send_mode_to_server_pi 
  8855.         ( Status : out Ftp_utilities.command_status_spec ;
  8856.           User_parameters : IN OUT Ftp_utilities.ftp_parameters_spec;
  8857.           Argument : IN Ftp_types.argument_list );
  8858.         ----------------------------------------------------------------------
  8859.         --
  8860.        -- This procedure is used during the 'mode' command.
  8861.        -- It sends the new mode to the server system.
  8862.         --
  8863.         ----------------------------------------------------------------------
  8864.  
  8865.    PROCEDURE Send_port_to_server_pi 
  8866.         ( Status : out Ftp_utilities.command_status_spec ;
  8867.           User_parameters : IN OUT Ftp_utilities.ftp_parameters_spec;
  8868.           Argument : IN Ftp_types.argument_list );
  8869.         ----------------------------------------------------------------------
  8870.         --
  8871.        -- This procedure is used during the 'port' command.
  8872.        -- It sends the new transmit port to the server system.
  8873.        -- 
  8874.         ----------------------------------------------------------------------
  8875.  
  8876. END User_dtp_commands;
  8877.  
  8878. --::::::::::::::
  8879. --ftpusrdtp.ada
  8880. --::::::::::::::
  8881. -----------------------------------------------------------------------
  8882. --
  8883. --         DoD Protocols    NA-00005-200       80-01113-100(-)
  8884. --         E-Systems, Inc.  August 07, 1985
  8885. --
  8886. --         FTPUSRDTP.ADA       Author : Mark Volpe
  8887. --
  8888. -----------------------------------------------------------------------
  8889. -- FILE : FTPUSRDTP               AUTHOR : MARK VOLPE
  8890.  
  8891. -- 5/21/85    10:39 AM : REVISED FOR USE WITH DEC COMPILER 
  8892. --                       OLD CODE (TELESOFT) MARKED WITH --&MT  
  8893.  
  8894. -- 5/31/85    2:29 PM  : REVISED FOR USE WITH TELESOFT COMPILER
  8895. --                       OLD CODE (DEC) MARKED WITH --&MT
  8896.  
  8897. -- 5/31/85    3:04 PM  : REVISED FOR USE WITH THE DEC COMPILER
  8898. --                       OLD CODE (TELESOFT) MARKED WITH --&MT
  8899.  
  8900. --&MT THE FOLLOWING LINE WAS ADDED TO GIVE FTPUSRDTP.ADA ACCESS TO TEXT_IO :
  8901. WITH TEXT_IO ;
  8902.  
  8903. PACKAGE BODY User_dtp_commands IS
  8904.  
  8905. --&MT SUBTYPE BIT_COUNT_32_TYPE IS LONG_INTEGER;
  8906.       SUBTYPE BIT_COUNT_32_TYPE IS INTEGER;
  8907.  
  8908. --&MT SUBTYPE BIT_COUNT_16_TYPE IS INTEGER;
  8909.       SUBTYPE BIT_COUNT_16_TYPE IS SHORT_INTEGER;
  8910.  
  8911. --&MT THE FOLLOWING LINES SHOULD BE DELETED WHEN USING TELESOFT :
  8912.   PACKAGE LONG_INT IS NEW TEXT_IO.INTEGER_IO(BIT_COUNT_32_TYPE);
  8913.   PACKAGE INT_IO IS NEW TEXT_IO.INTEGER_IO(BIT_COUNT_16_TYPE);
  8914.  
  8915.   PROCEDURE Change_our_port 
  8916.         ( Status : out Ftp_utilities.command_status_spec ;
  8917.           User_parameters : IN OUT Ftp_utilities.ftp_parameters_spec;
  8918.           Argument : IN Ftp_types.argument_list ) IS
  8919.             Port_id      : Ftp_types.argument_list;
  8920.             Strng        : 
  8921.  
  8922.        --&MT STRING( Argument'first..argument'last );
  8923.              STRING( bit_count_32_type(Argument'first)..bit_count_32_type(argument'last) );
  8924.  
  8925.             Strng_length : BIT_COUNT_16_TYPE;
  8926.       Temp_status : Ftp_utilities.command_status_spec ;     
  8927.     BEGIN
  8928.         Ftp_utilities.change_port ( Temp_status, User_parameters, Argument );
  8929.         IF NOT Ftp_utilities.command_was_successful ( Temp_status ) THEN
  8930.                 Ftp_terminal_driver.output_message_with_new_line
  8931.                     (" Invalid port specified");
  8932.         END IF;
  8933.         Port_id := Ftp_utilities.get_current_port ( User_parameters );
  8934.         Ftp_types.convert_argument_to_string ( Port_id, Strng, Strng_length );
  8935.         Ftp_terminal_driver.output_message (" New port is: ");
  8936.         Ftp_terminal_driver.output_message_with_new_line
  8937.             ( Strng( Strng'first..strng'first + 
  8938.  
  8939.          --&MT Strng_length - 1) );
  8940.                bit_count_32_type(Strng_length) - 1) );
  8941.  
  8942.         STATUS := Temp_status ;
  8943.     EXCEPTION
  8944.         WHEN OTHERS =>
  8945.             Ftp_terminal_driver.output_message_with_new_line
  8946.                       (" Unknown exception in Change_our_port");
  8947.             RAISE;
  8948.     END Change_our_port;
  8949.  
  8950.   PROCEDURE Send_port_to_server_pi 
  8951.            ( Status    : out Ftp_utilities.command_status_spec ;
  8952.                   User_parameters : IN OUT Ftp_utilities.ftp_parameters_spec;
  8953.              Argument    : IN Ftp_types.argument_list ) IS
  8954.         Reply        : Reply_types.reply_code_spec;
  8955.         XMIT_STATUS    : Ftp_command_utilities.transmission_status_spec;
  8956.     BEGIN
  8957.         Ftp_utilities.indicate_command_was_not_successful( Status );
  8958.         IF Site_details.specified_host_is_this_host( Argument ) THEN
  8959.                 Change_our_port ( Status, User_parameters, Argument );
  8960.         ELSIF NOT Ftp_utilities.telnet_link_is_open( User_parameters ) THEN
  8961.                 Ftp_terminal_driver.output_message_with_new_line
  8962.                     (" No telnet connection, " &
  8963.                      " please CALL remote_host first");
  8964.         ELSE
  8965.            Ftp_command_utilities.send_command_over_telnet
  8966.                     ( Xmit_status,
  8967.                       Ftp_types.port_command,
  8968.                       Argument );
  8969.            IF Ftp_command_utilities.transmission_successful( Xmit_status ) THEN
  8970.               Reply_utilities.get_reply_from_telnet( Reply );
  8971.               IF Reply_types.positive_completion_reply ( Reply ) THEN
  8972.                  Ftp_utilities.indicate_command_was_successful( Status);
  8973.                  Ftp_terminal_driver.output_message_with_new_line
  8974.                         (" Remote port changed");
  8975.               ELSIF Reply_types.transient_negative_completion_reply(reply) THEN
  8976.                  Ftp_terminal_driver.output_message_with_new_line
  8977.                         (" Please retry");
  8978.               ELSIF Reply_types.permanent_negative_completion_reply( Reply) THEN
  8979.                  Ftp_terminal_driver.output_message_with_new_line
  8980.                     (" Command failed at remote host");
  8981.               ELSE
  8982.                  Ftp_terminal_driver.output_message_with_new_line
  8983.                     (" Invalid reply, please retry");
  8984.               END IF;
  8985.            END IF;
  8986.         END IF;
  8987.     EXCEPTION
  8988.         WHEN OTHERS =>
  8989.                     Ftp_terminal_driver.output_message_with_new_line
  8990.                       (" Unknown exception in Send_port_to_server_pi");
  8991.                     RAISE;
  8992.     END Send_port_to_server_pi;
  8993.  
  8994.   PROCEDURE Send_stru_to_server_pi 
  8995.            ( Status : out Ftp_utilities.command_status_spec ;
  8996.                   User_parameters : IN OUT Ftp_utilities.ftp_parameters_spec;
  8997.              Argument : IN Ftp_types.argument_list ) IS
  8998.         Xmit_status        : Ftp_command_utilities.transmission_status_spec;
  8999.         Reply            : Reply_types.reply_code_spec ;
  9000.         Current_structure   : Ftp_types.argument_list 
  9001.                := Ftp_utilities.get_current_structure( User_parameters );
  9002.         Temp_status : Ftp_utilities.command_status_spec ;
  9003.     BEGIN
  9004.         Ftp_utilities.change_file_structure 
  9005.                                 ( Temp_status, User_parameters, Argument ); 
  9006.         IF Ftp_utilities.command_was_successful ( Temp_status ) THEN
  9007.             IF Ftp_utilities.telnet_link_is_open ( User_parameters ) THEN
  9008.                 Ftp_command_utilities.send_command_over_telnet
  9009.                     ( Xmit_status,ftp_types.stru_command,argument);
  9010.                    --
  9011.                    -- Make sure the command got there.
  9012.                    --
  9013.                 IF Ftp_command_utilities.transmission_successful( Xmit_status )
  9014.                 THEN
  9015.                   Ftp_utilities.indicate_command_was_not_successful(Temp_status);
  9016.                   Reply_utilities.get_reply_from_telnet( Reply );
  9017.                   IF Reply_types.positive_completion_reply (reply) THEN
  9018.                         Ftp_utilities.indicate_command_was_successful(Temp_status);
  9019.                   ELSIF Reply_types.transient_negative_completion_reply(reply)
  9020.                     THEN
  9021.                     Ftp_terminal_driver.output_message_with_new_line
  9022.                         (" Please retry");
  9023.               ELSIF Reply_types.permanent_negative_completion_reply(reply)
  9024.                 THEN
  9025.                     Ftp_terminal_driver.output_message_with_new_line
  9026.                       (" Structure not supported at remote host.");
  9027.               ELSE
  9028.                 Ftp_terminal_driver.output_message_with_new_line
  9029.                       (" Invalid reply, please retry");
  9030.               END IF;
  9031.             END IF;
  9032.             END IF;
  9033.         ELSE
  9034.             Ftp_terminal_driver.output_message_with_new_line
  9035.                 (" That structure is not supported at this host");
  9036.         END IF;
  9037.         IF NOT Ftp_utilities.command_was_successful ( Temp_status ) THEN
  9038.                 Ftp_utilities.change_file_structure 
  9039.                                 ( Temp_status, User_parameters, Current_structure );
  9040.         END IF;
  9041.         Current_structure := Ftp_utilities.get_current_structure
  9042.                                                            ( User_parameters );
  9043.         Ftp_terminal_driver.output_message (" Structure is ");
  9044.         Ftp_terminal_driver.output_message
  9045.             ( CHARACTER'( Current_structure( Current_structure'first )));
  9046.         Ftp_terminal_driver.new_line;
  9047.         Status := Temp_status ;
  9048.         EXCEPTION
  9049.             WHEN OTHERS =>
  9050.                 Ftp_terminal_driver.output_message_with_new_line
  9051.                       (" Unknown exception in Send_stru_to_server_pi");
  9052.                 RAISE;
  9053.        END Send_stru_to_server_pi ;
  9054.  
  9055.    PROCEDURE Send_type_to_server_pi 
  9056.            ( Status : out Ftp_utilities.command_status_spec ;
  9057.                   User_parameters : IN OUT Ftp_utilities.ftp_parameters_spec;
  9058.              Argument : IN Ftp_types.argument_list ) IS
  9059.             Reply    : Reply_types.reply_code_spec;
  9060.             Xmit_status    : Ftp_command_utilities.transmission_status_spec;
  9061.             Current_type_and_carriage_control : Ftp_types.argument_list
  9062.                    := Ftp_utilities.get_current_type ( User_parameters );
  9063.             Temp_argument : Ftp_types.argument_list;
  9064.             Temp_status : Ftp_utilities.command_status_spec ;
  9065.     BEGIN
  9066.         Ftp_utilities.change_file_type
  9067.                                 ( Temp_status, User_parameters, Argument );
  9068.         IF Ftp_utilities.command_was_successful ( Temp_status ) THEN
  9069.             IF Ftp_utilities.telnet_link_is_open ( User_parameters ) THEN
  9070.             Ftp_command_utilities.send_command_over_telnet
  9071.                 ( Xmit_status, Ftp_types.type_command, Argument);
  9072.             IF Ftp_command_utilities.transmission_successful( Xmit_status )
  9073.                 THEN
  9074.                   Reply_utilities.get_reply_from_telnet( Reply );
  9075.                   Ftp_utilities.indicate_command_was_not_successful ( Temp_status );
  9076.               IF Reply_types.positive_completion_reply( Reply) THEN
  9077.                         Ftp_utilities.indicate_command_was_successful(Temp_status);
  9078.               ELSIF Reply_types.transient_negative_completion_reply(reply)
  9079.                     THEN
  9080.                     Ftp_terminal_driver.output_message_with_new_line
  9081.                         (" Please retry");
  9082.               ELSIF Reply_types.permanent_negative_completion_reply(reply)
  9083.                 THEN
  9084.                     Ftp_terminal_driver.output_message_with_new_line
  9085.                                (" Type and/or carriage control " &
  9086.                                 "not supported at remote host.");
  9087.               ELSE
  9088.                 Ftp_terminal_driver.output_message_with_new_line
  9089.                       (" Invalid reply, please retry");
  9090.               END IF;
  9091.             END IF;
  9092.             END IF;
  9093.         ELSE
  9094.             Ftp_terminal_driver.output_message_with_new_line
  9095.                 (" That type and/or carriage control " &
  9096.                      "is not supported at this host");
  9097.         END IF;
  9098.         IF NOT Ftp_utilities.command_was_successful ( Temp_status ) THEN
  9099.                 Ftp_utilities.change_file_type 
  9100.                  (Temp_status, User_parameters, Current_type_and_carriage_control);
  9101.         END IF;
  9102.         Current_type_and_carriage_control 
  9103.                     := Ftp_utilities.get_current_type( User_parameters );
  9104.         Ftp_command_utilities.get_first_argument_from_argument_list
  9105.                     ( Current_type_and_carriage_control, Temp_argument );
  9106.         Ftp_terminal_driver.output_message (" Type is ");
  9107.         Ftp_terminal_driver.output_message
  9108.                 ( CHARACTER'(TEMP_ARGUMENT(TEMP_ARGUMENT'FIRST)));
  9109.         Ftp_terminal_driver.new_line;
  9110.         Ftp_command_utilities.get_second_argument_from_argument_list
  9111.                     ( Current_type_and_carriage_control, Temp_argument );
  9112.         Ftp_terminal_driver.output_message (" Carriage control is ");
  9113.         Ftp_terminal_driver.output_message
  9114.                 ( CHARACTER'( Temp_argument( Temp_argument'first)));
  9115.         Ftp_terminal_driver.new_line;
  9116.         STATUS := Temp_status ;
  9117.         EXCEPTION
  9118.             WHEN OTHERS =>
  9119.                 Ftp_terminal_driver.output_message_with_new_line
  9120.                       (" Unknown exception in Send_type_to_server_pi");
  9121.                 RAISE;
  9122.        END Send_type_to_server_pi ;
  9123.  
  9124.    PROCEDURE Send_mode_to_server_pi 
  9125.            ( Status : out Ftp_utilities.command_status_spec ;
  9126.                   User_parameters : IN OUT Ftp_utilities.ftp_parameters_spec;
  9127.              Argument : IN Ftp_types.argument_list ) IS
  9128.         Reply         : Reply_types.reply_code_spec ;
  9129.         Xmit_status     : Ftp_command_utilities.transmission_status_spec;
  9130.         Current_mode    : Ftp_types.argument_list
  9131.               := Ftp_utilities.get_current_mode ( User_parameters );
  9132.         Temp_status : Ftp_utilities.command_status_spec ;
  9133.     BEGIN
  9134.         Ftp_utilities.change_file_mode
  9135.                                 ( Temp_status, User_parameters, Argument );
  9136.         IF Ftp_utilities.command_was_successful ( Temp_status ) THEN
  9137.             IF Ftp_utilities.telnet_link_is_open ( User_parameters ) THEN
  9138.                 Ftp_utilities.indicate_command_was_not_successful ( Temp_status );
  9139.             Ftp_command_utilities.send_command_over_telnet
  9140.                     ( Xmit_status,ftp_types.mode_command,argument);
  9141.             IF Ftp_command_utilities.transmission_successful( Xmit_status ) 
  9142.                  THEN
  9143.                   Reply_utilities.get_reply_from_telnet( Reply );
  9144.               IF Reply_types.positive_completion_reply (reply) THEN
  9145.                         Ftp_utilities.indicate_command_was_successful(Temp_status);
  9146.               ELSIF Reply_types.transient_negative_completion_reply(reply)
  9147.                     THEN
  9148.                     Ftp_terminal_driver.output_message_with_new_line
  9149.                         (" Please retry");
  9150.               ELSIF Reply_types.permanent_negative_completion_reply(reply)
  9151.                 THEN
  9152.                     Ftp_terminal_driver.output_message_with_new_line
  9153.                       (" Mode not supported at remote host.");
  9154.               ELSE
  9155.                 Ftp_terminal_driver.output_message_with_new_line
  9156.                       (" Invalid reply, please retry");
  9157.               END IF;
  9158.             END IF;
  9159.             END IF;
  9160.         ELSE
  9161.             Ftp_terminal_driver.output_message_with_new_line
  9162.                 (" That mode is not supported at this host");
  9163.         END IF;
  9164.         IF NOT Ftp_utilities.command_was_successful ( Temp_status ) THEN
  9165.                 Ftp_utilities.change_file_mode 
  9166.                     ( Temp_status, User_parameters, Current_mode );
  9167.         END IF;
  9168.         Current_mode := Ftp_utilities.get_current_mode ( User_parameters );
  9169.         Ftp_terminal_driver.output_message (" Mode is ");
  9170.         Ftp_terminal_driver.output_message
  9171.                 ( CHARACTER'( Current_mode(current_mode'first)));
  9172.         Ftp_terminal_driver.new_line;
  9173.         Status := Temp_status ;
  9174.         EXCEPTION
  9175.             WHEN OTHERS =>
  9176.                 Ftp_terminal_driver.output_message_with_new_line
  9177.                       (" Unknown exception in Send_mode_to_server_pi");
  9178.                 RAISE;
  9179.        END Send_mode_to_server_pi ;
  9180.  
  9181. BEGIN
  9182.     NULL;
  9183. EXCEPTION
  9184.     WHEN OTHERS =>
  9185.         Ftp_terminal_driver.output_message_with_new_line
  9186.                   (" Unknown exception in User_dtp_commands");
  9187.         RAISE;
  9188. END User_dtp_commands;
  9189. --::::::::::::::
  9190. --ftpuser.ada
  9191. --::::::::::::::
  9192. -----------------------------------------------------------------------
  9193. --
  9194. --         DoD Protocols    NA-00005-200       80-01111-100(-)
  9195. --         E-Systems, Inc.  August 07, 1985
  9196. --
  9197. --         FTPUSER.ADA       Author : Mark Volpe
  9198. --
  9199. -----------------------------------------------------------------------
  9200. -- FILE : Ftpuser               AUTHOR : MARK VOLPE
  9201.  
  9202. -- REVISED FOR USE WITH DEC COMPILER ON : 5/21/85    11:25 AM
  9203. -- REVISIONS MARKED WITH &MT  
  9204.  
  9205. -- 6/24/85    4:45 PM  : converted SERVER_TELNET into a task,
  9206. --                       added code appended with --&KJW
  9207.  
  9208. --&MT PRAGMA SOURCE_INFO ( ON );
  9209.  
  9210. WITH
  9211.    Server_telnet_package, --&KJW
  9212.    Ftp_types,            -- GLOBAL TYPES AND VARIABLES
  9213.    Ftp_command_utilities, -- GET COMMAND FROM KEYBOARD
  9214.    Ftp_terminal_driver,  -- FOR OUTPUT TO THE TERMINAL
  9215.    User_pi_commands,     -- COMMANDS TO USER PI
  9216.    User_dtp_commands,    --
  9217.    User_xfer_commands,   -- COMMANDS TO XFER FILES
  9218.    Ftp_utilities;        --
  9219. USE
  9220.     User_xfer_commands,
  9221.     User_pi_commands,
  9222.     User_dtp_commands;
  9223.  
  9224. PROCEDURE User_ftp IS
  9225.    ----------------------------------------------------------------------
  9226.    --
  9227.    -- This procedure is the upper level of FTP on the user side.
  9228.    -- It is responsible for interfacing between the user and the remote
  9229.    -- system.
  9230.    --
  9231.    -- The command is accepted from the user via the nvt keyboard.
  9232.    -- This command is then verified and converted to an enumerated type.
  9233.    -- A command handler is called based on this enumerated type.
  9234.    --
  9235.    ----------------------------------------------------------------------
  9236.   
  9237.    User_parameters : Ftp_utilities.ftp_parameters_spec;
  9238.    TelNet_Server     : Server_telnet_package.TelNet_Controller;    
  9239.  
  9240.   TASK  Process_User_Command  IS    --&KJW
  9241.     PRAGMA Priority(6);            --&KJW
  9242.   END Process_User_Command;        --&KJW
  9243.  
  9244.   TASK BODY  Process_User_Command  IS    --&KJW
  9245.   --PROCEDURE Process_user_command
  9246.   --     ( User_parameters : IN OUT Ftp_utilities.ftp_parameters_spec ) IS
  9247.   -- N O T I C E ::  What was once parameter "server_parameters"    --&KJW
  9248.   --                    is now global object "server_parameters"    --&KJW
  9249.     -----------------------------------------------------------------
  9250.    --
  9251.    -- This procedure is the driver for ftp on the user side.
  9252.    -- It gets the command from telnet then calls the appropriate command
  9253.    -- handler.
  9254.    --
  9255.     -----------------------------------------------------------------
  9256.   
  9257.    Command             : Ftp_types.valid_command_spec;
  9258.    Argument            : Ftp_types.argument_list;
  9259.    User_command_status : Ftp_utilities.command_status_spec;
  9260.    Command_status      : Ftp_command_utilities.command_status_spec;
  9261.  
  9262.    BEGIN
  9263.        LOOP
  9264.         Ftp_command_utilities.get_command_from_keyboard
  9265.                         ( Command_status, Command, Argument );
  9266.         IF Ftp_command_utilities.argument_list_is_invalid( Command_status ) THEN
  9267.             Ftp_terminal_driver.output_message_with_new_line
  9268.                 (" Invalid command ");
  9269.         ELSE
  9270.           CASE FTP_TYPES.VALID_COMMAND_SPEC'(COMMAND) IS
  9271.             WHEN  Ftp_types.call_command =>
  9272.                    Call_server_pi
  9273.                     ( User_command_status, User_parameters, Argument );
  9274.             WHEN  Ftp_types.clos_command =>
  9275.                     Disconnect_from_server_pi
  9276.                             ( User_command_status, User_parameters, Argument);
  9277.             WHEN  Ftp_types.exit_command =>
  9278.                     Disconnect_from_server_pi
  9279.                             ( User_command_status, User_parameters, Argument);
  9280.                     IF Ftp_utilities.command_was_successful
  9281.                        ( User_command_status ) THEN
  9282.                                 EXIT;
  9283.                     END IF;
  9284.             WHEN  Ftp_types.quit_command =>
  9285.                    Send_quit_to_server_pi
  9286.                     ( User_command_status, User_parameters );
  9287.             WHEN  Ftp_types.help_command =>
  9288.                         Send_help_to_server_pi
  9289.                             ( User_command_status, User_parameters, Argument );
  9290.             WHEN  Ftp_types.user_command =>
  9291.                    Send_user_to_server_pi
  9292.                     ( User_command_status, User_parameters, Argument );
  9293.             WHEN  Ftp_types.pass_command =>
  9294.                   Ftp_terminal_driver.output_message_with_new_line
  9295.                     (" Password not valid in this context");
  9296.             WHEN  Ftp_types.noop_command =>
  9297.                    Send_noop_to_server_pi
  9298.                     ( User_command_status, User_parameters );
  9299.             WHEN  Ftp_types.stru_command =>
  9300.                    Send_stru_to_server_pi
  9301.                     ( User_command_status, User_parameters, Argument );
  9302.             WHEN  Ftp_types.type_command =>
  9303.                    Send_type_to_server_pi
  9304.                     ( User_command_status, User_parameters, Argument );
  9305.             WHEN  Ftp_types.mode_command =>
  9306.                    Send_mode_to_server_pi
  9307.                     ( User_command_status, User_parameters, Argument );
  9308.             WHEN  Ftp_types.port_command =>
  9309.                    Send_port_to_server_pi
  9310.                     ( User_command_status, User_parameters, Argument );
  9311.             WHEN  Ftp_types.stor_command =>
  9312.                    User_xfer_commands.send_file_user_to_server
  9313.                     ( User_command_status, User_parameters, Argument );
  9314.             WHEN  Ftp_types.retr_command =>
  9315.                   User_xfer_commands.accept_file_server_to_user
  9316.                     ( User_command_status, User_parameters, Argument );
  9317.             WHEN  Others =>
  9318.                 NULL;
  9319.           END CASE;
  9320.         END IF;
  9321.        END LOOP;
  9322.     EXCEPTION
  9323.         WHEN OTHERS =>
  9324.             Ftp_terminal_driver.output_message_with_new_line
  9325.                (" Unknown exeception in Process_User_Command");
  9326.             RAISE;
  9327.    END Process_user_command ;
  9328.   
  9329.    PROCEDURE User_exception_abort 
  9330.         ( User_parameters : IN OUT Ftp_utilities.ftp_parameters_spec ) IS
  9331.     ----------------------------------------------------------------------
  9332.    --
  9333.    -- This procedure issues commands over telnet that will cause a server
  9334.    -- system to be logged out. Any data xfers in progress will be
  9335.    -- iqnored.
  9336.    --
  9337.     ----------------------------------------------------------------------
  9338.    Return_status : FTP_UTILITIES.command_status_spec;
  9339.   
  9340.    BEGIN
  9341.   
  9342.     Ftp_terminal_driver.new_line;
  9343.     Ftp_terminal_driver.output_message_with_new_line
  9344.         (" Exception during command processing ");
  9345.     Ftp_terminal_driver.output_message_with_new_line
  9346.         (" FTP process aborted");
  9347.   
  9348.    User_pi_commands.send_quit_to_server_pi
  9349.                 ( return_status, User_parameters ); -- TELL SERVER TO SHUT DOWN
  9350.   
  9351.    EXCEPTION
  9352.     WHEN OTHERS =>
  9353.         Ftp_terminal_driver.output_message_with_new_line
  9354.             (" Unknown exception in User_Exception_Abort");
  9355.   
  9356.    END User_exception_abort;
  9357.  
  9358. BEGIN
  9359.     -- Process_user_command( User_parameters );        --&KJW
  9360.     TelNet_Server.Connection_Assignments(-1,0,0);    --&KJW
  9361. EXCEPTION
  9362.     WHEN OTHERS =>
  9363.         Ftp_terminal_driver.output_message_with_new_line
  9364.             (" Unknown exception in User_Ftp");
  9365.         User_exception_abort( User_parameters );
  9366. END User_ftp;
  9367.