home *** CD-ROM | disk | FTP | other *** search
/ Programmer's ROM - The Computer Language Library / programmersrom.iso / ada / help / lart.src < prev    next >
Encoding:
Text File  |  1988-05-03  |  31.1 KB  |  1,073 lines

  1. ::::::::::
  2. load_ar_tape.ada
  3. ::::::::::
  4.  
  5. ---------------------------------------------------------------
  6. --        *****************************************          --
  7. --       ***   The Applied Research Laboratory   ***         --
  8. --      ***                 of the                ***        --
  9. --       ***    Pennsylvania State University    ***         --
  10. --        *****************************************          --
  11. ---------------------------------------------------------------
  12. --                                                           -*
  13. -- Author       : A. F. Niessner, Jr.
  14. -- Unit Name    : Load_AR_Tape
  15. -- Document     : ARL Internal Memorandum  87-29
  16. -- Version      : 1.0
  17. -- Release Date : February 9, 1987
  18. -- Last Update  : February 9, 1987
  19. --
  20. -- (c)  Copyright 1987 the Pennsylvania State University
  21. --                                                           -*
  22. ---------------------------------------------------------------
  23.  
  24.  
  25.  
  26. With Text_Io;                   Use Text_Io;
  27. With Dyn;                       Use Dyn;
  28. With AR_Tape_Io;
  29. With AR_Log_Support;
  30. With AR_Directory_Support;
  31. With AR_System_Dependent;
  32. With Current_Exception;
  33.  
  34. Procedure Load_AR_Tape is
  35.  
  36.    Package ti Renames AR_Tape_Io;
  37.    Package ls Renames AR_Log_Support;
  38.    Package ds Renames AR_Directory_Support;
  39.    Package sd Renames AR_System_Dependent;
  40.  
  41.    Done           : Boolean             := False;
  42.    Correct        : Boolean             := True;
  43.    File_Name      : Dyn_String          := D_string ("");
  44.    Fatal_Error    : Exception;
  45.  
  46.  
  47.    Function Restart Return Boolean is
  48.  
  49.       Answer : Character;
  50.  
  51.    Begin  --  function Restart
  52.  
  53.       New_Line (3);
  54.       Put_Line ("   ***   Ada Repository Tape Loading Program   ***");
  55.       New_Line;
  56.       Put_Line ("   ***   Is this a first load Operation or     ***");
  57.       Put_Line ("   ***   is this a restart?                    ***");
  58.       New_Line;
  59.       Put      ("   Enter 'F' for a first load or 'R' for a restart ==> ");
  60.       Loop
  61.          Get (Answer);
  62.          Case Answer is
  63.             When 'f' | 'F' => Put ("irst load");  -- First load
  64.                               New_Line;
  65.                               Return False;
  66.             When 'r' | 'R' => Put ("estart");     -- Restart
  67.                               New_Line;
  68.                               Return True;
  69.             When Others    => Null;
  70.          End Case;
  71.       End Loop;
  72.  
  73.    End Restart;
  74.  
  75.  
  76.    Procedure Load_AR_Directory_File is
  77.  
  78.       Reference_File : Constant Dyn_String
  79.                      := D_String (sd.Directory_Source_File);
  80.  
  81.    Begin  --  procedure Load AR Directory File
  82.  
  83.       While Not Equals (File_Name, Reference_File)
  84.       Loop
  85.          ti.Get_File_Name (File_Name, Done);
  86.          ti.Get_File (ds.Full_Name (File_Name));
  87.          ti.Check_File_Name (File_Name, Correct);
  88.          If Not Correct
  89.          Then ls.Log_Fatal_Error (Str (File_Name));
  90.               Raise Fatal_Error;
  91.          End If;
  92.       End Loop;
  93.  
  94.    End Load_AR_Directory_File;
  95.  
  96.  
  97. Begin   --  procedure Load Ada Repository Tape
  98.  
  99.    ls.Open_Log_File;
  100.  
  101.    If Restart
  102.    Then
  103.       ti.Load_Restart_Tape;
  104.       ds.Build_AR_Directory_Array;
  105.    Else
  106.       ti.Initialize_Tape;
  107.       Load_AR_Directory_File;
  108.       ds.Generate_Directory;
  109.    End If;
  110.  
  111.    Loop
  112.       ti.Get_File_Name (File_Name, Done);
  113.       Exit When Done;
  114.       ti.Get_File (ds.Full_Name (File_Name));
  115.       ti.Check_File_Name (File_Name, Correct);
  116.       If Not Correct
  117.       Then ls.Log_Fatal_Error (Str (File_Name));
  118.            Raise Fatal_Error;
  119.       End If;
  120.    End Loop;
  121.  
  122.    ls.Close_Log_File;
  123.  
  124.    Exception
  125.       When Fatal_Error =>
  126.            Text_Io.New_Line (2);
  127.            Text_Io.Put_Line ("Fatal Error Occured on Tape Read");
  128.            Text_Io.Put_Line ("See the AR log file for the problem file");
  129.            Text_Io.New_Line (2);
  130.            ls.Close_Log_file;
  131.       When Others =>
  132.            Text_Io.New_Line (2);
  133.            Text_Io.Put_Line (Current_Exception.Name);
  134.            Text_Io.New_Line (2);
  135.            ls.Close_Log_File;
  136.  
  137. End Load_AR_Tape;
  138.  
  139. Pragma Main;
  140. ::::::::::
  141. ar_tape_io_sp.ada
  142. ::::::::::
  143.  
  144. With Dyn;                          Use Dyn;
  145.  
  146. Package AR_Tape_Io is
  147.  
  148.    Procedure Initialize_Tape;
  149.  
  150.    Procedure Load_Restart_Tape;
  151.  
  152.    Function Current_Tape_Record Return Natural;
  153.  
  154.    Procedure Get_File_Name (File  : Out Dyn_String;
  155.                             Done  : Out Boolean);
  156.  
  157.    Procedure Get_File (File  : In Dyn_string);
  158.  
  159.    Procedure Check_File_Name (File    : In Dyn_String;
  160.                               Correct : Out Boolean);
  161.  
  162. End AR_Tape_Io;
  163.  
  164. ::::::::::
  165. ar_tape_io_b.ada
  166. ::::::::::
  167.  
  168. With Text_Io;                    Use Text_Io;
  169. With AR_Log_Support;
  170. With AR_System_Dependent;
  171. With Current_Exception;
  172.  
  173. Package Body AR_Tape_Io is
  174.  
  175.  
  176.    Package ls Renames AR_Log_Support;
  177.    Package sd Renames AR_System_Dependent;
  178.       Package N_Io is new Integer_Io (Natural);
  179.  
  180.    Type Tapes is new Natural Range 1..6;
  181.  
  182.    Record_Count : Natural := 0;
  183.    Errors       : Natural := 0;
  184.    Current_Tape : Tapes   := 1;
  185.  
  186.  
  187.    Function Current_Tape_Record Return Natural is
  188.  
  189.    Begin  --  function Current Tape Record
  190.  
  191.       Return Record_Count;
  192.  
  193.    End Current_Tape_Record;
  194.  
  195.  
  196.    Procedure Initialize_Tape is
  197.  
  198.       Answer : Character;
  199.  
  200.    Begin  --  procedure Initialize Tape
  201.  
  202.       New_Line (2);
  203.       Put_Line ("   ***  Mount the starting Ada Repository Tape  ***");
  204.       New_Line;
  205.       Put      ("        Then press any character  ===> ");
  206.       Get (Answer);
  207.       New_Line (2);
  208.       Put_Line ("        Loading the starting Ada Repository Tape.");
  209.       New_Line (2);
  210.  
  211.    End Initialize_Tape;
  212.  
  213.  
  214.    Procedure Load_Restart_Tape is
  215.  
  216.       Starting_Record : Natural := 0;
  217.  
  218.  
  219.       Function Tape_Number Return Tapes is
  220.  
  221.          Header_File  : Text_Io.File_Type;
  222.          Buffer       : String (1..8);
  223.  
  224.       Begin  --  function Tape Number
  225.  
  226.          Open  (Header_File, In_File, sd.Tape_Drive & "0");
  227.          Get   (Header_file, Buffer);
  228.          Close (Header_File);
  229.          ls.Log_Tape_Name (Buffer);
  230.          Return Tapes (Character'Pos (Buffer (8)) - Character'Pos ('0'));
  231.  
  232.       End Tape_Number;
  233.  
  234.  
  235.    Begin  --  procedure Load the Restart Tape
  236.  
  237.       New_Line (2);
  238.       Put ("   What is the starting record number on the tape  ==> ");
  239.       N_Io.Get (Starting_Record);
  240.       New_Line (2);
  241.       Starting_Record := 3 * (Starting_Record / 3);
  242.       Initialize_Tape;
  243.       Current_Tape := Tape_Number;
  244.       Record_Count := Starting_Record;
  245.  
  246.    End Load_Restart_Tape;
  247.  
  248.  
  249.    Procedure Get_Next_Tape (Tape_Available : Out Boolean) is
  250.  
  251.       Answer     : Character := ' ';
  252.       Afirmative : Boolean;
  253.  
  254.    Begin  --  procedure Get Next Tape
  255.  
  256.       New_Line (2);
  257.       Put_Line
  258.       ("   ***  The current Ada Repository tape load is completed.  ***");
  259.       Put_Line
  260.       ("   ***  Please load the next Ada Repository tape.           ***");
  261.       New_Line;
  262.       Put_Line ("   Enter 'y' if a new tape is loaded  -- or --");
  263.       Put      ("   Enter 'n' if all the tapes have been loaded  ===> ");
  264.       Get_Answer:
  265.       Loop
  266.          Get (Answer);
  267.          Case Answer is
  268.             When 'y' | 'Y' => Tape_Available := True;
  269.                               Afirmative     := True;
  270.                               Current_Tape := Current_Tape + 1;
  271.                               Exit Get_Answer;
  272.             When 'n' | 'N' => Tape_Available := False;
  273.                               Afirmative     := False;
  274.                               Exit Get_Answer;
  275.             When Others    => Null;
  276.          End Case;
  277.       End Loop Get_Answer;
  278.       New_Line (2);
  279.       If Afirmative
  280.       Then  --  Give an afirmative response
  281.          Put_Line ("   The tape is now being loaded.");
  282.       Else  --  Give a completion response
  283.          Put_Line ("   The Ada Repository Tape Load is now done.");
  284.       End If;
  285.       New_Line (2);
  286.       Record_Count := 0;
  287.  
  288.    End Get_Next_Tape;
  289.  
  290.  
  291.    Function Extract_Name (x : String) Return Dyn_String is
  292.  
  293.       --| This function extracts the file name from the input
  294.       --| string and converts any dashes in the name to
  295.       --| underscores.  This conversion is necessary since
  296.       --| AOS/VS does not allow dashes in file names.
  297.  
  298.       Space : Constant Dyn_String := D_String (" ");
  299.       Work  : Dyn_String := Right (D_String (x), 5);
  300.  
  301.       Function Dashless (z : Dyn_String) Return Dyn_String is
  302.  
  303.          Dash        : Constant Dyn_string := D_String ("-");
  304.          Under_Score : Constant Character  := '_';
  305.  
  306.          Position    : Integer    := 1;
  307.          x           : Dyn_String := z;
  308.  
  309.       Begin  --  function dashless
  310.  
  311.          While Position > 0
  312.          Loop
  313.             Position := Index (x, Dash, Position);
  314.             If Position > 0
  315.             Then Substitute (x, Position, Under_Score);
  316.             End If;
  317.          End Loop;
  318.          Return x;
  319.  
  320.       End Dashless;
  321.  
  322.  
  323.    Begin  --  function extract name
  324.  
  325.       Return Dashless (Substring (Work, 1, Index (Work, Space, 1) - 1));
  326.  
  327.          --| The substring function removes the characters following
  328.          --| the first space character.
  329.  
  330.    End Extract_Name;
  331.  
  332.  
  333.  
  334.    Procedure Get_File_Name (File  : Out Dyn_String;
  335.                             Done  : Out Boolean) is
  336.  
  337.       Header_File  : Text_Io.File_Type;
  338.  
  339.       Buffer       : Array (1..10) of String (1..80);
  340.       Next         : Natural := 0;
  341.       Another_Tape : Boolean := True;
  342.       Tape_Id      : Array (Tapes) of String (1..14)
  343.                    := ("HDR1ADA1-FILE-",
  344.                        "HDR1ADA2-FILE-",
  345.                        "HDR1ADA3-FILE-",
  346.                        "HDR1ADA4-FILE-",
  347.                        "HDR1ADA5-FILE-",
  348.                        "HDR1ADA6-FILE-");
  349.  
  350.  
  351.    Begin  --  procedure get file name
  352.  
  353.       Done := False;
  354.       Open (Header_File, In_File,
  355.             sd.Tape_Drive & Str (Right (D_String (Record_Count), 2)));
  356.       While not End_of_File (Header_File)
  357.       Loop
  358.          Next := Next + 1;
  359.          Get (Header_file, Buffer (Next));
  360.       End Loop;
  361.       Close (Header_File);
  362.       Record_Count := Record_Count + 1;
  363.  
  364.       If Buffer (1)(1..14) = Tape_Id (Current_Tape)
  365.  
  366.          --| This test is needed to check if the file being read
  367.          --| is the file marking the end of the tape.
  368.  
  369.       Then Get_Next_Tape (Another_Tape);    -- It is the end of tape
  370.            If Another_Tape
  371.            Then Get_File_Name (File, Done);
  372.            Else Done := True;
  373.            End If;
  374.       Else If Next < 3
  375.  
  376.               --| This test checks for the first record on the tape
  377.               --| which has 3 lines and if it is, then the tape name
  378.               --| is read as well as the file name.
  379.  
  380.            Then File := Extract_Name (Buffer (1));
  381.            Else File := Extract_Name (Buffer (2));
  382.                 ls.Log_Tape_Name (Buffer (1)(1..8));
  383.                    --| The tape name is contained in the first
  384.                    --| eight characters of the first record.
  385.            End If;
  386.       End If;
  387.  
  388.    End Get_File_Name;
  389.  
  390.  
  391.    Procedure Get_File (File : In Dyn_String) is
  392.  
  393.  
  394.       Ada_File  : Text_Io.File_Type;
  395.       Source    : Text_Io.File_Type;
  396.  
  397.       Function Data_Line Return String is
  398.  
  399.             --| A line in the tape file is stored as a four character
  400.             --| number giving the length of the line including the
  401.             --| four charcaters for the length.
  402.  
  403.          Blank  : Constant String := " ";
  404.  
  405.          Buffer : String (1..512);   -- used to store a data line
  406.          Last   : Integer;
  407.          Recved : Integer;
  408.          Size   : String (1..4);     -- used to store the line length
  409.  
  410.       Begin  --  function data line
  411.  
  412.          Get (Source, Size);
  413.          If Size (1) > '9'                --| Some lines contain one
  414.          Then Size (1..3) := Size (2..4); --| extra character.  If so
  415.               Get (Source, Size (4));     --| this test pickes up the
  416.          End If;                          --| next number character.
  417.          Last := Int (D_String (Size)) - 4;
  418.          If Last > 0
  419.          Then Get_Line(Source, Buffer (1..Last), Recved);
  420.                  --| Getline is used here since some strange
  421.                  --| characters that abort a get have been
  422.                  --| found in the data.
  423.               Return Buffer (1..Recved);
  424.          Else Return Blank;
  425.          End If;
  426.  
  427.          Exception
  428.             When End_Error => Return Blank;
  429.             When Others    => --| Several files have a series of ^z's
  430.                               --| at the end.  These create a problem
  431.                               --| with the reading of the file.  This
  432.                               --| exception handler notes the error
  433.                               --| and terminates the file load when
  434.                               --| more than three errors are found in
  435.                               --| a file.
  436.                               ls.Log_Get_File_Error (Str (File),
  437.                                                      Current_Exception.Name);
  438.                               Errors := Errors + 1;
  439.                               Return Blank;
  440.  
  441.       End Data_Line;
  442.  
  443.  
  444.    Begin  --  procedure get file
  445.  
  446.       Errors := 0;
  447.       Put      ("Getting   ");
  448.       N_Io.Put (Record_Count - 1, 3);
  449.       Put      ("   ");
  450.       Put_Line (Str (File));
  451.       Open   (Source, In_file,
  452.               sd.Tape_Drive & Str (Right (D_String (Record_Count), 2)));
  453.       Create (Ada_File, Out_File, Str (File));
  454.       While not End_of_File (Source)
  455.       Loop
  456.          Put_Line (Ada_File, Data_Line);
  457.          Exit When Errors > 3;
  458.       End Loop;
  459.       Close (Ada_File);
  460.       Close (Source);
  461.       Record_Count := Record_Count + 1;
  462.  
  463.    End Get_File;
  464.  
  465.  
  466.    Procedure Check_File_Name (File    : In Dyn_String;
  467.                               Correct : Out Boolean) is
  468.  
  469.       Trailer : Text_Io.File_Type;
  470.  
  471.       Buffer  : Array (1..10) of String (1..80);
  472.       Check   : Dyn_String;
  473.       Next    : Natural      := 0;
  474.  
  475.    Begin  --  procedure check file name
  476.  
  477.       Open (Trailer, In_File,
  478.             sd.Tape_Drive & Str (Right (D_String (Record_Count), 2)));
  479.       While not End_of_File (Trailer)
  480.       Loop
  481.          Next := Next + 1;
  482.          Get (Trailer, Buffer (Next));
  483.       End Loop;
  484.       Close (Trailer);
  485.       Record_Count := Record_Count + 1;
  486.       Check := Extract_Name (Buffer (1));
  487.       If Equals (Check, File)
  488.       Then Correct := True;
  489.       Else ls.Log_Check_Error (Str (File), Str (Check));
  490.            Correct := False;
  491.       End If;
  492.  
  493.    End Check_File_Name;
  494.  
  495. End AR_Tape_Io;
  496.  
  497. ::::::::::
  498. ar_directory_support_sp.ada
  499. ::::::::::
  500.  
  501. With Dyn;                           Use Dyn;
  502.  
  503. Package AR_Directory_Support is
  504.  
  505.    Procedure Build_AR_Directory_Array;
  506.  
  507.    Procedure Generate_Directory;
  508.  
  509.    Function Full_Name (Name : In Dyn_String) Return Dyn_String;
  510.  
  511. End AR_Directory_Support;
  512.  
  513. ::::::::::
  514. ar_directory_support_b.ada
  515. ::::::::::
  516.  
  517. With Text_Io;                   Use Text_Io;
  518. With AR_Log_Support;
  519. With AR_System_Dependent;
  520.  
  521. Package Body AR_Directory_Support is
  522.  
  523.    Package ls Renames AR_Log_Support;
  524.    Package sd Renames AR_System_Dependent;
  525.  
  526.    Blank       : Constant Dyn_String  := D_String ("                ");
  527.    Dir_Length  : Constant             := 1024;
  528.  
  529.    Type Directory_Record is
  530.       Record
  531.          Dir  : Dyn_String := Blank;
  532.          File : Dyn_String := Blank;
  533.       End Record;
  534.  
  535.    Type Directory_Pointer is New Natural Range 1..Dir_Length;
  536.  
  537.    Directory_Array   : Array (Directory_Pointer) of Directory_Record;
  538.    Pointer           : Directory_Pointer := 1;
  539.    Dir_Name          : Dyn_string        := Blank;
  540.    Search            : Directory_Pointer := 10;
  541.  
  542.    Start             : Boolean           := True;
  543.    Restart           : Boolean           := False;
  544.  
  545.    Procedure Process (Data : In String) is
  546.  
  547.       Dir_Header  : Constant Dyn_String := D_String ("PD:<ADA.");
  548.       Tab         : Constant Character  := ASCII.ht;
  549.       Colon       : Constant Dyn_String := D_String (":");
  550.  
  551.       Work_String : Dyn_String := D_String (Data);
  552.  
  553.  
  554.       Function Dashless (z : Dyn_String) Return Dyn_String is
  555.  
  556.          Dash        : Constant Dyn_string := D_String ("-");
  557.          Under_Score : Constant Character  := '_';
  558.  
  559.          Position    : Integer    := 1;
  560.          x           : Dyn_String := z;
  561.  
  562.       Begin  --  function dashless
  563.  
  564.          While Position > 0
  565.          Loop
  566.             Position := Index (x, Dash, Position);
  567.             If Position > 0
  568.             Then Substitute (x, Position, Under_Score);
  569.             End If;
  570.          End Loop;
  571.          Return x;
  572.  
  573.       End Dashless;
  574.  
  575.  
  576.    Begin  --  procedure process
  577.  
  578.    If Char (Work_String) /= ' '
  579.    Then
  580.       If Char (Work_String) = Tab  --  it's a file name
  581.       Then Directory_Array (Pointer).File
  582.                            := Dashless (Right (Work_String, 2));
  583.            Directory_Array (Pointer).Dir  := Dir_Name;
  584.            Pointer := Pointer + 1;
  585.       Elsif Str (Substring (Work_String, 1, Length (Dir_Header)))
  586.             = Str (Dir_Header)   --  it's a directory name
  587.       Then Dir_Name := Dashless (Right (Work_String, Length (Dir_Header) + 1));
  588.            Dir_Name := Substring (Dir_Name, 1, Length (Dir_Name) - 1);
  589.            If Not Restart
  590.            Then sd.Make_Directory (sd.Home_Directory & Str (Dir_Name));
  591.            End If;
  592.       Else ls.Log_Directory_Error (Str (Dir_Name), Data);
  593.       End If;
  594.    End If;
  595.  
  596.    End Process;
  597.  
  598.  
  599.    Procedure Build_AR_Directory_Array is
  600.  
  601.    Begin  --  procedure Build AR Directory Array
  602.  
  603.       Restart := True;
  604.       Start   := False;      --| Set so that initial file name
  605.                              --| search in function full_name
  606.                              --| will not be made.
  607.       Search  := Dir_Length  --| Sets the search for a file name
  608.                - Pointer;    --| in function full_name to the
  609.                              --| length of the directory array.
  610.       Generate_Directory;
  611.  
  612.    End Build_AR_Directory_Array;
  613.  
  614.  
  615.    Procedure Generate_Directory is
  616.  
  617.       Header_Lines : Constant := 4;
  618.  
  619.       Source       : Text_Io.File_Type;
  620.       Buffer       : String (1..132);
  621.       Last         : Integer;
  622.  
  623.    Begin  --  procedure Generate Directory
  624.  
  625.       Open (Source, In_File, sd.Directory_Source);
  626.  
  627.       For i in 1..Header_Lines             --| Remove the header
  628.       Loop                                 --| lines from the top
  629.          Get_Line (Source, Buffer, Last);  --| of the Ada.crclst
  630.       End Loop;                            --| file.
  631.  
  632.       While not End_of_File (Source)
  633.       Loop
  634.          Get_Line (Source, Buffer, Last);
  635.          Process  (Buffer (1..Last));
  636.       End Loop;
  637.  
  638.       Close (Source);
  639.       Pointer := 1;
  640.  
  641.    End Generate_Directory;
  642.  
  643.  
  644.    Function Full_Name (Name : In Dyn_String) Return Dyn_String is
  645.  
  646.       Colon : Constant Dyn_String := D_String (":");
  647.  
  648.       Dir   : Dyn_String := Directory_Array (Pointer).Dir & Colon;
  649.       Next  : Dyn_String := Directory_Array (Pointer).File;
  650.  
  651.    Begin  --  function Full Name
  652.  
  653.       Next := Substring (Next, 1, Length (Name));
  654.  
  655.       If Start
  656.  
  657.          --| This code provides the sync between the tape files
  658.          --| and the directory array list of files.
  659.  
  660.       Then If Equals (Name, Next)
  661.            Then Start := False;
  662.                 ls.Log_File_Name (sd.Home_Directory & Str (Dir & Name));
  663.                 Pointer := Pointer + 1;
  664.                 Return D_String (sd.Home_Directory) & Dir & Name;
  665.            Else ls.Log_File_Name (sd.Home_Directory & Str (Name));
  666.                 Return D_String (sd.Home_Directory) & Name;
  667.            End If;
  668.       End If;
  669.  
  670.       If Equals (Name, Next)
  671.       Then ls.Log_File_Name (sd.Home_Directory & Str (Dir & Name));
  672.            Pointer := Pointer + 1;
  673.            Return D_String (sd.Home_Directory) & Dir & Name;
  674.       Else For i in (Pointer + 1)..(Pointer + Search)
  675.            Loop
  676.               Dir  := Directory_Array (i).Dir & Colon;
  677.               Next := Directory_Array (i).File;
  678.               Next := Substring (Next, 1, Length (Name));
  679.               If Equals (Name, Next)
  680.               Then Pointer := i + 1;
  681.                    Search  := 10;
  682.                    ls.Log_File_Name (sd.Home_Directory & Str (Dir & Name));
  683.                    Return D_String (sd.Home_Directory) & Dir & Name;
  684.               End If;
  685.            End Loop;
  686.            ls.Log_File_Name ((sd.Home_Directory & Str (Name)), True);
  687.            Return D_String (sd.Home_Directory) & Name;
  688.        End If;
  689.  
  690.    End Full_Name;
  691.  
  692.  
  693. End AR_Directory_Support;
  694.  
  695. ::::::::::
  696. ar_log_support_sp.ada
  697. ::::::::::
  698.  
  699. Package AR_Log_Support is
  700.  
  701.    Procedure Open_Log_File;
  702.  
  703.    Procedure Log_Tape_Name (Tape : In String);
  704.  
  705.    Procedure Log_File_Name (File  : In String;
  706.                             Check : In Boolean := False);
  707.  
  708.    Procedure Log_Check_Error (File_Name  : In String;
  709.                               Check_Name : In String);
  710.  
  711.    Procedure Log_Get_File_Error (File_Name : In String;
  712.                                  Error     : In String);
  713.  
  714.    Procedure Log_Directory_Error (Directory  : In String;
  715.                                   Error_Line : In String);
  716.  
  717.    Procedure Log_Fatal_Error (File : In String);
  718.  
  719.    Procedure Close_Log_File;
  720.  
  721. End AR_Log_Support;
  722.  
  723.  
  724. ::::::::::
  725. ar_log_support_b.ada
  726. ::::::::::
  727.  
  728. With AR_System_Dependent;
  729. With AR_Tape_Io;
  730. With Calendar;
  731. With Text_Io;                     Use Text_Io;
  732.  
  733. Package Body AR_Log_Support is
  734.  
  735.       Log_File      : Text_Io.File_Type;
  736.  
  737.    Package N_Io is new Text_Io.Integer_Io (Natural);
  738.    Use N_Io;
  739.  
  740.    Package ti Renames AR_Tape_Io;
  741.    Package sd Renames AR_System_Dependent;
  742.  
  743.  
  744.    Procedure Open_Log_File is
  745.  
  746.       Title  : Constant String :=
  747. "               Ada Repository Tape Load Log File";
  748.       Header : Constant String :=
  749. "  File No.  Full Path File Name                           File Check";
  750.  
  751.       Procedure Put_The_Date is
  752.  
  753.          Slash : Constant Character := '/';
  754.  
  755.          Use Calendar;
  756.  
  757.       Begin  --  procedure Put the Data
  758.  
  759.          Put (Log_File, Month (Clock), 2);
  760.          Put (Log_File, Slash);
  761.          Put (Log_File, Day (Clock), 2);
  762.          Put (Log_File, Slash);
  763.          Put (Log_File, Year (Clock) - 1900, 2);
  764.  
  765.       End Put_the_Date;
  766.  
  767.  
  768.    Begin  --  procedure Open Log File
  769.  
  770.       Create   (Log_File, Out_File, sd.Log_File_Name);
  771.       New_Line (Log_File, 2);
  772.       Put_Line (Log_File, Title);
  773.       New_Line (Log_File);
  774.       Put      (Log_File, "                                  Date: ");
  775.       Put_the_Date;
  776.       New_Line (Log_File, 2);
  777.       Put_Line (Log_File, Header);
  778.  
  779.    End Open_Log_File;
  780.  
  781.  
  782.    Procedure Log_Tape_Name (Tape : In String) is
  783.  
  784.    Begin  --  procedure Log Tape Name
  785.  
  786.       New_Line (Log_File);
  787.       Put      (Log_File, "The Tape Name is: ");
  788.       Put_Line (Log_File, Tape);
  789.       New_Line (Log_File);
  790.  
  791.    End Log_Tape_Name;
  792.  
  793.  
  794.    Procedure Log_File_Name (File  : In String;
  795.                             Check : In Boolean := False) is
  796.  
  797.       Number_Size  : Constant         := 9;
  798.       Check_Column : Constant Integer := 60;
  799.       Check_Ident  : Constant String  := "**********";
  800.  
  801.    Begin  --  procedure Log File Name
  802.  
  803.       Put      (Log_File, ti.Current_Tape_Record - 1, Number_Size);
  804.       Put      (Log_File, "    ");
  805.       Put      (Log_File, File);
  806.       If Check
  807.       Then For i in 1..(Check_Column - (Number_Size + 4 + File'Length))
  808.            Loop
  809.               Put (Log_File, " ");
  810.            End Loop;
  811.            Put (Log_File, Check_Ident);
  812.       End If;
  813.       New_Line (Log_File);
  814.  
  815.    End Log_File_Name;
  816.  
  817.  
  818.    Procedure Log_Check_Error (File_Name  : In String;
  819.                               Check_Name : In String) is
  820.  
  821.    Begin  --  procedure Log Check Error
  822.  
  823.       New_Line (Log_File, 2);
  824.       Put      (Log_File, "In Tape Record Number ==> ");
  825.       Put      (Log_File, (ti.Current_Tape_Record - 1), 6);
  826.       New_Line (Log_File);
  827.       Put      (Log_File, "The Check File Name   ==> ");
  828.       Put_Line (Log_File, Check_Name);
  829.       Put      (Log_File, "Did Not Agree With    ==> ");
  830.       Put_Line (Log_File, File_Name);
  831.       New_Line (Log_File, 2);
  832.  
  833.    End Log_Check_Error;
  834.  
  835.  
  836.    Procedure Log_Get_File_Error (File_Name : In String;
  837.                                  Error     : In String) is
  838.  
  839.    Begin  --  procedure Log Get File Error
  840.  
  841.       New_Line (Log_File, 2);
  842.       Put      (Log_File, "The Following Exception was raised during ");
  843.       Put_Line (Log_File, "a Get File");
  844.       Put      (Log_File, "of the file ");
  845.       Put_Line (Log_File, File_Name);
  846.       Put_Line (Log_File, Error);
  847.       Put      (Log_File, "In Tape Record Number ");
  848.       Put      (Log_File, ti.Current_Tape_Record, 6);
  849.       New_Line (Log_File, 3);
  850.  
  851.    End Log_Get_File_Error;
  852.  
  853.  
  854.    Procedure Log_Directory_Error (Directory  : In String;
  855.                                   Error_Line : In String) is
  856.  
  857.    Begin  --  procedure Log Directory Error
  858.  
  859.       New_Line (Log_File, 2);
  860.       Put      (Log_File, "The following incorrect line was read ");
  861.       Put_Line (Log_File, "during Directory Generation");
  862.       Put      (Log_File, "of directory ");
  863.       Put_Line (Log_File, Directory);
  864.       Put_Line (Log_File, Error_Line);
  865.       New_Line (Log_File, 2);
  866.  
  867.    End Log_Directory_Error;
  868.  
  869.  
  870.    Procedure Log_Fatal_Error (File : In String) is
  871.  
  872.    Begin  --  procedure Log Fatal Error
  873.  
  874.       New_Line (Log_File);
  875.       Put      (Log_File, "The AR Tape Load has been halted due to a ");
  876.       Put      (Log_File, "Name Check Error");
  877.       New_Line (Log_File);
  878.       Put      (Log_File, "While loading file ");
  879.       Put_Line (Log_File, File);
  880.       Put      (Log_File, "At Tape Record Number ==> ");
  881.       Put      (Log_File, ti.Current_Tape_Record, 6);
  882.       New_Line (Log_File, 2);
  883.  
  884.    End Log_Fatal_Error;
  885.  
  886.  
  887.    Procedure Close_Log_File is
  888.  
  889.       Ending : Constant String := "End of the Log File data.";
  890.  
  891.    Begin  --  procedure Close Log File
  892.  
  893.       New_Line (Log_File, 3);
  894.       Put_Line (Log_File, Ending);
  895.       New_Line (Log_File, 2);
  896.       Close    (Log_File);
  897.  
  898.    End Close_Log_File;
  899.  
  900.  
  901. End AR_Log_Support;
  902.  
  903. ::::::::::
  904. ar_system_dependent_sp.ada
  905. ::::::::::
  906.  
  907. Package AR_System_Dependent is
  908.  
  909.    Function Log_File_Name Return String;
  910.  
  911.    Function Tape_Drive Return String;
  912.  
  913.    Function Home_Directory Return String;
  914.  
  915.    Function Directory_Source Return String;
  916.  
  917.    Function Directory_Source_File Return String;
  918.  
  919.    Procedure Make_Directory (Directory_Name : In String);
  920.  
  921. End AR_System_Dependent;
  922.  
  923. ::::::::::
  924. ar_system_dependent_b.ada
  925. ::::::::::
  926.  
  927. With Sys_Calls;           --| These packages are used by the
  928. With String_Conversion;   --| procedure Make_Directory.
  929. With Bit_Ops;             --|
  930.  
  931. Package Body AR_System_Dependent is
  932.  
  933.  
  934.    --| The following names should be changed to match the installation
  935.    --| of the Ada Repository on your system.  The functions in this
  936.    --| package return these names to the program when needed.
  937.  
  938.    Log_Name         : Constant String := "AR_Tape_Load.Log";
  939.  
  940.       --| This is the name of the file which will contain the list
  941.       --| of files loaded from the Ada repository tape, the number
  942.       --| of the file on the tape, and the directory in which the
  943.       --| file was written.
  944.  
  945.    Tape_Drive_Name  : Constant String := "@mtb0:";
  946.  
  947.       --| Tape drive is the name system name used to read from the
  948.       --| magnetic tape containing the Ada repository files.
  949.  
  950.    AR_Directory     : Constant String := ":disk2:ada_repository:";
  951.  
  952.       --| AR directory is the pathname to the home directory where
  953.       --| the Ada repository subdirectories will be created.
  954.  
  955.    Directory_File   : Constant String := "ADA.CRCLST";
  956.  
  957.       --| The Ada.Crclst file should not be changed since the directory
  958.       --| extraction procedures in the package AR_Directory_Support
  959.       --| are written for the data as formatted in Ada.Crclst.
  960.       --|
  961.       --| Directory file is the name of the file from the Ada repository
  962.       --| tape that will be used to extract the Ada repository subdirectory
  963.       --| structure.  This file is read from the first Ada repository
  964.       --| tape and used to create the proper subdirectories for storing
  965.       --| the Ada repository files.
  966.  
  967.  
  968.  
  969.    Function Log_File_Name Return String is
  970.    Begin  --  function Log File Name
  971.       Return Log_Name;
  972.    End Log_File_Name;
  973.  
  974.  
  975.    Function Tape_Drive Return String is
  976.    Begin  --  function Tape Drive
  977.       Return Tape_Drive_Name;
  978.    End Tape_Drive;
  979.  
  980.  
  981.    Function Home_Directory Return String is
  982.    Begin  --  function Home Directory
  983.       Return AR_Directory;
  984.    End Home_Directory;
  985.  
  986.  
  987.    Function Directory_Source Return String is
  988.    Begin  --  function Directory Source
  989.       Return AR_Directory & Directory_File;
  990.    End Directory_Source;
  991.  
  992.  
  993.    Function Directory_Source_File Return String is
  994.    Begin  --  function Directory Source File
  995.       Return Directory_File;
  996.    End Directory_Source_File;
  997.  
  998.  
  999.    --| The following procedure has been written to create subdirectories
  1000.    --| for storing the Ada repository data with the same subdirectory
  1001.    --| structure as the Ada Repository on Simtel20.  This procedure is
  1002.    --| system dependent since it uses the Data General AOS/VS System
  1003.    --| calls package.
  1004.  
  1005. Procedure Make_Directory (Directory_Name : In String) is
  1006.  
  1007.    Use String_Conversion;
  1008.    Use Sys_Calls;
  1009.  
  1010.    Record_Format       :Integer  :=  0;  -- These three go
  1011.    Dir_File_Type       :Integer  := 10;  -- towards making
  1012.    Hash_Frame          :Integer  :=  0;  -- up word1
  1013.  
  1014.    Time_Address        :Integer  := -1;  -- word2
  1015.    Access_Control_List :Integer  := -1;  -- word3
  1016.    Control_P_Dir       :Integer  :=  0;  -- word4
  1017.  
  1018.    Max_Index_Level     :Integer  :=  3;  -- These two go
  1019.    Reserved            :Integer  :=  0;  -- towards making
  1020.                                          -- up word5
  1021.  
  1022.    Type Create_Packet is
  1023.       Record
  1024.          Word1 :Integer := Record_Format * 2**24
  1025.                          + Dir_File_Type * 2**16 + Hash_Frame;
  1026.          Word2 :Integer := Time_Address;
  1027.          Word3 :Integer := Access_Control_List;
  1028.          Word4 :Integer := Control_P_Dir;
  1029.          Word5 :Integer := Max_Index_Level * 2**16 + Reserved;
  1030.       End Record;
  1031.  
  1032.    Packet            : Create_Packet;
  1033.    Unchanged         : Integer;
  1034.    Undefined         : Integer;
  1035.    Pathname          : Packed_String(1..40);
  1036.    Address           : Integer;
  1037.    Cerror            : Error_Code;
  1038.  
  1039. Begin  --  procedure Make Directory
  1040.  
  1041.    Pack_String ((Directory_Name & Ascii.Nul), Pathname);
  1042.    Address := Bit_Ops.Left_Shift (Integer (Pathname (1)'Address),1);
  1043.    Sys (Create,
  1044.         In_AC0  => Address,
  1045.         In_AC1  => 0,
  1046.         In_AC2  => Integer (Packet'Address),
  1047.         Out_AC0 => Unchanged,
  1048.         Out_AC1 => Undefined,
  1049.         Out_AC2 => Unchanged,
  1050.         Error   => Cerror);
  1051.  
  1052. End Make_Directory;
  1053.  
  1054.  
  1055. End AR_System_Dependent;
  1056.  
  1057. ::::::::::
  1058. compile_lart.cli
  1059. ::::::::::
  1060.  
  1061. Ada AR_System_Dependent_sp.ada
  1062. Ada AR_Log_Support_sp.ada
  1063. Ada AR_Directory_Support_sp.ada
  1064. Ada AR_Tape_Io_sp.ada
  1065. Ada Load_AR_Tape.ada
  1066. Ada AR_System_Dependent_b.ada
  1067. Ada AR_Log_Support_b.ada
  1068. Ada AR_Directory_Support_b.ada
  1069. Ada AR_Tape_Io_b.ada
  1070. Adalink/mtop=2 Load_AR_Tape
  1071.  
  1072.  
  1073.