home *** CD-ROM | disk | FTP | other *** search
/ Programmer's ROM - The Computer Language Library / programmersrom.iso / ada / cais / cais.src < prev    next >
Encoding:
Text File  |  1988-05-03  |  1.3 MB  |  37,984 lines

Text Truncated. Only the first 1MB is shown below. Download the file for the complete contents.
  1. --::::::::::::::
  2. --CAIS.pro
  3. --::::::::::::::
  4.  
  5. -------- SIMTEL20 Ada Software Repository Prologue ------------
  6. --                                                           -*
  7. -- Unit name    : CAIS
  8. -- Version      : 860307
  9. -- Author       : Mitre Corp.
  10. --              : Rebecca Bowerman    Helen Gill
  11. --              : Chuck Howell        Robbie Hutchison
  12. --              : Mike McClimens
  13. -- DDN Address  : cig-info at mitre
  14. -- Date created : 07 MAR 86
  15. -- Release date : 07 MAR 86
  16. -- Last update  : 07 MAR 86
  17. -- Machine/System Compiled/Run on : Vax 8600
  18. --                                  UNIX
  19. --                                  Verdix Ada Development Sys
  20. --                                                           -*
  21. ---------------------------------------------------------------
  22. --                                                           -*
  23. -- Keywords     :  Tool Interfaces, Portability, Stoneman,
  24. --                 Operating System Calls, Host-Dependencies,
  25. --                 MIL-STD-CAIS, APSE, Programming Support Environment
  26. ----------------:
  27. --
  28. -- Abstract     :  
  29. --         This CAIS package provides a robust subset of the inter-
  30. --    faces defined in the proposed Military Standard Common Apse
  31. --    Interface Set(CAIS).  The goal of MIL-STD-CAIS is to promote
  32. --    tool portability by providing a standardized set of calls for
  33. --    operating system services.  It is also hoped that definition
  34. --    of a generalized node model will increase the interoperability
  35. --    of tool sets.
  36. --         
  37. --         This subset includes:
  38. --             5.1.1,2,3,5 -- Node_Definitions, Node_Management,
  39. --                            Attributes, and Structural_Nodes
  40. --             5.3.1,1-4,10-- Io_Definitions ,Direct_Io, Sequential_Io,
  41. --                            Text_Io, and File_Import_Export (also a 
  42. --                            few procedures from Scroll_Terminal)
  43. --             5.4.1-20,21 -- List_Utilities, Identifier_Items, and
  44. --                            String_Items
  45. --    The interfaces not included are Access_Control, Process_Control,
  46. --    Io_Control, the Io device packages, Float_Item, and Integer_Item.
  47. --
  48. --         It is intended that this CAIS subset be used to investigate
  49. --    the extent to which CAIS supports the needs of software 
  50. --    development tools.  Only by rehosting tools and their data to
  51. --    CAIS can the viability of CAIS be determined.
  52. ----------------:  
  53. --                                                           -*
  54. ------------------ Revision history ---------------------------
  55. --                                                           -*
  56. -- DATE      VERSION AUTHOR        HISTORY
  57. -- 03/07/85  860307  Mitre Corp    Initial Release
  58. --                                                           -*
  59. ------------------ Distribution and Copyright -----------------
  60. --                                                           -*
  61. -- This prologue must be included in all copies of this software.
  62. --
  63. -- This software is released to the Public Domain (note:
  64. --   software released to the Public Domain is not subject
  65. --   to copyright protection).
  66. --
  67. -- Restrictions on use or distribution:  Although there are
  68. --      no current plans to provide maintenance for this CAIS,
  69. --      further modifications are planned. We would appreciate
  70. --      your reporting problems and experiences to:
  71. --              
  72. --                cig-info at mitre    (net address)
  73. --
  74. --      or call at:
  75. --
  76. --                (703)  883-7858
  77. --                                                           -*
  78. ------------------ Disclaimer ---------------------------------
  79. --                                                           -*
  80. -- This software and its documentation are provided "AS IS" and
  81. -- without any expressed or implied warranties whatsoever.
  82. -- No warranties as to performance, merchantability, or fitness
  83. -- for a particular purpose exist.
  84. --
  85. -- Because of the diversity of conditions and hardware under
  86. -- which this software may be used, no warranty of fitness for
  87. -- a particular purpose is offered.  The user is advised to
  88. -- test the software thoroughly before relying on it.  The user
  89. -- must assume the entire risk and liability of using this
  90. -- software.
  91. --
  92. -- In no event shall any person or organization of people be
  93. -- held responsible for any direct, indirect, consequential
  94. -- or inconsequential damages or lost profits.
  95. --                                                           -*
  96. -------------------END-PROLOGUE--------------------------------
  97.  
  98. --::::::::::::::
  99. --cais.pro
  100. --::::::::::::::
  101.  
  102. -------- SIMTEL20 Ada Software Repository Prologue ------------
  103. --                                                           -*
  104. -- Unit name    : CAIS
  105. -- Version      : 860307
  106. -- Author       : Mitre Corp.
  107. --              : Rebecca Bowerman    Helen Gill
  108. --              : Chuck Howell        Robbie Hutchison
  109. --              : Mike McClimens
  110. -- DDN Address  : cig-info at mitre
  111. -- Date created : 07 MAR 86
  112. -- Release date : 07 MAR 86
  113. -- Last update  : 07 MAR 86
  114. -- Machine/System Compiled/Run on : Vax 8600
  115. --                                  UNIX
  116. --                                  Verdix Ada Development Sys
  117. --                                                           -*
  118. ---------------------------------------------------------------
  119. --                                                           -*
  120. -- Keywords     :  Tool Interfaces, Portability, Stoneman,
  121. --                 Operating System Calls, Host-Dependencies,
  122. --                 MIL-STD-CAIS, APSE, Programming Support Environment
  123. ----------------:
  124. --
  125. -- Abstract     :  
  126. --         This CAIS package provides a robust subset of the inter-
  127. --    faces defined in the proposed Military Standard Common Apse
  128. --    Interface Set(CAIS).  The goal of MIL-STD-CAIS is to promote
  129. --    tool portability by providing a standardized set of calls for
  130. --    operating system services.  It is also hoped that definition
  131. --    of a generalized node model will increase the interoperability
  132. --    of tool sets.
  133. --         
  134. --         This subset includes:
  135. --             5.1.1,2,3,5 -- Node_Definitions, Node_Management,
  136. --                            Attributes, and Structural_Nodes
  137. --             5.3.1,1-4,10-- Io_Definitions ,Direct_Io, Sequential_Io,
  138. --                            Text_Io, and File_Import_Export (also a 
  139. --                            few procedures from Scroll_Terminal)
  140. --             5.4.1-20,21 -- List_Utilities, Identifier_Items, and
  141. --                            String_Items
  142. --    The interfaces not included are Access_Control, Process_Control,
  143. --    Io_Control, the Io device packages, Float_Item, and Integer_Item.
  144. --
  145. --         It is intended that this CAIS subset be used to investigate
  146. --    the extent to which CAIS supports the needs of software 
  147. --    development tools.  Only by rehosting tools and their data to
  148. --    CAIS can the viability of CAIS be determined.
  149. ----------------:  
  150. --                                                           -*
  151. ------------------ Revision history ---------------------------
  152. --                                                           -*
  153. -- DATE      VERSION AUTHOR        HISTORY
  154. -- 03/07/85  860307  Mitre Corp    Initial Release
  155. --                                                           -*
  156. ------------------ Distribution and Copyright -----------------
  157. --                                                           -*
  158. -- This prologue must be included in all copies of this software.
  159. --
  160. -- This software is released to the Public Domain (note:
  161. --   software released to the Public Domain is not subject
  162. --   to copyright protection).
  163. --
  164. -- Restrictions on use or distribution:  Although there are
  165. --      no current plans to provide maintenance for this CAIS,
  166. --      further modifications are planned. We would appreciate
  167. --      your reporting problems and experiences to:
  168. --              
  169. --                cig-info at mitre    (net address)
  170. --
  171. --      or call at:
  172. --
  173. --                (703)  883-7858
  174. --                                                           -*
  175. ------------------ Disclaimer ---------------------------------
  176. --                                                           -*
  177. -- This software and its documentation are provided "AS IS" and
  178. -- without any expressed or implied warranties whatsoever.
  179. -- No warranties as to performance, merchantability, or fitness
  180. -- for a particular purpose exist.
  181. --
  182. -- Because of the diversity of conditions and hardware under
  183. -- which this software may be used, no warranty of fitness for
  184. -- a particular purpose is offered.  The user is advised to
  185. -- test the software thoroughly before relying on it.  The user
  186. -- must assume the entire risk and liability of using this
  187. -- software.
  188. --
  189. -- In no event shall any person or organization of people be
  190. -- held responsible for any direct, indirect, consequential
  191. -- or inconsequential damages or lost profits.
  192. --                                                           -*
  193. -------------------END-PROLOGUE--------------------------------
  194.  
  195. --::::::::::::::
  196. --README
  197. --::::::::::::::
  198. 1. Introduction
  199.     This is a brief (very brief!) overview of the MITRE CAIS 
  200.     prototype.  The Simtel20 prologue associated with the source code
  201.     and the file and module prologues associated with the specific
  202.     code portions should be consulted for additional information on
  203.     portions of the source code.
  204.  
  205. 2. Overview Of The Prototype
  206.     The prototype is distributed in 67 Ada files and 8 "C" files.
  207.     The Ada file names (in a compilation order) are:
  208.  
  209.         trace_spec.a
  210.         cset.a
  211.         generic_stack.a
  212.         str_pack-spec.a
  213.         generic_list.a
  214.         trace_body.a
  215.         str_pack-body.a
  216.         cais_spec.a
  217.         test_internals.a
  218.         cais_body.a
  219.         node_internals_body.a
  220.         get_identifier.a
  221.         read_shadow_file.a
  222.         get_parsed_pn.a
  223.         write_shadow_file.a
  224.         create_node.a
  225.         get_next_token.a
  226.         direct_io_definitions_body.a
  227.         sequential_io_definitions_body.a
  228.         node_management_body.a
  229.         copy_tree.a
  230.         copy_node.a
  231.         node_more.a
  232.         delete_node.a
  233.         delete_tree.a
  234.         rename.a
  235.         node_get_next.a
  236.         node_iterate.a
  237.         access_control_body.a
  238.         process_control_body.a
  239.         invoke_process.a
  240.         cais_host_dependent_body.a
  241.         get_userid.a
  242.         get_unique_filename.a
  243.         get_user_prefix.a
  244.         add_user.a
  245.         file_import_export_body.a
  246.         cais_utilities_body.a
  247.         attributes_body.a
  248.         structural_nodes_body.a
  249.         iterator_support_body.a
  250.         magnetic_tape_body.a
  251.         cais_sequential_io_body.a
  252.         cais_direct_io_body.a
  253.         cais_io_definitions_body.a
  254.         io_control_body.a
  255.         page_terminal_body.a
  256.         form_terminal_body.a
  257.         delete_user.a
  258.         node_representation_body.a
  259.         list_utilities_body.a
  260.         parse_list.a
  261.         v_string_body.a
  262.         dump.a
  263.         parse_token.a
  264.         identifier_items.a
  265.         scroll_terminal_body.a
  266.         string_items.a
  267.         cais_text_io_body.a
  268.         text_file_create.a
  269.         text_file_delete.a
  270.         text_file_open.a
  271.         text_file_reset.a
  272.         cais_generics.a
  273.         predef_relationships.a
  274.         set_for_append.a
  275.         text_file_close.a
  276.         
  277.     The "C" files are:
  278.         cbreak.c
  279.         cfile_exists.c
  280.         cget_userid.c
  281.         charget.c
  282.         create_uniq.c
  283.         get_user.c
  284.         setecho.c
  285.         simple_fork.c
  286.  
  287. 3. Installing The Prototype On Unix
  288.  
  289.     There are essentially three steps to installing the CAIS
  290.     Prototype on a UNIX system:
  291.     a) tailoring the file names in Cais_Host_Dependent to 
  292.       reflect your system;
  293.     b) compiling the Ada code (e.g. using VADS,
  294.       a.make -f *.a in a directory with all of the prototype code);
  295.     c) building an archive file for the "C" code
  296.         (the following example assumes that the only .o files in the
  297.          directory are from the cc of the CAIS "C" code; 
  298.          c-code.A should be replaced by your chosen archive name)
  299.         cc -c *.c;
  300.         ar q c-code.A *.o;
  301.         ranlib c-code.A;
  302.         ar t c-code.A;
  303.  
  304.     When linking your Ada program with CAIS code, remember to include
  305.     the archive file (e.g. on VADS,
  306.     a.ld <your_unit> -lm <archive file>; )
  307.  
  308.     Please see section 5 for information on the selection of
  309.     file names for Cais_Host_Dependent.
  310.  
  311. 4. Rehosting On Another System
  312.     
  313.     A rehost of the MITRE CAIS prototype to VMS is being performed
  314.     as one of the aspects of the FY86 IR&D on the CAIS at MITRE.
  315.     The prototype code has been structured to faciliate rehosting.
  316.     All of the dependencies on the underlying OS are isolated in the
  317.     package Cais_Host_Dependent.  A rehost requires that the bodies
  318.     of the routines in this package be implemented for the new host
  319.     OS.  For example, in the current prototype, there are several
  320.     uses of pragma Interface (C,...) in Cais_Host_Dependent.
  321.     Presumably host-dependent routines similar to the UNIX-specific
  322.     C code routines used here will be required for the new host.
  323.  
  324. 5. System Administration For the Prototype
  325.     A. Adding Users
  326.     The parameterless procedure Add_User is in package Cais.
  327.     This procedure will prompt the user for a new userid and
  328.     user prefix.  The userid is the key to the 'User relation
  329.     that will identify the new user; in effect Add_User is
  330.     adding a new 'User relationship to the System_Node.  
  331.  
  332.     The userid is required to be a valid Ada identifier since it
  333.     will be used as a relationship key.  Not all host OS userids
  334.     are valid Ada identifiers, however.  The Cais prototype code
  335.     uses a the routine Cais_Host_Dependent.Get_Userid  to
  336.     determine this key.  In the UNIX version of the prototype,
  337.     a Shell environment variable is used to set this name.
  338.     Typically a CAIS prototype user has in his or her .login
  339.     file something like the following line:
  340.         setenv CAIS_USERID howell
  341.     The name of the environment variable is CAIS_USERID.
  342.  
  343.     The user prefix is the path prefix (including the final
  344.     directory delimiter, e.g. "/usr2/howell/") that is prepended
  345.     to certain prototype-created files for each user. 
  346.  
  347.     B.  Host files
  348.     The host dependent file structure for the prototype involves
  349.     one directory, one unique file, and two files for each user
  350.     of the CAIS.  The host-dependent names for all of these
  351.     files is established in the package Cais_Host_Dependent.
  352.  
  353.     The Cais_Host_Directory is where a number of files will be 
  354.     created (a shadow file is the file created to capture information 
  355.     about a node e.g. attributes and relations).  It is necessary
  356.     that all CAIS users for your system have read, search, and
  357.     write priveledges for this directory.
  358.  
  359.     The Cais_System_Node is the host file that captures much of the
  360.     information of the structure of the prototype.   It is
  361.     written to by the procedure Add_User, and several prototype
  362.     routines read it.  It is necessary that all CAIS users have
  363.     read priveledges for this host file.
  364.  
  365.     Each user will also get two files created in the directory
  366.     specified as the "user prefix" during Add_User.  The Top_Node
  367.     is the file that captures information about the structural
  368.     node that is the top node for each user.  Top_User_Process
  369.     is the file where information about the process node
  370.     representing the user's initial job is captured.
  371.  
  372. --::::::::::::::
  373. --access_control_body.a
  374. --::::::::::::::
  375. with Trace; 
  376. separate(Cais)
  377. package body Access_Control is 
  378.     use Node_Definitions; 
  379.  
  380.  
  381.     procedure Set_Access_Control(Node      : Node_Type; 
  382.                                  Role_Node : Node_Type; 
  383.                                  Grant     : Grant_Value) is 
  384.     begin
  385.         Trace.Assert_Fatal(False, "Set_Access_Control is NOT implemented"); 
  386.     end Set_Access_Control; 
  387.  
  388.     procedure Set_Access_Control(Name      : Name_String; 
  389.                                  Role_Name : Name_String; 
  390.                                  Grant     : Grant_Value) is 
  391.     begin
  392.         Trace.Assert_Fatal(False, "Set_Access_Control is NOT implemented"); 
  393.     end Set_Access_Control; 
  394.  
  395.     function Is_Granted(Object_Node  : Node_Type; 
  396.                         Access_Right : Name_String) return Boolean is 
  397.     begin
  398.         Trace.Assert_Fatal(False, "Is_Granted is NOT implemented"); 
  399.         return False; 
  400.     end Is_Granted; 
  401.  
  402.     function Is_Granted(Object_Name  : Name_String; 
  403.                         Access_Right : Name_String) return Boolean is 
  404.     begin
  405.         Trace.Assert_Fatal(False, "Is_Granted is NOT implemented"); 
  406.         return False; 
  407.     end Is_Granted; 
  408.  
  409.     procedure Adopt(Role_Node : Node_Type; 
  410.                     Role_Key  : Relationship_Key := Latest_Key) is 
  411.     begin
  412.         Trace.Assert_Fatal(False, "Adopt is NOT implemented"); 
  413.     end Adopt; 
  414.  
  415.     procedure Unadopt(Role_Key : Relationship_Key) is 
  416.     begin
  417.         Trace.Assert_Fatal(False, "Unadopt is NOT implemented"); 
  418.     end Unadopt; 
  419.  
  420. end Access_Control; 
  421. --::::::::::::::
  422. --add_user.a
  423. --::::::::::::::
  424.  
  425. ----------------------------------------------------------------------
  426. --                        A D D _ U S E R
  427. --
  428. --
  429. --               CAIS tool to add a user to the CAIS 
  430. --
  431. --
  432. --
  433. --
  434. --                  Ada Software Engineering Group
  435. --                      The MITRE Corporation
  436. --                         McLean, VA 22102
  437. --
  438. --                   Thu Feb 20 00:27:43 EST 1986
  439. --                   
  440. --
  441. --                 (Unclassified and uncopyrighted)
  442. --
  443. ----------------------------------------------------------------------
  444.     -- Add_User will add the following information to the 
  445.     -- SYSTEM_NODE (if the user already is in the SYSTEM_NODE,
  446.     -- Add_User will verify that the old values should be replaced):
  447.         -- the primary relation USER pointing to the user's TOP_NODE
  448.         -- the user prefix for the user (an attribute of USER)
  449.     -- Add_User will then create a .TOP_NODE in the user prefix directory.
  450.     -- Add_User will also create a current process node shadow file.
  451.  
  452.     -- .TOP_NODE contains: 
  453.         -- the JOB primary relation, pointing to the Current_Process node
  454.         -- the PARENT secondary relationship, pointing to SYSTEM_NODE
  455.     -- the Current_Process shadow file contains:
  456.         -- the CURRENT_JOB secondary relationship, => Current_Proc 
  457.         -- the CURRENT_NODE secondary rel, => .TOP_NODE
  458.         -- the CURRENT_USER secondary rel, => .TOP_NODE
  459.         -- the PARENT secondary relationship, pointing to SYSTEM_NODE
  460.         -- the USER secondary rel, => .TOP_NODE
  461.  
  462. with Text_Io; 
  463.  
  464. separate(Cais)
  465. procedure Add_User is 
  466.  
  467.     use Standard.Text_Io; 
  468.     use Node_Definitions; 
  469.     use Node_Representation; 
  470.     use Cais_Host_Dependent; 
  471.     use List_Utilities; 
  472.     use Pragmatics; 
  473.     use Node_Internals; 
  474.     use Cais_Internals_Exceptions; 
  475.     use Cais_Utilities; -- frequently used routines
  476.     use List_Utilities.String_Items; 
  477.  
  478.  
  479.     Attributes         : List_Type; 
  480.     Simple_List        : List_Type; 
  481.     All_Users          : List_Type; 
  482.     User_Count         : List_Utilities.Count; 
  483.     User_Name          : Token_Type; 
  484.     User_Exists        : Boolean := True; 
  485.     Node               : Node_Type; 
  486.     Primary            : Boolean; 
  487.     Userid             : String(1 .. Max_Userid_Length); 
  488.     User_Prefix        : String(1 .. Max_User_Prefix_Length); 
  489.     Dummy_Shadow_File  : String(1 .. Max_Shadow_File_Length); 
  490.     Userid_Length      : Natural; 
  491.     User_Prefix_Length : Natural; 
  492.  
  493.     Valid_Response     : Boolean := False; 
  494.     type Response is (Yes, No); 
  495.     Procede    : Response; 
  496.     List_Users : Response; 
  497.  
  498.     package Yesno is 
  499.         new Enumeration_Io(Response); 
  500.     use Yesno; 
  501.  
  502. begin
  503.     Get_Node : begin
  504.         Set_Shadow_File_Name(Node, Cais_System_Node); 
  505.         Read_Shadow_File(Node); 
  506.  
  507.         while not Valid_Response loop
  508.             Put("List Current CAIS Users? (yes or no):"); 
  509.             Get_Answer1 : begin
  510.                 Get(List_Users); 
  511.                 if List_Users = Yes then 
  512.  
  513.                     Get_A_Relation(Node, "User", All_Users); 
  514.                     User_Count := Length(All_Users); 
  515.                     Put_Line("Number Of Users: " & Integer'Image(Integer(
  516.                         User_Count))); 
  517.                     New_Line; 
  518.                     for I in 1 .. User_Count loop
  519.                         Item_Name(All_Users, I, User_Name); 
  520.                         Put(Identifier_Items.To_Text(User_Name)); 
  521.                         Put(" " & Cais_Host_Dependent.Get_User_Prefix(
  522.                             Identifier_Items.To_Text(User_Name))); 
  523.                         Put_Line(Cais_Host_Dependent.Top_User_Process); 
  524.                     end loop; 
  525.  
  526.                 end if; 
  527.                 Valid_Response := True; 
  528.             exception
  529.                 when Data_Error => 
  530.                     Put_Line(Ascii.Bel & "PLEASE ENTER EITHER YES OR NO ONLY.")
  531.                         ; 
  532.             end Get_Answer1; 
  533.         end loop; 
  534.     Skip_Line(Standard_Input); 
  535.  
  536.     exception
  537.         when No_Such_Shadow_File | No_Such_Relationship => 
  538.             -- USER relation with the specified key was not found
  539.             User_Exists := False; 
  540.     end Get_Node; 
  541.  
  542.     Get_User_Info: begin
  543.         Valid_Response := False; 
  544.  
  545.         Put("Please Enter the New Userid: "); 
  546.         Get_Line(Userid, Userid_Length); 
  547.         Put("Please Enter the New User_Prefix: "); 
  548.         Get_Line(User_Prefix, User_Prefix_Length); 
  549.  
  550.     if User_Exists then
  551.         Get_A_Relationship(Node, "USER", Userid(1 .. Userid_Length), 
  552.         Dummy_Shadow_File, Attributes, Primary); 
  553.     end if;
  554.     exception
  555.         when No_Such_Shadow_File | No_Such_Relationship => 
  556.             -- USER relation with the specified key was not found
  557.             User_Exists := False; 
  558.     end Get_User_Info; 
  559.  
  560.     if User_Exists then 
  561.         while not Valid_Response loop
  562.             Put("User already exists. Replace? (yes or no):"); 
  563.             Get_Answer2 : begin
  564.                 Get(Procede); 
  565.                 if Procede = No then 
  566.                     return; 
  567.                 end if; 
  568.                 Valid_Response := True; 
  569.             exception
  570.                 when Data_Error => 
  571.                     Put_Line(Ascii.Bel & "PLEASE ENTER EITHER YES OR NO ONLY.")
  572.                         ; 
  573.             Skip_Line(Standard_Input); 
  574.             end Get_Answer2; 
  575.         end loop; 
  576.  
  577.     end if; -- User_Exists
  578.  
  579.     Copy(Attributes, Empty_List); 
  580.     String_To_Simple_List(User_Prefix(1 .. User_Prefix_Length), Simple_List); 
  581.     Insert(Attributes, List_Item => Simple_List, Named => "User_Prefix", 
  582.         Position => 0); 
  583.     String_To_Simple_List("STRUCTURAL", Simple_List); 
  584.     Insert(Attributes, List_Item => Simple_List, Named => "Kind", Position => 0)
  585.         ; 
  586.  
  587.     Set_A_Relationship(Node, "USER", Userid(1 .. Userid_Length), Attributes, 
  588.         Primary => True, Shadow_File => User_Prefix(1 .. User_Prefix_Length) & 
  589.         Top_User_Node); 
  590.     Set_Kind(Node, Structural); 
  591.     Write_Shadow_File(Node); 
  592.  
  593.     -- Now we add CAIS shadow files in the user's "CAIS" directory.
  594.     -- First, create the CURRENT_PROCESS node (this is the stopgap
  595.     -- approach for now; a much different approach may be needed when
  596.     -- we support process spawning...)
  597.     Set_Shadow_File_Name(Node, User_Prefix(1 .. User_Prefix_Length) & 
  598.         Top_User_Process); 
  599.     Set_Kind(Node, Process); 
  600.  
  601.     -- "reset" the node relations, then add the appropriate ones
  602.     Set_Node_Relations(Node, Empty_List); 
  603.     Copy(Attributes, Empty_List); 
  604.     String_To_Simple_List("PROCESS", Simple_List); 
  605.     Insert(Attributes, List_Item => Simple_List, Named => "Kind", Position => 0)
  606.         ; 
  607.     Set_A_Relationship(Node => Node, Rel_Name => "CURRENT_JOB", Rel_Key => "", 
  608.         Rel_Attributes => Attributes, Primary => False, Shadow_File => 
  609.         User_Prefix(1 .. User_Prefix_Length) & Top_User_Process); 
  610.         -- NB: The Rel_Key above should be #, and will be changed to
  611.         -- that when this feature is supported. CCH
  612.  
  613.     String_To_Simple_List("STRUCTURAL", Simple_List); 
  614.     Replace(Attributes, List_Item => Simple_List, Named => "Kind"); 
  615.     Set_A_Relationship(Node => Node, Rel_Name => "CURRENT_NODE", Rel_Key => "", 
  616.         Rel_Attributes => Attributes, Primary => False, Shadow_File => 
  617.         User_Prefix(1 .. User_Prefix_Length) & Top_User_Node); 
  618.  
  619.     Set_A_Relationship(Node => Node, Rel_Name => "CURRENT_USER", Rel_Key => "", 
  620.         Rel_Attributes => Attributes, Primary => False, Shadow_File => 
  621.         User_Prefix(1 .. User_Prefix_Length) & Top_User_Node); 
  622.  
  623.     Set_A_Relationship(Node => Node, Rel_Name => "USER", Rel_Key => Userid(1 .. 
  624.         Userid_Length), Rel_Attributes => Attributes, Primary => False, 
  625.         Shadow_File => User_Prefix(1 .. User_Prefix_Length) & Top_User_Node); 
  626.  
  627.     -- Attributes of the Parent relation are the Kind (standard for all
  628.     -- relations), and the primary relationship and key from the parent
  629.     -- node that designates this new node
  630.     Copy(Attributes, Empty_List); 
  631.     Cais_Utilities.String_To_Simple_List("STRUCTURAL", Simple_List); 
  632.     Insert(Attributes, Simple_List, "Kind", 0); 
  633.     Cais_Utilities.String_To_Simple_List("JOB", Simple_List); 
  634.     Insert(Attributes, Simple_List, "Primary_Relation", 0); 
  635.     Cais_Utilities.String_To_Simple_List(Null_Rel_Key, Simple_List); 
  636.     Insert(Attributes, Simple_List, "Primary_Key", 0); 
  637.  
  638.     Set_A_Relationship(Node => Node, Rel_Name => "PARENT", Rel_Key => "", 
  639.         Rel_Attributes => Attributes, Primary => False, Shadow_File => 
  640.         User_Prefix(1 .. User_Prefix_Length) & Top_User_Node); 
  641.  
  642.     Set_Node_Attributes(Node, Empty_List); 
  643.     Write_Shadow_File(Node); 
  644.  
  645.     -- Now to add the shadow file for the TOP_USER_NODE
  646.     Set_Shadow_File_Name(Node, User_Prefix(1 .. User_Prefix_Length) & 
  647.         Top_User_Node); 
  648.     Set_Kind(Node, Structural); 
  649.     Set_Node_Relations(Node, Empty_List); 
  650.  
  651.     String_To_Simple_List("PROCESS", Simple_List); 
  652.     Replace(Attributes, List_Item => Simple_List, Named => "Kind"); 
  653.     Set_A_Relationship(Node => Node, Rel_Name => "JOB", Rel_Key => "", 
  654.         Rel_Attributes => Attributes, Primary => True, Shadow_File => 
  655.         User_Prefix(1 .. User_Prefix_Length) & Top_User_Process); 
  656.  
  657.  
  658.     -- Attributes of the Parent relation are the Kind (standard for all
  659.     -- relations), and the primary relationship and key from the parent
  660.     -- node that designates this new node
  661.     Copy(Attributes, Empty_List); 
  662.     Cais_Utilities.String_To_Simple_List("STRUCTURAL", Simple_List); 
  663.     Insert(Attributes, Simple_List, "Kind", 0); 
  664.     Cais_Utilities.String_To_Simple_List("USER", Simple_List); 
  665.     Insert(Attributes, Simple_List, "Primary_Relation", 0); 
  666.     Cais_Utilities.String_To_Simple_List(Userid(1 .. Userid_Length), Simple_List
  667.         ); 
  668.     Insert(Attributes, Simple_List, "Primary_Key", 0); 
  669.     Set_A_Relationship(Node => Node, Rel_Name => "PARENT", Rel_Key => "", 
  670.         Rel_Attributes => Attributes, Primary => False, Shadow_File => 
  671.         Cais_System_Node); 
  672.     Write_Shadow_File(Node); 
  673.  
  674.     -- Finally, update the user relation of all of the other
  675.     -- users' top_process shadow files
  676.  
  677.     Copy(Attributes, Empty_List); 
  678.     String_To_Simple_List("STRUCTURAL", Simple_List); 
  679.     Insert(Attributes, List_Item => Simple_List, Named => "Kind", Position => 0)
  680.         ; 
  681.     Set_Shadow_File_Name(Node, Cais_System_Node); 
  682.     Read_Shadow_File(Node); 
  683.     Get_A_Relation(Node, "User", All_Users); 
  684.     User_Count := Length(All_Users); 
  685.     for I in 1 .. User_Count loop
  686.         Item_Name(All_Users, I, User_Name); 
  687.         Set_Shadow_File_Name(Node, Cais_Host_Dependent.Get_User_Prefix(
  688.             Identifier_Items.To_Text(User_Name)) & Cais_Host_Dependent.
  689.             Top_User_Process); 
  690.         Read_Shadow_File(Node); 
  691.  
  692.         Set_A_Relationship(Node => Node, Rel_Name => "USER", Rel_Key => Userid(1
  693.             .. Userid_Length), Rel_Attributes => Attributes, Primary => False, 
  694.             Shadow_File => User_Prefix(1 .. User_Prefix_Length) & Top_User_Node)
  695.             ; 
  696.         Write_Shadow_File(Node); 
  697.     end loop; 
  698. end Add_User; 
  699. --::::::::::::::
  700. --attributes_body.a
  701. --::::::::::::::
  702.  
  703. ----------------------------------------------------------------------
  704. --                         ATTRIBUTES
  705. --                       (Package Body)
  706. --
  707. --
  708. --      Package to support the definition and manipulation of
  709. --             attributes for nodes and relationships.
  710. --
  711. --
  712. --
  713. --                  Ada Software Engineering Group
  714. --                      The MITRE Corporation
  715. --                         McLean, VA 22102
  716. --
  717. --
  718. --                   Fri Oct 11 08:41:09 EDT 1985
  719. --
  720. --                 (Unclassified and uncopyrighted)
  721. ----------------------------------------------------------------------
  722. ----------------------------------------------------------------------
  723. --
  724. --  Purpose:
  725. --  --------
  726. --    This  package  supports  the  definition  and  manipulation   of
  727. --    attributes for nodes and relationships in the CAIS.  The name of
  728. --    an attribute follows the syntax of an Ada  identifier  (Ada  LRM
  729. --    2.3).  The value of an attribute is a list of the format defined
  730. --    by the  package  CAIS_list_utilities  (CAIS  1.4  section  5.4).
  731. --    Upper  vs.  lower  case  distinctions are significant within the
  732. --    value of attributes, but not within the attribute name.
  733. --
  734. --  Usage:
  735. --  -----
  736. --    The operations defined  for  the  manipipulation  of  attributes
  737. --    identify  the  node  to  which  an  attribute  belongs either by
  738. --    pathname or open node  handle.   They  identify  a  relationship
  739. --    implicitly  by the last path element of a pathname or explicitly
  740. --    by base node, key and relation name identification.
  741. --
  742. --  Example:
  743. --  -------
  744. --        To_List( "(""17NOV85"")", String_Value);
  745. --        To_List( "(""14APR86"")", New_Value);
  746. --          Create_Node_Attribute(Node, "DATE", String_Value);
  747. --        Set_Node_Attribute   (Node, "DATE", New_Value);
  748. --        Get_Node_Attribute   (Node, "DATE", String_Value);
  749. --        Delete_Node_Attribute(Node, "DATE");
  750. --
  751. --        Node_Attribute_Iterate(Node, Iterator, "D*");
  752. --        while More(Iterator) loop
  753. --            Get_Next(Iterator, Attribute, Value);
  754. --        end loop;
  755. --
  756. --  Notes:
  757. --  -----
  758. --    This is a version of the package CAIS_ATTRIBUTES,  specified  in
  759. --    MIL-STD-CAIS section 5.1.3; all references to the CAIS specification
  760. --    refer to the MIL-STD-CAIS specification dated 31 January 1985.
  761. --
  762. --  Revision History:
  763. --  ----------------
  764. --    12-04-85    Removed reference to V_String which is now hidden in
  765. --            List_Utilities.  We now access To_Text(xx)'length
  766. -------------------------------------------------------------------
  767.  
  768. separate(Cais)
  769. package body Attributes is 
  770.  
  771.     use List_Utilities; 
  772.     use Cais_Utilities; 
  773.     use Node_Definitions; 
  774.     use Node_Representation; 
  775.     use Node_Management; 
  776.     use Iterator_Support; 
  777.     use Identifier_Items; 
  778. ----------------------   Initialize_Iterator   ---------------------------
  779. --
  780. --  Purpose: This procedure allocates a new list for an allocator and sets
  781. --  -------  it to the Empty_List.  Position is set to zero.
  782. --
  783. --  Parameters:
  784. --  ----------
  785. --    Iterator      is the Attribute_Iterator to be itinialized
  786. --
  787. --  Exceptions:
  788. --  ----------
  789. --   None
  790. --
  791. --  Notes:
  792. --  -----
  793. --
  794. ---------------------------------------------------------------------------
  795.     procedure Initialize_Iterator(Iterator : in out Attribute_Iterator) is 
  796.     begin
  797.         Iterator.List := new List_Type; 
  798.         Iterator.Position := 0; 
  799.         Copy(Iterator.List.all, Empty_List); 
  800.     end Initialize_Iterator; 
  801. ----------------------   Check_For_Open_Node   ---------------------------
  802. --
  803. --  Purpose: This procedure checks that a Node is indeed open
  804. --  -------  
  805. --
  806. --  Parameters:
  807. --  ----------
  808. --    Node      is the Node to be accessed
  809. --
  810. --  Exceptions:
  811. --  ----------
  812. --   STATUS-ERROR       is raised if the node handle is not open
  813. --
  814. --
  815. --  Notes:
  816. --  -----
  817. --
  818. ---------------------------------------------------------------------------
  819.     procedure Check_For_Open_Node(Node : in Node_Type) is 
  820.     begin
  821.         if not Is_Open(Node) then 
  822.             raise Status_Error; 
  823.         end if; 
  824.     end Check_For_Open_Node; 
  825.  
  826.  
  827. ----------------------   Validity_Check     ---------------------------------
  828. --
  829. --  Purpose: This procedure checks for valid availability of an attribute.
  830. --  -------  It assures that the node is open with the proper intention and
  831. --         that the attribute name is not one of those predefined.
  832. --
  833. --  Parameters:
  834. --  ----------
  835. --    Node      is the Node to be accessed
  836. --    Intended  is the intent required by the callin routine
  837. --    Attribute is the name of the attribute to be accessed
  838. --
  839. --  Exceptions:
  840. --  ----------
  841. --   USE_ERROR          is raised if the node already has an attribute of the
  842. --                given name or if the name given is syntactically
  843. --                      illegal or is the name of a predefined node attribute.
  844. --
  845. --   STATUS-ERROR       is raised if the node handle is not open
  846. --
  847. --   INTENT_VIOLATION   is raised if NODE was not opened with the rights as
  848. --            requested by the parameter intended.
  849. --
  850. --
  851. --
  852. --  Notes:
  853. --  -----
  854. --
  855. ---------------------------------------------------------------------------
  856.     procedure Validity_Check(Node      : in Node_Type; 
  857.                              Intended  : in Intent_Specification; 
  858.                              Attribute : in Attribute_Name) is 
  859.  
  860.     begin
  861.         Check_For_Open_Node(Node);              --Status_Error check
  862.         Check_Intentions(Node, Intended);       --Intent check
  863.         if Predefined(Attribute, Cais_Utilities.Attribute) then 
  864.             raise Use_Error; 
  865.                           -- Use_Error if predefined
  866.         end if; 
  867.     end Validity_Check; 
  868.  
  869. ----------------------   Create_Node_Attribute ----------------------
  870. --
  871. --  Purpose: This procedure creates an attribute named by ATTRIBUTE of
  872. --  -------  of the node identified by the open node handle NODE and sets
  873. --           its initial value to VALUE.
  874. --
  875. --  Parameters:
  876. --  ----------
  877. --    Node       is the open node handle being modified
  878. --    Attribute  is the name of the attribute being added to this node
  879. --    Value      is the initial value of the attribute
  880. --
  881. --  Exceptions:
  882. --  ----------
  883. --   USE_ERROR          is raised if the node already has an attribute of the
  884. --                given name or if the name given is syntactically
  885. --                      illegal or is the name of a predefined node attribute.
  886. --
  887. --   STATUS-ERROR       is raised if the node handle is not open
  888. --
  889. --   INTENT_VIOLATION   is raised if NODE was not opened with the right to
  890. --            append attributes.
  891. --
  892. --   SECURITY_VIOLATION is raised if the operation represents a violation of
  893. --            mandatory access controls.  Raised only if no other
  894. --            exceptions apply.
  895. --
  896. --  Notes: MIL-STD CAIS 5.1.3.1
  897. --  -----
  898. --
  899. ---------------------------------------------------------------------
  900.     -- CAIS 5.1.3.1
  901.     procedure Create_Node_Attribute(  -- create attribute, set initial value
  902.                                     Node      : in out Node_Type; 
  903.                                       -- open node handle for desired node
  904.                                     Attribute : Attribute_Name; 
  905.                                       -- name of the attribute
  906.                                     Value     : List_Type) is 
  907.                                       -- initial value of the attribute
  908.         Top_Of_List    : Count := 0; 
  909.         Attribute_List : List_Type; 
  910.  
  911.     begin
  912.         Validity_Check(Node, Append_Attributes, Attribute); 
  913.         Get_Node_Attributes(Node, Attribute_List); 
  914.         Insert(Attribute_List, Value, Attribute, Top_Of_List);  --Use_Error is
  915.                                                                 --raised when
  916.                                                                 --appropriate
  917.         Set_Node_Attributes(Node, Attribute_List); 
  918.     end Create_Node_Attribute; 
  919.  
  920. -----------------------------------------------------------------------------
  921. --             ALTERNATE INTERFACE via NAME_STRING for Relationship        --
  922. -----------------------------------------------------------------------------
  923.     procedure Create_Node_Attribute(  -- create attribute, set initial value
  924.                                     Name      : Name_String; 
  925.                                    -- open node handle for desired node
  926.                                     Attribute : Attribute_Name; 
  927.                                       -- name of the attribute
  928.                                     Value     : List_Type) is 
  929.                                       -- initial value of the attribute
  930.         Node : Node_Type; 
  931.  
  932.     begin
  933.         Open(Node, Name, (1 => Append_Attributes)); 
  934.         Create_Node_Attribute(Node, Attribute, Value); 
  935.         Close(Node); 
  936.     exception
  937.         when others => 
  938.             Close(Node); 
  939.             raise; 
  940.     end Create_Node_Attribute; 
  941.  
  942.  
  943.  
  944.  
  945. ----------------------  Create_Path_Attribute  ----------------------
  946. --
  947. --  Purpose: This procedure creates an attribnute named by ATTRIBUTE of
  948. --  -------  of a relationship and sets its initial value to VALUE.  The 
  949. --         relationship is defined by the base node defined by the open
  950. --         node handle BASE, the relation name RELATION, and the
  951. --         relationship key KEY.
  952. --
  953. --  Parameters:
  954. --  ----------
  955. --    Base       is the open node handle of the base node
  956. --    Key       is the relationship key of the affected relationship
  957. --    Relation   is the relation name of the affected relationship
  958. --    Attribute  is the name of the attribute added to this relationship
  959. --    Value      is the initial value of the attribute
  960. --
  961. --  Exceptions:
  962. --  ----------
  963. --   NAME_ERROR        is raised if the relationship identified by BASE, KEY,
  964. --            and RELATION does not exist
  965. --
  966. --   USE_ERROR          is raised if the relationship already has an attribute
  967. --            of the given name or if the name given is syntactically
  968. --                      illegal or is the name of a predefined node attribute
  969. --            that cant be modified by the user. Use_Error is also
  970. --            raised if RELATION is the name of a predefined relation
  971. --            that can't be modified by the user.
  972. --
  973. --   STATUS-ERROR       is raised if the node handle BASE is not open
  974. --
  975. --   INTENT_VIOLATION   is raised if BASE was not opened with the right to
  976. --            write relationships.
  977. --
  978. --   SECURITY_VIOLATION is raised if the operation represents a violation of
  979. --            mandatory access controls.  Raised only if no other
  980. --            exceptions apply.
  981. --
  982. --  Notes: MIL-STD CAIS 5.1.3.2
  983. --  -----
  984. --
  985. ---------------------------------------------------------------------
  986.  
  987.     -- CAIS 5.1.3.2
  988.     procedure Create_Path_Attribute(    -- Create an attribute
  989.                                     Base      : in out Node_Type; 
  990.                                      -- open node handle from which 
  991.                                      -- the relationship emanates
  992.                                     Key       : Relationship_Key; 
  993.                                      -- key of affected relationship
  994.                                     Relation  : Relation_Name := 
  995.                                         Default_Relation; 
  996.                                      -- name of affected relationship
  997.                                     Attribute : Attribute_Name; 
  998.                                      -- name of created attribute
  999.                                     Value     : List_Type) is 
  1000.                                      -- initial value of the attribute
  1001.         Attribute_List : List_Type; 
  1002.         Top_Of_List    : constant Count := 0; 
  1003.         Primary_Flag   : Boolean; 
  1004.                                  --Returned by Get_A_Relationship and used by
  1005.         Shadow_File    : String(1 .. Pragmatics.Max_Shadow_File_Length); 
  1006.                                                                      --*****:
  1007.                                                          --Set_A_Relationship
  1008.  
  1009.     begin
  1010.         Validity_Check(Base, Write_Relationships, Attribute); 
  1011.         Get_A_Relationship(Base, Relation, Key, Shadow_File, Attribute_List, 
  1012.                                                         --Triggers
  1013.         Primary_Flag);                                  --Name_Error
  1014.         Insert(Attribute_List, Value, Attribute, Top_Of_List);  --Use_Error is
  1015.                                                                 --raised when
  1016.                                                                 --appropriate
  1017.         Set_A_Relationship(Base, Relation, Key, Attribute_List, Primary_Flag, 
  1018.             Shadow_File); 
  1019.     exception
  1020.         when Cais_Internals_Exceptions.No_Such_Relationship | 
  1021.             Cais_Internals_Exceptions.No_Such_Relation => 
  1022.             raise Name_Error; 
  1023.     end Create_Path_Attribute; 
  1024.  
  1025. -----------------------------------------------------------------------------
  1026. --             ALTERNATE INTERFACE via NAME_STRING for NODE                --
  1027. -----------------------------------------------------------------------------
  1028.     procedure Create_Path_Attribute(    -- Create an attribute
  1029.                                     Name      : Name_String; 
  1030.                                   -- name of affected relationship
  1031.                                     Attribute : Attribute_Name; 
  1032.                                      -- name of created attribute
  1033.                                     Value     : List_Type) is 
  1034.                                      -- initial value of the attribute
  1035.         Base : Node_Type; 
  1036.  
  1037.     begin
  1038.         Open(Base, Base_Path(Name), (1 => Write_Relationships)); 
  1039.         Create_Path_Attribute(Base, Last_Key(Name), Last_Relation(Name), 
  1040.             Attribute, Value); 
  1041.         Close(Base); 
  1042.     exception
  1043.         when others => 
  1044.             Close(Base); 
  1045.             raise; 
  1046.     end Create_Path_Attribute; 
  1047.  
  1048. ----------------------  Delete_Node_Attribute  ----------------------
  1049. --
  1050. --  Purpose: This procedure deletes an attribute named by ATTRIBUTE of
  1051. --  -------  of the node identified by the open node handle NODE.
  1052. --
  1053. --  Parameters:
  1054. --  ----------
  1055. --    Node       is the open node handle being modified
  1056. --    Attribute  is the name of the attribute being added to this node
  1057. --
  1058. --  Exceptions:
  1059. --  ----------
  1060. --   USE_ERROR          is raised if the node does not have an attribute of the
  1061. --                given name (or if the name given is syntactically
  1062. --                      illegal??) or is the name of a predefined node attribute
  1063. --            which can't be modified by the user.
  1064. --
  1065. --   STATUS-ERROR       is raised if the node handle is not open
  1066. --
  1067. --   INTENT_VIOLATION   is raised if NODE was not opened with the right to
  1068. --            write attributes.
  1069. --
  1070. --   SECURITY_VIOLATION is raised if the operation represents a violation of
  1071. --            mandatory access controls.  Raised only if no other
  1072. --            exceptions apply.
  1073. --
  1074. --  Notes: MIL-STD CAIS 5.1.3.3
  1075. --  -----
  1076. --
  1077. ---------------------------------------------------------------------
  1078.     -- CAIS 5.1.3.3
  1079.     procedure Delete_Node_Attribute(   -- Delete an attribute
  1080.                                     Node      : in out Node_Type; 
  1081.                                        -- open node handle for desired node
  1082.                                     Attribute : Attribute_Name) is 
  1083.                                        -- name of the attribute to be deleted
  1084.         Attribute_List : List_Type; 
  1085.  
  1086.     begin
  1087.         Validity_Check(Node, Write_Attributes, Attribute); 
  1088.         Get_Node_Attributes(Node, Attribute_List); 
  1089.  
  1090.         begin                                           --Raise Use_Error when
  1091.             Delete(Attribute_List, Attribute);          --Search_Error shows
  1092.         exception                                       --attribute doesn't
  1093.             when Search_Error =>                        --exist.
  1094.                 raise Use_Error; 
  1095.         end; 
  1096.  
  1097.         Set_Node_Attributes(Node, Attribute_List); 
  1098.     end Delete_Node_Attribute; 
  1099.  
  1100. -----------------------------------------------------------------------------
  1101. --             ALTERNATE INTERFACE via NAME_STRING for NODE                --
  1102. -----------------------------------------------------------------------------
  1103.     procedure Delete_Node_Attribute(  -- delete attribute
  1104.                                     Name      : Name_String; 
  1105.                                       -- open node handle for desired node
  1106.                                     Attribute : Attribute_Name) is 
  1107.                                       -- name of the attribute
  1108.         Node : Node_Type; 
  1109.  
  1110.     begin
  1111.         Open(Node, Name, (1 => Write_Attributes)); 
  1112.         Delete_Node_Attribute(Node, Attribute); 
  1113.         Close(Node); 
  1114.     exception
  1115.         when others => 
  1116.             Close(Node); 
  1117.             raise; 
  1118.     end Delete_Node_Attribute; 
  1119. ----------------------  Delete_Path_Attribute  ----------------------
  1120. --
  1121. --  Purpose: This procedure creates an attribnute named by ATTRIBUTE of
  1122. --  -------  of a relationship and sets its initial value to VALUE.  The 
  1123. --         relationship is defined by the base node defined by the open
  1124. --         node handle BASE, the relation name RELATION, and the
  1125. --         relationship key KEY.
  1126. --
  1127. --  Parameters:
  1128. --  ----------
  1129. --    Base       is the open node handle of the base node
  1130. --    Key       is the relationship key of the affected relationship
  1131. --    Relation   is the relation name of the affected relationship
  1132. --    Attribute  is the name of the attribute added to this relationship
  1133. --    Value      is the initial value of the attribute
  1134. --
  1135. --  Exceptions:
  1136. --  ----------
  1137. --   NAME_ERROR        is raised if the relationship identified by BASE, KEY,
  1138. --            and RELATION does not exist
  1139. --
  1140. --   USE_ERROR          is raised if the relationship already has an attribute
  1141. --            of the given name or if the name given is syntactically
  1142. --                      illegal or is the name of a predefined node attribute
  1143. --            that cant be modified by the user. Use_Error is also
  1144. --            raised if RELATION is the name of a predefined relation
  1145. --            that can't be modified by the user.
  1146. --
  1147. --   STATUS-ERROR       is raised if the node handle BASE is not open
  1148. --
  1149. --   INTENT_VIOLATION   is raised if BASE was not opened with the right to
  1150. --            write relationships.
  1151. --
  1152. --   SECURITY_VIOLATION is raised if the operation represents a violation of
  1153. --            mandatory access controls.  Raised only if no other
  1154. --            exceptions apply.
  1155. --
  1156. --  Notes: MIL-STD CAIS 5.1.3.4
  1157. --  -----
  1158. --
  1159. ---------------------------------------------------------------------
  1160.     -- CAIS 5.1.3.4
  1161.     procedure Delete_Path_Attribute(    -- delete an attribute
  1162.                                     Base      : in out Node_Type; 
  1163.                                         -- open node handle from which 
  1164.                                         -- the relationship emanates
  1165.                                     Key       : Relationship_Key; 
  1166.                                         -- key of affected relationship
  1167.                                     Relation  : Relation_Name := 
  1168.                                         Default_Relation; 
  1169.                                         -- name of affected relationship
  1170.                                     Attribute : Attribute_Name) is 
  1171.                                         -- name of created attribute
  1172.         Attribute_List : List_Type; 
  1173.         Primary_Flag   : Boolean; 
  1174.                                  --Returned by Get_A_Relationship and used by
  1175.         Shadow_File    : String(1 .. Pragmatics.Max_Shadow_File_Length); 
  1176.                                                                      --*****:
  1177.                                                          --Set_A_Relationship
  1178.  
  1179.     begin
  1180.         Validity_Check(Base, Write_Relationships, Attribute); 
  1181.         Get_A_Relationship(Base, Relation, Key, Shadow_File, Attribute_List, 
  1182.                                                         --Triggers
  1183.         Primary_Flag);                                  --Name_Error
  1184.  
  1185.         begin                                           --Raise Use_Error when
  1186.             Delete(Attribute_List, Attribute);          --Search_Error shows
  1187.         exception                                       --attribute doesn't
  1188.             when Search_Error =>                        --exist.
  1189.                 raise Use_Error; 
  1190.         end; 
  1191.  
  1192.         Set_A_Relationship(Base, Relation, Key, Attribute_List, Primary_Flag, 
  1193.             Shadow_File); 
  1194.     exception
  1195.         when Cais_Internals_Exceptions.No_Such_Relationship | 
  1196.             Cais_Internals_Exceptions.No_Such_Relation => 
  1197.             raise Name_Error; 
  1198.     end Delete_Path_Attribute; 
  1199.  
  1200. -----------------------------------------------------------------------------
  1201. --             ALTERNATE INTERFACE via NAME_STRING for Relationship        --
  1202. -----------------------------------------------------------------------------
  1203.     procedure Delete_Path_Attribute(    -- Delete an attribute
  1204.                                     Name      : Name_String; 
  1205.                                                 -- Node name
  1206.                                     Attribute : Attribute_Name) is 
  1207.                                         -- name of created attribute
  1208.         Base : Node_Type; 
  1209.  
  1210.     begin
  1211.         Open(Base, Base_Path(Name), (1 => Write_Relationships)); 
  1212.         Delete_Path_Attribute(Base, Last_Key(Name), Last_Relation(Name), 
  1213.             Attribute); 
  1214.         Close(Base); 
  1215.     exception
  1216.         when others => 
  1217.             Close(Base); 
  1218.             raise; 
  1219.     end Delete_Path_Attribute; 
  1220. ----------------------SET_NODE_ATTRIBUTE-----------------------------
  1221. --
  1222. --  Purpose: This procedure deletes an attribute named by ATTRIBUTE of
  1223. --  -------  of the node identified by the open node handle NODE.
  1224. --
  1225. --  Parameters:
  1226. --  ----------
  1227. --    Node       is the open node handle being modified
  1228. --    Attribute  is the name of the attribute being added to this node
  1229. --
  1230. --  Exceptions:
  1231. --  ----------
  1232. --   USE_ERROR          is raised if the node does not have an attribute of the
  1233. --                given name (or if the name given is syntactically
  1234. --                      illegal??) or is the name of a predefined node attribute
  1235. --            which can't be modified by the user.
  1236. --
  1237. --   STATUS-ERROR       is raised if the node handle is not open
  1238. --
  1239. --   INTENT_VIOLATION   is raised if NODE was not opened with the right to
  1240. --            write attributes.
  1241. --
  1242. --   SECURITY_VIOLATION is raised if the operation represents a violation of
  1243. --            mandatory access controls.  Raised only if no other
  1244. --            exceptions apply.
  1245. --
  1246. --  Notes: MIL-STD CAIS 5.1.3.5
  1247. --  -----
  1248. --
  1249. ---------------------------------------------------------------------
  1250.     -- CAIS 5.1.3.5
  1251.     procedure Set_Node_Attribute(      -- Set the value of existing attribute
  1252.                                  Node      : in out Node_Type; 
  1253.                                          -- open node handle 
  1254.                                  Attribute : Attribute_Name; 
  1255.                                          -- name of attribute to be set
  1256.                                  Value     : List_Type) is 
  1257.                                          -- new value of attribute
  1258.         Attribute_List : List_Type; 
  1259.     begin
  1260.         Validity_Check(Node, Write_Attributes, Attribute); 
  1261.         Get_Node_Attributes(Node, Attribute_List); 
  1262.  
  1263.         begin                                           --Raise Use_Error when
  1264.             Replace(Attribute_List, Value, Attribute);  --Search_Error shows
  1265.         exception                                       --attribute doesn't
  1266.             when Search_Error =>                        --exist.
  1267.                 raise Use_Error; 
  1268.         end; 
  1269.  
  1270.         Set_Node_Attributes(Node, Attribute_List); 
  1271.     end Set_Node_Attribute; 
  1272.  
  1273. -----------------------------------------------------------------------------
  1274. --             ALTERNATE INTERFACE via NAME_STRING for NODE                --
  1275. -----------------------------------------------------------------------------
  1276.     procedure Set_Node_Attribute(  -- set the value of a node attribute
  1277.                                  Name      : Name_String; 
  1278.                                         -- Node name
  1279.                                  Attribute : Attribute_Name; 
  1280.                                         -- name of the attribute
  1281.                                  Value     : List_Type) is 
  1282.                                         -- initial value of the attribute
  1283.         Node : Node_Type; 
  1284.  
  1285.     begin
  1286.         Open(Node, Name, (1 => Write_Attributes)); 
  1287.         Set_Node_Attribute(Node, Attribute, Value); 
  1288.         Close(Node); 
  1289.     exception
  1290.         when others => 
  1291.             Close(Node); 
  1292.             raise; 
  1293.     end Set_Node_Attribute; 
  1294. ----------------------    Set_Path_Attribute   ----------------------
  1295. --
  1296. --  Purpose: This procedure creates an attribnute named by ATTRIBUTE of
  1297. --  -------  of a relationship and sets its initial value to VALUE.  The 
  1298. --         relationship is defined by the base node defined by the open
  1299. --         node handle BASE, the relation name RELATION, and the
  1300. --         relationship key KEY.
  1301. --
  1302. --  Parameters:
  1303. --  ----------
  1304. --    Base       is the open node handle of the base node
  1305. --    Key       is the relationship key of the affected relationship
  1306. --    Relation   is the relation name of the affected relationship
  1307. --    Attribute  is the name of the attribute added to this relationship
  1308. --    Value      is the initial value of the attribute
  1309. --
  1310. --  Exceptions:
  1311. --  ----------
  1312. --   NAME_ERROR        is raised if the relationship identified by BASE, KEY,
  1313. --            and RELATION does not exist
  1314. --
  1315. --   USE_ERROR          is raised if the relationship already has an attribute
  1316. --            of the given name or if the name given is syntactically
  1317. --                      illegal or is the name of a predefined node attribute
  1318. --            that cant be modified by the user. Use_Error is also
  1319. --            raised if RELATION is the name of a predefined relation
  1320. --            that can't be modified by the user.
  1321. --
  1322. --   STATUS-ERROR       is raised if the node handle BASE is not open
  1323. --
  1324. --   INTENT_VIOLATION   is raised if NODE was not opened with the right to
  1325. --            write relationships.
  1326. --
  1327. --   SECURITY_VIOLATION is raised if the operation represents a violation of
  1328. --            mandatory access controls.  Raised only if no other
  1329. --            exceptions apply.
  1330. --
  1331. --  Notes: MIL-STD CAIS 5.1.3.6
  1332. --  -----
  1333. --
  1334. ---------------------------------------------------------------------
  1335.  
  1336.     -- CAIS 5.1.3.6
  1337.     procedure Set_Path_Attribute(    -- Set the value of an existing attribute
  1338.                                  Base      : in out Node_Type; 
  1339.                                         -- open node handle from which 
  1340.                                         -- the relationship emanates
  1341.                                  Key       : Relationship_Key; 
  1342.                                         -- key of affected relationship
  1343.                                  Relation  : Relation_Name := Default_Relation; 
  1344.                                         -- name of affected relationship
  1345.                                  Attribute : Attribute_Name; 
  1346.                                         -- name of created attribute
  1347.                                  Value     : List_Type) is 
  1348.                                         -- new value of attribute
  1349.         Attribute_List : List_Type; 
  1350.         Primary_Flag   : Boolean; 
  1351.                                  --Returned by Get_A_Relationship and used by
  1352.         Shadow_File    : String(1 .. Pragmatics.Max_Shadow_File_Length); 
  1353.                                                                      --*****:
  1354.                                                          --Set_A_Relationship
  1355.     begin
  1356.         Validity_Check(Base, Write_Relationships, Attribute); 
  1357.         Get_A_Relationship(Base, Relation, Key, Shadow_File, Attribute_List, 
  1358.                                                         --Triggers
  1359.         Primary_Flag);                                  --Name_Error
  1360.  
  1361.         begin                                           --Raise Use_Error when
  1362.             Replace(Attribute_List, Value, Attribute);  --Search_Error shows
  1363.         exception                                       --attribute doesn't
  1364.             when Search_Error =>                        --exist.
  1365.                 raise Use_Error; 
  1366.         end; 
  1367.  
  1368.         Set_A_Relationship(Base, Relation, Key, Attribute_List, Primary_Flag, 
  1369.             Shadow_File); 
  1370.     exception
  1371.         when Cais_Internals_Exceptions.No_Such_Relationship | 
  1372.             Cais_Internals_Exceptions.No_Such_Relation => 
  1373.             raise Name_Error; 
  1374.     end Set_Path_Attribute; 
  1375.  
  1376. -----------------------------------------------------------------------------
  1377. --             ALTERNATE INTERFACE via NAME_STRING for NODE                --
  1378. -----------------------------------------------------------------------------
  1379.     procedure Set_Path_Attribute(    -- Set the value of a path attribute
  1380.                                  Name      : Name_String; 
  1381.                                      -- name of affected relationship
  1382.                                  Attribute : Attribute_Name; 
  1383.                                      -- name of created attribute
  1384.                                  Value     : List_Type) is 
  1385.                                      -- initial value of the attribute
  1386.         Base : Node_Type; 
  1387.  
  1388.     begin
  1389.         Open(Base, Base_Path(Name), (1 => Write_Relationships)); 
  1390.         Set_Path_Attribute(Base, Last_Key(Name), Last_Relation(Name), Attribute
  1391.             , Value); 
  1392.         Close(Base); 
  1393.     exception
  1394.         when others => 
  1395.             Close(Base); 
  1396.             raise; 
  1397.     end Set_Path_Attribute; 
  1398. ----------------------    Get_Node_Attribute   ----------------------
  1399. --
  1400. --  Purpose: This procedure deletes an attribute named by ATTRIBUTE of
  1401. --  -------  of the node identified by the open node handle NODE.
  1402. --
  1403. --  Parameters:
  1404. --  ----------
  1405. --    Node       is the open node handle being modified
  1406. --    Attribute  is the name of the attribute being added to this node
  1407. --
  1408. --  Exceptions:
  1409. --  ----------
  1410. --   USE_ERROR          is raised if the node does not have an attribute of the
  1411. --                given name (or if the name given is syntactically
  1412. --                      illegal??) or is the name of a predefined node attribute
  1413. --            which can't be modified by the user.
  1414. --
  1415. --   STATUS-ERROR       is raised if the node handle is not open
  1416. --
  1417. --   INTENT_VIOLATION   is raised if NODE was not opened with the right to
  1418. --            read attributes.
  1419. --
  1420. --   SECURITY_VIOLATION is raised if the operation represents a violation of
  1421. --            mandatory access controls.  Raised only if no other
  1422. --            exceptions apply.
  1423. --
  1424. --  Notes: MIL-STD CAIS 5.1.3.7
  1425. --  -----
  1426. --
  1427. ---------------------------------------------------------------------
  1428.     -- CAIS 5.1.3.7
  1429.     procedure Get_Node_Attribute(     -- get the value of a node attribute
  1430.                                  Node      : Node_Type; 
  1431.                                          -- open node handle for desired node
  1432.                                  Attribute : Attribute_Name; 
  1433.                                          -- name of created attribute
  1434.                                  Value     : in out List_Type) is 
  1435.                                          -- result parm containing the value
  1436.         Attribute_List : List_Type; 
  1437.     begin
  1438.         Validity_Check(Node, Read_Attributes, Attribute); 
  1439.         Get_Node_Attributes(Node, Attribute_List); 
  1440.  
  1441.         begin                                           --Raise Use_Error when
  1442.             Extract(Attribute_List, Attribute, Value);  --Search_Error shows
  1443.         exception                                       --attribute doesn't
  1444.             when Search_Error =>                        --exist.
  1445.                 raise Use_Error; 
  1446.         end; 
  1447.  
  1448.     end Get_Node_Attribute; 
  1449.  
  1450. -----------------------------------------------------------------------------
  1451. --             ALTERNATE INTERFACE via NAME_STRING for NODE                --
  1452. -----------------------------------------------------------------------------
  1453.     procedure Get_Node_Attribute(  -- Retrieve value of a node attribute
  1454.                                  Name      : Name_String; 
  1455.                                         -- Node name
  1456.                                  Attribute : Attribute_Name; 
  1457.                                         -- name of the attribute
  1458.                                  Value     : in out List_Type) is 
  1459.                                          -- initial value of the attribute
  1460.         Node : Node_Type; 
  1461.  
  1462.     begin
  1463.         Open(Node, Name, (1 => Read_Attributes)); 
  1464.         Get_Node_Attribute(Node, Attribute, Value); 
  1465.         Close(Node); 
  1466.     exception
  1467.         when others => 
  1468.             Close(Node); 
  1469.             raise; 
  1470.     end Get_Node_Attribute; 
  1471. ----------------------   Get_Path_Attribute    ----------------------
  1472. --
  1473. --  Purpose: This procedure creates an attribnute named by ATTRIBUTE of
  1474. --  -------  of a relationship and sets its initial value to VALUE.  The 
  1475. --         relationship is defined by the base node defined by the open
  1476. --         node handle BASE, the relation name RELATION, and the
  1477. --         relationship key KEY.
  1478. --
  1479. --  Parameters:
  1480. --  ----------
  1481. --    Base       is the open node handle of the base node
  1482. --    Key       is the relationship key of the affected relationship
  1483. --    Relation   is the relation name of the affected relationship
  1484. --    Attribute  is the name of the attribute added to this relationship
  1485. --    Value      is the initial value of the attribute
  1486. --
  1487. --  Exceptions:
  1488. --  ----------
  1489. --   NAME_ERROR        is raised if the relationship identified by BASE, KEY,
  1490. --            and RELATION does not exist
  1491. --
  1492. --   USE_ERROR          is raised if the relationship already has an attribute
  1493. --            of the given name or if the name given is syntactically
  1494. --                      illegal or is the name of a predefined node attribute
  1495. --            that cant be modified by the user. Use_Error is also
  1496. --            raised if RELATION is the name of a predefined relation
  1497. --            that can't be modified by the user.
  1498. --
  1499. --   STATUS-ERROR       is raised if the node handle BASE is not open
  1500. --
  1501. --   INTENT_VIOLATION   is raised if BASE was not opened with the right to
  1502. --            read relationships.
  1503. --
  1504. --   SECURITY_VIOLATION is raised if the operation represents a violation of
  1505. --            mandatory access controls.  Raised only if no other
  1506. --            exceptions apply.
  1507. --
  1508. --  Notes: MIL-STD CAIS 5.1.3.8
  1509. --  -----
  1510. --
  1511. ---------------------------------------------------------------------
  1512.     -- CAIS 5.1.3.8
  1513.     procedure Get_Path_Attribute(    -- get the value of a path attribute
  1514.                                  Base      : Node_Type; 
  1515.                                         -- open node handle from which 
  1516.                                         -- the relationship emanates
  1517.                                  Key       : Relationship_Key; 
  1518.                                         -- key of affected relationship
  1519.                                  Relation  : Relation_Name := Default_Relation; 
  1520.                                          -- name of affected relationship
  1521.                                  Attribute : Attribute_Name; 
  1522.                                          -- name of created attribute
  1523.                                  Value     : in out List_Type) is 
  1524.                                          -- result parm containing the value
  1525.         Attribute_List : List_Type; 
  1526.         Primary_Flag   : Boolean; --Returned by Get_A_Relationship but not used
  1527.         Shadow_File    : String(1 .. Pragmatics.Max_Shadow_File_Length); 
  1528.                                                                         --DITTO
  1529.     begin
  1530.         Validity_Check(Base, Read_Relationships, Attribute); 
  1531.         Get_A_Relationship(Base, Relation, Key, Shadow_File, Attribute_List, 
  1532.                                                         --Triggers
  1533.         Primary_Flag);                                  --Name_Error
  1534.  
  1535.         begin                                           --Raise Use_Error when
  1536.             Extract(Attribute_List, Attribute, Value);  --Search_Error shows
  1537.         exception                                       --attribute doesn't
  1538.             when Search_Error =>                        --exist.
  1539.                 raise Use_Error; 
  1540.         end; 
  1541.  
  1542.     exception
  1543.         when Cais_Internals_Exceptions.No_Such_Relationship | 
  1544.             Cais_Internals_Exceptions.No_Such_Relation => 
  1545.             raise Name_Error; 
  1546.     end Get_Path_Attribute; 
  1547.  
  1548. -----------------------------------------------------------------------------
  1549. --             ALTERNATE INTERFACE via NAME_STRING for Relationship        --
  1550. -----------------------------------------------------------------------------
  1551.     procedure Get_Path_Attribute(    -- Retrieve the value of a path attribute
  1552.                                  Name      : Name_String; 
  1553.                                      -- Node name
  1554.                                  Attribute : Attribute_Name; 
  1555.                                         -- name of desired attribute
  1556.                                  Value     : in out List_Type) is 
  1557.                                         -- initial value of the attribute
  1558.         Base : Node_Type; 
  1559.  
  1560.     begin
  1561.         Open(Base, Base_Path(Name), (1 => Read_Relationships)); 
  1562.         Get_Path_Attribute(Base, Last_Key(Name), Last_Relation(Name), Attribute
  1563.             , Value); 
  1564.         Close(Base); 
  1565.     exception
  1566.         when others => 
  1567.             Close(Base); 
  1568.             raise; 
  1569.     end Get_Path_Attribute; 
  1570. --------------------------NODE_ATTRIBUTE_ITERATE---------------------
  1571. --
  1572. --  Purpose:  Creates a set of attributes from the named node which
  1573. --  -------   match the provided pattern containing wild card characters
  1574. --            '*' to match any string and '?' to match any character.
  1575. --
  1576. --  Parameters:
  1577. --  ----------
  1578. --   Iterator is the set of matching attributes
  1579. --   Node     is the node whose attributes are searched for matches
  1580. --   Pattern  is the string (with * and ?) which determines matches
  1581. --
  1582. --  Exceptions:
  1583. --  ----------
  1584. --   Use_Error        is raised if the Pattern is syntactically illegal
  1585. --   
  1586. --   Status_Error     is raised if the node is not an open node handle
  1587. --
  1588. --   Intent_Violation is rasied if Node is not open with the right to
  1589. --              read attributes.
  1590. --
  1591. --  Notes: MIL-STD CAIS 5.1.3.10
  1592. --  -----
  1593. --
  1594. ---------------------------------------------------------------------
  1595.     -- CAIS 5.1.3.10
  1596.     procedure Node_Attribute_Iterate(    -- get an attribute iterator
  1597.                                      Iterator : in out Attribute_Iterator; 
  1598.                                                -- see CAIS 1.4 5.1.3 for expl.)
  1599.                                      Node     : Node_Type; 
  1600.                                      -- open node handle for desired node
  1601.                                      Pattern  : Attribute_Pattern := "*") is 
  1602.                                                   -- pattern for attr. names
  1603.         Attribute_List : List_Type; 
  1604.         Token_Name     : Token_Type; 
  1605.         Value          : List_Type; 
  1606.         Size           : Integer := 0; 
  1607.     begin
  1608.         Verify_Pattern(Pattern, Size);                  --Use_Error check
  1609.         Check_For_Open_Node(Node);                      --Status_Error check
  1610.         Check_Intentions(Node, Read_Attributes);        --Intent check
  1611.         Get_Node_Attributes(Node, Attribute_List); 
  1612.  
  1613.         Initialize_Iterator(Iterator); 
  1614.  
  1615.         for I in 1 .. Length(Attribute_List) loop
  1616.             Item_Name(Attribute_List, I, Token_Name); 
  1617.             if Pattern_Match(To_Text(Token_Name), Pattern(Pattern'First .. Size)
  1618.                 ) then 
  1619.                 Extract(Attribute_List, I, Value); 
  1620.                 Insert(Iterator.List.all, Value, Token_Name, Lexical_Position(
  1621.                     Iterator.List.all, Token_Name)); 
  1622.             end if; 
  1623.         end loop; 
  1624.     end Node_Attribute_Iterate; 
  1625.  
  1626. -----------------------------------------------------------------------------
  1627. --             ALTERNATE INTERFACE via NAME_STRING for NODE                --
  1628. -----------------------------------------------------------------------------
  1629.     procedure Node_Attribute_Iterate(  -- create iterator over set of attributes
  1630.                                      Iterator : in out Attribute_Iterator; 
  1631.                                                --set being created
  1632.                                      Name     : Name_String; 
  1633.                                                --node from which set is built
  1634.                                      Pattern  : Attribute_Pattern := "*") is 
  1635.                                                --set descriptor
  1636.         Node : Node_Type; 
  1637.  
  1638.     begin
  1639.         Open(Node, Name, (1 => Read_Attributes)); 
  1640.         Node_Attribute_Iterate(Iterator, Node, Pattern); 
  1641.         Close(Node); 
  1642.     exception
  1643.         when others => 
  1644.             Close(Node); 
  1645.             raise; 
  1646.     end Node_Attribute_Iterate; 
  1647. ----------------------  Path_Attribute_Iterate  ----------------------
  1648. --
  1649. --  Purpose:  Creates a set of attributes from the named path which
  1650. --  -------   match the provided pattern containing wild card characters
  1651. --            '*' to match any string and '?' to match any character.
  1652. --
  1653. --  Parameters:
  1654. --  ----------
  1655. --   Iterator is the set of matching attributes
  1656. --   Base     is the open node handle from which the relationship emanates
  1657. --   Key      is the key of the affected relationship
  1658. --   Relation is the name of the affected relationship
  1659. --   Pattern  is the string (with * and ?) which determines matches
  1660. --
  1661. --  Exceptions:
  1662. --  ----------
  1663. --   Use_Error        is raised if the Pattern is syntactically illegal
  1664. --   
  1665. --   Status_Error     is raised if the node is not an open node handle
  1666. --
  1667. --   Intent_Violation is rasied if Node is not open with the right to
  1668. --              read relationships.
  1669. --
  1670. --  Notes: MIL-STD CAIS 5.1.3.11
  1671. --  -----
  1672. --
  1673. ---------------------------------------------------------------------
  1674.     -- CAIS 5.1.3.11
  1675.     procedure Path_Attribute_Iterate(  -- get iterator over relationship attr.
  1676.                                      Iterator : in out Attribute_Iterator; 
  1677.                                               -- see CAIS 1.4 5.1.3 for expl.)
  1678.                                      Base     : Node_Type; 
  1679.                                         -- open node handle from which 
  1680.                                         -- the relationship emanates
  1681.                                      Key      : Relationship_Key; 
  1682.                                         -- key of the relationship
  1683.                                      Relation : Relation_Name := 
  1684.                                          Default_Relation; 
  1685.                                         -- name of the relationship
  1686.                                      Pattern  : Attribute_Pattern := "*") is 
  1687.                                                  -- pattern for attr. names
  1688.         Attribute_List : List_Type; 
  1689.         Token_Name     : Token_Type; 
  1690.         Value          : List_Type; 
  1691.         Primary_Flag   : Boolean; --Return by Get_A_Relationship but not used
  1692.         Shadow_File    : String(1 .. Pragmatics.Max_Shadow_File_Length); 
  1693.                                                                        --DITTO
  1694.         Size           : Integer := 0; 
  1695.  
  1696.     begin
  1697.         Verify_Pattern(Pattern, Size);                  --Use_Error check
  1698.         Check_For_Open_Node(Base);                      --Status_Error check
  1699.         Check_Intentions(Base, Read_Relationships);     --Intent check
  1700.         Get_A_Relationship(Base, Relation, Key, Shadow_File, Attribute_List, 
  1701.                                                         --Triggers
  1702.         Primary_Flag);                                  --Name_Error
  1703.         Initialize_Iterator(Iterator); 
  1704.  
  1705.         for I in 1 .. Length(Attribute_List) loop
  1706.             Item_Name(Attribute_List, I, Token_Name); 
  1707.             if Pattern_Match(To_Text(Token_Name), Pattern(Pattern'First .. Size)
  1708.                 ) then 
  1709.                 Extract(Attribute_List, I, Value); 
  1710.                 Insert(Iterator.List.all, Value, Token_Name, Lexical_Position(
  1711.                     Iterator.List.all, Token_Name)); 
  1712.             end if; 
  1713.         end loop; 
  1714.     exception
  1715.         when Cais_Internals_Exceptions.No_Such_Relationship | 
  1716.             Cais_Internals_Exceptions.No_Such_Relation => 
  1717.             raise Name_Error; 
  1718.     end Path_Attribute_Iterate; 
  1719.  
  1720. -----------------------------------------------------------------------------
  1721. --             ALTERNATE INTERFACE via NAME_STRING for NODE                --
  1722. -----------------------------------------------------------------------------
  1723.     procedure Path_Attribute_Iterate(    -- build iteration set 
  1724.                                      Iterator : in out Attribute_Iterator; 
  1725.                                                 --set being built
  1726.                                      Name     : Name_String; 
  1727.                                              --name of affected relationship
  1728.                                      Pattern  : Attribute_Pattern := "*") is 
  1729.                                              --determines selected attributes
  1730.         Base : Node_Type; 
  1731.  
  1732.     begin
  1733.         Open(Base, Base_Path(Name), (1 => Read_Relationships)); 
  1734.         Path_Attribute_Iterate(Iterator, Base, Last_Key(Name), Last_Relation(
  1735.             Name), Pattern); 
  1736.         Close(Base); 
  1737.     exception
  1738.         when others => 
  1739.             Close(Base); 
  1740.             raise; 
  1741.     end Path_Attribute_Iterate; 
  1742. ----------------------          More           ----------------------
  1743. --
  1744. --  Purpose: The function More returns false if all attributes contained
  1745. --  -------  in the attribute iterator have been retrieved with the procedure
  1746. --         Get_Next; otherwise, it returns true.
  1747. --
  1748. --  Parameters:
  1749. --  ----------
  1750. --    Iterator is a previously constructed attribute iterator.
  1751. --
  1752. --  Exceptions:
  1753. --  ----------
  1754. --    Use_Error is raised if the iterator has not been previously set by the
  1755. --        procedure Node_Attribute_Iterate or Path_Attribute_Iterate.
  1756. --
  1757. --  Notes: MIL-STD CAIS 5.1.3.12
  1758. --  -----
  1759. --
  1760. ---------------------------------------------------------------------
  1761.     -- CAIS 5.1.3.12
  1762.     function More(  -- indicate if all attr. have been retrieved via Get_Next
  1763.                   Iterator : in Attribute_Iterator)
  1764.                                          -- previously constructed iterator
  1765.     return Boolean is 
  1766.  
  1767.         Dummy : Boolean;    -- for return statement in stub only 
  1768.     begin
  1769.         if Iterator.Position < 0 or else Iterator.List = null or else Iterator.
  1770.             Position > Length(Iterator.List.all) then 
  1771.             raise Use_Error;        --Poorly formed Iterator;
  1772.         else 
  1773.             return Iterator.Position /= Length(Iterator.List.all); 
  1774.         end if; 
  1775.     end More; 
  1776. ----------------------          Get_Next       ----------------------
  1777. --
  1778. --  Purpose: Returns, in the parameters Attribute and Value, both the name
  1779. --  -------  and the value of the next attribute in the iterator.
  1780. --
  1781. --  Parameters:
  1782. --  ----------
  1783. --    Iterator  is a previously constructed iterator.
  1784. --    Attribute contains the name of the retrieved attribute.
  1785. --    Value     contains the value of the attribute named by Attribute.
  1786. --
  1787. --  Exceptions:
  1788. --  ----------
  1789. --    Use_Error is raised if the Iterator has not been previously set by the
  1790. --        procedure Node_Attribute_Iterate or Path_Attribute_Iterate or if the
  1791. --        iterator is exhausted, i.e., More(Iterator) = false.
  1792. --
  1793. --  Notes: MIL-STD CAIS 5.1.3.13
  1794. --  -----
  1795. --
  1796. ---------------------------------------------------------------------
  1797.     -- CAIS 5.1.3.13
  1798.     procedure Get_Next(   -- get name and value of next attribute  in iterator
  1799.                        Iterator  : in out Attribute_Iterator; 
  1800.                                                -- see CAIS 1.4 5.1.3 for expl.)
  1801.                        Attribute : in out Attribute_Name; 
  1802.                                                   -- name of next attribute 
  1803.                        Value     : in out List_Type) is 
  1804.                                                -- value of next attribute
  1805.         Token_Name : Token_Type;        --Attribute name in token form
  1806.         Len        : Natural; 
  1807.  
  1808.     begin
  1809.         if Iterator.Position < 0 or else Iterator.List = null or else Iterator.
  1810.             Position >= Length(Iterator.List.all) then 
  1811.             raise Use_Error;    --Poorly formed or exhausted Iterator
  1812.         else 
  1813.             Iterator.Position := Iterator.Position + 1; 
  1814.                                                      --point to next value
  1815.             Extract(Iterator.List.all, Iterator.Position, Value); 
  1816.             Item_Name(Iterator.List.all, Iterator.Position, Token_Name); 
  1817.             Len := To_Text(Token_Name)'Length; 
  1818.             Attribute(Attribute'range ) := (others => ' '); 
  1819.             Attribute(Attribute'First .. Attribute'First + Len - 1) := To_Text(
  1820.                 Token_Name); 
  1821.         end if; 
  1822.     end Get_Next; 
  1823. ---------------------------------------------------------------------------
  1824. end Attributes; --END OF PACKAGE BODY 
  1825. ---------------------------------------------------------------------------
  1826. --::::::::::::::
  1827. --cais_body.a
  1828. --::::::::::::::
  1829. with Calendar; 
  1830. with Generic_List; 
  1831. with Trace; use Trace; 
  1832.  
  1833. package body Cais is 
  1834.  
  1835.  
  1836.     type Node_Rec is 
  1837.         record
  1838.             Kind            : Node_Definitions.Node_Kind; 
  1839.             Pathname        : String(1 .. Pragmatics.Max_Name_String); 
  1840.             Open_Intent     : Node_Definitions.Intention(Pragmatics.Intent_Count
  1841.                 ); 
  1842.             Intent_Size     : Pragmatics.Intent_Count; 
  1843.             Shadow_File     : String(1 .. Pragmatics.Max_Shadow_File_Length) := 
  1844.                 (others => ' '); 
  1845.             Contents_File   : String(1 .. Pragmatics.Max_Shadow_File_Length) := 
  1846.                 (others => ' '); 
  1847.             Node_Attributes : List_Utilities.List_Type; 
  1848.             Node_Relations  : List_Utilities.List_Type; 
  1849.             Access_Control  : List_Utilities.List_Type; 
  1850.             Node_Level      : List_Utilities.List_Type; 
  1851.             Open_Status     : Boolean := False; 
  1852.         end record; 
  1853. -- These list items are preset in the package body at elaboration to 
  1854. -- contain the names of all CAIS predefined attributes and relations.
  1855.     Predefined_Attributes : List_Utilities.List_Type; 
  1856.     Predefined_Relations  : List_Utilities.List_Type; 
  1857.  
  1858. ----------------------------------------------------------------------
  1859. --            C A I S _ I N T E R N A L S _ E X C E P T I O N S
  1860. --
  1861. --
  1862. --       Definitions of exceptions raised by CAIS implementation code
  1863. --
  1864. --
  1865. --
  1866. --
  1867. --                  Ada Software Engineering Group
  1868. --                      The MITRE Corporation
  1869. --                         McLean, VA 22102
  1870. --
  1871. --
  1872. --                   Tue May 21 11:20:56 EDT 1985
  1873. --
  1874. --                 (Unclassified and uncopyrighted)
  1875. --
  1876. ----------------------------------------------------------------------
  1877. ----------------------------------------------------------------------
  1878. --            C A I S _ I N T E R N A L S _ E X C E P T I O N S
  1879. --
  1880. --  Purpose:
  1881. --  -------
  1882. --    This package is simply the collection of exceptions used internally
  1883. --    in the CAIS prototype.  
  1884. --
  1885. --  Usage:
  1886. --  -----
  1887. --    The exceptions declared here are used any any other exceptions;
  1888. --    they are explicitly raised under certain conditions in internals
  1889. --    code, and trapped by exception handlers that either map them onto
  1890. --    cais_defined exceptions or attempt recovery.
  1891. --
  1892. --  Example:
  1893. --  -------
  1894. --    raise List_Too_Long;
  1895. --
  1896. --  Notes:
  1897. --  -----
  1898. --    None.
  1899. --
  1900. --  Revision History:
  1901. --  ----------------
  1902. --    None.
  1903. --
  1904. -------------------------------------------------------------------
  1905.     package Cais_Internals_Exceptions is 
  1906.  
  1907.         Pathname_Syntax_Error : exception; 
  1908.         No_Such_Component     : exception; 
  1909.         Pn_Parser_Error       : exception; 
  1910.         Internal_Error        : exception; 
  1911.         No_Such_User          : exception; 
  1912.         Shadow_File_Error     : exception; 
  1913.         Content_File_Error    : exception; 
  1914.         List_Too_Long         : exception; 
  1915.         Cais_Userid_Undefined : exception; 
  1916.         No_Such_Relation      : exception; 
  1917.         No_Such_Relationship  : exception; 
  1918.         No_Such_Shadow_File   : exception; 
  1919.  
  1920.     end Cais_Internals_Exceptions; 
  1921.  
  1922. ----------------------------------------------------------------------
  1923. --        N O D E _ R E P R E S E N T A T I O N
  1924. --
  1925. --  Function:
  1926. --  --------
  1927. --      This package provides the subprograms 
  1928. --      used by other components of the CAIS implementation for 
  1929. --      manipulation of objects of type Node_Type.
  1930. --
  1931. --  Usage:
  1932. --  -----
  1933. --    TBS
  1934. --
  1935. --  Example:
  1936. --  -------
  1937. --    TBS
  1938. --
  1939. --  Notes:
  1940. --  -----
  1941. --  
  1942. --  Revision History:
  1943. --  ----------------
  1944. --
  1945. ----------------------------------------------------------------------
  1946.  
  1947.     package Node_Representation is 
  1948.  
  1949.         use List_Utilities; 
  1950.         use Node_Definitions; 
  1951.  
  1952.  
  1953.         Null_Rel_Key : constant String := "C_A_I_S_N_U_L_L_K_E_Y"; 
  1954.         Primary_Rel  : constant String := "C_A_I_S_P_R_I_M_A_R_Y"; 
  1955.  
  1956.         type Pn_Rec is 
  1957.             record
  1958.                 Rel_Name   : String(1 .. Pragmatics.Max_Token_Size) := (others
  1959.                     => ' '); 
  1960.                 Rel_Key    : String(1 .. Pragmatics.Max_Token_Size) := (others
  1961.                     => ' '); 
  1962.                 Latest_Key : Boolean := False; 
  1963.             end record; 
  1964.  
  1965.         package Pn_Comp_List is 
  1966.             new Generic_List(Pn_Rec); 
  1967.         use Pn_Comp_List; 
  1968.  
  1969.         type Parsed_Pn is 
  1970.             record
  1971.                 L : Pn_Comp_List.List; 
  1972.             end record; 
  1973.  
  1974.  
  1975. ----------------------   I N I T _ N O D E     ----------------------
  1976. --
  1977. --  Purpose:
  1978. --  -------
  1979. --    Initialize an object of type Node_Type prior to use.
  1980. --
  1981. --  Parameters:
  1982. --  ----------
  1983. --    Node  - the node object to be initialized
  1984. --
  1985. --  Exceptions:
  1986. --  ----------
  1987. --    None
  1988. --
  1989. --  Notes:
  1990. --  -----
  1991. --
  1992. ---------------------------------------------------------------------
  1993.         procedure Init_Node(Node : in out Node_Type); 
  1994.  
  1995. ---------------------         G E T _ K I N D   ---------------------
  1996. --
  1997. --  Purpose:
  1998. --  -------
  1999. --    Extract the Node_Kind component from an object of the 
  2000. --    limited private type Node_Type.
  2001. --
  2002. --  Parameters:
  2003. --  ----------
  2004. --    Node  -  The object of type Node_Type
  2005. --
  2006. --  Exceptions:
  2007. --  ----------
  2008. --    Node_Definitions.Status_Error if the node is not initialized.
  2009. --
  2010. --  Notes:
  2011. --  -----
  2012. --
  2013. ---------------------------------------------------------------------
  2014.         function Get_Kind(Node : Node_Type) return Node_Kind; 
  2015.  
  2016. ---------------------  G E T _ P A T H N A M E  ---------------------
  2017. --
  2018. --  Purpose:
  2019. --  -------
  2020. --    Extract the Pathname component from an object of the 
  2021. --    limited private type Node_Type.
  2022. --
  2023. --  Parameters:
  2024. --  ----------
  2025. --    Node  -  The object of type Node_Type
  2026. --
  2027. --  Exceptions:
  2028. --  ----------
  2029. --    Node_Definitions.Status_Error if the node is not initialized.
  2030. --
  2031. --  Notes:
  2032. --  -----
  2033. --
  2034. ---------------------------------------------------------------------
  2035.         procedure Get_Pathname(Node     : Node_Type; 
  2036.                                Name     : in out String; 
  2037.                                Lastchar : in out Natural); 
  2038.                                     -- offset of last char returned
  2039.  
  2040. ---------------------         G E T _ I N T E N T -------------------
  2041. --
  2042. --  Purpose:
  2043. --  -------
  2044. --    Extract the Intention component from an object of the 
  2045. --    limited private type Node_Type.
  2046. --
  2047. --  Parameters:
  2048. --  ----------
  2049. --    Node  -  The object of type Node_Type
  2050. --
  2051. --  Exceptions:
  2052. --  ----------
  2053. --    Node_Definitions.STATUS_ERROR if the node is not initialized.
  2054. --
  2055. --  Notes:
  2056. --  -----
  2057. --
  2058. ---------------------------------------------------------------------
  2059.         function Get_Intent(Node : Node_Type) return Intention; 
  2060.  
  2061. -----------         G E T _ S H A D O W _ F I L E _ N A M E ---------
  2062. --
  2063. --  Purpose:
  2064. --  -------
  2065. --    Extract the Shadow file name component from an object of the 
  2066. --    limited private type Node_Type.
  2067. --
  2068. --  Parameters:
  2069. --  ----------
  2070. --    Node  -  The object of type Node_Type
  2071. --
  2072. --  Exceptions:
  2073. --  ----------
  2074. --    Node_Definitions.STATUS_ERROR if the node is not initialized.
  2075. --
  2076. --  Notes:
  2077. --  -----
  2078. --
  2079. ---------------------------------------------------------------------
  2080.         procedure Get_Shadow_File_Name(Node     : Node_Type; 
  2081.                                        Name     : in out String; 
  2082.                                        Lastchar : in out Natural); 
  2083.                                     -- offset of last char returned
  2084.  
  2085. -----------     G E T _ C O N T E N T S _ F I L E _ N A M E ---------
  2086. --
  2087. --  Purpose:
  2088. --  -------
  2089. --    Extract the Contents file name component from an object of the 
  2090. --    limited private type Node_Type.
  2091. --
  2092. --  Parameters:
  2093. --  ----------
  2094. --    Node  -  The object of type Node_Type
  2095. --
  2096. --  Exceptions:
  2097. --  ----------
  2098. --    Node_Definitions.STATUS_ERROR if the node is not initialized.
  2099. --
  2100. --  Notes:
  2101. --  -----
  2102. --
  2103. ---------------------------------------------------------------------
  2104.         procedure Get_Contents_File_Name(Node     : Node_Type; 
  2105.                                          Name     : in out String; 
  2106.                                          Lastchar : in out Natural); 
  2107.                                     -- offset of last char returned
  2108.  
  2109. ----------------  G E T _ N O D E _ A T T R I B U T E S  ------------
  2110. --
  2111. --  Purpose:
  2112. --  -------
  2113. --    Extract the node attributes component from an object of the 
  2114. --    limited private type Node_Type.
  2115. --
  2116. --  Parameters:
  2117. --  ----------
  2118. --    Node  -  The object of type Node_Type
  2119. --    Attributes - the list containing the node attributes extracted
  2120. --
  2121. --  Exceptions:
  2122. --  ----------
  2123. --    Node_Definitions.Status_Error if the node is not initialized.
  2124. --
  2125. --  Notes:
  2126. --  -----
  2127. --
  2128. ---------------------------------------------------------------------
  2129.         procedure Get_Node_Attributes(Node       : Node_Type; 
  2130.                                       Attributes : in out List_Type); 
  2131.  
  2132. ----------------  G E T _ N O D E _ R E L A T I O N S  --------------
  2133. --
  2134. --  Purpose:
  2135. --  -------
  2136. --    Extract the node relations component from an object of the 
  2137. --    limited private type Node_Type.
  2138. --
  2139. --  Parameters:
  2140. --  ----------
  2141. --    Node  -  The object of type Node_Type
  2142. --    Relations - the list containing the node relations extracted
  2143. --
  2144. --  Exceptions:
  2145. --  ----------
  2146. --    Node_Definitions.Status_Error if the node is not initialized.
  2147. --
  2148. --  Notes:
  2149. --  -----
  2150. --
  2151. ---------------------------------------------------------------------
  2152.         procedure Get_Node_Relations(Node      : Node_Type; 
  2153.                                      Relations : in out List_Type); 
  2154.  
  2155. ---------------  G E T _ A _ R E L A T I O N  -----------------------
  2156. --
  2157. --  Purpose:
  2158. --  -------
  2159. --    This procedure returns the list containing all of the internal
  2160. --    data structures associated with a specific node relation.
  2161. --
  2162. --  Parameters:
  2163. --  ----------
  2164. --    Node      - node_type of node from which the relation emanates.
  2165. --    Rel_Name  - The name of the relation
  2166. --    Rel_List  - the list returned containing all of the data structures.
  2167. --
  2168. --  Exceptions:
  2169. --  ----------
  2170. --    Status_Error   - if "Node" was not initialized
  2171. --    Cais_Internals_Exceptions.No_Such_Relation  - if "Rel_Name" does
  2172. --        not refer to an existing relation emanating from "Node".
  2173. --
  2174. --  Notes:
  2175. --  -----
  2176. --
  2177. ---------------------------------------------------------------------
  2178.         procedure Get_A_Relation(Node     : Node_Type; 
  2179.                                  Rel_Name : String; 
  2180.                                  Rel_List : in out List_Type); 
  2181.  
  2182. -------------  G E T _ A _ R E L A T I O N I ON S H I P -------------
  2183. --
  2184. --  Purpose:
  2185. --  -------
  2186. --    This procedure returns all of the internal data structures associated 
  2187. --    with a specific node relationionship.
  2188. --
  2189. --  Parameters:
  2190. --  ----------
  2191. --    Node      - node_type of node from which the relation emanates.
  2192. --    Rel_Name  - The name of the relation
  2193. --    Rel_Key   - The name of the relationship key
  2194. --    Rel_Attributes - all of the relationship attributes as a list
  2195. --    Primary   - Boolean indicating if this is a primary relationship
  2196. --    Shadow_File  - host name of the shadow file for this relationship
  2197. --
  2198. --  Exceptions:
  2199. --  ----------
  2200. --    Status_Error   - if "Node" was not initialized
  2201. --    Cais_Internals_Exceptions.No_Such_Relation  - if "Rel_Name" does
  2202. --        not refer to an existing relation emanating from "Node".
  2203. --    Cais_Internals_Exceptions.No_Such_Relationship  - if "Rel_Name" and
  2204. --        "Rel_Key" together do not refer to an existing relationship 
  2205. --        emanating from "Node".
  2206. --    Cais_Internals_Exceptions.Internal_Error  - if the shadow file
  2207. --        structure has become corrupted.
  2208. --
  2209. --  Notes:
  2210. --  -----
  2211. --
  2212. ---------------------------------------------------------------------
  2213.         procedure Get_A_Relationship(Node           : Node_Type; 
  2214.                                      Rel_Name       : String; 
  2215.                                      Rel_Key        : String; 
  2216.                                      Shadow_File    : in out String; 
  2217.                                      Rel_Attributes : in out List_Type; 
  2218.                                      Primary        : in out Boolean); 
  2219.  
  2220. ------------  G E T _ N O D E _ A C C E S S _ C O N T R O L ---------
  2221. --
  2222. --  Purpose:
  2223. --  -------
  2224. --    Extract the access control component from an object of the 
  2225. --    limited private type Node_Type.
  2226. --
  2227. --  Parameters:
  2228. --  ----------
  2229. --    Node  -  The object of type Node_Type
  2230. --    AccList - the list containing the access control information extracted
  2231. --
  2232. --  Exceptions:
  2233. --  ----------
  2234. --    Node_Definitions.Status_Error if the node is not initialized.
  2235. --
  2236. --  Notes:
  2237. --  -----
  2238. --
  2239. ---------------------------------------------------------------------
  2240.         procedure Get_Node_Access_Control(Node    : Node_Type; 
  2241.                                           Acclist : in out List_Type); 
  2242.  
  2243. ----------------  G E T _ N O D E _ L E V E L    --------------------
  2244. --
  2245. --  Purpose:
  2246. --  -------
  2247. --    Extract the node level component from an object of the 
  2248. --    limited private type Node_Type.
  2249. --
  2250. --  Parameters:
  2251. --  ----------
  2252. --    Node  -  The object of type Node_Type
  2253. --    Level - the list containing the node level extracted
  2254. --
  2255. --  Exceptions:
  2256. --  ----------
  2257. --    Node_Definitions.Status_Error if the node is not initialized.
  2258. --
  2259. --  Notes:
  2260. --  -----
  2261. --    Level refers to the classification attribute values associated with
  2262. --    the node, as described in MIL-STD-CAIS 4.4.3.  Mandatory access
  2263. --    control is NOT implemented in the MITRE prototype.
  2264. --
  2265. ---------------------------------------------------------------------
  2266.         procedure Get_Node_Level(Node  : Node_Type; 
  2267.                                  Level : in out List_Type); 
  2268.  
  2269. -----------     S E T _ N O D E _ A T T R I B U T E S   -------------
  2270. --
  2271. --  Purpose:
  2272. --  -------
  2273. --    Set the node attributes component in an object of the 
  2274. --    limited private type Node_Type.
  2275. --
  2276. --  Parameters:
  2277. --  ----------
  2278. --    Node        -  The object of type Node_Type
  2279. --    Attributes  -  The attributes list to be assigned
  2280. --
  2281. --  Exceptions:
  2282. --  ----------
  2283. --    None.
  2284. --
  2285. --  Notes:
  2286. --  -----
  2287. --
  2288. ---------------------------------------------------------------------
  2289.         procedure Set_Node_Attributes(Node       : in out Node_Type; 
  2290.                                       Attributes : List_Type); 
  2291.  
  2292. -----------     S E T _ N O D E _ R E L A T I O N S   ---------------
  2293. --
  2294. --  Purpose:
  2295. --  -------
  2296. --    Set the node relations component in an object of the 
  2297. --    limited private type Node_Type.
  2298. --
  2299. --  Parameters:
  2300. --  ----------
  2301. --    Node        -  The object of type Node_Type
  2302. --    relations   -  The relations list to be assigned
  2303. --
  2304. --  Exceptions:
  2305. --  ----------
  2306. --    None.
  2307. --
  2308. --  Notes:
  2309. --  -----
  2310. --
  2311. ---------------------------------------------------------------------
  2312.     -- if the relation does not exist, it is created.
  2313.     -- if the relation exists, it is replaced.
  2314.         procedure Set_Node_Relations(Node      : in out Node_Type; 
  2315.                                      Relations : List_Type); 
  2316.  
  2317. --------------     S E T _ A _ R E L A T I O N S H I P   ---------------
  2318. --
  2319. --  Purpose:
  2320. --  -------
  2321. --    Set the values for a specific node relationship
  2322. --
  2323. --  Parameters:
  2324. --  ----------
  2325. --    Node        - Node handle of node to be accessed
  2326. --    Rel_Name    - relation name of the relationship to be set
  2327. --    Rel_Key     - relation key of the relationship to be set
  2328. --    Rel_Attributes - relationship attributes of the relationship to be set 
  2329. --    Primary     - Boolean indicating if the relationship is primary
  2330. --    Shadow_File - fully qualified name of host shadow file
  2331. --
  2332. --  Exceptions:
  2333. --  ----------
  2334. --    None.
  2335. --
  2336. --  Notes:
  2337. --  -----
  2338. --
  2339. ---------------------------------------------------------------------
  2340.     -- if the relation does not exist, it is created.
  2341.     -- if the relationship exists, it is replaced.
  2342.         procedure Set_A_Relationship(Node           : in out Node_Type; 
  2343.                                      Rel_Name       : String; 
  2344.                                      Rel_Key        : String; 
  2345.                                      Rel_Attributes : List_Type; 
  2346.                                      Primary        : Boolean; 
  2347.                                      Shadow_File    : String); 
  2348.  
  2349. ----------------- D E L E T E _ A _ R E L A T I O N S H I P ---------
  2350. --
  2351. --  Purpose:
  2352. --  -------
  2353. --    This procedure deletes a specific relationship from the
  2354. --    relationships emanating from the node.
  2355. --
  2356. --  Parameters:
  2357. --  ----------
  2358. --    Node      - Node handle for specified node
  2359. --    Rel_Name  - relation name for relationship to be deleted
  2360. --    Rel_Key   - relation key for relationship to be deleted
  2361. --
  2362. --  Exceptions:
  2363. --  ----------
  2364. --    No_Such_Relation      - if the relation name does not refer to an
  2365. --                            existing node relation.
  2366. --    No_Such_Relationship  - if the relation name and key do not refer 
  2367. --                            to an existing node relationship.
  2368. --
  2369. --  Notes:
  2370. --  -----
  2371. --
  2372. ---------------------------------------------------------------------
  2373.         procedure Delete_A_Relationship(Node     : in out Node_Type; 
  2374.                                         Rel_Name : String; 
  2375.                                         Rel_Key  : String); 
  2376.  
  2377. ------------  S E T _ N O D E _ A C C E S S _ C O N T R O L ---------
  2378. --
  2379. --  Purpose:
  2380. --  -------
  2381. --    Set the access control component from an object of the 
  2382. --    limited private type Node_Type.
  2383. --
  2384. --  Parameters:
  2385. --  ----------
  2386. --    Node  -  The object of type Node_Type
  2387. --    AccList - the list containing the access control information
  2388. --
  2389. --  Exceptions:
  2390. --  ----------
  2391. --    None.
  2392. --
  2393. --  Notes:
  2394. --  -----
  2395. --
  2396. ---------------------------------------------------------------------
  2397.         procedure Set_Node_Access_Control(Node    : in out Node_Type; 
  2398.                                           Acclist : List_Type); 
  2399.  
  2400. ----------------  S E T _ N O D E _ L E V E L    --------------------
  2401. --
  2402. --  Purpose:
  2403. --  -------
  2404. --    Set the node level component of an object of the 
  2405. --    limited private type Node_Type.
  2406. --
  2407. --  Parameters:
  2408. --  ----------
  2409. --    Node  -  The object of type Node_Type
  2410. --    Level - the list containing the node level
  2411. --
  2412. --  Exceptions:
  2413. --  ----------
  2414. --    None.
  2415. --
  2416. --  Notes:
  2417. --  -----
  2418. --    Level refers to the classification attribute values associated with
  2419. --    the node, as described in MIL-STD-CAIS 4.4.3.  Mandatory access
  2420. --    control is NOT implemented in the MITRE prototype.
  2421. --
  2422. ---------------------------------------------------------------------
  2423.         procedure Set_Node_Level(Node  : in out Node_Type; 
  2424.                                  Level : List_Type); 
  2425.  
  2426.  
  2427. ---------------------         S E T _ K I N D   ---------------------
  2428. --
  2429. --  Purpose:
  2430. --  -------
  2431. --    Extract the Node_Kind component in an object of the 
  2432. --    limited private type Node_Type.
  2433. --
  2434. --  Parameters:
  2435. --  ----------
  2436. --    Node  -  The object of type Node_Type
  2437. --    Kind  - the value to be assigned
  2438. --
  2439. --  Exceptions:
  2440. --  ----------
  2441. --    None.
  2442. --
  2443. --  Notes:
  2444. --  -----
  2445. --
  2446. ---------------------------------------------------------------------
  2447.         procedure Set_Kind(Node : in out Node_Type; 
  2448.                            Kind : Node_Kind); 
  2449.  
  2450. ---------------------         S E T _ P N       ---------------------
  2451. --
  2452. --  Purpose:
  2453. --  -------
  2454. --    Set the Parsed_PN component in an object of the 
  2455. --    limited private type Node_Type.
  2456. --
  2457. --  Parameters:
  2458. --  ----------
  2459. --    Node  -  The object of type Node_Type
  2460. --    PN    -  the value to be assigned
  2461. --
  2462. --  Exceptions:
  2463. --  ----------
  2464. --    None.
  2465. --
  2466. --  Notes:
  2467. --  -----
  2468. --
  2469. ---------------------------------------------------------------------
  2470.         procedure Set_Pathname(Node     : in out Node_Type; 
  2471.                                Pathname : String); 
  2472.  
  2473. --------------------    S E T _ I N T E N T    ----------------------
  2474. --
  2475. --  Purpose:
  2476. --  -------
  2477. --    Set the Intention component in an object of the 
  2478. --    limited private type Node_Type.
  2479. --
  2480. --  Parameters:
  2481. --  ----------
  2482. --    Node  -  The object of type Node_Type
  2483. --    Open_Intent - The value to be assigned
  2484. --
  2485. --  Exceptions:
  2486. --  ----------
  2487. --    None.
  2488. --
  2489. --  Notes:
  2490. --  -----
  2491. --    The code in this procedure reflects the implementation convention
  2492. --    that the Intent array of a node is of the fixed length
  2493. --    Pragmatics.Intent_Count, and that the offset of the last
  2494. --    element in this array that is assigned a value from the Intention 
  2495. --    given by the user in the Open call is stored in Node.Intent_Size.
  2496. --
  2497. ---------------------------------------------------------------------
  2498.         procedure Set_Intent(Node        : in out Node_Type; 
  2499.                              Open_Intent : Intention); 
  2500.  
  2501. -----------         S E T _ S H A D O W _ F I L E _ N A M E ---------
  2502. --
  2503. --  Purpose:
  2504. --  -------
  2505. --    Set the Shadow file name component in an object of the 
  2506. --    limited private type Node_Type.
  2507. --
  2508. --  Parameters:
  2509. --  ----------
  2510. --    Node  -  The object of type Node_Type
  2511. --    Shadow_File - the value to be assigned
  2512. --
  2513. --  Exceptions:
  2514. --  ----------
  2515. --    None.
  2516. --
  2517. --  Notes:
  2518. --  -----
  2519. --
  2520. ---------------------------------------------------------------------
  2521.         procedure Set_Shadow_File_Name(Node : in out Node_Type; 
  2522.                                        Name : String); 
  2523.                         -- left justified, padded w/ blanks
  2524.  
  2525. -----------     S E T _ C O N T E N T S _ F I L E _ N A M E ---------
  2526. --
  2527. --  Purpose:
  2528. --  -------
  2529. --    Set the Contents file name component in an object of the 
  2530. --    limited private type Node_Type.
  2531. --
  2532. --  Parameters:
  2533. --  ----------
  2534. --    Node  -  The object of type Node_Type
  2535. --    Name  - the value to be assigned
  2536. --
  2537. --  Exceptions:
  2538. --  ----------
  2539. --    None.
  2540. --
  2541. --  Notes:
  2542. --  -----
  2543. --
  2544. ---------------------------------------------------------------------
  2545.         procedure Set_Contents_File_Name(Node : in out Node_Type; 
  2546.                                          Name : String); 
  2547.                         -- left justified, padded w/ blanks
  2548.  
  2549. ------------------    O P E N _ S T A T U S     ---------------------
  2550. --
  2551. --  Purpose:
  2552. --  -------
  2553. --    This Boolean function returns the current open status of the 
  2554. --    specified node (True if open, False if not open).
  2555. --
  2556. --  Parameters:
  2557. --  ----------
  2558. --    Node  - node handle to be examined.
  2559. --
  2560. --  Exceptions:
  2561. --  ----------
  2562. --    None.
  2563. --
  2564. --  Notes:
  2565. --  -----
  2566. --
  2567. ---------------------------------------------------------------------
  2568.         function Open_Status(Node : Node_Type) return Boolean; 
  2569.  
  2570. ----------------------   S E T _ O P E N     ------------------------
  2571. --
  2572. --  Purpose:
  2573. --  -------
  2574. --    This procedure sets the open status of the specified node
  2575. --    according to the Boolean variable "Status".
  2576. --
  2577. --  Parameters:
  2578. --  ----------
  2579. --    Node   - Node handle to be affected
  2580. --    Status - Boolean that indicates the new open status of the
  2581. --             node (True = open, False = closed).
  2582. --
  2583. --  Exceptions:
  2584. --  ----------
  2585. --    None.
  2586. --
  2587. --  Notes:
  2588. --  -----
  2589. --
  2590. ---------------------------------------------------------------------
  2591.         procedure Set_Open(Node   : in out Node_Type; 
  2592.                            Status : Boolean); 
  2593.  
  2594.  
  2595.     end Node_Representation; 
  2596.  
  2597.  
  2598. ----------------------------------------------------------------------
  2599. --        N O D E _ I N T E R N A L S
  2600. --
  2601. --  Purpose:
  2602. --  -------
  2603. --      This package provides services to work with CAIS pathnames
  2604. --      and to support the implementation of CAIS nodes.
  2605. --
  2606. --  Usage:
  2607. --  -----
  2608. --    TBS
  2609. --
  2610. --  Example:
  2611. --  -------
  2612. --    TBS
  2613. --
  2614. --  Notes:
  2615. --  -----
  2616. --
  2617. --  Revision History:
  2618. --  ----------------
  2619. --
  2620. -------------------------------------------------------------------
  2621.  
  2622.     package Node_Internals is 
  2623.  
  2624.         use Node_Representation; 
  2625.         use Node_Definitions; 
  2626.         use List_Utilities; 
  2627.  
  2628.  
  2629. ----------------------  C R E A T E _ N O D E  ----------------------
  2630. --
  2631. --  Purpose:
  2632. --  -------
  2633. --    This procedure creates a node and installs the 
  2634. --    primary relationship to it.  The relation name and relationship
  2635. --    key of the primary relationship to the node and the base node
  2636. --    from which it emanates are given by the parameters Relation,
  2637. --    Key, and Base.  An open node handle to the newly created node
  2638. --    with Write intent is returned in Node.
  2639. --
  2640. --  Parameters:
  2641. --  ----------
  2642. --    Node        closed node handle to be opened to the new node
  2643. --    Base        open node handle to the node from which the primary
  2644. --                relationship to the new node is to emanate
  2645. --    Kind        the Node_Kind of the new node
  2646. --    Internals_Attributes  Node attributes that are NOT settable
  2647. --                by the user or that are part of the implementation.
  2648. --    User_Attributes  Node attributes that are settable by the user.
  2649. --    Key         relationship key of the primary relation to be created
  2650. --    Relation    relation name of the primary relation to be created
  2651. --
  2652. --  Exceptions:  (All Node_Definitions.-)
  2653. --  ----------
  2654. --    Name_Error        - if a node exists for the node identification
  2655. --                        given, if the node identification is illegal.
  2656. --    Security_Violation  if the operation violates mandatory access
  2657. --                        controls; raised only if conditions for other
  2658. --                        exceptions are not met.
  2659. --    Use_Error         if the User_Attributes list includes invalid
  2660. --                      node attributes or attributes not user-settable.
  2661. --
  2662. --  Notes:
  2663. --  -----
  2664. --     The calling routine is responsible for creating the 
  2665. --     contents file if this is a File node.
  2666. --
  2667. ---------------------------------------------------------------------
  2668.  
  2669.  
  2670.         procedure Create_Node(Node                 : in out Node_Type; 
  2671.                               Base                 : in out Node_Type; 
  2672.                               Kind                 : Node_Kind; 
  2673.                               Internals_Attributes : List_Type; 
  2674.                               User_Attributes      : List_Type; 
  2675.                               Internals_Relations  : List_Type; 
  2676.                               Intent               : Intention; 
  2677.                               Access_Control       : List_Type; 
  2678.                               Level                : List_Type; 
  2679.                               Key                  : String; 
  2680.                               Relation             : String); 
  2681.  
  2682.  
  2683. --------------------    R E A D _ S H A D O W _ F I L E   ------------
  2684. --
  2685. --  Purpose:
  2686. --  -------
  2687. --    This procedure loads a node handle with the information stored
  2688. --    in a shadow file.
  2689. --
  2690. --  Parameters:
  2691. --  ----------
  2692. --    Node  - Node_Type
  2693. --
  2694. --  Exceptions:
  2695. --  ----------
  2696. --    Cais_Internals_Exceptions.List_Too_Long  - if the text representation
  2697. --        of a list stored in the shadow file is too long (i.e. >
  2698. --        Pragmatics.Max_List_Length).
  2699. --    Cais_Internals_Exceptions.No_Such_Shadow_File  - if the shadow file
  2700. --        name given does not correspond to an accessable host file.
  2701. --
  2702. --  Notes:
  2703. --  -----
  2704. --    The fully qualified host file name for the shadow file must be
  2705. --    in the node handle already.
  2706. --
  2707. ---------------------------------------------------------------------
  2708.         procedure Read_Shadow_File(Node : in out Node_Type); 
  2709.  
  2710. ----------------    W R I T E _ S H A D O W _ F I L E     ------------
  2711. --
  2712. --  Purpose:
  2713. --  -------
  2714. --    Write a shadow file, containing the contents of some of the
  2715. --    components of a node handle.
  2716. --    If the named shadow file exists, it is replaced; if it does not
  2717. --    exist, it is created.
  2718. --
  2719. --  Parameters:
  2720. --  ----------
  2721. --    Name  - fully qualified name of the shadow file
  2722. --    Node  - Node handle (does NOT have to be open)
  2723. --
  2724. --  Exceptions:
  2725. --  ----------
  2726. --    Cais_Internals_Exceptions.No_Such_Shadow_File  - if the specified
  2727. --        name is empty (i.e. there is no shadow file name).
  2728. --
  2729. --  Notes:
  2730. --  -----
  2731. --    None.
  2732. --
  2733. ---------------------------------------------------------------------
  2734.         procedure Write_Shadow_File(Node : Node_Type); 
  2735.  
  2736. ----------------------  G E T _ P A R S E D _ P N  ------------------
  2737. --
  2738. --  Purpose:
  2739. --  -------
  2740. --    Given a name string, this procedure will "parse"it into the
  2741. --    consituent CAIS pathname components. 
  2742. --
  2743. --  Parameters:
  2744. --  ----------
  2745. --    Name    - the string to be parsed
  2746. --    Result  - the fully parsed components.
  2747. --
  2748. --  Exceptions:
  2749. --  ----------
  2750. --    Cais_Internals_Exceptions.Pathname_Syntax_Error  - if the supplied
  2751. --       string is not a syntactically valid pathname.
  2752. --    Cais_Internals_Exceptions.Internal_Error  - if the parse stack
  2753. --      becomes garbled.
  2754. --
  2755. --  Notes:
  2756. --  -----
  2757. --    None.
  2758. --
  2759. ---------------------------------------------------------------------
  2760.         procedure Get_Parsed_Pn(Name   : Node_Definitions.Name_String; 
  2761.                                 Result : in out Parsed_Pn); 
  2762.  
  2763. ------------------- P N _ C O M P O N E N T _ C O U N T -------------
  2764. --
  2765. --  Purpose:
  2766. --  -------
  2767. --    This function returns the number of distinct pathname components
  2768. --    (i.e. pathname elements) in the given parsed pathname.
  2769. --
  2770. --  Parameters:
  2771. --  ----------
  2772. --    Pn - the parsed pathname to be examined.
  2773. --
  2774. --  Exceptions:
  2775. --  ----------
  2776. --    None.
  2777. --
  2778. --  Notes:
  2779. --  -----
  2780. --
  2781. ---------------------------------------------------------------------
  2782.         function Pn_Component_Count(Pn : Parsed_Pn) return Natural; 
  2783.  
  2784. --------------------  G E T _ P N _ C O M P O N E N T ---------------
  2785. --
  2786. --  Purpose:
  2787. --  -------
  2788. --    This procedure extracts the data associated with a specific
  2789. --    pathname component (i.e. pathname element).
  2790. --
  2791. --  Parameters:
  2792. --  ----------
  2793. --    Pn         - parsed pathname to be examined
  2794. --    Index      - offset of path element to be examined
  2795. --    Rel_Name   - Relation name of this path element
  2796. --    Rel_Key    - Relationship Key of this path element
  2797. --    Latest_Rel - boolean indicating if the relationship key
  2798. --                 ends with the latest key character (#)
  2799. --
  2800. --  Exceptions:
  2801. --  ----------
  2802. --    No_Such_Component - raised if "Index" does not refer to
  2803. --                        an existing component in the pathname.
  2804. --
  2805. --  Notes:
  2806. --  -----
  2807. --
  2808. ---------------------------------------------------------------------
  2809.         procedure Get_Pn_Component(Pn         : Parsed_Pn; 
  2810.                                    Index      : Positive; 
  2811.                                    Rel_Name   : in out String; 
  2812.                                    Rel_Key    : in out String; 
  2813.                                    Latest_Rel : in out Boolean); 
  2814.  
  2815.     end Node_Internals; 
  2816.  
  2817.  
  2818. ----------------------------------------------------------------------
  2819. --                   C A I S _ U T I L I T I E S
  2820. --
  2821. --  Purpose:
  2822. --  -------
  2823. --    This package serves to collect together various simple utilities
  2824. --    used in the CAIS prototype.  None of the utilities use "internals"
  2825. --    knowledge, i.e. all the interfaces that are used by these routines
  2826. --    are either in the externally visible MIL-STD-CAIS specification or
  2827. --    are in standard libraries.
  2828. --
  2829. --  Usage:
  2830. --  -----
  2831. --
  2832. --  Example:
  2833. --  -------
  2834. --    The procedure String_To_Simple_List and Simple_List_To_String
  2835. --    are useful for avoiding the error-prone manipulation of String
  2836. --    Items in List_Utilities (and working with the leading and trailing
  2837. --    embedded "s). 
  2838. --
  2839. --  Notes:
  2840. --  -----
  2841. --
  2842. --  Revision History:
  2843. --  ----------------
  2844. --
  2845. -------------------------------------------------------------------
  2846.  
  2847.     package Cais_Utilities is 
  2848.  
  2849.         use List_Utilities; 
  2850.         use Node_Definitions; 
  2851.  
  2852.         type Predefined_Kind is (Attribute, Relation); 
  2853.  
  2854.         function Predefined(Name : String; 
  2855.                             Kind : Predefined_Kind) return Boolean; 
  2856.  
  2857.  
  2858. ----------------------  C H E C K _ I N T E N T I O N S ------------------
  2859. --
  2860. --  Purpose: 
  2861. --  ------- 
  2862. --    This procedure checks that a Node has been opened with an
  2863. --    intent that explicitly or implicitly grants the priveledges of
  2864. --    Intent specified as a parameter.
  2865. --
  2866. --  Parameters:
  2867. --  ----------
  2868. --    Node      is the Node to be accessed
  2869. --    Intent    is the stated intention for accessing the node
  2870. --
  2871. --  Exceptions:
  2872. --  ----------
  2873. --    Node_Definitions.INTENT_VIOLATION  - if the specified intent
  2874. --        is not explicitly or implicitly granted by the current
  2875. --        Intention of the Node
  2876. --    Node_Definitions.USE_ERROR        - if Node is not an open node handle
  2877. --
  2878. --  Notes:
  2879. --  -----
  2880. --
  2881. ---------------------------------------------------------------------------
  2882.         procedure Check_Intentions(Node     : in Node_Type; 
  2883.                                    Intended : in Intent_Specification); 
  2884.  
  2885. ----------------------  C H E C K _ I N T E N T I O N S ------------------
  2886. --
  2887. --  Purpose: 
  2888. --  ------- 
  2889. --    This procedure checks that a Node has been opened with an
  2890. --    intent that explicitly or implicitly grants the priveledges of
  2891. --    Intent specified as a parameter.
  2892. --
  2893. --  Parameters:
  2894. --  ----------
  2895. --    Node      is the Node to be accessed
  2896. --    Intent    is the stated intention for accessing the node
  2897. --
  2898. --  Exceptions:
  2899. --  ----------
  2900. --    Node_Definitions.INTENT_VIOLATION  - if the specified intent
  2901. --        is not explicitly or implicitly granted by the current
  2902. --        Intention of the Node
  2903. --    Node_Definitions.USE_ERROR        - if Node is not an open node handle
  2904. --
  2905. --  Notes:
  2906. --  -----
  2907. --
  2908. ---------------------------------------------------------------------------
  2909.  
  2910.         procedure Check_Intentions(Intent   : in Intention; 
  2911.                                    Intended : in Intent_Specification); 
  2912.  
  2913.         procedure Check_Intentions(Intent   : in Intention; 
  2914.                                    Intended : in Intention); 
  2915.  
  2916.         procedure String_To_Simple_List(Str  : String; 
  2917.                                         List : in out List_Type); 
  2918.  
  2919.         procedure Simple_List_To_String(List : List_Type; 
  2920.                                         Str  : in out String); 
  2921.  
  2922.     function Valid_Relation_Name (Name : String) return Boolean;
  2923.  
  2924.     function Valid_Relation_Key (Name : String) return Boolean;
  2925.  
  2926. ----------------------      Copy      ----------------------
  2927. --
  2928. --  Purpose:
  2929. --  -------
  2930. --    This procedure copies to host (Ada) files byte by byte.
  2931. --
  2932. --  Parameters:
  2933. --  ----------
  2934. --    From_File    string identifying the file to be copied
  2935. --    To_File     string identifying the file to be written
  2936. --
  2937. --  Exceptions:
  2938. --  ----------
  2939. --    I/O errors other than End_Error are propogated.
  2940. --  Notes:
  2941. --  -----
  2942. --    Uses Sequential_Io.
  2943. --
  2944. ---------------------------------------------------------------------
  2945.  
  2946.         procedure Copy(From_File : in String; 
  2947.                        To_File   : in String); 
  2948.  
  2949.     end Cais_Utilities; 
  2950.  
  2951.  
  2952. ----------------------------------------------------------------------
  2953. --                  C A I S _ H O S T _ D E P E N D E N T 
  2954. --                         (Package Specification)
  2955. --
  2956. --         Host specific services used by the CAIS implementation
  2957. --
  2958. --
  2959. --
  2960. --
  2961. --                  Ada Software Engineering Group
  2962. --                      The MITRE Corporation
  2963. --                         McLean, VA 22102
  2964. --
  2965. --                  Sat Apr 13 13:44:38 EST 1985
  2966. --
  2967. --                 (Unclassified and uncopyrighted)
  2968. --
  2969. ----------------------------------------------------------------------
  2970. ----------------------------------------------------------------------
  2971. --
  2972. --  Purpose:
  2973. --  -------
  2974. --    This package is used to isolate host dependent services used
  2975. --    in the implementation of the CAIS prototype.
  2976. --
  2977. --  Usage:
  2978. --  -----
  2979. --    These services are used mostly in Node_Internals subprograms.
  2980. --
  2981. --  Example:
  2982. --  -------
  2983. --    TBS
  2984. --
  2985. --  Notes:
  2986. --  -----
  2987. --    None.
  2988. --
  2989. --  Revision History:
  2990. --  ----------------
  2991. --
  2992. -------------------------------------------------------------------
  2993.     package Cais_Host_Dependent is 
  2994.  
  2995.         Cais_System_Node    : constant String := 
  2996.         "/usr/users/howell/cais/.SYSTEM_NODE";
  2997.  
  2998.         Cais_Host_Directory : constant String := 
  2999.         "/usr/users/howell/cais/shadowdir/"; 
  3000.  
  3001.         Top_User_Node       : constant String := ".TOP_NODE"; 
  3002.  
  3003.         Top_User_Process    : constant String := ".:"; 
  3004.  
  3005.     -- The following routines interface with host services for 
  3006.     -- terminal I/O control.  Currently, only interfaces to work with
  3007.     -- the "controlling terminal" for the program (e.g. std_out, std_in)
  3008.     -- are supported.  There are therefore no interfaces to work
  3009.     -- with a file type.
  3010.  
  3011.         procedure Unbuffered_Io_On; 
  3012.         procedure Unbuffered_Io_Off; 
  3013.         procedure Setecho_On; 
  3014.         procedure Setecho_Off; 
  3015.         function Get_Char return Character; 
  3016.         function Echo_Status return Boolean; 
  3017.  
  3018. -----------------  G E T _ U N I Q U E _ F I L E N A M E -------------
  3019. --
  3020. --  Purpose:
  3021. --  -------
  3022. --    This routine is used generate a filename that is unique for the
  3023. --    CAIS "Host Directory" (the shadowdir directory).  The
  3024. --    name of the shadowdir directory (Cais_Host_Dependent.Cais_Host_Directory)
  3025. --    is used as part of a template passed to create_uniq.
  3026. --    The filename returned is fully qualified.  The new file is
  3027. --    given a file protection mask of 777 (i.e. rwxrwxrwx).
  3028. --
  3029. --  Parameters:
  3030. --  ----------
  3031. --    Name   -  name of new file
  3032. --    Length - number of significant characters in Name
  3033. --
  3034. --  Exceptions:
  3035. --  ----------
  3036. --    Cais_Internals_Exceptions.Internal_Error - if create_uniq fails
  3037. --
  3038. --  Notes:
  3039. --  -----
  3040. --
  3041. ---------------------------------------------------------------------
  3042.  
  3043.         procedure Get_Unique_Filename(Name   : in out String; 
  3044.                                       Length : in out Natural); 
  3045.  
  3046. -------------------     G E T _ U S E R I D       --------------------
  3047. --
  3048. --  Purpose:
  3049. --  -------
  3050. --    This routine determines the CAIS userid for the calling process.
  3051. --
  3052. --  Parameters:
  3053. --  ----------
  3054. --    None (returns a string representing the userid).
  3055. --
  3056. --  Exceptions:
  3057. --  ----------
  3058. --    Cais_Internals_Exceptions.Cais_Userid_Undefined  if the current
  3059. --       process (user) does not have a CAIS userid defined.
  3060. --
  3061. --  Notes:
  3062. --  -----
  3063. --    In this Unix implementation, the userid is defined by setting
  3064. --    an environment variable.
  3065. --    For example, in the user's .login, a "setenv CAIS_USERID howell"
  3066. --    for the particular user.
  3067. --
  3068. ---------------------------------------------------------------------
  3069.         function Get_Userid return String; 
  3070.  
  3071. ---- C U R R E N T _ P R O C E S S _ S H A D O W _ F I L E ----------
  3072. --
  3073. --  Purpose:
  3074. --  -------
  3075. --    Returns the fully qualified name of the shadow file that 
  3076. --    contains information about the current process.
  3077. --
  3078. --  Parameters:
  3079. --  ----------
  3080. --    None.
  3081. --
  3082. --  Exceptions:
  3083. --  ----------
  3084. --    None.
  3085. --
  3086. --  Notes:
  3087. --  -----
  3088. --    This first cut is a "quick and dirty" version that deferrs any
  3089. --    intelligent handling of multiple processes or even multiple
  3090. --    users logged in under the same id.
  3091. --
  3092. ---------------------------------------------------------------------
  3093.         function Current_Process_Shadow_File return String; 
  3094.  
  3095. -----------------  G E T _ U S E R _ P R E F I X  -------------------
  3096. --
  3097. --  Purpose:
  3098. --  -------
  3099. --    Given a particular CAIS user id, this subprogram returns the
  3100. --    fully qualified host filename for the "user prefix"; this is
  3101. --    the prefix to be added to all references to host files (shadow
  3102. --    files) specific to that user.
  3103. --
  3104. --  Parameters:
  3105. --  ----------
  3106. --    Userid   - string that is the specified CAIS user.
  3107. --
  3108. --  Exceptions:
  3109. --  ----------
  3110. --     Cais_Internals_Exceptions.No_Such_User - if the specified
  3111. --         user is not in the system node.
  3112. --
  3113. --  Notes:
  3114. --  -----
  3115. --    None.
  3116. --
  3117. ---------------------------------------------------------------------
  3118.         function Get_User_Prefix(Userid : String) return String; 
  3119.  
  3120. ----------------------  F I L E _ E X I S T S  ----------------------
  3121. --
  3122. --  Purpose:
  3123. --  -------
  3124. --    This routine determines if a given string refers to an accessable
  3125. --    host file.
  3126. --
  3127. --  Parameters:
  3128. --  ----------
  3129. --    Name  - the string representing the host file name.
  3130. --
  3131. --  Exceptions:
  3132. --  ----------
  3133. --    None.
  3134. --
  3135. --  Notes:
  3136. --  -----
  3137. --
  3138. ---------------------------------------------------------------------
  3139.         function File_Exists(Name : String) return Boolean; 
  3140.  
  3141.     private
  3142.  
  3143.         pragma Interface(C, Setecho_Off); 
  3144.         pragma Interface(C, Setecho_On); 
  3145.  
  3146.     end Cais_Host_Dependent; 
  3147.  
  3148. ----------------------------------------------------------------------
  3149. --        I T E R A T O R _ S U P P O R T
  3150. --
  3151. --  Purpose:
  3152. --  --------
  3153. --    This   package  provides  routines  which  support  pattern  matching
  3154. --    (including * and ? wild card characters)  and the  creation of sorted
  3155. --    lists.  These  capabilities are  required  for the  implementation of
  3156. --    Node and Attribute Iterators.  The iterator is  implemented as a list
  3157. --    of the format defined by the  package  list_utilities (MIL-STD CAIS
  3158. --    section  5.4).
  3159. --
  3160. --  Usage:
  3161. --  -----
  3162. --    Patterns are represented by character strings, which must conform  to
  3163. --    the rules for Ada identifiers except that wildcard characters  may be
  3164. --    included.  A routine is provided to validate patterns to these rules.
  3165. --    Another routine matches a token against a  pattern and another  finds
  3166. --    the lexicographic position within an already sorted list at which  to
  3167. --    insert a token.
  3168. --
  3169. --  Example:
  3170. --  -------
  3171. --    Verify_Pattern("*_body?");            --valid pattern
  3172. --    Verify_Pattern("*__spec");            --use_error __
  3173. --    Verify_Pattern("*.body?");            --use_error . no good
  3174. --                --checks attribute against pattern and if
  3175. --                --it matches saves it in alphabetized list
  3176. --    if Pattern_Match(Attribute,"T???") then
  3177. --        Insert(Found, Attribute, Lexical_Position(Found, Attribute));
  3178. --    end if;
  3179. --
  3180. --  Notes:
  3181. --  -----
  3182. --    This is a version of the package CAIS_ATTRIBUTES,  specified  in
  3183. --    MIL-STD-CAIS section 5.1.3; all references to the CAIS specification
  3184. --    refer to the MIL-STD-CAIS specification dated 31 January 1985.
  3185. --
  3186. --  Revision History:
  3187. --  ----------------
  3188. --
  3189. -------------------------------------------------------------------
  3190.     package Iterator_Support is 
  3191.  
  3192.         use List_Utilities; 
  3193.  
  3194. ----------------------   Lexical_Position     ---------------------------
  3195. --
  3196. --  Purpose: This function searches an alphebetized list returning the
  3197. --  -------  position at which the new named item should be inserted
  3198. --
  3199. --  Parameters:
  3200. --  ----------
  3201. --    List    is the named list being searched (names are assumed to be sorted)
  3202. --    Name    is the name of the new item to be inserted
  3203. --    returns Pos where the named item should be inserted
  3204. --
  3205. --  Exceptions:
  3206. --  ----------
  3207. --   None
  3208. --
  3209. --  Notes:
  3210. --  -----
  3211. --
  3212. ---------------------------------------------------------------------------
  3213.         function Lexical_Position(List : in List_Type; 
  3214.                                   Name : in Token_Type) return Count; 
  3215.  
  3216.  
  3217.  
  3218. ----------------------   Verify_Pattern   --------------------------------
  3219. --
  3220. --  Purpose: This procedure checks that a Pattern string conforms to the
  3221. --  -------  syntax for identifiers with the addition of wildcard characters
  3222. --           '?' and '*'.  It also allows trailing blanks and returns the
  3223. --           length of the pattern minus any trailing blanks.
  3224. --
  3225. --  Parameters:
  3226. --  ----------
  3227. --    Pattern      is the pattern string to be checked for conformance
  3228. --    Size       is returned with the length of Pattern less trailing ' 's
  3229. --
  3230. --  Exceptions:
  3231. --  ----------
  3232. --   Use_Error       is raised if the pattern fails conformance
  3233. --
  3234. --
  3235. --  Notes:
  3236. --  -----
  3237. --
  3238. ---------------------------------------------------------------------------
  3239.         procedure Verify_Pattern(Pattern : in String; 
  3240.                                  Size    : in out Integer); 
  3241.  
  3242.  
  3243.  
  3244. ----------------------   Pattern_Match   ---------------------------
  3245. --
  3246. --  Purpose: returns true if Canditate string conforms to the pattern
  3247. --  -------  which may contain ?s (any character) or *s (any string).
  3248. --
  3249. --  Parameters:
  3250. --  ----------
  3251. --    Candidate is a character string to be checked for conformance
  3252. --    Pattern   is a character string which defines conformance rules
  3253. --
  3254. --  Exceptions: None
  3255. --  ----------
  3256. --
  3257. --  Notes:
  3258. --  -----
  3259. --
  3260. ---------------------------------------------------------------------------
  3261.         function Pattern_Match(Candidate : in String; 
  3262.                                         --string to be checked
  3263.                                Pattern   : in String)
  3264.                                         --acceptance criteria
  3265.         return Boolean; 
  3266.  
  3267.     end Iterator_Support; 
  3268.  
  3269.  
  3270.  
  3271. --    Implementation support packages
  3272.  
  3273.     package body Node_Representation is separate; 
  3274.     package body Node_Internals is separate; 
  3275.     package body Cais_Utilities is separate; 
  3276.     package body Cais_Host_Dependent is separate; 
  3277.     package body Iterator_Support is separate; 
  3278.  
  3279. --    CAIS packages
  3280.     package body Node_Management is separate; 
  3281.  
  3282.     package body Attributes is separate; 
  3283.  
  3284.     package body Access_Control is separate; 
  3285.  
  3286.     package body Structural_Nodes is separate; 
  3287.  
  3288.     package body Process_Control is separate; 
  3289.  
  3290.     package body Io_Definitions is separate; 
  3291.  
  3292.     package body Direct_Io_Definitions is separate; 
  3293.  
  3294.     package body Sequential_Io_Definitions is separate; 
  3295.  
  3296.     package body Direct_Io is separate; 
  3297.  
  3298.     package body Sequential_Io is separate; 
  3299.  
  3300.     package body Text_Io is separate; 
  3301.  
  3302.     package body Io_Control is separate; 
  3303.  
  3304.     package body Scroll_Terminal is separate; 
  3305.  
  3306.     package body Page_Terminal is separate; 
  3307.  
  3308.     package body Form_Terminal is separate; 
  3309.  
  3310.     package body Magnetic_Tape is separate; 
  3311.  
  3312.     package body File_Import_Export is separate; 
  3313.  
  3314.     package body List_Utilities is separate; 
  3315.  
  3316. -- not in CAIS specification
  3317.  
  3318.     procedure Add_User is separate; 
  3319.     procedure Delete_User is separate; 
  3320.  
  3321. begin
  3322.  
  3323.     --elaboration time preset
  3324.     List_Utilities.To_List("(" & "Access" & "=> N" & "," & "Adopted_Role" & 
  3325.         "=> N" & "," & "Allow_Access" & "=> N" & "," & "Couple" & "=> N" & ","
  3326.         & "Current_Error" & "=> N" & "," & "Current_Input" & "=> N" & "," & 
  3327.         "Current_Job" & "=> N" & "," & "Current_Node" & "=> N" & "," & 
  3328.         "Current_Output" & "=> N" & "," & "Current_User" & "=> N" & "," & 
  3329.         "Device" & "=> N" & "," & 
  3330.                             --  "Dot"             & "=> N"    & "," &
  3331.     "Job" & "=> N" & "," & "Parent" & "=> N" & "," & "Permanent_Member" & "=> N"
  3332.         & "," & "Potential_Member" & "=> N" & "," & "Standard_Error" & "=> N"
  3333.         & "," & "Standard_Input" & "=> N" & "," & "Standard_Output" & "=> N" & 
  3334.         "," & "User" & "=> N" & ")", Predefined_Relations); 
  3335.  
  3336.  
  3337.     --elaboration time preset
  3338.     List_Utilities.To_List("(" & "Access_Method" & "=> N" & "," & 
  3339.         "Current_Status" & "=> N" & "," & "File_Kind" & "=> N" & "," & 
  3340.         "Finish_Time" & "=> N" & "," & "Grant" & "=> N" & "," & "Handles" & 
  3341.         "=> N" & "," & "Highest_Classification" & "=> N" & "," & "Io_Units" & 
  3342.         "=> N" & "," & "Kind" & "=> N" & "," & "Lowest_Classification" & "=> N"
  3343.         & "," & "Machine_Time" & "=> N" & "," & "Object_Classification" & 
  3344.         "=> N" & "," & "Parameters" & "=> N" & "," & "Queue_Kind" & "=> N" & ","
  3345.         & "Results" & "=> N" & "," & "Start_Time" & "=> N" & "," & 
  3346.         "Subject_Classification" & "=> N" & "," & "Terminal_Kind" & "=> N" & ")"
  3347.         , Predefined_Attributes); 
  3348.  
  3349. end Cais; 
  3350. --::::::::::::::
  3351. --cais_direct_io_body.a
  3352. --::::::::::::::
  3353.  
  3354.  
  3355.  
  3356. ----------------------------------------------------------------------
  3357. --                   Package  D I R E C T _ I O
  3358. --            (Package Body)
  3359. --
  3360. --            CAIS Direct_Io Access Method
  3361. --           Operations for File Node Input/Output
  3362. --
  3363. --
  3364. --
  3365. --                  Ada Software Engineering Group
  3366. --                      The MITRE Corporation
  3367. --                         McLean, VA 22102
  3368. --
  3369. --
  3370. --            Wed Oct  9 14:37:11 EDT 1985
  3371. --
  3372. --                 (Unclassified and uncopyrighted)
  3373. --
  3374. ----------------------------------------------------------------------
  3375. ----------------------------------------------------------------------
  3376. --                  C A I S _ D I R E C T _ I O
  3377. --
  3378. --  Purpose:
  3379. --  -------
  3380. --        This package provides facilities for direct-access input
  3381. --        and output to CAIS file comparable to those described
  3382. --        in the DIRECT_IO package of the Ada LRM.
  3383. --
  3384. --  Usage:
  3385. --  -----
  3386. --        Usage is analogous to usage of the Ada Direct_Io 
  3387. --        package.  The package is instantiated with the element
  3388. --        type of the file as parameter.  CAIS file nodes 
  3389. --        correspond to ordinary Ada files, and file handles are 
  3390. --        Ada objects of CAIS subtype Direct_Io.File_Type,
  3391. --        corresponding to the Ada (LRM) Direct_Io.File_Type.
  3392. --        CAIS Direct_Io input and output operations 
  3393. --        access the contents of CAIS file nodes.
  3394. --
  3395. --  Notes:
  3396. --  -----
  3397. --        This is a version of the package CAIS.DIRECT_IO,
  3398. --        specified in MIL-STD-CAIS section 5.3.2; all references
  3399. --        to the CAIS specification refer to the CAIS specification
  3400. --        dated 31 January 1985.  This implementation deviates 
  3401. --        from the CAIS specification in that a distinct type,
  3402. --        File_Type is employed in the package, following the
  3403. --        Ada LRM.  The package instantiates another generic 
  3404. --        package, direct_io_definitions, that supports the 
  3405. --        abstract data type, File_Type.
  3406. --
  3407. --  Revision History:
  3408. --  ----------------
  3409. --        None.
  3410. --
  3411. -------------------------------------------------------------------
  3412.  
  3413. with Direct_Io; 
  3414. with Unchecked_Conversion; 
  3415.  
  3416. separate(Cais)
  3417. package body Direct_Io is 
  3418.  
  3419.     use Node_Definitions; 
  3420.     use Node_Representation; 
  3421.     use Node_Management; 
  3422.     use Node_Internals; 
  3423.     use Cais_Utilities; 
  3424.     use List_Utilities; 
  3425.     use Dir_Io_Definitions; 
  3426.     use Identifier_Items; 
  3427.     use Trace; 
  3428.  
  3429.                                         -- Local instantiation to provide
  3430.                                         --   access to Direct_Io operations
  3431.                                         --   using unchecked conversion from
  3432.                                         --   corresponding definition of
  3433.                                         --   pointer to Ada File_Type in private
  3434.                                         --   part of Direct_Io_Definitions
  3435.     package Dir_Io is 
  3436.         new Standard.Direct_Io(Element_Type); 
  3437.     type File_Ptr is access Dir_Io.File_Type; 
  3438.     function Convert is 
  3439.         new Unchecked_Conversion(Direct_File_Ptr, File_Ptr); 
  3440.  
  3441.     type Mode_Array is array(Positive range <>) of File_Mode; 
  3442.  
  3443.   ----------------------------   Check_Open   -----------------------------
  3444.   --
  3445.   --    Local procedure which checks that file handle has required open status
  3446.   --
  3447.   ---------------------------------------------------------------------------
  3448.  
  3449.     procedure Check_Open(File            : File_Type; 
  3450.                          Required_Result : Boolean) is 
  3451.     begin
  3452.         if Is_Open(File) /= Required_Result then 
  3453.             raise Dir_Io_Definitions.Status_Error; 
  3454.         end if; 
  3455.     end Check_Open; 
  3456.  
  3457.   ----------------------------   Check_Open   -----------------------------
  3458.   --
  3459.   --    Local procedure which checks that node handle has required open status
  3460.   --
  3461.   ---------------------------------------------------------------------------
  3462.  
  3463.     procedure Check_Open(Node            : Cais.Node_Type; 
  3464.                          Required_Result : Boolean) is 
  3465.     begin
  3466.         if Is_Open(Node) /= Required_Result then 
  3467.             raise Node_Definitions.Status_Error; 
  3468.         end if; 
  3469.     end Check_Open; 
  3470.  
  3471. ---------------------------    Check_Not_Mode    --------------------------------
  3472. --
  3473. --    Local procedure which checks that mode is not in array of
  3474. --    excluded modes
  3475. --
  3476. -------------------------------------------------------------------------------
  3477.  
  3478.     procedure Check_Not_Mode(File      : File_Type; 
  3479.                              Bad_Modes : Mode_Array) is 
  3480.     begin
  3481.         for I in Bad_Modes'range loop
  3482.             if Bad_Modes(I) = Mode(File) then 
  3483.                 raise Mode_Error; 
  3484.             end if; 
  3485.         end loop; 
  3486.     end Check_Not_Mode; 
  3487.  
  3488. ---------------------------- Validate_Mode -----------------------------------
  3489. --
  3490. --    Local procedure which checks that Mode and intent of file_node
  3491. --    specified by File are consistent, and determines corresponding
  3492. --    Text_Io File_Mode.
  3493. --
  3494. -------------------------------------------------------------------------------
  3495.  
  3496.     procedure Validate_Mode(File       : File_Type; 
  3497.                             Mode       : File_Mode; 
  3498.                             Directmode : in out Dir_Io.File_Mode) is 
  3499.         Intent   : Intention(Pragmatics.Intent_Count); 
  3500.         Intended : Intention(1 .. 2); 
  3501.     begin
  3502.                                                         --Determine mode and
  3503.                                                         --check intentions
  3504.         Get_Intent(File, Intent); 
  3505.         case Mode is 
  3506.             when In_File => 
  3507.                 Directmode := Dir_Io.In_File; 
  3508.                 Check_Intentions(Intent, Read_Contents); 
  3509.             when Out_File => 
  3510.                 Directmode := Dir_Io.Out_File; 
  3511.                 Check_Intentions(Intent, Write_Contents); 
  3512.             when Inout_File => 
  3513.                 Directmode := Dir_Io.Inout_File; 
  3514.                 Check_Intentions(Intent, (1 => Read_Contents, 2 => 
  3515.                     Write_Contents)); 
  3516.         end case; 
  3517.  
  3518.     end Validate_Mode; 
  3519.  
  3520. ----------------------     Create     ----------------------
  3521. --
  3522. --  Purpose:
  3523. --  -------
  3524. --        This procedure creates a file and its file node; the
  3525. --        file contains elements which may be accessed either
  3526. --        directly or sequentially.  The attribute Access_Method is
  3527. --        assigned the value "(Direct,Sequential)" as part of the creation.
  3528. --
  3529. --  Parameters:
  3530. --  ----------
  3531. --    File    file handle, initially closed, to be opened.
  3532. --    Base    open node handle to the node which will be the
  3533. --        source of the primary relationship to the new
  3534. --        node.
  3535. --    Key    relationship key of the primary relationship to
  3536. --        be created.
  3537. --    Relation    relation name of the primary relationship to be created.
  3538. --    Mode    indicates mode of the file.
  3539. --    Form    indicates file characteristics.
  3540. --    Attributes
  3541. --        initial values for attributes of the new node.
  3542. --    Access_Control
  3543. --        defines the initial access control information
  3544. --        associated with the created node.
  3545. --    Level    defines the classification label for the created node.
  3546. --
  3547. --  Exceptions:
  3548. --  ----------
  3549. --    Name_Error
  3550. --        raised if a node already exists for the node specified
  3551. --        by Key and Relation or if Key or Relation is syntactically
  3552. --        illegal or if any node identifying a group specified in the
  3553. --        given Access_Control parameter is unobtainable.
  3554. --    Use_Error
  3555. --        raised if any of the parameters Access_Control, Level or
  3556. --        Attributes is syntactically or semantically illegal.
  3557. --        Use_Error is also raised if Relation is the name of a
  3558. --        predefined attribute other than File_Kind.  Also raised if
  3559. --        Relation is the name of a predefined relation which cannnot
  3560. --        be created by the user.
  3561. --    Status_Error
  3562. --        raised if Base is not an open node handle or if File is
  3563. --        an open file handle prior to the call.
  3564. --    Intent_Violation
  3565. --        raised if Base was not opened with an intent establishing
  3566. --        the right to append relationships.
  3567. --    Security_Violation
  3568. --        raised if the operation represents a violation of mandatory
  3569. --        access controls; raised only if the conditions for other
  3570. --        exceptions are not present.
  3571. --
  3572. --  Notes:
  3573. --  -----
  3574. --    This procedure is defined in section 5.3.2.2 of MIL-STD-CAIS,
  3575. --    dated 31 January 1985.
  3576. --    The additional interface for Create that is presented is
  3577. --    also provided.
  3578. --    NOTE:  The exception handler semantics of the additional
  3579. --    interface are not adequate.  The unconditional Close file
  3580. --    call may raise a Status_Error, causing the original
  3581. --    exception to be lost.
  3582. --
  3583. ---------------------------------------------------------------------
  3584.  
  3585.     procedure Create(File           : in out File_Type; 
  3586.                      Base           : in out Node_Type; 
  3587.                      Key            : Relationship_Key := Latest_Key; 
  3588.                      Relation       : Relation_Name := Default_Relation; 
  3589.                      Mode           : File_Mode := Inout_File; 
  3590.                      Form           : List_Type := Empty_List; 
  3591.                      Attributes     : List_Type := Empty_List; 
  3592.                      Access_Control : List_Type := Empty_List; 
  3593.                      Level          : List_Type := Empty_List) is 
  3594.  
  3595.  
  3596.         Node                   : Node_Type; 
  3597.                                         --Node to be created and associated
  3598.                                         --with this File
  3599.         Kind                   : constant Node_Kind := Node_Definitions.File; 
  3600.         Intent                 : Intention(1 .. 2); 
  3601.         Direct_File_Mode       : File_Mode; 
  3602.         Form_String            : String(1 .. 100); 
  3603.  
  3604.         User_Attributes        : List_Type; 
  3605.         Predefined_Attributes  : List_Type; 
  3606.         Predefined_Relations   : List_Type; 
  3607.  
  3608.         New_Contents_File_Name : String(1 .. Pragmatics.Max_Contents_File_Length
  3609.             ); 
  3610.         File_Name_Length       : Natural; 
  3611.         Last                   : Natural; 
  3612.  
  3613.   ---------------------------  Establish_Intent  ------------------------------
  3614.   --
  3615.   --    Local procedure which converts Mode parameter to Intent vector
  3616.   --    for node handle of new file node.
  3617.   --
  3618.   -----------------------------------------------------------------------------
  3619.  
  3620.         procedure Establish_Intent is 
  3621.         begin
  3622.             case Mode is 
  3623.                 when In_File => 
  3624.                     Intent := (1 => Read_Contents, 2 => Existence); 
  3625.                 when Out_File => 
  3626.                     Intent := (1 => Write_Contents, 2 => Existence); 
  3627.                 when Inout_File => 
  3628.                     Intent := (1 => Read_Contents, 2 => Write_Contents); 
  3629.             end case; 
  3630.         end Establish_Intent; 
  3631.  
  3632.   -------------------------- Filter_Relationships ----------------------------
  3633.   --
  3634.   --    Local procedure which screens initial values for predefined 
  3635.   --    relationships of new file node.
  3636.   --    (Note:  this procedure is stubbed.)
  3637.   --
  3638.   ----------------------------------------------------------------------------
  3639.  
  3640.         procedure Filter_Relationships is 
  3641.         begin
  3642.             Copy(Predefined_Relations, Empty_List); 
  3643.         end Filter_Relationships; 
  3644.  
  3645.  
  3646.   -------------------------- Filter_Attributes -------------------------------
  3647.   --
  3648.   --    Local procedure which screens initial values for predefined 
  3649.   --    attributes of new file node.
  3650.   --    Attributes are divided into two lists, one for user attributes
  3651.   --    and one for predefined attributes.
  3652.   --
  3653.   ----------------------------------------------------------------------------
  3654.  
  3655.         procedure Filter_Attributes is 
  3656.  
  3657.             Attribute             : List_Type; 
  3658.             Name                  : Token_Type; 
  3659.             List_Value            : List_Type; 
  3660.  
  3661.             File_Kind             : Token_Type; 
  3662.             File_Kind_Present     : Boolean := False; 
  3663.             File_Kind_Value       : List_Type; 
  3664.             Secondary_Storage     : List_Type; 
  3665.  
  3666.             Access_Method         : Token_Type; 
  3667.             Access_Method_Present : Boolean := False; 
  3668.             Access_Method_Value   : List_Type; 
  3669.             Direct                : Token_Type; 
  3670.             Sequential            : Token_Type; 
  3671.  
  3672.             Position              : Position_Count; 
  3673.             Value_Kind            : Item_Kind; 
  3674.  
  3675.             Result_List           : List_Type; 
  3676.  
  3677.  
  3678.         --------------------------  Check_And_Set  ------------------------
  3679.         --
  3680.         --    Local procedure which checks and sets a Boolean variable used
  3681.         --    for recording predefined attributes seen.
  3682.         --
  3683.         ----------------------------------------------------------------------
  3684.  
  3685.             procedure Check_And_Set(Attribute_Present : in out Boolean) is 
  3686.             begin
  3687.                 if Attribute_Present then 
  3688.                     Trace.Report(
  3689.                         "CAIS Use_Error: Duplicate attribute in Cais.Direct_Io.Create"
  3690.                         ); 
  3691.                     raise Node_Definitions.Use_Error; 
  3692.                 else 
  3693.                     Attribute_Present := True; 
  3694.                 end if; 
  3695.             end Check_And_Set; 
  3696.  
  3697.  
  3698.         -------------------------  Check_Syntax  ------------------------
  3699.         --
  3700.         --    Local procedure used for checking that list elements have
  3701.         --    the required item kind.
  3702.         --
  3703.         -----------------------------------------------------------------
  3704.  
  3705.             procedure Check_Syntax(Value_Kind    : Item_Kind; 
  3706.                                    Required_Kind : Item_Kind) is 
  3707.             begin
  3708.                 if Value_Kind /= Required_Kind then 
  3709.                     Trace.Report(
  3710.                         "CAIS Use_Error: Bad attribute value in Cais.Direct_Io.Create"
  3711.                         ); 
  3712.                     raise Dir_Io_Definitions.Use_Error; 
  3713.                 end if; 
  3714.             end Check_Syntax; 
  3715. ------------------------------------------------------------------------------
  3716.  
  3717.         begin
  3718.  
  3719.         -- Validate and filter predefined attributes
  3720.         --  into a list of initial values for predefined
  3721.         --  attributes, and a list of attributes which are
  3722.         --  user attributes to be created.
  3723.             Copy(User_Attributes, Empty_List); 
  3724.             Copy(Predefined_Attributes, Empty_List); 
  3725.             To_Token("File_Kind", File_Kind); 
  3726.             To_List("(Secondary_Storage)", Secondary_Storage); 
  3727.             To_Token("Access_Method", Access_Method); 
  3728.             To_Token("Direct", Direct); 
  3729.             To_Token("Sequential", Sequential); 
  3730.                                         -- Set defaults
  3731.             To_List("(Secondary_Storage)", File_Kind_Value); 
  3732.             To_List("(Direct,Sequential)", Access_Method_Value); 
  3733.  
  3734.                                         -- Filter attribute list
  3735.             if Get_List_Kind(Attributes) = Unnamed then 
  3736.                 raise Dir_Io_Definitions.Use_Error; 
  3737.             end if; 
  3738.  
  3739.             for I in 1 .. Length(Attributes) loop
  3740.  
  3741.                                                 -- extract and check attributes
  3742.                 Value_Kind := Get_Item_Kind(Attributes, I); 
  3743.                 Check_Syntax(Value_Kind, List_Item); 
  3744.                 Item_Name(Attributes, I, Name); 
  3745.                 if Predefined(To_Text(Name), Cais_Utilities.Attribute) then 
  3746.                                                 -- check for File_Kind
  3747.                     if Is_Equal(Name, File_Kind) then 
  3748.                         Check_And_Set(File_Kind_Present); 
  3749.                         Extract(Attributes, File_Kind, File_Kind_Value); 
  3750.                         if not Is_Equal(File_Kind_Value, Secondary_Storage)
  3751.                             then               -- copy value
  3752.                             Trace.Report(
  3753.                                 "CAIS Use_Error: Invalid File_Kind in Cais.Direct_Io.Create"
  3754.                                 ); 
  3755.                             raise Dir_Io_Definitions.Use_Error; 
  3756.                         end if; 
  3757.  
  3758.  
  3759.                                                 -- check for Access_Method
  3760.                     elsif Is_Equal(Name, Access_Method) then 
  3761.                         Check_And_Set(Access_Method_Present); 
  3762.                         Extract(Attributes, Access_Method, List_Value); 
  3763.  
  3764.                         begin   -- DIRECT, SEQUENTIAL must be included 
  3765.                             Position := Position_By_Value(List_Value, Direct); 
  3766.                             Position := Position_By_Value(List_Value, Sequential
  3767.                                 ); 
  3768.                             Copy(Access_Method_Value, List_Value); 
  3769.                         exception
  3770.                             when Search_Error => 
  3771.                                 Trace.Report(
  3772.                                     "CAIS Use_Error: Invalid Access_Method in Cais.Direct_Io.Create"
  3773.                                     ); 
  3774.                                 raise Dir_Io_Definitions.Use_Error; 
  3775.                             when others => 
  3776.                                 raise; 
  3777.                         end; 
  3778.  
  3779.  
  3780.                     else 
  3781.                         Trace.Report(
  3782.                             "CAIS Use_Error: Invalid predefined attribute in Cais.Direct_Io.Create"
  3783.                             ); 
  3784.                         raise Dir_Io_Definitions.Use_Error; 
  3785.                     end if; 
  3786.  
  3787.                 else            -- others must be user attributes
  3788.                     Extract(Attributes, Name, List_Value); 
  3789.                     Insert(User_Attributes, List_Value, Name, 0); 
  3790.                 end if; 
  3791.             end loop; 
  3792.  
  3793.                                         -- Attribute filter completed
  3794.                                         -- Construct predefined attribute list
  3795.  
  3796.                                         -- Initial value for Access_Method attr
  3797.             Insert(Predefined_Attributes, Access_Method_Value, Access_Method, 0)
  3798.                 ; 
  3799.  
  3800.             Insert(Predefined_Attributes, File_Kind_Value, File_Kind, 0); 
  3801.  
  3802.         end Filter_Attributes; 
  3803.  
  3804.  
  3805.   -----------------------  Establish_Contents_File  ---------------------------
  3806.   --
  3807.   --    Local procedure used to obtain a uniquely-named contents file
  3808.   --    for the new file node, and record its name in the node handle.
  3809.   --
  3810.   -----------------------------------------------------------------------------
  3811.  
  3812.         procedure Establish_Contents_File is 
  3813.         begin
  3814.             Cais_Host_Dependent.Get_Unique_Filename(New_Contents_File_Name, 
  3815.                 File_Name_Length); 
  3816.             Set_Contents_File_Name(Node, New_Contents_File_Name(1 .. 
  3817.                 File_Name_Length)); 
  3818.  
  3819.         end Establish_Contents_File; 
  3820.  
  3821.     begin-- Cais.Direct_Io.Create 
  3822.  
  3823.         Check_Open(Base, True); 
  3824.                               -- check that node handle is open
  3825.                                 -- (Node_Definitions.Status_Error)
  3826.         Check_Open(File, False); 
  3827.                                -- check that file handle is not open
  3828.                                 -- (Dir_Io_Definitions.Status_Error)
  3829.         Establish_Intent; 
  3830.         Filter_Relationships; 
  3831.         Filter_Attributes; 
  3832.         Establish_Contents_File; 
  3833.         Initialize(File); 
  3834.  
  3835.         -- Actually create the new file node
  3836.         --   (establishes its shadow file, checks status, sets attributes,
  3837.         --    opens file node)
  3838.         Node_Internals.Create_Node(Node => Node, Base => Base, Kind => Kind, 
  3839.             Internals_Attributes => Predefined_Attributes, User_Attributes => 
  3840.             User_Attributes, Internals_Relations => Predefined_Relations, Intent
  3841.             => Intent, Access_Control => Access_Control, Level => Level, Key
  3842.             => Key, Relation => Relation); 
  3843.  
  3844.         -- Open the file handle
  3845.         Open(File, Node, Mode); 
  3846.  
  3847.     exception
  3848.     -- exceptions that are trapped (nothing propagated)
  3849.  
  3850.     -- exceptions that are propagated
  3851.         when Dir_Io_Definitions.Name_Error | Dir_Io_Definitions.Use_Error | 
  3852.             Dir_Io_Definitions.Status_Error | Dir_Io_Definitions.Device_Error | 
  3853.             Node_Definitions.Intent_Violation | Node_Definitions.
  3854.             Security_Violation => 
  3855.             raise; 
  3856.  
  3857.     -- exceptions that are mapped to other exceptions
  3858.  
  3859.         when Node_Definitions.Name_Error => 
  3860.             raise Dir_Io_Definitions.Name_Error; 
  3861.         when Node_Definitions.Use_Error => 
  3862.             raise Dir_Io_Definitions.Use_Error; 
  3863.         when Node_Definitions.Status_Error => 
  3864.             raise Dir_Io_Definitions.Status_Error; 
  3865.  
  3866.     -- predefined exceptions (propagated with trace)
  3867.         when Constraint_Error | Tasking_Error | Program_Error | Storage_Error | 
  3868.             Numeric_Error => 
  3869.             Trace.Report("PREDEFINED EXCEPTION in Cais.Direct_Io.Create "); 
  3870.             raise; 
  3871.  
  3872.     -- unanticipated exceptions
  3873.         when others => 
  3874.             Trace.Report("UNANTICIPATED EXCEPTION in Cais.Direct_Io.Create "); 
  3875.             raise Trace.Assertion_Violation; 
  3876.  
  3877.     end Create; 
  3878. -------------------------------------------------------------------------------
  3879. --
  3880. --    Alternate interface using Name (pathname) rather than Base, Relation,
  3881. --    and Key to refer to file node.
  3882. --
  3883. -------------------------------------------------------------------------------
  3884.  
  3885.  
  3886.     procedure Create(File           : in out File_Type; 
  3887.                      Name           : Name_String; 
  3888.                      Mode           : File_Mode := Inout_File; 
  3889.                      Form           : List_Type := Empty_List; 
  3890.                      Attributes     : List_Type := Empty_List; 
  3891.                      Access_Control : List_Type := Empty_List; 
  3892.                      Level          : List_Type := Empty_List) is 
  3893.         Base : Node_Type; 
  3894.     begin
  3895.         Open(Base, Base_Path(Name), (1 => Append_Relationships)); 
  3896.         Create(File, Base, Last_Key(Name), Last_Relation(Name), Mode, Form, 
  3897.             Attributes, Access_Control, Level); 
  3898.         Close(Base); 
  3899.     exception
  3900.         when others => 
  3901.             Close(File); 
  3902.             Close(Base); 
  3903.             raise; 
  3904.     end Create; 
  3905. ----------------------     Open     ----------------------
  3906. --
  3907. --  Purpose:
  3908. --  -------
  3909. --    This procedure opens a file handle on a file containing
  3910. --    elements of the generic parameter type, given an open node
  3911. --    handle on the file node.
  3912. --
  3913. --  Parameters:
  3914. --  ----------
  3915. --    File    file handle, initially closed, to be opened.
  3916. --    Node    open node handle to the file node.
  3917. --    Mode    indicates the mode of the file.
  3918. --
  3919. --  Exceptions:
  3920. --  ----------
  3921. --    Use_Error
  3922. --        raised if the attribute Access_Method of the file node
  3923. --        does not have the value Direct, the element type of the
  3924. --        file does not correspond with the element type of this
  3925. --        instantiation of the CAIS Direct_Io package, or the Mode
  3926. --        is Append_File.
  3927. --
  3928. --    Status_Error
  3929. --        raised if File is an open file handle at the time of the call
  3930. --        or if Node is not an open node handle.
  3931. --
  3932. --    Intent_Violation
  3933. --        raised if Node has not been opened with an intent 
  3934. --        establishing the access rights required for the Mode.
  3935. --
  3936. --  Notes:
  3937. --  -----
  3938. --    This procedure is defined in section 5.3.2.3 of MIL-STD-CAIS,
  3939. --    dated 31 January 1985.
  3940. --    The additional interface for Open that is presented is
  3941. --    also provided.
  3942. --    NOTE:  The exception handler semantics of the additional
  3943. --    interface are not adequate.  The unconditional Close file
  3944. --    call may raise a Status_Error, causing the original
  3945. --    exception to be lost.
  3946. --
  3947. ---------------------------------------------------------------------
  3948.  
  3949.     procedure Open(File : in out File_Type; 
  3950.                    Node : Node_Type; 
  3951.                    Mode : File_Mode) is 
  3952.         File_Name           : Name_String(1 .. Pragmatics.Max_Name_String); 
  3953.         Directmode          : Dir_Io.File_Mode := Dir_Io.In_File; 
  3954.         Last_File_Char      : Natural; 
  3955.         Last_Path_Char      : Natural; 
  3956.  
  3957.         Pathname            : Name_String(1 .. Pragmatics.Max_Name_String); 
  3958.         Position            : Position_Count; 
  3959.         Attribute_List      : List_Type; 
  3960.  
  3961.         Access_Method       : Token_Type; 
  3962.         Access_Method_Value : List_Type; 
  3963.         Direct              : Token_Type; 
  3964.  
  3965.         File_Kind           : Token_Type; 
  3966.         File_Kind_Value     : List_Type; 
  3967.         Secondary_Storage   : List_Type; 
  3968.  
  3969.  
  3970.     begin
  3971.  
  3972.         Check_Open(Node, True); 
  3973.                               -- check that node handle is open
  3974.                                 -- (Node_Definitions.Status_Error)
  3975.         Check_Open(File, False); 
  3976.                                -- check that file handle is not open
  3977.                                 -- (Dir_Io_Definitions.Status_Error)
  3978.  
  3979.                                 -- Check that node is file node
  3980.         if Get_Kind(Node) /= Node_Definitions.File then 
  3981.             raise Node_Definitions.Use_Error; 
  3982.         end if; 
  3983.  
  3984.         Initialize(File); 
  3985.         Set_Intent(File, Get_Intent(Node));                     --Set intentions
  3986.         Get_Shadow_File_Name(Node, File_Name, Last_File_Char); 
  3987.                                                         --Set Shadow file
  3988.         Set_Shadow_File_Name(File, File_Name(1 .. Last_File_Char)); 
  3989.         Get_Contents_File_Name(Node, File_Name, Last_File_Char); 
  3990.                                                         --Set contents file
  3991.         Set_Contents_File_Name(File, File_Name(1 .. Last_File_Char)); 
  3992.         Get_Pathname(Node, Pathname, Last_Path_Char);           --Set file node name
  3993.         Set_Name(File, Pathname(1 .. Last_Path_Char)); 
  3994.  
  3995.                                                         --Check Use errors
  3996.         Validate_Mode(File, Mode, Directmode);  --checks mode against intent
  3997.  
  3998.         Get_Node_Attributes(Node, Attribute_List); 
  3999.         To_Token("Access_Method", Access_Method); 
  4000.         To_Token("Direct", Direct); 
  4001.         begin                   -- Check Access_Method includes Direct
  4002.             Extract(Attribute_List, Access_Method, Access_Method_Value); 
  4003.             Position := Position_By_Value(Access_Method_Value, Direct); 
  4004.  
  4005.         exception
  4006.             when List_Utilities.Search_Error => 
  4007.                 Trace.Report(
  4008.                     "CAIS Use_Error: Invalid Access_Method in Cais.Direct_Io.Open "
  4009.                     ); 
  4010.                 Trace.Report("Access_Method: " & To_Text(Access_Method_Value)); 
  4011.                 Trace.Report("Expected list containing: (Direct,Sequential)"); 
  4012.                 raise Dir_Io_Definitions.Use_Error; 
  4013.  
  4014.         end; 
  4015.  
  4016.         To_Token("File_Kind", File_Kind); 
  4017.         To_List("(Secondary_Storage)", Secondary_Storage); 
  4018.         Extract(Attribute_List, File_Kind, File_Kind_Value); 
  4019.         if not Is_Equal(File_Kind_Value, Secondary_Storage) then 
  4020.             Trace.Report(
  4021.                 "CAIS Use_Error: Invalid File_Kind in Cais.Direct_Io.Open "); 
  4022.             Trace.Report("Access_Method: " & To_Text(File_Kind_Value)); 
  4023.             Trace.Report("Expected: Secondary_Storage"); 
  4024.             raise Dir_Io_Definitions.Use_Error; 
  4025.         end if; 
  4026.  
  4027.  
  4028.         Set_Mode(File, Mode);                   --Set Mode
  4029.  
  4030.         Dir_Io.Open(Convert(Get_File_Type(File)).all, Directmode, File_Name(1
  4031.             .. Last_File_Char));                       --Open file
  4032.  
  4033.     exception
  4034.  
  4035.     -- exceptions that are propagated
  4036.         when Dir_Io_Definitions.Use_Error | Dir_Io_Definitions.Status_Error | 
  4037.             Dir_Io_Definitions.Device_Error | Node_Definitions.Intent_Violation
  4038.             => 
  4039.             raise; 
  4040.  
  4041.  
  4042.     -- exceptions that are mapped to other exceptions
  4043.     -- Search_Error looking for Direct in Access_Method list is
  4044.     --    mapped to Use_Error.
  4045.         when Node_Definitions.Use_Error => 
  4046.             raise Dir_Io_Definitions.Use_Error; 
  4047.         when Node_Definitions.Status_Error => 
  4048.             raise Dir_Io_Definitions.Status_Error; 
  4049.  
  4050.     -- predefined exceptions (propagated with trace)
  4051.         when Constraint_Error | Tasking_Error | Program_Error | Storage_Error | 
  4052.             Numeric_Error => 
  4053.             Trace.Report("PREDEFINED EXCEPTION in Cais.Direct_Io.Open "); 
  4054.             raise; 
  4055.  
  4056.     -- unanticipated exceptions
  4057.         when others => 
  4058.             Trace.Report("UNANTICIPATED EXCEPTION in Cais.Direct_Io.Open "); 
  4059.             raise Trace.Assertion_Violation; 
  4060.  
  4061.     end Open; 
  4062.  
  4063. -------------------------------------------------------------------------------
  4064. --
  4065. --    Alternate interface using Name (pathname) rather than Base, Relation,
  4066. --    and Key to refer to file node.
  4067. --
  4068. -------------------------------------------------------------------------------
  4069.  
  4070.     procedure Open(File : in out File_Type; 
  4071.                    Name : Name_String; 
  4072.                    Mode : File_Mode) is 
  4073.         Node : Node_Type; 
  4074.     begin
  4075.         case Mode is 
  4076.             when In_File => 
  4077.                 Open(Node, Name, (1 => Read_Contents)); 
  4078.             when Out_File => 
  4079.                 Open(Node, Name, (1 => Write_Contents)); 
  4080.             when Inout_File => 
  4081.                 Open(Node, Name, (Read_Contents, Write_Contents)); 
  4082.         end case; 
  4083.  
  4084.         Open(File, Node, Mode); 
  4085.         Close(Node); 
  4086.     exception
  4087.         when others => 
  4088.             Close(File); 
  4089.             Close(Node); 
  4090.             raise; 
  4091.     end Open; 
  4092.  
  4093.  
  4094. ----------------------     Close     ----------------------
  4095. --
  4096. --  Purpose:
  4097. --  -------
  4098. --    Closes file handle to CAIS file node.
  4099. --
  4100. --  Parameters:
  4101. --  ----------
  4102. --    File    open file handle.
  4103. --
  4104. --  Exceptions:
  4105. --  ----------
  4106. --    Status_Error
  4107. --        raised if file handle is not open.
  4108. --
  4109. --  Notes:
  4110. --  -----
  4111. --    Semantics correspond to Ada LRM, Section 14.2.1
  4112. --
  4113. ---------------------------------------------------------------------
  4114.  
  4115.  
  4116.     procedure Close(File : in out File_Type) is 
  4117.     begin
  4118.         Check_Open(File, True);  -- Status_Error if file handle not open
  4119.         Dir_Io.Close(Convert(Get_File_Type(File)).all); -- Close contents file
  4120.         Deallocate(File);                       -- Deallocate file handle
  4121.  
  4122.     exception
  4123.       -- exceptions that are propagated
  4124.         when Dir_Io_Definitions.Status_Error | Dir_Io_Definitions.Device_Error
  4125.             => 
  4126.             raise; 
  4127.  
  4128.       -- predefined exceptions (propagated with trace)
  4129.         when Constraint_Error | Tasking_Error | Program_Error | Storage_Error | 
  4130.             Numeric_Error => 
  4131.             Trace.Report("PREDEFINED EXCEPTION in Cais.Direct_Io.Close "); 
  4132.             raise; 
  4133.  
  4134.       -- unanticipated exceptions
  4135.         when others => 
  4136.             Trace.Report("UNANTICIPATED EXCEPTION in Cais.Direct_Io.Close "); 
  4137.             raise Trace.Assertion_Violation; 
  4138.  
  4139.     end Close; 
  4140.  
  4141.  
  4142.  
  4143. ----------------------     Delete     ----------------------
  4144. --
  4145. --  Purpose:
  4146. --  -------
  4147. --    This procedure deletes the CAIS file identified
  4148. --    by File.  
  4149. --    In addition to the semantics specified in the LRM,
  4150. --    the node associated with the open file handle File
  4151. --    is made unobtainable as if a call to the Delete_Node
  4152. --    procedure had been made.
  4153. --
  4154. --  Parameters:
  4155. --  ----------
  4156. --    File    an open file handle on the file being deleted.
  4157. --
  4158. --  Exceptions:
  4159. --  ----------
  4160. --    Name_Error
  4161. --        raised if the parent node of the node associated with
  4162. --        the file identified by File is inaccessible.
  4163. --    Use_Error
  4164. --        raised if any primary relationships emanate from the
  4165. --        node associated with the file identified by File.
  4166. --    Status_Error
  4167. --        raised if File is not an open file handle.
  4168. --    Lock_Error
  4169. --        raised if access with intent Write_Relationships to the
  4170. --        parent of the node to be deleted cannot be obtained due
  4171. --        to an existing lock on the node.
  4172. --    Access_Violation
  4173. --        raised if the current process does not have sufficient
  4174. --        discretionary access control rights to obtain access to
  4175. --        the parent of the node to be deleted with intent
  4176. --        Exclusive_Write; only raised if the conditions for
  4177. --        Name_Error are not present.
  4178. --    Security_Violation
  4179. --        raised if the operation represents a violation of mandatory
  4180. --        access controls; raised only if the conditions for other
  4181. --        exceptions are not present.
  4182. --
  4183. --  Notes:
  4184. --  -----
  4185. --    This procedure is defined in section 5.3.2.4 of MIL-STD-CAIS,
  4186. --    dated 31 January 1985.
  4187. --
  4188. ---------------------------------------------------------------------
  4189.  
  4190.     procedure Delete(File : in out File_Type) is 
  4191.         Name : String(1 .. Pragmatics.Max_Name_String); 
  4192.         Node : Node_Type; 
  4193.         Last : Natural; 
  4194.     begin
  4195.  
  4196.         Check_Open(File, True);  -- Status_Error if file handle not open
  4197.         Get_Name(File, Name, Last);     -- Get file node name
  4198.         Close(File);                    -- Close contents file
  4199.         Open(Node, Name(1 .. Last),             -- Make file node unobtainable
  4200.         (1 => Read_Relationships, 2 => Exclusive_Write)); 
  4201.         Delete_Node(Node); 
  4202.     exception
  4203.  
  4204.     -- exceptions that are propagated
  4205.         when Dir_Io_Definitions.Use_Error | Dir_Io_Definitions.Status_Error | 
  4206.             Dir_Io_Definitions.Device_Error | Node_Definitions.Lock_Error | 
  4207.             Node_Definitions.Access_Violation | Node_Definitions.
  4208.             Security_Violation => 
  4209.             raise; 
  4210.  
  4211.  
  4212.     -- exceptions that are mapped to other exceptions
  4213.         when Node_Definitions.Name_Error => 
  4214.             raise Dir_Io_Definitions.Name_Error; 
  4215.         when Node_Definitions.Use_Error => 
  4216.             raise Dir_Io_Definitions.Use_Error; 
  4217.         when Node_Definitions.Status_Error => 
  4218.             raise Dir_Io_Definitions.Status_Error; 
  4219.  
  4220.     -- predefined exceptions (propagated with trace)
  4221.         when Constraint_Error | Tasking_Error | Program_Error | Storage_Error | 
  4222.             Numeric_Error => 
  4223.             Trace.Report("PREDEFINED EXCEPTION in Cais.Direct_Io.Delete "); 
  4224.             raise; 
  4225.  
  4226.     -- unanticipated exceptions
  4227.         when others => 
  4228.             Trace.Report("UNANTICIPATED EXCEPTION in Cais.Direct_Io.Delete "); 
  4229.             raise Trace.Assertion_Violation; 
  4230.  
  4231.  
  4232.     end Delete; 
  4233.  
  4234.  
  4235. ----------------------     Reset     ----------------------
  4236. --
  4237. --  Purpose:
  4238. --  -------
  4239. --    Reset the file mode of a CAIS file.
  4240. --
  4241. --  Parameters:
  4242. --  ----------
  4243. --    File    An open file handle on the file being reset.
  4244. --    Mode    Indicates the mode of the file.
  4245. --
  4246. --  Exceptions:
  4247. --  ----------
  4248. --    Status_Error
  4249. --        raised if the file handle is not open
  4250. --    Use_Error
  4251. --        raised if the node associated with the file identified
  4252. --        by File has a value of Terminal or Magnetic_Tape for
  4253. --        the attribute File_Kind and the Mode is Append_File.
  4254. --    Intent_Error
  4255. --        See note.
  4256. --
  4257. --  Notes:
  4258. --  -----
  4259. --    This procedure is defined as in section 5.3.4.5 of MIL-STD-CAIS,
  4260. --    dated 31 January 1985.
  4261. --    The implementation raises Intent_Violation if mode
  4262. --    violates the intent with which the file node was opened.
  4263. --    These semantics are not stated in the MIL-STD-CAIS, but
  4264. --    are required for consistent intent enforcement.
  4265. --
  4266. ---------------------------------------------------------------------
  4267.  
  4268.     procedure Reset(File : in out File_Type; 
  4269.                     Mode : File_Mode) is 
  4270.         Directmode : Dir_Io.File_Mode := Dir_Io.In_File; 
  4271.     begin
  4272.         Check_Open(File, True);  -- Status_Error if file handle not open
  4273.  
  4274.         Validate_Mode(File, Mode, Directmode);          -- Confirm access rights
  4275.         Set_Mode(File, Mode);                   -- Record current CAIS mode
  4276.                                                 -- Reset contents file
  4277.         Dir_Io.Reset(Convert(Get_File_Type(File)).all, Directmode); 
  4278.     exception
  4279.  
  4280.     -- exceptions that are propagated
  4281.         when Dir_Io_Definitions.Use_Error | Dir_Io_Definitions.Status_Error | 
  4282.             Dir_Io_Definitions.Device_Error | Node_Definitions.Intent_Violation
  4283.             => 
  4284.             raise; 
  4285.  
  4286.  
  4287.       -- exceptions that are mapped to other exceptions
  4288.  
  4289.       -- predefined exceptions (propagated with trace)
  4290.         when Constraint_Error | Tasking_Error | Program_Error | Storage_Error | 
  4291.             Numeric_Error => 
  4292.             Trace.Report("PREDEFINED EXCEPTION in Cais.Direct_Io.Reset "); 
  4293.             raise; 
  4294.  
  4295.       -- unanticipated exceptions
  4296.         when others => 
  4297.             Trace.Report("UNANTICIPATED EXCEPTION in Cais.Direct_Io.Reset "); 
  4298.             raise Trace.Assertion_Violation; 
  4299.  
  4300.     end Reset; 
  4301.  
  4302.  
  4303. ----------------------     Reset     ----------------------
  4304. --
  4305. --  Purpose:
  4306. --  -------
  4307. --    Reset a CAIS file.
  4308. --
  4309. --  Parameters:
  4310. --  ----------
  4311. --    File    An open file handle on the file being reset.
  4312. --
  4313. --  Exceptions:
  4314. --  ----------
  4315. --    Status_Error
  4316. --        raised if the file handle is not open
  4317. --    Use_Error
  4318. --        raised if environment does not support resetting for
  4319. --        the stored file
  4320. --
  4321. --  Notes:
  4322. --  -----
  4323. --    This procedure is defined as in section 5.3.4.5 of MIL-STD-CAIS,
  4324. --    dated 31 January 1985.
  4325. --    Semantics of this procedure are not restricted to Ada LRM
  4326. --    semantics, pending clarification of the interaction of access
  4327. --    methods in the CAIS.
  4328. ---------------------------------------------------------------------
  4329.  
  4330.     procedure Reset(File : in out File_Type) is 
  4331.     begin
  4332.         Check_Open(File, True);  -- Status_Error if file handle not open
  4333.         Dir_Io.Reset(Convert(Get_File_Type(File)).all); 
  4334.     exception
  4335.       -- exceptions that are propagated
  4336.         when Dir_Io_Definitions.Status_Error | Dir_Io_Definitions.Device_Error
  4337.             => 
  4338.             raise; 
  4339.  
  4340.       -- predefined exceptions (propagated with trace)
  4341.         when Constraint_Error | Tasking_Error | Program_Error | Storage_Error | 
  4342.             Numeric_Error => 
  4343.             Trace.Report("PREDEFINED EXCEPTION in Cais.Direct_Io.Reset "); 
  4344.             raise; 
  4345.  
  4346.       -- unanticipated exceptions
  4347.         when others => 
  4348.             Trace.Report("UNANTICIPATED EXCEPTION in Cais.Direct_Io.Reset "); 
  4349.             raise Trace.Assertion_Violation; 
  4350.  
  4351.     end Reset; 
  4352.  
  4353. ----------------------     Mode     ----------------------
  4354. --
  4355. --  Purpose:
  4356. --  -------
  4357. --    Returns the current mode of the current CAIS file.
  4358. --
  4359. --  Parameters:
  4360. --  ----------
  4361. --    File    open file handle.
  4362. --
  4363. --  Exceptions:
  4364. --  ----------
  4365. --    Status_Error
  4366. --        raised if file handle is not open.
  4367. --
  4368. --  Notes:
  4369. --  -----
  4370. --    Semantics correspond to Ada LRM, Section 14.2.1
  4371. --
  4372. ---------------------------------------------------------------------
  4373.  
  4374.     function Mode(File : File_Type) return File_Mode is 
  4375.         Mode : File_Mode; 
  4376.     begin
  4377.         Check_Open(File, True);  -- Status_Error if file handle not open
  4378.         Get_Mode(File, Mode); 
  4379.         return Mode; 
  4380.     exception
  4381.       -- exceptions that are propagated
  4382.         when Dir_Io_Definitions.Status_Error | Dir_Io_Definitions.Device_Error
  4383.             => 
  4384.             raise; 
  4385.  
  4386.       -- predefined exceptions (propagated with trace)
  4387.         when Constraint_Error | Tasking_Error | Program_Error | Storage_Error | 
  4388.             Numeric_Error => 
  4389.             Trace.Report("PREDEFINED EXCEPTION in Cais.Direct_Io.Mode "); 
  4390.             raise; 
  4391.  
  4392.       -- unanticipated exceptions
  4393.         when others => 
  4394.             Trace.Report("UNANTICIPATED EXCEPTION in Cais.Direct_Io.Mode "); 
  4395.             raise Trace.Assertion_Violation; 
  4396.  
  4397.     end Mode; 
  4398.  
  4399. ----------------------     Name     ----------------------
  4400. --
  4401. --  Purpose:
  4402. --  -------
  4403. --    Returns a string containing the name of the CAIS file 
  4404. --    node currently associated with the file handle.
  4405. --
  4406. --  Parameters:
  4407. --  ----------
  4408. --    File    open file handle.
  4409. --
  4410. --  Exceptions:
  4411. --  ----------
  4412. --    Status_Error
  4413. --        raised if file handle is not open.
  4414. --
  4415. --  Notes:
  4416. --  -----
  4417. --    Semantics correspond to Ada LRM, Section 14.2.1
  4418. --
  4419. ---------------------------------------------------------------------
  4420.  
  4421.     function Name(File : File_Type) return String is 
  4422.         File_Node_Name : String(1 .. Pragmatics.Max_Name_String); 
  4423.         Last           : Natural; 
  4424.     begin
  4425.         Check_Open(File, True);  -- Status_Error if file handle not open
  4426.         Get_Name(File, File_Node_Name, Last); 
  4427.         return File_Node_Name(1 .. Last); 
  4428.     exception
  4429.       -- exceptions that are propagated
  4430.         when Dir_Io_Definitions.Status_Error | Dir_Io_Definitions.Device_Error
  4431.             => 
  4432.             raise; 
  4433.  
  4434.       -- predefined exceptions (propagated with trace)
  4435.         when Constraint_Error | Tasking_Error | Program_Error | Storage_Error | 
  4436.             Numeric_Error => 
  4437.             Trace.Report("PREDEFINED EXCEPTION in Cais.Direct_Io.Name "); 
  4438.             raise; 
  4439.  
  4440.       -- unanticipated exceptions
  4441.         when others => 
  4442.             Trace.Report("UNANTICIPATED EXCEPTION in Cais.Direct_Io.Name "); 
  4443.             raise Trace.Assertion_Violation; 
  4444.  
  4445.     end Name; 
  4446.  
  4447. ----------------------     Form     ----------------------
  4448. --
  4449. --  Purpose:
  4450. --  -------
  4451. --    Returns the form string for the external file currently
  4452. --    associated with the given file.
  4453. --
  4454. --  Parameters:
  4455. --  ----------
  4456. --    File    open file handle.
  4457. --
  4458. --  Exceptions:
  4459. --  ----------
  4460. --    Status_Error
  4461. --        raised if file handle is not open.
  4462. --
  4463. --  Notes:
  4464. --  -----
  4465. --    Semantics correspond to Ada LRM, Section 14.2.1
  4466. --
  4467. ---------------------------------------------------------------------
  4468.  
  4469.     function Form(File : File_Type) return String is 
  4470.     begin
  4471.         Check_Open(File, True);  -- Status_Error if file handle not open
  4472.         return Dir_Io.Form(Convert(Get_File_Type(File)).all); 
  4473.     exception
  4474.       -- exceptions that are propagated
  4475.         when Dir_Io_Definitions.Status_Error | Dir_Io_Definitions.Device_Error
  4476.             => 
  4477.             raise; 
  4478.  
  4479.       -- predefined exceptions (propagated with trace)
  4480.         when Constraint_Error | Tasking_Error | Program_Error | Storage_Error | 
  4481.             Numeric_Error => 
  4482.             Trace.Report("PREDEFINED EXCEPTION in Cais.Direct_Io.Form "); 
  4483.             raise; 
  4484.  
  4485.       -- unanticipated exceptions
  4486.         when others => 
  4487.             Trace.Report("UNANTICIPATED EXCEPTION in Cais.Direct_Io.Form "); 
  4488.             raise Trace.Assertion_Violation; 
  4489.  
  4490.     end Form; 
  4491.  
  4492. ----------------------     Is_Open     ----------------------
  4493. --
  4494. --  Purpose:
  4495. --  -------
  4496. --    Returns TRUE if the file handle is open, otherwise returns FALSE.
  4497. --
  4498. --  Parameters:
  4499. --  ----------
  4500. --    File    file handle.
  4501. --
  4502. --  Exceptions:
  4503. --  ----------
  4504. --    None.
  4505. --
  4506. --  Notes:
  4507. --  -----
  4508. --    Semantics correspond to Ada LRM, Section 14.2.1
  4509. --
  4510. ---------------------------------------------------------------------
  4511.  
  4512.     function Is_Open(File : File_Type) return Boolean is 
  4513.     begin
  4514.         return (not Un_Initialized(File)) and then Dir_Io.Is_Open(Convert(
  4515.             Get_File_Type(File)).all); 
  4516.     end Is_Open; 
  4517.  
  4518.  
  4519. ---------------------------     Read     ---------------------------
  4520. --
  4521. --  Purpose:
  4522. --  -------
  4523. --    Sets the current index of the given file to the index
  4524. --    value given by the parameter From.
  4525. --    Returns in the parameter Item, the value of the element 
  4526. --    whose position in the given file is specified by the 
  4527. --    current index of the file; then increases the current
  4528. --    index by one.
  4529. --
  4530. --  Parameters:
  4531. --  ----------
  4532. --    File    open file handle.
  4533. --    Item    returns element read from file.
  4534. --    From    index of element to be read.
  4535. --
  4536. --  Exceptions:
  4537. --  ----------
  4538. --    Status_Error
  4539. --        raised if file handle is not open.
  4540. --    Mode_Error
  4541. --        raised if the mode is not In_File.
  4542. --    End_Error
  4543. --        raised if the index to be used exceeds the size
  4544. --        of the given file.
  4545. --    Data_Error
  4546. --        raised if the element read cannot be interpreted
  4547. --        as a value of the generic parameter type.
  4548. --
  4549. --  Notes:
  4550. --  -----
  4551. --    Semantics follow Ada LRM Section 14.2.4.
  4552. --
  4553. ---------------------------------------------------------------------
  4554.  
  4555.     procedure Read(File : File_Type; 
  4556.                    Item : in out Element_Type; 
  4557.                    From : Positive_Count) is 
  4558.     begin
  4559.         Check_Open(File, True);  -- Status_Error if file handle not open
  4560.         Dir_Io.Read(Convert(Get_File_Type(File)).all, Item, Dir_Io.
  4561.             Positive_Count(From)); 
  4562.     exception
  4563.  
  4564.       -- exceptions that are propagated
  4565.         when Dir_Io_Definitions.Status_Error | Dir_Io_Definitions.Mode_Error | 
  4566.             Dir_Io_Definitions.Device_Error | Dir_Io_Definitions.End_Error | 
  4567.             Dir_Io_Definitions.Data_Error => 
  4568.             raise; 
  4569.  
  4570.  
  4571.       -- exceptions that are mapped to other exceptions
  4572.  
  4573.       -- predefined exceptions (propagated with trace)
  4574.         when Constraint_Error | Tasking_Error | Program_Error | Storage_Error | 
  4575.             Numeric_Error => 
  4576.             Trace.Report("PREDEFINED EXCEPTION in Cais.Direct_Io.Read "); 
  4577.             raise; 
  4578.  
  4579.       -- unanticipated exceptions
  4580.         when others => 
  4581.             Trace.Report("UNANTICIPATED EXCEPTION in Cais.Direct_Io.Read "); 
  4582.             raise Trace.Assertion_Violation; 
  4583.  
  4584.     end Read; 
  4585.  
  4586. ---------------------------     Read     ---------------------------
  4587. --
  4588. --  Purpose:
  4589. --  -------
  4590. --    Returns in the parameter Item, the value of the element 
  4591. --    whose position in the given file is specified by the 
  4592. --    current index of the file; then increases the current
  4593. --    index by one.
  4594. --
  4595. --  Parameters:
  4596. --  ----------
  4597. --    File    open file handle.
  4598. --    Item    returns element read from file.
  4599. --
  4600. --  Exceptions:
  4601. --  ----------
  4602. --    Status_Error
  4603. --        raised if file handle is not open.
  4604. --    Mode_Error
  4605. --        raised if the mode is not In_File.
  4606. --    End_Error
  4607. --        raised if the index to be used exceeds the size
  4608. --        of the given file.
  4609. --    Data_Error
  4610. --        raised if the element read cannot be interpreted
  4611. --        as a value of the generic parameter type.
  4612. --
  4613. --  Notes:
  4614. --  -----
  4615. --    Semantics follow Ada LRM Section 14.2.4.
  4616. --
  4617. ---------------------------------------------------------------------
  4618.  
  4619.     procedure Read(File : File_Type; 
  4620.                    Item : in out Element_Type) is 
  4621.     begin
  4622.         Check_Open(File, True);  -- Status_Error if file handle not open
  4623.         Dir_Io.Read(Convert(Get_File_Type(File)).all, Item); 
  4624.     exception
  4625.  
  4626.       -- exceptions that are propagated
  4627.         when Dir_Io_Definitions.Status_Error | Dir_Io_Definitions.Mode_Error | 
  4628.             Dir_Io_Definitions.Device_Error | Dir_Io_Definitions.End_Error | 
  4629.             Dir_Io_Definitions.Data_Error => 
  4630.             raise; 
  4631.  
  4632.  
  4633.       -- exceptions that are mapped to other exceptions
  4634.  
  4635.       -- predefined exceptions (propagated with trace)
  4636.         when Constraint_Error | Tasking_Error | Program_Error | Storage_Error | 
  4637.             Numeric_Error => 
  4638.             Trace.Report("PREDEFINED EXCEPTION in Cais.Direct_Io.Read "); 
  4639.             raise; 
  4640.  
  4641.       -- unanticipated exceptions
  4642.         when others => 
  4643.             Trace.Report("UNANTICIPATED EXCEPTION in Cais.Direct_Io.Read "); 
  4644.             raise Trace.Assertion_Violation; 
  4645.  
  4646.     end Read; 
  4647.  
  4648. ---------------------------     Write     ---------------------------
  4649. --
  4650. --  Purpose:
  4651. --  -------
  4652. --    Sets the index of the given file to the index value given
  4653. --    by the parameter To.
  4654. --    Gives the value of the parameter Item to the element whose
  4655. --    position in the given file is specified by the current index
  4656. --    of the file; then increases the current index by one.
  4657. --
  4658. --  Parameters:
  4659. --  ----------
  4660. --    File    open file handle.
  4661. --    Item    element to be written to the file.
  4662. --    To    index of element to be written.
  4663. --
  4664. --  Exceptions:
  4665. --  ----------
  4666. --    Status_Error
  4667. --        raised if file handle is not open.
  4668. --    Mode_Error
  4669. --        raised if mode is In_File.
  4670. --    Use_Error
  4671. --        raised if the capacity of the file is exceeded.
  4672. --
  4673. --  Notes:
  4674. --  -----
  4675. --    Semantics follow Ada LRM Section 14.2.4.
  4676. --
  4677. ---------------------------------------------------------------------
  4678.  
  4679.     procedure Write(File : File_Type; 
  4680.                     Item : Element_Type; 
  4681.                     To   : Positive_Count) is 
  4682.     begin
  4683.         Check_Open(File, True);  -- Status_Error if file handle not open
  4684.         Dir_Io.Write(Convert(Get_File_Type(File)).all, Item, Dir_Io.
  4685.             Positive_Count(To)); 
  4686.     exception
  4687.  
  4688.       -- exceptions that are propagated
  4689.         when Dir_Io_Definitions.Status_Error | Dir_Io_Definitions.Use_Error | 
  4690.             Dir_Io_Definitions.Mode_Error | Dir_Io_Definitions.Device_Error => 
  4691.             raise; 
  4692.  
  4693.  
  4694.       -- exceptions that are mapped to other exceptions
  4695.  
  4696.       -- predefined exceptions (propagated with trace)
  4697.         when Constraint_Error | Tasking_Error | Program_Error | Storage_Error | 
  4698.             Numeric_Error => 
  4699.             Trace.Report("PREDEFINED EXCEPTION in Cais.Direct_Io.Write "); 
  4700.             raise; 
  4701.  
  4702.       -- unanticipated exceptions
  4703.         when others => 
  4704.             Trace.Report("UNANTICIPATED EXCEPTION in Cais.Direct_Io.Write "); 
  4705.             raise Trace.Assertion_Violation; 
  4706.  
  4707.     end Write; 
  4708.  
  4709. ---------------------------     Write     ---------------------------
  4710. --
  4711. --  Purpose:
  4712. --  -------
  4713. --    Gives the value of the parameter Item to the element whose
  4714. --    position in the given file is specified by the current index
  4715. --    of the file; then increases the current index by one.
  4716. --
  4717. --  Parameters:
  4718. --  ----------
  4719. --    File    open file handle.
  4720. --    Item    element to be written to the file.
  4721. --  Exceptions:
  4722. --  ----------
  4723. --    Status_Error
  4724. --        raised if file handle is not open.
  4725. --    Mode_Error
  4726. --        raised if mode is In_File.
  4727. --    Use_Error
  4728. --        raised if the capacity of the file is exceeded.
  4729. --
  4730. --  Notes:
  4731. --  -----
  4732. --    Semantics follow Ada LRM Section 14.2.4.
  4733. --
  4734. ---------------------------------------------------------------------
  4735.  
  4736.     procedure Write(File : File_Type; 
  4737.                     Item : Element_Type) is 
  4738.     begin
  4739.         Check_Open(File, True);  -- Status_Error if file handle not open
  4740.         Dir_Io.Write(Convert(Get_File_Type(File)).all, Item); 
  4741.     exception
  4742.  
  4743.       -- exceptions that are propagated
  4744.         when Dir_Io_Definitions.Use_Error | Dir_Io_Definitions.Status_Error | 
  4745.             Dir_Io_Definitions.Mode_Error | Dir_Io_Definitions.Device_Error => 
  4746.             raise; 
  4747.  
  4748.  
  4749.       -- exceptions that are mapped to other exceptions
  4750.  
  4751.       -- predefined exceptions (propagated with trace)
  4752.         when Constraint_Error | Tasking_Error | Program_Error | Storage_Error | 
  4753.             Numeric_Error => 
  4754.             Trace.Report("PREDEFINED EXCEPTION in Cais.Direct_Io.Write "); 
  4755.             raise; 
  4756.  
  4757.       -- unanticipated exceptions
  4758.         when others => 
  4759.             Trace.Report("UNANTICIPATED EXCEPTION in Cais.Direct_Io.Write "); 
  4760.             raise Trace.Assertion_Violation; 
  4761.  
  4762.     end Write; 
  4763.  
  4764.  
  4765. ----------------------     Set_Index     ----------------------
  4766. --
  4767. --  Purpose:
  4768. --  -------
  4769. --    Sets the current index of the given file to the given
  4770. --    index value (which may exceed the current size of the file).
  4771. --
  4772. --  Parameters:
  4773. --  ----------
  4774. --    File    open file handle.
  4775. --    To    index value.
  4776. --
  4777. --  Exceptions:
  4778. --  ----------
  4779. --    Status_Error
  4780. --        raised if file handle is not open.
  4781. --
  4782. --  Notes:
  4783. --  -----
  4784. --    Semantics follow Ada LRM Section 14.2.4.
  4785. --
  4786. ---------------------------------------------------------------------
  4787.  
  4788.     procedure Set_Index(File : File_Type; 
  4789.                         To   : Positive_Count) is 
  4790.     begin
  4791.         Check_Open(File, True);  -- Status_Error if file handle not open
  4792.         Dir_Io.Set_Index(Convert(Get_File_Type(File)).all, Dir_Io.Positive_Count
  4793.             (To)); 
  4794.     exception
  4795.       -- exceptions that are propagated
  4796.         when Dir_Io_Definitions.Status_Error | Dir_Io_Definitions.Device_Error
  4797.             => 
  4798.             raise; 
  4799.  
  4800.       -- predefined exceptions (propagated with trace)
  4801.         when Constraint_Error | Tasking_Error | Program_Error | Storage_Error | 
  4802.             Numeric_Error => 
  4803.             Trace.Report("PREDEFINED EXCEPTION in Cais.Direct_Io.Set_Index "); 
  4804.             raise; 
  4805.  
  4806.       -- unanticipated exceptions
  4807.         when others => 
  4808.             Trace.Report("UNANTICIPATED EXCEPTION in Cais.Direct_Io.Set_Index ")
  4809.                 ; 
  4810.             raise Trace.Assertion_Violation; 
  4811.  
  4812.     end Set_Index; 
  4813.  
  4814.  
  4815.  
  4816. ----------------------     Index     ----------------------
  4817. --
  4818. --  Purpose:
  4819. --  -------
  4820. --    Returns the current index of the given file.
  4821. --
  4822. --  Parameters:
  4823. --  ----------
  4824. --    File    open file handle.
  4825. --
  4826. --  Exceptions:
  4827. --  ----------
  4828. --    Status_Error
  4829. --        raised if file handle is not open.
  4830. --
  4831. --  Notes:
  4832. --  -----
  4833. --    Semantics follow Ada LRM Section 14.2.4.
  4834. --
  4835. ---------------------------------------------------------------------
  4836.  
  4837.     function Index(File : File_Type) return Positive_Count is 
  4838.     begin
  4839.         Check_Open(File, True);  -- Status_Error if file handle not open
  4840.         return Positive_Count(Dir_Io.Index(Convert(Get_File_Type(File)).all)); 
  4841.     exception
  4842.       -- exceptions that are propagated
  4843.         when Dir_Io_Definitions.Status_Error | Dir_Io_Definitions.Device_Error
  4844.             => 
  4845.             raise; 
  4846.  
  4847.       -- predefined exceptions (propagated with trace)
  4848.         when Constraint_Error | Tasking_Error | Program_Error | Storage_Error | 
  4849.             Numeric_Error => 
  4850.             Trace.Report("PREDEFINED EXCEPTION in Cais.Direct_Io.Index "); 
  4851.             raise; 
  4852.  
  4853.       -- unanticipated exceptions
  4854.         when others => 
  4855.             Trace.Report("UNANTICIPATED EXCEPTION in Cais.Direct_Io.Index "); 
  4856.             raise Trace.Assertion_Violation; 
  4857.  
  4858.     end Index; 
  4859.  
  4860.  
  4861. ----------------------     Size     ----------------------
  4862. --
  4863. --  Purpose:
  4864. --  -------
  4865. --    Returns the current size of the given file.
  4866. --
  4867. --  Parameters:
  4868. --  ----------
  4869. --    File    open file handle.
  4870. --
  4871. --  Exceptions:
  4872. --  ----------
  4873. --    Status_Error
  4874. --        raised if file handle is not open.
  4875. --
  4876. --  Notes:
  4877. --  -----
  4878. --    Semantics follow Ada LRM Section 14.2.4.
  4879. --
  4880. ---------------------------------------------------------------------
  4881.  
  4882.     function Size(File : File_Type) return Count is 
  4883.     begin
  4884.         Check_Open(File, True);  -- Status_Error if file handle not open
  4885.         return Positive_Count(Dir_Io.Size(Convert(Get_File_Type(File)).all)); 
  4886.     exception
  4887.       -- exceptions that are propagated
  4888.         when Dir_Io_Definitions.Status_Error | Dir_Io_Definitions.Device_Error
  4889.             => 
  4890.             raise; 
  4891.  
  4892.       -- predefined exceptions (propagated with trace)
  4893.         when Constraint_Error | Tasking_Error | Program_Error | Storage_Error | 
  4894.             Numeric_Error => 
  4895.             Trace.Report("PREDEFINED EXCEPTION in Cais.Direct_Io.Size "); 
  4896.             raise; 
  4897.  
  4898.       -- unanticipated exceptions
  4899.         when others => 
  4900.             Trace.Report("UNANTICIPATED EXCEPTION in Cais.Direct_Io.Size "); 
  4901.             raise Trace.Assertion_Violation; 
  4902.  
  4903.     end Size; 
  4904.  
  4905. ----------------------     End_Of_File     ----------------------
  4906. --
  4907. --  Purpose:
  4908. --  -------
  4909. --    Returns True if the current index is exceeds the size of the
  4910. --    given file;  otherwise returns False.
  4911. --
  4912. --  Parameters:
  4913. --  ----------
  4914. --    File    open file handle.
  4915. --
  4916. --  Exceptions:
  4917. --  ----------
  4918. --    Status_Error
  4919. --        raised if file handle is not open.
  4920. --    Mode_Error
  4921. --        raised if file mode is Out_File.
  4922. --
  4923. --  Notes:
  4924. --  -----
  4925. --    Semantics follow Ada LRM Section 14.2.4.
  4926. --
  4927. ---------------------------------------------------------------------
  4928.  
  4929.     function End_Of_File(File : File_Type) return Boolean is 
  4930.     begin
  4931.         Check_Open(File, True);  -- Status_Error if file handle not open
  4932.         return Dir_Io.End_Of_File(Convert(Get_File_Type(File)).all); 
  4933.     exception
  4934.       -- exceptions that are propagated
  4935.         when Dir_Io_Definitions.Status_Error | Dir_Io_Definitions.Mode_Error | 
  4936.             Dir_Io_Definitions.Device_Error => 
  4937.             raise; 
  4938.  
  4939.       -- predefined exceptions (propagated with trace)
  4940.         when Constraint_Error | Tasking_Error | Program_Error | Storage_Error | 
  4941.             Numeric_Error => 
  4942.             Trace.Report("PREDEFINED EXCEPTION in Cais.Direct_Io.End_Of_File ")
  4943.                 ; 
  4944.             raise; 
  4945.  
  4946.       -- unanticipated exceptions
  4947.         when others => 
  4948.             Trace.Report(
  4949.                 "UNANTICIPATED EXCEPTION in Cais.Direct_Io.End_Of_File "); 
  4950.             raise Trace.Assertion_Violation; 
  4951.  
  4952.     end End_Of_File; 
  4953.  
  4954. ------------------------------------------------------------------------
  4955. end Direct_Io; 
  4956. ------------------------------------------------------------------------
  4957. --::::::::::::::
  4958. --cais_generics.a
  4959. --::::::::::::::
  4960.  
  4961.  
  4962. ----------------------------------------------------------------------
  4963. --            I N T E G E R _ I O
  4964. --     (Separately compiled package body from Cais.Text_Io)
  4965. --
  4966. --            E N U M E R A T I O N _ I O
  4967. --     (Separately compiled package body from Cais.Text_Io)
  4968. --
  4969. --            F I X E D _ I O
  4970. --     (Separately compiled package body from Cais.Text_Io)
  4971. --
  4972. --            F L O A T _ I O
  4973. --     (Separately compiled package body from Cais.Text_Io)
  4974. --
  4975. --
  4976. --            Generic Packages in
  4977. --            CAIS Text_Io Access Method
  4978. --
  4979. --
  4980. --
  4981. --                  Ada Software Engineering Group
  4982. --                      The MITRE Corporation
  4983. --                         McLean, VA 22102
  4984. --
  4985. --
  4986. --            Wed Oct  9 10:55:45 EDT 1985
  4987. --
  4988. --                 (Unclassified and uncopyrighted)
  4989. --
  4990. ----------------------------------------------------------------------
  4991.  
  4992. ----------------------------------------------------------------------
  4993. --              C A I S . T E X T _ I O . I N T E G E R _ I O
  4994. --
  4995. --  Purpose:
  4996. --  -------
  4997. --        Integer_Io is a generic package nested in the CAIS Text_Io package.
  4998. --        This package provides facilities for the input and output
  4999. --        of textual integer data to CAIS files.  These facilities are
  5000. --        comparable to those specified in the package TEXT_IO.INTEGER_IO
  5001. --        in the Ada LRM, Chapter 14.  
  5002. --
  5003. --  Usage:
  5004. --  -----
  5005. --        Usage is analogous to usage of the Ada Text_Io.Integer_Io package.
  5006. --        CAIS file nodes correspond to ordinary Ada files. 
  5007. --        Input and output operations access the contents of CAIS 
  5008. --        file nodes.  
  5009. --        The package is instantiated for the element type.  File_Type
  5010. --        and File_Mode are subtypes declared in the Cais.Text_Io package.
  5011. --
  5012. --  Example:
  5013. --  -------
  5014. --        type Small_Integer is range 1..20;
  5015. --        ...
  5016. --        File      : File_Type;
  5017. --        package Small_Io is new Cais.Text_Io.Integer_Io (Small_Integer);
  5018. --        ...
  5019. --        Small_Io.Put (File, 15);
  5020. --        ...
  5021. --
  5022. --  Notes:
  5023. --  -----
  5024. --        This is a version of the package CAIS.TEXT_IO.INTEGER_IO,
  5025. --        specified in MIL-STD-CAIS section 5.3.4; all references
  5026. --        to the CAIS specification refer to the CAIS specification
  5027. --        dated 31 January 1985.
  5028. --
  5029. --  Revision History:
  5030. --  ----------------
  5031. --        None.
  5032. --
  5033. -------------------------------------------------------------------
  5034.  
  5035. with Text_Io; 
  5036. separate(Cais.Text_Io)
  5037. package body Integer_Io is 
  5038.  
  5039.   --Default_Width  : Field := Num'Width;
  5040.   --Default_Base   : Number_Base := 10;
  5041.  
  5042.     package Int_Io is 
  5043.         new Standard.Text_Io.Integer_Io(Num); 
  5044.  
  5045.  
  5046. ----------------------     Get     ----------------------
  5047. --
  5048. --  Purpose:
  5049. --  -------
  5050. --    This procedure reads characters from the specified
  5051. --    text file, according to the syntax of a literal
  5052. --    of the parameter type,
  5053. --    and stores the converted value in the item parameter.
  5054. --
  5055. --  Parameters:
  5056. --  ----------
  5057. --    File    open file handle.
  5058. --    Item    out parameter of the generic parameter type.
  5059. --    Width    field width, or 0 if unbounded.
  5060. --
  5061. --  Exceptions:
  5062. --  ----------
  5063. --    Status_Error
  5064. --        raised if File is not open.
  5065. --    Mode_Error
  5066. --        raised if file mode is not In_File.
  5067. --    End_Error
  5068. --        raised if attempt is made to skip file terminator.
  5069. --    Data_Error
  5070. --        raised if the sequence input is not a lexical element
  5071. --        corresponding to the item type.
  5072. --
  5073. --  Notes:
  5074. --  -----
  5075. --    This procedure is defined in section 5.3.4.6 of MIL-STD-CAIS,
  5076. --    dated 31 January 1985.
  5077. --
  5078. ---------------------------------------------------------------------
  5079.  
  5080.     procedure Get(File  : File_Type; 
  5081.                   Item  : in out Num; 
  5082.                   Width : Field := 0) is 
  5083.     begin
  5084.         Check_Open(File, True); -- Status_Error if file not open
  5085.         Int_Io.Get(Get_File_Type(File).all, Item, Width); 
  5086.     end Get; 
  5087.  
  5088.  
  5089.     procedure Get(Item  : in out Num; 
  5090.                   Width : Field := 0) is 
  5091.     begin
  5092.         Get(Current_Input, Item, Width); 
  5093.     end Get; 
  5094.  
  5095. ----------------------     Put     ----------------------
  5096. --
  5097. --  Purpose:
  5098. --  -------
  5099. --    This procedure writes the value of Item, represented as a literal
  5100. --    of the parameter type, to the specified file.
  5101. --    
  5102. --
  5103. --  Parameters:
  5104. --  ----------
  5105. --    File    open file handle.
  5106. --    Item    in parameter of the generic parameter type.
  5107. --    Width    minimum field width.
  5108. --    Base    base for literal representation.
  5109. --
  5110. --  Exceptions:
  5111. --  ----------
  5112. --    Status_Error
  5113. --        raised if File is not open.
  5114. --    Mode_Error
  5115. --        raised if file mode is not Out_File or Append_File.
  5116. --    Layout_Error
  5117. --        raised if the number of characters to be output 
  5118. --        exceeds the maximum line length.
  5119. --
  5120. --  Notes:
  5121. --  -----
  5122. --    This procedure is defined in section 5.3.4.7 of MIL-STD-CAIS,
  5123. --    dated 31 January 1985.
  5124. --
  5125. ---------------------------------------------------------------------
  5126.  
  5127.     procedure Put(File  : File_Type; 
  5128.                   Item  : Num; 
  5129.                   Width : Field := Default_Width; 
  5130.                   Base  : Number_Base := Default_Base) is 
  5131.     begin
  5132.         Check_Open(File, True); -- Status_Error if file not open
  5133.         Int_Io.Put(Get_File_Type(File).all, Item, Width, Base); 
  5134.     end Put; 
  5135.  
  5136.  
  5137.     procedure Put(Item  : Num; 
  5138.                   Width : Field := Default_Width; 
  5139.                   Base  : Number_Base := Default_Base) is 
  5140.     begin
  5141.         Put(Current_Output, Item, Width, Base); 
  5142.     end Put; 
  5143.  
  5144. ----------------------     Get     ----------------------
  5145. --
  5146. --  Purpose:
  5147. --  -------
  5148. --    This procedure reads characters from the specified
  5149. --    string into the item parameter, following the same
  5150. --    rule as for reading from a file, but treating the
  5151. --    end of the string as a file terminator.
  5152. --
  5153. --  Parameters:
  5154. --  ----------
  5155. --    From    string.
  5156. --    Item    out parameter of the generic parameter type.
  5157. --    Last    index value of last character read.
  5158. --
  5159. --  Exceptions:
  5160. --  ----------
  5161. --    End_Error
  5162. --        raised if attempt is made to skip file terminator.
  5163. --    Data_Error
  5164. --        raised if the sequence input is not a lexical element
  5165. --        corresponding to the item type.
  5166. --
  5167. --  Notes:
  5168. --  -----
  5169. --    Semantics correspond to Ada LRM, Section 14.3.7
  5170. --
  5171. ---------------------------------------------------------------------
  5172.  
  5173.     procedure Get(From : String; 
  5174.                   Item : in out Num; 
  5175.                   Last : in out Positive) is 
  5176.     begin
  5177.         Int_Io.Get(From, Item, Last); 
  5178.     end Get; 
  5179.  
  5180. ----------------------     Put     ----------------------
  5181. --
  5182. --  Purpose:
  5183. --  -------
  5184. --    This procedure writes characters to the specified string,
  5185. --    following the same rule as for output to a file.
  5186. --
  5187. --  Parameters:
  5188. --  ----------
  5189. --    To    string.
  5190. --    Item    in parameter of generic parameter type.
  5191. --    Base    base for literal representation.
  5192. --
  5193. --  Exceptions:
  5194. --  ----------
  5195. --    Layout_Error
  5196. --        raised if the number of characters to be output 
  5197. --        exceeds the remaining string length.
  5198. --
  5199. --  Notes:
  5200. --  -----
  5201. --    Semantics correspond to Ada LRM, Section 14.3.7
  5202. --
  5203. ---------------------------------------------------------------------
  5204.  
  5205.     procedure Put(To   : in out String; 
  5206.                   Item : Num; 
  5207.                   Base : Number_Base := Default_Base) is 
  5208.     begin
  5209.         Int_Io.Put(To, Item, Base); 
  5210.     end Put; 
  5211.  
  5212. end Integer_Io; 
  5213.  
  5214. ----------------------------------------------------------------------
  5215. --              C A I S . T E X T _ I O . F L O A T _ I O
  5216. --
  5217. --  Purpose:
  5218. --  -------
  5219. --        Float_Io is a generic package nested in the CAIS Text_Io package.
  5220. --        This package provides facilities for the input and output
  5221. --        of textual float data to CAIS files.  These facilities are
  5222. --        comparable to those specified in the package TEXT_IO.FLOAT_IO
  5223. --        in the Ada LRM, Chapter 14.  
  5224. --
  5225. --  Usage:
  5226. --  -----
  5227. --        Usage is analogous to usage of the Ada Standard.Text_Io.Float_Io package.
  5228. --        CAIS file nodes correspond to ordinary Ada files. 
  5229. --        Input and output operations access the contents of CAIS 
  5230. --        file nodes.  
  5231. --        The package is instantiated for the element type.  File_Type
  5232. --        and File_Mode are subtypes declared in the Cais.Text_Io package.
  5233. --
  5234. --  Example:
  5235. --  -------
  5236. --        type Real_Float is digits 5 range 0.0000 .. 9.9999;
  5237. --        ...
  5238. --        File      : File_Type;
  5239. --        package Real_Io is new Cais.Text_Io.Float_Io (Real_Float);
  5240. --        ...
  5241. --        Real_Io.Put (File, 2.3456);
  5242. --        ...
  5243. --
  5244. --  Notes:
  5245. --  -----
  5246. --        This is a version of the package CAIS.TEXT_IO.FLOAT_IO,
  5247. --        specified in MIL-STD-CAIS section 5.3.4; all references
  5248. --        to the CAIS specification refer to the CAIS specification
  5249. --        dated 31 January 1985.
  5250. --
  5251. --  Revision History:
  5252. --  ----------------
  5253. --        None.
  5254. --
  5255. -------------------------------------------------------------------
  5256.  
  5257. with Text_Io; 
  5258. separate(Cais.Text_Io)
  5259. package body Float_Io is 
  5260.  
  5261.   --Default_Fore    :  Field := 2;
  5262.   --Default_Aft    :  Field := Num'Digits-1;
  5263.   --Default_Exp    :  Field := 3;
  5264.  
  5265.     package Flt_Io is 
  5266.         new Standard.Text_Io.Float_Io(Num); 
  5267.  
  5268.  
  5269. ----------------------     Get     ----------------------
  5270. --
  5271. --  Purpose:
  5272. --  -------
  5273. --    This procedure reads characters from the specified
  5274. --    text file, according to the syntax of a literal
  5275. --    of the parameter type,
  5276. --    and stores the converted value in the item parameter.
  5277. --
  5278. --  Parameters:
  5279. --  ----------
  5280. --    File    open file handle.
  5281. --    Item    out parameter of the generic parameter type.
  5282. --    Width    field width, or 0 if unbounded.
  5283. --
  5284. --  Exceptions:
  5285. --  ----------
  5286. --    Status_Error
  5287. --        raised if File is not open.
  5288. --    Mode_Error
  5289. --        raised if file mode is not In_File.
  5290. --    End_Error
  5291. --        raised if attempt is made to skip file terminator.
  5292. --    Data_Error
  5293. --        raised if the sequence input is not a lexical element
  5294. --        corresponding to the item type.
  5295. --
  5296. --  Notes:
  5297. --  -----
  5298. --    This procedure is defined in section 5.3.4.6 of MIL-STD-CAIS,
  5299. --    dated 31 January 1985.
  5300. --
  5301. ---------------------------------------------------------------------
  5302.  
  5303.     procedure Get(File  : File_Type; 
  5304.                   Item  : in out Num; 
  5305.                   Width : Field := 0) is 
  5306.     begin
  5307.         Check_Open(File, True); -- Status_Error if file not open
  5308.         Flt_Io.Get(Get_File_Type(File).all, Item, Width); 
  5309.     end Get; 
  5310.  
  5311.  
  5312.     procedure Get(Item  : in out Num; 
  5313.                   Width : Field := 0) is 
  5314.     begin
  5315.         Get(Current_Input, Item, Width); 
  5316.     end Get; 
  5317.  
  5318.  
  5319. ----------------------     Put     ----------------------
  5320. --
  5321. --  Purpose:
  5322. --  -------
  5323. --    This procedure writes the value of Item, represented as a literal
  5324. --    of the parameter type, to the specified file.
  5325. --    
  5326. --
  5327. --  Parameters:
  5328. --  ----------
  5329. --    File    open file handle.
  5330. --    Item    in parameter of the generic parameter type.
  5331. --    Width    minimum field width.
  5332. --    Fore    digits before decimal in literal representation.
  5333. --    Aft    digits after decimal in literal representation.
  5334. --    Exp    digits in exponent in literal representation.
  5335. --
  5336. --  Exceptions:
  5337. --  ----------
  5338. --    Status_Error
  5339. --        raised if File is not open.
  5340. --    Mode_Error
  5341. --        raised if file mode is not Out_File or Append_File.
  5342. --    Layout_Error
  5343. --        raised if the number of characters to be output 
  5344. --        exceeds the maximum line length.
  5345. --
  5346. --  Notes:
  5347. --  -----
  5348. --    This procedure is defined in section 5.3.4.7 of MIL-STD-CAIS,
  5349. --    dated 31 January 1985.
  5350. --
  5351. ---------------------------------------------------------------------
  5352.  
  5353.     procedure Put(File : File_Type; 
  5354.                   Item : Num; 
  5355.                   Fore : Field := Default_Fore; 
  5356.                   Aft  : Field := Default_Aft; 
  5357.                   Exp  : Field := Default_Exp) is 
  5358.     begin
  5359.         Check_Open(File, True); -- Status_Error if file not open
  5360.         Flt_Io.Put(Get_File_Type(File).all, Item, Fore, Aft, Exp); 
  5361.     end Put; 
  5362.  
  5363.  
  5364.     procedure Put(Item : Num; 
  5365.                   Fore : Field := Default_Fore; 
  5366.                   Aft  : Field := Default_Aft; 
  5367.                   Exp  : Field := Default_Exp) is 
  5368.     begin
  5369.         Put(Current_Output, Item, Fore, Aft, Exp); 
  5370.     end Put; 
  5371.  
  5372. ----------------------     Get     ----------------------
  5373. --
  5374. --  Purpose:
  5375. --  -------
  5376. --    This procedure reads characters from the specified
  5377. --    string into the item parameter, following the same
  5378. --    rule as for reading from a file, but treating the
  5379. --    end of the string as a file terminator.
  5380. --
  5381. --  Parameters:
  5382. --  ----------
  5383. --    From    string.
  5384. --    Item    out parameter of the generic parameter type.
  5385. --    Last    index value of last character read.
  5386. --
  5387. --  Exceptions:
  5388. --  ----------
  5389. --    End_Error
  5390. --        raised if attempt is made to skip file terminator.
  5391. --    Data_Error
  5392. --        raised if the sequence input is not a lexical element
  5393. --        corresponding to the item type.
  5394. --
  5395. --  Notes:
  5396. --  -----
  5397. --    Semantics correspond to Ada LRM, Section 14.3.7
  5398. --
  5399. ---------------------------------------------------------------------
  5400.  
  5401.     procedure Get(From : String; 
  5402.                   Item : in out Num; 
  5403.                   Last : in out Positive) is 
  5404.     begin
  5405.         Flt_Io.Get(From, Item, Last); 
  5406.     end Get; 
  5407.  
  5408. ----------------------     Put     ----------------------
  5409. --
  5410. --  Purpose:
  5411. --  -------
  5412. --    This procedure writes characters to the specified string,
  5413. --    following the same rule as for output to a file.
  5414. --    The number of digits before the exponent is adjusted so
  5415. --    that the literal exactly fills the string.
  5416. --
  5417. --  Parameters:
  5418. --  ----------
  5419. --    To    string.
  5420. --    Item    in parameter of generic parameter type.
  5421. --    Aft    digits after the decimal in the literal representation.
  5422. --    Exp    digits in the exponent in the literal representation.
  5423. --
  5424. --  Exceptions:
  5425. --  ----------
  5426. --    Layout_Error
  5427. --        raised if the number of characters to be output 
  5428. --        exceeds the remaining string length.
  5429. --
  5430. --  Notes:
  5431. --  -----
  5432. --    Semantics correspond to Ada LRM, Section 14.3.7
  5433. --
  5434. ---------------------------------------------------------------------
  5435.  
  5436.     procedure Put(To   : in out String; 
  5437.                   Item : Num; 
  5438.                   Aft  : Field := Default_Aft; 
  5439.                   Exp  : Field := Default_Exp) is 
  5440.     begin
  5441.         Flt_Io.Put(To, Item, Aft, Exp); 
  5442.     end Put; 
  5443.  
  5444. end Float_Io; 
  5445.  
  5446.  
  5447.  
  5448. ----------------------------------------------------------------------
  5449. --              C A I S . T E X T _ I O . F I X E D _ I O
  5450. --
  5451. --  Purpose:
  5452. --  -------
  5453. --        Fixed_Io is a generic package nested in the CAIS Text_Io package.
  5454. --        This package provides facilities for the input and output
  5455. --        of textual Fixed data to CAIS files.  These facilities are
  5456. --        comparable to those specified in the package TEXT_IO.FIXED_IO
  5457. --        in the Ada LRM, Chapter 14.  
  5458. --
  5459. --  Usage:
  5460. --  -----
  5461. --        Usage is analogous to usage of the Ada Text_Io.Fixed_Io package.
  5462. --        CAIS file nodes correspond to ordinary Ada files. 
  5463. --        Input and output operations access the contents of CAIS 
  5464. --        file nodes.  
  5465. --        The package is instantiated for the element type.  File_Type
  5466. --        and File_Mode are subtypes declared in the Cais.Text_Io package.
  5467. --
  5468. --  Example:
  5469. --  -------
  5470. --        type Real_Fixed is delta 0.001 range 0.000 .. 9.999;
  5471. --        ...
  5472. --        File      : File_Type;
  5473. --        package Real_Io is new Cais.Text_Io.Fixed_Io (Real_Fixed);
  5474. --        ...
  5475. --        Real_Io.Put (File, 5.432);
  5476. --  Notes:
  5477. --  -----
  5478. --        This is a version of the package CAIS.TEXT_IO.FIXED_IO,
  5479. --        specified in MIL-STD-CAIS section 5.3.4; all references
  5480. --        to the CAIS specification refer to the CAIS specification
  5481. --        dated 31 January 1985.
  5482. --
  5483. --  Revision History:
  5484. --  ----------------
  5485. --        None.
  5486. --
  5487. -------------------------------------------------------------------
  5488.  
  5489. with Text_Io; 
  5490. separate(Cais.Text_Io)
  5491. package body Fixed_Io is 
  5492.  
  5493.   --Default_Fore    :  Field := Num'Fore;
  5494.   --Default_Aft    :  Field := Num'Aft;
  5495.   --Default_Exp    :  Field := 0;
  5496.  
  5497.     package Fix_Io is 
  5498.         new Standard.Text_Io.Fixed_Io(Num); 
  5499.  
  5500.  
  5501. ----------------------     Get     ----------------------
  5502. --
  5503. --  Purpose:
  5504. --  -------
  5505. --    This procedure reads characters from the specified
  5506. --    text file, according to the syntax of a literal
  5507. --    of the parameter type,
  5508. --    and stores the converted value in the item parameter.
  5509. --
  5510. --  Parameters:
  5511. --  ----------
  5512. --    File    open file handle.
  5513. --    Item    out parameter of the generic parameter type.
  5514. --    Width    field width, or 0 if unbounded.
  5515. --
  5516. --  Exceptions:
  5517. --  ----------
  5518. --    Status_Error
  5519. --        raised if File is not open.
  5520. --    Mode_Error
  5521. --        raised if file mode is not In_File.
  5522. --    End_Error
  5523. --        raised if attempt is made to skip file terminator.
  5524. --    Data_Error
  5525. --        raised if the sequence input is not a lexical element
  5526. --        corresponding to the item type.
  5527. --
  5528. --  Notes:
  5529. --  -----
  5530. --    This procedure is defined in section 5.3.4.6 of MIL-STD-CAIS,
  5531. --    dated 31 January 1985.
  5532. --
  5533. ---------------------------------------------------------------------
  5534.  
  5535.     procedure Get(File  : File_Type; 
  5536.                   Item  : in out Num; 
  5537.                   Width : Field := 0) is 
  5538.     begin
  5539.         Check_Open(File, True); -- Status_Error if file not open
  5540.         Fix_Io.Get(Get_File_Type(File).all, Item, Width); 
  5541.     end Get; 
  5542.  
  5543.  
  5544.     procedure Get(Item  : in out Num; 
  5545.                   Width : Field := 0) is 
  5546.     begin
  5547.         Get(Current_Input, Item, Width); 
  5548.     end Get; 
  5549.  
  5550.  
  5551. ----------------------     Put     ----------------------
  5552. --
  5553. --  Purpose:
  5554. --  -------
  5555. --    This procedure writes the value of Item, represented as a literal
  5556. --    of the parameter type, to the specified file.
  5557. --    
  5558. --
  5559. --  Parameters:
  5560. --  ----------
  5561. --    File    open file handle.
  5562. --    Item    in parameter of the generic parameter type.
  5563. --    Width    minimum field width.
  5564. --    Fore    digits before decimal in literal representation.
  5565. --    Aft    digits after decimal in literal representation.
  5566. --    Exp    digits in exponent in literal representation.
  5567. --
  5568. --  Exceptions:
  5569. --  ----------
  5570. --    Status_Error
  5571. --        raised if File is not open.
  5572. --    Mode_Error
  5573. --        raised if file mode is not Out_File or Append_File.
  5574. --    Layout_Error
  5575. --        raised if the number of characters to be output 
  5576. --        exceeds the maximum line length.
  5577. --
  5578. --  Notes:
  5579. --  -----
  5580. --    This procedure is defined in section 5.3.4.7 of MIL-STD-CAIS,
  5581. --    dated 31 January 1985.
  5582. --
  5583. ---------------------------------------------------------------------
  5584.  
  5585.     procedure Put(File : File_Type; 
  5586.                   Item : Num; 
  5587.                   Fore : Field := Default_Fore; 
  5588.                   Aft  : Field := Default_Aft; 
  5589.                   Exp  : Field := Default_Exp) is 
  5590.     begin
  5591.         Check_Open(File, True); -- Status_Error if file not open
  5592.         Fix_Io.Put(Get_File_Type(File).all, Item, Fore, Aft, Exp); 
  5593.     end Put; 
  5594.  
  5595.  
  5596.     procedure Put(Item : Num; 
  5597.                   Fore : Field := Default_Fore; 
  5598.                   Aft  : Field := Default_Aft; 
  5599.                   Exp  : Field := Default_Exp) is 
  5600.     begin
  5601.         Put(Current_Output, Item, Fore, Aft, Exp); 
  5602.     end Put; 
  5603.  
  5604. ----------------------     Get     ----------------------
  5605. --
  5606. --  Purpose:
  5607. --  -------
  5608. --    This procedure reads characters from the specified
  5609. --    string into the item parameter, following the same
  5610. --    rule as for reading from a file, but treating the
  5611. --    end of the string as a file terminator.
  5612. --
  5613. --  Parameters:
  5614. --  ----------
  5615. --    From    string.
  5616. --    Item    out parameter of the generic parameter type.
  5617. --    Last    index value of last character read.
  5618. --
  5619. --  Exceptions:
  5620. --  ----------
  5621. --    End_Error
  5622. --        raised if attempt is made to skip file terminator.
  5623. --    Data_Error
  5624. --        raised if the sequence input is not a lexical element
  5625. --        corresponding to the item type.
  5626. --
  5627. --  Notes:
  5628. --  -----
  5629. --    Semantics correspond to Ada LRM, Section 14.3.8
  5630. --
  5631. ---------------------------------------------------------------------
  5632.  
  5633.     procedure Get(From : String; 
  5634.                   Item : in out Num; 
  5635.                   Last : in out Positive) is 
  5636.     begin
  5637.         Fix_Io.Get(From, Item, Last); 
  5638.     end Get; 
  5639.  
  5640. ----------------------     Put     ----------------------
  5641. --
  5642. --  Purpose:
  5643. --  -------
  5644. --    This procedure writes characters to the specified string,
  5645. --    following the same rule as for output to a file.
  5646. --    The number of digits before the exponent is adjusted so
  5647. --    that the literal exactly fills the string.
  5648. --
  5649. --  Parameters:
  5650. --  ----------
  5651. --    To    string.
  5652. --    Item    in parameter of generic parameter type.
  5653. --    Aft    digits after the decimal in the literal representation.
  5654. --    Exp    digits in the exponent in the literal representation.
  5655. --
  5656. --  Exceptions:
  5657. --  ----------
  5658. --    Layout_Error
  5659. --        raised if the number of characters to be output 
  5660. --        exceeds the remaining string length.
  5661. --
  5662. --  Notes:
  5663. --  -----
  5664. --    Semantics correspond to Ada LRM, Section 14.3.8
  5665. --
  5666. ---------------------------------------------------------------------
  5667.  
  5668.     procedure Put(To   : in out String; 
  5669.                   Item : Num; 
  5670.                   Aft  : Field := Default_Aft; 
  5671.                   Exp  : Field := Default_Exp) is 
  5672.     begin
  5673.         Fix_Io.Put(To, Item, Aft, Exp); 
  5674.     end Put; 
  5675.  
  5676. end Fixed_Io; 
  5677.  
  5678. ----------------------------------------------------------------------
  5679. --              C A I S . T E X T _ I O . E N U M E R A T I O N _ I O
  5680. --
  5681. --  Purpose:
  5682. --  -------
  5683. --        Enumeration_Io is a generic package nested in the CAIS Text_Io package.
  5684. --        This package provides facilities for the input and output
  5685. --        of textual enumeration data to CAIS files.  These facilities are
  5686. --        comparable to those specified in the package TEXT_IO.ENUMERATION_IO
  5687. --        in the Ada LRM, Chapter 14.  
  5688. --
  5689. --  Usage:
  5690. --  -----
  5691. --        Usage is analogous to usage of the Ada Text_Io.Enumeration_Io package.
  5692. --        CAIS file nodes correspond to ordinary Ada files. 
  5693. --        Input and output operations access the contents of CAIS 
  5694. --        file nodes.  
  5695. --        The package is instantiated for the element type.  File_Type
  5696. --        and File_Mode are subtypes declared in the Cais.Text_Io package.
  5697. --
  5698. --  Example:
  5699. --  -------
  5700. --        type Color is (Red, Yellow, Blue);
  5701. --        package Hue_Io is new Cais.Text_Io.Enumeration_Io (Color); 
  5702. --        ...
  5703. --        File : File_Type;
  5704. --        ...
  5705. --        Hue_Io.Put (File, Blue);
  5706. --        ...
  5707. --
  5708. --  Notes:
  5709. --  -----
  5710. --        This is a version of the package CAIS.TEXT_IO.ENUMERATION_IO,
  5711. --        specified in MIL-STD-CAIS section 5.3.4; all references
  5712. --        to the CAIS specification refer to the CAIS specification
  5713. --        dated 31 January 1985.
  5714. --
  5715. --  Revision History:
  5716. --  ----------------
  5717. --        None.
  5718. --
  5719. -------------------------------------------------------------------
  5720.  
  5721. with Text_Io; 
  5722. separate(Cais.Text_Io)
  5723. package body Enumeration_Io is 
  5724.  
  5725.   --Default_Width    : Field := 0;
  5726.   --Default_Setting  : Type_Set := Upper_Case;
  5727.  
  5728.     package Enum_Io is 
  5729.         new Standard.Text_Io.Enumeration_Io(Enum); 
  5730.  
  5731.  
  5732. ----------------------     Get     ----------------------
  5733. --
  5734. --  Purpose:
  5735. --  -------
  5736. --    This procedure reads characters from the specified
  5737. --    text file, according to the syntax of a literal
  5738. --    of the parameter type,
  5739. --    and stores the converted value in the item parameter.
  5740. --
  5741. --  Parameters:
  5742. --  ----------
  5743. --    File    open file handle.
  5744. --    Item    out parameter of the generic parameter type.
  5745. --
  5746. --  Exceptions:
  5747. --  ----------
  5748. --    Status_Error
  5749. --        raised if File is not open.
  5750. --    Mode_Error
  5751. --        raised if file mode is not In_File.
  5752. --    End_Error
  5753. --        raised if attempt is made to skip file terminator.
  5754. --    Data_Error
  5755. --        raised if the sequence input is not a lexical element
  5756. --        corresponding to the item type.
  5757. --
  5758. --  Notes:
  5759. --  -----
  5760. --    This procedure is defined in section 5.3.4.6 of MIL-STD-CAIS,
  5761. --    dated 31 January 1985.
  5762. --
  5763. ---------------------------------------------------------------------
  5764.  
  5765.     procedure Get(File : File_Type; 
  5766.                   Item : in out Enum) is 
  5767.     begin
  5768.         Check_Open(File, True); -- Status_Error if file not open
  5769.         Enum_Io.Get(Get_File_Type(File).all, Item); 
  5770.     end Get; 
  5771.  
  5772.  
  5773.     procedure Get(Item : in out Enum) is 
  5774.     begin
  5775.         Get(Current_Input, Item); 
  5776.     end Get; 
  5777.  
  5778. ----------------------     Put     ----------------------
  5779. --
  5780. --  Purpose:
  5781. --  -------
  5782. --    This procedure writes the value of Item, represented as a literal
  5783. --    of the parameter type, to the specified file.
  5784. --    
  5785. --
  5786. --  Parameters:
  5787. --  ----------
  5788. --    File    open file handle.
  5789. --    Item    in parameter of the generic parameter type.
  5790. --    Width    minimum field width.
  5791. --    Set    character set.
  5792. --
  5793. --  Exceptions:
  5794. --  ----------
  5795. --    Status_Error
  5796. --        raised if File is not open.
  5797. --    Mode_Error
  5798. --        raised if file mode is not Out_File or Append_File.
  5799. --    Layout_Error
  5800. --        raised if the number of characters to be output 
  5801. --        exceeds the maximum line length.
  5802. --
  5803. --  Notes:
  5804. --  -----
  5805. --    This procedure is defined in section 5.3.4.7 of MIL-STD-CAIS,
  5806. --    dated 31 January 1985.
  5807. --
  5808. ---------------------------------------------------------------------
  5809.  
  5810.     procedure Put(File  : File_Type; 
  5811.                   Item  : Enum; 
  5812.                   Width : Field := Default_Width; 
  5813.                   Set   : Type_Set := Default_Setting) is 
  5814.     begin
  5815.         Check_Open(File, True); -- Status_Error if file not open
  5816.         Enum_Io.Put(Get_File_Type(File).all, Item, Width, Standard.Text_Io.
  5817.             Type_Set'Val(Type_Set'Pos(Set))); 
  5818.     end Put; 
  5819.  
  5820.  
  5821.     procedure Put(Item  : Enum; 
  5822.                   Width : Field := Default_Width; 
  5823.                   Set   : Type_Set := Default_Setting) is 
  5824.     begin
  5825.         Put(Current_Output, Item, Width, Set); 
  5826.     end Put; 
  5827.  
  5828. ----------------------     Get     ----------------------
  5829. --
  5830. --  Purpose:
  5831. --  -------
  5832. --    This procedure reads characters from the specified
  5833. --    string into the item parameter, following the same
  5834. --    rule as for reading from a file, but treating the
  5835. --    end of the string as a file terminator.
  5836. --
  5837. --  Parameters:
  5838. --  ----------
  5839. --    From    string.
  5840. --    Item    out parameter of the generic parameter type.
  5841. --    Last    index value of last character read.
  5842. --
  5843. --  Exceptions:
  5844. --  ----------
  5845. --    End_Error
  5846. --        raised if attempt is made to skip file terminator.
  5847. --    Data_Error
  5848. --        raised if the sequence input is not a lexical element
  5849. --        corresponding to the item type.
  5850. --
  5851. --  Notes:
  5852. --  -----
  5853. --    Semantics correspond to Ada LRM, Section 14.3.9
  5854. --
  5855. ---------------------------------------------------------------------
  5856.  
  5857.     procedure Get(From : String; 
  5858.                   Item : in out Enum; 
  5859.                   Last : in out Positive) is 
  5860.     begin
  5861.         Enum_Io.Get(From, Item, Last); 
  5862.     end Get; 
  5863.  
  5864. ----------------------     Put     ----------------------
  5865. --
  5866. --  Purpose:
  5867. --  -------
  5868. --    This procedure writes characters to the specified string,
  5869. --    following the same rule as for output to a file.
  5870. --    The number of digits before the exponent is adjusted so
  5871. --    that the literal exactly fills the string.
  5872. --
  5873. --  Parameters:
  5874. --  ----------
  5875. --    To    string.
  5876. --    Item    in parameter of generic parameter type.
  5877. --    Set    character set.
  5878. --
  5879. --  Exceptions:
  5880. --  ----------
  5881. --    Layout_Error
  5882. --        raised if the number of characters to be output 
  5883. --        exceeds the remaining string length.
  5884. --
  5885. --  Notes:
  5886. --  -----
  5887. --    Semantics correspond to Ada LRM, Section 14.3.9
  5888. --
  5889. ---------------------------------------------------------------------
  5890.  
  5891.     procedure Put(To   : in out String; 
  5892.                   Item : Enum; 
  5893.                   Set  : Type_Set := Default_Setting) is 
  5894.     begin
  5895.         Enum_Io.Put(To, Item, Standard.Text_Io.Type_Set'Val(Type_Set'Pos(Set)))
  5896.             ; 
  5897.     end Put; 
  5898.  
  5899. end Enumeration_Io; 
  5900. --::::::::::::::
  5901. --cais_host_dependent_body.a
  5902. --::::::::::::::
  5903.  
  5904. ----------------------------------------------------------------------
  5905. --                  C A I S _ H O S T _ D E P E N D E N T 
  5906. --                             (Package Body)
  5907. --
  5908. --         Host specific services used by the CAIS implementation
  5909. --
  5910. --
  5911. --
  5912. --
  5913. --                  Ada Software Engineering Group
  5914. --                      The MITRE Corporation
  5915. --                         McLean, VA 22102
  5916. --
  5917. --                  Sat Apr 13 13:44:38 EST 1985
  5918. --
  5919. --                 (Unclassified and uncopyrighted)
  5920. --
  5921. ----------------------------------------------------------------------
  5922. ----------------------------------------------------------------------
  5923. --
  5924. --  Purpose:
  5925. --  -------
  5926. --    This package is used to isolate host dependent services used
  5927. --    in the implementation of the CAIS prototype.
  5928. --
  5929. --  Usage:
  5930. --  -----
  5931. --    These services are used mostly in Node_Internals subprograms.
  5932. --
  5933. --  Example:
  5934. --  -------
  5935. --    TBS
  5936. --
  5937. --  Notes:
  5938. --  -----
  5939. --    None.
  5940. --
  5941. --  Revision History:
  5942. --  ----------------
  5943. --
  5944. -------------------------------------------------------------------
  5945.  
  5946. with Trace; 
  5947. with Unchecked_Conversion; 
  5948. with System;
  5949.  
  5950. separate(Cais)
  5951. package body Cais_Host_Dependent is 
  5952.  
  5953.     procedure Cbreak_On; 
  5954.     procedure Cbreak_Off; 
  5955.     function Charget return Tiny_Integer; 
  5956.     function Test_Echo return Integer; 
  5957.     function cfile_exists (Name : System.Address) return Integer;  
  5958.  
  5959.     pragma Interface(C, Cbreak_On); 
  5960.     pragma Interface(C, Cbreak_Off); 
  5961.     pragma Interface(C, Charget); 
  5962.     pragma Interface(C, Test_Echo); 
  5963.     pragma interface (C, cfile_exists);    
  5964.  
  5965.  
  5966.     -- The C routine "charget" returns a single byte as an integer, so it is
  5967.     -- necessary to convert it to a character before returning it.
  5968.     function Byte_To_Char is 
  5969.         new Unchecked_Conversion(Tiny_Integer, Character); 
  5970.  
  5971.  
  5972.     procedure Unbuffered_Io_On is 
  5973.     begin
  5974.         Cbreak_On; 
  5975.     end Unbuffered_Io_On; 
  5976.  
  5977.     procedure Unbuffered_Io_Off is 
  5978.     begin
  5979.         Cbreak_Off; 
  5980.     end Unbuffered_Io_Off; 
  5981.  
  5982.     function Get_Char return Character is 
  5983.  
  5984.         Charint : Tiny_Integer; 
  5985.     begin
  5986.         Cbreak_On; 
  5987.  
  5988.         Charint := Charget; 
  5989.         if (Charint =  -1) then 
  5990.             raise Cais.Io_Definitions.End_Error; 
  5991.         end if; 
  5992.  
  5993.         Cbreak_Off; 
  5994.         return Byte_To_Char(Charint); 
  5995.     exception
  5996.     -- exceptions that are trapped (nothing propagated)
  5997.         -- None.
  5998.     -- exceptions that are propagated
  5999.         when Cais.Io_Definitions.End_Error => 
  6000.             raise; 
  6001.     -- exceptions that are mapped to other exceptions
  6002.         -- None.
  6003.     -- predefined exceptions (propagated with trace)
  6004.         when Constraint_Error | Tasking_Error | Program_Error | Storage_Error | 
  6005.             Numeric_Error => 
  6006.             Trace.Report("PREDEFINED EXCEPTION in " & 
  6007.                 "Cais_Host_Dependent.Get_Char"); 
  6008.             raise; 
  6009.     -- unanticipated exceptions
  6010.         when others => 
  6011.             Trace.Report("UNANTICIPATED EXCEPTION in " & 
  6012.                 "Cais_Host_Dependent.Get_Char"); 
  6013.             raise Trace.Assertion_Violation; 
  6014.     end Get_Char; 
  6015.  
  6016.     function Echo_Status return Boolean is 
  6017.         Result : Integer; 
  6018.     begin
  6019.         Result := Test_Echo; 
  6020.         if Result =  -1 then 
  6021.             raise Cais.Io_Definitions.Device_Error; 
  6022.         else 
  6023.             return (Result = 1); 
  6024.         end if; 
  6025.     end Echo_Status; 
  6026.  
  6027.     procedure Get_Unique_Filename(Name   : in out String; 
  6028.                                   Length : in out Natural) is separate; 
  6029.  
  6030.  
  6031.     function Get_Userid return String is separate; 
  6032.  
  6033.  
  6034. ---- C U R R E N T _ P R O C E S S _ S H A D O W _ F I L E ----------
  6035. --
  6036. --  Purpose:
  6037. --  -------
  6038. --    Returns the fully qualified name of the shadow file that 
  6039. --    contains information about the current process.
  6040. --
  6041. --  Parameters:
  6042. --  ----------
  6043. --    None.
  6044. --
  6045. --  Exceptions:
  6046. --  ----------
  6047. --    None.
  6048. --
  6049. --  Notes:
  6050. --  -----
  6051. --    This first cut is a "quick and dirty" version that deferrs any
  6052. --    intelligent handling of multiple processes or even multiple
  6053. --    users logged in under the same id.
  6054. --
  6055. ---------------------------------------------------------------------
  6056.  
  6057.     function Current_Process_Shadow_File return String is 
  6058.     begin
  6059.         return (Get_User_Prefix(Get_Userid) & Top_User_Process); 
  6060.     end Current_Process_Shadow_File; 
  6061.  
  6062.     function Get_User_Prefix(Userid : String) return String is separate; 
  6063.  
  6064. ----------------------  F I L E _ E X I S T S  ----------------------
  6065. --
  6066. --  Purpose:
  6067. --  -------
  6068. --    This routine determines if a given string refers to an accessable
  6069. --    host file.
  6070. --
  6071. --  Parameters:
  6072. --  ----------
  6073. --    Name  - the string representing the host file name.
  6074. --
  6075. --  Exceptions:
  6076. --  ----------
  6077. --    None.
  6078. --
  6079. --  Notes:
  6080. --  -----
  6081. --
  6082. ---------------------------------------------------------------------
  6083.  
  6084.     function File_Exists (
  6085.     Name : String)
  6086.     return Boolean is
  6087.  
  6088.     Tmp  : String (Name'range);
  6089.  
  6090.     begin
  6091.  
  6092.     if Name'last = 0 then
  6093.         return False;
  6094.     else
  6095.         Tmp := Name;
  6096.         return (0 = Cfile_Exists (Tmp'address));
  6097.     end if;
  6098.  
  6099.     end File_Exists;
  6100.  
  6101. end Cais_Host_Dependent; 
  6102. --::::::::::::::
  6103. --cais_io_definitions_body.a
  6104. --::::::::::::::
  6105.  
  6106.  
  6107. ----------------------------------------------------------------------
  6108. --                 I O _ D E F I N I T I O N S
  6109. --                           (Package Body)
  6110. --
  6111. --
  6112. --               This package defines the types and exceptions
  6113. --                       associated with file nodes.
  6114. --
  6115. --
  6116. --
  6117. --                  Ada Software Engineering Group
  6118. --                      The MITRE Corporation
  6119. --                         McLean, VA 22102
  6120. --
  6121. --
  6122. --            Thu Oct 17 08:45:44 EDT 1985
  6123. --
  6124. --                 (Unclassified and uncopyrighted)
  6125. --
  6126. ----------------------------------------------------------------------
  6127. ----------------------------------------------------------------------
  6128. --                C A I S _ I O _ D E F I N I T I O N S
  6129. --
  6130. --  Purpose:
  6131. --  -------
  6132. --    This package defines the types and exceptions associated
  6133. --    with file nodes.
  6134. --
  6135. --  Usage:
  6136. --  -----
  6137. --    This package contains declarations of base types and exceptions 
  6138. --    for I/O.  The operations in the interface are internal 
  6139. --    suprograms for use in implementation of the I/O packages.
  6140. --
  6141. --  Notes:
  6142. --  -----
  6143. --      The     use     of     a     limited     private     type
  6144. --      (Cais_IO_Definitions.File_Type)  implies  the addition of
  6145. --      subprograms to manipulate  that  type  (e.g.  to  set  or
  6146. --      extract  the  contents of an object of that type).  These
  6147. --      are in this specification, although they are additions to
  6148. --      the  CAIS  specification  for  this  package.
  6149. --    
  6150. --      This is a version of the package Cais_IO_Definitions,
  6151. --      specified in MIL-STD-CAIS section 5.3.1
  6152. --      Those portions of this specification that are NOT in
  6153. --      MIL-STD-CAIS specification (i.e. added for this implementation)
  6154. --      are so indicated.
  6155. --
  6156. --  Revision History:
  6157. --  ----------------
  6158. --    None.
  6159. --
  6160. -------------------------------------------------------------------
  6161.  
  6162. with Unchecked_Deallocation; 
  6163.  
  6164. separate(Cais)
  6165. package body Io_Definitions is 
  6166.  
  6167.     use List_Utilities; 
  6168.  
  6169. ---------------------------------  Is_Space  ---------------------------------
  6170. --
  6171. --    Local version of  function from package Character_Set
  6172. --
  6173. -------------------------------------------------------------------------------
  6174.  
  6175.     function Is_Space(Ch : Character) return Boolean is 
  6176.     begin
  6177.         case Ch is 
  6178.             when Ascii.Ht => 
  6179.                 return True; 
  6180.             when Ascii.Lf => 
  6181.                 return True; 
  6182.             when Ascii.Vt => 
  6183.                 return True; 
  6184.             when Ascii.Ff => 
  6185.                 return True; 
  6186.             when Ascii.Cr => 
  6187.                 return True; 
  6188.             when ' ' => 
  6189.                 return True; 
  6190.             when others => 
  6191.                 return False; 
  6192.         end case; 
  6193.     end Is_Space; 
  6194.  
  6195. -------------------------  Last_Non_Space  ------------------------------------
  6196. --
  6197. --    Local version of  function from package Character_Set
  6198. --
  6199. -------------------------------------------------------------------------------
  6200.  
  6201.     function Last_Non_Space(Str : String) return Integer is 
  6202.         Tmp : Integer; 
  6203.     begin
  6204.         Tmp := Str'Last; 
  6205.         for I in reverse Str'range loop
  6206.             exit when not Is_Space(Str(I)); 
  6207.             Tmp := Tmp - 1; 
  6208.         end loop; 
  6209.         return (Tmp); 
  6210.     end Last_Non_Space; 
  6211.  
  6212.  
  6213. ---------------------------------  Free  --------------------------------------
  6214. --
  6215. --    Local procedure for deallocating File_Type
  6216. --
  6217. -------------------------------------------------------------------------------
  6218.  
  6219.     procedure Free is 
  6220.         new Unchecked_Deallocation(File_Rec, File_Type); 
  6221. ----------------------- Initialize ----------------------------
  6222. --
  6223. --  Purpose:
  6224. --  -------
  6225. --    Internal function to allocate file handle.
  6226. --
  6227. --  Parameters:
  6228. --  ----------
  6229. --    FT    (access to) file handle record.
  6230. --
  6231. --  Exceptions:
  6232. --  ----------
  6233. --    None raised.
  6234. --
  6235. --  Notes:
  6236. --  -----
  6237. --    File_Recs are allocated from heap.
  6238. --
  6239. ---------------------------------------------------------------------
  6240.  
  6241.     procedure Initialize(Ft : in out File_Type) is 
  6242.     begin
  6243.         Ft := new File_Rec; 
  6244.     end Initialize; 
  6245.  
  6246. ----------------------- Deallocate ----------------------------
  6247. --
  6248. --  Purpose:
  6249. --  -------
  6250. --    Internal function to deallocate file handle.
  6251. --
  6252. --  Parameters:
  6253. --  ----------
  6254. --    FT    (access to) file handle record.
  6255. --
  6256. --  Exceptions:
  6257. --  ----------
  6258. --    None raised.
  6259. --
  6260. --  Notes:
  6261. --  -----
  6262. --    File_Recs are released to heap via unchecked deallocation.
  6263. --
  6264. ---------------------------------------------------------------------
  6265.  
  6266.     procedure Deallocate(Ft : in out File_Type) is 
  6267.     begin
  6268.         Free(Ft); 
  6269.         null; 
  6270.     end Deallocate; 
  6271.  
  6272. ----------------------- Un_Initialized ----------------------------
  6273. --
  6274. --  Purpose:
  6275. --  -------
  6276. --    Internal function to test whether file has been
  6277. --    initialized.  Returns True if not initialized,
  6278. --    otherwise returns False.
  6279. --
  6280. --  Parameters:
  6281. --  ----------
  6282. --    FT    (access to) file handle record.
  6283. --
  6284. --  Exceptions:
  6285. --  ----------
  6286. --    None raised.
  6287. --
  6288. --  Notes:
  6289. --  -----
  6290. --    Handle is checked for null reference.
  6291. --
  6292. ---------------------------------------------------------------------
  6293.  
  6294.     function Un_Initialized(Ft : File_Type) return Boolean is 
  6295.     begin
  6296.         return (Ft = null); 
  6297.     end Un_Initialized; 
  6298.  
  6299. ----------------------- Assign ----------------------------
  6300. --
  6301. --  Purpose:
  6302. --  -------
  6303. --    Internal procedure to copy one file handle record to
  6304. --    another.
  6305. --
  6306. --  Parameters:
  6307. --  ----------
  6308. --    From    (access to) source file handle record.
  6309. --    To    (access to) target file handle record.
  6310. --
  6311. --  Exceptions:
  6312. --  ----------
  6313. --    None raised.
  6314. --
  6315. --  Notes:
  6316. --  -----
  6317. --    If the target file handle is uninitialized, Assign initializes
  6318. --    it before copying the components of the record.
  6319. --
  6320. ---------------------------------------------------------------------
  6321.  
  6322.     procedure Assign(From : File_Type; 
  6323.                      To   : in out File_Type) is 
  6324.     begin
  6325.         if Un_Initialized(To) then 
  6326.             Initialize(To); 
  6327.         end if; 
  6328.         To.Fd := From.Fd; 
  6329.         To.Shadow_File_Name := From.Shadow_File_Name; 
  6330.         To.Contents_File_Name := From.Contents_File_Name; 
  6331.         To.Intent := From.Intent; 
  6332.         To.Intent_Size := From.Intent_Size; 
  6333.         To.Mode := From.Mode; 
  6334.         To.Name := From.Name; 
  6335.         Copy(To.Form, From.Form); 
  6336.     end Assign; 
  6337. -----------------------  Get_File_Type ----------------------------
  6338. --
  6339. --  Purpose:
  6340. --  -------
  6341. --    Internal function to fetch (access to) the Ada file descriptor 
  6342. --    for the contents file from the CAIS file handle.
  6343. --
  6344. --  Parameters:
  6345. --  ----------
  6346. --    FT    initialized file handle.
  6347. --
  6348. --  Exceptions:
  6349. --  ----------
  6350. --    Status_Error
  6351. --        raised if file handle has not been initialized.
  6352. --
  6353. --  Notes:
  6354. --  -----
  6355. --    The file descriptor is implemented as an Ada Text_Io.File_Type.
  6356. --    The access value returned is of type Text_File_Ptr.
  6357. --
  6358. ---------------------------------------------------------------------
  6359.  
  6360.     function Get_File_Type(Ft : File_Type) return Text_File_Ptr is 
  6361.     begin
  6362.         if Un_Initialized(Ft) then 
  6363.             raise Status_Error; 
  6364.         end if; 
  6365.         return Ft.Fd; 
  6366.     end Get_File_Type; 
  6367.  
  6368. -----------------------  Set_File_Type ----------------------------
  6369. --
  6370. --  Purpose:
  6371. --  -------
  6372. --    Internal procedure to store (access to) an Ada file descriptor 
  6373. --    for the contents file into the CAIS file handle.
  6374. --
  6375. --  Parameters:
  6376. --  ----------
  6377. --    FT    initialized file handle.
  6378. --    TFD    access to the Text_Io file descriptor.
  6379. --
  6380. --  Exceptions:
  6381. --  ----------
  6382. --    Status_Error
  6383. --        raised if file handle has not been initialized.
  6384. --
  6385. --  Notes:
  6386. --  -----
  6387. --    The file descriptor is implemented as an Ada Text_Io.File_Type.
  6388. --    The access parameter is of type Text_File_Ptr.
  6389. --
  6390. ---------------------------------------------------------------------
  6391.  
  6392.     procedure Set_File_Type(Ft  : in out File_Type; 
  6393.                             Tfd : Text_File_Ptr) is 
  6394.     begin
  6395.         if Un_Initialized(Ft) then 
  6396.             raise Status_Error; 
  6397.         end if; 
  6398.         Ft.Fd := Tfd; 
  6399.     end Set_File_Type; 
  6400.  
  6401. -----------------------  Get_Shadow_File_Name ----------------------------
  6402. --
  6403. --  Purpose:
  6404. --  -------
  6405. --    Internal procedure to fetch the name of the shadow file
  6406. --    from the CAIS file handle.
  6407. --    The file name and its length are returned in parameters
  6408. --    Name and Lastchar, respectively.
  6409. --
  6410. --  Parameters:
  6411. --  ----------
  6412. --    FT      initialized file handle.
  6413. --    Name      name string.
  6414. --    Lastchar  index of last non-blank character in Name.
  6415. --    
  6416. --
  6417. --  Exceptions:
  6418. --  ----------
  6419. --    None raised.
  6420. --
  6421. --  Notes:
  6422. --  -----
  6423. --    The shadow file contains the node image for the
  6424. --    CAIS file node, and its attributes and relationships.
  6425. --
  6426. ---------------------------------------------------------------------
  6427.  
  6428.     procedure Get_Shadow_File_Name(Ft       : File_Type; 
  6429.                                    Name     : in out String; 
  6430.                                    Lastchar : in out Natural) is 
  6431.  
  6432.         Last : Natural; 
  6433.     begin
  6434.         Last := Last_Non_Space(Ft.Shadow_File_Name); 
  6435.         Name(1 .. Last) := Ft.Shadow_File_Name(1 .. Last); 
  6436.         Lastchar := Last; 
  6437.     end Get_Shadow_File_Name; 
  6438.  
  6439. -----------------------  Set_Shadow_File_Name ----------------------------
  6440. --
  6441. --  Purpose:
  6442. --  -------
  6443. --    Internal procedure to store the name of the shadow file
  6444. --    into the CAIS file handle.
  6445. --
  6446. --  Parameters:
  6447. --  ----------
  6448. --    FT      initialized file handle.
  6449. --    Name      name string.
  6450. --    
  6451. --
  6452. --  Exceptions:
  6453. --  ----------
  6454. --    None raised.
  6455. --
  6456. --  Notes:
  6457. --  -----
  6458. --    The shadow file contains the node image for the
  6459. --    CAIS file node, and its attributes and relationships.
  6460. --
  6461. ---------------------------------------------------------------------
  6462.  
  6463.     procedure Set_Shadow_File_Name(Ft   : in out File_Type; 
  6464.                                    Name : String) is 
  6465.  
  6466.         Lastchar : Natural; 
  6467.     begin
  6468.         Lastchar := Last_Non_Space(Name); 
  6469.         Ft.Shadow_File_Name := (others => ' '); 
  6470.         Ft.Shadow_File_Name(1 .. Lastchar) := Name(1 .. Lastchar); 
  6471.     end Set_Shadow_File_Name; 
  6472.  
  6473. -----------------------  Get_Contents_File_Name ----------------------------
  6474. --
  6475. --  Purpose:
  6476. --  -------
  6477. --    Internal procedure to fetch the name of the contents file
  6478. --    from the CAIS file handle.
  6479. --    The file name and its length are returned in parameters
  6480. --    Name and Lastchar, respectively.
  6481. --
  6482. --  Parameters:
  6483. --  ----------
  6484. --    FT      initialized file handle.
  6485. --    Name      name string.
  6486. --    Lastchar  index of last non-blank character in Name.
  6487. --    
  6488. --
  6489. --  Exceptions:
  6490. --  ----------
  6491. --    None raised.
  6492. --
  6493. --  Notes:
  6494. --  -----
  6495. --    The contents file holds the actual file contents for the
  6496. --    CAIS file node.
  6497. --
  6498. ---------------------------------------------------------------------
  6499.  
  6500.     procedure Get_Contents_File_Name(Ft       : File_Type; 
  6501.                                      Name     : in out String; 
  6502.                                      Lastchar : in out Natural) is 
  6503.  
  6504.         Last : Natural; 
  6505.     begin
  6506.         Last := Last_Non_Space(Ft.Contents_File_Name); 
  6507.         Name(1 .. Last) := Ft.Contents_File_Name(1 .. Last); 
  6508.         Lastchar := Last; 
  6509.     end Get_Contents_File_Name; 
  6510.  
  6511. -----------------------  Set_Contents_File_Name ----------------------------
  6512. --
  6513. --  Purpose:
  6514. --  -------
  6515. --    Internal procedure to store the name of the contents file
  6516. --    into the CAIS file handle.
  6517. --
  6518. --  Parameters:
  6519. --  ----------
  6520. --    FT      initialized file handle.
  6521. --    Name      name string.
  6522. --    
  6523. --
  6524. --  Exceptions:
  6525. --  ----------
  6526. --    None raised.
  6527. --
  6528. --  Notes:
  6529. --  -----
  6530. --    The contents file holds the actual file contents for the
  6531. --    CAIS file node.
  6532. --
  6533. ---------------------------------------------------------------------
  6534.  
  6535.     procedure Set_Contents_File_Name(Ft   : in out File_Type; 
  6536.                                      Name : String) is 
  6537.  
  6538.         Lastchar : Natural; 
  6539.     begin
  6540.         Lastchar := Last_Non_Space(Name); 
  6541.         Ft.Contents_File_Name := (others => ' '); 
  6542.         Ft.Contents_File_Name(1 .. Lastchar) := Name(1 .. Lastchar); 
  6543.     end Set_Contents_File_Name; 
  6544.  
  6545. -----------------------  Get_Intent ----------------------------
  6546. --
  6547. --  Purpose:
  6548. --  -------
  6549. --    Internal procedure to fetch the intention of the node handle,
  6550. --    from the CAIS file handle.
  6551. --
  6552. --  Parameters:
  6553. --  ----------
  6554. --    FT      initialized file handle.
  6555. --    Intent      intention array.
  6556. --    
  6557. --
  6558. --  Exceptions:
  6559. --  ----------
  6560. --    None raised.
  6561. --
  6562. --  Notes:
  6563. --  -----
  6564. --    The intention returned is the intention with which the node
  6565. --    handle was opened to the file node.  When the file handle is
  6566. --    opened via the node handle, the intention is copied to the 
  6567. --    file handle.
  6568. --
  6569. ---------------------------------------------------------------------
  6570.  
  6571.     procedure Get_Intent(Ft     : File_Type; 
  6572.                          Intent : in out Intention) is 
  6573.     begin
  6574.         Intent := Ft.Intent(1 .. Ft.Intent_Size); 
  6575.     end Get_Intent; 
  6576.  
  6577. -----------------------  Set_Intent ----------------------------
  6578. --
  6579. --  Purpose:
  6580. --  -------
  6581. --    Internal procedure to store the intention of the node handle,
  6582. --    into the CAIS file handle.
  6583. --
  6584. --  Parameters:
  6585. --  ----------
  6586. --    FT      initialized file handle.
  6587. --    Intent      intention array.
  6588. --    
  6589. --
  6590. --  Exceptions:
  6591. --  ----------
  6592. --    None raised.
  6593. --
  6594. --  Notes:
  6595. --  -----
  6596. --    The intention to be stored is the intention with which the node
  6597. --    handle was opened to the file node.  When the file handle is
  6598. --    opened via the node handle, the intention is copied to the 
  6599. --    file handle.
  6600. --
  6601. ---------------------------------------------------------------------
  6602.  
  6603.     procedure Set_Intent(Ft     : in out File_Type; 
  6604.                          Intent : Intention) is 
  6605.     begin
  6606.         Ft.Intent(Intent'range ) := Intent; 
  6607.         Ft.Intent_Size := Intent'Last; 
  6608.     end Set_Intent; 
  6609.  
  6610. -----------------------  Get_Mode ----------------------------
  6611. --
  6612. --  Purpose:
  6613. --  -------
  6614. --    Internal procedure to fetch the file mode
  6615. --    from the CAIS file handle.
  6616. --
  6617. --  Parameters:
  6618. --  ----------
  6619. --    FT      initialized file handle.
  6620. --    Mode      file mode.
  6621. --    
  6622. --
  6623. --  Exceptions:
  6624. --  ----------
  6625. --    None raised.
  6626. --
  6627. --  Notes:
  6628. --  -----
  6629. --    The mode returned is the mode with which the file handle
  6630. --    was opened.
  6631. --
  6632. ---------------------------------------------------------------------
  6633.  
  6634.     procedure Get_Mode(Ft   : File_Type; 
  6635.                        Mode : in out File_Mode) is 
  6636.     begin
  6637.         Mode := Ft.Mode; 
  6638.     end Get_Mode; 
  6639.  
  6640. -----------------------  Set_Mode ----------------------------
  6641. --
  6642. --  Purpose:
  6643. --  -------
  6644. --    Internal procedure to store the file mode
  6645. --    into the CAIS file handle.
  6646. --
  6647. --  Parameters:
  6648. --  ----------
  6649. --    FT      initialized file handle.
  6650. --    Mode      file mode.
  6651. --    
  6652. --
  6653. --  Exceptions:
  6654. --  ----------
  6655. --    None raised.
  6656. --
  6657. --  Notes:
  6658. --  -----
  6659. --    The mode to be stored is the mode with which the file handle
  6660. --    is being opened (or reset).
  6661. --
  6662. ---------------------------------------------------------------------
  6663.  
  6664.     procedure Set_Mode(Ft   : in out File_Type; 
  6665.                        Mode : File_Mode) is 
  6666.     begin
  6667.         Ft.Mode := Mode; 
  6668.     end Set_Mode; 
  6669.  
  6670. -----------------------  Get_Name ----------------------------
  6671. --
  6672. --  Purpose:
  6673. --  -------
  6674. --    Internal procedure to fetch the pathname of the file node 
  6675. --    from the CAIS file handle.
  6676. --
  6677. --  Parameters:
  6678. --  ----------
  6679. --    FT      initialized file handle.
  6680. --    Name      name string.
  6681. --    Lastchar  index of last non-blank character in Name.
  6682. --    
  6683. --
  6684. --  Exceptions:
  6685. --  ----------
  6686. --    None raised.
  6687. --
  6688. --  Notes:
  6689. --  -----
  6690. --    The pathname returned is the pathname from the node handle
  6691. --    through which the file handle was opened.
  6692. --
  6693. ---------------------------------------------------------------------
  6694.  
  6695.     procedure Get_Name(Ft       : File_Type; 
  6696.                        Name     : in out String; 
  6697.                        Lastchar : in out Natural) is 
  6698.  
  6699.         Last : Natural; 
  6700.     begin
  6701.         Last := Last_Non_Space(Ft.Name); 
  6702.         Name(1 .. Last) := Ft.Name(1 .. Last); 
  6703.         Lastchar := Last; 
  6704.     end Get_Name; 
  6705.  
  6706. -----------------------  Set_Name ----------------------------
  6707. --
  6708. --  Purpose:
  6709. --  -------
  6710. --    Internal procedure to store the pathname of the file node 
  6711. --    into the CAIS file handle.
  6712. --
  6713. --  Parameters:
  6714. --  ----------
  6715. --    FT      initialized file handle.
  6716. --    Name      name string.
  6717. --    
  6718. --
  6719. --  Exceptions:
  6720. --  ----------
  6721. --    None raised.
  6722. --
  6723. --  Notes:
  6724. --  -----
  6725. --    The pathname to be stored is the pathname from the node handle
  6726. --    through which the file handle is being opened.
  6727. --
  6728. ---------------------------------------------------------------------
  6729.  
  6730.     procedure Set_Name(Ft   : in out File_Type; 
  6731.                        Name : String) is 
  6732.  
  6733.         Lastchar : Natural; 
  6734.     begin
  6735.         Lastchar := Last_Non_Space(Name); 
  6736.         Ft.Name := (others => ' '); 
  6737.         Ft.Name(1 .. Lastchar) := Name(1 .. Lastchar); 
  6738.     end Set_Name; 
  6739.  
  6740. -----------------------  Get_Form ----------------------------
  6741. --
  6742. --  Purpose:
  6743. --  -------
  6744. --    Internal function which returns the form list of the file node 
  6745. --    from the CAIS file handle.
  6746. --
  6747. --  Parameters:
  6748. --  ----------
  6749. --    FT      initialized file handle.
  6750. --    
  6751. --
  6752. --  Exceptions:
  6753. --  ----------
  6754. --    None raised.
  6755. --
  6756. --  Notes:
  6757. --  -----
  6758. --    Conversion between form strings for external files and the
  6759. --    CAIS form is not implemented in the prototype.
  6760. --
  6761. ---------------------------------------------------------------------
  6762.  
  6763.     function Get_Form(Ft : File_Type) return List_Type is 
  6764.     begin
  6765.         return Ft.Form; 
  6766.     end Get_Form; 
  6767.  
  6768. -----------------------  Set_Form ----------------------------
  6769. --
  6770. --  Purpose:
  6771. --  -------
  6772. --    Internal procedure which stores the form list of the file node 
  6773. --    into the CAIS file handle.
  6774. --
  6775. --  Parameters:
  6776. --  ----------
  6777. --    FT      initialized file handle.
  6778. --    Form      list of form entries.
  6779. --    
  6780. --
  6781. --  Exceptions:
  6782. --  ----------
  6783. --    None raised.
  6784. --
  6785. --  Notes:
  6786. --  -----
  6787. --    Conversion between form strings for external files and the
  6788. --    CAIS form is not implemented in the prototype.
  6789. --
  6790. ---------------------------------------------------------------------
  6791.  
  6792.     procedure Set_Form(Ft   : in out File_Type; 
  6793.                        Form : List_Type) is 
  6794.     begin
  6795.         Copy(Ft.Form, Form); 
  6796.     end Set_Form; 
  6797.  
  6798. ---------------------------------------------------------------------
  6799. end Io_Definitions; 
  6800. ---------------------------------------------------------------------
  6801. --::::::::::::::
  6802. --cais_sequential_io_body.a
  6803. --::::::::::::::
  6804.  
  6805.  
  6806. ----------------------------------------------------------------------
  6807. --                Package  S E Q U E N T I A L _ I O
  6808. --                (Package Body)
  6809. --
  6810. --         CAIS Sequential_Io Access Method
  6811. --           Operations for File Node Input/Output
  6812. --
  6813. --
  6814. --
  6815. --                  Ada Software Engineering Group
  6816. --                      The MITRE Corporation
  6817. --                         McLean, VA 22102
  6818. --
  6819. --
  6820. --            Wed Oct  9 13:38:28 EDT 1985
  6821. --
  6822. --                 (Unclassified and uncopyrighted)
  6823. --
  6824. ----------------------------------------------------------------------
  6825. ----------------------------------------------------------------------
  6826. --              C A I S _ S E Q U E N T I A L _ I O
  6827. --
  6828. --  Purpose:
  6829. --  -------
  6830. --        This package provides facilities for sequentially accessing
  6831. --        data elements in CAIS files.  These facilities are comparable
  6832. --        to those described in the SEQUENTIAL_IO package of the Ada LRM.
  6833. --
  6834. --  Usage:
  6835. --  -----
  6836. --        Usage is analogous to usage of the Ada Sequential_Io 
  6837. --        package.  The package is instantiated with the element
  6838. --        type of the file as parameter.  CAIS file nodes 
  6839. --        correspond to ordinary Ada files, and file handles are 
  6840. --        Ada objects of CAIS subtype Sequential_Io.File_Type,
  6841. --        corresponding to Ada (LRM) Sequential_Io.File_Type.
  6842. --        CAIS Sequential_Io input and output operations 
  6843. --        access the contents of CAIS file nodes.
  6844. --
  6845. --  Notes:
  6846. --  -----
  6847. --        This is a version of the package CAIS.SEQUENTIAL_IO,
  6848. --        specified in MIL-STD-CAIS section 5.3.3; all references
  6849. --        to the CAIS specification refer to the CAIS specification
  6850. --        dated 31 January 1985.  This implementation deviates 
  6851. --        from the CAIS specification in that a distinct type,
  6852. --        File_Type is employed in the package, following the
  6853. --        Ada LRM.  The package instantiates another generic 
  6854. --        package, Sequential_Io_Definitions, that supports the 
  6855. --        abstract data type, File_Type.
  6856. --
  6857. --  Revision History:
  6858. --  ----------------
  6859. --        None.
  6860. --
  6861. -------------------------------------------------------------------
  6862.  
  6863. with Sequential_Io; 
  6864. with Unchecked_Conversion; 
  6865.  
  6866. separate(Cais)
  6867. package body Sequential_Io is 
  6868.  
  6869.     use Node_Definitions; 
  6870.     use Node_Representation; 
  6871.     use Node_Management; 
  6872.     use Node_Internals; 
  6873.     use Cais_Utilities; 
  6874.     use List_Utilities; 
  6875.     use Cais_Host_Dependent; 
  6876.     use Seq_Io_Definitions; 
  6877.     use Identifier_Items; 
  6878.  
  6879.                                         -- Local instantiation to provide
  6880.                                         --   access to Sequential_Io operations
  6881.                                         --   using unchecked conversion from
  6882.                                         --   corresponding definition of
  6883.                                         --   pointer to Ada File_Type in private
  6884.                                         --   part of Sequential_Io_Definitions
  6885.     package Seq_Io is 
  6886.         new Standard.Sequential_Io(Element_Type); 
  6887.     type File_Ptr is access Seq_Io.File_Type; 
  6888.     function Convert is 
  6889.         new Unchecked_Conversion(Sequential_File_Ptr, File_Ptr); 
  6890.  
  6891.     type Mode_Array is array(Positive range <>) of File_Mode; 
  6892.  
  6893.   ----------------------------   Check_Open   -----------------------------
  6894.   --
  6895.   --    Local procedure which checks that file handle has required open status
  6896.   --
  6897.   ---------------------------------------------------------------------------
  6898.  
  6899.     procedure Check_Open(File            : File_Type; 
  6900.                          Required_Result : Boolean) is 
  6901.     begin
  6902.         if Is_Open(File) /= Required_Result then 
  6903.             raise Seq_Io_Definitions.Status_Error; 
  6904.         end if; 
  6905.     end Check_Open; 
  6906.  
  6907.   ----------------------------   Check_Open   -----------------------------
  6908.   --
  6909.   --    Local procedure which checks that node handle has required open status
  6910.   --
  6911.   ---------------------------------------------------------------------------
  6912.  
  6913.     procedure Check_Open(Node            : Cais.Node_Type; 
  6914.                          Required_Result : Boolean) is 
  6915.     begin
  6916.         if Is_Open(Node) /= Required_Result then 
  6917.             raise Node_Definitions.Status_Error; 
  6918.         end if; 
  6919.     end Check_Open; 
  6920.  
  6921. ---------------------------    Check_Not_Mode    --------------------------------
  6922. --
  6923. --    Local procedure which checks that mode is not in array of
  6924. --    excluded modes
  6925. --
  6926. -------------------------------------------------------------------------------
  6927.  
  6928.     procedure Check_Not_Mode(File      : File_Type; 
  6929.                              Bad_Modes : Mode_Array) is 
  6930.     begin
  6931.         for I in Bad_Modes'range loop
  6932.             if Bad_Modes(I) = Mode(File) then 
  6933.                 raise Mode_Error; 
  6934.             end if; 
  6935.         end loop; 
  6936.     end Check_Not_Mode; 
  6937.  
  6938. ---------------------------- Validate_Mode -----------------------------------
  6939. --
  6940. --    Local procedure which checks that Mode and intent of file_node
  6941. --    specified by File are consistent, and determines corresponding
  6942. --    Text_Io File_Mode.
  6943. --
  6944. -------------------------------------------------------------------------------
  6945.  
  6946.     procedure Validate_Mode(File    : File_Type; 
  6947.                             Mode    : File_Mode; 
  6948.                             Seqmode : in out Seq_Io.File_Mode) is 
  6949.         Intent   : Intention(Pragmatics.Intent_Count); 
  6950.         Intended : Intention(1 .. 2); 
  6951.     begin
  6952.                                                         --Determine mode and
  6953.                                                         --check intentions
  6954.         Get_Intent(File, Intent); 
  6955.         case Mode is 
  6956.             when Seq_Io_Definitions.In_File => 
  6957.                 Seqmode := Seq_Io.In_File; 
  6958.                 Check_Intentions(Intent, Read_Contents); 
  6959.             when Seq_Io_Definitions.Out_File => 
  6960.                 Seqmode := Seq_Io.Out_File; 
  6961.                 Check_Intentions(Intent, Write_Contents); 
  6962.             when Seq_Io_Definitions.Inout_File => 
  6963.                 Seqmode := Seq_Io.Out_File; 
  6964.                 Check_Intentions(Intent, (1 => Read_Contents, 2 => 
  6965.                     Write_Contents)); 
  6966.             when Seq_Io_Definitions.Append_File => 
  6967.                 Seqmode := Seq_Io.Out_File; 
  6968.                 Check_Intentions(Intent, Append_Contents); 
  6969.         end case; 
  6970.  
  6971.     end Validate_Mode; 
  6972.  
  6973. ---------------------------- Set_For_Append -----------------------------------
  6974. --
  6975. --    Local procedure which positions a file opened in Append_File
  6976. --    mode.  To accomplish this, the Ada implementation must copy out
  6977. --    the existing contents of the file, then copy it back. The underlying
  6978. --    file is left in Out_File mode, ready to write the next
  6979. --    record after the last record in the file.
  6980. --
  6981. -------------------------------------------------------------------------------
  6982.  
  6983.     procedure Set_For_Append(File : in out File_Type) is 
  6984.         Element            : Element_Type; 
  6985.         Image_File         : Seq_Io.File_Type; 
  6986.         Image_File_Name    : Name_String(1 .. Pragmatics.Max_Name_String); 
  6987.         Image_Last_Char    : Natural; 
  6988.         Contents_File_Name : Name_String(1 .. Pragmatics.Max_Name_String); 
  6989.         Contents_Last_Char : Natural; 
  6990.     begin
  6991.         Get_Contents_File_Name(File, Contents_File_Name, Contents_Last_Char); 
  6992.                                 -- Allocate file for temporary image
  6993.         Get_Unique_Filename(Image_File_Name, Image_Last_Char); 
  6994.  
  6995.                                 -- Copy file contents to image file
  6996.         Seq_Io.Open(Convert(Get_File_Type(File)).all, Seq_Io.In_File, 
  6997.             Contents_File_Name(1 .. Contents_Last_Char)); 
  6998.         Seq_Io.Open(Image_File, Seq_Io.Out_File, Image_File_Name(1 .. 
  6999.             Image_Last_Char)); 
  7000.  
  7001.         while not Seq_Io.End_Of_File(Convert(Get_File_Type(File)).all) loop
  7002.             Seq_Io.Read(Convert(Get_File_Type(File)).all, Element); 
  7003.             Seq_Io.Write(Image_File, Element); 
  7004.         end loop; 
  7005.         Seq_Io.Close(Image_File); 
  7006.         Seq_Io.Close(Convert(Get_File_Type(File)).all); 
  7007.  
  7008.                                 -- Copy image back to contents file
  7009.         Seq_Io.Open(Image_File, Seq_Io.In_File, Image_File_Name(1 .. 
  7010.             Image_Last_Char)); 
  7011.         Seq_Io.Open(Convert(Get_File_Type(File)).all, Seq_Io.Out_File, 
  7012.             Contents_File_Name(1 .. Contents_Last_Char)); 
  7013.  
  7014.         while not Seq_Io.End_Of_File(Image_File) loop
  7015.             Seq_Io.Read(Image_File, Element); 
  7016.             Seq_Io.Write(Convert(Get_File_Type(File)).all, Element); 
  7017.         end loop; 
  7018.         Seq_Io.Delete(Image_File); 
  7019.  
  7020.     end Set_For_Append; 
  7021.  
  7022.  
  7023. ----------------------     Create     ----------------------
  7024. --
  7025. --  Purpose:
  7026. --  -------
  7027. --        This procedure creates a file and its file node; the
  7028. --        file contains elements which may be accessed either
  7029. --        sequentially.  The attribute Access_Method is
  7030. --        assigned the value "(Sequential)" as part of the creation.
  7031. --
  7032. --  Parameters:
  7033. --  ----------
  7034. --    File    file handle, initially closed, to be opened.
  7035. --    Base    open node handle to the node which will be the
  7036. --        source of the primary relationship to the new
  7037. --        node.
  7038. --    Key    relationship key of the primary relationship to
  7039. --        be created.
  7040. --    Relation    relation name of the primary relationship to be created.
  7041. --    Mode    indicates mode of the file.
  7042. --    Form    indicates file characteristics.
  7043. --    Attributes
  7044. --        initial values for attributes of the new node.
  7045. --    Access_Control
  7046. --        defines the initial access control information
  7047. --        associated with the created node.
  7048. --    Level    defines the classification label for the created node.
  7049. --
  7050. --  Exceptions:
  7051. --  ----------
  7052. --    Name_Error
  7053. --        raised if a node already exists for the node specified
  7054. --        by Key and Relation or if Key or Relation is syntactically
  7055. --        illegal or if any node identifying a group specified in the
  7056. --        given Access_Control parameter is unobtainable.
  7057. --    Use_Error
  7058. --        raised if any of the parameters Access_Control, Level or
  7059. --        Attributes is syntactically or semantically illegal.
  7060. --        Use_Error is also raised if Relation is the name of a
  7061. --        predefined attribute other than File_Kind.  Also raised if
  7062. --        Relation is the name of a predefined relation which cannnot
  7063. --        be created by the user.
  7064. --    Status_Error
  7065. --        raised if Base is not an open node handle or if File is
  7066. --        an open file handle prior to the call.
  7067. --    Intent_Violation
  7068. --        raised if Base was not opened with an intent establishing
  7069. --        the right to append relationships.
  7070. --    Security_Violation
  7071. --        raised if the operation represents a violation of mandatory
  7072. --        access controls; raised only if the conditions for other
  7073. --        exceptions are not present.
  7074. --
  7075. --  Notes:
  7076. --  -----
  7077. --    This procedure is defined in section 5.3.3.2 of MIL-STD-CAIS,
  7078. --    dated 31 January 1985.
  7079. --    The additional interface for Create that is presented is
  7080. --    also provided.
  7081. --    NOTE:  The exception handler semantics of the additional
  7082. --    interface are not adequate.  The unconditional Close file
  7083. --    call may raise a Status_Error, causing the original
  7084. --    exception to be lost.
  7085. --
  7086. ---------------------------------------------------------------------
  7087.  
  7088.     procedure Create(File           : in out File_Type; 
  7089.                      Base           : in out Node_Type; 
  7090.                      Key            : Relationship_Key := Latest_Key; 
  7091.                      Relation       : Relation_Name := Default_Relation; 
  7092.                      Mode           : File_Mode := Inout_File; 
  7093.                      Form           : List_Type := Empty_List; 
  7094.                      Attributes     : List_Type := Empty_List; 
  7095.                      Access_Control : List_Type := Empty_List; 
  7096.                      Level          : List_Type := Empty_List) is 
  7097.  
  7098.  
  7099.         Node                   : Node_Type; 
  7100.                                         --Node to be created and associated
  7101.                                         --with this File
  7102.         Kind                   : constant Node_Kind := Node_Definitions.File; 
  7103.         Intent                 : Intention(1 .. 2); 
  7104.         Sequential_File_Mode   : File_Mode; 
  7105.         Form_String            : String(1 .. 100); 
  7106.  
  7107.         User_Attributes        : List_Type; 
  7108.         Predefined_Attributes  : List_Type; 
  7109.         Predefined_Relations   : List_Type; 
  7110.  
  7111.         New_Contents_File_Name : String(1 .. Pragmatics.Max_Contents_File_Length
  7112.             ); 
  7113.         File_Name_Length       : Natural; 
  7114.         Last                   : Natural; 
  7115.  
  7116.  
  7117.   ---------------------------  Establish_Intent  ------------------------------
  7118.   --
  7119.   --    Local procedure which converts Mode parameter to Intent vector
  7120.   --    for node handle of new file node.
  7121.   --
  7122.   -----------------------------------------------------------------------------
  7123.  
  7124.         procedure Establish_Intent is 
  7125.         begin
  7126.             case Mode is 
  7127.                 when In_File => 
  7128.                     Intent := (1 => Read_Contents, 2 => Existence); 
  7129.                 when Out_File => 
  7130.                     Intent := (1 => Write_Contents, 2 => Existence); 
  7131.                 when Inout_File => 
  7132.                     Intent := (1 => Read_Contents, 2 => Write_Contents); 
  7133.                 when Append_File => 
  7134.                     Intent := (1 => Append_Contents, 2 => Existence); 
  7135.             end case; 
  7136.         end Establish_Intent; 
  7137.  
  7138.   -------------------------- Filter_Relationships ----------------------------
  7139.   --
  7140.   --    Local procedure which screens initial values for predefined 
  7141.   --    relationships of new file node.
  7142.   --    (Note:  this procedure is stubbed.)
  7143.   --
  7144.   ----------------------------------------------------------------------------
  7145.  
  7146.         procedure Filter_Relationships is 
  7147.         begin
  7148.             Copy(Predefined_Relations, Empty_List); 
  7149.         end Filter_Relationships; 
  7150.  
  7151.   -------------------------- Filter_Attributes -------------------------------
  7152.   --
  7153.   --    Local procedure which screens initial values for predefined 
  7154.   --    attributes of new file node.
  7155.   --    Attributes are divided into two lists, one for user attributes
  7156.   --    and one for predefined attributes.
  7157.   --
  7158.   ----------------------------------------------------------------------------
  7159.  
  7160.         procedure Filter_Attributes is 
  7161.  
  7162.             Attribute             : List_Type; 
  7163.             Name                  : Token_Type; 
  7164.             List_Value            : List_Type; 
  7165.  
  7166.             File_Kind             : Token_Type; 
  7167.             File_Kind_Present     : Boolean := False; 
  7168.             File_Kind_Value       : List_Type; 
  7169.             Secondary_Storage     : List_Type; 
  7170.             Queue                 : List_Type; 
  7171.  
  7172.             Access_Method         : Token_Type; 
  7173.             Access_Method_Present : Boolean := False; 
  7174.             Access_Method_Value   : List_Type; 
  7175.             Sequential            : Token_Type; 
  7176.                                                -- element of Access_Method list
  7177.  
  7178.             Queue_Kind            : Token_Type; 
  7179.             Queue_Kind_Present    : Boolean := False; 
  7180.             Queue_Kind_Value      : List_Type; 
  7181.             Solo                  : List_Type; 
  7182.  
  7183.             Position              : Position_Count; 
  7184.             Value_Kind            : Item_Kind; 
  7185.  
  7186.             Result_List           : List_Type; 
  7187.  
  7188.  
  7189.         --------------------------  Check_And_Set  ------------------------
  7190.         --
  7191.         --    Local procedure which checks and sets a Boolean variable used
  7192.         --    for recording predefined attributes seen.
  7193.         --
  7194.         ----------------------------------------------------------------------
  7195.  
  7196.             procedure Check_And_Set(Attribute_Present : in out Boolean) is 
  7197.             begin
  7198.                 if Attribute_Present then 
  7199.                     Trace.Report(
  7200.                         "CAIS Use_Error: Duplicate attribute in Cais.Sequential_Io.Create"
  7201.                         ); 
  7202.                     raise Node_Definitions.Use_Error; 
  7203.                 else 
  7204.                     Attribute_Present := True; 
  7205.                 end if; 
  7206.             end Check_And_Set; 
  7207.  
  7208.  
  7209.         -------------------------  Check_Syntax  ------------------------
  7210.         --
  7211.         --    Local procedure used for checking that list elements have
  7212.         --    the required item kind.
  7213.         --
  7214.         -----------------------------------------------------------------
  7215.  
  7216.             procedure Check_Syntax(Value_Kind    : Item_Kind; 
  7217.                                    Required_Kind : Item_Kind) is 
  7218.             begin
  7219.                 if Value_Kind /= Required_Kind then 
  7220.                     Trace.Report(
  7221.                         "CAIS Use_Error: Bad attribute value in Cais.Sequential_Io.Create"
  7222.                         ); 
  7223.                     raise Node_Definitions.Use_Error; 
  7224.                 end if; 
  7225.             end Check_Syntax; 
  7226.  
  7227.         begin
  7228.  
  7229.         -- Validate and filter predefined attributes
  7230.         --  into a list of initial values for predefined
  7231.         --  attributes, and a list of attributes which are
  7232.         --  user attributes to be created.
  7233.             Copy(User_Attributes, Empty_List); 
  7234.             Copy(Predefined_Attributes, Empty_List); 
  7235.  
  7236.             To_Token("File_Kind", File_Kind); 
  7237.             To_List("(Secondary_Storage)", Secondary_Storage); 
  7238.             To_List("(Queue)", Queue); 
  7239.  
  7240.             To_Token("Access_Method", Access_Method); 
  7241.             To_Token("Sequential", Sequential); 
  7242.  
  7243.             To_Token("Queue_Kind", Queue_Kind); 
  7244.             To_List("(Solo)", Solo); 
  7245.                                         -- Set defaults
  7246.             To_List("(Secondary_Storage)", File_Kind_Value); 
  7247.             To_List("(Sequential)", Access_Method_Value); 
  7248.             To_List("(Solo)", Queue_Kind_Value); 
  7249.  
  7250.                                         -- Filter attribute list
  7251.             if Get_List_Kind(Attributes) = Unnamed then 
  7252.                 raise Seq_Io_Definitions.Use_Error; 
  7253.             end if; 
  7254.  
  7255.             for I in 1 .. Length(Attributes) loop
  7256.  
  7257.                                                 -- extract and check attributes
  7258.                 Value_Kind := Get_Item_Kind(Attributes, I); 
  7259.                 Check_Syntax(Value_Kind, List_Item); 
  7260.                 Item_Name(Attributes, I, Name); 
  7261.                 if Predefined(To_Text(Name), Cais_Utilities.Attribute) then 
  7262.                                                 -- check for File_Kind
  7263.                     if Is_Equal(Name, File_Kind) then 
  7264.                         Check_And_Set(File_Kind_Present); 
  7265.                         Extract(Attributes, File_Kind, File_Kind_Value); 
  7266.                         if not Is_Equal(File_Kind_Value, Secondary_Storage) and 
  7267.                             then not Is_Equal(File_Kind_Value, Queue) then 
  7268.                             Trace.Report(
  7269.                                 "CAIS Use_Error: Invalid File_Kind in Cais.Sequential_Io.Create"
  7270.                                 ); 
  7271.                             raise Seq_Io_Definitions.Use_Error; 
  7272.                         end if; 
  7273.  
  7274.                                                 -- check for Queue_Kind
  7275.                     elsif Is_Equal(Name, Queue_Kind) then 
  7276.                         Check_And_Set(Queue_Kind_Present); 
  7277.                         Extract(Attributes, Queue_Kind, Queue_Kind_Value); 
  7278.                         if not Is_Equal(Queue_Kind_Value, Solo) then 
  7279.                             Trace.Report(
  7280.                                 "CAIS Use_Error: Invalid File_Kind in Cais.Sequential_Io.Create"
  7281.                                 ); 
  7282.                             raise Seq_Io_Definitions.Use_Error; 
  7283.                         end if; 
  7284.  
  7285.                                                 -- check for Access_Method
  7286.                     elsif Is_Equal(Name, Access_Method) then 
  7287.                         Check_And_Set(Access_Method_Present); 
  7288.                         Extract(Attributes, Access_Method, List_Value); 
  7289.  
  7290.                         begin   --  SEQUENTIAL must be included 
  7291.                             Position := Position_By_Value(List_Value, Sequential
  7292.                                 ); 
  7293.                             Copy(Access_Method_Value, List_Value); 
  7294.                         exception
  7295.                             when Search_Error => 
  7296.                                 Trace.Report(
  7297.                                     "CAIS Use_Error: Invalid Access_Method in Cais.Sequential_Io.Create"
  7298.                                     ); 
  7299.                                 raise Seq_Io_Definitions.Use_Error; 
  7300.                             when others => 
  7301.                                 raise; 
  7302.                         end; 
  7303.  
  7304.  
  7305.                     else 
  7306.                         Trace.Report(
  7307.                             "CAIS Use_Error: Invalid predefined attribute in Cais.Sequential_Io.Create"
  7308.                             ); 
  7309.                         raise Seq_Io_Definitions.Use_Error; 
  7310.                     end if; 
  7311.  
  7312.                 else            -- others must be user attributes
  7313.                     Extract(Attributes, Name, List_Value); 
  7314.                     Insert(User_Attributes, List_Value, Name, 0); 
  7315.                 end if; 
  7316.             end loop; 
  7317.  
  7318.                                         -- Check consistent use of File_Kind
  7319.                                         --  Queue, and Queue_Kind attributes
  7320.             if Queue_Kind_Present then 
  7321.                 if not Is_Equal(File_Kind_Value, Queue) then 
  7322.                     Trace.Report(
  7323.                         "CAIS Use_Error: Inconsistent Queue_Kind attribute in Cais.Sequential_Io.Create"
  7324.                         ); 
  7325.                     raise Seq_Io_Definitions.Use_Error; 
  7326.                 end if; 
  7327.             end if; 
  7328.  
  7329.                                         -- Attribute filter completed
  7330.                                         -- Construct predefined attribute list
  7331.  
  7332.                                         -- Initial value for Access_Method attr
  7333.             Insert(Predefined_Attributes, Access_Method_Value, Access_Method, 0)
  7334.                 ; 
  7335.  
  7336.             Insert(Predefined_Attributes, File_Kind_Value, File_Kind, 0); 
  7337.  
  7338.             if Is_Equal(File_Kind_Value, Queue) then 
  7339.                 Insert(Predefined_Attributes, Queue_Kind_Value, Queue_Kind, 0); 
  7340.             end if; 
  7341.  
  7342.         end Filter_Attributes; 
  7343.  
  7344.  
  7345.   -----------------------  Establish_Contents_File  ---------------------------
  7346.   --
  7347.   --    Local procedure used to obtain a uniquely-named contents file
  7348.   --    for the new file node, and record its name in the node handle.
  7349.   --
  7350.   -----------------------------------------------------------------------------
  7351.  
  7352.         procedure Establish_Contents_File is 
  7353.         begin
  7354.             Cais_Host_Dependent.Get_Unique_Filename(New_Contents_File_Name, 
  7355.                 File_Name_Length); 
  7356.             Set_Contents_File_Name(Node, New_Contents_File_Name(1 .. 
  7357.                 File_Name_Length)); 
  7358.  
  7359.         end Establish_Contents_File; 
  7360.  
  7361.     begin-- Cais.Sequential_Io.Create 
  7362.  
  7363.         Check_Open(Base, True); 
  7364.                              -- check that node handle is open
  7365.                              -- (Node_Definitions.Status_Error)
  7366.         Check_Open(File, False); 
  7367.                               -- check that file handle is not open
  7368.                              -- (Seq_Io_Definitions.Status_Error)
  7369.         Establish_Intent; 
  7370.         Filter_Relationships; 
  7371.         Filter_Attributes; 
  7372.         Establish_Contents_File; 
  7373.         Initialize(File); 
  7374.  
  7375.         -- Actually create the new file node
  7376.         --   (establishes its shadow file, checks status, sets attributes,
  7377.         --    opens file node)
  7378.         Node_Internals.Create_Node(Node => Node, Base => Base, Kind => Kind, 
  7379.             Internals_Attributes => Predefined_Attributes, User_Attributes => 
  7380.             User_Attributes, Internals_Relations => Predefined_Relations, Intent
  7381.             => Intent, Access_Control => Access_Control, Level => Level, Key
  7382.             => Key, Relation => Relation); 
  7383.  
  7384.         -- Open the file handle
  7385.         Open(File, Node, Mode); 
  7386.  
  7387.     exception
  7388.  
  7389.     -- exceptions that are propagated
  7390.         when Seq_Io_Definitions.Name_Error | Seq_Io_Definitions.Use_Error | 
  7391.             Seq_Io_Definitions.Status_Error | Seq_Io_Definitions.Device_Error | 
  7392.             Node_Definitions.Intent_Violation | Node_Definitions.
  7393.             Security_Violation => 
  7394.             raise; 
  7395.  
  7396.     -- exceptions that are mapped to other exceptions
  7397.         when Node_Definitions.Name_Error => 
  7398.             raise Seq_Io_Definitions.Name_Error; 
  7399.         when Node_Definitions.Use_Error => 
  7400.             raise Seq_Io_Definitions.Use_Error; 
  7401.         when Node_Definitions.Status_Error => 
  7402.             raise Seq_Io_Definitions.Status_Error; 
  7403.  
  7404.     -- predefined exceptions (propagated with trace)
  7405.         when Constraint_Error | Tasking_Error | Program_Error | Storage_Error | 
  7406.             Numeric_Error => 
  7407.             Trace.Report("PREDEFINED EXCEPTION in Cais.Sequential_Io.Create "); 
  7408.             raise; 
  7409.  
  7410.     -- unanticipated exceptions
  7411.         when others => 
  7412.             Trace.Report("UNANTICIPATED EXCEPTION in Cais.Sequential_Io.Create "
  7413.                 ); 
  7414.             raise Trace.Assertion_Violation; 
  7415.  
  7416.     end Create; 
  7417.  
  7418. -------------------------------------------------------------------------------
  7419. --
  7420. --    Alternate interface using Name (pathname) rather than Base, Relation,
  7421. --    and Key to refer to file node.
  7422. --
  7423. -------------------------------------------------------------------------------
  7424.  
  7425.     procedure Create(File           : in out File_Type; 
  7426.                      Name           : Name_String; 
  7427.                      Mode           : File_Mode := Inout_File; 
  7428.                      Form           : List_Type := Empty_List; 
  7429.                      Attributes     : List_Type := Empty_List; 
  7430.                      Access_Control : List_Type := Empty_List; 
  7431.                      Level          : List_Type := Empty_List) is 
  7432.         Base : Node_Type; 
  7433.     begin
  7434.         Open(Base, Base_Path(Name), (1 => Append_Relationships)); 
  7435.         Create(File, Base, Last_Key(Name), Last_Relation(Name), Mode, Form, 
  7436.             Attributes, Access_Control, Level); 
  7437.         Close(Base); 
  7438.     exception
  7439.         when others => 
  7440.             Close(File); 
  7441.             Close(Base); 
  7442.             raise; 
  7443.     end Create; 
  7444.  
  7445. ----------------------     Open     ----------------------
  7446. --
  7447. --  Purpose:
  7448. --  -------
  7449. --    This procedure opens a file handle on a file containing
  7450. --    elements of the generic parameter type, given an open node
  7451. --    handle on the file node.
  7452. --
  7453. --  Parameters:
  7454. --  ----------
  7455. --    File    file handle, initially closed, to be opened.
  7456. --    Node    open node handle to the file node.
  7457. --    Mode    indicates the mode of the file.
  7458. --
  7459. --  Exceptions:
  7460. --  ----------
  7461. --    Use_Error
  7462. --        raised if the attribute Access_Method of the file node
  7463. --        does not have the value Sequential or the element type of the
  7464. --        file does not correspond with the element type of this
  7465. --        instantiation of the CAIS Sequential_Io package.
  7466. --
  7467. --        also raised if the node identified by Node has a value of
  7468. --        Queue for the attribute File_Kind and a value of Mimic for
  7469. --        the attribute Queue_Kind and the mimic queue file identified
  7470. --        by File is being opened with Mode other than In_File but the
  7471. --        coupled file has been deleted.
  7472. --
  7473. --    Status_Error
  7474. --        raised if File is an open file handle at the time of the call
  7475. --        or if Node is not an open node handle.
  7476. --
  7477. --    Intent_Violation
  7478. --        raised if Node has not been opened with an intent 
  7479. --        establishing the access rights required for the Mode.
  7480. --
  7481. --  Notes:
  7482. --  -----
  7483. --    This procedure is defined in section 5.3.3.3 of MIL-STD-CAIS,
  7484. --    dated 31 January 1985.
  7485. --    The additional interface for Open that is presented is
  7486. --    also provided.
  7487. --    NOTE:  The exception handler semantics of the additional
  7488. --    interface are not adequate.  The unconditional Close file
  7489. --    call may raise a Status_Error, causing the original
  7490. --    exception to be lost.
  7491. --
  7492. ---------------------------------------------------------------------
  7493.  
  7494.     procedure Open(File : in out File_Type; 
  7495.                    Node : Node_Type; 
  7496.                    Mode : File_Mode) is 
  7497.         File_Name           : Name_String(1 .. Pragmatics.Max_Name_String); 
  7498.         Sequentialmode      : Seq_Io.File_Mode := Seq_Io.In_File; 
  7499.         Last_File_Char      : Natural; 
  7500.         Last_Path_Char      : Natural; 
  7501.  
  7502.         Pathname            : Name_String(1 .. Pragmatics.Max_Name_String); 
  7503.         Position            : Position_Count; 
  7504.         Attribute_List      : List_Type; 
  7505.  
  7506.         Access_Method       : Token_Type; 
  7507.         Access_Method_Value : List_Type; 
  7508.         Sequential          : Token_Type; 
  7509.  
  7510.         File_Kind           : Token_Type; 
  7511.         File_Kind_Value     : List_Type; 
  7512.         Queue               : List_Type; 
  7513.  
  7514.         Queue_Kind          : Token_Type; 
  7515.         Queue_Kind_Value    : List_Type; 
  7516.         Mimic               : List_Type; 
  7517.  
  7518.  
  7519.     begin
  7520.  
  7521.         Check_Open(Node, True); 
  7522.                               -- Node_Definitions.Status_Error if not open
  7523.         Check_Open(File, False); 
  7524.                                -- Seq_Io_Definitions.Status_Error if open
  7525.  
  7526.                                 -- check that node is file node
  7527.         if Get_Kind(Node) /= Node_Definitions.File then 
  7528.             raise Node_Definitions.Use_Error; 
  7529.         end if; 
  7530.  
  7531.         Initialize(File); 
  7532.         Set_Intent(File, Get_Intent(Node));                     --Set intentions
  7533.         Get_Shadow_File_Name(Node, File_Name, Last_File_Char); 
  7534.                                                         --Set Shadow file
  7535.         Set_Shadow_File_Name(File, File_Name(1 .. Last_File_Char)); 
  7536.         Get_Contents_File_Name(Node, File_Name, Last_File_Char); 
  7537.                                                         --Set contents file
  7538.         Set_Contents_File_Name(File, File_Name(1 .. Last_File_Char)); 
  7539.         Get_Pathname(Node, Pathname, Last_Path_Char);           --Set file node name
  7540.         Set_Name(File, Pathname(1 .. Last_Path_Char)); 
  7541.  
  7542.         Get_Node_Attributes(Node, Attribute_List); 
  7543.         To_Token("Access_Method", Access_Method); 
  7544.         To_Token("Sequential", Sequential); 
  7545.         begin                   -- Check Access_Method includes Sequential
  7546.             Extract(Attribute_List, Access_Method, Access_Method_Value); 
  7547.             Position := Position_By_Value(Access_Method_Value, Sequential); 
  7548.  
  7549.         exception
  7550.             when List_Utilities.Search_Error => 
  7551.                 Trace.Report(
  7552.                     "CAIS Use_Error: Invalid Access_Method in Cais.Sequential_Io.Open "
  7553.                     ); 
  7554.                 Trace.Report("Access_Method: " & To_Text(Access_Method_Value)); 
  7555.                 Trace.Report("Expected list containing: (Sequential)"); 
  7556.                 raise Seq_Io_Definitions.Use_Error; 
  7557.  
  7558.         end; 
  7559.  
  7560.         To_Token("File_Kind", File_Kind); 
  7561.         Extract(Attribute_List, File_Kind, File_Kind_Value); 
  7562.         To_List("(Queue)", Queue); 
  7563.         if Is_Equal(File_Kind_Value, Queue) then 
  7564.             To_Token("Queue_Kind", Queue_Kind); 
  7565.             Extract(Attribute_List, Queue_Kind, Queue_Kind_Value); 
  7566.             To_List("(Mimic)", Mimic); 
  7567.             if Is_Equal(File_Kind_Value, Queue) and then Is_Equal(
  7568.                 Queue_Kind_Value, Mimic) and then Mode /= In_File
  7569.            --!stub  and then coupled file has been deleted
  7570.             then 
  7571.                 Trace.Report(
  7572.                     "CAIS Use_Error: Mimic queue has coupled file deleted"); 
  7573.                 Trace.Report("                Mode is not In_File"); 
  7574.                 raise Seq_Io_Definitions.Use_Error; 
  7575.             end if; 
  7576.         end if; 
  7577.  
  7578.  
  7579.         Validate_Mode(File, Mode, Sequentialmode);      --checks modes and
  7580.                                                         --proper intentions
  7581.                                                         --Check Use errors
  7582.         Set_Mode(File, Mode);                   --Set Mode
  7583.  
  7584.         if Mode = Append_File then 
  7585.             Set_For_Append(File);               --Open for Append_File
  7586.         else                                    --Open file
  7587.             Seq_Io.Open(Convert(Get_File_Type(File)).all, Sequentialmode, 
  7588.                 File_Name(1 .. Last_File_Char)); 
  7589.         end if; 
  7590.  
  7591.     exception
  7592.  
  7593.     -- exceptions that are propagated
  7594.         when Seq_Io_Definitions.Use_Error | Seq_Io_Definitions.Status_Error | 
  7595.             Seq_Io_Definitions.Device_Error | Node_Definitions.Intent_Violation
  7596.             => 
  7597.             raise; 
  7598.  
  7599.  
  7600.     -- exceptions that are mapped to other exceptions
  7601.     -- Search_Error looking for Sequential in Access_Method list is
  7602.     --    mapped to Use_Error.
  7603.         when Node_Definitions.Use_Error => 
  7604.             raise Seq_Io_Definitions.Use_Error; 
  7605.         when Node_Definitions.Status_Error => 
  7606.             raise Seq_Io_Definitions.Status_Error; 
  7607.  
  7608.     -- predefined exceptions (propagated with trace)
  7609.         when Constraint_Error | Tasking_Error | Program_Error | Storage_Error | 
  7610.             Numeric_Error => 
  7611.             Trace.Report("PREDEFINED EXCEPTION in Cais.Sequential_Io.Open "); 
  7612.             raise; 
  7613.  
  7614.     -- unanticipated exceptions
  7615.         when others => 
  7616.             Trace.Report("UNANTICIPATED EXCEPTION in Cais.Sequential_Io.Open ")
  7617.                 ; 
  7618.             raise Trace.Assertion_Violation; 
  7619.  
  7620.     end Open; 
  7621.  
  7622. -------------------------------------------------------------------------------
  7623. --
  7624. --    Alternate interface using Name (pathname) rather than Base, Relation,
  7625. --    and Key to refer to file node.
  7626. --
  7627. -------------------------------------------------------------------------------
  7628.  
  7629.     procedure Open(File : in out File_Type; 
  7630.                    Name : Name_String; 
  7631.                    Mode : File_Mode) is 
  7632.         Node : Node_Type; 
  7633.     begin
  7634.         case Mode is 
  7635.             when In_File => 
  7636.                 Open(Node, Name, (1 => Read_Contents)); 
  7637.             when Out_File => 
  7638.                 Open(Node, Name, (1 => Write_Contents)); 
  7639.             when Inout_File => 
  7640.                 Open(Node, Name, (Read_Contents, Write_Contents)); 
  7641.             when Append_File => 
  7642.                 Open(Node, Name, (1 => Append_Contents)); 
  7643.         end case; 
  7644.  
  7645.         Open(File, Node, Mode); 
  7646.         Close(Node); 
  7647.     exception
  7648.         when others => 
  7649.             if Is_Open(File) then 
  7650.                 Close(File); 
  7651.             end if; 
  7652.             Close(Node); 
  7653.             raise; 
  7654.     end Open; 
  7655.  
  7656. ----------------------     Close     ----------------------
  7657. --
  7658. --  Purpose:
  7659. --  -------
  7660. --    Closes file handle to CAIS file node.
  7661. --
  7662. --  Parameters:
  7663. --  ----------
  7664. --    File    open file handle.
  7665. --
  7666. --  Exceptions:
  7667. --  ----------
  7668. --    Status_Error
  7669. --        raised if file handle is not open.
  7670. --
  7671. --  Notes:
  7672. --  -----
  7673. --    Semantics correspond to Ada LRM, Section 14.2.1
  7674. --
  7675. ---------------------------------------------------------------------
  7676.  
  7677.     procedure Close(File : in out File_Type) is 
  7678.     begin
  7679.         Check_Open(File, True);         -- Status_Error if not open
  7680.         Seq_Io.Close(Convert(Get_File_Type(File)).all); -- Close contents file
  7681.         Deallocate(File);                       -- Deallocate file handle
  7682.     exception
  7683.     -- exceptions that are propagated
  7684.         when Seq_Io_Definitions.Status_Error | Seq_Io_Definitions.Device_Error
  7685.             => 
  7686.             raise; 
  7687.  
  7688.     -- predefined exceptions (propagated with trace)
  7689.         when Constraint_Error | Tasking_Error | Program_Error | Storage_Error | 
  7690.             Numeric_Error => 
  7691.             Trace.Report("PREDEFINED EXCEPTION in Cais.Sequential_Io.Close "); 
  7692.             raise; 
  7693.  
  7694.     -- unanticipated exceptions
  7695.         when others => 
  7696.             Trace.Report("UNANTICIPATED EXCEPTION in Cais.Sequential_Io.Close ")
  7697.                 ; 
  7698.             raise Trace.Assertion_Violation; 
  7699.  
  7700.     end Close; 
  7701.  
  7702. ----------------------     Delete     ----------------------
  7703. --
  7704. --  Purpose:
  7705. --  -------
  7706. --    This procedure deletes the CAIS file identified
  7707. --    by File.  
  7708. --    In addition to the semantics specified in the LRM,
  7709. --    the node associated with the open file handle File
  7710. --    is made unobtainable as if a call to the Delete_Node
  7711. --    procedure had been made.
  7712. --
  7713. --  Parameters:
  7714. --  ----------
  7715. --    File    an open file handle on the file being deleted.
  7716. --
  7717. --  Exceptions:
  7718. --  ----------
  7719. --    Name_Error
  7720. --        raised if the parent node of the node associated with
  7721. --        the file identified by File is inaccessible.
  7722. --    Use_Error
  7723. --        raised if any primary relationships emanate from the
  7724. --        node associated with the file identified by File.
  7725. --    Status_Error
  7726. --        raised if File is not an open file handle.
  7727. --    Lock_Error
  7728. --        raised if access with intent Write_Relationships to the
  7729. --        parent of the node to be deleted cannot be obtained due
  7730. --        to an existing lock on the node.
  7731. --    Access_Violation
  7732. --        raised if the current process does not have sufficient
  7733. --        discretionary access control rights to obtain access to
  7734. --        the parent of the node to be deleted with intent
  7735. --        Exclusive_Write; only raised if the conditions for
  7736. --        Name_Error are not present.
  7737. --    Security_Violation
  7738. --        raised if the operation represents a violation of mandatory
  7739. --        access controls; raised only if the conditions for other
  7740. --        exceptions are not present.
  7741. --
  7742. --  Notes:
  7743. --  -----
  7744. --    This procedure is defined in section 5.3.3.4 of MIL-STD-CAIS,
  7745. --    dated 31 January 1985.
  7746. --
  7747. ---------------------------------------------------------------------
  7748.  
  7749.     procedure Delete(File : in out File_Type) is 
  7750.         Name : String(1 .. Pragmatics.Max_Name_String); 
  7751.         Node : Node_Type; 
  7752.         Last : Natural; 
  7753.     begin
  7754.         Check_Open(File, True);  -- Status_Error if not open
  7755.  
  7756.         Get_Name(File, Name, Last);     -- Get file node name
  7757.         Close(File);                    -- Close contents file
  7758.         Open(Node, Name(1 .. Last),             -- Make file node unobtainable
  7759.         (1 => Read_Relationships, 2 => Exclusive_Write)); 
  7760.         Delete_Node(Node); 
  7761.  
  7762.     exception
  7763.  
  7764.     -- exceptions that are propagated
  7765.         when Seq_Io_Definitions.Use_Error | Seq_Io_Definitions.Status_Error | 
  7766.             Seq_Io_Definitions.Device_Error | Node_Definitions.Lock_Error | 
  7767.             Node_Definitions.Access_Violation | Node_Definitions.
  7768.             Security_Violation => 
  7769.             raise; 
  7770.  
  7771.  
  7772.     -- exceptions that are mapped to other exceptions
  7773.         when Node_Definitions.Name_Error => 
  7774.             raise Seq_Io_Definitions.Name_Error; 
  7775.         when Node_Definitions.Use_Error => 
  7776.             raise Seq_Io_Definitions.Use_Error; 
  7777.  
  7778.     -- predefined exceptions (propagated with trace)
  7779.         when Constraint_Error | Tasking_Error | Program_Error | Storage_Error | 
  7780.             Numeric_Error => 
  7781.             Trace.Report("PREDEFINED EXCEPTION in Cais.Sequential_Io.Delete "); 
  7782.             raise; 
  7783.  
  7784.     -- unanticipated exceptions
  7785.         when others => 
  7786.             Trace.Report("UNANTICIPATED EXCEPTION in Cais.Sequential_Io.Delete "
  7787.                 ); 
  7788.             raise Trace.Assertion_Violation; 
  7789.  
  7790.     end Delete; 
  7791.  
  7792. ----------------------     Reset     ----------------------
  7793. --
  7794. --  Purpose:
  7795. --  -------
  7796. --    Reset the file mode of a CAIS file.
  7797. --
  7798. --  Parameters:
  7799. --  ----------
  7800. --    File    An open file handle on the file being reset.
  7801. --    Mode    Indicates the mode of the file.
  7802. --
  7803. --  Exceptions:
  7804. --  ----------
  7805. --    See note.
  7806. --
  7807. --  Notes:
  7808. --  -----
  7809. --    This procedure is defined as in section 5.3.4.5 of MIL-STD-CAIS,
  7810. --    dated 31 January 1985.
  7811. --    Semantics of this procedure are not restricted to Ada LRM
  7812. --    semantics, pending clarification of the interaction of access
  7813. --    methods in the CAIS.
  7814. --
  7815. --    Although no exceptions are defined in the CAIS, checking of
  7816. --    Status_Error and Use_Error for invalid mode is done.
  7817. ---------------------------------------------------------------------
  7818.  
  7819.     procedure Reset(File : in out File_Type; 
  7820.                     Mode : File_Mode) is 
  7821.         Seqmode : Seq_Io.File_Mode := Seq_Io.In_File; 
  7822.     begin
  7823.         Check_Open(File, True);         -- Status_Error if not open
  7824.         Validate_Mode(File, Mode, Seqmode); -- Confirm access rights
  7825.         Set_Mode(File, Mode);                -- Record current CAIS mode
  7826.         Seq_Io.Reset(Convert(Get_File_Type(File)).all, Seqmode); -- Reset contents file
  7827.     exception
  7828.  
  7829.       -- exceptions that are propagated
  7830.         when Seq_Io_Definitions.Status_Error | Seq_Io_Definitions.Use_Error | 
  7831.             Seq_Io_Definitions.Device_Error | Node_Definitions.Intent_Violation
  7832.             => 
  7833.             raise; 
  7834.  
  7835.  
  7836.       -- exceptions that are mapped to other exceptions
  7837.  
  7838.       -- predefined exceptions (propagated with trace)
  7839.         when Constraint_Error | Tasking_Error | Program_Error | Storage_Error | 
  7840.             Numeric_Error => 
  7841.             Trace.Report("PREDEFINED EXCEPTION in Cais.Sequential_Io.Reset "); 
  7842.             raise; 
  7843.  
  7844.       -- unanticipated exceptions
  7845.         when others => 
  7846.             Trace.Report("UNANTICIPATED EXCEPTION in Cais.Sequential_Io.Reset ")
  7847.                 ; 
  7848.             raise Trace.Assertion_Violation; 
  7849.  
  7850.     end Reset; 
  7851.  
  7852.  
  7853. ----------------------     Reset     ----------------------
  7854. --
  7855. --  Purpose:
  7856. --  -------
  7857. --    Reset a CAIS file.
  7858. --
  7859. --  Parameters:
  7860. --  ----------
  7861. --    File    An open file handle on the file being reset.
  7862. --
  7863. --  Exceptions:
  7864. --  ----------
  7865. --    None raised.
  7866. --
  7867. --  Notes:
  7868. --  -----
  7869. --    This procedure is defined as in section 5.3.4.5 of MIL-STD-CAIS,
  7870. --    dated 31 January 1985.
  7871. --    Semantics of this procedure are not restricted to Ada LRM
  7872. --    semantics, pending clarification of the interaction of access
  7873. --    methods in the CAIS.
  7874. ---------------------------------------------------------------------
  7875.  
  7876.     procedure Reset(File : in out File_Type) is 
  7877.     begin
  7878.         Check_Open(File, True);         -- Status_Error if not open
  7879.         Seq_Io.Reset(Convert(Get_File_Type(File)).all); -- Reset contents file
  7880.     exception
  7881.         -- exceptions that are propagated
  7882.         when Seq_Io_Definitions.Status_Error | Seq_Io_Definitions.Use_Error | 
  7883.             Seq_Io_Definitions.Device_Error => 
  7884.             raise; 
  7885.  
  7886.         -- predefined exceptions (propagated with trace)
  7887.         when Constraint_Error | Tasking_Error | Program_Error | Storage_Error | 
  7888.             Numeric_Error => 
  7889.             Trace.Report("PREDEFINED EXCEPTION in Cais.Sequential_Io.Reset "); 
  7890.             raise; 
  7891.  
  7892.         -- unanticipated exceptions
  7893.         when others => 
  7894.             Trace.Report("UNANTICIPATED EXCEPTION in Cais.Sequential_Io.Reset ")
  7895.                 ; 
  7896.             raise Trace.Assertion_Violation; 
  7897.  
  7898.     end Reset; 
  7899.  
  7900. ----------------------     Mode     ----------------------
  7901. --
  7902. --  Purpose:
  7903. --  -------
  7904. --    Returns the current mode of the current CAIS file.
  7905. --
  7906. --  Parameters:
  7907. --  ----------
  7908. --    File    open file handle.
  7909. --
  7910. --  Exceptions:
  7911. --  ----------
  7912. --    Status_Error
  7913. --        raised if file handle is not open.
  7914. --
  7915. --  Notes:
  7916. --  -----
  7917. --    Semantics correspond to Ada LRM, Section 14.2.1
  7918. --
  7919. ---------------------------------------------------------------------
  7920.  
  7921.     function Mode(File : File_Type) return File_Mode is 
  7922.         Mode : File_Mode; 
  7923.     begin
  7924.         Check_Open(File, True);         -- Status_Error if not open
  7925.         Seq_Io_Definitions.Get_Mode(File, Mode); 
  7926.         return Mode; 
  7927.     exception
  7928.         -- exceptions that are propagated
  7929.         when Seq_Io_Definitions.Status_Error | Seq_Io_Definitions.Device_Error
  7930.             => 
  7931.             raise; 
  7932.  
  7933.         -- predefined exceptions (propagated with trace)
  7934.         when Constraint_Error | Tasking_Error | Program_Error | Storage_Error | 
  7935.             Numeric_Error => 
  7936.             Trace.Report("PREDEFINED EXCEPTION in Cais.Sequential_Io.Mode "); 
  7937.             raise; 
  7938.  
  7939.         -- unanticipated exceptions
  7940.         when others => 
  7941.             Trace.Report("UNANTICIPATED EXCEPTION in Cais.Sequential_Io.Mode ")
  7942.                 ; 
  7943.             raise Trace.Assertion_Violation; 
  7944.  
  7945.     end Mode; 
  7946.  
  7947. ----------------------     Name     ----------------------
  7948. --
  7949. --  Purpose:
  7950. --  -------
  7951. --    Returns a string containing the name of the CAIS file 
  7952. --    node currently associated with the file handle.
  7953. --
  7954. --  Parameters:
  7955. --  ----------
  7956. --    File    open file handle.
  7957. --
  7958. --  Exceptions:
  7959. --  ----------
  7960. --    Status_Error
  7961. --        raised if file handle is not open.
  7962. --
  7963. --  Notes:
  7964. --  -----
  7965. --    Semantics correspond to Ada LRM, Section 14.2.1
  7966. --
  7967. ---------------------------------------------------------------------
  7968.  
  7969.     function Name(File : File_Type) return String is 
  7970.         File_Node_Name : String(1 .. Pragmatics.Max_Name_String); 
  7971.         Last           : Natural; 
  7972.     begin
  7973.         Check_Open(File, True);         -- Status_Error if not open
  7974.         Get_Name(File, File_Node_Name, Last); 
  7975.         return File_Node_Name(1 .. Last); 
  7976.     exception
  7977.         -- exceptions that are propagated
  7978.         when Seq_Io_Definitions.Status_Error | Seq_Io_Definitions.Device_Error
  7979.             => 
  7980.             raise; 
  7981.  
  7982.         -- predefined exceptions (propagated with trace)
  7983.         when Constraint_Error | Tasking_Error | Program_Error | Storage_Error | 
  7984.             Numeric_Error => 
  7985.             Trace.Report("PREDEFINED EXCEPTION in Cais.Sequential_Io.Name "); 
  7986.             raise; 
  7987.  
  7988.         -- unanticipated exceptions
  7989.         when others => 
  7990.             Trace.Report("UNANTICIPATED EXCEPTION in Cais.Sequential_Io.Name ")
  7991.                 ; 
  7992.             raise Trace.Assertion_Violation; 
  7993.  
  7994.     end Name; 
  7995.  
  7996. ----------------------     Form     ----------------------
  7997. --
  7998. --  Purpose:
  7999. --  -------
  8000. --    Returns the form string for the external file currently
  8001. --    associated with the given file.
  8002. --
  8003. --  Parameters:
  8004. --  ----------
  8005. --    File    open file handle.
  8006. --
  8007. --  Exceptions:
  8008. --  ----------
  8009. --    Status_Error
  8010. --        raised if file handle is not open.
  8011. --
  8012. --  Notes:
  8013. --  -----
  8014. --    Semantics correspond to Ada LRM, Section 14.2.1
  8015. --
  8016. ---------------------------------------------------------------------
  8017.  
  8018.     function Form(File : File_Type) return String is 
  8019.     begin
  8020.         Check_Open(File, True);         -- Status_Error if not open
  8021.         return Seq_Io.Form(Convert(Get_File_Type(File)).all); 
  8022.     exception
  8023.         -- exceptions that are propagated
  8024.         when Seq_Io_Definitions.Status_Error | Seq_Io_Definitions.Device_Error
  8025.             => 
  8026.             raise; 
  8027.  
  8028.         -- predefined exceptions (propagated with trace)
  8029.         when Constraint_Error | Tasking_Error | Program_Error | Storage_Error | 
  8030.             Numeric_Error => 
  8031.             Trace.Report("PREDEFINED EXCEPTION in Cais.Sequential_Io.Form "); 
  8032.             raise; 
  8033.  
  8034.         -- unanticipated exceptions
  8035.         when others => 
  8036.             Trace.Report("UNANTICIPATED EXCEPTION in Cais.Sequential_Io.Form ")
  8037.                 ; 
  8038.             raise Trace.Assertion_Violation; 
  8039.  
  8040.     end Form; 
  8041.  
  8042. ----------------------     Is_Open     ----------------------
  8043. --
  8044. --  Purpose:
  8045. --  -------
  8046. --    Returns TRUE if the file handle is open, otherwise returns FALSE.
  8047. --
  8048. --  Parameters:
  8049. --  ----------
  8050. --    File    file handle.
  8051. --
  8052. --  Exceptions:
  8053. --  ----------
  8054. --    None.
  8055. --
  8056. --  Notes:
  8057. --  -----
  8058. --    Semantics correspond to Ada LRM, Section 14.2.1
  8059. --
  8060. ---------------------------------------------------------------------
  8061.  
  8062.     function Is_Open(File : File_Type) return Boolean is 
  8063.     begin
  8064.         return (not Un_Initialized(File)) and then Seq_Io.Is_Open(Convert(
  8065.             Get_File_Type(File)).all); 
  8066.     exception
  8067.         -- exceptions that are propagated
  8068.         when Seq_Io_Definitions.Device_Error => 
  8069.             raise; 
  8070.  
  8071.         -- predefined exceptions (propagated with trace)
  8072.         when Constraint_Error | Tasking_Error | Program_Error | Storage_Error | 
  8073.             Numeric_Error => 
  8074.             Trace.Report("PREDEFINED EXCEPTION in Cais.Sequential_Io.Is_Open ")
  8075.                 ; 
  8076.             raise; 
  8077.  
  8078.         -- unanticipated exceptions
  8079.         when others => 
  8080.             Trace.Report(
  8081.                 "UNANTICIPATED EXCEPTION in Cais.Sequential_Io.Is_Open "); 
  8082.             raise Trace.Assertion_Violation; 
  8083.  
  8084.     end Is_Open; 
  8085.  
  8086.  
  8087. ---------------------------     Read     ---------------------------
  8088. --
  8089. --  Purpose:
  8090. --  -------
  8091. --    Reads an element from the given file, and returns the value
  8092. --    of this element in the Item parameter.
  8093. --
  8094. --  Parameters:
  8095. --  ----------
  8096. --    File    open file handle.
  8097. --    Item    returns element read from file.
  8098. --
  8099. --  Exceptions:
  8100. --  ----------
  8101. --    Status_Error
  8102. --        raised if file handle is not open.
  8103. --    Mode_Error
  8104. --        raised if the mode is not In_File.
  8105. --    End_Error
  8106. --        raised if no more elements can be read from the
  8107. --        given file.
  8108. --    Data_Error
  8109. --        raised if the element read cannot be interpreted
  8110. --        as a value of the generic parameter type.
  8111. --
  8112. --  Notes:
  8113. --  -----
  8114. --    Semantics follow Ada LRM Section 14.2.2.
  8115. --
  8116. ---------------------------------------------------------------------
  8117.  
  8118.     procedure Read(File : File_Type; 
  8119.                    Item : in out Element_Type) is 
  8120.     begin
  8121.         Check_Open(File, True);         -- Status_Error if not open
  8122.         Seq_Io.Read(Convert(Get_File_Type(File)).all, Item); 
  8123.     exception
  8124.         -- exceptions that are propagated
  8125.         when Seq_Io_Definitions.Status_Error | Seq_Io_Definitions.Mode_Error | 
  8126.             Seq_Io_Definitions.Data_Error | Seq_Io_Definitions.End_Error | 
  8127.             Seq_Io_Definitions.Device_Error => 
  8128.             raise; 
  8129.  
  8130.         -- predefined exceptions (propagated with trace)
  8131.         when Constraint_Error | Tasking_Error | Program_Error | Storage_Error | 
  8132.             Numeric_Error => 
  8133.             Trace.Report("PREDEFINED EXCEPTION in Cais.Sequential_Io.Read "); 
  8134.             raise; 
  8135.  
  8136.         -- unanticipated exceptions
  8137.         when others => 
  8138.             Trace.Report("UNANTICIPATED EXCEPTION in Cais.Sequential_Io.Read ")
  8139.                 ; 
  8140.             raise Trace.Assertion_Violation; 
  8141.  
  8142.     end Read; 
  8143.  
  8144. ---------------------------     Write     ---------------------------
  8145. --
  8146. --  Purpose:
  8147. --  -------
  8148. --    Writes the value of Item to the given file.
  8149. --
  8150. --  Parameters:
  8151. --  ----------
  8152. --    File    open file handle.
  8153. --    Item    element to be written to the file.
  8154. --
  8155. --  Exceptions:
  8156. --  ----------
  8157. --    Status_Error
  8158. --        raised if file handle is not open.
  8159. --    Mode_Error
  8160. --        raised if mode is not Out_File.
  8161. --    Use_Error
  8162. --        raised if the capacity of the file is exceeded.
  8163. --
  8164. --  Notes:
  8165. --  -----
  8166. --    Semantics follow Ada LRM Section 14.2.2.
  8167. --
  8168. ---------------------------------------------------------------------
  8169.  
  8170.     procedure Write(File : File_Type; 
  8171.                     Item : Element_Type) is 
  8172.     begin
  8173.         Check_Open(File, True);         -- Status_Error if not open
  8174.         Seq_Io.Write(Convert(Get_File_Type(File)).all, Item); 
  8175.     exception
  8176.         -- exceptions that are propagated
  8177.         when Seq_Io_Definitions.Status_Error | Seq_Io_Definitions.Use_Error | 
  8178.             Seq_Io_Definitions.Mode_Error | Seq_Io_Definitions.Device_Error => 
  8179.             raise; 
  8180.  
  8181.         -- predefined exceptions (propagated with trace)
  8182.         when Constraint_Error | Tasking_Error | Program_Error | Storage_Error | 
  8183.             Numeric_Error => 
  8184.             Trace.Report("PREDEFINED EXCEPTION in Cais.Sequential_Io.Write "); 
  8185.             raise; 
  8186.  
  8187.         -- unanticipated exceptions
  8188.         when others => 
  8189.             Trace.Report("UNANTICIPATED EXCEPTION in Cais.Sequential_Io.Write ")
  8190.                 ; 
  8191.             raise Trace.Assertion_Violation; 
  8192.  
  8193.     end Write; 
  8194.  
  8195. ----------------------     End_Of_File     ----------------------
  8196. --
  8197. --  Purpose:
  8198. --  -------
  8199. --    Returns True if no more elements can be read from the
  8200. --    given file;  otherwise returns False.
  8201. --
  8202. --  Parameters:
  8203. --  ----------
  8204. --    File    open file handle.
  8205. --
  8206. --  Exceptions:
  8207. --  ----------
  8208. --    Status_Error
  8209. --        raised if file handle is not open.
  8210. --    Mode_Error
  8211. --        raised if file mode is not In_File.
  8212. --
  8213. --  Notes:
  8214. --  -----
  8215. --    Semantics follow Ada LRM Section 14.2.2.
  8216. --
  8217. ---------------------------------------------------------------------
  8218.  
  8219.     function End_Of_File(File : File_Type) return Boolean is 
  8220.     begin
  8221.         Check_Open(File, True);         -- Status_Error if not open
  8222.         return Seq_Io.End_Of_File(Convert(Get_File_Type(File)).all); 
  8223.  
  8224.     exception
  8225.         -- exceptions that are propagated
  8226.         when Seq_Io_Definitions.Status_Error | Seq_Io_Definitions.Mode_Error | 
  8227.             Seq_Io_Definitions.Device_Error => 
  8228.             raise; 
  8229.  
  8230.         -- predefined exceptions (propagated with trace)
  8231.         when Constraint_Error | Tasking_Error | Program_Error | Storage_Error | 
  8232.             Numeric_Error => 
  8233.             Trace.Report(
  8234.                 "PREDEFINED EXCEPTION in Cais.Sequential_Io.End_Of_File "); 
  8235.             raise; 
  8236.  
  8237.         -- unanticipated exceptions
  8238.         when others => 
  8239.             Trace.Report(
  8240.                 "UNANTICIPATED EXCEPTION in Cais.Sequential_Io.End_Of_File "); 
  8241.             raise Trace.Assertion_Violation; 
  8242.  
  8243.     end End_Of_File; 
  8244.  
  8245. ---------------------------------------------------------------------
  8246. end Sequential_Io; 
  8247. ---------------------------------------------------------------------
  8248. --::::::::::::::
  8249. --cais_spec.a
  8250. --::::::::::::::
  8251. with Calendar; use Calendar; 
  8252. with Text_Io;  -- Not in Cais spec
  8253. with Direct_Io;  -- Not in Cais spec
  8254. with Sequential_Io;  -- Not in Cais spec
  8255. with Io_Exceptions; 
  8256. package Cais is 
  8257.  
  8258.     type Node_Type is limited private; 
  8259. ----------------------------------------------------------------------
  8260. --                       P R A G M A T I C S
  8261. --
  8262. --  Purpose:
  8263. --  -------
  8264. --    This package is the central location for implementation-defined
  8265. --    limits and values (e.g. maximum length of a CAIS pathname).
  8266. --    It is intended to limit the use of "magic numbers" distributed
  8267. --    throughout the CAIS prototype code.
  8268. --
  8269. --  Usage:
  8270. --  -----
  8271. --    Constants can be used in data structure declarations, constraint
  8272. --    checks, etc.
  8273. --
  8274. --  Example:
  8275. --  -------
  8276. --    Pathname_String  : String (1..Pragmatics.Max_Name_String);
  8277. --
  8278. --  Notes:
  8279. --  -----
  8280. --    None.
  8281. --
  8282. --  Revision History:
  8283. --  ----------------
  8284. --    None.
  8285. --
  8286. -------------------------------------------------------------------
  8287.  
  8288.     package Pragmatics is 
  8289.  
  8290.  
  8291.         Max_Name_String          : constant := 255; 
  8292.                                                  -- CAIS 4.5.1
  8293.  
  8294.         Max_Relationship_Key     : constant := 80; 
  8295.                                                  -- CAIS 4.5.1
  8296.  
  8297.         Max_Attribute_Name       : constant := 80; 
  8298.                                                  -- CAIS 4.5.1
  8299.  
  8300.         Max_Relationship_Name    : constant := 80; 
  8301.                                                  -- CAIS 4.5.1
  8302.  
  8303.     -- this should be set to the maximum of
  8304.     -- Max_Relationship_Key, Max_Relationship_Name, Max_Attribute_Name
  8305.         Max_Token_Size           : constant := 80; 
  8306.  
  8307.         Max_Shadow_File_Length   : constant := 100; 
  8308.                                                -- arbitrary length
  8309.  
  8310.         Max_Contents_File_Length : constant := 100; 
  8311.                                                 -- arbitrary length
  8312.  
  8313.         Max_Userid_Length        : constant := 10; 
  8314.                                                -- arbitrary length
  8315.  
  8316.         Max_User_Prefix_Length   : constant := 100; 
  8317.                                                -- arbitrary length
  8318.  
  8319.         Max_List_Length          : constant := 5000; 
  8320.                                           -- arbitrary length
  8321.  
  8322.         subtype Intent_Count is Integer range 1 .. 32; 
  8323.     end Pragmatics; 
  8324. ----------------------------------------------------------------------
  8325. --              C A I S _ N O D E _ D E F I N I T I O N S
  8326. --
  8327. --  Function:
  8328. --  --------
  8329. --      This package defines the Ada subtype "Node_Type".  It defines
  8330. --      certain enumeration and String types, and exceptions useful for
  8331. --      CAIS node manipulations.  
  8332. --
  8333. --  Usage:
  8334. --  -----
  8335. --    TBS
  8336. --
  8337. --  Example:
  8338. --  -------
  8339. --    TBS
  8340. --
  8341. --  Notes:
  8342. --  -----
  8343. --      This is a version of the package Node_Definitions,
  8344. --      specified in MIL-STD-CAIS section 5.1.1
  8345. --    The definition of type Node_Type is moved to package Cais in
  8346. --    anticipation of a change in the MIL-STD-CAIS.
  8347. --      Other portions of this specification that are NOT in
  8348. --      MIL-STD-CAIS specification (i.e. added for this implementation)
  8349. --      are so indicated.
  8350. --  
  8351. --  Revision History:
  8352. --  ----------------
  8353. --
  8354.  
  8355.     package Node_Definitions is 
  8356.  
  8357.         subtype Node_Type is Cais.Node_Type; 
  8358.  
  8359.         type Node_Kind is (File, Structural, Process); 
  8360.  
  8361.         type Intent_Specification is (Existence, Read, Write, Read_Attributes, 
  8362.             Write_Attributes, Append_Attributes, Read_Relationships, 
  8363.             Write_Relationships, Append_Relationships, Read_Contents, 
  8364.             Write_Contents, Append_Contents, Control, Execute, Exclusive_Read, 
  8365.             Exclusive_Write, Exclusive_Read_Attributes, 
  8366.             Exclusive_Write_Attributes, Exclusive_Append_Attributes, 
  8367.             Exclusive_Read_Relationships, Exclusive_Write_Relationships, 
  8368.             Exclusive_Append_Relationships, Exclusive_Read_Contents, 
  8369.             Exclusive_Write_Contents, Exclusive_Append_Contents, 
  8370.             Exclusive_Control); 
  8371.  
  8372.         type Intention is array(Positive range <>) of Intent_Specification; 
  8373.  
  8374.         subtype Name_String is String; 
  8375.         subtype Relationship_Key is String; 
  8376.         subtype Relation_Name is String; 
  8377.         subtype Form_String is String; 
  8378.  
  8379.  
  8380.         Current_User       : constant Name_String := "'Current_User"; 
  8381.         Current_Node       : constant Name_String := "'CURRENT_NODE"; 
  8382.         Current_Process    : constant Name_String := ":"; 
  8383.         Latest_Key         : constant Relationship_Key := "#"; 
  8384.         Default_Relation   : constant Relation_Name := "DOT"; 
  8385.         No_Delay           : constant Duration := Duration'First; 
  8386.  
  8387.  
  8388.         Status_Error       : exception; 
  8389.         Name_Error         : exception; 
  8390.         Use_Error          : exception; 
  8391.         Lock_Error         : exception; 
  8392.         Access_Violation   : exception; 
  8393.         Intent_Violation   : exception; 
  8394.         Security_Violation : exception; 
  8395.  
  8396.  
  8397.     end Node_Definitions; 
  8398.  
  8399. ----------------------------------------------------------------------
  8400. --                   L I S T _ U T I L I T I E S
  8401. --
  8402. --  Purpose:
  8403. --  -------
  8404. --    List_Utilities provides operations for objects of List_Type.  These
  8405. --    objects are heterogeneous lists of string, integer, float, sub-list,
  8406. --    and list items.  Operations provided include Insert, Extract, Replace,
  8407. --    Delete, and a value search.  Conmversions to and from text are also
  8408. --    provided.  Lists may be named or unnamed.  Related packages are
  8409. --    String_Items, Identifier_Items, Integer_Items, and Float_Items.
  8410. --  Usage:
  8411. --  -----
  8412. --    Lists are used to represent attribute values and parameters in CAIS.
  8413. --    Implementations may use Lists to represent relationships.
  8414. --
  8415. --  Example:
  8416. --  -------
  8417. --        To_List("(Integers=>(1,2), Identifier=>Ada_Name)", Sample);
  8418. --        Extract(Sample, 1, Integer_List);
  8419. --  Notes:
  8420. --  -----
  8421. --    The visibility of the internal package V_String is questionable and
  8422. --    should possibly be hidden.
  8423. --  Revision History:
  8424. --  ----------------
  8425. --    12-01-85 Changed Text_Length for Items: they now return Natural since
  8426. --         length may be 0 when item is a null string
  8427. --    12-01-85 Removed specification for V_String which was added to
  8428. --         List_Utilities_body.  V_String is now hidden in List_Utilities
  8429. --
  8430. -------------------------------------------------------------------
  8431.     package List_Utilities is 
  8432.  
  8433.  
  8434.    -- The following type and exception declarations are from
  8435.    -- CAIS 5.4.1.1
  8436.  
  8437.         type List_Type is limited private; 
  8438.         type Token_Type is limited private; 
  8439.         subtype Namestring is String; 
  8440.  
  8441.         type List_Kind is (Unnamed, Named, Empty); 
  8442.                                               -- See note above re "empty"
  8443.  
  8444.         type Item_Kind is (List_Item, String_Item, Integer_Item, Float_Item, 
  8445.             Identifier_Item); 
  8446.  
  8447.         subtype List_Text is String; 
  8448.         subtype Element_Text is String;    --ADDITION TO MIL_STD CAIS
  8449.         type Count is range 0 .. Integer'Last; 
  8450.         subtype Position_Count is Count range Count'First + 1 .. Count'Last; 
  8451.  
  8452.         Search_Error : exception; 
  8453.         Empty_List   : constant List_Type; 
  8454.  
  8455.  
  8456. -----------------------C O P Y----------------------------------
  8457. --
  8458. -- Purpose:
  8459. -- ---------
  8460. --    Returns in the the parameter T0_List a copy of the list value
  8461. --    of the parameter From_List.  Subsequent modification of either
  8462. --    list does not affect the other list.
  8463. --
  8464. -- Parameters:
  8465. -- ----------
  8466. --    To_List   is the list returned as a copy of the value of From_List
  8467. --    From_List is thew list to be copied.
  8468. --   
  8469. -- Exceptions:
  8470. -- ----------
  8471. --    None
  8472. --
  8473. -- Notes: MIL_STD CAIS 5.4.1.2
  8474. -- -----
  8475. --    None
  8476. ----------------------------------------------------------------
  8477.    -- MIL_STD CAIS 5.4.1.2
  8478.         procedure Copy(To_List   : in out List_Type; 
  8479.                        From_List : in List_Type); 
  8480.  
  8481. ---------------------T O _ L I S T------------------------------
  8482. --
  8483. -- Purpose: 
  8484. -- -------
  8485. --     Converts the external representation of a list to List_Type
  8486. --     and returns the converted value.  This function establishes
  8487. --     the list to be of named, unnamed, or null kind.
  8488. --
  8489. -- Parameters:
  8490. -- ----------
  8491. --     List_Literal is the string representation to be converted to a list
  8492. --     List         is the List_Type internal representation of List_Literal
  8493. --            
  8494. --
  8495. -- Exceptions: 
  8496. -- ----------  
  8497. --     Use_Error is raised if ther is a syntax error.
  8498. --    
  8499. -- Notes:  MIL_STD CAIS 5.4.1.3
  8500. -- -----
  8501. --
  8502. ----------------------------------------------------------------
  8503.    -- MIL_STD CAIS 5.4.1.3
  8504.         procedure To_List(List_Literal : in List_Text; 
  8505.                           List         : in out List_Type); 
  8506.  
  8507. --------------------T O _ T E X T-------------------------------
  8508. --
  8509. -- Purpose: 
  8510. -- -------
  8511. --     Returns thje external representation of the value of
  8512. --     list, as defined in MIL_STD CAIS 5.4
  8513. --
  8514. --
  8515. -- Parameters:
  8516. -- ----------
  8517. --     List   is a list_type to be converted to text
  8518. --     return string representation of List
  8519. --
  8520. -- Exceptions: 
  8521. -- ----------  
  8522. --     None
  8523. --    
  8524. --
  8525. --
  8526. -- Notes: MIL_STD CAIS 5.4.1.4
  8527. -- -----
  8528. --
  8529. --
  8530. ----------------------------------------------------------------
  8531.    -- MIL_STD CAIS 5.4.1.4
  8532.         function To_Text(List : in List_Type) return List_Text; 
  8533.  
  8534. --------------------I S _ E Q U A L-----------------------------
  8535. --
  8536. -- Purpose:
  8537. -- -------
  8538. --     returns True if the two lists are equal as determined by:
  8539. --
  8540. --    - Both lists are of the same kind (named, unnamed, or empty)
  8541. --    - Both lists contain the same number of items
  8542. --    - For each position, the values of list items at this position,
  8543. --      as obtained by Extract, are of the same kind and are equal
  8544. --      under the equality defined for this kind
  8545. --    - In thew case of named lists, for each position, the names of the
  8546. --      items at this position are equal under Token_Type equality
  8547. --
  8548. -- Parameters:
  8549. -- ----------
  8550. --        List1  is List_Type to be compared
  8551. --        List2  is List_Type to be compared
  8552. --        return TRUE if lists are of the same kind, have the same number
  8553. --         of items, and all corresponding names and items are equal
  8554. --            
  8555. --
  8556. -- Exceptions:
  8557. -- ----------
  8558. --      None
  8559. --
  8560. -- Notes: MIL_STD CAIS 5.4.1.5
  8561. -- -----
  8562. --
  8563. ----------------------------------------------------------------
  8564.    -- MIL_STD CAIS 5.4.1.5
  8565.         function Is_Equal(List1 : in List_Type; 
  8566.                           List2 : in List_Type) return Boolean; 
  8567.  
  8568.  
  8569. --------------------D E L E T E----POSITIONAL ITEM--------------
  8570. --
  8571. -- Purpose: 
  8572. -- -------
  8573. --     Removes the list item at this position from the list
  8574. --
  8575. --
  8576. -- Parameters:
  8577. -- ----------
  8578. --     List     is the list from which an item is to be deleted, positional
  8579. --     Position is the position of the item to be deleted.
  8580. --            
  8581. --
  8582. -- Exceptions: 
  8583. -- ----------  
  8584. --     Use_Error    may be raised by Find if bad position
  8585. --
  8586. --
  8587. -- Notes: MIL_STD CAIS 5.4.1.6
  8588. -- -----
  8589. --
  8590. --
  8591. ----------------------------------------------------------------
  8592.    -- MIL_STD CAIS 5.4.1.6
  8593.         procedure Delete(List     : in out List_Type; 
  8594.                          Position : in Position_Count); 
  8595.  
  8596. --------------------D E L E T E----NAMED     ITEM--------------
  8597. --
  8598. -- Purpose: 
  8599. -- -------
  8600. --     Removes the list item of this name  from the list
  8601. --
  8602. --
  8603. -- Parameters:
  8604. -- ----------
  8605. --     List     is the list from which an item is to be deleted, named
  8606. --     Named    is the name of the item to be deleted.
  8607. --            
  8608. --
  8609. -- Exceptions: 
  8610. -- ----------  
  8611. --     Search_Error    may be raised by find if name doesn't exist
  8612. --     Use_Error       may be raised by find if list is not named
  8613. --
  8614. --
  8615. -- Notes: MIL_STD CAIS 5.4.1.6
  8616. -- -----
  8617. --
  8618. --
  8619. ----------------------------------------------------------------
  8620.         procedure Delete(List  : in out List_Type; 
  8621.                          Named : in Namestring); 
  8622.  
  8623. --------------------D E L E T E----NAMED  ITEM OF TOKEN TYPE---
  8624. --
  8625. -- Purpose: 
  8626. -- -------
  8627. --     Removes the list item of this name  from the list
  8628. --
  8629. --
  8630. -- Parameters:
  8631. -- ----------
  8632. --     List     is the list from which an item is to be deleted, named
  8633. --     Named    is the name (in token form) of the item to be deleted.
  8634. --            
  8635. --
  8636. -- Exceptions: 
  8637. -- ----------  
  8638. --     Search_Error    may be raised by find if name doesn't exist
  8639. --     Use_Error       may be raised by find if list is not named
  8640. --
  8641. --
  8642. -- Notes: MIL_STD CAIS 5.4.1.6
  8643. -- -----
  8644. --
  8645. --
  8646. ----------------------------------------------------------------
  8647.         procedure Delete(List  : in out List_Type; 
  8648.                          Named : in Token_Type); 
  8649.  
  8650.  
  8651. ---------------G E T _ L I S T _ K I N D----------------OF LIST-
  8652. --
  8653. -- Purpose:
  8654. -- -------
  8655. --     Returns the kind of list, either empty, unnamed, or named.
  8656. --
  8657. -- Parameters:
  8658. -- ----------
  8659. --     List    is the list_type being looked at
  8660. --     return  the kind of list, either empty, unnamed, or named
  8661. --
  8662. -- Exceptions: 
  8663. -- ----------  
  8664. --     None
  8665. --    
  8666. -- Notes: MIL_STD CAIS 5.4.1.7
  8667. -- -----
  8668. --
  8669. ----------------------------------------------------------------
  8670.    -- MIL_STD CAIS 5.4.1.7
  8671.         function Get_List_Kind(List : in List_Type) return List_Kind; 
  8672.  
  8673. ----------------G E T _ I T E M _ K I N D------------OF UNNAMED ITEM--
  8674. --
  8675. -- Purpose:
  8676. -- -------
  8677. --     Returns the kind of a single list item within an unnamed list.
  8678. --     The item kinds are LIST_ITEM, STRING_ITEM, INTEGER_ITEM,
  8679. --     REAL_ITEM, and IDENTIFIER_ITEM.
  8680. --
  8681. -- Parameters:
  8682. -- ----------
  8683. --     List      is the unnamed list containing the item of interest
  8684. --     Position  is the position of the item of interest
  8685. --     return    the item_kind of the specified item
  8686. --            
  8687. -- Exceptions: 
  8688. -- ----------  
  8689. --     Use_Error       may be propogated by Find for no names or bad position
  8690. --
  8691. -- Notes: MIL_STD CAIS 5.4.1.8
  8692. --
  8693. ------------------------------------------------------------------------------
  8694.         function Get_Item_Kind(List  : in List_Type; 
  8695.                                Named : in Namestring) return Item_Kind; 
  8696.  
  8697.  
  8698. ----------------G E T _ I T E M _ K I N D------------OF NAMED ITEM--
  8699. --
  8700. -- Purpose:
  8701. -- -------
  8702. --     Returns the kind of a single list item within a named list.
  8703. --     The item kinds are LIST_ITEM, STRING_ITEM, INTEGER_ITEM,
  8704. --     REAL_ITEM, and IDENTIFIER_ITEM.
  8705. --
  8706. -- Parameters:
  8707. -- ----------
  8708. --     List      is the named list containing the item of interest
  8709. --     Named     is the name of the item of interest
  8710. --     return    the item_kind of the specified item
  8711. --            
  8712. -- Exceptions: 
  8713. -- ----------  
  8714. --     Search_Error    may be propogated from Find if name doesn't exist
  8715. --     Use_Error       may be propogated by Find if list is unnamed
  8716. --
  8717. -- Notes: MIL_STD CAIS 5.4.1.8
  8718. -- -----
  8719. --
  8720. ----------------------------------------------------------------
  8721.         function Get_Item_Kind(List  : in List_Type; 
  8722.                                Named : in Token_Type) return Item_Kind; 
  8723. ------------G E T _ I T E M _ K I N D--------OF NAMED ITEM-TOKEN---
  8724. --
  8725. -- Purpose:
  8726. -- -------
  8727. --     Returns the kind of a single list item within a named list.
  8728. --     The item kinds are LIST_ITEM, STRING_ITEM, INTEGER_ITEM,
  8729. --     REAL_ITEM, and IDENTIFIER_ITEM.
  8730. --
  8731. -- Parameters:
  8732. -- ----------
  8733. --     List      is the named list containing the item of interest
  8734. --     Named     is the name (in token form) of the item of interest
  8735. --     return    the item_kind of the specified item
  8736. --            
  8737. -- Exceptions: 
  8738. -- ----------  
  8739. --     Search_Error    may be propogated from Find if name doesn't exist
  8740. --     Use_Error       may be propogated by Find if list is unnamed
  8741. --    
  8742. -- Notes: MIL_STD CAIS 5.4.1.8
  8743. -- -----
  8744. --
  8745. ----------------------------------------------------------------
  8746.    -- MIL_STD CAIS 5.4.1.8
  8747.         function Get_Item_Kind(List     : in List_Type; 
  8748.                                Position : in Position_Count) return Item_Kind; 
  8749.  
  8750. -----------------------S P L I C E-----TEXT---------------------
  8751. --
  8752. -- Purpose:
  8753. -- -------
  8754. --     Inserts a list into a list.  The items in the list to be inserted
  8755. --     will become items in the resulting list.  Subsequent modifications
  8756. --     to the value of List or to the value of Sub_List do not affect the
  8757. --     other list.
  8758. --
  8759. -- Parameters:
  8760. -- ----------
  8761. --     List      is the list_type into which the Sub_List is to be added
  8762. --     Position  is the position within List at which Sub_List is added
  8763. --     Sub_List  is text which is an external representation of a string
  8764. --               a list_type is created from this string and added to list
  8765. --            
  8766. -- Exceptions:
  8767. -- ----------
  8768. --     Use_Error   is raised if List and Sub_List are not of the same kind
  8769. --           and neither of them is Empty; if Sub_List contains a
  8770. --           name identical to one in List; if Position is too large;
  8771. --           or if List_Text is of invalid format.
  8772. --
  8773. -- Notes: MIL_STD CAIS 5.4.1.9
  8774. -- -----
  8775. --
  8776. ----------------------------------------------------------------
  8777.         procedure Splice(List     : in out List_Type; 
  8778.                          Position : in Position_Count; 
  8779.                          Sub_List : in List_Type); 
  8780.  
  8781. -----------------------S P L I C E-----LIST---------------------
  8782. --
  8783. -- Purpose:
  8784. -- -------
  8785. --     Inserts a list into a list.  The items in the list to be inserted
  8786. --     will becomes items in the resulting list.  Subsequent modifications
  8787. --     to the value of List or to the value of Sub_List do not affect the
  8788. --     other list.
  8789. --
  8790. -- Parameters:
  8791. -- ----------
  8792. --     List      is the list_type into which the Sub_List is to be added
  8793. --     Position  is the position within List at which Sub_List is added
  8794. --     Sub_List  is an unchanged list_type, a copy of which is added to List
  8795. --            
  8796. -- Exceptions:
  8797. -- ----------
  8798. --     Use_Error   is raised if List and Sub_List are not of the same kind
  8799. --           and neither of them is Empty; if Sub_List contains a
  8800. --           name identical to one in List; or if Position is too large.
  8801. --
  8802. -- Notes: MIL_STD CAIS 5.4.1.9
  8803. -- -----
  8804. --
  8805. ----------------------------------------------------------------
  8806.    -- MIL_STD CAIS 5.4.1.9
  8807.         procedure Splice(List     : in out List_Type; 
  8808.                          Position : in Position_Count; 
  8809.                          Sub_List : in List_Text); 
  8810.  
  8811.  
  8812. ----------------------M E R G E---------------------------------
  8813. --
  8814. -- Purpose:
  8815. -- -------
  8816. --     Returns in result a list which is constructed from the
  8817. --     parameters Front and Back.  The lists Front and Back
  8818. --     lists are not modified by this procedure.
  8819. --
  8820. -- Parameters:
  8821. -- ----------
  8822. --     Front  : is a List_Type which is read but unchanged
  8823. --     Back   : is a List_Type which is read but unchanged
  8824. --     Result : is a new list_type made up of Front catenated to Back
  8825. --            
  8826. -- Exceptions: 
  8827. -- ----------  
  8828. --     Use_Error is raised if one list is named and one is not.
  8829. --    
  8830. -- Notes: MIL_STD CAIS 5.4.1.10
  8831. -- -----  
  8832. --     
  8833. ----------------------------------------------------------------
  8834.    -- MIL_STD CAIS 5.4.1.10
  8835.         procedure Merge(Front  : in List_Type; 
  8836.                         Back   : in List_Type; 
  8837.                         Result : in out List_Type); 
  8838.  
  8839. -----------------S E T _ E X T R A C T--------------------------
  8840. --
  8841. -- Purpose:
  8842. -- -------
  8843. --     Extracts a (sub)list from a list.  The return value is a copy of the
  8844. --     list subset that starts at the item at Position and has Length items
  8845. --     in it.  If there are fewer than Length items in this part of the list,
  8846. --     the subset extends to the tail of the list.
  8847. --
  8848. -- Parameters:
  8849. -- ----------
  8850. --     List      is the list_type(unchanged) from which the sublist is read
  8851. --     Position  is position of the first item to be copied out
  8852. --     Length    is the number of items to be copied to the sublist
  8853. --     return    is the Text representation of the selected sublist
  8854. --            
  8855. -- Exceptions:
  8856. -- ----------
  8857. --     Use Error     is raised if Position is larger than the list length
  8858. --
  8859. -- Notes: MIL_STD CAIS 5.4.1.11
  8860. -- -----
  8861. --
  8862. ----------------------------------------------------------------
  8863.    -- MIL_STD CAIS 5.4.1.11
  8864.         function Set_Extract(List     : in List_Type; 
  8865.                              Position : in Position_Count; 
  8866.                              Length   : in Positive := Positive'Last) return
  8867.             List_Text; 
  8868.  
  8869. --------------------L E N G T H------OF LIST--------------------
  8870. --
  8871. -- Purpose:
  8872. -- -------
  8873. --     Returns a count of the number of items in List. If list
  8874. --     is empty, Length returns zero.
  8875. --
  8876. -- Parameters:
  8877. -- ----------
  8878. --     List   is the list_type whose items are being counted
  8879. --     return the number of items (note list_items count as a single item)
  8880. --            
  8881. -- Exceptions: 
  8882. -- ----------  
  8883. --     None
  8884. --    
  8885. -- Notes: MIL_STD CAIS 5.4.1.12
  8886. -- -----
  8887. --     None
  8888. --
  8889. ----------------------------------------------------------------
  8890.    -- MIL_STD CAIS 5.4.1.12
  8891.         function Length(List : in List_Type) return Count; 
  8892.                                                           --Mod to MIL_STD CAIS
  8893.  
  8894. ------------------T E X T _ L E N G T H----OF LIST--------------
  8895. --
  8896. -- Purpose:
  8897. -- -------
  8898. --     Returns the length of a string representing a list according
  8899. --     to the syntax prescribed in MIL_STD CAIS
  8900. --
  8901. -- Parameters:
  8902. -- ----------
  8903. --     List   is the list being examined
  8904. --     return the length of the string which is the external text for List
  8905. --            
  8906. -- Exceptions: 
  8907. -- ----------  
  8908. --     None
  8909. --    
  8910. -- Notes: MIL_STD CAIS 5.4.1.13
  8911. -- -----
  8912. --     None
  8913. --
  8914. ----------------------------------------------------------------
  8915.         function Text_Length(List : in List_Type) return Positive; 
  8916.  
  8917. ------------------T E X T - L E N G T H----OF POSITIONAL ITEM---
  8918. --
  8919. -- Purpose:
  8920. -- -------
  8921. --     Returns the length of a string representing a list item according
  8922. --     to the syntax prescribed in MIL_STD CAIS.  The item is found by
  8923. --     position within a list.
  8924. --
  8925. -- Parameters:
  8926. -- ----------
  8927. --     List     is the list being examined
  8928. --     Position is the position of the item being examined
  8929. --     return   the length of the string which is the external text for 
  8930. --        the item at the designated position
  8931. --            
  8932. -- Exceptions: 
  8933. -- ----------  
  8934. --     Use_Error is raised if position is not in range
  8935. --    
  8936. -- Notes: MIL_STD CAIS 5.4.1.13
  8937. -- -----
  8938. --     None
  8939. --
  8940. ----------------------------------------------------------------
  8941.         function Text_Length(List     : in List_Type; 
  8942.                              Position : in Position_Count) return Natural; 
  8943.  
  8944. ------------------T E X T - L E N G T H----OF NAMED ITEM--------
  8945. --
  8946. -- Purpose:
  8947. -- -------
  8948. --     Returns the length of a string representing a list item according
  8949. --     to the syntax prescribed in MIL_STD CAIS.  The item is found by
  8950. --     searching for the item name.
  8951. --
  8952. -- Parameters:
  8953. -- ----------
  8954. --     List     is the list being examined
  8955. --     Named    is the name of the item being examined
  8956. --     return   the length of the string which is the external text for 
  8957. --        the item of the designated name
  8958. --            
  8959. -- Exceptions: 
  8960. -- ----------  
  8961. --     Use_Error    is raised if this is an unnamed list
  8962. --     Search_Error is raised if a matching name is not found
  8963. --    
  8964. -- Notes: MIL_STD CAIS 5.4.1.13
  8965. -- -----
  8966. --     None
  8967. --
  8968. ----------------------------------------------------------------
  8969.         function Text_Length(List  : in List_Type; 
  8970.                              Named : in Namestring) return Natural; 
  8971.  
  8972. ------------------T E X T - L E N G T H----OF TOKEN_NAMED ITEM-------
  8973. --
  8974. -- Purpose:
  8975. -- -------
  8976. --     Returns the length of a string representing a list item according
  8977. --     to the syntax prescribed in MIL_STD CAIS.  The item is found by
  8978. --     searching for the named token.
  8979. --
  8980. -- Parameters:
  8981. -- ----------
  8982. --     List     is the list being examined
  8983. --     Named    is the name (in token format) of the item being examined
  8984. --     return   the length of the string which is the external text for 
  8985. --        the item of the designated name
  8986. --            
  8987. -- Exceptions: 
  8988. -- ----------  
  8989. --     None
  8990. --    
  8991. -- Notes: MIL_STD CAIS 5.4.1.13
  8992. -- -----
  8993. --     None
  8994. --
  8995. ----------------------------------------------------------------
  8996.    -- MIL_STD CAIS 5.4.1.13
  8997.         function Text_Length(List  : in List_Type; 
  8998.                              Named : in Token_Type) return Natural; 
  8999.  
  9000. ----------------------I T E M _ N A M E----PROCEDURE---------------
  9001. --
  9002. -- Purpose:
  9003. -- -------
  9004. --     Returns the name of the list item in a named list, specified
  9005. --     by position.
  9006. --
  9007. -- Parameters:
  9008. -- ----------
  9009. --     List       is the list_type of interest
  9010. --     Position   is the position of the item whose name is desired
  9011. --     Named      is the Name returned for the item
  9012. --            
  9013. -- Exceptions: 
  9014. -- ----------  
  9015. --     Use_Error    is raised if list is positional
  9016. --                  or if position exceeds the list length
  9017. --
  9018. -- Notes: MIL_STD CAIS 5.4.1.14
  9019. -- -----  
  9020. --     Again the CAIS 1.4 semantics are not explicit with respect to
  9021. --     null lists. Here, null lists are treated as in Insert, i.e. as
  9022. --     either named or positional
  9023. --
  9024. ----------------------------------------------------------------
  9025.    -- MIL_STD CAIS 5.4.1.14
  9026.         procedure Item_Name(List     : in List_Type; 
  9027.                             Position : in Position_Count; 
  9028.                             Named    : in out Token_Type); 
  9029.  
  9030. ----------------P O S I T I O N _ B Y _ N A M E----STRING-------
  9031. --
  9032. -- Purpose:
  9033. -- -------
  9034. --     Returns the Position at which the given Named is located in the
  9035. --     List.  It may only be used with named lists.
  9036. --
  9037. -- Parameters:
  9038. -- ----------
  9039. --     List   is the list_type of interest
  9040. --     Named  is the Name of the item whose position is desired
  9041. --     return the position of the named item
  9042. --            
  9043. -- Exceptions:
  9044. -- ----------
  9045. --     Use_Error      is raised if List is not named
  9046. --     Search_Error   is raised if Named is not in the List
  9047. --
  9048. -- Notes: MIL_STD CAIS 5.4.1.15
  9049. -- -----
  9050. --
  9051. ----------------------------------------------------------------
  9052.    -- MIL_STD CAIS 5.4.1.15
  9053.         function Position_By_Name(List  : in List_Type; 
  9054.                                   Named : in Namestring) return Position_Count; 
  9055.  
  9056. ----------------P O S I T I O N _ B Y _ N A M E----TOKEN_TYPE---
  9057. --
  9058. -- Purpose:
  9059. -- -------
  9060. --     Returns the Position at which the given Named is located in the
  9061. --     List.  It may only be used with named lists.
  9062. --
  9063. -- Parameters:
  9064. -- ----------
  9065. --     List   is the list_type of interest
  9066. --     Named  is the Name(in token format) of the item whose position is desired
  9067. --     return the position of the named item
  9068. --            
  9069. -- Exceptions:
  9070. -- ----------
  9071. --     Use_Error      is raised if List is not named
  9072. --     Search_Error   is raised if Named is not in the List
  9073. --
  9074. -- Notes: MIL_STD CAIS 5.4.1.15
  9075. -- -----
  9076. --
  9077. ----------------------------------------------------------------
  9078.         function Position_By_Name(List  : in List_Type; 
  9079.                                   Named : in Token_Type) return Position_Count; 
  9080.  
  9081. ---------------------E X T R A C T----NAME --LIS----------------
  9082. --
  9083. -- Purpose: 
  9084. -- -------
  9085. --     Returns the named List_Element from the list without removing it.
  9086. --     Use_Error, Search_Error, indicate unsuccessful extraction.
  9087. --
  9088. -- Parameters:
  9089. -- ----------
  9090. --     List      is the named list from which a list_item is to be selected
  9091. --     Named     is the name of the item to be copied
  9092. --     List_Item is a new list_type consisting of the extacted list
  9093. --            
  9094. -- Exceptions: 
  9095. -- ----------  
  9096. --     Search_error     indicates Named item not found
  9097. --     Use_Error        indicates an empty or positional list, or that
  9098. --                      item is not of list kind.
  9099. --
  9100. -- Notes: MIL_STD CAIS 5.4.1.16
  9101. -- -----  
  9102. --    
  9103. -------------------------------------------------------------------
  9104.    -- MIL_STD CAIS 5.4.1.16
  9105.         procedure Extract(List      : in List_Type; 
  9106.                           Position  : in Position_Count; 
  9107.                           List_Item : in out List_Type); 
  9108.  
  9109. ---------------------E X T R A C T----TOKEN NAME----LIST--------
  9110. --
  9111. -- Purpose: 
  9112. -- -------
  9113. --     Returns the named List_Element from the list without removing it.
  9114. --     Use_Error, Search_Error, indicate unsuccessful extraction.
  9115. --
  9116. -- Parameters:
  9117. -- ----------
  9118. --     List      is the named list from which a list_item is to be selected
  9119. --     Named     is the name (in token form) of the item to be copied
  9120. --     List_Item is a new list_type consisting of the extacted list
  9121. --            
  9122. -- Exceptions: 
  9123. -- ----------  
  9124. --     Search_error     indicates Named item not found
  9125. --     Use_Error        indicates an empty or positional list
  9126. --
  9127. -- Notes: MIL_STD CAIS 5.4.1.16
  9128. -- -----  
  9129. --    
  9130. -------------------------------------------------------------------
  9131.         procedure Extract(List      : in List_Type; 
  9132.                           Named     : in Namestring; 
  9133.                           List_Item : in out List_Type); 
  9134.  
  9135. ---------------------E X T R A C T----POSITIONAL ---------------------
  9136. --
  9137. -- Purpose: 
  9138. -- -------
  9139. --     Returns the nth List_Element from the positional list without
  9140. --     removing it.  Use_Error, Search_Error, imply unsuccessful extraction.
  9141. --
  9142. -- Parameters:
  9143. -- ----------
  9144. --     List      is the unnamed list from which a list_item is to be selected
  9145. --     Position  is the position of the item to be copied
  9146. --     List_Item is a new list_type consisting of the extacted list
  9147. --            
  9148. -- Exceptions: 
  9149. -- ----------  
  9150. --     Use_Error        indicates an empty or positional list
  9151. --                      or indicates Position exceeds list length
  9152. --
  9153. -- Notes: MIL_STD CAIS 5.4.1.16
  9154. -- ----- 
  9155. --     
  9156. ----------------------------------------------------------------
  9157.         procedure Extract(List      : in List_Type; 
  9158.                           Named     : in Token_Type; 
  9159.                           List_Item : in out List_Type); 
  9160.  
  9161. --------------------R E P L A C E-----POSITIONAL--------------------
  9162. --
  9163. -- Purpose: 
  9164. -- -------
  9165. --     Replaces an item in a positional list.  The new item
  9166. --     must be of the same item kind as the one being replaced.
  9167. --
  9168. -- Parameters:
  9169. -- ----------
  9170. --     List       is the unnamed list of interest
  9171. --     List_Item  is the value of list_type which will replace an item in list
  9172. --     Position   is the position of a list_item in list which will be replaced
  9173. --            
  9174. -- Exceptions: 
  9175. -- ----------  
  9176. --     Use_Error     is raised if position exceeds list length.
  9177. --                   or if item kinds do not match.
  9178. --
  9179. -- Notes: MIL_STD CAIS 5.4.1.17
  9180. -- -----
  9181. --
  9182. ----------------------------------------------------------------
  9183.    -- MIL_STD CAIS 5.4.1.17
  9184.         procedure Replace(List      : in out List_Type; 
  9185.                           List_Item : in List_Type; 
  9186.                           Position  : in Position_Count); 
  9187. --------------------R E P L A C E-----NAMED-------------------------
  9188. --
  9189. -- Purpose: 
  9190. -- -------
  9191. --     Replaces an item in a named list.  The new item
  9192. --     must be of the same item kind as the one being replaced.
  9193. --
  9194. -- Parameters:
  9195. -- ----------
  9196. --     List       is the named list of interest
  9197. --     List_Item  is the value of list_type which will replace an item in list
  9198. --     Named      is the name of a list_item in list which will be replaced
  9199. --            
  9200. -- Exceptions: 
  9201. -- ----------  
  9202. --     Use_Error        is raised if item kinds do not match.
  9203. --     Search_Error     is raised if Named item is not found.
  9204. --
  9205. -- Notes: MIL_STD CAIS 5.4.1.17
  9206. -- -----
  9207. --
  9208. ----------------------------------------------------------------
  9209.         procedure Replace(List      : in out List_Type; 
  9210.                           List_Item : in List_Type; 
  9211.                           Named     : in Namestring); 
  9212.  
  9213. --------------------R E P L A C E-----NAMED----TOKEN----------------
  9214. --
  9215. -- Purpose: 
  9216. -- -------
  9217. --     Replaces an item in a named list.  The new item
  9218. --     must be of the same item kind as the one being replaced.
  9219. --
  9220. -- Parameters:
  9221. -- ----------
  9222. --     List       is the named list of interest
  9223. --     List_Item  is the value of list_type which will replace an item in list
  9224. --     Named      is the name (in token format) of a list_item in list which
  9225. --                will be replaced
  9226. --            
  9227. -- Exceptions: 
  9228. -- ----------  
  9229. --     Use_Error        is raised if item kinds do not match.
  9230. --     Search_Error     is raised if Named item is not found.
  9231. --
  9232. -- Notes: MIL_STD CAIS 5.4.1.17
  9233. -- -----
  9234. --
  9235. ----------------------------------------------------------------
  9236.         procedure Replace(List      : in out List_Type; 
  9237.                           List_Item : in List_Type; 
  9238.                           Named     : in Token_Type); 
  9239.  
  9240.  
  9241. -----------------I N S E R T----POSITIONAL----------------------
  9242. --
  9243. -- Purpose: 
  9244. -- -------
  9245. --     Inserts a list item into a positional list.  Use_Error
  9246. --     or Search_Error may be raised indicating list item has
  9247. --     not been inserted.
  9248. --
  9249. -- Parameters:
  9250. -- ----------
  9251. --     List       is the list_type of interest
  9252. --     List_Item  is the value to be added to list as a list_item
  9253. --     Position   is the position in list after which List_Item will be placed
  9254. --            
  9255. -- Exceptions: 
  9256. -- ----------  
  9257. --     Use_Error     is raised if this is a named list.
  9258. --                   or if position exceeds size of list
  9259. --
  9260. -- Notes: MIL_STD CAIS 5.4.1.18
  9261. -- -----
  9262. --
  9263. ----------------------------------------------------------------
  9264.    -- MIL_STD CAIS 5.4.1.18
  9265.         procedure Insert(List      : in out List_Type; 
  9266.                          List_Item : in List_Type; 
  9267.                          Position  : in Count); 
  9268.  
  9269. -----------------I N S E R T----NAMED---STRING------------------
  9270. --
  9271. -- Purpose: 
  9272. -- -------
  9273. --     Inserts a list item into a named list.  Use_Error
  9274. --     or Search_Error may be raised indicating list item has
  9275. --     not been inserted.
  9276. --
  9277. -- Parameters:
  9278. -- ----------
  9279. --     List       is the list_type of interest
  9280. --     List_Item  is the value to be added to list as a list_item
  9281. --     Named      is the string value of the name to be used for List-Item
  9282. --     Position   is the position in list after which List_Item will be placed
  9283. --            
  9284. -- Exceptions: 
  9285. -- ----------  
  9286. --     Use_Error     is raised if this is an unnamed list.
  9287. --                   or if position exceeds size of list
  9288. --
  9289. -- Notes: MIL_STD CAIS 5.4.1.18
  9290. -- -----
  9291. --
  9292. ----------------------------------------------------------------
  9293.         procedure Insert(List      : in out List_Type; 
  9294.                          List_Item : in List_Type; 
  9295.                          Named     : in Namestring; 
  9296.                          Position  : in Count); 
  9297.  
  9298. -----------------I N S E R T----NAMED---TOKEN-------------------
  9299. --
  9300. -- Purpose: 
  9301. -- -------
  9302. --     Inserts a list item into a named list.  Use_Error
  9303. --     or Search_Error may be raised indicating list item has
  9304. --     not been inserted.
  9305. --
  9306. -- Parameters:
  9307. -- ----------
  9308. --     List       is the list_type of interest
  9309. --     List_Item  is the value to be added to list as a list_item
  9310. --     Named      is the name value (in token form) to be used for List-Item
  9311. --     Position   is the position in list after which List_Item will be placed
  9312. --            
  9313. -- Exceptions: 
  9314. -- ----------  
  9315. --     Use_Error     is raised if this is an unnamed list.
  9316. --                   or if position exceeds size of list
  9317. --
  9318. -- Notes: MIL_STD CAIS 5.4.1.18
  9319. -- -----
  9320. --
  9321. ----------------------------------------------------------------
  9322.         procedure Insert(List      : in out List_Type; 
  9323.                          List_Item : in List_Type; 
  9324.                          Named     : in Token_Type; 
  9325.                          Position  : in Count); 
  9326.  
  9327. -----------P O S I T I O N _ B Y _ V A L U E--------------------
  9328. --
  9329. -- Purpose:
  9330. -- -------  
  9331. --     Returns the position at which the next list_type item of the given
  9332. --     value is located. the search begins at the Start_Position and ends
  9333. --     when either an item of Value is found, the last item of the list
  9334. --     has been examined, or the item at the End_Position has been 
  9335. --     examined, whichever comes first.
  9336. --
  9337. -- Parameters:
  9338. -- ----------
  9339. --     List           is the list_type of interest
  9340. --     Value          is the value of list_type being looked for
  9341. --     Start_Position is the position of the starting item in the search
  9342. --     End_Position   is the position of the ending   item in the search
  9343. --     return         the position of an item whose value matches
  9344. --            
  9345. -- Exceptions:
  9346. -- ----------
  9347. --     Use_Error     raised if Start<End or Start > length of list
  9348. --     Search_Error  raised if Value not found in specified range
  9349. --
  9350. -- Notes: MIL_STD CAIS 5.4.1.19
  9351. -- -----
  9352. --
  9353. ----------------------------------------------------------------
  9354.   --MIL_STD CAIS 5.4.1.19
  9355.         function Position_By_Value(List           : in List_Type; 
  9356.                                    Value          : in List_Type; 
  9357.                                    Start_Position : in Position_Count := 
  9358.                                        Position_Count'First; 
  9359.                                    End_Position   : in Position_Count := 
  9360.                                        Position_Count'Last) return
  9361.             Position_Count; 
  9362.  
  9363. --------------------------------------------------------------------------
  9364. --   S E P A R A T E     P A C K A G E   I D E N T I F I E R _ I T E M
  9365. --MIL_STD CAIS 5.4.1.20
  9366. --------------------------------------------------------------------------
  9367.   --MIL_STD CAIS 5.4.1.20
  9368.         package Identifier_Items is 
  9369.           -- MIL STD CAIS 5.4.1.23.1
  9370.             procedure To_Token(Identifier : in Namestring; 
  9371.                                Token      : in out Token_Type); 
  9372.  
  9373.           -- MIL_STD CAIS 5.4.1.20.2
  9374.             function To_Text(List_Item : in Token_Type) return Namestring; 
  9375.  
  9376.           -- MIL_STD CAIS 5.4.1.20.3
  9377.             function Is_Equal(Token1 : in Token_Type; 
  9378.                               Token2 : in Token_Type) return Boolean; 
  9379.  
  9380.           -- MIL STD CAIS 5.4.1.20.4
  9381.             procedure Extract(List     : in List_Type; 
  9382.                               Position : in Position_Count; 
  9383.                               Token    : in out Token_Type); 
  9384.  
  9385.             procedure Extract(List  : in List_Type; 
  9386.                               Named : in Namestring; 
  9387.                               Token : in out Token_Type); 
  9388.  
  9389.             procedure Extract(List  : in List_Type; 
  9390.                               Named : in Token_Type; 
  9391.                               Token : in out Token_Type); 
  9392.  
  9393.           -- MIL_STD CAIS 5.4.1.20.5
  9394.             procedure Replace(List      : in out List_Type; 
  9395.                               List_Item : in Token_Type; 
  9396.                               Position  : in Position_Count); 
  9397.  
  9398.             procedure Replace(List      : in out List_Type; 
  9399.                               List_Item : in Token_Type; 
  9400.                               Named     : in Namestring); 
  9401.  
  9402.             procedure Replace(List      : in out List_Type; 
  9403.                               List_Item : in Token_Type; 
  9404.                               Named     : in Token_Type); 
  9405.  
  9406.           -- MIL_STD CAIS 5.4.1.20.6
  9407.             procedure Insert(List      : in out List_Type; 
  9408.                              List_Item : in Token_Type; 
  9409.                              Position  : in Count); 
  9410.  
  9411.             procedure Insert(List      : in out List_Type; 
  9412.                              List_Item : in Token_Type; 
  9413.                              Named     : in Namestring; 
  9414.                              Position  : in Count); 
  9415.  
  9416.             procedure Insert(List      : in out List_Type; 
  9417.                              List_Item : in Token_Type; 
  9418.                              Named     : in Token_Type; 
  9419.                              Position  : in Count); 
  9420.  
  9421.           --MIL_STD CAIS 5.4.1.20.7
  9422.             function Position_By_Value(List           : in List_Type; 
  9423.                                        Value          : in Token_Type; 
  9424.                                        Start_Position : in Position_Count := 
  9425.                                            Position_Count'First; 
  9426.                                        End_Position   : in Position_Count := 
  9427.                                            Position_Count'Last) return
  9428.                 Position_Count; 
  9429.  
  9430.         end Identifier_Items; 
  9431.  
  9432. --------------------------------------------------------------------------
  9433. --   S E P A R A T E     P A C K A G E   S T R I N G _ I T E M
  9434. --MIL_STD CAIS 5.4.1.23
  9435. --------------------------------------------------------------------------
  9436.   --MIL_STD CAIS 5.4.1.23
  9437.         package String_Items is 
  9438.           -- MIL STD CAIS 5.4.1.23.1
  9439.             function Extract(List     : in List_Type; 
  9440.                              Position : in Position_Count) return String; 
  9441.             function Extract(List  : in List_Type; 
  9442.                              Named : in Namestring) return String; 
  9443.             function Extract(List  : in List_Type; 
  9444.                              Named : in Token_Type) return String; 
  9445.  
  9446.           -- MIL_STD CAIS 5.4.1.23.2
  9447.             procedure Replace(List      : in out List_Type; 
  9448.                               List_Item : in String; 
  9449.                               Position  : in Position_Count); 
  9450.             procedure Replace(List      : in out List_Type; 
  9451.                               List_Item : in String; 
  9452.                               Named     : in Namestring); 
  9453.             procedure Replace(List      : in out List_Type; 
  9454.                               List_Item : in String; 
  9455.                               Named     : in Token_Type); 
  9456.  
  9457.           -- MIL_STD CAIS 5.4.1.23.3
  9458.             procedure Insert(List      : in out List_Type; 
  9459.                              List_Item : in String; 
  9460.                              Position  : in Count); 
  9461.             procedure Insert(List      : in out List_Type; 
  9462.                              List_Item : in String; 
  9463.                              Named     : in Namestring; 
  9464.                              Position  : in Count); 
  9465.             procedure Insert(List      : in out List_Type; 
  9466.                              List_Item : in String; 
  9467.                              Named     : in Token_Type; 
  9468.                              Position  : in Count); 
  9469.  
  9470.           --MIL_STD CAIS 5.4.1.23.4
  9471.             function Position_By_Value(List           : in List_Type; 
  9472.                                        Value          : in String; 
  9473.                                        Start_Position : in Position_Count := 
  9474.                                            Position_Count'First; 
  9475.                                        End_Position   : in Position_Count := 
  9476.                                            Position_Count'Last) return
  9477.                 Position_Count; 
  9478.  
  9479.         end String_Items; 
  9480.  
  9481.         procedure Dump(List : in List_Type); 
  9482.     private
  9483.  
  9484.         type String_Of_Any_Length(Size : Natural) is 
  9485.             record
  9486.                 Value : String(1 .. Size); 
  9487.             end record; 
  9488.         type Token_Type is access String_Of_Any_Length; 
  9489.  
  9490.         type Item_Descriptor; 
  9491.         type List_Type is access Item_Descriptor; 
  9492.         type Item_Descriptor is 
  9493.             record
  9494.                 Kind      : Item_Kind; 
  9495.                 Name      : Token_Type; 
  9496.                 Element   : Token_Type; 
  9497.                 List      : List_Type; 
  9498.                 Next_Item : List_Type; 
  9499.             end record; 
  9500.  
  9501.         Empty_List : constant List_Type := null; 
  9502.  
  9503. ---------------------------------------------------------------------------
  9504.     end List_Utilities; 
  9505.                       --  END OF PACKAGE SPEC 
  9506. ---------------------------------------------------------------------------
  9507. ----------------------------------------------------------------------
  9508. --             C A I S _ N O D E _ M A N A G E M E N T
  9509. --
  9510. --  Function:
  9511. --  --------
  9512. --      This package defines the general primitives for manipulating,
  9513. --      copying, renaming and deleting nodes and their relationships.
  9514. --
  9515. --  Usage:
  9516. --  -----
  9517. --      The operations defined in this package are applicable to all
  9518. --      nodes, relationships, and attributes, except where explicitly
  9519. --      stated otherwise.  These operations DO NOT include the CREATION
  9520. --      of nodes.  The creation of structural nodes is performed by
  9521. --      the Create_Node procedures of package CAIS_Structural_Nodes
  9522. --      (MIL-STD-CAIS Section 5.1.5), the creation of nodes for processes
  9523. --      is performed by Invoke_Process and Spawn_Process of package
  9524. --      CAIS_Process_Control (MIL-STD-CAIS Section 5.1.5), and the creation
  9525. --      of nodes for files os performed by the Create procedures of the
  9526. --      CAIS Input/Output packages (MIL-STD-CAIS Section 5.3).
  9527. --
  9528. --      There are three CAIS interfaces for manipulating node handles;
  9529. --      Open opens a node handle, Close closes the node handle, and
  9530. --      Change_Intent alters the specification of the intention of node
  9531. --      handle usage.  These interfaces perform access synchronization 
  9532. --      in accordance with an intent specified by the parameter "Intent".
  9533. --
  9534. --  Example:
  9535. --  -------
  9536. --      TBS
  9537. --
  9538. --  Notes:
  9539. --  -----
  9540. --      This is a version of the package CAIS_NODE_MANAGEMENT,
  9541. --      specified in MIL-STD-CAIS section 5.1.2; all references to 
  9542. --      the CAIS specification refer to the MIL-STD-CAIS specification 
  9543. --      dated 31 January 1985.
  9544. --
  9545. --  Revision History:
  9546. --  ----------------
  9547. --
  9548. -------------------------------------------------------------------
  9549.  
  9550.     package Node_Management is 
  9551.  
  9552.         use Node_Definitions; 
  9553.         use List_Utilities; 
  9554.         use Pragmatics; 
  9555.  
  9556.  
  9557.     -- The following type declarations are from CAIS section 5.1.2.25
  9558.         type Node_Iterator is limited private; 
  9559.         subtype Relationship_Key_Pattern is Relationship_Key; 
  9560.         subtype Relation_Name_Pattern is Relation_Name; 
  9561.  
  9562.  
  9563. ------------------------       O P E N       ------------------------
  9564. --
  9565. --  Purpose:
  9566. --  -------
  9567. --    These procedure return an open node handle in "Node" to the
  9568. --    node identified by the pathname "Name" or "Base"/"Key"/"Relation",
  9569. --    respectively.  
  9570. --
  9571. --  Parameters:
  9572. --  ----------
  9573. --    Node      - a node handle, initially closed, to be opened to the
  9574. --                identified node
  9575. --    Name      - the pathname identifying the node to be opened
  9576. --    Base      - open node handle to a base node for identification
  9577. --    Key       - the relationship key for node identification
  9578. --    Relation  - the relation name for node identification
  9579. --    Intent    - the intent of subsequent operations on the node; the
  9580. --                actual parameter takes the form of an array aggregate
  9581. --    Time_Limit - specifies time limit for the delay on waiting for the 
  9582. --                unlocking of a node in accordance with the desired intent
  9583. --
  9584. --  Exceptions:
  9585. --  ----------
  9586. --    Name_Error        - raised if the pathname specified by "Name" is
  9587. --                        syntactically illegal or if any traversed node
  9588. --                        in the path specified by pathname is unobtainable,
  9589. --                        inaccessible, or non-existant, or if the relationship
  9590. --                        specified by "Relation" and "Key" or by the last
  9591. --                        path element of "Name" does not exist.  Name_Error
  9592. --                        is also raised if the node to which a handle is to
  9593. --                        be opened is inaccessible or unobtainable and the
  9594. --                        given "Intent" includes any intent other 
  9595. --                        than "Existence".
  9596. --    Use_Error         - is raised if the specified intent is an empty array.
  9597. --    Status_Error      - is raised if the Node_Handle "Node" is already
  9598. --                        open prior to the call on Open or if Base is not
  9599. --                        an open node handle.
  9600. --    Lock_Error        - is raised if the Open operation is delayed beyond
  9601. --                        the specified time limit due to the existance of
  9602. --                        locks in conflict with the specified Intent.  This
  9603. --                        includes any delays caused by locks on nodes
  9604. --                        traversed on the path specified by the pathname
  9605. --                        "Name", or locks on the node identified by "Base",
  9606. --                        preventing the reading of relationships emanating
  9607. --                        from these nodes.
  9608. --    Intent_Violation  - is raised if "Base" was not opened with an intent
  9609. --                        establishing the right to read relationships.
  9610. --    Access_Violation  - is raised if the current process's discretionary
  9611. --                        access control rights are insufficient to traverse
  9612. --                        the path specified by "Name" or by "Base", "Key",
  9613. --                        and "Relation" or to obtain access to the node
  9614. --                        consistent with the specified intent.  
  9615. --                        Access_Violation is raised only if the conditions
  9616. --                        for Name_Error are not present.
  9617. --    Security_Violation -is raised if the attempt to obtain access to the
  9618. --                        node with the specified intent represents a 
  9619. --                        violation of mandatory access controls for the
  9620. --                        CAIS.  Security_Violation is raised only if the
  9621. --                        conditions for other exceptions are not present.
  9622. --
  9623. --  Notes:   CAIS 5.1.2.1
  9624. --  -----
  9625. --
  9626. ---------------------------------------------------------------------
  9627.         procedure Open(Node       : in out Node_Type; 
  9628.                        Name       : Name_String; 
  9629.                        Intent     : Intention := (1 => Read); 
  9630.                        Time_Limit : Duration := No_Delay); 
  9631.  
  9632.         procedure Open(Node       : in out Node_Type; 
  9633.                        Base       : Node_Type; 
  9634.                        Key        : Relationship_Key; 
  9635.                        Relation   : Relation_Name := Default_Relation; 
  9636.                        Intent     : Intention := (1 => Read); 
  9637.                        Time_Limit : Duration := No_Delay); 
  9638.  
  9639. ----------------------      C L O S E          ----------------------
  9640. --
  9641. --  Purpose:
  9642. --  -------
  9643. --    This procedure severs any association between the node handle
  9644. --    "Node" and the node, and releases any associated locks on the
  9645. --    node imposed by the intent of the node handle "Node".  Closing
  9646. --    an alReady closed node handle has no effect.
  9647. --
  9648. --  Parameters:
  9649. --  ----------
  9650. --    Node - node handle, initially open, to be closed.
  9651. --
  9652. --  Exceptions:
  9653. --  ----------
  9654. --    None.
  9655. --
  9656. --  Notes:
  9657. --  -----
  9658. --     CAIS 5.1.2.2
  9659. --
  9660. ---------------------------------------------------------------------
  9661.         procedure Close(Node : in out Node_Type); 
  9662.  
  9663. ----------------------  C H A N G E _ I N T E N T -------------------
  9664. --
  9665. --  Purpose:
  9666. --  -------
  9667. --    This procedure changes the intention regarding the use of the node
  9668. --    handle "Node".  It is semantically equivalent to closing the node
  9669. --    handle an reopening the node handle to the same node with the 
  9670. --    "Intent" and "Time_Limit" paramters of Change_Intent, except that
  9671. --    Change_Intent guarantees to return an open node handle that refers
  9672. --    to the same node as the node handle input in "Node".  (See the issue
  9673. --    explained in the nore below).
  9674. --
  9675. --  Parameters:
  9676. --  ----------
  9677. --    Node      - an open node handle
  9678. --    Intent    - the intent of subsequent operations on the node; the
  9679. --                actual parameter takes the form of an array aggregate.
  9680. --    Time_Limit- specifies the time limit for the delay on waiting on
  9681. --                waiting for the unlocking of a node in accordance with
  9682. --                the desired intent.
  9683. --
  9684. --  Exceptions:
  9685. --  ----------
  9686. --    Name_Error        - is raised if the node handle "Node" refers to
  9687. --                        an unobtainable node and "Intent" contains any
  9688. --                        intent specification other than "Existence".
  9689. --    Status_Error      - is raised if the node handle "Node" is not an
  9690. --                        open node handle.
  9691. --    Lock_Error        - is raised if the operation is delayed beyond the
  9692. --                        specified time limit due to the existence of locks
  9693. --                        on the node in conflict with the specified "Intent".
  9694. --    Access_Violation  - is raised if the current process's discretionary
  9695. --                        access control rights are insufficient to obtain
  9696. --                        access to the node consistent with the specified
  9697. --                        intent.  Access_Violation is raised only of the
  9698. --                        condition for Name_Error is not present.
  9699. --    Security_Violation- is raised if an attempt to obtain access consistent
  9700. --                        with the intention "Intent" to the node specified
  9701. --                        by "Node" represents a violation of mandatory 
  9702. --                        access controls for the CAIS.  Security_Violation
  9703. --                        is raised only if the conditions for other exceptions
  9704. --                        are not present.
  9705. --
  9706. --  Notes:  CAIS 5.1.2.3 
  9707. --  -----
  9708. --    Use of the sequence of a Close and an Open operation instead of a
  9709. --    Change_Intent operation cannot guarantee that the same node is opened,
  9710. --    since relationships, and therefore the node identification, may have
  9711. --    changed since the previous Open on the Node.
  9712. --
  9713. ---------------------------------------------------------------------
  9714.     -- CAIS 5.1.2.3 
  9715.         procedure Change_Intent(Node       : in out Node_Type; 
  9716.                                 Intent     : Intention; 
  9717.                                 Time_Limit : Duration := No_Delay); 
  9718.  
  9719. ----------------------     I S _ O P E N       ----------------------
  9720. --
  9721. --  Purpose:
  9722. --  -------
  9723. --    This function returns True if the node handle "Node" is open;
  9724. --    otherwise, it returns FALSE.
  9725. --
  9726. --  Parameters:
  9727. --  ----------
  9728. --    Node - node handle
  9729. --
  9730. --  Exceptions:
  9731. --  ----------
  9732. --    None.
  9733. --
  9734. --  Notes:
  9735. --  -----
  9736. --     CAIS 5.1.2.4
  9737. --
  9738. ---------------------------------------------------------------------
  9739.         function Is_Open(Node : Node_Type) return Boolean; 
  9740.  
  9741. ----------------------     I N T E N T _ O F   ----------------------
  9742. --
  9743. --  Purpose:
  9744. --  -------
  9745. --    This function returns the intent with which the node handle
  9746. --    Node is open.
  9747. --
  9748. --  Parameters:
  9749. --  ----------
  9750. --    Node   - an open node handle.
  9751. --
  9752. --  Exceptions:
  9753. --  ----------
  9754. --    Node_Definitions.Status_Error - if the node handle is not open.
  9755. --
  9756. --  Notes:
  9757. --  -----
  9758. --   CAIS 5.1.2.5
  9759. --
  9760. ---------------------------------------------------------------------
  9761.         function Intent_Of(Node : Node_Type) return Intention; 
  9762.  
  9763. ----------------------        K I N D          ----------------------
  9764. --
  9765. --  Purpose:
  9766. --  -------
  9767. --    This function returns the kind of a node, either FILE, PROCESS,
  9768. --    or STRUCTURAL.
  9769. --
  9770. --  Parameters:
  9771. --  ----------
  9772. --    Node  - open node handle
  9773. --
  9774. --  Exceptions:
  9775. --  ----------
  9776. --    Node_Definitions.Status_Error  - if the node handle is not open.
  9777. --
  9778. --  Notes:
  9779. --  -----
  9780. --   CAIS 5.1.2.6
  9781. --
  9782. ---------------------------------------------------------------------
  9783.         function Kind(Node : Node_Type) return Node_Kind; 
  9784.  
  9785. ------------------------ P R I M A R Y _ N A M E---------------------
  9786. --
  9787. --  Purpose:
  9788. --  -------
  9789. --    This function returns the unique primary name of the node identified
  9790. --    by NODE.
  9791. --
  9792. --  Parameters:
  9793. --  ----------
  9794. --    Node      - an open node handle identifying the node of interest
  9795. --
  9796. --  Exceptions:
  9797. --  ----------
  9798. --    Name_Error        - is raised if any node traversed on the primary
  9799. --                        path is inaccessible.
  9800. --    Status_Error      - is raised if the Node_Handle "Node" is not open.
  9801. --    Lock_Error        - is raised if access consistent with intent
  9802. --                        Read_Relationships to any node traversed on the
  9803. --                        primary path cannot be obtained due to an existing
  9804. --                        lock on the node.
  9805. --    Intent_Violation  - is raised if "Node" was not opened with an intent
  9806. --                        establishing the right to read relationships.
  9807. --    Access_Violation  - is raised if the current process's discretionary
  9808. --                        access control rights are insufficient to traverse
  9809. --                        the node's primary path.  Access_Violation is raised
  9810. --              only if the conditions for Name_Error are not present.
  9811. --
  9812. --  Notes:   CAIS 5.1.2.7
  9813. --  -----
  9814. --
  9815. ---------------------------------------------------------------------
  9816.         function Primary_Name(Node : in Node_Type) return Name_String; 
  9817.  
  9818. ------------------------ P R I M A R Y _ K E Y ----------------------
  9819. --
  9820. --  Purpose:
  9821. --  -------
  9822. --    This function returns the relationship key of the last path
  9823. --    element of the unique primary name of the node identified by NODE.
  9824. --
  9825. --  Parameters:
  9826. --  ----------
  9827. --    Node      - an open node handle identifying the node of interest
  9828. --
  9829. --  Exceptions:
  9830. --  ----------
  9831. --    Name_Error        - is raised if the parent node of the node identified
  9832. --                        by "Node" is inaccessible.
  9833. --    Status_Error      - is raised if the Node_Handle "Node" is not open.
  9834. --    Lock_Error        - is raised if the parent node is locked against
  9835. --                        Read_Relationships.
  9836. --    Intent_Violation  - is raised if "Node" was not opened with an intent
  9837. --                        establishing the right to read relationships.
  9838. --    Access_Violation  - is raised if the current process's discretionary
  9839. --                        access control rights are insufficient to obtain
  9840. --              access to the node's parent consistent with intent
  9841. --              Read_Relationships.  Access_Violation is raised
  9842. --              only if the conditions for Name_Error are not present.
  9843. --
  9844. --  Notes:   CAIS 5.1.2.8
  9845. --  -----
  9846. --
  9847. ---------------------------------------------------------------------
  9848.         function Primary_Key(Node : in Node_Type) return Relationship_Key; 
  9849.  
  9850. ------------------- P R I M A R Y _ R E L A T I O N ------------------
  9851. --
  9852. --  Purpose:
  9853. --  -------
  9854. --    This function returns the relation name of the last path
  9855. --    element of the unique primary name of the node identified by NODE.
  9856. --
  9857. --  Parameters:
  9858. --  ----------
  9859. --    Node      - an open node handle identifying the node of interest
  9860. --
  9861. --  Exceptions:
  9862. --  ----------
  9863. --    Name_Error        - is raised if the parent node of the node identified
  9864. --                        by "Node" is inaccessible.
  9865. --    Status_Error      - is raised if the Node_Handle "Node" is not open.
  9866. --    Lock_Error        - is raised if the parent node is locked against
  9867. --                        Read_Relationships.
  9868. --    Intent_Violation  - is raised if "Node" was not opened with an intent
  9869. --                        establishing the right to read relationships.
  9870. --    Access_Violation  - is raised if the current process's discretionary
  9871. --                        access control rights are insufficient to obtain
  9872. --              access to the node's parent consistent with intent
  9873. --              Read_Relationships.  Access_Violation is raised
  9874. --              only if the conditions for Name_Error are not present.
  9875. --
  9876. --  Notes:   CAIS 5.1.2.9
  9877. --  -----
  9878. --
  9879. ---------------------------------------------------------------------
  9880.         function Primary_Relation(Node : in Node_Type) return Relation_Name; 
  9881.  
  9882. ----------------------    P A T H _ K E Y      ----------------------
  9883. --
  9884. --  Purpose:
  9885. --  -------
  9886. --    This function returns the relationship key of the relationship
  9887. --    corresponding to the last path element of the pathname used
  9888. --    in opening this node handle.  Since a path element is a string,
  9889. --    the relationship key is returned even if the relationship has
  9890. --    been deleted.
  9891. --
  9892. --  Parameters:
  9893. --  ----------
  9894. --    Node      - an open node handle
  9895. --
  9896. --  Exceptions:
  9897. --  ----------
  9898. --    Status_Error      - raised if the node handle "Node" is not open.
  9899. --
  9900. --  Notes:   CAIS 5.1.2.10
  9901. --  -----
  9902. --
  9903. ---------------------------------------------------------------------
  9904.         function Path_Key(Node : Node_Type) return Relationship_Key; 
  9905.  
  9906. ----------------------     P A T H _ R E L A T I O N ----------------
  9907. --
  9908. --  Purpose:
  9909. --  -------
  9910. --    This function returns the relation name of the relationship
  9911. --    corresponding to the last path element of the pathname used
  9912. --    in opening this node handle. 
  9913. --    The relationship key is returned even if the relationship has
  9914. --    been deleted.
  9915. --
  9916. --  Parameters:
  9917. --  ----------
  9918. --    Node      - an open node handle
  9919. --
  9920. --  Exceptions:
  9921. --  ----------
  9922. --    Status_Error      - raised if the node handle "Node" is not open.
  9923. --
  9924. --  Notes:   CAIS 5.1.2.11
  9925. --  -----
  9926. --
  9927. ---------------------------------------------------------------------
  9928.         function Path_Relation(Node : Node_Type) return Relation_Name; 
  9929.  
  9930. ----------------------    B A S E _ P A T H    ----------------------
  9931. --
  9932. --  Purpose:
  9933. --  -------
  9934. --    This function returns the pathname obtained by deleting the last
  9935. --    path element from "Name".  It does not establish whether the
  9936. --    pathname identifies an existing node; only the syntactic properties
  9937. --    of the pathname are examined.  This function also checks the
  9938. --    legality of the pathname "Name".
  9939. --
  9940. --  Parameters:
  9941. --  ----------
  9942. --    Name      - a pathname (not necessarily identifying a node).
  9943. --
  9944. --  Exceptions:
  9945. --  ----------
  9946. --    Name_Error  - raised if Name is a syntactically illegal pathname.
  9947. --
  9948. --  Notes: CAIS 5.1.2.12
  9949. --  -----
  9950. --
  9951. ---------------------------------------------------------------------
  9952.         function Base_Path(Name : Name_String) return Name_String; 
  9953.  
  9954. ----------------------   L A S T _ R E L A T I O N  -----------------
  9955. --
  9956. --  Purpose:
  9957. --  -------
  9958. --    This function returns the name of the relation of the last
  9959. --    path element of the pathname "Name".  It does not establish
  9960. --    whether the pathname identifies an existing node; only the
  9961. --    syntactic properties of the pathname are examined.  This function
  9962. --    also checks the syntactic legality of the pathname "Name".
  9963. --
  9964. --  Parameters:
  9965. --  ----------
  9966. --    Name   - a pathname, not necessarily identifying a node.
  9967. --
  9968. --  Exceptions:
  9969. --  ----------
  9970. --    Name_Error   - if name is syntactically illegal.
  9971. --
  9972. --  Notes:   CAIS 5.1.2.13
  9973. --  -----
  9974. --
  9975. ---------------------------------------------------------------------
  9976.         function Last_Relation(Name : Name_String) return Relation_Name; 
  9977.  
  9978. ------------------------     L A S T _ K E Y     --------------------
  9979. --
  9980. --  Purpose:
  9981. --  -------
  9982. --    This function returns the name of the relationship key of the last
  9983. --    path element of the pathname "Name".  It does not establish
  9984. --    whether the pathname identifies an existing node; only the
  9985. --    syntactic properties of the pathname are examined.  This function
  9986. --    also checks the syntactic legality of the pathname "Name".
  9987. --
  9988. --  Parameters:
  9989. --  ----------
  9990. --    Name   - a pathname, not necessarily identifying a node.
  9991. --
  9992. --  Exceptions:
  9993. --  ----------
  9994. --    Name_Error   - if name is syntactically illegal.
  9995. --
  9996. --  Notes:   CAIS 5.1.2.14
  9997. --  -----
  9998. --
  9999. ---------------------------------------------------------------------
  10000.  
  10001.         function Last_Key(Name : Name_String) return Relationship_Key; 
  10002.  
  10003. ----------------------   I S _ O B T A I N A B L E  -----------------
  10004. --
  10005. --  Purpose:
  10006. --  -------
  10007. --    This function returns False if the node identified by "Node"
  10008. --    is unobtainable or inaccessible.  It returns True otherwise.
  10009. --
  10010. --  Parameters:
  10011. --  ----------
  10012. --    Node - an open node handle identifying the node
  10013. --
  10014. --  Exceptions:
  10015. --  ----------
  10016. --    Status_Error  - raised if "Node" is not an open node handle.
  10017. --
  10018. --  Notes:  CAIS 5.1.2.15
  10019. --  -----
  10020. --
  10021. ---------------------------------------------------------------------
  10022.         function Is_Obtainable(Node : Node_Type) return Boolean; 
  10023.  
  10024. ----------------------     I S _ S A M E      -----------------------
  10025. --
  10026. --  Purpose:
  10027. --  -------
  10028. --    This function returns True if the nodes identified by its
  10029. --    arguments are the same node; otherwise, it returns FALSE.
  10030. --
  10031. --  Parameters:
  10032. --  ----------
  10033. --    Node1   - open node handle to a node
  10034. --    Node2   - open node handle to a node
  10035. --
  10036. --  Exceptions:
  10037. --  ----------
  10038. --    Status_Error  is raised if either of the node handles is not open.
  10039. --
  10040. --  Notes:
  10041. --  -----
  10042. --      This is a version of the function Is_Same,
  10043. --      specified in MIL-STD-CAIS 5.1.2.16; all references to 
  10044. --      the CAIS specification refer to the CAIS  specification 
  10045. --      dated 31 January 1985.
  10046. --
  10047. ---------------------------------------------------------------------
  10048.         function Is_Same(Node1 : Node_Type; 
  10049.                          Node2 : Node_Type) return Boolean; 
  10050. ----------------------------------------------------------------------
  10051. --        A D D I T I O N A L   I N T E R F A C E
  10052. ----------------------------------------------------------------------
  10053.         function Is_Same(Name1 : Name_String; 
  10054.                          Name2 : Name_String) return Boolean; 
  10055.  
  10056. ------------------------  G E T _ P A R E N T  ----------------------
  10057. --
  10058. --  Purpose:
  10059. --  -------
  10060. --    This procedure returns an open node handle in "Parent" to the parent
  10061. --    of the node identified by the open node handle "Node".  The intent
  10062. --    under which the node handle "Parent" is opened is specified by "Intent".
  10063. --    A call on Get_Parent is equivalent to a call:
  10064. --        Open(Parent, Node, "", Parent, Intent, Time_Limit);
  10065. --
  10066. --  Parameters:
  10067. --  ----------
  10068. --    Parent    - a node handle, initially closed, to be opened to the
  10069. --                parent node
  10070. --    Node      - an open handle identifying the node
  10071. --    Intent    - the intent of subsequent operations on the node "Parent";
  10072. --                the actual parameter takes the form of an array aggregate
  10073. --    Time_Limit - specifies time limit for the delay on waiting for the 
  10074. --                unlocking of the parent node in accordance with the desired
  10075. --        - intent
  10076. --
  10077. --  Exceptions:
  10078. --  ----------
  10079. --    Name_Error        - raised if the node identified by "Node" is a top
  10080. --              level node or if its parent node is inaccessible.
  10081. --    Use_Error         - is raised if the specified intent is an empty array.
  10082. --    Status_Error      - is raised if the Node_Handle "Parent" is already
  10083. --                        open prior to the call on or if "Node" is not
  10084. --                        an open node handle.
  10085. --    Lock_Error        - is raised if the opening of the Parent node is
  10086. --              delayed beyond the specified time limit due to
  10087. --              the existance of locks in conflict with the
  10088. --              specified Intent.
  10089. --    Intent_Violation  - is raised if "Node" was not opened with an intent
  10090. --                        establishing the right to read relationships.
  10091. --    Access_Violation  - is raised if the current process's discretionary
  10092. --                        access control rights are insufficient to obtain
  10093. --                        access to the parent node with the specified intent.  
  10094. --                        Access_Violation is raised only if the conditions
  10095. --                        for Name_Error are not present.
  10096. --    Security_Violation -is raised if the attempt to obtain access to the
  10097. --                        parent node with the specified intent represents a 
  10098. --                        violation of mandatory access controls for the
  10099. --                        CAIS.  Security_Violation is raised only if the
  10100. --                        conditions for other exceptions are not present.
  10101. --
  10102. --  Notes:   CAIS 5.1.2.17
  10103. --  -----
  10104. --
  10105. ---------------------------------------------------------------------
  10106.         procedure Get_Parent(Parent     : in out Node_Type; 
  10107.                              Node       : in Node_Type; 
  10108.                              Intent     : Intention := (1 => Read); 
  10109.                              Time_Limit : Duration := No_Delay); 
  10110.  
  10111. ------------------------       C O P Y       ------------------------
  10112. --
  10113. --  Purpose:
  10114. --  -------
  10115. --    These procedures copy a file or structural node THAT DOES NOT HAVE
  10116. --    EMANATING PRIMARY RELATIONSHIPS.  The node copied is identified by
  10117. --    the open node handle "From" and is copied to a newly created node.
  10118. --    The new node is identified by the combination of the To_Base, To_Key,
  10119. --    and To_Relation parameters.  The newly created node is of the same
  10120. --    kind as the node identified by From. If the node is a file node, its
  10121. --    contents are also copied, i.e., a new copied file is created.  Any
  10122. --    secondary relationships emanating from the original node, excepting
  10123. --    the relation of the predefined relation parent(which is appropriately
  10124. --    adjusted), are recreated in the copy.  If the target of the original
  10125. --    nodes relationship IS THE NODE ITSELF, THEN THE COPY HAS AN ANALOGOUS
  10126. --    RELATION TO ITSELF.  Any other secondary relationship whose target is
  10127. --    the original node is unaffected.  All attributes of the From node are
  10128. --    also copied.  Regardless of any locks on the node identified by From,
  10129. --    the newly creasted node is unlucked.
  10130. --
  10131. --  Parameters:
  10132. --  ----------
  10133. --    From      - an open node handle to the node to be copied.
  10134. --    To_Base   - open node handle to a base node for identification of the
  10135. --          node to be created.
  10136. --    To_Key    - the relationship key for identification of the node to be
  10137. --              - created.
  10138. --    To_Relation  - the relation name for identification of the node to be
  10139. --                created.
  10140. --
  10141. --  Exceptions:
  10142. --  ----------
  10143. --    Name_Error        - raised if the new node identification is illegal
  10144. --                        or if a node already exists with the identification
  10145. --                        given for the new node.
  10146. --    Use_Error         - is raised if the origianl node is not a file or
  10147. --              structural node or if any primary relationships
  10148. --              emanate from the original node.  Use_Error is also
  10149. --              raised if the To_Relation is the name of a predefined
  10150. --              relation that cannot be modified or created by the
  10151. --              user.
  10152. --    Status_Error      - is raised if the Node_Handles From and To_Base are
  10153. --              not both open.
  10154. --    Intent_Violation  - is raised if "From" was not opened with an intent
  10155. --                        establishing the right to read contents, attributes
  10156. --              and relationships, or if To_Base was not opened with
  10157. --              the right to append relationships. Intent_Violation
  10158. --              is not raised if the conditions for name error are
  10159. --              present.
  10160. --    Security_Violation -is raised if the attempt to obtain access to the
  10161. --                        node with the specified intent represents a 
  10162. --                        violation of mandatory access controls for the
  10163. --                        CAIS.  Security_Violation is raised only if the
  10164. --                        conditions for other exceptions are not present.
  10165. --
  10166. --  Notes:   CAIS 5.1.2.18
  10167. --  -----
  10168. --
  10169. ---------------------------------------------------------------------
  10170.  
  10171.         procedure Copy_Node(From        : Node_Type; 
  10172.                             To_Base     : in out Node_Type; 
  10173.                             To_Key      : Relationship_Key; 
  10174.                             To_Relation : Relation_Name := Default_Relation); 
  10175.  
  10176.         procedure Copy_Node(From : in Node_Type; 
  10177.                             To   : in Name_String); 
  10178.  
  10179. ------------------       C O P Y _ T R E E       ------------------------
  10180. --
  10181. --  Purpose:
  10182. --  -------
  10183. --    These procedures copy a tree of file or structural nodes formed by the
  10184. --    primary relationships emanating from the node identified by the open node
  10185. --    handle From.  Primary relationships are recreated between corresponding
  10186. --    copied nodes.  The root node of the newly created tree corresponding to
  10187. --    the From node is the node identified by the combination of the To_Base,
  10188. --    To_Key, and To_Relation parameters.  If an exception is raised by the
  10189. --    procedure none of the nodes are copied.  Secondary relationships,
  10190. --    attributes, and node contents are copied as described for Copy_Node with
  10191. --    the following additional rules: secondary relationships between two nodes
  10192. --    which are both copied are recreated between the two copies.  Secondary
  10193. --    relationships emanating from a node which is copied, but which refer to
  10194. --    nodes outside the tree being copied, are copied so that they emanate from
  10195. --    the copy, but still refer to the original target node.  Secondary
  10196. --    relationships emanating from a node which is not copied, but which refer
  10197. --    to nodes inside the tree being copied, are unaffected.  If the node
  10198. --    identified by To_Base is part of the tree being copied, then the copy of
  10199. --    the node identified by From will not be copied recursively.
  10200. --
  10201. --  Parameters:
  10202. --  ----------
  10203. --    From      - an open node handle to the root node of the tree to be copied.
  10204. --    To_Base   - open node handle to a base node for identification of the
  10205. --          node to be created as root of the new tree.
  10206. --    To_Key    - the relationship key for identification of the node to be
  10207. --              - created as root of the new tree.
  10208. --    To_Relation  - the relation name for identification of the node to be
  10209. --                created as root of the new tree.
  10210. --
  10211. --  Exceptions:
  10212. --  ----------
  10213. --    Name_Error        - raised if the new node identification is illegal
  10214. --                        or if a node already exists with the identification
  10215. --                        given for the new node to be created as a copy of
  10216. --              the node identified by From.
  10217. --    Use_Error         - is raised if the origianl node is not a file or
  10218. --              structural node.  Use_Error is also raised if the
  10219. --              To_Relation is the name of a predefined relation
  10220. --              that cannot be modified or created by the user.
  10221. --    Status_Error      - is raised if the Node_Handles From and To_Base are
  10222. --              not both open.
  10223. --    Lock_Error    - is raised if any node to be copied except the node
  10224. --              identified by From is locked against read access to
  10225. --              attributes, relationships, or contents.
  10226. --    Intent_Violation  - is raised if "From" was not opened with an intent
  10227. --                        establishing the right to read contents, attributes
  10228. --              and relationships, or if To_Base was not opened with
  10229. --              the right to append relationships. Intent_Violation
  10230. --              is not raised if the conditions for name error are
  10231. --              present.
  10232. --    Access_Violation     - is raised if the current process' discretionary
  10233. --              access control rights are insufficient to obtain
  10234. --              access to each node to be copied with intent Read.
  10235. --              Access_Violation is not raised if conditions for
  10236. --              Name_Error are present.
  10237. --    Security_Violation -is raised if the operations represents a 
  10238. --                        violation of mandatory access controls for the
  10239. --                        CAIS.  Security_Violation is raised only if the
  10240. --                        conditions for other exceptions are not present.
  10241. --
  10242. --  Notes:   CAIS 5.1.2.19
  10243. --  -----
  10244. --
  10245. ---------------------------------------------------------------------
  10246.  
  10247.         procedure Copy_Tree(From        : Node_Type; 
  10248.                             To_Base     : in out Node_Type; 
  10249.                             To_Key      : Relationship_Key; 
  10250.                             To_Relation : Relation_Name := Default_Relation); 
  10251.  
  10252.         procedure Copy_Tree(From : in Node_Type; 
  10253.                             To   : in Name_String); 
  10254.  
  10255.  
  10256. ------------------------     R E N A M E     ------------------------
  10257. --
  10258. --  Purpose:
  10259. --  -------
  10260. --    These procedures rename a file or a structural node.  They delete
  10261. --    the Primary relationship to the node identified by "Node" and install
  10262. --    a new primary relationship to the node, emanating from the node
  10263. --    identified by "New_Base", with key and relation given by the New_KEy and
  10264. --    New_Relation parameters.  The parent relationship is changed accordingly.
  10265. --    This the unique primary path name of the node.  Existing secondary
  10266. --    relationships with the renamed node as target track the renaming, i.e.,
  10267. --    they have the renamed node as target.
  10268. --
  10269. --  Parameters:
  10270. --  ----------
  10271. --    Node      - an opened node handle to the node to be renamed.
  10272. --    New_Base  - open node handle to a base node from which the new primary
  10273. --          relationship to the renamed node emanates.
  10274. --    New_Key   - the relationship key for the new primary relationship
  10275. --    New_Relation  - the relation name for the new primary relationship
  10276. --
  10277. --  Exceptions:
  10278. --  ----------
  10279. --    Name_Error        - raised if the new node identification is illegal
  10280. --              or if a node already exists with the identification
  10281. --              given for the new node.
  10282. --    Use_Error         - is raised if the node identified by "Node" is not a
  10283. --              file or structural node or if the renaming cannot be
  10284. --              accomplished while still maintaining acircularity of
  10285. --              primary relationships (eg. if the new parent node
  10286. --              would be the renamed node).  Use Error is also raised
  10287. --              if New_Relation is the name of a predefined relation
  10288. --              that cannot be modified or createdby the user or if
  10289. --              the primary relationship to be deleted belongs to a
  10290. --              predefined relation that cannot be modified by the
  10291. --              user.
  10292. --    Status_Error      - is raised if the Node_Handle "Node" and "New_Base"
  10293. --                        are not open.
  10294. --    Lock_Error        - is raised if access with intent Write_Relationships,
  10295. --                        to the parent of the node to be renamed cannot be
  10296. --              obtained to due to an existing lock on the node.
  10297. --    Intent_Violation  - is raised if "Node" was not opened with an intent
  10298. --                        establishing the right to write relationships or
  10299. --              if "New_Base" was not opened with an intent
  10300. --                        establishing the right to append relationships.
  10301. --    Access_Violation  - is raised if the current process's discretionary
  10302. --                        access control rights are insufficient to obtain
  10303. --                        access to the parent of the node to be renamed 
  10304. --                        with intent Write_Relationships and the conditions
  10305. --              for Name_Error are not present.
  10306. --    Security_Violation -is raised if the operation represents a 
  10307. --                        violation of mandatory access controls for the
  10308. --                        CAIS.  Security_Violation is raised only if the
  10309. --                        conditions for other exceptions are not present.
  10310. --
  10311. --  Notes:   CAIS 5.1.2.20
  10312. --  -----
  10313. --
  10314. ---------------------------------------------------------------------
  10315.  
  10316.         procedure Rename(Node         : in out Node_Type; 
  10317.                          New_Base     : in out Node_Type; 
  10318.                          New_Key      : Relationship_Key; 
  10319.                          New_Relation : Relation_Name := Default_Relation); 
  10320.  
  10321.         procedure Rename(Node     : in out Node_Type; 
  10322.                          New_Name : Name_String); 
  10323.  
  10324. ----------------------   D E L E T E _ N O D E ----------------------
  10325. --
  10326. --  Purpose:
  10327. --  -------
  10328. --    This procedure deletes the primary relationship to a node
  10329. --    identified by Node.  The node becomes unobtainable.  The node
  10330. --    handle Node is closed.  If the node is a process node and the
  10331. --    process is not yet terminated (see Section 5.2 of MIL-STD-CAIS),
  10332. --    Delete_Node aborts the process.
  10333. --
  10334. --  Parameters:
  10335. --  ----------
  10336. --    Node  - an open node handle to the node which is the target of
  10337. --            the primary relationship to be deleted.
  10338. --
  10339. --  Exceptions:
  10340. --  ----------
  10341. --    (all defined in Node_Definitions)
  10342. --    Name_Error          - if parent node of Node is inaccessable
  10343. --    Use_Error           - if any primary Relationships emanate from Node
  10344. --    Status_Error        - if Node is not open
  10345. --    Lock_Error          - if access, with intent Write_Relationships,
  10346. --                          to the parent of the node to be deleted
  10347. --                          cannot be obtained due to an existing lock
  10348. --                          on the node.
  10349. --    Intent_Violation    - if the node handle Node was not opened with
  10350. --                          an intent including Exclusive_Write and 
  10351. --                          Read_Relationships.
  10352. --    Access_Violation    - if the current process does not have sufficient
  10353. --                          discretionary access control rights to obtain
  10354. --                          access to the parent of the node to be deleted
  10355. --                          with intent Write_Relationships and the
  10356. --                          conditions for Name_Error are not present.
  10357. --    Security_Violation  - if the operation represents a violation of
  10358. --                          mandatory access controls.  Security_Violation
  10359. --                          is raised only if the conditions for other
  10360. --                          exceptions are not present.
  10361. --
  10362. --  Notes:
  10363. --  -----
  10364. --    MIL-STD-CAIS 5.1.2.21
  10365. --     Locking support will have to be added here...
  10366. ---------------------------------------------------------------------
  10367.         procedure Delete_Node(Node : in out Node_Type); 
  10368.  
  10369.         procedure Delete_Node(Name : Name_String); 
  10370.  
  10371. ----------------------   D E L E T E _ T R E E ----------------------
  10372. --
  10373. --  Purpose:
  10374. --  -------
  10375. --    This procedure effectively performs the Delete_Node operation for
  10376. --    a specified node and recursively applies Delete_Tree to all nodes
  10377. --    reachable by a unique primary pathname from the designated node.
  10378. --    The nodes whose primary relationships are to be deleted are opened
  10379. --    with intent Exclusive_Write, thus locking them for other operations.
  10380. --    The order in which the deletions of primary relationships is performed
  10381. --    is not specified.  If the Delete_Tree operation raises an exception,
  10382. --    none of the primary relationships is deleted.
  10383. --
  10384. --  Parameters:
  10385. --  ----------
  10386. --    Node  - an open node handle to the node at the root of the tree 
  10387. --            whose primary relationships are to be deleted.
  10388. --
  10389. --  Exceptions:
  10390. --  ----------
  10391. --    (all defined in Node_Definitions)
  10392. --    Name_Error          - if parent node of Node or any of the target nodes of
  10393. --                primary relationships to be deleted are inaccessable
  10394. --    Use_Error           - if the primary Relationship of Node belongs to a
  10395. --                predefined relation that cannot be modified by the
  10396. --                user.
  10397. --    Status_Error        - if Node is not open
  10398. --    Lock_Error          - if access, with intent Write_Relationships,
  10399. --                          to the parent of the "Node" cannot be obtained due
  10400. --                to an existing lock or if a node handle identifying
  10401. --                any node whose unique primary path traverses the
  10402. --                node identified by Node cannot be opened with intent
  10403. --                Exclisive_Write.
  10404. --    Intent_Violation    - if the node handle Node was not opened with
  10405. --                          an intent including Exclusive_Write and 
  10406. --                          Read_Relationships.
  10407. --    Access_Violation    - if the current process does not have sufficient
  10408. --                          discretionary access control rights to obtain
  10409. --                          access to the parent of the node specified by Node
  10410. --                          with intent Write_Relationships or to obtain 
  10411. --                access to any target node of a primary relationship
  10412. --                to be deleted with the intent Exclusive_Write and
  10413. --                the conditions for Name_Error are not present.
  10414. --    Security_Violation  - if the operation represents a violation of
  10415. --                          mandatory access controls.  Security_Violation
  10416. --                          is raised only if the conditions for other
  10417. --                          exceptions are not present.
  10418. --
  10419. --  Notes:
  10420. --  -----
  10421. --    MIL-STD-CAIS 5.1.2.23
  10422. --     Locking support will have to be added here...
  10423. ---------------------------------------------------------------------
  10424.         procedure Delete_Tree(Node : in out Node_Type); 
  10425.  
  10426.         procedure Delete_Tree(Name : Name_String); 
  10427.  
  10428. -------------------------   L I N K   -------------------------------
  10429. --
  10430. --  Purpose:
  10431. --  -------
  10432. --    This procedure creates a secondary relationship between two existing
  10433. --    The procedure takes a node handle "Node" on the target node, a
  10434. --    node handle "New_Base" on the source node, and an explicit key
  10435. --    "New_Key" and a relation name "New_Relation" for the relationship
  10436. --    to be established from "New_Base" to "Node".
  10437. --
  10438. --  Parameters:
  10439. --  ----------
  10440. --    Node        - open node handle to the node to which the new 
  10441. --                  secondary relationship points.
  10442. --    New_Base    - an open node handle to the base node from which the
  10443. --                  new secondary relationship to the node emanates.
  10444. --    New_Key     - the relationship key for the new secondary relationship
  10445. --    New_Relation - the relation name for the new secondary relationship
  10446. --
  10447. --  Exceptions:
  10448. --  ----------
  10449. --    Name_Error     - raised if the relationship key or the relation
  10450. --                     name are illegal or if a node already exists
  10451. --                     with the identification given by "New_Base",
  10452. --                     "New_Key", and "New_Relation".
  10453. --    Use_Eror       - raised if "New_Relation" is the name of a predefined
  10454. --                     relation that cannot be modified or created by the user.
  10455. --    Status_Error   - raised if the node handles "Node" and "New_Base" are
  10456. --                     not open.
  10457. --    Intent_Violation  - raised if "New_Base" was not opened with an intent
  10458. --                        establishing the right to append relationships.
  10459. --    Security_Violation - raised if the operation represents a violation
  10460. --                         of mandatory access controls.  Security_Violation
  10461. --                         is raised only if the conditions for other
  10462. --                         exceptions are not present.
  10463. --  Notes:   CAIS 5.1.2.23
  10464. --  -----
  10465. --
  10466. ---------------------------------------------------------------------
  10467.         procedure Link(Node         : in out Node_Type; 
  10468.                        New_Base     : in out Node_Type; 
  10469.                        New_Key      : Relationship_Key; 
  10470.                        New_Relation : Relation_Name := Default_Relation); 
  10471.  
  10472.     -- Additional Interface
  10473.         procedure Link(Node     : in out Node_Type; 
  10474.                        New_Name : Name_String); 
  10475.  
  10476. --------------------------   U N L I N K     ------------------------
  10477. --
  10478. --  Purpose:
  10479. --  -------
  10480. --    This procedure deletes a secondary relationship identified by the
  10481. --    "Base", "Key", and "Relation" parameters.
  10482. --
  10483. --  Parameters:
  10484. --  ----------
  10485. --    Base     - an open node handle to the node from which the relationship
  10486. --               emanates which is to be deleted.
  10487. --    Key      - the relationship key of the relationship to be deleted.
  10488. --    Relation - the relation name of the relation to be deleted.
  10489. --
  10490. --  Exceptions:
  10491. --  ----------
  10492. --    Name_Error    - raised if the relationship identified by "Base",
  10493. --                    "Key", and "Relation" does not exist.
  10494. --    Use_Error     - raised if the specific relationship is a primary
  10495. --                    relationship.  Use_Eror is also raised if "Relation"
  10496. --                    is the name of a predefined relation that cannot be
  10497. --                    modified or created by the user.
  10498. --    Status_Error  - raised if the "base" is not an open node handle.
  10499. --    Intent_Violation - raised if "Base" was not opened with an intent
  10500. --                    establishing the right to write relationships.
  10501. --    Security_Violation - raised if the operation represents a violation
  10502. --                         of mandatory access controls.  Security_Violation
  10503. --                         is raised only if the conditions for other
  10504. --                         exceptions are not present.
  10505. --
  10506. --  Notes:   CAIS 5.1.2.24
  10507. --  -----
  10508. --
  10509. ---------------------------------------------------------------------
  10510.         procedure Unlink(Base     : in out Node_Type; 
  10511.                          Key      : Relationship_Key; 
  10512.                          Relation : Relation_Name := Default_Relation); 
  10513.  
  10514.     -- Additional Interface
  10515.         procedure Unlink(Name : Name_String); 
  10516.  
  10517.  
  10518. ----------------------     I T E R A T E     ------------------------
  10519. --
  10520. --  Purpose:
  10521. --  -------
  10522. --    This procedure establishes a node iterator "Iterator" over the
  10523. --    set of nodes that are the targets of relationships emanating
  10524. --    from a given node identified by "Node" and matching the specified
  10525. --    "Key" and "Relation" patterns.  Nodes that are of a different kind
  10526. --    than the "Kind" specified are omitted by subsequent calls to
  10527. --    "Get_Next" using the resulting iterator.  If "Primary_Only" is
  10528. --    true, then the iterator will be based only on primary relationships.
  10529. --
  10530. --  Parameters:
  10531. --  ----------
  10532. --    Iterator      - the node iterator returned.
  10533. --    Node          - an open node handle to a node whose relationships
  10534. --                    form the basis for constructing the iterator.
  10535. --    Kind          - the kind of nodes on which the iterator is based.
  10536. --    Key           - the pattern for the relationship keys on which
  10537. --                    the iterator is based.
  10538. --    Relation      - the pattern for the relation names on which
  10539. --                    the iterator is based.
  10540. --    Primary_Only  - if true, the iterator will be based on only
  10541. --                    primary relationships; if false, the iterator
  10542. --                    will be based on all relationships satisfying
  10543. --                    the pattern.
  10544. --
  10545. --  Exceptions:
  10546. --  ----------
  10547. --    Use_Error     - raised if the pattern given in "Key" or "Relation"
  10548. --                    is syntactically illegal.
  10549. --    Status_Error  - raised if "Node" is not an open node.
  10550. --    Intent_Violation - raised if "Node" was not opened with an intent
  10551. --                       establishing the right to read relationships.
  10552. --
  10553. --  Notes:   CAIS 5.1.2.26
  10554. --  -----
  10555. --
  10556. ---------------------------------------------------------------------
  10557.         procedure Iterate(-- build an iterator
  10558.                           Iterator     : in out Node_Iterator; 
  10559.                                           -- see CAIS 1.4 5.1.2.25 for expl.)
  10560.                           Node         : in Node_Type; 
  10561.                                           -- open node handle for desired node
  10562.                           Kind         : in Node_Kind; 
  10563.                                           -- kind of nodes to include
  10564.                           Key          : in Relationship_Key_Pattern := "*"; 
  10565.                                           -- pattern to select keys
  10566.                           Relation     : in Relation_Name_Pattern := 
  10567.                               Default_Relation; 
  10568.                                           -- pattern to select relations
  10569.                           Primary_Only : in Boolean := True); 
  10570.     -------------------------------------------------------------------------
  10571.     --         ALTERNATE INTERFACE via NAME_STRING for NODE                --
  10572.     -------------------------------------------------------------------------
  10573.         procedure Iterate(-- build an iterator
  10574.                           Iterator     : in out Node_Iterator; 
  10575.                                           -- see CAIS 1.4 5.1.2.25 for expl.)
  10576.                           Name         : in Name_String; 
  10577.                                           -- pathname of iterator's source node
  10578.                           Kind         : in Node_Kind; 
  10579.                                           -- kind of nodes to include
  10580.                           Key          : in Relationship_Key_Pattern := "*"; 
  10581.                                           -- pattern to select keys
  10582.                           Relation     : in Relation_Name_Pattern := 
  10583.                               Default_Relation; 
  10584.                                           -- pattern to select relations
  10585.                           Primary_Only : in Boolean := True); 
  10586.  
  10587. -------------------------   M O R E       ---------------------------
  10588. --
  10589. --  Purpose:
  10590. --  -------
  10591. --    This function returns False if all nodes contained in the node
  10592. --    iterator have been retrieved with the "Get_Next" procedure;
  10593. --    otherwise it returns True.
  10594. --
  10595. --  Parameters:
  10596. --  ----------
  10597. --    Iterator  - a node iterator previously set by the procedure 
  10598. --                "Iterate".
  10599. --
  10600. --  Exceptions:
  10601. --  ----------
  10602. --    Use_Error   - raised if the"Iterator" has not been previously
  10603. --                  set by the procedure "Iterate".
  10604. --
  10605. --  Notes:   CAIS 5.1.2.28
  10606. --  -----
  10607. --
  10608. ---------------------------------------------------------------------
  10609.         function More(
  10610.                     -- indicate if all nodes have been retrieved via Get_Next
  10611.                       Iterator : in Node_Iterator)
  10612.                                     -- previously constructed iterator
  10613.         return Boolean; 
  10614.  
  10615.  
  10616. ----------------------    G E T _ N E X T      ----------------------
  10617. --
  10618. --  Purpose:
  10619. --  -------
  10620. --    This procedure returns an open node handle to the next node in the
  10621. --    parameter "Next_Node"; the intent under which the node handle is
  10622. --    opened is specified by the "Intent" parameter.  If "Next_Node"
  10623. --    is open prior to the call to "Get_Next", it is closed prior to
  10624. --    being opened to the next node.  A time limit can be specified
  10625. --    for the maximum delay permitted if the node to be opened is locked
  10626. --    against access with the specified "Intent".
  10627. --
  10628. --  Parameters:
  10629. --  ----------
  10630. --    Iterator     - node iterator previously set by "Iterate".
  10631. --    Next_Node    - node handle to be opened to the next node on the
  10632. --                   iterator.
  10633. --    Intent       - the intent of subsequent operations on the node
  10634. --                   handle "Next_Node".
  10635. --    Time_Limit   - specifies the time limit for the delay on waiting
  10636. --                   for the unlocking of the node in accordance with the
  10637. --                   desired "Intent".
  10638. --
  10639. --  Exceptions:
  10640. --  ----------
  10641. --    Name_Error    - raised if the node whose node handle is to be
  10642. --                    returned by "Next_Node" is unobtainable and if the
  10643. --                    "Intent" includes any intent other than "Existance".
  10644. --    Use_Error     - raised if the iterator has not been previously set
  10645. --                    by "Iterate" or if the iterator has been exhausted
  10646. --                    or if "Intent" is an empty array.
  10647. --    Lock_Error    - raised if the opening of this node is delayed beyond
  10648. --                    the specified "Time_Limit" due to the existence of
  10649. --                    locks in conflict with the specified "Intent".
  10650. --    Access_Violation - raised if the current process's discretionary
  10651. --                       access control rights are insufficient to obtain
  10652. --                       access to the next node with the specified intent.
  10653. --                       Access_Violation is raised only if the conditions
  10654. --                       for Name_Error are not present.
  10655. --    Security_Violation - raised if the operation represents a violation
  10656. --                         of mandatory access controls.  Security_Violation
  10657. --                         is raised only if the conditions for other
  10658. --                         exceptions are not present.
  10659. --
  10660. --  Notes:   CAIS 5.1.2.28
  10661. --  -----
  10662. --
  10663. ---------------------------------------------------------------------
  10664.         procedure Get_Next(
  10665.                           -- get open node handle to next node  in iterator
  10666.                            Iterator   : in out Node_Iterator; 
  10667.                                           -- see CAIS 1.4 5.1.2.25 for expl.
  10668.                            Next_Node  : in out Node_Type; 
  10669.                                           -- will be the open node handle
  10670.                            Intent     : in Intention := (1 => Existence); 
  10671.                                                      --intent for opening
  10672.                            Time_Limit : in Duration := No_Delay); 
  10673.                                                      --time limit for opening
  10674.  
  10675.     private
  10676.  
  10677.     -- The following type declaration supports the Node_Iterator type
  10678.         type Pseudo_List_Type is access List_Utilities.List_Type; 
  10679.         type Node_Iterator is 
  10680.             record
  10681.                 List             : Pseudo_List_Type; 
  10682.                                                 --List of relations where each
  10683.                                                 --relation contains a list of
  10684.                                                 --keys
  10685.                 Rel_Position     : List_Utilities.Count := 0; 
  10686.                                                         --current Relation 
  10687.                 Key_Position     : List_Utilities.Count := 0; 
  10688.                                                         --current Key     
  10689.                 Base_Name_Length : Integer range 1 .. Pragmatics.Max_Name_String
  10690.                     ; 
  10691.                 Base_Name        : String(1 .. Pragmatics.Max_Name_String); 
  10692.                                                 --pathname of node
  10693.                                                 --from which Iterator
  10694.                                                 --is created. Actual
  10695.                                                 --length is Base_Name_Length
  10696.             end record; 
  10697.  
  10698. ---------------------------------------------------------------------
  10699.     end Node_Management; 
  10700.                        --  END OF PACKAGE SPEC 
  10701. ---------------------------------------------------------------------
  10702. ----------------------------------------------------------------------
  10703. --                         A T T R I B U T E S
  10704. --
  10705. --  Purpose:
  10706. --  --------
  10707. --    This  package  supports  the  definition  and  manipulation   of
  10708. --    attributes for nodes and relationships in the CAIS.  The name of
  10709. --    an attribute follows the syntax of an Ada  identifier  (Ada  LRM
  10710. --    2.3).  The value of an attribute is a list of the format defined
  10711. --    by the  package  list_utilities  (MIL-STD CAIS section  5.4).
  10712. --    Upper  vs.  lower  case  distinctions are significant within the
  10713. --    value of attributes, but not within the attribute name.
  10714. --
  10715. --  Usage:
  10716. --  -----
  10717. --    The operations defined  for  the  manipipulation  of  attributes
  10718. --    identify  the  node  to  which  an  attribute  belongs either by
  10719. --    pathname or open node  handle.   They  identify  a  relationship
  10720. --    implicitly  by the last path element of a pathname or explicitly
  10721. --    by base node, key and relation name identification.
  10722. --
  10723. --  Example:
  10724. --  -------
  10725. --        To_List( "(""17NOV85"")", String_Value);
  10726. --        To_List( "(""14APR86"")", New_Value);
  10727. --          Create_Node_Attribute(Node, "DATE", String_Value);
  10728. --        Set_Node_Attribute   (Node, "DATE", New_Value);
  10729. --        Get_Node_Attribute   (Node, "DATE", String_Value);
  10730. --        Delete_Node_Attribute(Node, "DATE");
  10731. --
  10732. --        Node_Attribute_Iterate(Node, Iterator, "D*");
  10733. --        while More(Iterator) loop
  10734. --            Get_Next(Iterator, Attribute, Value);
  10735. --        end loop;
  10736. --
  10737. --  Notes:
  10738. --  -----
  10739. --
  10740. --  Revision History:
  10741. --  ----------------
  10742. --
  10743. -------------------------------------------------------------------
  10744.     package Attributes is 
  10745.  
  10746.         use Node_Definitions; 
  10747.         use List_Utilities; 
  10748.  
  10749.     -- The following type declarations are from CAIS section 5.1.3.9
  10750.         subtype Attribute_Name is String; 
  10751.         type Attribute_Iterator is private; 
  10752.         subtype Attribute_Pattern is String; 
  10753.     -- This type is needed to define Attribute_Iterator
  10754.         type Pseudo_List_Type is access List_Type; 
  10755. ----------------------   Create_Node_Attribute ----------------------
  10756. --
  10757. --  Purpose: This procedure creates an attribute named by ATTRIBUTE of
  10758. --  -------  of the node identified by the open node handle NODE and sets
  10759. --           its initial value to VALUE.
  10760. --
  10761. --  Parameters:
  10762. --  ----------
  10763. --    Node       is the open node handle being modified
  10764. --    Attribute  is the name of the attribute being added to this node
  10765. --    Value      is the initial value of the attribute
  10766. --
  10767. --  Exceptions:
  10768. --  ----------
  10769. --   USE_ERROR          is raised if the node already has an attribute of the
  10770. --                given name or if the name given is syntactically
  10771. --                      illegal or is the name of a predefined node attribute.
  10772. --
  10773. --   STATUS-ERROR       is raised if the node handle is not open
  10774. --
  10775. --   INTENT_VIOLATION   is raised if NODE was not opened with the right to
  10776. --            append attributes.
  10777. --
  10778. --   SECURITY_VIOLATION is raised if the operation represents a violation of
  10779. --            mandatory access controls.  Raised only if no other
  10780. --            exceptions apply.
  10781. --
  10782. --  Notes: MIL-STD CAIS 5.1.3.1
  10783. --  -----
  10784. --   Security_Violation is not implemented
  10785. ---------------------------------------------------------------------
  10786.     -- CAIS 5.1.3.1
  10787.         procedure Create_Node_Attribute(
  10788.                                       -- create attribute, set initial value
  10789.                                         Node      : in out Node_Type; 
  10790.                                       -- open node handle for desired node
  10791.                                         --************************************
  10792.                                         --PROPOSED DEVIATION FROM MIL STD CAIS
  10793.                                         --************************************
  10794.                                         Attribute : Attribute_Name; 
  10795.                                       -- name of the attribute
  10796.                                         Value     : List_Type); 
  10797.                                       -- initial value of the attribute
  10798. -----------------------------------------------------------------------------
  10799. --             ALTERNATE INTERFACE via NAME_STRING for Relationship        --
  10800. -----------------------------------------------------------------------------
  10801.         procedure Create_Node_Attribute(
  10802.                                       -- create attribute, set initial value
  10803.                                         Name      : Name_String; 
  10804.                                       -- pathname of desired node
  10805.                                         Attribute : Attribute_Name; 
  10806.                                       -- name of the attribute
  10807.                                         Value     : List_Type); 
  10808.                                       -- initial value of the attribute
  10809.  
  10810.  
  10811. ----------------------  Create_Path_Attribute  ----------------------
  10812. --  Purpose: This procedure creates an attribnute named by ATTRIBUTE of
  10813. --  -------  of a relationship and sets its initial value to VALUE.  The 
  10814. --         relationship is defined by the base node defined by the open
  10815. --         node handle BASE, the relation name RELATION, and the
  10816. --         relationship key KEY.
  10817. --
  10818. --  Parameters:
  10819. --  ----------
  10820. --    Base       is the open node handle of the base node
  10821. --    Key       is the relationship key of the affected relationship
  10822. --    Relation   is the relation name of the affected relationship
  10823. --    Attribute  is the name of the attribute added to this relationship
  10824. --    Value      is the initial value of the attribute
  10825. --
  10826. --  Exceptions:
  10827. --  ----------
  10828. --   NAME_ERROR        is raised if the relationship identified by BASE, KEY,
  10829. --            and RELATION does not exist
  10830. --
  10831. --   USE_ERROR          is raised if the relationship already has an attribute
  10832. --            of the given name or if the name given is syntactically
  10833. --                      illegal or is the name of a predefined node attribute
  10834. --            that cant be modified by the user. Use_Error is also
  10835. --            raised if RELATION is the name of a predefined relation
  10836. --            that can't be modified by the user.
  10837. --
  10838. --   STATUS-ERROR       is raised if the node handle BASE is not open
  10839. --   INTENT_VIOLATION   is raised if BASE was not opened with the right to
  10840. --            write relationships.
  10841. --   SECURITY_VIOLATION is raised if the operation represents a violation of
  10842. --            mandatory access controls.  Raised only if no other
  10843. --            exceptions apply.
  10844. --
  10845. --  Notes: MIL-STD CAIS 5.1.3.2
  10846. --  -----
  10847. --   Security_Violation is not implemented
  10848. ---------------------------------------------------------------------
  10849.         procedure Create_Path_Attribute(-- Create an attribute
  10850.                                         Base      : in out Node_Type; 
  10851.                                      -- open node handle from which 
  10852.                                      -- the relationship emanates
  10853.                                         Key       : Relationship_Key; 
  10854.                                      -- key of affected relationship
  10855.                                         Relation  : Relation_Name := 
  10856.                                             Default_Relation; 
  10857.                                      -- name of affected relationship
  10858.                                         Attribute : Attribute_Name; 
  10859.                                      -- name of created attribute
  10860.                                         Value     : List_Type); 
  10861.                                      -- initial value of the attribute
  10862. -----------------------------------------------------------------------------
  10863. --             ALTERNATE INTERFACE via NAME_STRING for NODE                --
  10864. -----------------------------------------------------------------------------
  10865.         procedure Create_Path_Attribute(-- Create an attribute
  10866.                                         Name      : Name_String; 
  10867.                                      -- pathname of desired node
  10868.                                         Attribute : Attribute_Name; 
  10869.                                      -- name of created attribute
  10870.                                         Value     : List_Type); 
  10871.                                      -- initial value of the attribute
  10872. ----------------------  Delete_Node_Attribute  ----------------------
  10873. --
  10874. --  Purpose: This procedure deletes an attribute named by ATTRIBUTE of
  10875. --  -------  of the node identified by the open node handle NODE.
  10876. --
  10877. --  Parameters:
  10878. --  ----------
  10879. --    Node       is the open node handle being modified
  10880. --    Attribute  is the name of the attribute being added to this node
  10881. --
  10882. --  Exceptions:
  10883. --  ----------
  10884. --   USE_ERROR          is raised if the node does not have an attribute of the
  10885. --                given name (or if the name given is syntactically
  10886. --                      illegal??) or is the name of a predefined node attribute
  10887. --            which can't be modified by the user.
  10888. --
  10889. --   STATUS-ERROR       is raised if the node handle is not open
  10890. --
  10891. --   INTENT_VIOLATION   is raised if NODE was not opened with the right to
  10892. --            write attributes.
  10893. --
  10894. --   SECURITY_VIOLATION is raised if the operation represents a violation of
  10895. --            mandatory access controls.  Raised only if no other
  10896. --            exceptions apply.
  10897. --
  10898. --  Notes: MIL-STD CAIS 5.1.3.3
  10899. --  -----
  10900. --   Security_Violation is not implemented
  10901. ---------------------------------------------------------------------
  10902.     -- CAIS 5.1.3.3
  10903.         procedure Delete_Node_Attribute(
  10904.                                        -- Delete an attribute
  10905.                                         Node      : in out Node_Type; 
  10906.                                       -- open node handle for desired node
  10907.                                         --************************************
  10908.                                         --PROPOSED DEVIATION FROM MIL STD CAIS
  10909.                                         --************************************
  10910.                                         Attribute : Attribute_Name); 
  10911.                                      -- name of the attribute to be deleted
  10912. -----------------------------------------------------------------------------
  10913. --             ALTERNATE INTERFACE via NAME_STRING for NODE                --
  10914. -----------------------------------------------------------------------------
  10915.         procedure Delete_Node_Attribute(
  10916.                                        -- Delete an attribute
  10917.                                         Name      : Name_String; 
  10918.                                      -- pathname of desired node
  10919.                                         Attribute : Attribute_Name); 
  10920.                                      -- name of the attribute to be deleted
  10921.  
  10922.  
  10923. ----------------------  Delete_Path_Attribute  ----------------------
  10924. --  Purpose: This procedure creates an attribnute named by ATTRIBUTE of
  10925. --  -------  of a relationship and sets its initial value to VALUE.  The 
  10926. --         relationship is defined by the base node defined by the open
  10927. --         node handle BASE, the relation name RELATION, and the
  10928. --         relationship key KEY.
  10929. --
  10930. --  Parameters:
  10931. --  ----------
  10932. --    Base       is the open node handle of the base node
  10933. --    Key       is the relationship key of the affected relationship
  10934. --    Relation   is the relation name of the affected relationship
  10935. --    Attribute  is the name of the attribute added to this relationship
  10936. --    Value      is the initial value of the attribute
  10937. --
  10938. --  Exceptions:
  10939. --  ----------
  10940. --   NAME_ERROR        is raised if the relationship identified by BASE, KEY,
  10941. --            and RELATION does not exist
  10942. --
  10943. --   USE_ERROR          is raised if the relationship already has an attribute
  10944. --            of the given name or if the name given is syntactically
  10945. --                      illegal or is the name of a predefined node attribute
  10946. --            that cant be modified by the user. Use_Error is also
  10947. --            raised if RELATION is the name of a predefined relation
  10948. --            that can't be modified by the user.
  10949. --
  10950. --   STATUS-ERROR       is raised if the node handle BASE is not open
  10951. --   INTENT_VIOLATION   is raised if BASE was not opened with the right to
  10952. --            write relationships.
  10953. --   SECURITY_VIOLATION is raised if the operation represents a violation of
  10954. --            mandatory access controls.  Raised only if no other
  10955. --            exceptions apply.
  10956. --
  10957. --  Notes: MIL-STD CAIS 5.1.3.4
  10958. --  -----
  10959. --   Security_Violation is not implemented
  10960. ---------------------------------------------------------------------
  10961.         procedure Delete_Path_Attribute(-- delete an attribute
  10962.                                         Base      : in out Node_Type; 
  10963.                                         -- open node handle from which 
  10964.                                         -- the relationship emanates
  10965.                                         Key       : Relationship_Key; 
  10966.                                         -- key of affected relationship
  10967.                                         Relation  : Relation_Name := 
  10968.                                             Default_Relation; 
  10969.                                         -- name of affected relationship
  10970.                                         Attribute : Attribute_Name); 
  10971.                                         -- name of created attribute
  10972. -----------------------------------------------------------------------------
  10973. --             ALTERNATE INTERFACE via NAME_STRING for NODE                --
  10974. -----------------------------------------------------------------------------
  10975.         procedure Delete_Path_Attribute(-- delete an attribute
  10976.                                         Name      : Name_String; 
  10977.                                         -- pathname of desired node
  10978.                                         Attribute : Attribute_Name); 
  10979.                                         -- name of created attribute
  10980. ----------------------SET_NODE_ATTRIBUTE-----------------------------
  10981. --
  10982. --  Purpose: This procedure deletes an attribute named by ATTRIBUTE of
  10983. --  -------  of the node identified by the open node handle NODE.
  10984. --
  10985. --  Parameters:
  10986. --  ----------
  10987. --    Node       is the open node handle being modified
  10988. --    Attribute  is the name of the attribute being added to this node
  10989. --
  10990. --  Exceptions:
  10991. --  ----------
  10992. --   USE_ERROR          is raised if the node does not have an attribute of the
  10993. --                given name (or if the name given is syntactically
  10994. --                      illegal??) or is the name of a predefined node attribute
  10995. --            which can't be modified by the user.
  10996. --
  10997. --   STATUS-ERROR       is raised if the node handle is not open
  10998. --
  10999. --   INTENT_VIOLATION   is raised if NODE was not opened with the right to
  11000. --            write attributes.
  11001. --
  11002. --   SECURITY_VIOLATION is raised if the operation represents a violation of
  11003. --            mandatory access controls.  Raised only if no other
  11004. --            exceptions apply.
  11005. --
  11006. --  Notes: MIL-STD CAIS 5.1.3.5
  11007. --  -----
  11008. --   Security_Violation is not implemented
  11009. ---------------------------------------------------------------------
  11010.     -- CAIS 5.1.3.5
  11011.         procedure Set_Node_Attribute(  -- Set the value of existing attribute
  11012.                                      Node      : in out Node_Type; 
  11013.                                       -- open node handle for desired node
  11014.                                         --************************************
  11015.                                         --PROPOSED DEVIATION FROM MIL STD CAIS
  11016.                                         --************************************
  11017.                                      Attribute : Attribute_Name; 
  11018.                                          -- name of attribute to be set
  11019.                                      Value     : List_Type); 
  11020.                                          -- new value of attribute
  11021. -----------------------------------------------------------------------------
  11022. --             ALTERNATE INTERFACE via NAME_STRING for NODE                --
  11023. -----------------------------------------------------------------------------
  11024.         procedure Set_Node_Attribute(  -- Set the value of existing attribute
  11025.                                      Name      : Name_String; 
  11026.                                          -- pathname of desired node
  11027.                                      Attribute : Attribute_Name; 
  11028.                                          -- name of attribute to be set
  11029.                                      Value     : List_Type); 
  11030.                                          -- new value of attribute
  11031. ----------------------    Set_Path_Attribute   ----------------------
  11032. --  Purpose: This procedure creates an attribnute named by ATTRIBUTE of
  11033. --  -------  of a relationship and sets its initial value to VALUE.  The 
  11034. --         relationship is defined by the base node defined by the open
  11035. --         node handle BASE, the relation name RELATION, and the
  11036. --         relationship key KEY.
  11037. --
  11038. --  Parameters:
  11039. --  ----------
  11040. --    Base       is the open node handle of the base node
  11041. --    Key       is the relationship key of the affected relationship
  11042. --    Relation   is the relation name of the affected relationship
  11043. --    Attribute  is the name of the attribute added to this relationship
  11044. --    Value      is the initial value of the attribute
  11045. --
  11046. --  Exceptions:
  11047. --  ----------
  11048. --   NAME_ERROR        is raised if the relationship identified by BASE, KEY,
  11049. --            and RELATION does not exist
  11050. --
  11051. --   USE_ERROR          is raised if the relationship already has an attribute
  11052. --            of the given name or if the name given is syntactically
  11053. --                      illegal or is the name of a predefined node attribute
  11054. --            that cant be modified by the user. Use_Error is also
  11055. --            raised if RELATION is the name of a predefined relation
  11056. --            that can't be modified by the user.
  11057. --
  11058. --   STATUS-ERROR       is raised if the node handle BASE is not open
  11059. --   INTENT_VIOLATION   is raised if NODE was not opened with the right to
  11060. --            write relationships.
  11061. --   SECURITY_VIOLATION is raised if the operation represents a violation of
  11062. --            mandatory access controls.  Raised only if no other
  11063. --            exceptions apply.
  11064. --
  11065. --  Notes: MIL-STD CAIS 5.1.3.6
  11066. --  -----
  11067. --   Security_Violation is not implemented
  11068. ---------------------------------------------------------------------
  11069.         procedure Set_Path_Attribute(-- Set the value of an existing attribute
  11070.                                      Base      : in out Node_Type; 
  11071.                                         -- open node handle from which 
  11072.                                         -- the relationship emanates
  11073.                                      Key       : Relationship_Key; 
  11074.                                         -- key of affected relationship
  11075.                                      Relation  : Relation_Name := 
  11076.                                          Default_Relation; 
  11077.                                         -- name of affected relationship
  11078.                                      Attribute : Attribute_Name; 
  11079.                                         -- name of created attribute
  11080.                                      Value     : List_Type); 
  11081.                                         -- new value of attribute
  11082. -----------------------------------------------------------------------------
  11083. --             ALTERNATE INTERFACE via NAME_STRING for NODE                --
  11084. -----------------------------------------------------------------------------
  11085.         procedure Set_Path_Attribute(-- Set the value of an existing attribute
  11086.                                      Name      : Name_String; 
  11087.                                         -- pathname of desired node
  11088.                                      Attribute : Attribute_Name; 
  11089.                                         -- name of created attribute
  11090.                                      Value     : List_Type); 
  11091.                                         -- new value of attribute
  11092. ----------------------    Get_Node_Attribute   ----------------------
  11093. --
  11094. --  Purpose: This procedure deletes an attribute named by ATTRIBUTE of
  11095. --  -------  of the node identified by the open node handle NODE.
  11096. --
  11097. --  Parameters:
  11098. --  ----------
  11099. --    Node       is the open node handle being modified
  11100. --    Attribute  is the name of the attribute being added to this node
  11101. --
  11102. --  Exceptions:
  11103. --  ----------
  11104. --   USE_ERROR          is raised if the node does not have an attribute of the
  11105. --                given name (or if the name given is syntactically
  11106. --                      illegal??) or is the name of a predefined node attribute
  11107. --            which can't be modified by the user.
  11108. --
  11109. --   STATUS-ERROR       is raised if the node handle is not open
  11110. --
  11111. --   INTENT_VIOLATION   is raised if NODE was not opened with the right to
  11112. --            read attributes.
  11113. --
  11114. --   SECURITY_VIOLATION is raised if the operation represents a violation of
  11115. --            mandatory access controls.  Raised only if no other
  11116. --            exceptions apply.
  11117. --
  11118. --  Notes: MIL-STD CAIS 5.1.3.7
  11119. --  -----
  11120. --   Security_Violation is not implemented
  11121. ---------------------------------------------------------------------
  11122.     -- CAIS 5.1.3.7
  11123.         procedure Get_Node_Attribute( -- get the value of a node attribute
  11124.                                      Node      : Node_Type; 
  11125.                                          -- open node handle for desired node
  11126.                                      Attribute : Attribute_Name; 
  11127.                                          -- name of created attribute
  11128.                                      Value     : in out List_Type); 
  11129.                                          -- result parm containing the value
  11130. -----------------------------------------------------------------------------
  11131. --             ALTERNATE INTERFACE via NAME_STRING for NODE                --
  11132. -----------------------------------------------------------------------------
  11133.         procedure Get_Node_Attribute( -- get the value of a node attribute
  11134.                                      Name      : Name_String; 
  11135.                                          -- pathname of desired node
  11136.                                      Attribute : Attribute_Name; 
  11137.                                          -- name of created attribute
  11138.                                      Value     : in out List_Type); 
  11139.                                          -- result parm containing the value
  11140. ----------------------   Get_Path_Attribute    ----------------------
  11141. --  Purpose: This procedure creates an attribnute named by ATTRIBUTE of
  11142. --  -------  of a relationship and sets its initial value to VALUE.  The 
  11143. --         relationship is defined by the base node defined by the open
  11144. --         node handle BASE, the relation name RELATION, and the
  11145. --         relationship key KEY.
  11146. --
  11147. --  Parameters:
  11148. --  ----------
  11149. --    Base       is the open node handle of the base node
  11150. --    Key       is the relationship key of the affected relationship
  11151. --    Relation   is the relation name of the affected relationship
  11152. --    Attribute  is the name of the attribute added to this relationship
  11153. --    Value      is the initial value of the attribute
  11154. --
  11155. --  Exceptions:
  11156. --  ----------
  11157. --   NAME_ERROR        is raised if the relationship identified by BASE, KEY,
  11158. --            and RELATION does not exist
  11159. --
  11160. --   USE_ERROR          is raised if the relationship already has an attribute
  11161. --            of the given name or if the name given is syntactically
  11162. --                      illegal or is the name of a predefined node attribute
  11163. --            that cant be modified by the user. Use_Error is also
  11164. --            raised if RELATION is the name of a predefined relation
  11165. --            that can't be modified by the user.
  11166. --
  11167. --   STATUS-ERROR       is raised if the node handle BASE is not open
  11168. --   INTENT_VIOLATION   is raised if BASE was not opened with the right to
  11169. --            read relationships.
  11170. --   SECURITY_VIOLATION is raised if the operation represents a violation of
  11171. --            mandatory access controls.  Raised only if no other
  11172. --            exceptions apply.
  11173. --
  11174. --  Notes: MIL-STD CAIS 5.1.3.8
  11175. --  -----
  11176. --   Security_Violation is not implemented
  11177. ---------------------------------------------------------------------
  11178.         procedure Get_Path_Attribute(-- get the value of a path attribute
  11179.                                      Base      : Node_Type; 
  11180.                                         -- open node handle from which 
  11181.                                         -- the relationship emanates
  11182.                                      Key       : Relationship_Key; 
  11183.                                         -- key of affected relationship
  11184.                                      Relation  : Relation_Name := 
  11185.                                          Default_Relation; 
  11186.                                          -- name of affected relationship
  11187.                                      Attribute : Attribute_Name; 
  11188.                                          -- name of created attribute
  11189.                                      Value     : in out List_Type); 
  11190.                                          -- result parm containing the value
  11191. -----------------------------------------------------------------------------
  11192. --             ALTERNATE INTERFACE via NAME_STRING for NODE                --
  11193. -----------------------------------------------------------------------------
  11194.         procedure Get_Path_Attribute(-- get the value of a path attribute
  11195.                                      Name      : Name_String; 
  11196.                                          -- pathname of desired node
  11197.                                      Attribute : Attribute_Name; 
  11198.                                          -- name of created attribute
  11199.                                      Value     : in out List_Type); 
  11200.                                          -- result parm containing the value
  11201. -- CAIS 5.1.3.9 is a collection of type definitions; they are
  11202. -- at start of this package specification.
  11203.  
  11204.  
  11205. --------------------------NODE_ATTRIBUTE_ITERATE---------------------
  11206. --
  11207. --  Purpose:  Creates a set of attributes from the named node which
  11208. --  -------   match the provided pattern containing wild card characters
  11209. --            '*' to match any string and '?' to match any character.
  11210. --
  11211. --  Parameters:
  11212. --  ----------
  11213. --   Iterator is the set of matching attributes
  11214. --   Node     is the node whose attributes are searched for matches
  11215. --   Pattern  is the string (with * and ?) which determines matches
  11216. --
  11217. --  Exceptions:
  11218. --  ----------
  11219. --   Use_Error        is raised if the Pattern is syntactically illegal
  11220. --   
  11221. --   Status_Error     is raised if the node is not an open node handle
  11222. --
  11223. --   Intent_Violation is rasied if Node is not open with the right to
  11224. --              read attributes.
  11225. --
  11226. --  Notes: MIL-STD CAIS 5.1.3.10
  11227. --  -----
  11228. --
  11229. ---------------------------------------------------------------------
  11230.     -- CAIS 5.1.3.10
  11231.         procedure Node_Attribute_Iterate(-- get an attribute iterator
  11232.                                          Iterator : in out Attribute_Iterator; 
  11233.                                                -- see CAIS 1.4 5.1.3 for expl.)
  11234.                                          Node     : Node_Type; 
  11235.                                      -- open node handle for desired node
  11236.                                          Pattern  : Attribute_Pattern := "*"); 
  11237.                                                 -- pattern for attr. names
  11238. -----------------------------------------------------------------------------
  11239. --             ALTERNATE INTERFACE via NAME_STRING for NODE                --
  11240. -----------------------------------------------------------------------------
  11241.         procedure Node_Attribute_Iterate(-- get an attribute iterator
  11242.                                          Iterator : in out Attribute_Iterator; 
  11243.                                                -- see CAIS 1.4 5.1.3 for expl.)
  11244.                                          Name     : Name_String; 
  11245.                                                -- pathname of desired node
  11246.                                          Pattern  : Attribute_Pattern := "*"); 
  11247.                                                -- pattern for attr. names
  11248. ----------------------  Path_Attribute_Iterate  ----------------------
  11249. --
  11250. --  Purpose:  Creates a set of attributes from the named path which
  11251. --  -------   match the provided pattern containing wild card characters
  11252. --            '*' to match any string and '?' to match any character.
  11253. --
  11254. --  Parameters:
  11255. --  ----------
  11256. --   Iterator is the set of matching attributes
  11257. --   Base     is the open node handle from which the relationship emanates
  11258. --   Key      is the key of the affected relationship
  11259. --   Relation is the name of the affected relationship
  11260. --   Pattern  is the string (with * and ?) which determines matches
  11261. --
  11262. --  Exceptions:
  11263. --  ----------
  11264. --   Use_Error        is raised if the Pattern is syntactically illegal
  11265. --   
  11266. --   Status_Error     is raised if the node is not an open node handle
  11267. --
  11268. --   Intent_Violation is rasied if Node is not open with the right to
  11269. --              read relationships.
  11270. --
  11271. --  Notes: MIL-STD CAIS 5.1.3.11
  11272. --  -----
  11273. --
  11274. ---------------------------------------------------------------------
  11275.     -- CAIS 5.1.3.11
  11276.         procedure Path_Attribute_Iterate(
  11277.                                        -- get iterator over relationship attr.
  11278.                                          Iterator : in out Attribute_Iterator; 
  11279.                                               -- see CAIS 1.4 5.1.3 for expl.)
  11280.                                          Base     : Node_Type; 
  11281.                                         -- open node handle from which 
  11282.                                         -- the relationship emanates
  11283.                                          Key      : Relationship_Key; 
  11284.                                         -- key of the relationship
  11285.                                          Relation : Relation_Name := 
  11286.                                              Default_Relation; 
  11287.                                         -- name of the relationship
  11288.                                          Pattern  : Attribute_Pattern := "*"); 
  11289.                                                 -- pattern for attr. names
  11290. -----------------------------------------------------------------------------
  11291. --             ALTERNATE INTERFACE via NAME_STRING for NODE                --
  11292. -----------------------------------------------------------------------------
  11293.         procedure Path_Attribute_Iterate(
  11294.                                        -- get iterator over relationship attr.
  11295.                                          Iterator : in out Attribute_Iterator; 
  11296.                                                -- see CAIS 1.4 5.1.3 for expl.)
  11297.                                          Name     : Name_String; 
  11298.                                                -- pathname of desired node
  11299.                                          Pattern  : Attribute_Pattern := "*"); 
  11300.                                                -- pattern for attr. names
  11301.  
  11302. ----------------------          More           ----------------------
  11303. --
  11304. --  Purpose: The function More returns false if all attributes contained
  11305. --  -------  in the attribute iterator have been retrieved with the procedure
  11306. --         Get_Next; otherwise, it returns true.
  11307. --
  11308. --  Parameters:
  11309. --  ----------
  11310. --    Iterator is a previously constructed attribute iterator.
  11311. --
  11312. --  Exceptions:
  11313. --  ----------
  11314. --    Use_Error is raised if the iterator has not been previously set by the
  11315. --        procedure Node_Attribute_Iterate or Path_Attribute_Iterate.
  11316. --
  11317. --  Notes: MIL-STD CAIS 5.1.3.12
  11318. --  -----
  11319. --
  11320. ---------------------------------------------------------------------
  11321.     -- CAIS 5.1.3.12
  11322.         function More(
  11323.                     -- indicate if all attr. have been retrieved via Get_Next
  11324.                       Iterator : in Attribute_Iterator)
  11325.                                          -- previously constructed iterator
  11326.         return Boolean; 
  11327.  
  11328. ----------------------          Get_Next       ----------------------
  11329. --
  11330. --  Purpose: Returns, in the parameters Attribute and Value, both the name
  11331. --  -------  and the value of the next attribute in the iterator.
  11332. --
  11333. --  Parameters:
  11334. --  ----------
  11335. --    Iterator  is a previously constructed iterator.
  11336. --    Attribute contains the name of the retrieved attribute.
  11337. --    Value     contains the value of the attribute named by Attribute.
  11338. --
  11339. --  Exceptions:
  11340. --  ----------
  11341. --    Use_Error is raised if the Iterator has not been previously set by the
  11342. --        procedure Node_Attribute_Iterate or Path_Attribute_Iterate or if the
  11343. --        iterator is exhausted, i.e., More(Iterator) = false.
  11344. --
  11345. --  Notes: MIL-STD CAIS 5.1.3.13
  11346. --  -----
  11347. --
  11348. ------------------------------------------------------------------------------
  11349.     -- CAIS 5.1.3.13
  11350.         procedure Get_Next(
  11351.                           -- get name and value of next attribute  in iterator
  11352.                            Iterator  : in out Attribute_Iterator; 
  11353.                                                -- see CAIS 1.4 5.1.3 for expl.)
  11354.                            Attribute : in out Attribute_Name; 
  11355.                                                   -- name of next attribute 
  11356.                            Value     : in out List_Type); 
  11357.                                                -- value of next attribute
  11358.     private
  11359.  
  11360.         type Attribute_Iterator is 
  11361.             record
  11362.                 List     : Pseudo_List_Type; 
  11363.                                         --the set of attributes being iterated
  11364.                 Position : Count := 0;  --current attribute to be supplied
  11365.             end record; 
  11366.  
  11367. ---------------------------------------------------------------------------
  11368.     end Attributes; 
  11369.                 --END OF PACKAGE SPEC 
  11370. ---------------------------------------------------------------------------
  11371.  
  11372.     package Access_Control is 
  11373.         use Node_Definitions; 
  11374.  
  11375.         subtype Grant_Value is Cais.List_Utilities.List_Type; 
  11376.         procedure Set_Access_Control(Node      : Node_Type; 
  11377.                                      Role_Node : Node_Type; 
  11378.                                      Grant     : Grant_Value); 
  11379.         procedure Set_Access_Control(Name      : Name_String; 
  11380.                                      Role_Name : Name_String; 
  11381.                                      Grant     : Grant_Value); 
  11382.         function Is_Granted(Object_Node  : Node_Type; 
  11383.                             Access_Right : Name_String) return Boolean; 
  11384.         function Is_Granted(Object_Name  : Name_String; 
  11385.                             Access_Right : Name_String) return Boolean; 
  11386.         procedure Adopt(Role_Node : Node_Type; 
  11387.                         Role_Key  : Relationship_Key := Latest_Key); 
  11388.         procedure Unadopt(Role_Key : Relationship_Key); 
  11389.     end Access_Control; 
  11390.  
  11391. ----------------------------------------------------------------------
  11392. --                S T R U C T U R A L _ N O D E S
  11393. --
  11394. --  Purpose:
  11395. --  -------
  11396. --      Structural nodes are special nodes in the sense that they
  11397. --      do not have contents as the other nodes of the CAIS model do.
  11398. --      Their purpose is solely to be carriers of common information
  11399. --      about other nodes related to the structural node.  This package
  11400. --      defines the primitive operations for creating structural nodes.
  11401. --
  11402. --  Usage:
  11403. --  -----
  11404. --      Structural nodes are typically used to create conventional 
  11405. --      directories, configuration objects, etc.
  11406. --
  11407. --  Example:
  11408. --  -------
  11409. --      TBS
  11410. --
  11411. --  Notes:
  11412. --  -----
  11413. --      This package is defined in section 5.1.5 of the MIL-STD CAIS
  11414. --      specification, dated 31 January 1985.
  11415. --
  11416. --  Revision History:
  11417. --  ----------------
  11418. --      None.
  11419. --
  11420. -------------------------------------------------------------------
  11421.  
  11422.     package Structural_Nodes is 
  11423.  
  11424.         use List_Utilities; 
  11425.         use Node_Definitions; 
  11426.  
  11427. ----------------------  C R E A T E _ N O D E  ----------------------
  11428. --
  11429. --  Purpose:
  11430. --  -------
  11431. --    This procedure creates a structural node and installs the 
  11432. --    primary relationship to it.  The relation name and relationship
  11433. --    key of the primary relationship to the node and the base node
  11434. --    from which it emanates are given by the parameters Relation,
  11435. --    Key, and Base.  An open node handle to the newly created node
  11436. --    with WRITE intent is returned in Node.
  11437. --
  11438. --  Parameters:
  11439. --  ----------
  11440. --    Node        closed node handle to be opened to the new node
  11441. --    Base        open node handle to the node from which the primary
  11442. --            relationship to the new node is to emanate
  11443. --    Key         relationship key of the primary relation to be created
  11444. --    Relation    relation name of the primary relation to be created
  11445. --    Attributes  a named list whose elements are used to establish
  11446. --                initial values for attributes of the new node
  11447. --    Access_Control  initial access control information associated with
  11448. --                the new node
  11449. --    Level       classification level for the new node
  11450. --
  11451. --  Exceptions:
  11452. --  ----------
  11453. --    NAME_ERROR        - if a node exists for the node identification
  11454. --                        given, if the node identification is illegal,
  11455. --                        or if any node identifying a group specified
  11456. --                        in the given Access_Control parameter is 
  11457. --                        unobtainable or inaccessible.
  11458. --    USE_ERROR         - if Access_Control or Level parameters do not adhere
  11459. --                        to the required syntax or if the Attributes parameter
  11460. --                        contains references to predefined attributes which
  11461. --                        cannot be modified or created by the user.  
  11462. --                        USE_ERROR is also raised if Relation is the name
  11463. --                        of a predefined relation that cannot be modified
  11464. --                        or created by the user.
  11465. --    STATUS_ERROR      - if Base is not open or if Node is open
  11466. --    INTENT_VIOLATION  - if Base was not opened with an intent establishing
  11467. --                        the right to append relationships
  11468. --    SECURITY_VIOLATION  if the operation violates mandatory access
  11469. --                        controls; raised only if conditions for other
  11470. --                        exceptions are not met.
  11471. --
  11472. --  Notes:
  11473. --  -----
  11474. --    This procedure is defined in section 5.1.5.1 of MIL-STD-CAIS,
  11475. --    dated 31 January 1985.
  11476. --    The additional interfaces for Create_Node that are presented 
  11477. --    in that section are provided.
  11478. --    NOTE: The second additional interface described in the CAIS
  11479. --    spec appears to be erroneous; the body defined for it is NOT
  11480. --    a mapping to another Create_Node, but is a recursive call to
  11481. --    itself.  The signature for this interface is distinct because
  11482. --    lacks an in/out parameter of Node_Type.  The call to Create_Node
  11483. --    in this body uses a local variable as a "placeholder" for the
  11484. --    unused node handle.  However, it lacks a base node for the
  11485. --    call.  The body in this package reflects our belief that the
  11486. --    CAIS spec is not what was intended for this procedure.
  11487. --
  11488. ---------------------------------------------------------------------
  11489.  
  11490.         procedure Create_Node(Node           : in out Node_Type; 
  11491.                               Base           : in out Node_Type; 
  11492.                                             -- different from MIL-STD
  11493.                               Key            : Relationship_Key := Latest_Key; 
  11494.                               Relation       : Relation_Name := Default_Relation
  11495.                                   ; 
  11496.                               Attributes     : List_Type := Empty_List; 
  11497.                               Access_Control : List_Type := Empty_List; 
  11498.                               Level          : List_Type := Empty_List); 
  11499.  
  11500.  
  11501.     -- "Alternate Interface 1"
  11502.         procedure Create_Node(Node           : in out Node_Type; 
  11503.                               Name           : Node_Definitions.Name_String; 
  11504.                               Attributes     : List_Type := Empty_List; 
  11505.                               Access_Control : List_Type := Empty_List; 
  11506.                               Level          : List_Type := Empty_List); 
  11507.  
  11508.     -- "Alternate Interface 2"
  11509.         procedure Create_Node(Base           : in out Node_Type; 
  11510.         -- defined but not used in MIL-STD-CAIS
  11511.  
  11512.                               Key            : Relationship_Key := Latest_Key; 
  11513.                               Relation       : Relation_Name := Default_Relation
  11514.                                   ; 
  11515.                               Attributes     : List_Type := Empty_List; 
  11516.                               Access_Control : List_Type := Empty_List; 
  11517.                               Level          : List_Type := Empty_List); 
  11518.  
  11519.  
  11520.     -- "Alternate Interface 3"
  11521.         procedure Create_Node(Name           : Node_Definitions.Name_String; 
  11522.                               Attributes     : List_Type := Empty_List; 
  11523.                               Access_Control : List_Type := Empty_List; 
  11524.                               Level          : List_Type := Empty_List); 
  11525.  
  11526.  
  11527.     end Structural_Nodes; 
  11528.  
  11529. ----------------------------------------------------------------------
  11530. --               P R O C E S S _ D E F I N I T I O N S
  11531. --
  11532. --  Purpose:
  11533. --  -------
  11534. --    This package defines the types and exceptions associated with
  11535. --    CAIS process nodes.
  11536. --
  11537. --  Usage:
  11538. --  -----
  11539. --    Simply referenced by code requiring these types and exceptions.
  11540. --
  11541. --  Example:
  11542. --  -------
  11543. --    None.
  11544. --
  11545. --  Notes:
  11546. --  -----
  11547. --    CAIS MIL-STD 5.2.1 dated 31 January 1985
  11548. --
  11549. --  Revision History:
  11550. --  ----------------
  11551. --    None.
  11552. --
  11553. -------------------------------------------------------------------
  11554.  
  11555.     package Process_Definitions is 
  11556.  
  11557.         use Node_Definitions; 
  11558.         use List_Utilities; 
  11559.  
  11560.         type Process_Status is (Ready, Suspended, Aborted, Terminated); 
  11561.  
  11562.         subtype Results_List is List_Utilities.List_Type; 
  11563.         subtype Results_String is String; 
  11564.         subtype Parameter_List is List_Utilities.List_Type; 
  11565.  
  11566.         Root_Process   : constant Name_String := "'CURRENT_JOB"; 
  11567.         Current_Input  : constant Name_String := "'CURRENT_INPUT"; 
  11568.         Current_Output : constant Name_String := "'CURRENT_OUTPUT"; 
  11569.         Current_Error  : constant Name_String := "'CURRENT_ERROR"; 
  11570.  
  11571.     end Process_Definitions; 
  11572.  
  11573. ----------------------------------------------------------------------
  11574. --                    P R O C E S S _ C O N T R O L
  11575. --
  11576. --  Purpose:
  11577. --  -------
  11578. --    This package specifies interfaces for the creation and termination
  11579. --    of process and the examination and modification of process node
  11580. --    attributes.
  11581. --
  11582. --  Usage:
  11583. --  -----
  11584. --    See Section 5.2.2 of MIL-STD-CAIS
  11585. --
  11586. --  Example:
  11587. --  -------
  11588. --    See Section 5.2.2 of MIL-STD-CAIS
  11589. --
  11590. --  Notes:     MIL-STD-CAIS 5.2.2
  11591. --  -----
  11592. --    The subprograms in this package are currently stubbed, with the
  11593. --    exception of the procedure Invoke_Process.
  11594. --
  11595. --  Revision History:
  11596. --  ----------------
  11597. --
  11598. -------------------------------------------------------------------
  11599.  
  11600.  
  11601.     package Process_Control is 
  11602.  
  11603.         use Node_Definitions; 
  11604.         use List_Utilities; 
  11605.         use Process_Definitions; 
  11606.  
  11607.  
  11608.         procedure Spawn_Process(Node             : in out Node_Type; 
  11609.                                 File_Node        : Node_Type; 
  11610.                                 Input_Parameters : Parameter_List := Empty_List
  11611.                                     ; 
  11612.                                 Key              : Relationship_Key := 
  11613.                                     Latest_Key; 
  11614.                                 Relation         : Relation_Name := 
  11615.                                     Default_Relation; 
  11616.                                 Access_Control   : List_Type := Empty_List; 
  11617.                                 Level            : List_Type := Empty_List; 
  11618.                                 Attributes       : List_Type := Empty_List; 
  11619.                                 Input_File       : Name_String := Current_Input
  11620.                                     ; 
  11621.                                 Output_File      : Name_String := Current_Output
  11622.                                     ; 
  11623.                                 Error_File       : Name_String := Current_Error
  11624.                                     ; 
  11625.                                 Environment_Node : Name_String := Current_Node)
  11626.             ; 
  11627.  
  11628.         procedure Await_Process_Completion(Node       : Node_Type; 
  11629.                                            Time_Limit : Duration := Duration'
  11630.                                                Last); 
  11631.         procedure Await_Process_Completion(Node             : Node_Type; 
  11632.                                            Results_Returned : in out 
  11633.                                                Results_List; 
  11634.                                            Status           : in out 
  11635.                                                Process_Status; 
  11636.                                            Time_Limit       : Duration := 
  11637.                                                Duration'Last); 
  11638.  
  11639. ----------------- I N V O K E _ P R O C E S S  ----------------------
  11640. --
  11641. --  Purpose:
  11642. --  -------
  11643. --    This procedure creates a new process node whose contents represent
  11644. --    the execution of the program contained in the specified file node.
  11645. --    Control returns to the calling task after the new process is 
  11646. --    terminated.  
  11647. --
  11648. --  Parameters:
  11649. --  ----------
  11650. --    Node              - node handle returned open on the new process node
  11651. --    File_Node         - open node handle on the file node containing the
  11652. --                        executable image whose execution will be 
  11653. --                        represented by the new process
  11654. --    Results_Returned  - list of results which are represented by strings
  11655. --                        from the new process.  
  11656. --    Status            - the process status of the process.  
  11657. --    Input_Parameters  - a list containing process parameter information.
  11658. --    Key               - the relationship key of the primary relationship
  11659. --                        from the current process node to the new process
  11660. --                        node.
  11661. --    Relation          - the relation name of the primary relationship
  11662. --                        from the current process node to the new node.
  11663. --    Access_Control    - defines the initial access control information
  11664. --                        associated with the created node.
  11665. --    Level             - defines the classification label for the created
  11666. --                        node.
  11667. --    Attributes        - a list which can be used to set attributes of the
  11668. --                        new node.
  11669. --    Input_File        - pathname for standard input for the new process
  11670. --    Output_File       - pathname for standard output for the new process
  11671. --    Error_File        - pathname for error output for the new process
  11672. --    Environment_Node  - the node the new process will have as its current
  11673. --                        node
  11674. --    Time_Limit        - the limit on the time that the calling task will
  11675. --                        be suspended awaiting the new process.  When
  11676. --                        the limit is exceeded, the calling task resumes
  11677. --                        execution.
  11678.  
  11679. --
  11680. --  Exceptions:
  11681. --  ----------
  11682. --    Name_Error        - raised if a node alreadyt exists for the 
  11683. --                        relationship specified by Key and Relation.
  11684. --                        Name_Error is also raised if any of the nodes
  11685. --                        identified by Input_File, Output_File,
  11686. --                        Error_File, or Environment_Node do not exist.
  11687. --                        It is also raised if Key or Relation is 
  11688. --                        syntactically illegal or if any node identifying
  11689. --                        a group specified in the given  Access_Control
  11690. --                        parameter is unobtainable or inaccessible.
  11691. --    Use_Error         - is raised if it can be determined that the node
  11692. --                        indicated by File_Node does not contain an executable
  11693. --                        image.  Use_Error is also raised if any of the
  11694. --                        parameters Input_Paramters, Level, Access_Control,
  11695. --                        or Attributes is syntactically illegal.  Use_Error
  11696. --                        is also raised if Relation is the name of a 
  11697. --                        predefined relation or if the Attributes parameter
  11698. --                        contains references to a predefined attribute which
  11699. --                        cannot be modified or created by the user.
  11700. --    Status_Error      - is raised if Node is an open node handle prior to 
  11701. --                        the call or if File_Node is not an open node handle.
  11702. --    Lock_Error        - is raised if access with intent Append_Relationships
  11703. --                        cannot be obtained to the current process node due
  11704. --                        to an existing lock on the node.
  11705. --    Intent_Violation  - is raised if the node designated by File_Node was
  11706. --                        not opened with an intent establishing the right
  11707. --                        to execute contents.
  11708. --
  11709. --  Notes:   MIL-STD-CAIS 5.2.2.3
  11710. --  -----
  11711. --
  11712. ---------------------------------------------------------------------
  11713.  
  11714.         procedure Invoke_Process(Node             : in out Node_Type; 
  11715.                                  File_Node        : Node_Type; 
  11716.                                  Results_Returned : in out Results_List; 
  11717.                                  Status           : in out Process_Status; 
  11718.                                  Input_Parameters : Parameter_List; 
  11719.                                  Key              : Relationship_Key := 
  11720.                                      Latest_Key; 
  11721.                                  Relation         : Relation_Name := 
  11722.                                      Default_Relation; 
  11723.                                  Access_Control   : List_Type := Empty_List; 
  11724.                                  Level            : List_Type := Empty_List; 
  11725.                                  Attributes       : List_Type := Empty_List; 
  11726.                                  Input_File       : Name_String := Current_Input
  11727.                                      ; 
  11728.                                  Output_File      : Name_String := 
  11729.                                      Current_Output; 
  11730.                                  Error_File       : Name_String := Current_Error
  11731.                                      ; 
  11732.                                  Environment_Node : Name_String := Current_Node
  11733.                                      ; 
  11734.                                  Time_Limit       : Duration := Duration'Last); 
  11735.         procedure Create_Job(File_Node        : Node_Type; 
  11736.                              Input_Parameters : Parameter_List := Empty_List; 
  11737.                              Key              : Relationship_Key := Latest_Key; 
  11738.                              Access_Control   : List_Type := Empty_List; 
  11739.                              Level            : List_Type := Empty_List; 
  11740.                              Attributes       : List_Type := Empty_List; 
  11741.                              Input_File       : Name_String := Current_Input; 
  11742.                              Output_File      : Name_String := Current_Output; 
  11743.                              Error_File       : Name_String := Current_Error; 
  11744.                              Environment_Node : Name_String := Current_User); 
  11745.         procedure Append_Results(Results : Results_String); 
  11746.         procedure Write_Results(Results : Results_String); 
  11747.         procedure Get_Results(Node    : Node_Type; 
  11748.                               Results : in out Results_List); 
  11749.         procedure Get_Results(Node    : Node_Type; 
  11750.                               Results : in out Results_List; 
  11751.                               Status  : in out Process_Status); 
  11752.         procedure Get_Results(Name    : Name_String; 
  11753.                               Results : in out Results_List; 
  11754.                               Status  : in out Process_Status); 
  11755.         procedure Get_Results(Name    : Name_String; 
  11756.                               Results : in out Results_List); 
  11757.         procedure Get_Parameters(Parameters : in out Parameter_List); 
  11758.         procedure Abort_Process(Node    : Node_Type; 
  11759.                                 Results : Results_String); 
  11760.         procedure Abort_Process(Name    : Name_String; 
  11761.                                 Results : Results_String); 
  11762.         procedure Abort_Process(Node : Node_Type); 
  11763.         procedure Abort_Process(Name : Name_String); 
  11764.         procedure Suspend_Process(Node : Node_Type); 
  11765.         procedure Suspend_Process(Name : Name_String); 
  11766.         procedure Resume_Process(Node : Node_Type); 
  11767.         procedure Resume_Process(Name : Name_String); 
  11768.         function Status_Of_Process(Node : Node_Type) return Process_Status; 
  11769.         function Status_Of_Process(Name : Name_String) return Process_Status; 
  11770.         function Handles_Open(Node : Node_Type) return Natural; 
  11771.         function Handles_Open(Name : Name_String) return Natural; 
  11772.         function Io_Units(Node : Node_Type) return Natural; 
  11773.         function Io_Units(Name : Name_String) return Natural; 
  11774.         function Start_Time(Node : Node_Type) return Time; 
  11775.         function Start_Time(Name : Name_String) return Time; 
  11776.         function Finish_Time(Node : Node_Type) return Time; 
  11777.         function Finish_Time(Name : Name_String) return Time; 
  11778.         function Machine_Time(Node : Node_Type) return Duration; 
  11779.         function Machine_Time(Name : Name_String) return Duration; 
  11780.  
  11781.     end Process_Control; 
  11782.  
  11783. ----------------------------------------------------------------------
  11784. --                I O _ D E F I N I T I O N S
  11785. --
  11786. --  Purpose:
  11787. --  -------
  11788. --    This package defines the types and exceptions associated
  11789. --    with file nodes.
  11790. --
  11791. --  Usage:
  11792. --  -----
  11793. --    This package contains declarations of base types and exceptions 
  11794. --    for I/O.  The operations in the interface are internal 
  11795. --    suprograms for use in implementation of the I/O packages.
  11796. --
  11797. --  Notes:
  11798. --  -----
  11799. --      The     use     of     a     limited     private     type
  11800. --      (IO_Definitions.File_Type)  implies  the addition of
  11801. --      subprograms to manipulate  that  type  (e.g.  to  set  or
  11802. --      extract  the  contents of an object of that type).  These
  11803. --      are in this specification, although they are additions to
  11804. --      the  CAIS  specification  for  this  package.
  11805. --    
  11806. --      This is a version of the package IO_Definitions,
  11807. --      specified in MIL-STD-CAIS section 5.3.1
  11808. --      Those portions of this specification that are NOT in
  11809. --      MIL-STD-CAIS specification (i.e. added for this implementation)
  11810. --      are so indicated.
  11811. --
  11812. --  Revision History:
  11813. --  ----------------
  11814. --    None.
  11815. --
  11816. -------------------------------------------------------------------
  11817.  
  11818.     package Io_Definitions is 
  11819.  
  11820.         use Node_Definitions; 
  11821.                           -- Not in Cais spec
  11822.         use List_Utilities; 
  11823.                         -- Not in Cais spec
  11824.         use Pragmatics; 
  11825.                      -- Not in Cais spec
  11826.  
  11827.         type Character_Array is array(Character) of Boolean; 
  11828.  
  11829.         type File_Mode is (In_File, Inout_File, Out_File, Append_File); 
  11830.  
  11831.         type File_Type is limited private; 
  11832.  
  11833.  
  11834.         type Function_Key_Descriptor(Length : Positive) is private; 
  11835.         type Tab_Enumeration is (Horizontal, Vertical); 
  11836.         type Position_Type is 
  11837.             record
  11838.                 Row    : Natural; 
  11839.                 Column : Natural; 
  11840.             end record; 
  11841.  
  11842.         Status_Error : exception renames Io_Exceptions.Status_Error; 
  11843.         Mode_Error   : exception renames Io_Exceptions.Mode_Error; 
  11844.         Name_Error   : exception renames Io_Exceptions.Name_Error; 
  11845.         Use_Error    : exception renames Io_Exceptions.Use_Error; 
  11846.         Device_Error : exception renames Io_Exceptions.Device_Error; 
  11847.         End_Error    : exception renames Io_Exceptions.End_Error; 
  11848.         Data_Error   : exception renames Io_Exceptions.Data_Error; 
  11849.         Layout_Error : exception renames Io_Exceptions.Layout_Error; 
  11850.  
  11851.     -- The following is NOT part of the CAIS specification.
  11852.  
  11853.         type Text_File_Ptr is access Text_Io.File_Type; 
  11854.  
  11855.  
  11856. ----------------------- Initialize ----------------------------
  11857. --
  11858. --  Purpose:
  11859. --  -------
  11860. --    Internal function to allocate file handle.
  11861. --
  11862. --  Parameters:
  11863. --  ----------
  11864. --    FT    (access to) file handle record.
  11865. --
  11866. --  Exceptions:
  11867. --  ----------
  11868. --    None raised.
  11869. --
  11870. --  Notes:
  11871. --  -----
  11872. --    File_Recs are allocated from heap.
  11873. --
  11874. ---------------------------------------------------------------------
  11875.  
  11876.         procedure Initialize(Ft : in out File_Type); 
  11877.  
  11878. ----------------------- Deallocate ----------------------------
  11879. --
  11880. --  Purpose:
  11881. --  -------
  11882. --    Internal function to deallocate file handle.
  11883. --
  11884. --  Parameters:
  11885. --  ----------
  11886. --    FT    (access to) file handle record.
  11887. --
  11888. --  Exceptions:
  11889. --  ----------
  11890. --    None raised.
  11891. --
  11892. --  Notes:
  11893. --  -----
  11894. --    File_Recs are released to heap via unchecked deallocation.
  11895. --
  11896. ---------------------------------------------------------------------
  11897.  
  11898.         procedure Deallocate(Ft : in out File_Type); 
  11899.  
  11900. ----------------------- Un_Initialized ----------------------------
  11901. --
  11902. --  Purpose:
  11903. --  -------
  11904. --    Internal function to test whether file has been
  11905. --    initialized.  Returns True if not initialized,
  11906. --    otherwise returns False.
  11907. --
  11908. --  Parameters:
  11909. --  ----------
  11910. --    FT    (access to) file handle record.
  11911. --
  11912. --  Exceptions:
  11913. --  ----------
  11914. --    None raised.
  11915. --
  11916. --  Notes:
  11917. --  -----
  11918. --    Handle is checked for null reference.
  11919. --
  11920. ---------------------------------------------------------------------
  11921.  
  11922.         function Un_Initialized(Ft : File_Type) return Boolean; 
  11923.  
  11924. ----------------------- Assign ----------------------------
  11925. --
  11926. --  Purpose:
  11927. --  -------
  11928. --    Internal procedure to copy one file handle record to
  11929. --    another.
  11930. --
  11931. --  Parameters:
  11932. --  ----------
  11933. --    From    (access to) source file handle record.
  11934. --    To    (access to) target file handle record.
  11935. --
  11936. --  Exceptions:
  11937. --  ----------
  11938. --    None raised.
  11939. --
  11940. --  Notes:
  11941. --  -----
  11942. --    If the target file handle is uninitialized, Assign initializes
  11943. --    it before copying the components of the record.
  11944. --
  11945. ---------------------------------------------------------------------
  11946.  
  11947.         procedure Assign(From : File_Type; 
  11948.                          To   : in out File_Type); 
  11949. -----------------------  Get_File_Type ----------------------------
  11950. --
  11951. --  Purpose:
  11952. --  -------
  11953. --    Internal function to fetch (access to) the Ada file descriptor 
  11954. --    for the contents file from the CAIS file handle.
  11955. --
  11956. --  Parameters:
  11957. --  ----------
  11958. --    FT    initialized file handle.
  11959. --
  11960. --  Exceptions:
  11961. --  ----------
  11962. --    Status_Error
  11963. --        raised if file handle has not been initialized.
  11964. --
  11965. --  Notes:
  11966. --  -----
  11967. --    The file descriptor is implemented as an Ada Text_Io.File_Type.
  11968. --    The access value returned is of type Text_File_Ptr.
  11969. --
  11970. ---------------------------------------------------------------------
  11971.  
  11972.         function Get_File_Type(Ft : File_Type) return Text_File_Ptr; 
  11973.  
  11974. -----------------------  Set_File_Type ----------------------------
  11975. --
  11976. --  Purpose:
  11977. --  -------
  11978. --    Internal procedure to store (access to) an Ada file descriptor 
  11979. --    for the contents file into the CAIS file handle.
  11980. --
  11981. --  Parameters:
  11982. --  ----------
  11983. --    FT    initialized file handle.
  11984. --    TFD    access to the Text_Io file descriptor.
  11985. --
  11986. --  Exceptions:
  11987. --  ----------
  11988. --    Status_Error
  11989. --        raised if file handle has not been initialized.
  11990. --
  11991. --  Notes:
  11992. --  -----
  11993. --    The file descriptor is implemented as an Ada Text_Io.File_Type.
  11994. --    The access parameter is of type Text_File_Ptr.
  11995. --
  11996. ---------------------------------------------------------------------
  11997.  
  11998.         procedure Set_File_Type(Ft  : in out File_Type; 
  11999.                                 Tfd : Text_File_Ptr); 
  12000.  
  12001. -----------------------  Get_Shadow_File_Name ----------------------------
  12002. --
  12003. --  Purpose:
  12004. --  -------
  12005. --    Internal procedure to fetch the name of the shadow file
  12006. --    from the CAIS file handle.
  12007. --    The file name and its length are returned in parameters
  12008. --    Name and Lastchar, respectively.
  12009. --
  12010. --  Parameters:
  12011. --  ----------
  12012. --    FT      initialized file handle.
  12013. --    Name      name string.
  12014. --    Lastchar  index of last non-blank character in Name.
  12015. --    
  12016. --
  12017. --  Exceptions:
  12018. --  ----------
  12019. --    None raised.
  12020. --
  12021. --  Notes:
  12022. --  -----
  12023. --    The shadow file contains the node image for the
  12024. --    CAIS file node, and its attributes and relationships.
  12025. --
  12026. ---------------------------------------------------------------------
  12027.  
  12028.         procedure Get_Shadow_File_Name(Ft       : File_Type; 
  12029.                                        Name     : in out String; 
  12030.                                        Lastchar : in out Natural); 
  12031.  
  12032. -----------------------  Set_Shadow_File_Name ----------------------------
  12033. --
  12034. --  Purpose:
  12035. --  -------
  12036. --    Internal procedure to store the name of the shadow file
  12037. --    into the CAIS file handle.
  12038. --
  12039. --  Parameters:
  12040. --  ----------
  12041. --    FT      initialized file handle.
  12042. --    Name      name string.
  12043. --    
  12044. --
  12045. --  Exceptions:
  12046. --  ----------
  12047. --    None raised.
  12048. --
  12049. --  Notes:
  12050. --  -----
  12051. --    The shadow file contains the node image for the
  12052. --    CAIS file node, and its attributes and relationships.
  12053. --
  12054. ---------------------------------------------------------------------
  12055.  
  12056.         procedure Set_Shadow_File_Name(Ft   : in out File_Type; 
  12057.                                        Name : String); 
  12058.  
  12059. -----------------------  Get_Contents_File_Name ----------------------------
  12060. --
  12061. --  Purpose:
  12062. --  -------
  12063. --    Internal procedure to fetch the name of the contents file
  12064. --    from the CAIS file handle.
  12065. --    The file name and its length are returned in parameters
  12066. --    Name and Lastchar, respectively.
  12067. --
  12068. --  Parameters:
  12069. --  ----------
  12070. --    FT      initialized file handle.
  12071. --    Name      name string.
  12072. --    Lastchar  index of last non-blank character in Name.
  12073. --    
  12074. --
  12075. --  Exceptions:
  12076. --  ----------
  12077. --    None raised.
  12078. --
  12079. --  Notes:
  12080. --  -----
  12081. --    The contents file holds the actual file contents for the
  12082. --    CAIS file node.
  12083. --
  12084. ---------------------------------------------------------------------
  12085.  
  12086.         procedure Get_Contents_File_Name(Ft       : File_Type; 
  12087.                                          Name     : in out String; 
  12088.                                          Lastchar : in out Natural); 
  12089.  
  12090. -----------------------  Set_Contents_File_Name ----------------------------
  12091. --
  12092. --  Purpose:
  12093. --  -------
  12094. --    Internal procedure to store the name of the contents file
  12095. --    into the CAIS file handle.
  12096. --
  12097. --  Parameters:
  12098. --  ----------
  12099. --    FT      initialized file handle.
  12100. --    Name      name string.
  12101. --    
  12102. --
  12103. --  Exceptions:
  12104. --  ----------
  12105. --    None raised.
  12106. --
  12107. --  Notes:
  12108. --  -----
  12109. --    The contents file holds the actual file contents for the
  12110. --    CAIS file node.
  12111. --
  12112. ---------------------------------------------------------------------
  12113.  
  12114.         procedure Set_Contents_File_Name(Ft   : in out File_Type; 
  12115.                                          Name : String); 
  12116.  
  12117. -----------------------  Get_Intent ----------------------------
  12118. --
  12119. --  Purpose:
  12120. --  -------
  12121. --    Internal procedure to fetch the intention of the node handle,
  12122. --    from the CAIS file handle.
  12123. --
  12124. --  Parameters:
  12125. --  ----------
  12126. --    FT      initialized file handle.
  12127. --    Intent      intention array.
  12128. --    
  12129. --
  12130. --  Exceptions:
  12131. --  ----------
  12132. --    None raised.
  12133. --
  12134. --  Notes:
  12135. --  -----
  12136. --    The intention returned is the intention with which the node
  12137. --    handle was opened to the file node.  When the file handle is
  12138. --    opened via the node handle, the intention is copied to the 
  12139. --    file handle.
  12140. --
  12141. ---------------------------------------------------------------------
  12142.  
  12143.         procedure Get_Intent(Ft     : File_Type; 
  12144.                              Intent : in out Intention); 
  12145.  
  12146. -----------------------  Set_Intent ----------------------------
  12147. --
  12148. --  Purpose:
  12149. --  -------
  12150. --    Internal procedure to store the intention of the node handle,
  12151. --    into the CAIS file handle.
  12152. --
  12153. --  Parameters:
  12154. --  ----------
  12155. --    FT      initialized file handle.
  12156. --    Intent      intention array.
  12157. --    
  12158. --
  12159. --  Exceptions:
  12160. --  ----------
  12161. --    None raised.
  12162. --
  12163. --  Notes:
  12164. --  -----
  12165. --    The intention to be stored is the intention with which the node
  12166. --    handle was opened to the file node.  When the file handle is
  12167. --    opened via the node handle, the intention is copied to the 
  12168. --    file handle.
  12169. --
  12170. ---------------------------------------------------------------------
  12171.  
  12172.         procedure Set_Intent(Ft     : in out File_Type; 
  12173.                              Intent : Intention); 
  12174.  
  12175. -----------------------  Get_Mode ----------------------------
  12176. --
  12177. --  Purpose:
  12178. --  -------
  12179. --    Internal procedure to fetch the file mode
  12180. --    from the CAIS file handle.
  12181. --
  12182. --  Parameters:
  12183. --  ----------
  12184. --    FT      initialized file handle.
  12185. --    Mode      file mode.
  12186. --    
  12187. --
  12188. --  Exceptions:
  12189. --  ----------
  12190. --    None raised.
  12191. --
  12192. --  Notes:
  12193. --  -----
  12194. --    The mode returned is the mode with which the file handle
  12195. --    was opened.
  12196. --
  12197. ---------------------------------------------------------------------
  12198.  
  12199.         procedure Get_Mode(Ft   : File_Type; 
  12200.                            Mode : in out File_Mode); 
  12201.  
  12202. -----------------------  Set_Mode ----------------------------
  12203. --
  12204. --  Purpose:
  12205. --  -------
  12206. --    Internal procedure to store the file mode
  12207. --    into the CAIS file handle.
  12208. --
  12209. --  Parameters:
  12210. --  ----------
  12211. --    FT      initialized file handle.
  12212. --    Mode      file mode.
  12213. --    
  12214. --
  12215. --  Exceptions:
  12216. --  ----------
  12217. --    None raised.
  12218. --
  12219. --  Notes:
  12220. --  -----
  12221. --    The mode to be stored is the mode with which the file handle
  12222. --    is being opened (or reset).
  12223. --
  12224. ---------------------------------------------------------------------
  12225.  
  12226.         procedure Set_Mode(Ft   : in out File_Type; 
  12227.                            Mode : File_Mode); 
  12228.  
  12229. -----------------------  Get_Name ----------------------------
  12230. --
  12231. --  Purpose:
  12232. --  -------
  12233. --    Internal procedure to fetch the pathname of the file node 
  12234. --    from the CAIS file handle.
  12235. --
  12236. --  Parameters:
  12237. --  ----------
  12238. --    FT      initialized file handle.
  12239. --    Name      name string.
  12240. --    Lastchar  index of last non-blank character in Name.
  12241. --    
  12242. --
  12243. --  Exceptions:
  12244. --  ----------
  12245. --    None raised.
  12246. --
  12247. --  Notes:
  12248. --  -----
  12249. --    The pathname returned is the pathname from the node handle
  12250. --    through which the file handle was opened.
  12251. --
  12252. ---------------------------------------------------------------------
  12253.  
  12254.         procedure Get_Name(Ft       : File_Type; 
  12255.                            Name     : in out String; 
  12256.                            Lastchar : in out Natural); 
  12257.  
  12258. -----------------------  Set_Name ----------------------------
  12259. --
  12260. --  Purpose:
  12261. --  -------
  12262. --    Internal procedure to store the pathname of the file node 
  12263. --    into the CAIS file handle.
  12264. --
  12265. --  Parameters:
  12266. --  ----------
  12267. --    FT      initialized file handle.
  12268. --    Name      name string.
  12269. --    
  12270. --
  12271. --  Exceptions:
  12272. --  ----------
  12273. --    None raised.
  12274. --
  12275. --  Notes:
  12276. --  -----
  12277. --    The pathname to be stored is the pathname from the node handle
  12278. --    through which the file handle is being opened.
  12279. --
  12280. ---------------------------------------------------------------------
  12281.  
  12282.         procedure Set_Name(Ft   : in out File_Type; 
  12283.                            Name : String); 
  12284.  
  12285. -----------------------  Get_Form ----------------------------
  12286. --
  12287. --  Purpose:
  12288. --  -------
  12289. --    Internal function which returns the form list of the file node 
  12290. --    from the CAIS file handle.
  12291. --
  12292. --  Parameters:
  12293. --  ----------
  12294. --    FT      initialized file handle.
  12295. --    
  12296. --
  12297. --  Exceptions:
  12298. --  ----------
  12299. --    None raised.
  12300. --
  12301. --  Notes:
  12302. --  -----
  12303. --    Conversion between form strings for external files and the
  12304. --    CAIS form is not implemented in the prototype.
  12305. --
  12306. ---------------------------------------------------------------------
  12307.  
  12308.         function Get_Form(Ft : File_Type) return List_Type; 
  12309.  
  12310. -----------------------  Set_Form ----------------------------
  12311. --
  12312. --  Purpose:
  12313. --  -------
  12314. --    Internal procedure which stores the form list of the file node 
  12315. --    into the CAIS file handle.
  12316. --
  12317. --  Parameters:
  12318. --  ----------
  12319. --    FT      initialized file handle.
  12320. --    Form      list of form entries.
  12321. --    
  12322. --
  12323. --  Exceptions:
  12324. --  ----------
  12325. --    None raised.
  12326. --
  12327. --  Notes:
  12328. --  -----
  12329. --    Conversion between form strings for external files and the
  12330. --    CAIS form is not implemented in the prototype.
  12331. --
  12332. ---------------------------------------------------------------------
  12333.  
  12334.         procedure Set_Form(Ft   : in out File_Type; 
  12335.                            Form : List_Type); 
  12336.     private
  12337.  
  12338.         type Function_Key_Descriptor(Length : Positive) is 
  12339.             record
  12340.                 Not_Implemented : Boolean := True; 
  12341.             end record; 
  12342.  
  12343.         type File_Rec is 
  12344.             record
  12345.                 Fd                 : Text_File_Ptr := new Standard.Text_Io.
  12346.                     File_Type; 
  12347.                 Shadow_File_Name   : String(1 .. Max_Shadow_File_Length); 
  12348.                 Contents_File_Name : String(1 .. Max_Contents_File_Length); 
  12349.                 Intent             : Intention(Pragmatics.Intent_Count); 
  12350.                 Intent_Size        : Pragmatics.Intent_Count; 
  12351.                 Mode               : File_Mode; 
  12352.                 Name               : String(1 .. Max_Name_String); 
  12353.                 Form               : List_Type; 
  12354.             end record; 
  12355.  
  12356.         type File_Type is access File_Rec; 
  12357.  
  12358. -----------------------------------------------------------------------------
  12359.     end Io_Definitions; 
  12360. -----------------------------------------------------------------------------
  12361.  
  12362.     package Io_Control is 
  12363.         use Io_Definitions; 
  12364.         use Node_Definitions; 
  12365.         use List_Utilities; 
  12366.  
  12367.         procedure Open_File_Node(File       : File_Type; 
  12368.                                  Node       : in out Node_Type; 
  12369.                                  Intent     : Intention; 
  12370.                                  Time_Limit : Duration := No_Delay); 
  12371.         procedure Synchronize(File : File_Type); 
  12372.         procedure Set_Log(File     : File_Type; 
  12373.                           Log_File : File_Type); 
  12374.         procedure Clear_Log(File : File_Type); 
  12375.         function Logging(File : File_Type) return Boolean; 
  12376.         function Get_Log(File : File_Type) return File_Type; 
  12377.         function Number_Of_Elements(File : File_Type) return Natural; 
  12378.         procedure Set_Prompt(Terminal : File_Type; 
  12379.                              Prompt   : String); 
  12380.         function Get_Prompt(Terminal : File_Type) return String; 
  12381.         function Intercepted_Characters(Terminal : File_Type) return
  12382.             Character_Array; 
  12383.         procedure Enable_Function_Keys(Terminal : File_Type; 
  12384.                                        Enable   : Boolean); 
  12385.         function Function_Keys_Enabled(Terminal : File_Type) return Boolean; 
  12386.         procedure Couple(Queue_Base     : Node_Type; 
  12387.                          Queue_Key      : Relationship_Key := Latest_Key; 
  12388.                          Queue_Relation : Relation_Name := Default_Relation; 
  12389.                          File_Node      : Node_Type; 
  12390.                          Form           : List_Type := Empty_List; 
  12391.                          Attributes     : List_Type; 
  12392.                                             -- intentionally no default
  12393.                          Access_Control : List_Type := Empty_List; 
  12394.                          Level          : List_Type := Empty_List); 
  12395.         procedure Couple(Queue_Name     : Name_String; 
  12396.                          File_Node      : Node_Type; 
  12397.                          Form           : List_Type := Empty_List; 
  12398.                          Attributes     : List_Type; 
  12399.                          Access_Control : List_Type := Empty_List; 
  12400.                          Level          : List_Type := Empty_List); 
  12401.         procedure Couple(Queue_Base     : Node_Type; 
  12402.                          Queue_Key      : Relationship_Key := Latest_Key; 
  12403.                          Queue_Relation : Relation_Name := Default_Relation; 
  12404.                          File_Name      : Name_String; 
  12405.                          Form           : List_Type := Empty_List; 
  12406.                          Attributes     : List_Type; 
  12407.                          Access_Control : List_Type := Empty_List; 
  12408.                          Level          : List_Type := Empty_List); 
  12409.         procedure Couple(Queue_Name     : Name_String; 
  12410.                          File_Name      : Name_String; 
  12411.                          Form           : List_Type := Empty_List; 
  12412.                          Attributes     : List_Type; 
  12413.                          Access_Control : List_Type := Empty_List; 
  12414.                          Level          : List_Type := Empty_List); 
  12415.  
  12416.  
  12417.     end Io_Control; 
  12418.  
  12419. ----------------------------------------------------------------------
  12420. --              D I R E C T _ I O _ D E F I N I T I O N S
  12421. --
  12422. --  Purpose:
  12423. --  -------
  12424. --      This package defines the types and exceptions associated with 
  12425. --      Direct_Io file handles.
  12426. --
  12427. --  Usage:
  12428. --  -----
  12429. --    Package Cais.Direct_Io instantiates this package to produce
  12430. --    a new package Dir_Io_Definitions nested in the Cais.Direct_Io 
  12431. --    specification.  For direct use of the base types and exceptions 
  12432. --    used by Cais.Direct_Io, the user can refer to the instantiated 
  12433. --    package.
  12434. --
  12435. --  Notes:
  12436. --  -----
  12437. --    This package  is added to the CAIS implementation
  12438. --    to provide distinct File_Types for each CAIS.Direct_Io
  12439. --    instantiation.  This is an alternative to the present 
  12440. --    CAIS file handle usage, which differs substantially from 
  12441. --    standard Ada Input/Output.
  12442. --    Ada generic I/O packages permit an unbounded number of 
  12443. --    file types to be constructed.  The CAIS requires a single
  12444. --    file type to hide all file types, for use by  text and generic
  12445. --    instantiations of direct and sequential IO packages.
  12446. --    This implementation follows Ada.
  12447. --
  12448. --      The     use     of     a     limited     private     type
  12449. --      (Direct_Io_Definitions.File_Type)  implies  the addition of
  12450. --      subprograms to manipulate  that  type  (e.g.  to  set  or
  12451. --      extract  the  contents of an object of that type).  These
  12452. --      are in this specification, although they are additions to
  12453. --      the  CAIS  specification  for  this  package.  
  12454. --    
  12455. --      This is a version of the package Cais.IO_Definitions,
  12456. --      specified in MIL-STD-CAIS section 5.3.1
  12457. --
  12458. --  Revision History:
  12459. --  ----------------
  12460. --    None.
  12461. --
  12462. -------------------------------------------------------------------
  12463.  
  12464.     generic
  12465.         type Element_Type is private; 
  12466.     package Direct_Io_Definitions is 
  12467.  
  12468.         use Node_Definitions; 
  12469.                           -- Not in Cais spec
  12470.         use Pragmatics; 
  12471.                      -- Not in Cais spec
  12472.         use Io_Exceptions; 
  12473.         use List_Utilities; 
  12474.                         -- Not in Cais spec
  12475.  
  12476.  
  12477.         type File_Mode is (In_File, Inout_File, Out_File); 
  12478.  
  12479.         type File_Type is limited private; 
  12480.  
  12481.  
  12482.         Status_Error : exception renames Io_Exceptions.Status_Error; 
  12483.         Mode_Error   : exception renames Io_Exceptions.Mode_Error; 
  12484.         Name_Error   : exception renames Io_Exceptions.Name_Error; 
  12485.         Use_Error    : exception renames Io_Exceptions.Use_Error; 
  12486.         Device_Error : exception renames Io_Exceptions.Device_Error; 
  12487.         End_Error    : exception renames Io_Exceptions.End_Error; 
  12488.         Data_Error   : exception renames Io_Exceptions.Data_Error; 
  12489.         Layout_Error : exception renames Io_Exceptions.Layout_Error; 
  12490.  
  12491.     -- The following is NOT part of the CAIS specification.
  12492.  
  12493.  
  12494.         type Direct_File_Ptr is private; 
  12495.  
  12496. ----------------------- Initialize ----------------------------
  12497. --
  12498. --  Purpose:
  12499. --  -------
  12500. --    Internal function to allocate file handle.
  12501. --
  12502. --  Parameters:
  12503. --  ----------
  12504. --    FT    (access to) file handle record.
  12505. --
  12506. --  Exceptions:
  12507. --  ----------
  12508. --    None raised.
  12509. --
  12510. --  Notes:
  12511. --  -----
  12512. --    File_Recs are allocated from heap.
  12513. --
  12514. ---------------------------------------------------------------------
  12515.  
  12516.         procedure Initialize(Ft : in out File_Type); 
  12517.  
  12518. ----------------------- Deallocate ----------------------------
  12519. --
  12520. --  Purpose:
  12521. --  -------
  12522. --    Internal function to deallocate file handle.
  12523. --
  12524. --  Parameters:
  12525. --  ----------
  12526. --    FT    (access to) file handle record.
  12527. --
  12528. --  Exceptions:
  12529. --  ----------
  12530. --    None raised.
  12531. --
  12532. --  Notes:
  12533. --  -----
  12534. --    File_Recs are released to heap via unchecked deallocation.
  12535. --
  12536. ---------------------------------------------------------------------
  12537.  
  12538.         procedure Deallocate(Ft : in out File_Type); 
  12539.  
  12540. ----------------------- Un_Initialized ----------------------------
  12541. --
  12542. --  Purpose:
  12543. --  -------
  12544. --    Internal function to test whether file has been
  12545. --    initialized.  Returns True if not initialized,
  12546. --    otherwise returns False.
  12547. --
  12548. --  Parameters:
  12549. --  ----------
  12550. --    FT    (access to) file handle record.
  12551. --
  12552. --  Exceptions:
  12553. --  ----------
  12554. --    None raised.
  12555. --
  12556. --  Notes:
  12557. --  -----
  12558. --    Handle is checked for null reference.
  12559. --
  12560. ---------------------------------------------------------------------
  12561.  
  12562.         function Un_Initialized(Ft : File_Type) return Boolean; 
  12563.  
  12564. ----------------------- Assign ----------------------------
  12565. --
  12566. --  Purpose:
  12567. --  -------
  12568. --    Internal procedure to copy one file handle record to
  12569. --    another.
  12570. --
  12571. --  Parameters:
  12572. --  ----------
  12573. --    From    (access to) source file handle record.
  12574. --    To    (access to) target file handle record.
  12575. --
  12576. --  Exceptions:
  12577. --  ----------
  12578. --    None raised.
  12579. --
  12580. --  Notes:
  12581. --  -----
  12582. --    If the target file handle is uninitialized, Assign initializes
  12583. --    it before copying the components of the record.
  12584. --
  12585. ---------------------------------------------------------------------
  12586.  
  12587.         procedure Assign(From : File_Type; 
  12588.                          To   : in out File_Type); 
  12589. -----------------------  Get_File_Type ----------------------------
  12590. --
  12591. --  Purpose:
  12592. --  -------
  12593. --    Internal function to fetch (access to) the Ada file descriptor 
  12594. --    for the contents file from the CAIS file handle.
  12595. --
  12596. --  Parameters:
  12597. --  ----------
  12598. --    FT    initialized file handle.
  12599. --
  12600. --  Exceptions:
  12601. --  ----------
  12602. --    Status_Error
  12603. --        raised if file handle has not been initialized.
  12604. --
  12605. --  Notes:
  12606. --  -----
  12607. --    The file descriptor is implemented as an Ada Direct_Io.File_Type,
  12608. --    The access value returned is of type Direct_File_Ptr.
  12609. --
  12610. ---------------------------------------------------------------------
  12611.  
  12612.         function Get_File_Type(Ft : File_Type) return Direct_File_Ptr; 
  12613.  
  12614. -----------------------  Set_File_Type ----------------------------
  12615. --
  12616. --  Purpose:
  12617. --  -------
  12618. --    Internal procedure to store (access to) an Ada file descriptor 
  12619. --    for the contents file into the CAIS file handle.
  12620. --
  12621. --  Parameters:
  12622. --  ----------
  12623. --    FT    initialized file handle.
  12624. --    DFD    access to the Direct_Io file descriptor.
  12625. --
  12626. --  Exceptions:
  12627. --  ----------
  12628. --    Status_Error
  12629. --        raised if file handle has not been initialized.
  12630. --
  12631. --  Notes:
  12632. --  -----
  12633. --    The file descriptor is implemented as an Ada Direct_Io.File_Type.
  12634. --    The access parameter is of type Direct_File_Ptr.
  12635. --
  12636. ---------------------------------------------------------------------
  12637.  
  12638.         procedure Set_File_Type(Ft  : in out File_Type; 
  12639.                                 Dfd : Direct_File_Ptr); 
  12640.  
  12641. -----------------------  Get_Shadow_File_Name ----------------------------
  12642. --
  12643. --  Purpose:
  12644. --  -------
  12645. --    Internal procedure to fetch the name of the shadow file
  12646. --    from the CAIS file handle.
  12647. --    The file name and its length are returned in parameters
  12648. --    Name and Lastchar, respectively.
  12649. --
  12650. --  Parameters:
  12651. --  ----------
  12652. --    FT      initialized file handle.
  12653. --    Name      name string.
  12654. --    Lastchar  index of last non-blank character in Name.
  12655. --    
  12656. --
  12657. --  Exceptions:
  12658. --  ----------
  12659. --    None raised.
  12660. --
  12661. --  Notes:
  12662. --  -----
  12663. --    The shadow file contains the node image for the
  12664. --    CAIS file node, and its attributes and relationships.
  12665. --
  12666. ---------------------------------------------------------------------
  12667.  
  12668.         procedure Get_Shadow_File_Name(Ft       : File_Type; 
  12669.                                        Name     : in out String; 
  12670.                                        Lastchar : in out Natural); 
  12671.  
  12672. -----------------------  Set_Shadow_File_Name ----------------------------
  12673. --
  12674. --  Purpose:
  12675. --  -------
  12676. --    Internal procedure to store the name of the shadow file
  12677. --    into the CAIS file handle.
  12678. --
  12679. --  Parameters:
  12680. --  ----------
  12681. --    FT      initialized file handle.
  12682. --    Name      name string.
  12683. --    
  12684. --
  12685. --  Exceptions:
  12686. --  ----------
  12687. --    None raised.
  12688. --
  12689. --  Notes:
  12690. --  -----
  12691. --    The shadow file contains the node image for the
  12692. --    CAIS file node, and its attributes and relationships.
  12693. --
  12694. ---------------------------------------------------------------------
  12695.  
  12696.         procedure Set_Shadow_File_Name(Ft   : in out File_Type; 
  12697.                                        Name : String); 
  12698.  
  12699. -----------------------  Get_Contents_File_Name ----------------------------
  12700. --
  12701. --  Purpose:
  12702. --  -------
  12703. --    Internal procedure to fetch the name of the contents file
  12704. --    from the CAIS file handle.
  12705. --    The file name and its length are returned in parameters
  12706. --    Name and Lastchar, respectively.
  12707. --
  12708. --  Parameters:
  12709. --  ----------
  12710. --    FT      initialized file handle.
  12711. --    Name      name string.
  12712. --    Lastchar  index of last non-blank character in Name.
  12713. --    
  12714. --
  12715. --  Exceptions:
  12716. --  ----------
  12717. --    None raised.
  12718. --
  12719. --  Notes:
  12720. --  -----
  12721. --    The contents file holds the actual file contents for the
  12722. --    CAIS file node.
  12723. --
  12724. ---------------------------------------------------------------------
  12725.  
  12726.         procedure Get_Contents_File_Name(Ft       : File_Type; 
  12727.                                          Name     : in out String; 
  12728.                                          Lastchar : in out Natural); 
  12729.  
  12730. -----------------------  Set_Contents_File_Name ----------------------------
  12731. --
  12732. --  Purpose:
  12733. --  -------
  12734. --    Internal procedure to store the name of the contents file
  12735. --    into the CAIS file handle.
  12736. --
  12737. --  Parameters:
  12738. --  ----------
  12739. --    FT      initialized file handle.
  12740. --    Name      name string.
  12741. --    
  12742. --
  12743. --  Exceptions:
  12744. --  ----------
  12745. --    None raised.
  12746. --
  12747. --  Notes:
  12748. --  -----
  12749. --    The contents file holds the actual file contents for the
  12750. --    CAIS file node.
  12751. --
  12752. ---------------------------------------------------------------------
  12753.  
  12754.         procedure Set_Contents_File_Name(Ft   : in out File_Type; 
  12755.                                          Name : String); 
  12756.  
  12757. -----------------------  Get_Intent ----------------------------
  12758. --
  12759. --  Purpose:
  12760. --  -------
  12761. --    Internal procedure to fetch the intention of the node handle,
  12762. --    from the CAIS file handle.
  12763. --
  12764. --  Parameters:
  12765. --  ----------
  12766. --    FT      initialized file handle.
  12767. --    Intent      intention array.
  12768. --    
  12769. --
  12770. --  Exceptions:
  12771. --  ----------
  12772. --    None raised.
  12773. --
  12774. --  Notes:
  12775. --  -----
  12776. --    The intention returned is the intention with which the node
  12777. --    handle was opened to the file node.  When the file handle is
  12778. --    opened via the node handle, the intention is copied to the 
  12779. --    file handle.
  12780. --
  12781. ---------------------------------------------------------------------
  12782.  
  12783.         procedure Get_Intent(Ft     : File_Type; 
  12784.                              Intent : in out Intention); 
  12785.  
  12786. -----------------------  Set_Intent ----------------------------
  12787. --
  12788. --  Purpose:
  12789. --  -------
  12790. --    Internal procedure to store the intention of the node handle,
  12791. --    into the CAIS file handle.
  12792. --
  12793. --  Parameters:
  12794. --  ----------
  12795. --    FT      initialized file handle.
  12796. --    Intent      intention array.
  12797. --    
  12798. --
  12799. --  Exceptions:
  12800. --  ----------
  12801. --    None raised.
  12802. --
  12803. --  Notes:
  12804. --  -----
  12805. --    The intention to be stored is the intention with which the node
  12806. --    handle was opened to the file node.  When the file handle is
  12807. --    opened via the node handle, the intention is copied to the 
  12808. --    file handle.
  12809. --
  12810. ---------------------------------------------------------------------
  12811.  
  12812.         procedure Set_Intent(Ft     : in out File_Type; 
  12813.                              Intent : Intention); 
  12814.  
  12815. -----------------------  Get_Mode ----------------------------
  12816. --
  12817. --  Purpose:
  12818. --  -------
  12819. --    Internal procedure to fetch the file mode
  12820. --    from the CAIS file handle.
  12821. --
  12822. --  Parameters:
  12823. --  ----------
  12824. --    FT      initialized file handle.
  12825. --    Mode      file mode.
  12826. --    
  12827. --
  12828. --  Exceptions:
  12829. --  ----------
  12830. --    None raised.
  12831. --
  12832. --  Notes:
  12833. --  -----
  12834. --    The mode returned is the mode with which the file handle
  12835. --    was opened.
  12836. --
  12837. ---------------------------------------------------------------------
  12838.  
  12839.         procedure Get_Mode(Ft   : File_Type; 
  12840.                            Mode : in out File_Mode); 
  12841.  
  12842. -----------------------  Set_Mode ----------------------------
  12843. --
  12844. --  Purpose:
  12845. --  -------
  12846. --    Internal procedure to store the file mode
  12847. --    into the CAIS file handle.
  12848. --
  12849. --  Parameters:
  12850. --  ----------
  12851. --    FT      initialized file handle.
  12852. --    Mode      file mode.
  12853. --    
  12854. --
  12855. --  Exceptions:
  12856. --  ----------
  12857. --    None raised.
  12858. --
  12859. --  Notes:
  12860. --  -----
  12861. --    The mode to be stored is the mode with which the file handle
  12862. --    is being opened (or reset).
  12863. --
  12864. ---------------------------------------------------------------------
  12865.  
  12866.         procedure Set_Mode(Ft   : in out File_Type; 
  12867.                            Mode : File_Mode); 
  12868.  
  12869. -----------------------  Get_Name ----------------------------
  12870. --
  12871. --  Purpose:
  12872. --  -------
  12873. --    Internal procedure to fetch the pathname of the file node 
  12874. --    from the CAIS file handle.
  12875. --
  12876. --  Parameters:
  12877. --  ----------
  12878. --    FT      initialized file handle.
  12879. --    Name      name string.
  12880. --    Lastchar  index of last non-blank character in Name.
  12881. --    
  12882. --
  12883. --  Exceptions:
  12884. --  ----------
  12885. --    None raised.
  12886. --
  12887. --  Notes:
  12888. --  -----
  12889. --    The pathname returned is the pathname from the node handle
  12890. --    through which the file handle was opened.
  12891. --
  12892. ---------------------------------------------------------------------
  12893.  
  12894.         procedure Get_Name(Ft       : File_Type; 
  12895.                            Name     : in out String; 
  12896.                            Lastchar : in out Natural); 
  12897.  
  12898. -----------------------  Set_Name ----------------------------
  12899. --
  12900. --  Purpose:
  12901. --  -------
  12902. --    Internal procedure to store the pathname of the file node 
  12903. --    into the CAIS file handle.
  12904. --
  12905. --  Parameters:
  12906. --  ----------
  12907. --    FT      initialized file handle.
  12908. --    Name      name string.
  12909. --    
  12910. --
  12911. --  Exceptions:
  12912. --  ----------
  12913. --    None raised.
  12914. --
  12915. --  Notes:
  12916. --  -----
  12917. --    The pathname to be stored is the pathname from the node handle
  12918. --    through which the file handle is being opened.
  12919. --
  12920. ---------------------------------------------------------------------
  12921.  
  12922.         procedure Set_Name(Ft   : in out File_Type; 
  12923.                            Name : String); 
  12924.  
  12925. -----------------------  Get_Form ----------------------------
  12926. --
  12927. --  Purpose:
  12928. --  -------
  12929. --    Internal function which returns the form list of the file node 
  12930. --    from the CAIS file handle.
  12931. --
  12932. --  Parameters:
  12933. --  ----------
  12934. --    FT      initialized file handle.
  12935. --    
  12936. --
  12937. --  Exceptions:
  12938. --  ----------
  12939. --    None raised.
  12940. --
  12941. --  Notes:
  12942. --  -----
  12943. --    Conversion between form strings for external files and the
  12944. --    CAIS form is not implemented in the prototype.
  12945. --
  12946. ---------------------------------------------------------------------
  12947.  
  12948.         function Get_Form(Ft : File_Type) return List_Type; 
  12949.  
  12950. -----------------------  Set_Form ----------------------------
  12951. --
  12952. --  Purpose:
  12953. --  -------
  12954. --    Internal procedure which stores the form list of the file node 
  12955. --    into the CAIS file handle.
  12956. --
  12957. --  Parameters:
  12958. --  ----------
  12959. --    FT      initialized file handle.
  12960. --    Form      list of form entries.
  12961. --    
  12962. --
  12963. --  Exceptions:
  12964. --  ----------
  12965. --    None raised.
  12966. --
  12967. --  Notes:
  12968. --  -----
  12969. --    Conversion between form strings for external files and the
  12970. --    CAIS form is not implemented in the prototype.
  12971. --
  12972. ---------------------------------------------------------------------
  12973.  
  12974.         procedure Set_Form(Ft   : in out File_Type; 
  12975.                            Form : List_Type); 
  12976.     private
  12977.         package Dir_Io is 
  12978.             new Standard.Direct_Io(Element_Type); 
  12979.         type Direct_File_Ptr is access Dir_Io.File_Type; 
  12980.  
  12981.         type File_Rec is 
  12982.             record
  12983.                 Fd                 : Direct_File_Ptr := new Dir_Io.File_Type; 
  12984.                 Shadow_File_Name   : String(1 .. Max_Shadow_File_Length); 
  12985.                 Contents_File_Name : String(1 .. Max_Contents_File_Length); 
  12986.                 Intent             : Intention(Pragmatics.Intent_Count); 
  12987.                 Intent_Size        : Pragmatics.Intent_Count; 
  12988.                 Mode               : File_Mode; 
  12989.                 Name               : String(1 .. Max_Name_String); 
  12990.                 Form               : List_Type; 
  12991.             end record; 
  12992.  
  12993.         type File_Type is access File_Rec; 
  12994.  
  12995. ------------------------------------------------------------------------------
  12996.     end Direct_Io_Definitions; 
  12997. ------------------------------------------------------------------------------
  12998. ----------------------------------------------------------------------
  12999. --                  D I R E C T _ I O
  13000. --
  13001. --  Purpose:
  13002. --  -------
  13003. --        This package provides facilities for direct-access input
  13004. --        and output to CAIS file comparable to those described
  13005. --        in the DIRECT_IO package of the Ada LRM.
  13006. --
  13007. --  Usage:
  13008. --  -----
  13009. --        Usage is analogous to usage of the Ada Direct_Io 
  13010. --        package.  The package is instantiated with the element
  13011. --        type of the file as parameter.  CAIS file nodes 
  13012. --        correspond to ordinary Ada files, and file handles are 
  13013. --        Ada objects of CAIS subtype Direct_Io.File_Type,
  13014. --        corresponding to the Ada (LRM) Direct_Io.File_Type.
  13015. --        CAIS Direct_Io input and output operations 
  13016. --        access the contents of CAIS file nodes.
  13017. --
  13018. --  Notes:
  13019. --  -----
  13020. --        This is a version of the package CAIS.DIRECT_IO,
  13021. --        specified in MIL-STD-CAIS section 5.3.2; all references
  13022. --        to the CAIS specification refer to the CAIS specification
  13023. --        dated 31 January 1985.  This implementation deviates 
  13024. --        from the CAIS specification in that a distinct type,
  13025. --        File_Type is employed in the package, following the
  13026. --        Ada LRM.  The package instantiates another generic 
  13027. --        package, Direct_Io_Definitions, that supports the 
  13028. --        abstract data type, File_Type.
  13029. --
  13030. --  Revision History:
  13031. --  ----------------
  13032. --        None.
  13033. --
  13034. -------------------------------------------------------------------
  13035.  
  13036.     generic
  13037.         type Element_Type is private; 
  13038.     package Direct_Io is 
  13039.  
  13040.         use Node_Definitions; 
  13041.         use List_Utilities; 
  13042.  
  13043.         package Dir_Io_Definitions is 
  13044.             new Direct_Io_Definitions(Element_Type); 
  13045.         use Dir_Io_Definitions; 
  13046.  
  13047.         subtype File_Type is Dir_Io_Definitions.File_Type; 
  13048.         subtype File_Mode is Dir_Io_Definitions.File_Mode; 
  13049.  
  13050.         type Count is range 0 .. Integer'Last; 
  13051.         subtype Positive_Count is Count range 1 .. Count'Last; 
  13052.  
  13053. ----------------------     Create     ----------------------
  13054. --
  13055. --  Purpose:
  13056. --  -------
  13057. --        This procedure creates a file and its file node; the
  13058. --        file contains elements which may be accessed either
  13059. --        directly or sequentially.  The attribute Access_Method is
  13060. --        assigned the value "(Direct,Sequential)" as part of the creation.
  13061. --
  13062. --  Parameters:
  13063. --  ----------
  13064. --    File    file handle, initially closed, to be opened.
  13065. --    Base    open node handle to the node which will be the
  13066. --        source of the primary relationship to the new
  13067. --        node.
  13068. --    Key    relationship key of the primary relationship to
  13069. --        be created.
  13070. --    Relation    relation name of the primary relationship to be created.
  13071. --    Mode    indicates mode of the file.
  13072. --    Form    indicates file characteristics.
  13073. --    Attributes
  13074. --        initial values for attributes of the new node.
  13075. --    Access_Control
  13076. --        defines the initial access control information
  13077. --        associated with the created node.
  13078. --    Level    defines the classification label for the created node.
  13079. --
  13080. --  Exceptions:
  13081. --  ----------
  13082. --    Name_Error
  13083. --        raised if a node already exists for the node specified
  13084. --        by Key and Relation or if Key or Relation is syntactically
  13085. --        illegal or if any node identifying a group specified in the
  13086. --        given Access_Control parameter is unobtainable.
  13087. --    Use_Error
  13088. --        raised if any of the parameters Access_Control, Level or
  13089. --        Attributes is syntactically or semantically illegal.
  13090. --        Use_Error is also raised if Relation is the name of a
  13091. --        predefined attribute other than File_Kind.  Also raised if
  13092. --        Relation is the name of a predefined relation which cannnot
  13093. --        be created by the user.
  13094. --    Status_Error
  13095. --        raised if Base is not an open node handle or if File is
  13096. --        an open file handle prior to the call.
  13097. --    Intent_Violation
  13098. --        raised if Base was not opened with an intent establishing
  13099. --        the right to append relationships.
  13100. --    Security_Violation
  13101. --        raised if the operation represents a violation of mandatory
  13102. --        access controls; raised only if the conditions for other
  13103. --        exceptions are not present.
  13104. --
  13105. --  Notes:
  13106. --  -----
  13107. --    This procedure is defined in section 5.3.2.2 of MIL-STD-CAIS,
  13108. --    dated 31 January 1985.
  13109. --    The additional interface for Create that is presented is
  13110. --    also provided.
  13111. --    NOTE:  The exception handler semantics of the additional
  13112. --    interface are not adequate.  The unconditional Close file
  13113. --    call may raise a Status_Error, causing the original
  13114. --    exception to be lost.
  13115. --
  13116. ---------------------------------------------------------------------
  13117.  
  13118.         procedure Create(File           : in out File_Type; 
  13119.                          Base           : in out Node_Type; 
  13120.                          Key            : Relationship_Key := Latest_Key; 
  13121.                          Relation       : Relation_Name := Default_Relation; 
  13122.                          Mode           : File_Mode := Inout_File; 
  13123.                          Form           : List_Type := Empty_List; 
  13124.                          Attributes     : List_Type := Empty_List; 
  13125.                          Access_Control : List_Type := Empty_List; 
  13126.                          Level          : List_Type := Empty_List); 
  13127.  
  13128. -------------------------------------------------------------------------------
  13129. --
  13130. --    Alternate interface using Name (pathname) rather than Base, Relation,
  13131. --    and Key to refer to file node.
  13132. --
  13133. -------------------------------------------------------------------------------
  13134.  
  13135.         procedure Create(File           : in out File_Type; 
  13136.                          Name           : Name_String; 
  13137.                          Mode           : File_Mode := Inout_File; 
  13138.                          Form           : List_Type := Empty_List; 
  13139.                          Attributes     : List_Type := Empty_List; 
  13140.                          Access_Control : List_Type := Empty_List; 
  13141.                          Level          : List_Type := Empty_List); 
  13142.  
  13143. ----------------------     Open     ----------------------
  13144. --
  13145. --  Purpose:
  13146. --  -------
  13147. --    This procedure opens a file handle on a file containing
  13148. --    elements of the generic parameter type, given an open node
  13149. --    handle on the file node.
  13150. --
  13151. --  Parameters:
  13152. --  ----------
  13153. --    File    file handle, initially closed, to be opened.
  13154. --    Node    open node handle to the file node.
  13155. --    Mode    indicates the mode of the file.
  13156. --
  13157. --  Exceptions:
  13158. --  ----------
  13159. --    Use_Error
  13160. --        raised if the attribute Access_Method of the file node
  13161. --        does not have the value Direct, the element type of the
  13162. --        file does not correspond with the element type of this
  13163. --        instantiation of the CAIS Direct_Io package, or the Mode
  13164. --        is Append_File.
  13165. --
  13166. --    Status_Error
  13167. --        raised if File is an open file handle at the time of the call
  13168. --        or if Node is not an open node handle.
  13169. --
  13170. --    Intent_Violation
  13171. --        raised if Node has not been opened with an intent 
  13172. --        establishing the access rights required for the Mode.
  13173. --
  13174. --  Notes:
  13175. --  -----
  13176. --    This procedure is defined in section 5.3.2.3 of MIL-STD-CAIS,
  13177. --    dated 31 January 1985.
  13178. --    The additional interface for Open that is presented is
  13179. --    also provided.
  13180. --    NOTE:  The exception handler semantics of the additional
  13181. --    interface are not adequate.  The unconditional Close file
  13182. --    call may raise a Status_Error, causing the original
  13183. --    exception to be lost.
  13184. --
  13185. ---------------------------------------------------------------------
  13186.  
  13187.         procedure Open(File : in out File_Type; 
  13188.                        Node : Node_Type; 
  13189.                        Mode : File_Mode); 
  13190.  
  13191.  
  13192.  
  13193. -------------------------------------------------------------------------------
  13194. --
  13195. --    Alternate interface using Name (pathname) rather than Base, Relation,
  13196. --    and Key to refer to file node.
  13197. --
  13198. -------------------------------------------------------------------------------
  13199.  
  13200.         procedure Open(File : in out File_Type; 
  13201.                        Name : Name_String; 
  13202.                        Mode : File_Mode); 
  13203.  
  13204. ----------------------     Close     ----------------------
  13205. --
  13206. --  Purpose:
  13207. --  -------
  13208. --    Closes file handle to CAIS file node.
  13209. --
  13210. --  Parameters:
  13211. --  ----------
  13212. --    File    open file handle.
  13213. --
  13214. --  Exceptions:
  13215. --  ----------
  13216. --    Status_Error
  13217. --        raised if file handle is not open.
  13218. --
  13219. --  Notes:
  13220. --  -----
  13221. --    Semantics correspond to Ada LRM, Section 14.2.1
  13222. --
  13223. ---------------------------------------------------------------------
  13224.  
  13225.         procedure Close(File : in out File_Type); 
  13226.  
  13227. ----------------------     Delete     ----------------------
  13228. --
  13229. --  Purpose:
  13230. --  -------
  13231. --    This procedure deletes the CAIS file identified
  13232. --    by File.  
  13233. --    In addition to the semantics specified in the LRM,
  13234. --    the node associated with the open file handle File
  13235. --    is made unobtainable as if a call to the Delete_Node
  13236. --    procedure had been made.
  13237. --
  13238. --  Parameters:
  13239. --  ----------
  13240. --    File    an open file handle on the file being deleted.
  13241. --
  13242. --  Exceptions:
  13243. --  ----------
  13244. --    Name_Error
  13245. --        raised if the parent node of the node associated with
  13246. --        the file identified by File is inaccessible.
  13247. --    Use_Error
  13248. --        raised if any primary relationships emanate from the
  13249. --        node associated with the file identified by File.
  13250. --    Status_Error
  13251. --        raised if File is not an open file handle.
  13252. --    Lock_Error
  13253. --        raised if access with intent Write_Relationships to the
  13254. --        parent of the node to be deleted cannot be obtained due
  13255. --        to an existing lock on the node.
  13256. --    Access_Violation
  13257. --        raised if the current process does not have sufficient
  13258. --        discretionary access control rights to obtain access to
  13259. --        the parent of the node to be deleted with intent
  13260. --        Exclusive_Write; only raised if the conditions for
  13261. --        Name_Error are not present.
  13262. --    Security_Violation
  13263. --        raised if the operation represents a violation of mandatory
  13264. --        access controls; raised only if the conditions for other
  13265. --        exceptions are not present.
  13266. --
  13267. --  Notes:
  13268. --  -----
  13269. --    This procedure is defined in section 5.3.2.4 of MIL-STD-CAIS,
  13270. --    dated 31 January 1985.
  13271. --
  13272. ---------------------------------------------------------------------
  13273.  
  13274.         procedure Delete(File : in out File_Type); 
  13275. ----------------------     Reset     ----------------------
  13276. --
  13277. --  Purpose:
  13278. --  -------
  13279. --    Reset the file mode of a CAIS file.
  13280. --
  13281. --  Parameters:
  13282. --  ----------
  13283. --    File    An open file handle on the file being reset.
  13284. --    Mode    Indicates the mode of the file.
  13285. --
  13286. --  Exceptions:
  13287. --  ----------
  13288. --    See note.
  13289. --
  13290. --  Notes:
  13291. --  -----
  13292. --    This procedure is defined as in section 5.3.4.5 of MIL-STD-CAIS,
  13293. --    dated 31 January 1985.
  13294. --    Semantics of this procedure are not restricted to Ada LRM
  13295. --    semantics, pending clarification of the interaction of access
  13296. --    methods in the CAIS.
  13297. --
  13298. --    Although no exceptions are defined in the CAIS, checking of
  13299. --    Status_Error and Use_Error for invalid mode is done.
  13300. ---------------------------------------------------------------------
  13301.  
  13302.         procedure Reset(File : in out File_Type; 
  13303.                         Mode : File_Mode); 
  13304. ----------------------     Reset     ----------------------
  13305. --
  13306. --  Purpose:
  13307. --  -------
  13308. --    Reset a CAIS file.
  13309. --
  13310. --  Parameters:
  13311. --  ----------
  13312. --    File    An open file handle on the file being reset.
  13313. --
  13314. --  Exceptions:
  13315. --  ----------
  13316. --    None raised.
  13317. --
  13318. --  Notes:
  13319. --  -----
  13320. --    This procedure is defined as in section 5.3.4.5 of MIL-STD-CAIS,
  13321. --    dated 31 January 1985.
  13322. --    Semantics of this procedure are not restricted to Ada LRM
  13323. --    semantics, pending clarification of the interaction of access
  13324. --    methods in the CAIS.
  13325. ---------------------------------------------------------------------
  13326.  
  13327.         procedure Reset(File : in out File_Type); 
  13328.  
  13329. ----------------------     Mode     ----------------------
  13330. --
  13331. --  Purpose:
  13332. --  -------
  13333. --    Returns the current mode of the current CAIS file.
  13334. --
  13335. --  Parameters:
  13336. --  ----------
  13337. --    File    open file handle.
  13338. --
  13339. --  Exceptions:
  13340. --  ----------
  13341. --    Status_Error
  13342. --        raised if file handle is not open.
  13343. --
  13344. --  Notes:
  13345. --  -----
  13346. --    Semantics correspond to Ada LRM, Section 14.2.1
  13347. --
  13348. ---------------------------------------------------------------------
  13349.  
  13350.         function Mode(File : File_Type) return File_Mode; 
  13351. ----------------------     Name     ----------------------
  13352. --
  13353. --  Purpose:
  13354. --  -------
  13355. --    Returns a string containing the name of the CAIS file 
  13356. --    node currently associated with the file handle.
  13357. --
  13358. --  Parameters:
  13359. --  ----------
  13360. --    File    open file handle.
  13361. --
  13362. --  Exceptions:
  13363. --  ----------
  13364. --    Status_Error
  13365. --        raised if file handle is not open.
  13366. --
  13367. --  Notes:
  13368. --  -----
  13369. --    Semantics correspond to Ada LRM, Section 14.2.1
  13370. --
  13371. ---------------------------------------------------------------------
  13372.  
  13373.         function Name(File : File_Type) return String; 
  13374. ----------------------     Form     ----------------------
  13375. --
  13376. --  Purpose:
  13377. --  -------
  13378. --    Returns the form string for the external file currently
  13379. --    associated with the given file.
  13380. --
  13381. --  Parameters:
  13382. --  ----------
  13383. --    File    open file handle.
  13384. --
  13385. --  Exceptions:
  13386. --  ----------
  13387. --    Status_Error
  13388. --        raised if file handle is not open.
  13389. --
  13390. --  Notes:
  13391. --  -----
  13392. --    Semantics correspond to Ada LRM, Section 14.2.1
  13393. --
  13394. ---------------------------------------------------------------------
  13395.  
  13396.         function Form(File : File_Type) return String; 
  13397.  
  13398. ----------------------     Is_Open     ----------------------
  13399. --
  13400. --  Purpose:
  13401. --  -------
  13402. --    Returns TRUE if the file handle is open, otherwise returns FALSE.
  13403. --
  13404. --  Parameters:
  13405. --  ----------
  13406. --    File    file handle.
  13407. --
  13408. --  Exceptions:
  13409. --  ----------
  13410. --    None.
  13411. --
  13412. --  Notes:
  13413. --  -----
  13414. --    Semantics correspond to Ada LRM, Section 14.2.1
  13415. --
  13416. ---------------------------------------------------------------------
  13417.  
  13418.         function Is_Open(File : File_Type) return Boolean; 
  13419.  
  13420. ---------------------------     Read     ---------------------------
  13421. --
  13422. --  Purpose:
  13423. --  -------
  13424. --    Sets the current index of the given file to the index
  13425. --    value given by the parameter From.
  13426. --    Returns in the parameter Item, the value of the element 
  13427. --    whose position in the given file is specified by the 
  13428. --    current index of the file; then increases the current
  13429. --    index by one.
  13430. --
  13431. --  Parameters:
  13432. --  ----------
  13433. --    File    open file handle.
  13434. --    Item    returns element read from file.
  13435. --    From    index of element to be read.
  13436. --
  13437. --  Exceptions:
  13438. --  ----------
  13439. --    Status_Error
  13440. --        raised if file handle is not open.
  13441. --    Mode_Error
  13442. --        raised if the mode is not In_File.
  13443. --    End_Error
  13444. --        raised if the index to be used exceeds the size
  13445. --        of the given file.
  13446. --    Data_Error
  13447. --        raised if the element read cannot be interpreted
  13448. --        as a value of the generic parameter type.
  13449. --
  13450. --  Notes:
  13451. --  -----
  13452. --    Semantics follow Ada LRM Section 14.2.4.
  13453. --
  13454. ---------------------------------------------------------------------
  13455.  
  13456.         procedure Read(File : File_Type; 
  13457.                        Item : in out Element_Type; 
  13458.                        From : Positive_Count); 
  13459.  
  13460. ---------------------------     Read     ---------------------------
  13461. --
  13462. --  Purpose:
  13463. --  -------
  13464. --    Returns in the parameter Item, the value of the element 
  13465. --    whose position in the given file is specified by the 
  13466. --    current index of the file; then increases the current
  13467. --    index by one.
  13468. --
  13469. --  Parameters:
  13470. --  ----------
  13471. --    File    open file handle.
  13472. --    Item    returns element read from file.
  13473. --
  13474. --  Exceptions:
  13475. --  ----------
  13476. --    Status_Error
  13477. --        raised if file handle is not open.
  13478. --    Mode_Error
  13479. --        raised if the mode is not In_File.
  13480. --    End_Error
  13481. --        raised if the index to be used exceeds the size
  13482. --        of the given file.
  13483. --    Data_Error
  13484. --        raised if the element read cannot be interpreted
  13485. --        as a value of the generic parameter type.
  13486. --
  13487. --  Notes:
  13488. --  -----
  13489. --    Semantics follow Ada LRM Section 14.2.4.
  13490. --
  13491. ---------------------------------------------------------------------
  13492.  
  13493.         procedure Read(File : File_Type; 
  13494.                        Item : in out Element_Type); 
  13495.  
  13496. ---------------------------     Write     ---------------------------
  13497. --
  13498. --  Purpose:
  13499. --  -------
  13500. --    Sets the index of the given file to the index value given
  13501. --    by the parameter To.
  13502. --    Gives the value of the parameter Item to the element whose
  13503. --    position in the given file is specified by the current index
  13504. --    of the file; then increases the current index by one.
  13505. --
  13506. --  Parameters:
  13507. --  ----------
  13508. --    File    open file handle.
  13509. --    Item    element to be written to the file.
  13510. --    To    index of element to be written.
  13511. --
  13512. --  Exceptions:
  13513. --  ----------
  13514. --    Status_Error
  13515. --        raised if file handle is not open.
  13516. --    Mode_Error
  13517. --        raised if mode is In_File.
  13518. --    Use_Error
  13519. --        raised if the capacity of the file is exceeded.
  13520. --
  13521. --  Notes:
  13522. --  -----
  13523. --    Semantics follow Ada LRM Section 14.2.4.
  13524. --
  13525. ---------------------------------------------------------------------
  13526.  
  13527.         procedure Write(File : File_Type; 
  13528.                         Item : Element_Type; 
  13529.                         To   : Positive_Count); 
  13530.  
  13531. ---------------------------     Write     ---------------------------
  13532. --
  13533. --  Purpose:
  13534. --  -------
  13535. --    Gives the value of the parameter Item to the element whose
  13536. --    position in the given file is specified by the current index
  13537. --    of the file; then increases the current index by one.
  13538. --
  13539. --  Parameters:
  13540. --  ----------
  13541. --    File    open file handle.
  13542. --    Item    element to be written to the file.
  13543. --
  13544. --  Exceptions:
  13545. --  ----------
  13546. --    Status_Error
  13547. --        raised if file handle is not open.
  13548. --    Mode_Error
  13549. --        raised if mode is In_File.
  13550. --    Use_Error
  13551. --        raised if the capacity of the file is exceeded.
  13552. --
  13553. --  Notes:
  13554. --  -----
  13555. --    Semantics follow Ada LRM Section 14.2.4.
  13556. --
  13557. ---------------------------------------------------------------------
  13558.  
  13559.         procedure Write(File : File_Type; 
  13560.                         Item : Element_Type); 
  13561.  
  13562. ----------------------     Set_Index     ----------------------
  13563. --
  13564. --  Purpose:
  13565. --  -------
  13566. --    Sets the current index of the given file to the given
  13567. --    index value (which may exceed the current size of the file).
  13568. --
  13569. --  Parameters:
  13570. --  ----------
  13571. --    File    open file handle.
  13572. --    To    index value.
  13573. --
  13574. --  Exceptions:
  13575. --  ----------
  13576. --    Status_Error
  13577. --        raised if file handle is not open.
  13578. --
  13579. --  Notes:
  13580. --  -----
  13581. --    Semantics follow Ada LRM Section 14.2.4.
  13582. --
  13583. ---------------------------------------------------------------------
  13584.  
  13585.         procedure Set_Index(File : File_Type; 
  13586.                             To   : Positive_Count); 
  13587. ----------------------     Index     ----------------------
  13588. --
  13589. --  Purpose:
  13590. --  -------
  13591. --    Returns the current index of the given file.
  13592. --
  13593. --  Parameters:
  13594. --  ----------
  13595. --    File    open file handle.
  13596. --
  13597. --  Exceptions:
  13598. --  ----------
  13599. --    Status_Error
  13600. --        raised if file handle is not open.
  13601. --
  13602. --  Notes:
  13603. --  -----
  13604. --    Semantics follow Ada LRM Section 14.2.4.
  13605. --
  13606. ---------------------------------------------------------------------
  13607.  
  13608.         function Index(File : File_Type) return Positive_Count; 
  13609.  
  13610. ----------------------     Size     ----------------------
  13611. --
  13612. --  Purpose:
  13613. --  -------
  13614. --    Returns the current size of the given file.
  13615. --
  13616. --  Parameters:
  13617. --  ----------
  13618. --    File    open file handle.
  13619. --
  13620. --  Exceptions:
  13621. --  ----------
  13622. --    Status_Error
  13623. --        raised if file handle is not open.
  13624. --
  13625. --  Notes:
  13626. --  -----
  13627. --    Semantics follow Ada LRM Section 14.2.4.
  13628. --
  13629. ---------------------------------------------------------------------
  13630.  
  13631.         function Size(File : File_Type) return Count; 
  13632.  
  13633. ----------------------     End_Of_File     ----------------------
  13634. --
  13635. --  Purpose:
  13636. --  -------
  13637. --    Returns True if the current index is exceeds the size of the
  13638. --    given file;  otherwise returns False.
  13639. --
  13640. --  Parameters:
  13641. --  ----------
  13642. --    File    open file handle.
  13643. --
  13644. --  Exceptions:
  13645. --  ----------
  13646. --    Status_Error
  13647. --        raised if file handle is not open.
  13648. --    Mode_Error
  13649. --        raised if file mode is Out_File.
  13650. --
  13651. --  Notes:
  13652. --  -----
  13653. --    Semantics follow Ada LRM Section 14.2.4.
  13654. --
  13655. ---------------------------------------------------------------------
  13656.  
  13657.         function End_Of_File(File : File_Type) return Boolean; 
  13658.  
  13659. ---------------------------------------------------------------------
  13660.     end Direct_Io; 
  13661. ---------------------------------------------------------------------
  13662.  
  13663. ----------------------------------------------------------------------
  13664. --          S E Q U E N T I A L _ I O _ D E F I N I T I O N S
  13665. --
  13666. --  Purpose:
  13667. --  -------
  13668. --      This package defines the types and exceptions associated with 
  13669. --      sequential_io file handles.
  13670. --
  13671. --  Usage:
  13672. --  -----
  13673. --    Package Cais.Sequential_Io instantiates this package to produce
  13674. --    a new package Seq_Io_Definitions nested in the Cais.Sequential_Io 
  13675. --    specification.  For direct use of the base types and exceptions 
  13676. --    used by Cais.Sequential_Io, the user can refer to the instantiated 
  13677. --    package.
  13678. --
  13679. --  Notes:
  13680. --  -----
  13681. --    This package  is added to the CAIS implementation
  13682. --    to provide distinct File_Types for each CAIS.Sequential_Io
  13683. --    instantiation.  This is an alternative to the present 
  13684. --    CAIS file handle usage, which differs substantially from 
  13685. --    standard Ada Input/Output.
  13686. --    Ada generic I/O packages permit an unbounded number of 
  13687. --    file types to be constructed.  The CAIS requires a single
  13688. --    file type to hide all file types, for use by  text and generic
  13689. --    instantiations of direct and sequential IO packages.
  13690. --    This implementation follows Ada.
  13691. --
  13692. --      The     use     of     a     limited     private     type
  13693. --      (Sequential_Io_Definitions.File_Type)  implies  the addition of
  13694. --      subprograms to manipulate  that  type  (e.g.  to  set  or
  13695. --      extract  the  contents of an object of that type).  These
  13696. --      are in this specification, although they are additions to
  13697. --      the  CAIS  specification  for  this  package.  
  13698. --    
  13699. --      This is a version of the package Cais.IO_Definitions,
  13700. --      specified in MIL-STD-CAIS section 5.3.1
  13701. --
  13702. --  Revision History:
  13703. --  ----------------
  13704. --    None.
  13705. --
  13706. -------------------------------------------------------------------
  13707.  
  13708.     generic
  13709.         type Element_Type is private; 
  13710.     package Sequential_Io_Definitions is 
  13711.  
  13712.         use Node_Definitions; 
  13713.                           -- Not in Cais spec
  13714.         use Pragmatics; 
  13715.                      -- Not in Cais spec
  13716.         use Io_Exceptions; 
  13717.         use List_Utilities; 
  13718.                         -- Not in Cais spec
  13719.  
  13720.  
  13721.         type File_Mode is (In_File, Inout_File, Out_File, Append_File); 
  13722.  
  13723.         type File_Type is limited private; 
  13724.  
  13725.  
  13726.         Status_Error : exception renames Io_Exceptions.Status_Error; 
  13727.         Mode_Error   : exception renames Io_Exceptions.Mode_Error; 
  13728.         Name_Error   : exception renames Io_Exceptions.Name_Error; 
  13729.         Use_Error    : exception renames Io_Exceptions.Use_Error; 
  13730.         Device_Error : exception renames Io_Exceptions.Device_Error; 
  13731.         End_Error    : exception renames Io_Exceptions.End_Error; 
  13732.         Data_Error   : exception renames Io_Exceptions.Data_Error; 
  13733.         Layout_Error : exception renames Io_Exceptions.Layout_Error; 
  13734.  
  13735.     -- The following is NOT part of the CAIS specification.
  13736.  
  13737.  
  13738.         type Sequential_File_Ptr is private; 
  13739.  
  13740. ----------------------- Initialize ----------------------------
  13741. --
  13742. --  Purpose:
  13743. --  -------
  13744. --    Internal function to allocate file handle.
  13745. --
  13746. --  Parameters:
  13747. --  ----------
  13748. --    FT    (access to) file handle record.
  13749. --
  13750. --  Exceptions:
  13751. --  ----------
  13752. --    None raised.
  13753. --
  13754. --  Notes:
  13755. --  -----
  13756. --    File_Recs are allocated from heap.
  13757. --
  13758. ---------------------------------------------------------------------
  13759.  
  13760.         procedure Initialize(Ft : in out File_Type); 
  13761.  
  13762. ----------------------- Deallocate ----------------------------
  13763. --
  13764. --  Purpose:
  13765. --  -------
  13766. --    Internal function to deallocate file handle.
  13767. --
  13768. --  Parameters:
  13769. --  ----------
  13770. --    FT    (access to) file handle record.
  13771. --
  13772. --  Exceptions:
  13773. --  ----------
  13774. --    None raised.
  13775. --
  13776. --  Notes:
  13777. --  -----
  13778. --    File_Recs are released to heap via unchecked deallocation.
  13779. --
  13780. ---------------------------------------------------------------------
  13781.  
  13782.         procedure Deallocate(Ft : in out File_Type); 
  13783.  
  13784. ----------------------- Un_Initialized ----------------------------
  13785. --
  13786. --  Purpose:
  13787. --  -------
  13788. --    Internal function to test whether file has been
  13789. --    initialized.  Returns True if not initialized,
  13790. --    otherwise returns False.
  13791. --
  13792. --  Parameters:
  13793. --  ----------
  13794. --    FT    (access to) file handle record.
  13795. --
  13796. --  Exceptions:
  13797. --  ----------
  13798. --    None raised.
  13799. --
  13800. --  Notes:
  13801. --  -----
  13802. --    Handle is checked for null reference.
  13803. --
  13804. ---------------------------------------------------------------------
  13805.  
  13806.         function Un_Initialized(Ft : File_Type) return Boolean; 
  13807.  
  13808. ----------------------- Assign ----------------------------
  13809. --
  13810. --  Purpose:
  13811. --  -------
  13812. --    Internal procedure to copy one file handle record to
  13813. --    another.
  13814. --
  13815. --  Parameters:
  13816. --  ----------
  13817. --    From    (access to) source file handle record.
  13818. --    To    (access to) target file handle record.
  13819. --
  13820. --  Exceptions:
  13821. --  ----------
  13822. --    None raised.
  13823. --
  13824. --  Notes:
  13825. --  -----
  13826. --    If the target file handle is uninitialized, Assign initializes
  13827. --    it before copying the components of the record.
  13828. --
  13829. ---------------------------------------------------------------------
  13830.  
  13831.         procedure Assign(From : File_Type; 
  13832.                          To   : in out File_Type); 
  13833. -----------------------  Get_File_Type ----------------------------
  13834. --
  13835. --  Purpose:
  13836. --  -------
  13837. --    Internal function to fetch (access to) the Ada file descriptor 
  13838. --    for the contents file from the CAIS file handle.
  13839. --
  13840. --  Parameters:
  13841. --  ----------
  13842. --    FT    initialized file handle.
  13843. --
  13844. --  Exceptions:
  13845. --  ----------
  13846. --    Status_Error
  13847. --        raised if file handle has not been initialized.
  13848. --
  13849. --  Notes:
  13850. --  -----
  13851. --    The file descriptor is implemented as an Ada Sequential_Io.File_Type,
  13852. --    The access value returned is of type Sequential_File_Ptr.
  13853. --
  13854. ---------------------------------------------------------------------
  13855.  
  13856.         function Get_File_Type(Ft : File_Type) return Sequential_File_Ptr; 
  13857.  
  13858. -----------------------  Set_File_Type ----------------------------
  13859. --
  13860. --  Purpose:
  13861. --  -------
  13862. --    Internal procedure to store (access to) an Ada file descriptor 
  13863. --    for the contents file into the CAIS file handle.
  13864. --
  13865. --  Parameters:
  13866. --  ----------
  13867. --    FT    initialized file handle.
  13868. --    SFD    access to the Sequential_Io file descriptor.
  13869. --
  13870. --  Exceptions:
  13871. --  ----------
  13872. --    Status_Error
  13873. --        raised if file handle has not been initialized.
  13874. --
  13875. --  Notes:
  13876. --  -----
  13877. --    The file descriptor is implemented as an Ada Sequential_Io.File_Type.
  13878. --    The access parameter is of type Sequential_File_Ptr.
  13879. --
  13880. ---------------------------------------------------------------------
  13881.  
  13882.         procedure Set_File_Type(Ft  : in out File_Type; 
  13883.                                 Sfd : Sequential_File_Ptr); 
  13884.  
  13885. -----------------------  Get_Shadow_File_Name ----------------------------
  13886. --
  13887. --  Purpose:
  13888. --  -------
  13889. --    Internal procedure to fetch the name of the shadow file
  13890. --    from the CAIS file handle.
  13891. --    The file name and its length are returned in parameters
  13892. --    Name and Lastchar, respectively.
  13893. --
  13894. --  Parameters:
  13895. --  ----------
  13896. --    FT      initialized file handle.
  13897. --    Name      name string.
  13898. --    Lastchar  index of last non-blank character in Name.
  13899. --    
  13900. --
  13901. --  Exceptions:
  13902. --  ----------
  13903. --    None raised.
  13904. --
  13905. --  Notes:
  13906. --  -----
  13907. --    The shadow file contains the node image for the
  13908. --    CAIS file node, and its attributes and relationships.
  13909. --
  13910. ---------------------------------------------------------------------
  13911.  
  13912.         procedure Get_Shadow_File_Name(Ft       : File_Type; 
  13913.                                        Name     : in out String; 
  13914.                                        Lastchar : in out Natural); 
  13915.  
  13916. -----------------------  Set_Shadow_File_Name ----------------------------
  13917. --
  13918. --  Purpose:
  13919. --  -------
  13920. --    Internal procedure to store the name of the shadow file
  13921. --    into the CAIS file handle.
  13922. --
  13923. --  Parameters:
  13924. --  ----------
  13925. --    FT      initialized file handle.
  13926. --    Name      name string.
  13927. --    
  13928. --
  13929. --  Exceptions:
  13930. --  ----------
  13931. --    None raised.
  13932. --
  13933. --  Notes:
  13934. --  -----
  13935. --    The shadow file contains the node image for the
  13936. --    CAIS file node, and its attributes and relationships.
  13937. --
  13938. ---------------------------------------------------------------------
  13939.  
  13940.         procedure Set_Shadow_File_Name(Ft   : in out File_Type; 
  13941.                                        Name : String); 
  13942.  
  13943. -----------------------  Get_Contents_File_Name ----------------------------
  13944. --
  13945. --  Purpose:
  13946. --  -------
  13947. --    Internal procedure to fetch the name of the contents file
  13948. --    from the CAIS file handle.
  13949. --    The file name and its length are returned in parameters
  13950. --    Name and Lastchar, respectively.
  13951. --
  13952. --  Parameters:
  13953. --  ----------
  13954. --    FT      initialized file handle.
  13955. --    Name      name string.
  13956. --    Lastchar  index of last non-blank character in Name.
  13957. --    
  13958. --
  13959. --  Exceptions:
  13960. --  ----------
  13961. --    None raised.
  13962. --
  13963. --  Notes:
  13964. --  -----
  13965. --    The contents file holds the actual file contents for the
  13966. --    CAIS file node.
  13967. --
  13968. ---------------------------------------------------------------------
  13969.  
  13970.         procedure Get_Contents_File_Name(Ft       : File_Type; 
  13971.                                          Name     : in out String; 
  13972.                                          Lastchar : in out Natural); 
  13973.  
  13974. -----------------------  Set_Contents_File_Name ----------------------------
  13975. --
  13976. --  Purpose:
  13977. --  -------
  13978. --    Internal procedure to store the name of the contents file
  13979. --    into the CAIS file handle.
  13980. --
  13981. --  Parameters:
  13982. --  ----------
  13983. --    FT      initialized file handle.
  13984. --    Name      name string.
  13985. --    
  13986. --
  13987. --  Exceptions:
  13988. --  ----------
  13989. --    None raised.
  13990. --
  13991. --  Notes:
  13992. --  -----
  13993. --    The contents file holds the actual file contents for the
  13994. --    CAIS file node.
  13995. --
  13996. ---------------------------------------------------------------------
  13997.  
  13998.         procedure Set_Contents_File_Name(Ft   : in out File_Type; 
  13999.                                          Name : String); 
  14000.  
  14001. -----------------------  Get_Intent ----------------------------
  14002. --
  14003. --  Purpose:
  14004. --  -------
  14005. --    Internal procedure to fetch the intention of the node handle,
  14006. --    from the CAIS file handle.
  14007. --
  14008. --  Parameters:
  14009. --  ----------
  14010. --    FT      initialized file handle.
  14011. --    Intent      intention array.
  14012. --    
  14013. --
  14014. --  Exceptions:
  14015. --  ----------
  14016. --    None raised.
  14017. --
  14018. --  Notes:
  14019. --  -----
  14020. --    The intention returned is the intention with which the node
  14021. --    handle was opened to the file node.  When the file handle is
  14022. --    opened via the node handle, the intention is copied to the 
  14023. --    file handle.
  14024. --
  14025. ---------------------------------------------------------------------
  14026.  
  14027.         procedure Get_Intent(Ft     : File_Type; 
  14028.                              Intent : in out Intention); 
  14029.  
  14030. -----------------------  Set_Intent ----------------------------
  14031. --
  14032. --  Purpose:
  14033. --  -------
  14034. --    Internal procedure to store the intention of the node handle,
  14035. --    into the CAIS file handle.
  14036. --
  14037. --  Parameters:
  14038. --  ----------
  14039. --    FT      initialized file handle.
  14040. --    Intent      intention array.
  14041. --    
  14042. --
  14043. --  Exceptions:
  14044. --  ----------
  14045. --    None raised.
  14046. --
  14047. --  Notes:
  14048. --  -----
  14049. --    The intention to be stored is the intention with which the node
  14050. --    handle was opened to the file node.  When the file handle is
  14051. --    opened via the node handle, the intention is copied to the 
  14052. --    file handle.
  14053. --
  14054. ---------------------------------------------------------------------
  14055.  
  14056.         procedure Set_Intent(Ft     : in out File_Type; 
  14057.                              Intent : Intention); 
  14058.  
  14059. -----------------------  Get_Mode ----------------------------
  14060. --
  14061. --  Purpose:
  14062. --  -------
  14063. --    Internal procedure to fetch the file mode
  14064. --    from the CAIS file handle.
  14065. --
  14066. --  Parameters:
  14067. --  ----------
  14068. --    FT      initialized file handle.
  14069. --    Mode      file mode.
  14070. --    
  14071. --
  14072. --  Exceptions:
  14073. --  ----------
  14074. --    None raised.
  14075. --
  14076. --  Notes:
  14077. --  -----
  14078. --    The mode returned is the mode with which the file handle
  14079. --    was opened.
  14080. --
  14081. ---------------------------------------------------------------------
  14082.  
  14083.         procedure Get_Mode(Ft   : File_Type; 
  14084.                            Mode : in out File_Mode); 
  14085.  
  14086. -----------------------  Set_Mode ----------------------------
  14087. --
  14088. --  Purpose:
  14089. --  -------
  14090. --    Internal procedure to store the file mode
  14091. --    into the CAIS file handle.
  14092. --
  14093. --  Parameters:
  14094. --  ----------
  14095. --    FT      initialized file handle.
  14096. --    Mode      file mode.
  14097. --    
  14098. --
  14099. --  Exceptions:
  14100. --  ----------
  14101. --    None raised.
  14102. --
  14103. --  Notes:
  14104. --  -----
  14105. --    The mode to be stored is the mode with which the file handle
  14106. --    is being opened (or reset).
  14107. --
  14108. ---------------------------------------------------------------------
  14109.  
  14110.         procedure Set_Mode(Ft   : in out File_Type; 
  14111.                            Mode : File_Mode); 
  14112.  
  14113. -----------------------  Get_Name ----------------------------
  14114. --
  14115. --  Purpose:
  14116. --  -------
  14117. --    Internal procedure to fetch the pathname of the file node 
  14118. --    from the CAIS file handle.
  14119. --
  14120. --  Parameters:
  14121. --  ----------
  14122. --    FT      initialized file handle.
  14123. --    Name      name string.
  14124. --    Lastchar  index of last non-blank character in Name.
  14125. --    
  14126. --
  14127. --  Exceptions:
  14128. --  ----------
  14129. --    None raised.
  14130. --
  14131. --  Notes:
  14132. --  -----
  14133. --    The pathname returned is the pathname from the node handle
  14134. --    through which the file handle was opened.
  14135. --
  14136. ---------------------------------------------------------------------
  14137.  
  14138.         procedure Get_Name(Ft       : File_Type; 
  14139.                            Name     : in out String; 
  14140.                            Lastchar : in out Natural); 
  14141.  
  14142. -----------------------  Set_Name ----------------------------
  14143. --
  14144. --  Purpose:
  14145. --  -------
  14146. --    Internal procedure to store the pathname of the file node 
  14147. --    into the CAIS file handle.
  14148. --
  14149. --  Parameters:
  14150. --  ----------
  14151. --    FT      initialized file handle.
  14152. --    Name      name string.
  14153. --    
  14154. --
  14155. --  Exceptions:
  14156. --  ----------
  14157. --    None raised.
  14158. --
  14159. --  Notes:
  14160. --  -----
  14161. --    The pathname to be stored is the pathname from the node handle
  14162. --    through which the file handle is being opened.
  14163. --
  14164. ---------------------------------------------------------------------
  14165.  
  14166.         procedure Set_Name(Ft   : in out File_Type; 
  14167.                            Name : String); 
  14168.  
  14169. -----------------------  Get_Form ----------------------------
  14170. --
  14171. --  Purpose:
  14172. --  -------
  14173. --    Internal function which returns the form list of the file node 
  14174. --    from the CAIS file handle.
  14175. --
  14176. --  Parameters:
  14177. --  ----------
  14178. --    FT      initialized file handle.
  14179. --    
  14180. --
  14181. --  Exceptions:
  14182. --  ----------
  14183. --    None raised.
  14184. --
  14185. --  Notes:
  14186. --  -----
  14187. --    Conversion between form strings for external files and the
  14188. --    CAIS form is not implemented in the prototype.
  14189. --
  14190. ---------------------------------------------------------------------
  14191.  
  14192.         function Get_Form(Ft : File_Type) return List_Type; 
  14193.  
  14194. -----------------------  Set_Form ----------------------------
  14195. --
  14196. --  Purpose:
  14197. --  -------
  14198. --    Internal procedure which stores the form list of the file node 
  14199. --    into the CAIS file handle.
  14200. --
  14201. --  Parameters:
  14202. --  ----------
  14203. --    FT      initialized file handle.
  14204. --    Form      list of form entries.
  14205. --    
  14206. --
  14207. --  Exceptions:
  14208. --  ----------
  14209. --    None raised.
  14210. --
  14211. --  Notes:
  14212. --  -----
  14213. --    Conversion between form strings for external files and the
  14214. --    CAIS form is not implemented in the prototype.
  14215. --
  14216. ---------------------------------------------------------------------
  14217.  
  14218.         procedure Set_Form(Ft   : in out File_Type; 
  14219.                            Form : List_Type); 
  14220.     private
  14221.         package Seq_Io is 
  14222.             new Standard.Sequential_Io(Element_Type); 
  14223.         type Sequential_File_Ptr is access Seq_Io.File_Type; 
  14224.  
  14225.         type File_Rec is 
  14226.             record
  14227.                 Fd                 : Sequential_File_Ptr := new Seq_Io.File_Type
  14228.                     ; 
  14229.                 Shadow_File_Name   : String(1 .. Max_Shadow_File_Length); 
  14230.                 Contents_File_Name : String(1 .. Max_Contents_File_Length); 
  14231.                 Intent             : Intention(Pragmatics.Intent_Count); 
  14232.                 Intent_Size        : Pragmatics.Intent_Count; 
  14233.                 Mode               : File_Mode; 
  14234.                 Name               : String(1 .. Max_Name_String); 
  14235.                 Form               : List_Type; 
  14236.             end record; 
  14237.  
  14238.         type File_Type is access File_Rec; 
  14239.  
  14240. ----------------------------------------------------------------------------
  14241.     end Sequential_Io_Definitions; 
  14242. ----------------------------------------------------------------------------
  14243. ----------------------------------------------------------------------
  14244. --              S E Q U E N T I A L _ I O
  14245. --
  14246. --  Purpose:
  14247. --  -------
  14248. --        This package provides facilities for sequentially accessing
  14249. --        data elements in CAIS files.  These facilities are comparable
  14250. --        to those described in the SEQUENTIAL_IO package of the Ada LRM.
  14251. --
  14252. --  Usage:
  14253. --  -----
  14254. --        Usage is analogous to usage of the Ada Sequential_Io 
  14255. --        package.  The package is instantiated with the element
  14256. --        type of the file as parameter.  CAIS file nodes 
  14257. --        correspond to ordinary Ada files, and file handles are 
  14258. --        Ada objects of CAIS subtype Sequential_Io.File_Type,
  14259. --        corresponding to Ada (LRM) Sequential_Io.File_Type.
  14260. --        CAIS Sequential_Io input and output operations 
  14261. --        access the contents of CAIS file nodes.
  14262. --
  14263. --  Notes:
  14264. --  -----
  14265. --        This is a version of the package CAIS.SEQUENTIAL_IO,
  14266. --        specified in MIL-STD-CAIS section 5.3.3; all references
  14267. --        to the CAIS specification refer to the CAIS specification
  14268. --        dated 31 January 1985.  This implementation deviates 
  14269. --        from the CAIS specification in that a distinct type,
  14270. --        File_Type is employed in the package, following the
  14271. --        Ada LRM.  The package instantiates another generic 
  14272. --        package, Sequential_Io_Definitions, that supports the 
  14273. --        abstract data type, File_Type.
  14274. --
  14275. --  Revision History:
  14276. --  ----------------
  14277. --        None.
  14278. --
  14279. -------------------------------------------------------------------
  14280.  
  14281.     generic
  14282.         type Element_Type is private; 
  14283.     package Sequential_Io is 
  14284.  
  14285.         use Node_Definitions; 
  14286.         use List_Utilities; 
  14287.  
  14288.         package Seq_Io_Definitions is 
  14289.             new Sequential_Io_Definitions(Element_Type); 
  14290.         use Seq_Io_Definitions; 
  14291.  
  14292.         subtype File_Type is Seq_Io_Definitions.File_Type; 
  14293.         subtype File_Mode is Seq_Io_Definitions.File_Mode; 
  14294.  
  14295.  
  14296. ----------------------     Create     ----------------------
  14297. --
  14298. --  Purpose:
  14299. --  -------
  14300. --        This procedure creates a file and its file node; the
  14301. --        file contains elements which may be accessed either
  14302. --        sequentially.  The attribute Access_Method is
  14303. --        assigned the value "(Sequential)" as part of the creation.
  14304. --
  14305. --  Parameters:
  14306. --  ----------
  14307. --    File    file handle, initially closed, to be opened.
  14308. --    Base    open node handle to the node which will be the
  14309. --        source of the primary relationship to the new
  14310. --        node.
  14311. --    Key    relationship key of the primary relationship to
  14312. --        be created.
  14313. --    Relation    relation name of the primary relationship to be created.
  14314. --    Mode    indicates mode of the file.
  14315. --    Form    indicates file characteristics.
  14316. --    Attributes
  14317. --        initial values for attributes of the new node.
  14318. --    Access_Control
  14319. --        defines the initial access control information
  14320. --        associated with the created node.
  14321. --    Level    defines the classification label for the created node.
  14322. --
  14323. --  Exceptions:
  14324. --  ----------
  14325. --    Name_Error
  14326. --        raised if a node already exists for the node specified
  14327. --        by Key and Relation or if Key or Relation is syntactically
  14328. --        illegal or if any node identifying a group specified in the
  14329. --        given Access_Control parameter is unobtainable.
  14330. --    Use_Error
  14331. --        raised if any of the parameters Access_Control, Level or
  14332. --        Attributes is syntactically or semantically illegal.
  14333. --        Use_Error is also raised if Relation is the name of a
  14334. --        predefined attribute other than File_Kind.  Also raised if
  14335. --        Relation is the name of a predefined relation which cannnot
  14336. --        be created by the user.
  14337. --    Status_Error
  14338. --        raised if Base is not an open node handle or if File is
  14339. --        an open file handle prior to the call.
  14340. --    Intent_Violation
  14341. --        raised if Base was not opened with an intent establishing
  14342. --        the right to append relationships.
  14343. --    Security_Violation
  14344. --        raised if the operation represents a violation of mandatory
  14345. --        access controls; raised only if the conditions for other
  14346. --        exceptions are not present.
  14347. --
  14348. --  Notes:
  14349. --  -----
  14350. --    This procedure is defined in section 5.3.3.2 of MIL-STD-CAIS,
  14351. --    dated 31 January 1985.
  14352. --    The additional interface for Create that is presented is
  14353. --    also provided.
  14354. --    NOTE:  The exception handler semantics of the additional
  14355. --    interface are not adequate.  The unconditional Close file
  14356. --    call may raise a Status_Error, causing the original
  14357. --    exception to be lost.
  14358. --
  14359. ---------------------------------------------------------------------
  14360.  
  14361.         procedure Create(File           : in out File_Type; 
  14362.                          Base           : in out Node_Type; 
  14363.                          Key            : Relationship_Key := Latest_Key; 
  14364.                          Relation       : Relation_Name := Default_Relation; 
  14365.                          Mode           : File_Mode := Inout_File; 
  14366.                          Form           : List_Type := Empty_List; 
  14367.                          Attributes     : List_Type := Empty_List; 
  14368.                          Access_Control : List_Type := Empty_List; 
  14369.                          Level          : List_Type := Empty_List); 
  14370.  
  14371.  
  14372.  
  14373. -------------------------------------------------------------------------------
  14374. --
  14375. --    Alternate interface using Name (pathname) rather than Base, Relation,
  14376. --    and Key to refer to file node.
  14377. --
  14378. -------------------------------------------------------------------------------
  14379.  
  14380.         procedure Create(File           : in out File_Type; 
  14381.                          Name           : Name_String; 
  14382.                          Mode           : File_Mode := Inout_File; 
  14383.                          Form           : List_Type := Empty_List; 
  14384.                          Attributes     : List_Type := Empty_List; 
  14385.                          Access_Control : List_Type := Empty_List; 
  14386.                          Level          : List_Type := Empty_List); 
  14387.  
  14388.  
  14389. ----------------------     Open     ----------------------
  14390. --
  14391. --  Purpose:
  14392. --  -------
  14393. --    This procedure opens a file handle on a file containing
  14394. --    elements of the generic parameter type, given an open node
  14395. --    handle on the file node.
  14396. --
  14397. --  Parameters:
  14398. --  ----------
  14399. --    File    file handle, initially closed, to be opened.
  14400. --    Node    open node handle to the file node.
  14401. --    Mode    indicates the mode of the file.
  14402. --
  14403. --  Exceptions:
  14404. --  ----------
  14405. --    Use_Error
  14406. --        raised if the attribute Access_Method of the file node
  14407. --        does not have the value Sequential or the element type of the
  14408. --        file does not correspond with the element type of this
  14409. --        instantiation of the CAIS Sequential_Io package.
  14410. --
  14411. --        also raised if the node identified by Node has a value of
  14412. --        Queue for the attribute File_Kind and a value of Mimic for
  14413. --        the attribute Queue_Kind and the mimic queue file identified
  14414. --        by File is being opened with Mode other than In_File but the
  14415. --        coupled file has been deleted.
  14416. --
  14417. --    Status_Error
  14418. --        raised if File is an open file handle at the time of the call
  14419. --        or if Node is not an open node handle.
  14420. --
  14421. --    Intent_Violation
  14422. --        raised if Node has not been opened with an intent 
  14423. --        establishing the access rights required for the Mode.
  14424. --
  14425. --  Notes:
  14426. --  -----
  14427. --    This procedure is defined in section 5.3.3.3 of MIL-STD-CAIS,
  14428. --    dated 31 January 1985.
  14429. --    The additional interface for Open that is presented is
  14430. --    also provided.
  14431. --    NOTE:  The exception handler semantics of the additional
  14432. --    interface are not adequate.  The unconditional Close file
  14433. --    call may raise a Status_Error, causing the original
  14434. --    exception to be lost.
  14435. --
  14436. ---------------------------------------------------------------------
  14437.  
  14438.         procedure Open(File : in out File_Type; 
  14439.                        Node : Node_Type; 
  14440.                        Mode : File_Mode); 
  14441.  
  14442.  
  14443. -------------------------------------------------------------------------------
  14444. --
  14445. --    Alternate interface using Name (pathname) rather than Base, Relation,
  14446. --    and Key to refer to file node.
  14447. --
  14448. -------------------------------------------------------------------------------
  14449.  
  14450.         procedure Open(File : in out File_Type; 
  14451.                        Name : Name_String; 
  14452.                        Mode : File_Mode); 
  14453.  
  14454. ----------------------     Close     ----------------------
  14455. --
  14456. --  Purpose:
  14457. --  -------
  14458. --    Closes file handle to CAIS file node.
  14459. --
  14460. --  Parameters:
  14461. --  ----------
  14462. --    File    open file handle.
  14463. --
  14464. --  Exceptions:
  14465. --  ----------
  14466. --    Status_Error
  14467. --        raised if file handle is not open.
  14468. --
  14469. --  Notes:
  14470. --  -----
  14471. --    Semantics correspond to Ada LRM, Section 14.2.1
  14472. --
  14473. ---------------------------------------------------------------------
  14474.  
  14475.         procedure Close(File : in out File_Type); 
  14476.  
  14477. ----------------------     Delete     ----------------------
  14478. --
  14479. --  Purpose:
  14480. --  -------
  14481. --    This procedure deletes the CAIS file identified
  14482. --    by File.  
  14483. --    In addition to the semantics specified in the LRM,
  14484. --    the node associated with the open file handle File
  14485. --    is made unobtainable as if a call to the Delete_Node
  14486. --    procedure had been made.
  14487. --
  14488. --  Parameters:
  14489. --  ----------
  14490. --    File    an open file handle on the file being deleted.
  14491. --
  14492. --  Exceptions:
  14493. --  ----------
  14494. --    Name_Error
  14495. --        raised if the parent node of the node associated with
  14496. --        the file identified by File is inaccessible.
  14497. --    Use_Error
  14498. --        raised if any primary relationships emanate from the
  14499. --        node associated with the file identified by File.
  14500. --    Status_Error
  14501. --        raised if File is not an open file handle.
  14502. --    Lock_Error
  14503. --        raised if access with intent Write_Relationships to the
  14504. --        parent of the node to be deleted cannot be obtained due
  14505. --        to an existing lock on the node.
  14506. --    Access_Violation
  14507. --        raised if the current process does not have sufficient
  14508. --        discretionary access control rights to obtain access to
  14509. --        the parent of the node to be deleted with intent
  14510. --        Exclusive_Write; only raised if the conditions for
  14511. --        Name_Error are not present.
  14512. --    Security_Violation
  14513. --        raised if the operation represents a violation of mandatory
  14514. --        access controls; raised only if the conditions for other
  14515. --        exceptions are not present.
  14516. --
  14517. --  Notes:
  14518. --  -----
  14519. --    This procedure is defined in section 5.3.3.4 of MIL-STD-CAIS,
  14520. --    dated 31 January 1985.
  14521. --
  14522. ---------------------------------------------------------------------
  14523.  
  14524.         procedure Delete(File : in out File_Type); 
  14525.  
  14526. ----------------------     Reset     ----------------------
  14527. --
  14528. --  Purpose:
  14529. --  -------
  14530. --    Reset the file mode of a CAIS file.
  14531. --
  14532. --  Parameters:
  14533. --  ----------
  14534. --    File    An open file handle on the file being reset.
  14535. --    Mode    Indicates the mode of the file.
  14536. --
  14537. --  Exceptions:
  14538. --  ----------
  14539. --    See note.
  14540. --
  14541. --  Notes:
  14542. --  -----
  14543. --    This procedure is defined as in section 5.3.4.5 of MIL-STD-CAIS,
  14544. --    dated 31 January 1985.
  14545. --    Semantics of this procedure are not restricted to Ada LRM
  14546. --    semantics, pending clarification of the interaction of access
  14547. --    methods in the CAIS.
  14548. --
  14549. --    Although no exceptions are defined in the CAIS, checking of
  14550. --    Status_Error and Use_Error for invalid mode is done.
  14551. ---------------------------------------------------------------------
  14552.  
  14553.         procedure Reset(File : in out File_Type; 
  14554.                         Mode : File_Mode); 
  14555. ----------------------     Reset     ----------------------
  14556. --
  14557. --  Purpose:
  14558. --  -------
  14559. --    Reset a CAIS file.
  14560. --
  14561. --  Parameters:
  14562. --  ----------
  14563. --    File    An open file handle on the file being reset.
  14564. --
  14565. --  Exceptions:
  14566. --  ----------
  14567. --    None raised.
  14568. --
  14569. --  Notes:
  14570. --  -----
  14571. --    This procedure is defined as in section 5.3.4.5 of MIL-STD-CAIS,
  14572. --    dated 31 January 1985.
  14573. --    Semantics of this procedure are not restricted to Ada LRM
  14574. --    semantics, pending clarification of the interaction of access
  14575. --    methods in the CAIS.
  14576. ---------------------------------------------------------------------
  14577.  
  14578.         procedure Reset(File : in out File_Type); 
  14579.  
  14580. ----------------------     Mode     ----------------------
  14581. --
  14582. --  Purpose:
  14583. --  -------
  14584. --    Returns the current mode of the current CAIS file.
  14585. --
  14586. --  Parameters:
  14587. --  ----------
  14588. --    File    open file handle.
  14589. --
  14590. --  Exceptions:
  14591. --  ----------
  14592. --    Status_Error
  14593. --        raised if file handle is not open.
  14594. --
  14595. --  Notes:
  14596. --  -----
  14597. --    Semantics correspond to Ada LRM, Section 14.2.1
  14598. --
  14599. ---------------------------------------------------------------------
  14600.  
  14601.         function Mode(File : File_Type) return File_Mode; 
  14602. ----------------------     Name     ----------------------
  14603. --
  14604. --  Purpose:
  14605. --  -------
  14606. --    Returns a string containing the name of the CAIS file 
  14607. --    node currently associated with the file handle.
  14608. --
  14609. --  Parameters:
  14610. --  ----------
  14611. --    File    open file handle.
  14612. --
  14613. --  Exceptions:
  14614. --  ----------
  14615. --    Status_Error
  14616. --        raised if file handle is not open.
  14617. --
  14618. --  Notes:
  14619. --  -----
  14620. --    Semantics correspond to Ada LRM, Section 14.2.1
  14621. --
  14622. ---------------------------------------------------------------------
  14623.  
  14624.         function Name(File : File_Type) return String; 
  14625. ----------------------     Form     ----------------------
  14626. --
  14627. --  Purpose:
  14628. --  -------
  14629. --    Returns the form string for the external file currently
  14630. --    associated with the given file.
  14631. --
  14632. --  Parameters:
  14633. --  ----------
  14634. --    File    open file handle.
  14635. --
  14636. --  Exceptions:
  14637. --  ----------
  14638. --    Status_Error
  14639. --        raised if file handle is not open.
  14640. --
  14641. --  Notes:
  14642. --  -----
  14643. --    Semantics correspond to Ada LRM, Section 14.2.1
  14644. --
  14645. ---------------------------------------------------------------------
  14646.  
  14647.         function Form(File : File_Type) return String; 
  14648.  
  14649. ----------------------     Is_Open     ----------------------
  14650. --
  14651. --  Purpose:
  14652. --  -------
  14653. --    Returns TRUE if the file handle is open, otherwise returns FALSE.
  14654. --
  14655. --  Parameters:
  14656. --  ----------
  14657. --    File    file handle.
  14658. --
  14659. --  Exceptions:
  14660. --  ----------
  14661. --    None.
  14662. --
  14663. --  Notes:
  14664. --  -----
  14665. --    Semantics correspond to Ada LRM, Section 14.2.1
  14666. --
  14667. ---------------------------------------------------------------------
  14668.  
  14669.         function Is_Open(File : File_Type) return Boolean; 
  14670.  
  14671.  
  14672. ---------------------------     Read     ---------------------------
  14673. --
  14674. --  Purpose:
  14675. --  -------
  14676. --    Reads an element from the given file, and returns the value
  14677. --    of this element in the Item parameter.
  14678. --
  14679. --  Parameters:
  14680. --  ----------
  14681. --    File    open file handle.
  14682. --    Item    returns element read from file.
  14683. --
  14684. --  Exceptions:
  14685. --  ----------
  14686. --    Status_Error
  14687. --        raised if file handle is not open.
  14688. --    Mode_Error
  14689. --        raised if the mode is not In_File.
  14690. --    End_Error
  14691. --        raised if no more elements can be read from the
  14692. --        given file.
  14693. --    Data_Error
  14694. --        raised if the element read cannot be interpreted
  14695. --        as a value of the generic parameter type.
  14696. --
  14697. --  Notes:
  14698. --  -----
  14699. --    Semantics follow Ada LRM Section 14.2.2.
  14700. --
  14701. ---------------------------------------------------------------------
  14702.  
  14703.         procedure Read(File : File_Type; 
  14704.                        Item : in out Element_Type); 
  14705. ---------------------------     Write     ---------------------------
  14706. --
  14707. --  Purpose:
  14708. --  -------
  14709. --    Writes the value of Item to the given file.
  14710. --
  14711. --  Parameters:
  14712. --  ----------
  14713. --    File    open file handle.
  14714. --    Item    element to be written to the file.
  14715. --
  14716. --  Exceptions:
  14717. --  ----------
  14718. --    Status_Error
  14719. --        raised if file handle is not open.
  14720. --    Mode_Error
  14721. --        raised if mode is not Out_File.
  14722. --    Use_Error
  14723. --        raised if the capacity of the file is exceeded.
  14724. --
  14725. --  Notes:
  14726. --  -----
  14727. --    Semantics follow Ada LRM Section 14.2.2.
  14728. --
  14729. ---------------------------------------------------------------------
  14730.  
  14731.         procedure Write(File : File_Type; 
  14732.                         Item : Element_Type); 
  14733.  
  14734. ----------------------     End_Of_File     ----------------------
  14735. --
  14736. --  Purpose:
  14737. --  -------
  14738. --    Returns True if no more elements can be read from the
  14739. --    given file;  otherwise returns False.
  14740. --
  14741. --  Parameters:
  14742. --  ----------
  14743. --    File    open file handle.
  14744. --
  14745. --  Exceptions:
  14746. --  ----------
  14747. --    Status_Error
  14748. --        raised if file handle is not open.
  14749. --    Mode_Error
  14750. --        raised if file mode is not In_File.
  14751. --
  14752. --  Notes:
  14753. --  -----
  14754. --    Semantics follow Ada LRM Section 14.2.2.
  14755. --
  14756. ---------------------------------------------------------------------
  14757.  
  14758.         function End_Of_File(File : File_Type) return Boolean; 
  14759.  
  14760. ---------------------------------------------------------------------
  14761.     end Sequential_Io; 
  14762. ---------------------------------------------------------------------
  14763.  
  14764. ----------------------------------------------------------------------
  14765. --                     T E X T _ I O
  14766. --
  14767. --  Purpose:
  14768. --  -------
  14769. --        This package comprises the CAIS Input/Output operations
  14770. --        on text files, which correspond to those in Ada LRM
  14771. --        Chapter 14 I/O.  Input and output operations access
  14772. --        the contents of CAIS file nodes.  Generic packages
  14773. --        for text input/output of integer, enumeration, fixed and
  14774. --        float types are nested in CAIS Text_Io, as they are in
  14775. --        Ada (Ch. 14) I/O.  Additional interfaces to manage Standard
  14776. --        and Current Error files are provided.
  14777. --
  14778. --  Usage:
  14779. --  -----
  14780. --        Usage is analogous to usage of the Ada Text_Io package.
  14781. --        CAIS file nodes correspond to ordinary Ada files, and
  14782. --        file handles are Ada objects of type CAIS Text_Io.File_Type,
  14783. --        rather than Ada (LRM) Text_Io.File_Type.
  14784. --
  14785. --  Notes:
  14786. --  -----
  14787. --        This is a version of the package CAIS.TEXT_IO,
  14788. --        specified in MIL-STD-CAIS section 5.3.4; all references
  14789. --        to the CAIS specification refer to the CAIS specification
  14790. --        dated 31 January 1985.
  14791. --
  14792. --  Revision History:
  14793. --  ----------------
  14794. --        None.
  14795. --
  14796. -------------------------------------------------------------------
  14797.  
  14798.     package Text_Io is 
  14799.  
  14800.         use Node_Definitions; 
  14801.         use List_Utilities; 
  14802.         use Cais.Io_Definitions; 
  14803.  
  14804.         type Count is range 0 .. Integer'Last; 
  14805.  
  14806.         subtype Positive_Count is Count range 1 .. Count'Last; 
  14807.  
  14808.         Unbounded : constant Count := 0; 
  14809.                                      --Line and page length
  14810.  
  14811.         subtype Field is Integer range 0 .. Integer'Last; 
  14812.         subtype Number_Base is Integer range 2 .. 16; 
  14813.  
  14814.         type Type_Set is (Lower_Case, Upper_Case); 
  14815.  
  14816. --MIL STD 5.3.4.1
  14817.         subtype File_Type is Cais.Io_Definitions.File_Type; 
  14818.         subtype File_Mode is Cais.Io_Definitions.File_Mode; 
  14819.  
  14820. --not in CAIS, additional interface
  14821.  
  14822.         In_File     : constant File_Mode := Cais.Io_Definitions.In_File; 
  14823.         Inout_File  : constant File_Mode := Cais.Io_Definitions.Inout_File; 
  14824.         Out_File    : constant File_Mode := Cais.Io_Definitions.Out_File; 
  14825.         Append_File : constant File_Mode := Cais.Io_Definitions.Append_File; 
  14826.  
  14827.  
  14828.  
  14829. ----------------------     Create     ----------------------
  14830. --
  14831. --  Purpose:
  14832. --  -------
  14833. --        This procedure creates a file and its file node; the
  14834. --        file is textual.  The attribute Access_Method is
  14835. --        assigned the value "(Text)" as part of the creation.
  14836. --
  14837. --  Parameters:
  14838. --  ----------
  14839. --    File    file handle, initially closed, to be opened.
  14840. --    Base    open node handle to the node which will be the
  14841. --        source of the primary relationship to the new
  14842. --        node.
  14843. --    Key    relationship key of the primary relationship to
  14844. --        be created.
  14845. --    Relation    relation name of the primary relationship to be created.
  14846. --    Mode    indicates mode of the file.
  14847. --    Form    indicates file characteristics.
  14848. --    Attributes
  14849. --        initial values for attributes of the new node.
  14850. --    Access_Control
  14851. --        defines the initial access control information
  14852. --        associated with the created node.
  14853. --    Level    defines the classification label for the created node.
  14854. --
  14855. --  Exceptions:
  14856. --  ----------
  14857. --    Name_Error
  14858. --        raised if a node already exists for the node specified
  14859. --        by Key and Relation or if Key or Relation is syntactically
  14860. --        illegal or if any node identifying a group specified in the
  14861. --        given Access_Control parameter is unobtainable.
  14862. --    Use_Error
  14863. --        raised if any of the parameters Access_Control, Level or
  14864. --        Attributes is syntactically or semantically illegal.
  14865. --        Use_Error is also raised if Relation is the name of a
  14866. --        predefined attribute other than File_Kind.  Also raised if
  14867. --        Relation is the name of a predefined relation which cannnot
  14868. --        be created by the user.
  14869. --    Status_Error
  14870. --        raised if Base is not an open node handle or if File is
  14871. --        an open file handle prior to the call.
  14872. --    Intent_Violation
  14873. --        raised if Base was not opened with an intent establishing
  14874. --        the right to append relationships.
  14875. --    Security_Violation
  14876. --        raised if the operation represents a violation of mandatory
  14877. --        access controls; raised only if the conditions for other
  14878. --        exceptions are not present.
  14879. --
  14880. --  Notes:
  14881. --  -----
  14882. --    This procedure is defined in section 5.3.4.2 of MIL-STD-CAIS,
  14883. --    dated 31 January 1985.
  14884. --    The additional interface for Create that is presented is
  14885. --    also provided.
  14886. --    NOTE:  The exception handler semantics of the additional
  14887. --    interface are not adequate.  The unconditional Close file
  14888. --    call may raise a Status_Error, causing the original
  14889. --    exception to be lost.
  14890. --
  14891. ---------------------------------------------------------------------
  14892.  
  14893.         procedure Create(File           : in out File_Type; 
  14894.                          Base           : in out Node_Type; 
  14895.                          Key            : Relationship_Key := Latest_Key; 
  14896.                          Relation       : Relation_Name := Default_Relation; 
  14897.                          Mode           : File_Mode := Inout_File; 
  14898.                          Form           : List_Type := Empty_List; 
  14899.                          Attributes     : List_Type := Empty_List; 
  14900.                          Access_Control : List_Type := Empty_List; 
  14901.                          Level          : List_Type := Empty_List); 
  14902.  
  14903.  
  14904. -------------------------------------------------------------------------------
  14905. --
  14906. --    Alternate interface using Name (pathname) rather than Base, Relation,
  14907. --    and Key to refer to file node.
  14908. --
  14909. -------------------------------------------------------------------------------
  14910.  
  14911.         procedure Create(File           : in out File_Type; 
  14912.                          Name           : Name_String; 
  14913.                          Mode           : File_Mode := Inout_File; 
  14914.                          Form           : List_Type := Empty_List; 
  14915.                          Attributes     : List_Type := Empty_List; 
  14916.                          Access_Control : List_Type := Empty_List; 
  14917.                          Level          : List_Type := Empty_List); 
  14918.  
  14919.  
  14920. ----------------------     Open     ----------------------
  14921. --
  14922. --  Purpose:
  14923. --  -------
  14924. --    This procedure opens a file handle on a file that
  14925. --    has textual content, given an open node handle on
  14926. --    the file node.
  14927. --
  14928. --  Parameters:
  14929. --  ----------
  14930. --    File    file handle, initially closed, to be opened.
  14931. --    Node    open node handle to the file node.
  14932. --    Mode    indicates the mode of the file.
  14933. --
  14934. --  Exceptions:
  14935. --  ----------
  14936. --    Use_Error
  14937. --        raised if the attribute Access_Method of the file node
  14938. --        does not have the value Text or the element type of the
  14939. --        file does not correspond with the element type of this
  14940. --        instantiation of the CAIS Text_Io package.
  14941. --
  14942. --        also raised if the node identified by Node has a value of
  14943. --        Queue for the attribute File_Kind and a value of Mimic for
  14944. --        the attribute Queue_Kind and the mimic queue file identified
  14945. --        by File is being opened with Mode other than In_File but the
  14946. --        coupled file has been deleted.
  14947. --
  14948. --        also raised if the node identified by Node has a value of
  14949. --        Terminal or Magnetic_Tape for the attribute File_Kind and the
  14950. --        Mode is Append_File.
  14951. --    Status_Error
  14952. --        raised if File is an open file handle at the time of the call
  14953. --        or if Node is not an open node handle.
  14954. --    Intent_Violation
  14955. --        raised if Node has not been opened with an intent 
  14956. --        establishing the access rights required for the Mode.
  14957. --
  14958. --  Notes:
  14959. --  -----
  14960. --    This procedure is defined in section 5.3.4.3 of MIL-STD-CAIS,
  14961. --    dated 31 January 1985.
  14962. --    The additional interface for Open that is presented is
  14963. --    also provided.
  14964. --    NOTE:  The exception handler semantics of the additional
  14965. --    interface are not adequate.  The unconditional Close file
  14966. --    call may raise a Status_Error, causing the original
  14967. --    exception to be lost.
  14968. --
  14969. ---------------------------------------------------------------------
  14970.  
  14971.         procedure Open(File : in out File_Type; 
  14972.                        Node : Node_Type; 
  14973.                        Mode : File_Mode); 
  14974.  
  14975.  
  14976. -------------------------------------------------------------------------------
  14977. --
  14978. --    Alternate interface using Name (pathname) rather than Base, Relation,
  14979. --    and Key to refer to file node.
  14980. --
  14981. -------------------------------------------------------------------------------
  14982.  
  14983.         procedure Open(File : in out File_Type; 
  14984.                        Name : Name_String; 
  14985.                        Mode : File_Mode); 
  14986.  
  14987. ----------------------     Close     ----------------------
  14988. --
  14989. --  Purpose:
  14990. --  -------
  14991. --    Closes file handle to CAIS file node.
  14992. --
  14993. --  Parameters:
  14994. --  ----------
  14995. --    File    open file handle.
  14996. --
  14997. --  Exceptions:
  14998. --  ----------
  14999. --    Status_Error
  15000. --        raised if file handle is not open.
  15001. --
  15002. --  Notes:
  15003. --  -----
  15004. --    Semantics correspond to Ada LRM, Section 14.2.1
  15005. --
  15006. ---------------------------------------------------------------------
  15007.  
  15008.         procedure Close(File : in out File_Type); 
  15009.  
  15010. ----------------------     Delete     ----------------------
  15011. --
  15012. --  Purpose:
  15013. --  -------
  15014. --    This procedure deletes the CAIS file identified
  15015. --    by File.  
  15016. --    In addition to the semantics specified in the LRM,
  15017. --    the node associated with the open file handle File
  15018. --    is made unobtainable as if a call to the Delete_Node
  15019. --    procedure had been made.
  15020. --
  15021. --  Parameters:
  15022. --  ----------
  15023. --    File    an open file handle on the file being deleted.
  15024. --
  15025. --  Exceptions:
  15026. --  ----------
  15027. --    Name_Error
  15028. --        raised if the parent node of the node associated with
  15029. --        the file identified by File is inaccessible.
  15030. --    Use_Error
  15031. --        raised if any primary relationships emanate from the
  15032. --        node associated with the file identified by File.
  15033. --    Status_Error
  15034. --        raised if File is not an open file handle.
  15035. --    Lock_Error
  15036. --        raised if access with intent Write_Relationships to the
  15037. --        parent of the node to be deleted cannot be obtained due
  15038. --        to an existing lock on the node.
  15039. --    Access_Violation
  15040. --        raised if the current process does not have sufficient
  15041. --        discretionary access control rights to obtain access to
  15042. --        the parent of the node to be deleted with intent
  15043. --        Exclusive_Write; only raised if the conditions for
  15044. --        Name_Error are not present.
  15045. --    Security_Violation
  15046. --        raised if the operation represents a violation of mandatory
  15047. --        access controls; raised only if the conditions for other
  15048. --        exceptions are not present.
  15049. --
  15050. --  Notes:
  15051. --  -----
  15052. --    This procedure is defined in section 5.3.4.4 of MIL-STD-CAIS,
  15053. --    dated 31 January 1985.
  15054. --
  15055. ---------------------------------------------------------------------
  15056.  
  15057.         procedure Delete(File : in out File_Type); 
  15058. ----------------------     Reset     ----------------------
  15059. --
  15060. --  Purpose:
  15061. --  -------
  15062. --    Reset a CAIS file.
  15063. --
  15064. --  Parameters:
  15065. --  ----------
  15066. --    File    An open file handle on the file being reset.
  15067. --
  15068. --  Exceptions:
  15069. --  ----------
  15070. --    Use_Error
  15071. --        raised if the node associated with the file identified
  15072. --        by File has a value of Terminal or Magnetic_Tape for
  15073. --        the attribute File_Kind and the Mode is Append_File.
  15074. --
  15075. --  Notes:
  15076. --  -----
  15077. --    This procedure is defined in section 5.3.4.5 of MIL-STD-CAIS,
  15078. --    dated 31 January 1985.
  15079. ---------------------------------------------------------------------
  15080.  
  15081.         procedure Reset(File : in out File_Type); 
  15082. ----------------------     Reset     ----------------------
  15083. --
  15084. --  Purpose:
  15085. --  -------
  15086. --    Reset the file mode of a CAIS file.
  15087. --
  15088. --  Parameters:
  15089. --  ----------
  15090. --    File    An open file handle on the file being reset.
  15091. --    Mode    Indicates the mode of the file.
  15092. --
  15093. --  Exceptions:
  15094. --  ----------
  15095. --    Use_Error
  15096. --        raised if the node associated with the file identified
  15097. --        by File has a value of Terminal or Magnetic_Tape for
  15098. --        the attribute File_Kind and the Mode is Append_File.
  15099. --
  15100. --  Notes:
  15101. --  -----
  15102. --    This procedure is defined in section 5.3.4.5 of MIL-STD-CAIS,
  15103. --    dated 31 January 1985.
  15104. ---------------------------------------------------------------------
  15105.  
  15106.         procedure Reset(File : in out File_Type; 
  15107.                         Mode : File_Mode); 
  15108.  
  15109. ----------------------     Mode     ----------------------
  15110. --
  15111. --  Purpose:
  15112. --  -------
  15113. --    Returns the current mode of the current CAIS file.
  15114. --
  15115. --  Parameters:
  15116. --  ----------
  15117. --    File    open file handle.
  15118. --
  15119. --  Exceptions:
  15120. --  ----------
  15121. --    Status_Error
  15122. --        raised if file handle is not open.
  15123. --
  15124. --  Notes:
  15125. --  -----
  15126. --    Semantics correspond to Ada LRM, Section 14.2.1
  15127. --
  15128. ---------------------------------------------------------------------
  15129.  
  15130.         function Mode(File : File_Type) return File_Mode; 
  15131. ----------------------     Name     ----------------------
  15132. --
  15133. --  Purpose:
  15134. --  -------
  15135. --    Returns a string containing the name of the CAIS file 
  15136. --    node currently associated with the file handle.
  15137. --
  15138. --  Parameters:
  15139. --  ----------
  15140. --    File    open file handle.
  15141. --
  15142. --  Exceptions:
  15143. --  ----------
  15144. --    Status_Error
  15145. --        raised if file handle is not open.
  15146. --
  15147. --  Notes:
  15148. --  -----
  15149. --    Semantics correspond to Ada LRM, Section 14.2.1
  15150. --
  15151. ---------------------------------------------------------------------
  15152.  
  15153.         function Name(File : File_Type) return String; 
  15154. ----------------------     Form     ----------------------
  15155. --
  15156. --  Purpose:
  15157. --  -------
  15158. --    Returns the form string for the external file currently
  15159. --    associated with the given file.
  15160. --
  15161. --  Parameters:
  15162. --  ----------
  15163. --    File    open file handle.
  15164. --
  15165. --  Exceptions:
  15166. --  ----------
  15167. --    Status_Error
  15168. --        raised if file handle is not open.
  15169. --
  15170. --  Notes:
  15171. --  -----
  15172. --    Semantics correspond to Ada LRM, Section 14.2.1
  15173. --
  15174. ---------------------------------------------------------------------
  15175.  
  15176.         function Form(File : File_Type) return String; 
  15177.  
  15178. ----------------------     Is_Open     ----------------------
  15179. --
  15180. --  Purpose:
  15181. --  -------
  15182. --    Returns TRUE if the file handle is open, otherwise returns FALSE.
  15183. --
  15184. --  Parameters:
  15185. --  ----------
  15186. --    File    file handle.
  15187. --
  15188. --  Exceptions:
  15189. --  ----------
  15190. --    None.
  15191. --
  15192. --  Notes:
  15193. --  -----
  15194. --    Semantics correspond to Ada LRM, Section 14.2.1
  15195. --
  15196. ---------------------------------------------------------------------
  15197.  
  15198.         function Is_Open(File : File_Type) return Boolean; 
  15199.  
  15200.  
  15201. ----------------------     Set_Input     ----------------------
  15202. --
  15203. --  Purpose:
  15204. --  -------
  15205. --    Sets the current default input file to File.
  15206. --    In addition to the semantics specified in the Ada LRM, the
  15207. --    file node associated with the file identified by File becomes
  15208. --    the target of the relationship of the predefined relation
  15209. --    Current_Input of the current process node.
  15210. --
  15211. --  Parameters:
  15212. --  ----------
  15213. --    File    an open file handle.
  15214. --
  15215. --  Exceptions:
  15216. --  ----------
  15217. --    Mode_Error
  15218. --        raised if the mode of the file identified by File
  15219. --        is Out_File or Append_File.
  15220. --    Status_Error
  15221. --        raised if File is not an open file handle.
  15222. --    Lock_Error
  15223. --        raised if the current process node is locked against
  15224. --        writing relationships.
  15225. --
  15226. --  Notes:
  15227. --  -----
  15228. --    This procedure is defined in section 5.3.4.8 of MIL-STD-CAIS,
  15229. --    dated 31 January 1985.
  15230. --
  15231. ---------------------------------------------------------------------
  15232.  
  15233.         procedure Set_Input(File : File_Type); 
  15234.  
  15235. ----------------------     Set_Output     ----------------------
  15236. --
  15237. --  Purpose:
  15238. --  -------
  15239. --    Sets the current default output file to File.
  15240. --    In addition to the semantics specified in the Ada LRM, the
  15241. --    file node associated with the file identified by File becomes
  15242. --    the target of the relationship of the predefined relation
  15243. --    Current_Output of the current process node.
  15244. --
  15245. --  Parameters:
  15246. --  ----------
  15247. --    File    an open file handle.
  15248. --
  15249. --  Exceptions:
  15250. --  ----------
  15251. --    Mode_Error
  15252. --        raised if the mode of the file identified by File
  15253. --        is In_File
  15254. --    Status_Error
  15255. --        raised if File is not an open file handle.
  15256. --    Lock_Error
  15257. --        raised if the current process node is locked against
  15258. --        writing relationships.
  15259. --
  15260. --  Notes:
  15261. --  -----
  15262. --    This procedure is defined in section 5.3.4.9 of MIL-STD-CAIS,
  15263. --    dated 31 January 1985.
  15264. --
  15265. ---------------------------------------------------------------------
  15266.  
  15267.         procedure Set_Output(File : File_Type); 
  15268.  
  15269. ----------------------     Set_Error     ----------------------
  15270. --
  15271. --  Purpose:
  15272. --  -------
  15273. --    Sets the current default error file to File.  The
  15274. --    file node associated with the file identified by File becomes
  15275. --    the target of the relationship of the predefined relation
  15276. --    Current_Error of the current process node.
  15277. --
  15278. --  Parameters:
  15279. --  ----------
  15280. --    File    an open file handle.
  15281. --
  15282. --  Exceptions:
  15283. --  ----------
  15284. --    Mode_Error
  15285. --        raised if the mode of the file identified by File
  15286. --        is In_File
  15287. --    Status_Error
  15288. --        raised if File is not an open file handle.
  15289. --    Lock_Error
  15290. --        raised if the current process node is locked against
  15291. --        writing relationships.
  15292. --
  15293. --  Notes:
  15294. --  -----
  15295. --    This procedure is defined in section 5.3.4.9 of MIL-STD-CAIS,
  15296. --    dated 31 January 1985.
  15297. --
  15298. ---------------------------------------------------------------------
  15299.  
  15300.         procedure Set_Error(File : File_Type); 
  15301.  
  15302. ----------------------     Standard_Input     ----------------------
  15303. --
  15304. --  Purpose:
  15305. --  -------
  15306. --    This function returns an open file handle to the target node
  15307. --    of the relationship of the predefined relation Standard_Input
  15308. --    that was set at the start of program execution.
  15309. --
  15310. --  Parameters:
  15311. --  ----------
  15312. --    None.
  15313. --
  15314. --  Exceptions:
  15315. --  ----------
  15316. --    Lock_Error
  15317. --        raised if the current process node is locked against
  15318. --        reading relationships.
  15319. --
  15320. --  Notes:
  15321. --  -----
  15322. --    This procedure is defined as in section 5.3.4.11 of MIL-STD-CAIS,
  15323. --    dated 31 January 1985.
  15324. --
  15325. ---------------------------------------------------------------------
  15326.  
  15327.         function Standard_Input return File_Type; 
  15328.  
  15329. ----------------------     Standard_Output     ----------------------
  15330. --
  15331. --  Purpose:
  15332. --  -------
  15333. --    This function returns an open file handle to the target node
  15334. --    of the relationship of the predefined relation Standard_Output
  15335. --    that was set at the start of program execution.
  15336. --
  15337. --  Parameters:
  15338. --  ----------
  15339. --    None.
  15340. --
  15341. --  Exceptions:
  15342. --  ----------
  15343. --    Lock_Error
  15344. --        raised if the current process node is locked against
  15345. --        reading relationships.
  15346. --
  15347. --  Notes:
  15348. --  -----
  15349. --    This procedure is defined as in section 5.3.4.11 of MIL-STD-CAIS,
  15350. --    dated 31 January 1985.
  15351. --
  15352. ---------------------------------------------------------------------
  15353.  
  15354.         function Standard_Output return File_Type; 
  15355.  
  15356. ----------------------     Standard_Error     ----------------------
  15357. --
  15358. --  Purpose:
  15359. --  -------
  15360. --    This function returns an open file handle to the target node
  15361. --    of the relationship of the predefined relation Standard_Error
  15362. --    that was set at the start of program execution.
  15363. --
  15364. --  Parameters:
  15365. --  ----------
  15366. --    None.
  15367. --
  15368. --  Exceptions:
  15369. --  ----------
  15370. --    Lock_Error
  15371. --        raised if the current process node is locked against
  15372. --        reading relationships.
  15373. --
  15374. --  Notes:
  15375. --  -----
  15376. --    This procedure is defined in section 5.3.4.11 of MIL-STD-CAIS,
  15377. --    dated 31 January 1985.
  15378. --
  15379. ---------------------------------------------------------------------
  15380.  
  15381.         function Standard_Error return File_Type; 
  15382.  
  15383. ----------------------     Current_Input     ----------------------
  15384. --
  15385. --  Purpose:
  15386. --  -------
  15387. --    This function returns an open file handle to the target node
  15388. --    of the relationship of the predefined relation Current_Input
  15389. --    which is either the standard input file or the file specified
  15390. --    in the most recent invocation of Set_Input in the current process.
  15391. --
  15392. --  Parameters:
  15393. --  ----------
  15394. --    None.
  15395. --
  15396. --  Exceptions:
  15397. --  ----------
  15398. --    Lock_Error
  15399. --        raised if the current process node is locked against
  15400. --        reading relationships.
  15401. --
  15402. --  Notes:
  15403. --  -----
  15404. --    This procedure is defined as in section 5.3.4.12 of MIL-STD-CAIS,
  15405. --    dated 31 January 1985.
  15406. --
  15407. ---------------------------------------------------------------------
  15408.  
  15409.         function Current_Input return File_Type; 
  15410.  
  15411. ----------------------     Current_Output     ----------------------
  15412. --
  15413. --  Purpose:
  15414. --  -------
  15415. --    This function returns an open file handle to the target node
  15416. --    of the relationship of the predefined relation Current_Output
  15417. --    which is either the standard output file or the file specified
  15418. --    in the most recent invocation of Set_Output in the current process.
  15419. --
  15420. --  Parameters:
  15421. --  ----------
  15422. --    None.
  15423. --
  15424. --  Exceptions:
  15425. --  ----------
  15426. --    Lock_Error
  15427. --        raised if the current process node is locked against
  15428. --        reading relationships.
  15429. --
  15430. --  Notes:
  15431. --  -----
  15432. --    This procedure is defined as in section 5.3.4.12 of MIL-STD-CAIS,
  15433. --    dated 31 January 1985.
  15434. --
  15435. ---------------------------------------------------------------------
  15436.  
  15437.         function Current_Output return File_Type; 
  15438.  
  15439. ----------------------     Current_Error     ----------------------
  15440. --
  15441. --  Purpose:
  15442. --  -------
  15443. --    This function returns an open file handle to the target node
  15444. --    of the relationship of the predefined relation Current_Error
  15445. --    which is either the standard error file or the file specified
  15446. --    in the most recent invocation of Set_Error in the current process.
  15447. --
  15448. --  Parameters:
  15449. --  ----------
  15450. --    None.
  15451. --
  15452. --  Exceptions:
  15453. --  ----------
  15454. --    Lock_Error
  15455. --        raised if the current process node is locked against
  15456. --        reading relationships.
  15457. --
  15458. --  Notes:
  15459. --  -----
  15460. --    This procedure is defined in section 5.3.4.12 of MIL-STD-CAIS,
  15461. --    dated 31 January 1985.
  15462. --
  15463. ---------------------------------------------------------------------
  15464.  
  15465.         function Current_Error return File_Type; 
  15466.  
  15467.  
  15468. ----------------------     Set_Line_Length     ----------------------
  15469. --
  15470. --  Purpose:
  15471. --  -------
  15472. --    Sets the maximum line length of the specified output file to the
  15473. --    number of characters specified by To.  The value 0 for To specifies an
  15474. --    unbounded line length.
  15475. --
  15476. --  Parameters:
  15477. --  ----------
  15478. --    File    open file handle.
  15479. --    To    number to which bound is to be set.
  15480. --
  15481. --  Exceptions:
  15482. --  ----------
  15483. --    Status_Error
  15484. --        raised if file is not open.
  15485. --    Mode_Error
  15486. --        raised if mode of the file is not Out_File or Append_File.
  15487. --    Use_Error
  15488. --        raised if the specified line length is inappropriate for
  15489. --        the associated external file.
  15490. --
  15491. --  Notes:
  15492. --  -----
  15493. --    Semantics correspond to Ada LRM, Section 14.3.3
  15494. --
  15495. ---------------------------------------------------------------------
  15496.  
  15497.         procedure Set_Line_Length(File : File_Type; 
  15498.                                   To   : Count); 
  15499.         procedure Set_Line_Length(To : Count); 
  15500.  
  15501. ----------------------     Set_Page_Length     ----------------------
  15502. --
  15503. --  Purpose:
  15504. --  -------
  15505. --    Sets the maximum page length of the specified output file to the
  15506. --    number of lines specified by To.  The value 0 for To specifies an
  15507. --    unbounded page length.
  15508. --
  15509. --  Parameters:
  15510. --  ----------
  15511. --    File    open file handle.
  15512. --    To    number to which bound is to be set.
  15513. --
  15514. --  Exceptions:
  15515. --  ----------
  15516. --    Status_Error
  15517. --        raised if file is not open.
  15518. --    Mode_Error
  15519. --        raised if mode of the file is not Out_File or Append_File.
  15520. --    Use_Error
  15521. --        raised if the specified page length is inappropriate for
  15522. --        the associated external file.
  15523. --
  15524. --  Notes:
  15525. --  -----
  15526. --    Semantics correspond to Ada LRM, Section 14.3.3
  15527. --
  15528. ---------------------------------------------------------------------
  15529.  
  15530.         procedure Set_Page_Length(File : File_Type; 
  15531.                                   To   : Count); 
  15532.         procedure Set_Page_Length(To : Count); 
  15533.  
  15534.  
  15535. ----------------------     Line_Length     ----------------------
  15536. --
  15537. --  Purpose:
  15538. --  -------
  15539. --    Returns the line length currently set for the specified output file,
  15540. --    or zero if the line length is unbounded.
  15541. --
  15542. --  Parameters:
  15543. --  ----------
  15544. --    File    open file handle.
  15545. --
  15546. --  Exceptions:
  15547. --  ----------
  15548. --    Status_Error
  15549. --        raised if file is not open.
  15550. --    Mode_Error
  15551. --        raised if mode of the file is not Out_File or Append_File.
  15552. --
  15553. --  Notes:
  15554. --  -----
  15555. --    Semantics correspond to Ada LRM, Section 14.3.3
  15556. --
  15557. ---------------------------------------------------------------------
  15558.  
  15559.         function Line_Length(File : File_Type) return Count; 
  15560.         function Line_Length return Count; 
  15561.  
  15562.  
  15563. ----------------------     Page_Length     ----------------------
  15564. --
  15565. --  Purpose:
  15566. --  -------
  15567. --    Returns the page length currently set for the specified output file,
  15568. --    or zero if the page length is unbounded.
  15569. --
  15570. --  Parameters:
  15571. --  ----------
  15572. --    File    open file handle.
  15573. --
  15574. --  Exceptions:
  15575. --  ----------
  15576. --    Status_Error
  15577. --        raised if file is not open.
  15578. --    Mode_Error
  15579. --        raised if mode of the file is not Out_File or Append_File.
  15580. --
  15581. --  Notes:
  15582. --  -----
  15583. --    Semantics correspond to Ada LRM, Section 14.3.3
  15584. --
  15585. ---------------------------------------------------------------------
  15586.  
  15587.         function Page_Length(File : File_Type) return Count; 
  15588.         function Page_Length return Count; 
  15589.  
  15590.  
  15591. ----------------------     New_Line     ----------------------
  15592. --
  15593. --  Purpose:
  15594. --  -------
  15595. --    Outputs a line terminator and sets the current column
  15596. --    number to one.  Increments line number or if line
  15597. --    number exceeds maximum line for bounded page length,
  15598. --    outputs a page terminator, increments page number,
  15599. --    and sets line number to one.
  15600. --
  15601. --  Parameters:
  15602. --  ----------
  15603. --    File      open file handle.
  15604. --    Spacing   number of times New_Line action is performed.
  15605. --
  15606. --  Exceptions:
  15607. --  ----------
  15608. --    Status_Error
  15609. --        raised if file is not open.
  15610. --    Mode_Error
  15611. --        raised if mode of the file is not Out_File or Append_File.
  15612. --
  15613. --  Notes:
  15614. --  -----
  15615. --    Semantics correspond to Ada LRM, Section 14.3.4
  15616. --
  15617. ---------------------------------------------------------------------
  15618.  
  15619.         procedure New_Line(File    : File_Type; 
  15620.                            Spacing : Positive_Count := 1); 
  15621.         procedure New_Line(Spacing : Positive_Count := 1); 
  15622.  
  15623. ----------------------     Skip_Line     ----------------------
  15624. --
  15625. --  Purpose:
  15626. --  -------
  15627. --    Reads and discards all characters until a line terminator has
  15628. --    been read.  Then sets the current column number to one.
  15629. --
  15630. --  Parameters:
  15631. --  ----------
  15632. --    File      open file handle.
  15633. --    Spacing   number of times Skip_Line action is to be performed.
  15634. --
  15635. --  Exceptions:
  15636. --  ----------
  15637. --    Status_Error
  15638. --        raised if file is not open.
  15639. --    Mode_Error
  15640. --        raised if mode of the file is not In_File.
  15641. --    End_Error
  15642. --        raised if attempt is made to read a file terminator.
  15643. --
  15644. --  Notes:
  15645. --  -----
  15646. --    Semantics correspond to Ada LRM, Section 14.3.4
  15647. --
  15648. ---------------------------------------------------------------------
  15649.  
  15650.         procedure Skip_Line(File    : File_Type; 
  15651.                             Spacing : Positive_Count := 1); 
  15652.         procedure Skip_Line(Spacing : Positive_Count := 1); 
  15653.  
  15654. ----------------------     End_Of_Line     ----------------------
  15655. --
  15656. --  Purpose:
  15657. --  -------
  15658. --    Returns True if a line terminator or a file terminator 
  15659. --    is next; otherwise returns False.
  15660. --
  15661. --  Parameters:
  15662. --  ----------
  15663. --    File    open file handle.
  15664. --
  15665. --  Exceptions:
  15666. --  ----------
  15667. --    Status_Error
  15668. --        raised if file is not open.
  15669. --    Mode_Error
  15670. --        raised if mode of the file is not In_File.
  15671. --
  15672. --  Notes:
  15673. --  -----
  15674. --    Semantics correspond to Ada LRM, Section 14.3.4
  15675. --
  15676. ---------------------------------------------------------------------
  15677.  
  15678.         function End_Of_Line(File : File_Type) return Boolean; 
  15679.         function End_Of_Line return Boolean; 
  15680.  
  15681. ----------------------     New_Page     ----------------------
  15682. --
  15683. --  Purpose:
  15684. --  -------
  15685. --    Outputs a line terminator if the current line is not
  15686. --    terminated or current page is empty.  Outputs a page
  15687. --    terminator and adds one to current page number. Sets 
  15688. --    the current column and line numbers to one.
  15689. --
  15690. --  Parameters:
  15691. --  ----------
  15692. --    File      open file handle.
  15693. --
  15694. --  Exceptions:
  15695. --  ----------
  15696. --    Status_Error
  15697. --        raised if file is not open.
  15698. --    Mode_Error
  15699. --        raised if mode of the file is not Out_File or Append_File.
  15700. --
  15701. --  Notes:
  15702. --  -----
  15703. --    Semantics correspond to Ada LRM, Section 14.3.4
  15704. --
  15705. ---------------------------------------------------------------------
  15706.  
  15707.         procedure New_Page(File : File_Type); 
  15708.         procedure New_Page; 
  15709.  
  15710. ----------------------     Skip_Page     ----------------------
  15711. --
  15712. --  Purpose:
  15713. --  -------
  15714. --    Reads and discards all characters until a page terminator has
  15715. --    been read.  Then adds one to the current page number and
  15716. --    sets the current column number and line numbers to one.
  15717. --
  15718. --  Parameters:
  15719. --  ----------
  15720. --    File      open file handle.
  15721. --
  15722. --  Exceptions:
  15723. --  ----------
  15724. --    Status_Error
  15725. --        raised if file is not open.
  15726. --    Mode_Error
  15727. --        raised if mode of the file is not In_File.
  15728. --    End_Error
  15729. --        raised if attempt is made to read a file terminator.
  15730. --
  15731. --  Notes:
  15732. --  -----
  15733. --    Semantics correspond to Ada LRM, Section 14.3.4
  15734. --
  15735. ---------------------------------------------------------------------
  15736.  
  15737.         procedure Skip_Page(File : File_Type); 
  15738.         procedure Skip_Page; 
  15739.  
  15740. ----------------------     End_Of_Page     ----------------------
  15741. --
  15742. --  Purpose:
  15743. --  -------
  15744. --    Returns True if a line terminator and a page terminator
  15745. --    or a file terminator is next; otherwise returns False.
  15746. --
  15747. --  Parameters:
  15748. --  ----------
  15749. --    File    open file handle.
  15750. --
  15751. --  Exceptions:
  15752. --  ----------
  15753. --    Status_Error
  15754. --        raised if file is not open.
  15755. --    Mode_Error
  15756. --        raised if mode of the file is not In_File.
  15757. --
  15758. --  Notes:
  15759. --  -----
  15760. --    Semantics correspond to Ada LRM, Section 14.3.4
  15761. --
  15762. ---------------------------------------------------------------------
  15763.  
  15764.         function End_Of_Page(File : File_Type) return Boolean; 
  15765.         function End_Of_Page return Boolean; 
  15766.  
  15767. ----------------------     End_Of_File     ----------------------
  15768. --
  15769. --  Purpose:
  15770. --  -------
  15771. --    Returns True if a file terminator or the combination of a line 
  15772. --    terminator, page terminator, and a file terminator
  15773. --    is next; otherwise returns False.
  15774. --
  15775. --  Parameters:
  15776. --  ----------
  15777. --    File    open file handle.
  15778. --
  15779. --  Exceptions:
  15780. --  ----------
  15781. --    Status_Error
  15782. --        raised if file is not open.
  15783. --    Mode_Error
  15784. --        raised if mode of the file is not In_File.
  15785. --
  15786. --  Notes:
  15787. --  -----
  15788. --    Semantics correspond to Ada LRM, Section 14.3.4
  15789. --
  15790. ---------------------------------------------------------------------
  15791.  
  15792.         function End_Of_File(File : File_Type) return Boolean; 
  15793.         function End_Of_File return Boolean; 
  15794.  
  15795.  
  15796. ----------------------     Set_Col     ----------------------
  15797. --
  15798. --  Purpose:
  15799. --  -------
  15800. --    If mode is Out_File, outputs spaces until current column
  15801. --    equals To.  If To is less than current column, a New_Line
  15802. --    is performed first.
  15803. --
  15804. --    If mode is In_File, discards characters until next character
  15805. --    has column equal to To. 
  15806. --
  15807. --  Parameters:
  15808. --  ----------
  15809. --    File    open file handle.
  15810. --    To    column number.
  15811. --
  15812. --  Exceptions:
  15813. --  ----------
  15814. --    Layout_Error
  15815. --        raised if mode is Out_File and To exceeds maximum
  15816. --        line length.
  15817. --    End_Error
  15818. --        raised if attempt is made to read file terminator.
  15819. --
  15820. --  Notes:
  15821. --  -----
  15822. --    Semantics correspond to Ada LRM, Section 14.3.4
  15823. --
  15824. ---------------------------------------------------------------------
  15825.  
  15826.         procedure Set_Col(File : File_Type; 
  15827.                           To   : Positive_Count); 
  15828.         procedure Set_Col(To : Positive_Count); 
  15829.  
  15830.  
  15831. ----------------------     Set_Line     ----------------------
  15832. --
  15833. --  Purpose:
  15834. --  -------
  15835. --    If mode is Out_File, performs New_Line until current line
  15836. --    equals To.  If To is less than current line, a New_Page
  15837. --    is performed first.
  15838. --
  15839. --    If mode is In_File, performs Skip_Line until current line number
  15840. --    is equal to To. 
  15841. --
  15842. --  Parameters:
  15843. --  ----------
  15844. --    File    open file handle.
  15845. --    To    column number.
  15846. --
  15847. --  Exceptions:
  15848. --  ----------
  15849. --    Layout_Error
  15850. --        raised if mode is Out_File and To exceeds maximum
  15851. --        page length.
  15852. --    End_Error
  15853. --        raised if attempt is made to read file terminator.
  15854. --
  15855. --  Notes:
  15856. --  -----
  15857. --    Semantics correspond to Ada LRM, Section 14.3.4
  15858. --
  15859. ---------------------------------------------------------------------
  15860.  
  15861.         procedure Set_Line(File : File_Type; 
  15862.                            To   : Positive_Count); 
  15863.         procedure Set_Line(To : Positive_Count); 
  15864.  
  15865. ----------------------     Col     ----------------------
  15866. --
  15867. --  Purpose:
  15868. --  -------
  15869. --    Returns the current column number.
  15870. --
  15871. --  Parameters:
  15872. --  ----------
  15873. --    File    open file handle.
  15874. --
  15875. --  Exceptions:
  15876. --  ----------
  15877. --    Status_Error
  15878. --        raised if file is not open.
  15879. --    Layout_Error
  15880. --        raised if this number exceeds Count'Last.
  15881. --
  15882. --  Notes:
  15883. --  -----
  15884. --    Semantics correspond to Ada LRM, Section 14.3.4
  15885. --
  15886. ---------------------------------------------------------------------
  15887.  
  15888.         function Col(File : File_Type) return Positive_Count; 
  15889.         function Col return Positive_Count; 
  15890.  
  15891. ----------------------     Line     ----------------------
  15892. --
  15893. --  Purpose:
  15894. --  -------
  15895. --    Returns the current line number.
  15896. --
  15897. --  Parameters:
  15898. --  ----------
  15899. --    File    open file handle.
  15900. --
  15901. --  Exceptions:
  15902. --  ----------
  15903. --    Status_Error
  15904. --        raised if file is not open.
  15905. --    Layout_Error
  15906. --        raised if this number exceeds Count'Last.
  15907. --
  15908. --  Notes:
  15909. --  -----
  15910. --    Semantics correspond to Ada LRM, Section 14.3.4
  15911. --
  15912. ---------------------------------------------------------------------
  15913.  
  15914.         function Line(File : File_Type) return Positive_Count; 
  15915.         function Line return Positive_Count; 
  15916.  
  15917. ----------------------     Page     ----------------------
  15918. --
  15919. --  Purpose:
  15920. --  -------
  15921. --    Returns the current page number.
  15922. --
  15923. --  Parameters:
  15924. --  ----------
  15925. --    File    open file handle.
  15926. --
  15927. --  Exceptions:
  15928. --  ----------
  15929. --    Status_Error
  15930. --        raised if file is not open.
  15931. --    Layout_Error
  15932. --        raised if this number exceeds Count'Last.
  15933. --
  15934. --  Notes:
  15935. --  -----
  15936. --    Semantics correspond to Ada LRM, Section 14.3.4
  15937. --
  15938. ---------------------------------------------------------------------
  15939.  
  15940.         function Page(File : File_Type) return Positive_Count; 
  15941.         function Page return Positive_Count; 
  15942.  
  15943.  
  15944.  
  15945. ----------------------     Get     ----------------------
  15946. --
  15947. --  Purpose:
  15948. --  -------
  15949. --    This procedure reads characters from the specified
  15950. --    text file into the item parameter.
  15951. --
  15952. --  Parameters:
  15953. --  ----------
  15954. --    File    open file handle.
  15955. --    Item    out parameter of type Character.
  15956. --
  15957. --  Exceptions:
  15958. --  ----------
  15959. --    Status_Error
  15960. --        raised if File is not open.
  15961. --    Mode_Error
  15962. --        raised if file mode is not In_File.
  15963. --    End_Error
  15964. --        raised if attempt is made to skip file terminator.
  15965. --    Data_Error
  15966. --        raised if the sequence input is not a lexical element
  15967. --        corresponding to the item type.
  15968. --
  15969. --  Notes:
  15970. --  -----
  15971. --    This procedure is defined in section 5.3.4.6 of MIL-STD-CAIS,
  15972. --    dated 31 January 1985.
  15973. --
  15974. ---------------------------------------------------------------------
  15975.  
  15976.         procedure Get(File : File_Type; 
  15977.                       Item : in out Character); 
  15978.         procedure Get(Item : in out Character); 
  15979.  
  15980. ----------------------     Put     ----------------------
  15981. --
  15982. --  Purpose:
  15983. --  -------
  15984. --    This procedure writes characters to the specified file.
  15985. --
  15986. --  Parameters:
  15987. --  ----------
  15988. --    File    open file handle.
  15989. --    Item    in parameter of type Character.
  15990. --
  15991. --  Exceptions:
  15992. --  ----------
  15993. --    Status_Error
  15994. --        raised if File is not open.
  15995. --    Mode_Error
  15996. --        raised if file mode is not Out_File or Append_File.
  15997. --    Layout_Error
  15998. --        raised if the number of characters to be output 
  15999. --        exceeds the maximum line length.
  16000. --
  16001. --  Notes:
  16002. --  -----
  16003. --    This procedure is defined in section 5.3.4.6 of MIL-STD-CAIS,
  16004. --    dated 31 January 1985.
  16005. --
  16006. ---------------------------------------------------------------------
  16007.  
  16008.         procedure Put(File : File_Type; 
  16009.                       Item : Character); 
  16010.         procedure Put(Item : Character); 
  16011.  
  16012. ----------------------     Get     ----------------------
  16013. --
  16014. --  Purpose:
  16015. --  -------
  16016. --    This procedure reads characters from the specified
  16017. --    text file into the item parameter.
  16018. --    The number of Get character operations is determined by
  16019. --    the length of the string.
  16020. --
  16021. --  Parameters:
  16022. --  ----------
  16023. --    File    open file handle.
  16024. --    Item    out parameter of type String.
  16025. --
  16026. --  Exceptions:
  16027. --  ----------
  16028. --    Status_Error
  16029. --        raised if File is not open.
  16030. --    Mode_Error
  16031. --        raised if file mode is not In_File.
  16032. --    End_Error
  16033. --        raised if attempt is made to skip file terminator.
  16034. --    Data_Error
  16035. --        raised if the sequence input is not a lexical element
  16036. --        corresponding to the item type.
  16037. --
  16038. --  Notes:
  16039. --  -----
  16040. --    This procedure is defined in section 5.3.4.6 of MIL-STD-CAIS,
  16041. --    dated 31 January 1985.
  16042. --
  16043. ---------------------------------------------------------------------
  16044.  
  16045.         procedure Get(File : File_Type; 
  16046.                       Item : in out String); 
  16047.         procedure Get(Item : in out String); 
  16048.  
  16049. ----------------------     Put     ----------------------
  16050. --
  16051. --  Purpose:
  16052. --  -------
  16053. --    This procedure writes characters to the specified file.
  16054. --    The number of Put character operations is determined by
  16055. --    the length of the string.
  16056. --
  16057. --  Parameters:
  16058. --  ----------
  16059. --    File    open file handle.
  16060. --    Item    in parameter of type String.
  16061. --
  16062. --  Exceptions:
  16063. --  ----------
  16064. --    Status_Error
  16065. --        raised if File is not open.
  16066. --    Mode_Error
  16067. --        raised if file mode is not Out_File or Append_File.
  16068. --    Layout_Error
  16069. --        raised if the number of characters to be output 
  16070. --        exceeds the maximum line length.
  16071. --
  16072. --  Notes:
  16073. --  -----
  16074. --    This procedure is defined in section 5.3.4.6 of MIL-STD-CAIS,
  16075. --    dated 31 January 1985.
  16076. --
  16077. ---------------------------------------------------------------------
  16078.  
  16079.         procedure Put(File : File_Type; 
  16080.                       Item : String); 
  16081.         procedure Put(Item : String); 
  16082.  
  16083. ----------------------     Get_Line     ----------------------
  16084. --
  16085. --  Purpose:
  16086. --  -------
  16087. --    This procedure reads successive characters from the specified
  16088. --    text file into the item parameter.  Reading stops if the end
  16089. --    of line is met.
  16090. --
  16091. --  Parameters:
  16092. --  ----------
  16093. --    File    open file handle.
  16094. --    Item    out parameter of type String.
  16095. --
  16096. --  Exceptions:
  16097. --  ----------
  16098. --    Status_Error
  16099. --        raised if File is not open.
  16100. --    Mode_Error
  16101. --        raised if file mode is not In_File.
  16102. --    End_Error
  16103. --        raised if attempt is made to skip file terminator.
  16104. --    Data_Error
  16105. --        raised if the sequence input is not a lexical element
  16106. --        corresponding to the item type.
  16107. --
  16108. --  Notes:
  16109. --  -----
  16110. --    Semantics correspond to Ada LRM, Section 14.3.6.
  16111. --
  16112. ---------------------------------------------------------------------
  16113.  
  16114.         procedure Get_Line(File : File_Type; 
  16115.                            Item : in out String; 
  16116.                            Last : in out Natural); 
  16117.         procedure Get_Line(Item : in out String; 
  16118.                            Last : in out Natural); 
  16119.  
  16120. ----------------------     Put_Line     ----------------------
  16121. --
  16122. --  Purpose:
  16123. --  -------
  16124. --    This procedure calls procedure Put for the given string,
  16125. --    then New_Line, with a spacing of one.
  16126. --
  16127. --  Parameters:
  16128. --  ----------
  16129. --    File    open file handle.
  16130. --    Item    in parameter of type String.
  16131. --
  16132. --  Exceptions:
  16133. --  ----------
  16134. --    Status_Error
  16135. --        raised if File is not open.
  16136. --    Mode_Error
  16137. --        raised if file mode is not Out_File or Append_File.
  16138. --
  16139. --  Notes:
  16140. --  -----
  16141. --    Semantics correspond to Ada LRM, Section 14.3.6
  16142. --
  16143. ---------------------------------------------------------------------
  16144.  
  16145.         procedure Put_Line(File : File_Type; 
  16146.                            Item : String); 
  16147.         procedure Put_Line(Item : String); 
  16148.  
  16149. ----------------------------------------------------------------------
  16150. --              C A I S _ T E X T _ I O . I N T E G E R _ I O
  16151. --
  16152. --  Purpose:
  16153. --  -------
  16154. --        Integer_Io is a generic package nested in the CAIS Text_Io package.
  16155. --        This package provides facilities for the input and output
  16156. --        of textual integer data to CAIS files.  These facilities are
  16157. --        comparable to those specified in the package TEXT_IO.INTEGER_IO
  16158. --        in the Ada LRM, Chapter 14.  
  16159. --
  16160. --  Usage:
  16161. --  -----
  16162. --        Usage is analogous to usage of the Ada Text_Io.Integer_Io package.
  16163. --        CAIS file nodes correspond to ordinary Ada files. 
  16164. --        Input and output operations access the contents of CAIS 
  16165. --        file nodes.  
  16166. --        The package is instantiated for the element type.  File_Type
  16167. --        and File_Mode are subtypes declared in the Cais.Text_Io package.
  16168. --
  16169. --  Example:
  16170. --  -------
  16171. --        type Small_Integer is range 1..20;
  16172. --        ...
  16173. --        File      : File_Type;
  16174. --        package Small_Io is new Cais.Text_Io.Integer_Io (Small_Integer);
  16175. --        ...
  16176. --        Small_Io.Put (File, 15);
  16177. --        ...
  16178. --
  16179. --  Notes:
  16180. --  -----
  16181. --        This is a version of the package CAIS.TEXT_IO.INTEGER_IO,
  16182. --        specified in MIL-STD-CAIS section 5.3.4; all references
  16183. --        to the CAIS specification refer to the CAIS specification
  16184. --        dated 31 January 1985.
  16185. --
  16186. --  Revision History:
  16187. --  ----------------
  16188. --        None.
  16189. --
  16190. -------------------------------------------------------------------
  16191.  
  16192.         generic
  16193.             type Num is range <>; 
  16194.         package Integer_Io is 
  16195.  
  16196.             Default_Width : Field := Num'Width; 
  16197.             Default_Base  : Number_Base := 10; 
  16198.  
  16199. ----------------------     Get     ----------------------
  16200. --
  16201. --  Purpose:
  16202. --  -------
  16203. --    This procedure reads characters from the specified
  16204. --    text file, according to the syntax of a literal
  16205. --    of the parameter type,
  16206. --    and stores the converted value in the item parameter.
  16207. --
  16208. --  Parameters:
  16209. --  ----------
  16210. --    File    open file handle.
  16211. --    Item    out parameter of the generic parameter type.
  16212. --    Width    field width, or 0 if unbounded.
  16213. --
  16214. --  Exceptions:
  16215. --  ----------
  16216. --    Status_Error
  16217. --        raised if File is not open.
  16218. --    Mode_Error
  16219. --        raised if file mode is not In_File.
  16220. --    End_Error
  16221. --        raised if attempt is made to skip file terminator.
  16222. --    Data_Error
  16223. --        raised if the sequence input is not a lexical element
  16224. --        corresponding to the item type.
  16225. --
  16226. --  Notes:
  16227. --  -----
  16228. --    This procedure is defined in section 5.3.4.6 of MIL-STD-CAIS,
  16229. --    dated 31 January 1985.
  16230. --
  16231. ---------------------------------------------------------------------
  16232.  
  16233.             procedure Get(File  : File_Type; 
  16234.                           Item  : in out Num; 
  16235.                           Width : Field := 0); 
  16236.  
  16237.  
  16238.             procedure Get(Item  : in out Num; 
  16239.                           Width : Field := 0); 
  16240.  
  16241. ----------------------     Put     ----------------------
  16242. --
  16243. --  Purpose:
  16244. --  -------
  16245. --    This procedure writes the value of Item, represented as a literal
  16246. --    of the parameter type, to the specified file.
  16247. --    
  16248. --
  16249. --  Parameters:
  16250. --  ----------
  16251. --    File    open file handle.
  16252. --    Item    in parameter of the generic parameter type.
  16253. --    Width    minimum field width.
  16254. --    Base    base for literal representation.
  16255. --
  16256. --  Exceptions:
  16257. --  ----------
  16258. --    Status_Error
  16259. --        raised if File is not open.
  16260. --    Mode_Error
  16261. --        raised if file mode is not Out_File or Append_File.
  16262. --    Layout_Error
  16263. --        raised if the number of characters to be output 
  16264. --        exceeds the maximum line length.
  16265. --
  16266. --  Notes:
  16267. --  -----
  16268. --    This procedure is defined in section 5.3.4.7 of MIL-STD-CAIS,
  16269. --    dated 31 January 1985.
  16270. --
  16271. ---------------------------------------------------------------------
  16272.  
  16273.             procedure Put(File  : File_Type; 
  16274.                           Item  : Num; 
  16275.                           Width : Field := Default_Width; 
  16276.                           Base  : Number_Base := Default_Base); 
  16277.  
  16278.  
  16279.             procedure Put(Item  : Num; 
  16280.                           Width : Field := Default_Width; 
  16281.                           Base  : Number_Base := Default_Base); 
  16282.  
  16283. ----------------------     Get     ----------------------
  16284. --
  16285. --  Purpose:
  16286. --  -------
  16287. --    This procedure reads characters from the specified
  16288. --    string into the item parameter, following the same
  16289. --    rule as for reading from a file, but treating the
  16290. --    end of the string as a file terminator.
  16291. --
  16292. --  Parameters:
  16293. --  ----------
  16294. --    From    string.
  16295. --    Item    out parameter of the generic parameter type.
  16296. --    Last    index value of last character read.
  16297. --
  16298. --  Exceptions:
  16299. --  ----------
  16300. --    End_Error
  16301. --        raised if attempt is made to skip file terminator.
  16302. --    Data_Error
  16303. --        raised if the sequence input is not a lexical element
  16304. --        corresponding to the item type.
  16305. --
  16306. --  Notes:
  16307. --  -----
  16308. --    Semantics correspond to Ada LRM, Section 14.3.7
  16309. --
  16310. ---------------------------------------------------------------------
  16311.  
  16312.             procedure Get(From : String; 
  16313.                           Item : in out Num; 
  16314.                           Last : in out Positive); 
  16315.  
  16316. ----------------------     Put     ----------------------
  16317. --
  16318. --  Purpose:
  16319. --  -------
  16320. --    This procedure writes characters to the specified string,
  16321. --    following the same rule as for output to a file.
  16322. --
  16323. --  Parameters:
  16324. --  ----------
  16325. --    To    string.
  16326. --    Item    in parameter of generic parameter type.
  16327. --    Base    base for literal representation.
  16328. --
  16329. --  Exceptions:
  16330. --  ----------
  16331. --    Layout_Error
  16332. --        raised if the number of characters to be output 
  16333. --        exceeds the remaining string length.
  16334. --
  16335. --  Notes:
  16336. --  -----
  16337. --    Semantics correspond to Ada LRM, Section 14.3.7
  16338. --
  16339. ---------------------------------------------------------------------
  16340.  
  16341.             procedure Put(To   : in out String; 
  16342.                           Item : Num; 
  16343.                           Base : Number_Base := Default_Base); 
  16344.  
  16345.         end Integer_Io; 
  16346.  
  16347.  
  16348.  
  16349. ----------------------------------------------------------------------
  16350. --              C A I S _ T E X T _ I O . F L O A T _ I O
  16351. --
  16352. --  Purpose:
  16353. --  -------
  16354. --        Float_Io is a generic package nested in the CAIS Text_Io package.
  16355. --        This package provides facilities for the input and output
  16356. --        of textual float data to CAIS files.  These facilities are
  16357. --        comparable to those specified in the package TEXT_IO.FLOAT_IO
  16358. --        in the Ada LRM, Chapter 14.  
  16359. --
  16360. --  Usage:
  16361. --  -----
  16362. --        Usage is analogous to usage of the Ada Text_Io.Float_Io package.
  16363. --        CAIS file nodes correspond to ordinary Ada files. 
  16364. --        Input and output operations access the contents of CAIS 
  16365. --        file nodes.  
  16366. --        The package is instantiated for the element type.  File_Type
  16367. --        and File_Mode are subtypes declared in the Cais.Text_Io package.
  16368. --
  16369. --  Example:
  16370. --  -------
  16371. --        type Real_Float is digits 5 range 0.0000 .. 9.9999;
  16372. --        ...
  16373. --        File      : File_Type;
  16374. --        package Real_Io is new Cais.Text_Io.Float_Io (Real_Float);
  16375. --        ...
  16376. --        Real_Io.Put (File, 2.3456);
  16377. --        ...
  16378. --
  16379. --  Notes:
  16380. --  -----
  16381. --        This is a version of the package CAIS.TEXT_IO.FLOAT_IO,
  16382. --        specified in MIL-STD-CAIS section 5.3.4; all references
  16383. --        to the CAIS specification refer to the CAIS specification
  16384. --        dated 31 January 1985.
  16385. --
  16386. --  Revision History:
  16387. --  ----------------
  16388. --        None.
  16389. --
  16390. -------------------------------------------------------------------
  16391.  
  16392.         generic
  16393.             type Num is digits <>; 
  16394.         package Float_Io is 
  16395.  
  16396.             Default_Fore : Field := 2; 
  16397.             Default_Aft  : Field := Num'digits - 1; 
  16398.             Default_Exp  : Field := 3; 
  16399.  
  16400.  
  16401. ----------------------     Get     ----------------------
  16402. --
  16403. --  Purpose:
  16404. --  -------
  16405. --    This procedure reads characters from the specified
  16406. --    text file, according to the syntax of a literal
  16407. --    of the parameter type,
  16408. --    and stores the converted value in the item parameter.
  16409. --
  16410. --  Parameters:
  16411. --  ----------
  16412. --    File    open file handle.
  16413. --    Item    out parameter of the generic parameter type.
  16414. --    Width    field width, or 0 if unbounded.
  16415. --
  16416. --  Exceptions:
  16417. --  ----------
  16418. --    Status_Error
  16419. --        raised if File is not open.
  16420. --    Mode_Error
  16421. --        raised if file mode is not In_File.
  16422. --    End_Error
  16423. --        raised if attempt is made to skip file terminator.
  16424. --    Data_Error
  16425. --        raised if the sequence input is not a lexical element
  16426. --        corresponding to the item type.
  16427. --
  16428. --  Notes:
  16429. --  -----
  16430. --    This procedure is defined in section 5.3.4.6 of MIL-STD-CAIS,
  16431. --    dated 31 January 1985.
  16432. --
  16433. ---------------------------------------------------------------------
  16434.  
  16435.             procedure Get(File  : File_Type; 
  16436.                           Item  : in out Num; 
  16437.                           Width : Field := 0); 
  16438.  
  16439.             procedure Get(Item  : in out Num; 
  16440.                           Width : Field := 0); 
  16441.  
  16442. ----------------------     Put     ----------------------
  16443. --
  16444. --  Purpose:
  16445. --  -------
  16446. --    This procedure writes the value of Item, represented as a literal
  16447. --    of the parameter type, to the specified file.
  16448. --    
  16449. --
  16450. --  Parameters:
  16451. --  ----------
  16452. --    File    open file handle.
  16453. --    Item    in parameter of the generic parameter type.
  16454. --    Width    minimum field width.
  16455. --    Fore    digits before decimal in literal representation.
  16456. --    Aft    digits after decimal in literal representation.
  16457. --    Exp    digits in exponent in literal representation.
  16458. --
  16459. --  Exceptions:
  16460. --  ----------
  16461. --    Status_Error
  16462. --        raised if File is not open.
  16463. --    Mode_Error
  16464. --        raised if file mode is not Out_File or Append_File.
  16465. --    Layout_Error
  16466. --        raised if the number of characters to be output 
  16467. --        exceeds the maximum line length.
  16468. --
  16469. --  Notes:
  16470. --  -----
  16471. --    This procedure is defined in section 5.3.4.7 of MIL-STD-CAIS,
  16472. --    dated 31 January 1985.
  16473. --
  16474. ---------------------------------------------------------------------
  16475.  
  16476.  
  16477.             procedure Put(File : File_Type; 
  16478.                           Item : Num; 
  16479.                           Fore : Field := Default_Fore; 
  16480.                           Aft  : Field := Default_Aft; 
  16481.                           Exp  : Field := Default_Exp); 
  16482.  
  16483.             procedure Put(Item : Num; 
  16484.                           Fore : Field := Default_Fore; 
  16485.                           Aft  : Field := Default_Aft; 
  16486.                           Exp  : Field := Default_Exp); 
  16487.  
  16488. ----------------------     Get     ----------------------
  16489. --
  16490. --  Purpose:
  16491. --  -------
  16492. --    This procedure reads characters from the specified
  16493. --    string into the item parameter, following the same
  16494. --    rule as for reading from a file, but treating the
  16495. --    end of the string as a file terminator.
  16496. --
  16497. --  Parameters:
  16498. --  ----------
  16499. --    From    string.
  16500. --    Item    out parameter of the generic parameter type.
  16501. --    Last    index value of last character read.
  16502. --
  16503. --  Exceptions:
  16504. --  ----------
  16505. --    End_Error
  16506. --        raised if attempt is made to skip file terminator.
  16507. --    Data_Error
  16508. --        raised if the sequence input is not a lexical element
  16509. --        corresponding to the item type.
  16510. --
  16511. --  Notes:
  16512. --  -----
  16513. --    Semantics correspond to Ada LRM, Section 14.3.7
  16514. --
  16515. ---------------------------------------------------------------------
  16516.  
  16517.             procedure Get(From : String; 
  16518.                           Item : in out Num; 
  16519.                           Last : in out Positive); 
  16520.  
  16521. ----------------------     Put     ----------------------
  16522. --
  16523. --  Purpose:
  16524. --  -------
  16525. --    This procedure writes characters to the specified string,
  16526. --    following the same rule as for output to a file.
  16527. --    The number of digits before the exponent is adjusted so
  16528. --    that the literal exactly fills the string.
  16529. --
  16530. --  Parameters:
  16531. --  ----------
  16532. --    To    string.
  16533. --    Item    in parameter of generic parameter type.
  16534. --    Aft    digits after the decimal in the literal representation.
  16535. --    Exp    digits in the exponent in the literal representation.
  16536. --
  16537. --  Exceptions:
  16538. --  ----------
  16539. --    Layout_Error
  16540. --        raised if the number of characters to be output 
  16541. --        exceeds the remaining string length.
  16542. --
  16543. --  Notes:
  16544. --  -----
  16545. --    Semantics correspond to Ada LRM, Section 14.3.7
  16546. --
  16547. ---------------------------------------------------------------------
  16548.  
  16549.             procedure Put(To   : in out String; 
  16550.                           Item : Num; 
  16551.                           Aft  : Field := Default_Aft; 
  16552.                           Exp  : Field := Default_Exp); 
  16553.  
  16554.         end Float_Io; 
  16555.  
  16556. ----------------------------------------------------------------------
  16557. --              C A I S _ T E X T _ I O . F I X E D _ I O
  16558. --
  16559. --  Purpose:
  16560. --  -------
  16561. --        Fixed_Io is a generic package nested in the CAIS Text_Io package.
  16562. --        This package provides facilities for the input and output
  16563. --        of textual Fixed data to CAIS files.  These facilities are
  16564. --        comparable to those specified in the package TEXT_IO.FIXED_IO
  16565. --        in the Ada LRM, Chapter 14.  
  16566. --
  16567. --  Usage:
  16568. --  -----
  16569. --        Usage is analogous to usage of the Ada Text_Io.Fixed_Io package.
  16570. --        CAIS file nodes correspond to ordinary Ada files. 
  16571. --        Input and output operations access the contents of CAIS 
  16572. --        file nodes.  
  16573. --        The package is instantiated for the element type.  File_Type
  16574. --        and File_Mode are subtypes declared in the Cais.Text_Io package.
  16575. --
  16576. --  Example:
  16577. --  -------
  16578. --        type Real_Fixed is delta 0.001 range 0.000 .. 9.999;
  16579. --        ...
  16580. --        File      : File_Type;
  16581. --        package Real_Io is new Cais.Text_Io.Fixed_Io (Real_Fixed);
  16582. --        ...
  16583. --        Real_Io.Put (File, 5.432);
  16584. --  Notes:
  16585. --  -----
  16586. --        This is a version of the package CAIS.TEXT_IO.FIXED_IO,
  16587. --        specified in MIL-STD-CAIS section 5.3.4; all references
  16588. --        to the CAIS specification refer to the CAIS specification
  16589. --        dated 31 January 1985.
  16590. --
  16591. --  Revision History:
  16592. --  ----------------
  16593. --        None.
  16594. --
  16595. -------------------------------------------------------------------
  16596.  
  16597.         generic
  16598.             type Num is delta <>; 
  16599.         package Fixed_Io is 
  16600.  
  16601.             Default_Fore : Field := Num'Fore; 
  16602.             Default_Aft  : Field := Num'Aft; 
  16603.             Default_Exp  : Field := 0; 
  16604.  
  16605.  
  16606. ----------------------     Get     ----------------------
  16607. --
  16608. --  Purpose:
  16609. --  -------
  16610. --    This procedure reads characters from the specified
  16611. --    text file, according to the syntax of a literal
  16612. --    of the parameter type,
  16613. --    and stores the converted value in the item parameter.
  16614. --
  16615. --  Parameters:
  16616. --  ----------
  16617. --    File    open file handle.
  16618. --    Item    out parameter of the generic parameter type.
  16619. --    Width    field width, or 0 if unbounded.
  16620. --
  16621. --  Exceptions:
  16622. --  ----------
  16623. --    Status_Error
  16624. --        raised if File is not open.
  16625. --    Mode_Error
  16626. --        raised if file mode is not In_File.
  16627. --    End_Error
  16628. --        raised if attempt is made to skip file terminator.
  16629. --    Data_Error
  16630. --        raised if the sequence input is not a lexical element
  16631. --        corresponding to the item type.
  16632. --
  16633. --  Notes:
  16634. --  -----
  16635. --    This procedure is defined in section 5.3.4.6 of MIL-STD-CAIS,
  16636. --    dated 31 January 1985.
  16637. --
  16638. ---------------------------------------------------------------------
  16639.  
  16640.             procedure Get(File  : File_Type; 
  16641.                           Item  : in out Num; 
  16642.                           Width : Field := 0); 
  16643.  
  16644.             procedure Get(Item  : in out Num; 
  16645.                           Width : Field := 0); 
  16646.  
  16647.  
  16648. ----------------------     Put     ----------------------
  16649. --
  16650. --  Purpose:
  16651. --  -------
  16652. --    This procedure writes the value of Item, represented as a literal
  16653. --    of the parameter type, to the specified file.
  16654. --    
  16655. --
  16656. --  Parameters:
  16657. --  ----------
  16658. --    File    open file handle.
  16659. --    Item    in parameter of the generic parameter type.
  16660. --    Width    minimum field width.
  16661. --    Fore    digits before decimal in literal representation.
  16662. --    Aft    digits after decimal in literal representation.
  16663. --    Exp    digits in exponent in literal representation.
  16664. --
  16665. --  Exceptions:
  16666. --  ----------
  16667. --    Status_Error
  16668. --        raised if File is not open.
  16669. --    Mode_Error
  16670. --        raised if file mode is not Out_File or Append_File.
  16671. --    Layout_Error
  16672. --        raised if the number of characters to be output 
  16673. --        exceeds the maximum line length.
  16674. --
  16675. --  Notes:
  16676. --  -----
  16677. --    This procedure is defined in section 5.3.4.7 of MIL-STD-CAIS,
  16678. --    dated 31 January 1985.
  16679. --
  16680. ---------------------------------------------------------------------
  16681.  
  16682.             procedure Put(File : File_Type; 
  16683.                           Item : Num; 
  16684.                           Fore : Field := Default_Fore; 
  16685.                           Aft  : Field := Default_Aft; 
  16686.                           Exp  : Field := Default_Exp); 
  16687.  
  16688.             procedure Put(Item : Num; 
  16689.                           Fore : Field := Default_Fore; 
  16690.                           Aft  : Field := Default_Aft; 
  16691.                           Exp  : Field := Default_Exp); 
  16692.  
  16693. ----------------------     Get     ----------------------
  16694. --
  16695. --  Purpose:
  16696. --  -------
  16697. --    This procedure reads characters from the specified
  16698. --    string into the item parameter, following the same
  16699. --    rule as for reading from a file, but treating the
  16700. --    end of the string as a file terminator.
  16701. --
  16702. --  Parameters:
  16703. --  ----------
  16704. --    From    string.
  16705. --    Item    out parameter of the generic parameter type.
  16706. --    Last    index value of last character read.
  16707. --
  16708. --  Exceptions:
  16709. --  ----------
  16710. --    End_Error
  16711. --        raised if attempt is made to skip file terminator.
  16712. --    Data_Error
  16713. --        raised if the sequence input is not a lexical element
  16714. --        corresponding to the item type.
  16715. --
  16716. --  Notes:
  16717. --  -----
  16718. --    Semantics correspond to Ada LRM, Section 14.3.8
  16719. --
  16720. ---------------------------------------------------------------------
  16721.  
  16722.             procedure Get(From : String; 
  16723.                           Item : in out Num; 
  16724.                           Last : in out Positive); 
  16725.  
  16726. ----------------------     Put     ----------------------
  16727. --
  16728. --  Purpose:
  16729. --  -------
  16730. --    This procedure writes characters to the specified string,
  16731. --    following the same rule as for output to a file.
  16732. --    The number of digits before the exponent is adjusted so
  16733. --    that the literal exactly fills the string.
  16734. --
  16735. --  Parameters:
  16736. --  ----------
  16737. --    To    string.
  16738. --    Item    in parameter of generic parameter type.
  16739. --    Aft    digits after the decimal in the literal representation.
  16740. --    Exp    digits in the exponent in the literal representation.
  16741. --
  16742. --  Exceptions:
  16743. --  ----------
  16744. --    Layout_Error
  16745. --        raised if the number of characters to be output 
  16746. --        exceeds the remaining string length.
  16747. --
  16748. --  Notes:
  16749. --  -----
  16750. --    Semantics correspond to Ada LRM, Section 14.3.8
  16751. --
  16752. ---------------------------------------------------------------------
  16753.  
  16754.             procedure Put(To   : in out String; 
  16755.                           Item : Num; 
  16756.                           Aft  : Field := Default_Aft; 
  16757.                           Exp  : Field := Default_Exp); 
  16758.  
  16759.         end Fixed_Io; 
  16760.  
  16761. ----------------------------------------------------------------------
  16762. --              C A I S _ T E X T _ I O . E N U M E R A T I O N _ I O
  16763. --
  16764. --  Purpose:
  16765. --  -------
  16766. --        Enumeration_Io is a generic package nested in the CAIS Text_Io package.
  16767. --        This package provides facilities for the input and output
  16768. --        of textual enumeration data to CAIS files.  These facilities are
  16769. --        comparable to those specified in the package TEXT_IO.ENUMERATION_IO
  16770. --        in the Ada LRM, Chapter 14.  
  16771. --
  16772. --  Usage:
  16773. --  -----
  16774. --        Usage is analogous to usage of the Ada Text_Io.Enumeration_Io package.
  16775. --        CAIS file nodes correspond to ordinary Ada files. 
  16776. --        Input and output operations access the contents of CAIS 
  16777. --        file nodes.  
  16778. --        The package is instantiated for the element type.  File_Type
  16779. --        and File_Mode are subtypes declared in the Cais.Text_Io package.
  16780. --
  16781. --  Example:
  16782. --  -------
  16783. --        type Color is (Red, Yellow, Blue);
  16784. --        package Hue_Io is new Cais.Text_Io.Enumeration_Io (Color); 
  16785. --        ...
  16786. --        File : File_Type;
  16787. --        ...
  16788. --        Hue_Io.Put (File, Blue);
  16789. --        ...
  16790. --
  16791. --  Notes:
  16792. --  -----
  16793. --        This is a version of the package CAIS.TEXT_IO.ENUMERATION_IO,
  16794. --        specified in MIL-STD-CAIS section 5.3.4; all references
  16795. --        to the CAIS specification refer to the CAIS specification
  16796. --        dated 31 January 1985.
  16797. --
  16798. --  Revision History:
  16799. --  ----------------
  16800. --        None.
  16801. --
  16802. -------------------------------------------------------------------
  16803.  
  16804.         generic
  16805.             type Enum is (<>); 
  16806.         package Enumeration_Io is 
  16807.  
  16808.             Default_Width   : Field := 0; 
  16809.             Default_Setting : Type_Set := Upper_Case; 
  16810.  
  16811. ----------------------     Get     ----------------------
  16812. --
  16813. --  Purpose:
  16814. --  -------
  16815. --    This procedure reads characters from the specified
  16816. --    text file, according to the syntax of a literal
  16817. --    of the parameter type,
  16818. --    and stores the converted value in the item parameter.
  16819. --
  16820. --  Parameters:
  16821. --  ----------
  16822. --    File    open file handle.
  16823. --    Item    out parameter of the generic parameter type.
  16824. --
  16825. --  Exceptions:
  16826. --  ----------
  16827. --    Status_Error
  16828. --        raised if File is not open.
  16829. --    Mode_Error
  16830. --        raised if file mode is not In_File.
  16831. --    End_Error
  16832. --        raised if attempt is made to skip file terminator.
  16833. --    Data_Error
  16834. --        raised if the sequence input is not a lexical element
  16835. --        corresponding to the item type.
  16836. --
  16837. --  Notes:
  16838. --  -----
  16839. --    This procedure is defined in section 5.3.4.6 of MIL-STD-CAIS,
  16840. --    dated 31 January 1985.
  16841. --
  16842. ---------------------------------------------------------------------
  16843.  
  16844.             procedure Get(File : File_Type; 
  16845.                           Item : in out Enum); 
  16846.  
  16847.             procedure Get(Item : in out Enum); 
  16848.  
  16849. ----------------------     Put     ----------------------
  16850. --
  16851. --  Purpose:
  16852. --  -------
  16853. --    This procedure writes the value of Item, represented as a literal
  16854. --    of the parameter type, to the specified file.
  16855. --    
  16856. --
  16857. --  Parameters:
  16858. --  ----------
  16859. --    File    open file handle.
  16860. --    Item    in parameter of the generic parameter type.
  16861. --    Width    minimum field width.
  16862. --    Set    character set.
  16863. --
  16864. --  Exceptions:
  16865. --  ----------
  16866. --    Status_Error
  16867. --        raised if File is not open.
  16868. --    Mode_Error
  16869. --        raised if file mode is not Out_File or Append_File.
  16870. --    Layout_Error
  16871. --        raised if the number of characters to be output 
  16872. --        exceeds the maximum line length.
  16873. --
  16874. --  Notes:
  16875. --  -----
  16876. --    This procedure is defined in section 5.3.4.7 of MIL-STD-CAIS,
  16877. --    dated 31 January 1985.
  16878. --
  16879. ---------------------------------------------------------------------
  16880.  
  16881.             procedure Put(File  : File_Type; 
  16882.                           Item  : Enum; 
  16883.                           Width : Field := Default_Width; 
  16884.                           Set   : Type_Set := Default_Setting); 
  16885.  
  16886.             procedure Put(Item  : Enum; 
  16887.                           Width : Field := Default_Width; 
  16888.                           Set   : Type_Set := Default_Setting); 
  16889.  
  16890. ----------------------     Get     ----------------------
  16891. --
  16892. --  Purpose:
  16893. --  -------
  16894. --    This procedure reads characters from the specified
  16895. --    string into the item parameter, following the same
  16896. --    rule as for reading from a file, but treating the
  16897. --    end of the string as a file terminator.
  16898. --
  16899. --  Parameters:
  16900. --  ----------
  16901. --    From    string.
  16902. --    Item    out parameter of the generic parameter type.
  16903. --    Last    index value of last character read.
  16904. --
  16905. --  Exceptions:
  16906. --  ----------
  16907. --    End_Error
  16908. --        raised if attempt is made to skip file terminator.
  16909. --    Data_Error
  16910. --        raised if the sequence input is not a lexical element
  16911. --        corresponding to the item type.
  16912. --
  16913. --  Notes:
  16914. --  -----
  16915. --    Semantics correspond to Ada LRM, Section 14.3.9
  16916. --
  16917. ---------------------------------------------------------------------
  16918.  
  16919.             procedure Get(From : String; 
  16920.                           Item : in out Enum; 
  16921.                           Last : in out Positive); 
  16922.  
  16923. ----------------------     Put     ----------------------
  16924. --
  16925. --  Purpose:
  16926. --  -------
  16927. --    This procedure writes characters to the specified string,
  16928. --    following the same rule as for output to a file.
  16929. --    The number of digits before the exponent is adjusted so
  16930. --    that the literal exactly fills the string.
  16931. --
  16932. --  Parameters:
  16933. --  ----------
  16934. --    To    string.
  16935. --    Item    in parameter of generic parameter type.
  16936. --    Set    character set.
  16937. --
  16938. --  Exceptions:
  16939. --  ----------
  16940. --    Layout_Error
  16941. --        raised if the number of characters to be output 
  16942. --        exceeds the remaining string length.
  16943. --
  16944. --  Notes:
  16945. --  -----
  16946. --    Semantics correspond to Ada LRM, Section 14.3.9
  16947. --
  16948. ---------------------------------------------------------------------
  16949.  
  16950.             procedure Put(To   : in out String; 
  16951.                           Item : Enum; 
  16952.                           Set  : Type_Set := Default_Setting); 
  16953.  
  16954.         end Enumeration_Io; 
  16955.  
  16956. -----------------------------------------------------------------------------
  16957.     end Text_Io; 
  16958. -----------------------------------------------------------------------------
  16959.  
  16960. ----------------------------------------------------------------------
  16961. --                     S C R O L L _ T E R M I N A L
  16962. --
  16963. --  Purpose:
  16964. --  -------
  16965. --    This package provides the functionality of a scroll terminal.
  16966. --    A scroll terminal consists of two devices: an input device
  16967. --    (keyboard) and an associated output device (a printer or display).
  16968. --    A scroll terminal may be accesses either as a single file of mode
  16969. --    "Inout_File" or as two files: one of mode "In_File" (the keyboard)
  16970. --    and the other of mode "Out_File" (the printer or display).  As keys
  16971. --    pressed on the scroll terminal keyboard, the transmitted characters
  16972. --    are made available for reading by the CAIS Scroll_Terminal package.
  16973. --    As characters are written to the scroll terminal file, they are
  16974. --    displayed on the output device.
  16975. --
  16976. --  Usage:
  16977. --  -----
  16978. --    One of the advantages of Scroll_Terminal over Text_Io for interactive
  16979. --    I/O is that Scroll_Terminal provides some very useful host-independent
  16980. --    terminal control facilities.  For example, enabling and disabling
  16981. --    echo at the terminal is available.  Text_Io.Get is NOT required to
  16982. --    provide an unbuffered single character Get; this is available in
  16983. --    Scroll_Terminal.
  16984. --
  16985. --  Example:
  16986. --  -------
  16987. --    TBS
  16988. --
  16989. --  Notes:
  16990. --  -----
  16991. --    None.
  16992. --
  16993. --  Revision History:
  16994. --  ----------------
  16995. --
  16996. -------------------------------------------------------------------
  16997.  
  16998.     package Scroll_Terminal is 
  16999.  
  17000.         use Cais.Io_Definitions; 
  17001.         use Node_Definitions; 
  17002.  
  17003.         subtype File_Type is Cais.Io_Definitions.File_Type; 
  17004.         subtype Function_Key_Descriptor is Cais.Io_Definitions.
  17005.             Function_Key_Descriptor; 
  17006.         subtype Position_Type is Cais.Io_Definitions.Position_Type; 
  17007.         subtype Tab_Eumeration is Cais.Io_Definitions.Tab_Enumeration; 
  17008.  
  17009.         procedure Set_Position(Terminal : File_Type; 
  17010.                                Position : Position_Type); 
  17011.         procedure Set_Position(Position : Position_Type); 
  17012.         function Get_Position(Terminal : File_Type) return Position_Type; 
  17013.         function Get_Position return Position_Type; 
  17014.         function Terminal_Size(Terminal : File_Type) return Position_Type; 
  17015.         function Terminal_Size return Position_Type; 
  17016.         procedure Set_Tab(Terminal : File_Type; 
  17017.                           Kind     : Tab_Enumeration := Horizontal); 
  17018.         procedure Set_Tab(Kind : Tab_Enumeration := Horizontal); 
  17019.         procedure Clear_Tab(Terminal : File_Type; 
  17020.                             Kind     : Tab_Enumeration := Horizontal); 
  17021.         procedure Clear_Tab(Kind : Tab_Enumeration := Horizontal); 
  17022.         procedure Tab(Terminal : File_Type; 
  17023.                       Kind     : Tab_Enumeration := Horizontal; 
  17024.                       Count    : Positive := 1); 
  17025.         procedure Tab(Kind  : Tab_Enumeration := Horizontal; 
  17026.                       Count : Positive := 1); 
  17027.         procedure Bell(Terminal : File_Type); 
  17028.         procedure Bell; 
  17029.         procedure Put(Terminal : File_Type; 
  17030.                       Item     : Character); 
  17031.         procedure Put(Item : Character); 
  17032.         procedure Put(Terminal : File_Type; 
  17033.                       Item     : String); 
  17034.         procedure Put(Item : String); 
  17035.         procedure Set_Echo(Terminal : File_Type; 
  17036.                            To       : Boolean := True); 
  17037.         procedure Set_Echo(To : Boolean := True); 
  17038.         function Echo(Terminal : File_Type) return Boolean; 
  17039.         function Echo return Boolean; 
  17040.         function Maximum_Function_Key(Terminal : File_Type) return Natural; 
  17041.         function Maximum_Function_Key return Natural; 
  17042.         procedure Get(Terminal : File_Type; 
  17043.                       Item     : in out Character; 
  17044.                       Keys     : in out Function_Key_Descriptor); 
  17045.         procedure Get(Item : in out Character; 
  17046.                       Keys : in out Function_Key_Descriptor); 
  17047.         procedure Get(Terminal : File_Type; 
  17048.                       Item     : in out String; 
  17049.                       Last     : in out Natural; 
  17050.                       Keys     : in out Function_Key_Descriptor); 
  17051.         procedure Get(Item : in out String; 
  17052.                       Last : in out Natural; 
  17053.                       Keys : in out Function_Key_Descriptor); 
  17054.         function Function_Key_Count(Keys : Function_Key_Descriptor) return
  17055.             Natural; 
  17056.         procedure Function_Key(Keys           : Function_Key_Descriptor; 
  17057.                                Index          : Positive; 
  17058.                                Key_Identifier : in out Positive; 
  17059.                                Position       : in out Natural); 
  17060.         procedure Function_Key_Name(Terminal       : File_Type; 
  17061.                                     Key_Identifier : Positive; 
  17062.                                     Key_Name       : in out String; 
  17063.                                     Last           : in out Positive); 
  17064.         procedure Function_Key_Name(Key_Identifier : Positive; 
  17065.                                     Key_Name       : in out String; 
  17066.                                     Last           : in out Positive); 
  17067.         procedure New_Line(Terminal : File_Type; 
  17068.                            Count    : Positive := 1); 
  17069.         procedure New_Line(Count : Positive := 1); 
  17070.         procedure New_Page(Terminal : File_Type); 
  17071.         procedure New_Page; 
  17072.  
  17073.     end Scroll_Terminal; 
  17074.  
  17075.     package Page_Terminal is 
  17076.         use Node_Definitions; 
  17077.         use Io_Definitions; 
  17078.         use Io_Control; 
  17079.         subtype File_Type is Cais.Io_Definitions.File_Type; 
  17080.         subtype Function_Key_Descriptor is Cais.Io_Definitions.
  17081.             Function_Key_Descriptor; 
  17082.         subtype Position_Type is Cais.Io_Definitions.Position_Type; 
  17083.         subtype Tab_Enumeration is Cais.Io_Definitions.Tab_Enumeration; 
  17084.  
  17085.         type Select_Enumeration is (From_Active_Position_To_End, 
  17086.             From_Start_To_Active_Position, All_Positions); 
  17087.         type Graphic_Rendition_Enumeration is (Primary_Rendition, Bold, Faint, 
  17088.             Underscore, Slow_Blink, Rapid_Blink, Reverse_Image); 
  17089.         type Graphic_Rendition_Array is array(Graphic_Rendition_Enumeration) of 
  17090.             Boolean; 
  17091.  
  17092.         Default_Graphic_Rendition : constant Graphic_Rendition_Array := (True, 
  17093.             False, False, False, False, False, False); 
  17094.  
  17095.         procedure Set_Position(Terminal : File_Type; 
  17096.                                Position : Position_Type); 
  17097.         procedure Set_Position(Position : Position_Type); 
  17098.         function Get_Position(Terminal : File_Type) return Position_Type; 
  17099.         function Get_Position return Position_Type; 
  17100.         function Terminal_Size(Terminal : File_Type) return Position_Type; 
  17101.         function Terminal_Size return Position_Type; 
  17102.         procedure Set_Tab(Terminal : File_Type; 
  17103.                           Kind     : Tab_Enumeration := Horizontal); 
  17104.         procedure Set_Tab(Kind : Tab_Enumeration := Horizontal); 
  17105.         procedure Clear_Tab(Terminal : File_Type; 
  17106.                             Kind     : Tab_Enumeration := Horizontal); 
  17107.         procedure Clear_Tab(Kind : Tab_Enumeration := Horizontal); 
  17108.         procedure Tab(Terminal : File_Type; 
  17109.                       Kind     : Tab_Enumeration := Horizontal; 
  17110.                       Count    : Positive := 1); 
  17111.         procedure Tab(Kind  : Tab_Enumeration := Horizontal; 
  17112.                       Count : Positive := 1); 
  17113.         procedure Bell(Terminal : File_Type); 
  17114.         procedure Bell; 
  17115.         procedure Put(Terminal : File_Type; 
  17116.                       Item     : Character); 
  17117.         procedure Put(Item : Character); 
  17118.         procedure Put(Terminal : File_Type; 
  17119.                       Item     : String); 
  17120.         procedure Put(Item : String); 
  17121.         procedure Set_Echo(Terminal : File_Type; 
  17122.                            To       : Boolean := True); 
  17123.         procedure Set_Echo(To : Boolean := True); 
  17124.         function Echo(Terminal : File_Type) return Boolean; 
  17125.         function Echo return Boolean; 
  17126.         function Maximum_Function_Key(Terminal : File_Type) return Natural; 
  17127.         function Maximum_Function_Key return Natural; 
  17128.         procedure Get(Terminal : File_Type; 
  17129.                       Item     : in out Character; 
  17130.                       Keys     : in out Function_Key_Descriptor); 
  17131.         procedure Get(Item : in out Character; 
  17132.                       Keys : in out Function_Key_Descriptor); 
  17133.         procedure Get(Terminal : File_Type; 
  17134.                       Item     : in out String; 
  17135.                       Last     : in out Natural; 
  17136.                       Keys     : in out Function_Key_Descriptor); 
  17137.         procedure Get(Item : in out String; 
  17138.                       Last : in out Natural; 
  17139.                       Keys : in out Function_Key_Descriptor); 
  17140.         function Function_Key_Count(Keys : Function_Key_Descriptor) return
  17141.             Natural; 
  17142.         procedure Function_Key(Keys           : Function_Key_Descriptor; 
  17143.                                Index          : Positive; 
  17144.                                Key_Identifier : in out Positive; 
  17145.                                Position       : in out Natural); 
  17146.         procedure Function_Key_Name(Terminal       : File_Type; 
  17147.                                     Key_Identifier : Positive; 
  17148.                                     Key_Name       : in out String; 
  17149.                                     Last           : in out Positive); 
  17150.         procedure Function_Key_Name(Key_Identifier : Positive; 
  17151.                                     Key_Name       : in out String; 
  17152.                                     Last           : in out Positive); 
  17153.         procedure Delete_Character(Terminal : File_Type; 
  17154.                                    Count    : Positive := 1); 
  17155.         procedure Delete_Character(Count : Positive := 1); 
  17156.         procedure Delete_Line(Terminal : File_Type; 
  17157.                               Count    : Positive := 1); 
  17158.         procedure Delete_Line(Count : Positive := 1); 
  17159.         procedure Erase_Character(Terminal : File_Type; 
  17160.                                   Count    : Positive := 1); 
  17161.         procedure Erase_Character(Count : Positive := 1); 
  17162.         procedure Erase_In_Display(Terminal  : File_Type; 
  17163.                                    Selection : Select_Enumeration); 
  17164.         procedure Erase_In_Display(Selection : Select_Enumeration); 
  17165.         procedure Erase_In_Line(Terminal  : File_Type; 
  17166.                                 Selection : Select_Enumeration); 
  17167.         procedure Erase_In_Line(Selection : Select_Enumeration); 
  17168.         procedure Insert_Space(Terminal : File_Type; 
  17169.                                Count    : Positive := 1); 
  17170.         procedure Insert_Space(Count : Positive := 1); 
  17171.         procedure Insert_Line(Terminal : File_Type; 
  17172.                               Count    : Positive := 1); 
  17173.         procedure Insert_Line(Count : Positive := 1); 
  17174.         function Graphic_Rendition_Support(Terminal  : File_Type; 
  17175.                                            Rendition : Graphic_Rendition_Array)
  17176.             return Boolean; 
  17177.         function Graphic_Rendition_Support(Rendition : Graphic_Rendition_Array)
  17178.             return Boolean; 
  17179.         procedure Select_Graphic_Rendition(Terminal  : File_Type; 
  17180.                                            Rendition : Graphic_Rendition_Array
  17181.                                                := Default_Graphic_Rendition); 
  17182.         procedure Select_Graphic_Rendition(Rendition : Graphic_Rendition_Array
  17183.                                                := Default_Graphic_Rendition); 
  17184.  
  17185.     end Page_Terminal; 
  17186.  
  17187.     package Form_Terminal is 
  17188.         use Node_Definitions; 
  17189.         use Io_Definitions; 
  17190.         use Io_Control; 
  17191.         subtype File_Type is Cais.Io_Definitions.File_Type; 
  17192.  
  17193.         type Area_Intensity is (None, Normal, High); 
  17194.         type Area_Protection is (Unprotected, Protected); 
  17195.         type Area_Input is (Graphic_Characters, Numerics, Alphabetics); 
  17196.         type Area_Value is (No_Fill, Fill_With_Zeroes, Fill_With_Spaces); 
  17197.  
  17198.         type Form_Type(Row                           : Positive; 
  17199.                        Column                        : Positive; 
  17200.                        Area_Qualifier_Requires_Space : Boolean) is private; 
  17201.  
  17202.         subtype Printable_Character is Character range ' ' .. '~'; 
  17203.  
  17204.  
  17205.         function Maximum_Function_Key(Terminal : File_Type) return Natural; 
  17206.         function Maximum_Function_Key return Natural; 
  17207.         procedure Define_Qualified_Area(Form       : in out Form_Type; 
  17208.                                         Intensity  : Area_Intensity := Normal; 
  17209.                                         Protection : Area_Protection := 
  17210.                                             Protected; 
  17211.                                         Input      : Area_Input := 
  17212.                                             Graphic_Characters; 
  17213.                                         Value      : Area_Value := No_Fill); 
  17214.         procedure Remove_Area_Qualifier(Form : in out Form_Type); 
  17215.         procedure Set_Position(Form     : in out Form_Type; 
  17216.                                Position : Position_Type); 
  17217.         procedure Next_Qualified_Area(Form  : in out Form_Type; 
  17218.                                       Count : Positive := 1); 
  17219.         procedure Put(Form : in out Form_Type; 
  17220.                       Item : Printable_Character); 
  17221.         procedure Put(Form : in out Form_Type; 
  17222.                       Item : String); 
  17223.         procedure Erase_Area(Form : in out Form_Type); 
  17224.         procedure Erase_Form(Form : in out Form_Type); 
  17225.         procedure Activate(Terminal : File_Type; 
  17226.                            Form     : in out Form_Type); 
  17227.         procedure Get(Form : in out Form_Type; 
  17228.                       Item : in out Printable_Character); 
  17229.         procedure Get(Form : in out Form_Type; 
  17230.                       Item : in out String); 
  17231.         function Is_Form_Updated(Form : Form_Type) return Boolean; 
  17232.         function Termination_Key(Form : Form_Type) return Natural; 
  17233.         function Form_Size(Form : Form_Type) return Position_Type; 
  17234.         function Terminal_Size(Terminal : File_Type) return Position_Type; 
  17235.         function Terminal_Size return Position_Type; 
  17236.         function Area_Qualifier_Requires_Space(Form : Form_Type) return Boolean
  17237.             ; 
  17238.         function Area_Qualifier_Requires_Space(Terminal : File_Type) return
  17239.             Boolean; 
  17240.         function Area_Qualifier_Requires_Space return Boolean; 
  17241.  
  17242.  
  17243.     private
  17244.  
  17245.         type Form_Type(Row                           : Positive; 
  17246.                        Column                        : Positive; 
  17247.                        Area_Qualifier_Requires_Space : Boolean) is 
  17248.             record
  17249.                 null; -- should be defined by implementor
  17250.             end record; 
  17251.  
  17252.     end Form_Terminal; 
  17253.  
  17254.  
  17255.     package Magnetic_Tape is 
  17256.         use Node_Definitions; 
  17257.         use Io_Definitions; 
  17258.  
  17259.         type Tape_Position is (Beginning_Of_Tape, Physical_End_Of_Tape, 
  17260.             Tape_Mark, Other); 
  17261.  
  17262.         subtype Volume_String is String(1 .. 6); 
  17263.         subtype File_String is String(1 .. 17); 
  17264.         subtype Reel_Name is String; 
  17265.         subtype File_Type is Cais.Io_Definitions.File_Type; 
  17266.         subtype Label_String is String(1 .. 80); 
  17267.  
  17268.         procedure Mount(Tape_Drive : File_Type; 
  17269.                         Tape_Name  : Reel_Name; 
  17270.                         Density    : Positive); 
  17271.         procedure Load_Unlabeled(Tape_Drive : File_Type; 
  17272.                                  Density    : Positive; 
  17273.                                  Block_Size : Positive); 
  17274.         procedure Initialize_Unlabeled(Tape_Drive : File_Type; 
  17275.                                        Density    : Positive; 
  17276.                                        Block_Size : Positive); 
  17277.         procedure Load_Labeled(Tape_Drive        : File_Type; 
  17278.                                Volume_Identifier : Volume_String; 
  17279.                                Density           : Positive; 
  17280.                                Block_Size        : Positive); 
  17281.         procedure Initialize_Labeled(Tape_Drive        : File_Type; 
  17282.                                      Volume_Identifier : Volume_String; 
  17283.                                      Density           : Positive; 
  17284.                                      Block_Size        : Positive; 
  17285.                                      Accessibility     : Character := ' '); 
  17286.         procedure Unload(Tape_Drive : File_Type); 
  17287.         procedure Dismount(Tape_Drive : File_Type); 
  17288.         function Is_Loaded(Tape_Drive : File_Type) return Boolean; 
  17289.         function Is_Mounted(Tape_Drive : File_Type) return Boolean; 
  17290.         function Tape_Status(Tape_Drive : File_Type) return Tape_Position; 
  17291.         procedure Rewind_Tape(Tape_Drive : File_Type); 
  17292.         procedure Skip_Tape_Marks(Tape_Drive : File_Type; 
  17293.                                   Number     : Integer := 1; 
  17294.                                   Tape_State : in out Tape_Position); 
  17295.         procedure Write_Tape_Mark(Tape_Drive : File_Type; 
  17296.                                   Number     : Positive := 1; 
  17297.                                   Tape_State : in out Tape_Position); 
  17298.         procedure Volume_Header(Tape_Drive        : File_Type; 
  17299.                                 Volume_Identifier : Volume_String; 
  17300.                                 Accessibility     : Character := ' '); 
  17301.         procedure File_Header(Tape_Drive      : File_Type; 
  17302.                               File_Identifier : File_String; 
  17303.                               Expiration_Date : String := " 99366"; 
  17304.                               Accessibility   : Character := ' '); 
  17305.         procedure End_File_Label(Tape_Drive : File_Type); 
  17306.         procedure Read_Label(Tape_Drive : File_Type; 
  17307.                              Label      : in out Label_String); 
  17308.  
  17309.  
  17310.  
  17311.     end Magnetic_Tape; 
  17312. ----------------------------------------------------------------------
  17313. --               F I L E _ I M P O R T _ E X P O R T
  17314. --
  17315. --  Purpose:
  17316. --  -------
  17317. --        The CAIS allows a particular CAIS implementation to
  17318. --        maintain files separately from files maintained by
  17319. --        the host file system.  This package provides the
  17320. --        capability to transfer files between these two systems.
  17321. --
  17322. --  Usage:
  17323. --  -----
  17324. --        The operations contained in this package are
  17325. --        Import which transfers a file from the host file 
  17326. --        system into a CAIS file node, and Export which 
  17327. --        transfers the contents of a CAIS file node to a 
  17328. --        host file.
  17329. --
  17330. --  Notes:
  17331. --  -----
  17332. --        This is a version of the package CAIS.FILE_IMPORT_EXPORT, 
  17333. --        specified in MIL-STD-CAIS section 5.3.10; all references 
  17334. --        to the CAIS specification refer to the CAIS specification
  17335. --        dated 31 January 1985.
  17336. --
  17337. --  Revision History:
  17338. --  ----------------
  17339. --        None.
  17340. --
  17341. -------------------------------------------------------------------
  17342.  
  17343.     package File_Import_Export is 
  17344.  
  17345.         use Node_Definitions; 
  17346.  
  17347. ----------------------     Import     ----------------------
  17348. --
  17349. --  Purpose:
  17350. --  -------
  17351. --    This procedure searches for a file in the host file system
  17352. --    named Host_File_Name and copies its contents into a CAIS
  17353. --    file which is the contents of the node identified by Node.
  17354. --
  17355. --  Parameters:
  17356. --  ----------
  17357. --    Node        open node handle on the file node.
  17358. --    Host_File_Name    name of the host file to be copied.
  17359. --
  17360. --  Exceptions:
  17361. --  ----------
  17362. --    Name_Error
  17363. --        raised if the node identified by Node is inaccessible.
  17364. --    Use_Error
  17365. --        raised if Host_File_Name noes not adhere to the
  17366. --        required syntax for file names in the host file system
  17367. --        or if Host_File_Name does not exist in the host file
  17368. --        system.
  17369. --
  17370. --        also raised if File is not the value of the attribute
  17371. --        Kind of the node identified by Node.
  17372. --    Status_Error
  17373. --        raised if Node is not an open node handle.
  17374. --    Intent_Violation
  17375. --        raised if Node was not opened with an intent establishing
  17376. --        the right to write contents.
  17377. --    Security_Violation
  17378. --        raised if the operation represents a violation of mandatory
  17379. --        access controls.  Security_Violation is raised only if the
  17380. --        conditions for other exceptions are not present.
  17381. --
  17382. --  Notes:
  17383. --  -----
  17384. --    Semantics are defined in cais_MIL-STD Section 5.3.10.1
  17385. --
  17386. ---------------------------------------------------------------------
  17387.  
  17388.         procedure Import(Node           : in out Node_Type; 
  17389.                          Host_File_Name : in String); 
  17390.  
  17391.  
  17392. -------------------------------------------------------------------------------
  17393. --
  17394. --    Alternate interface using Name (pathname) rather than Base, Relation,
  17395. --    and Key to refer to file node.
  17396. --
  17397. -------------------------------------------------------------------------------
  17398.  
  17399.         procedure Import(Name           : in Name_String; 
  17400.                          Host_File_Name : in String); 
  17401.  
  17402.  
  17403. ----------------------     Export     ----------------------
  17404. --
  17405. --  Purpose:
  17406. --  -------
  17407. --    This procedure creates a new file named Host_File_Name in
  17408. --    the host file system and copies the contents of the file
  17409. --    node identified by Node into it.
  17410. --
  17411. --  Parameters:
  17412. --  ----------
  17413. --    Node        open node handle on the file node.
  17414. --    Host_File_Name    name of the host file to be created.
  17415. --
  17416. --  Exceptions:
  17417. --  ----------
  17418. --    Name_Error
  17419. --        raised if the node identified by Node is inaccessible.
  17420. --    Use_Error
  17421. --        raised if Host_File_Name noes not adhere to the
  17422. --        required syntax for file names in the host file system
  17423. --        or if Host_File_Name cannot be created in the host file
  17424. --        system.
  17425. --
  17426. --        also raised if File is not the value of the attribute
  17427. --        Kind of the node identified by Node.
  17428. --    Status_Error
  17429. --        raised if Node is not an open node handle.
  17430. --    Intent_Violation
  17431. --        raised if Node was not opened with an intent establishing
  17432. --        the right to read contents.
  17433. --
  17434. --  Notes:
  17435. --  -----
  17436. --    Semantics are defined in cais_MIL-STD Section 5.3.10.2
  17437. --
  17438. ---------------------------------------------------------------------
  17439.  
  17440.         procedure Export(Node           : in out Node_Type; 
  17441.                          Host_File_Name : in String); 
  17442.  
  17443.  
  17444. -------------------------------------------------------------------------------
  17445. --
  17446. --    Alternate interface using Name (pathname) rather than Base, Relation,
  17447. --    and Key to refer to file node.
  17448. --
  17449. -------------------------------------------------------------------------------
  17450.  
  17451.         procedure Export(Name           : in Name_String; 
  17452.                          Host_File_Name : in String); 
  17453.  
  17454. ----------------------------------------------------------------------------
  17455.     end File_Import_Export; 
  17456.  
  17457. -- Not in CAIS interface
  17458.  
  17459.     procedure Add_User; 
  17460.     procedure Delete_User; 
  17461.  
  17462. ----------------------------------------------------------------------------
  17463.  
  17464. private         -- all of private portion is implementation-specific.
  17465.  
  17466.     -- Node_Type_Record is defined in the CAIS package body
  17467.     type Node_Rec; 
  17468.     type Node_Type is access Node_Rec; 
  17469.  
  17470. end Cais; 
  17471. --::::::::::::::
  17472. --cais_text_io_body.a
  17473. --::::::::::::::
  17474.  
  17475.  
  17476. ----------------------------------------------------------------------
  17477. --                      T E X T _ I O
  17478. --                 (Package Body)
  17479. --
  17480. --               Procedure and Function Bodies for the
  17481. --            CAIS Text_Io Access Method
  17482. --
  17483. --
  17484. --                  Ada Software Engineering Group
  17485. --                      The MITRE Corporation
  17486. --                         McLean, VA 22102
  17487. --
  17488. --
  17489. --            Wed Oct  9 11:03:56 EDT 1985
  17490. --
  17491. --                 (Unclassified and uncopyrighted)
  17492. --
  17493. ----------------------------------------------------------------------
  17494. ----------------------------------------------------------------------
  17495. --                      T E X T _ I O
  17496. --
  17497. --  Purpose:
  17498. --  -------
  17499. --        This package comprises the CAIS Input/Output operations
  17500. --        on text files, which correspond to those in Ada LRM
  17501. --        Chapter 14 I/O.  Input and output operations access
  17502. --        the contents of CAIS file nodes.  Generic packages
  17503. --        for text input/output of integer, enumeration, fixed and
  17504. --        float types are nested in CAIS Text_Io, as they are in
  17505. --        Ada (Ch. 14) I/O.  Additional interfaces to manage Standard
  17506. --        and Current Error files are provided.
  17507. --
  17508. --  Usage:
  17509. --  -----
  17510. --        Usage is analogous to usage of the Ada Text_Io package.
  17511. --        CAIS file nodes correspond to ordinary Ada files, and
  17512. --        file handles are Ada objects of type CAIS Text_Io.File_Type,
  17513. --        rather than Ada (LRM) Text_Io.File_Type.
  17514. --
  17515. --  Notes:
  17516. --  -----
  17517. --        This is a version of the package CAIS.TEXT_IO,
  17518. --        specified in MIL-STD-CAIS section 5.3.4; all references
  17519. --        to the CAIS specification refer to the CAIS specification
  17520. --        dated 31 January 1985.
  17521. --
  17522. --  Revision History:
  17523. --  ----------------
  17524. --        None.
  17525. --
  17526. -------------------------------------------------------------------
  17527.  
  17528. with Text_Io; 
  17529.  
  17530.  
  17531. separate(Cais)
  17532. package body Text_Io is 
  17533.  
  17534.     use Node_Definitions; 
  17535.     use Node_Management; 
  17536.     use Node_Internals; 
  17537.     use List_Utilities; 
  17538.     use Cais_Utilities; 
  17539.     use Io_Definitions; 
  17540.     use Trace; 
  17541.     use Identifier_Items; 
  17542.  
  17543.     type Mode_Array is array(Positive range <>) of File_Mode; 
  17544.  
  17545.                                         --File handles for pseudo standard
  17546.                                         -- and current input, output, and
  17547.                                         -- error files
  17548.     Cais_Standard_Input      : File_Type; 
  17549.     Cais_Standard_Output     : File_Type; 
  17550.     Cais_Standard_Error      : File_Type; 
  17551.     Cais_Current_Input       : File_Type; 
  17552.     Cais_Current_Output      : File_Type; 
  17553.     Cais_Current_Error       : File_Type; 
  17554.                                         -- Variable for recording open status
  17555.                                         --   of standard/current files
  17556.     File_Environment_Is_Open : Boolean := False; 
  17557.  
  17558.  
  17559.  
  17560. --------------------------- Establish_File_Environment ------------------------
  17561. --
  17562. --    Local procedure which stubs the initialization of standard and
  17563. --    current input for the "current process."
  17564. --
  17565. -------------------------------------------------------------------------------
  17566.  
  17567.     procedure Establish_File_Environment is 
  17568.     begin
  17569.         Initialize(Cais_Standard_Input); 
  17570.         Initialize(Cais_Standard_Output); 
  17571.         Initialize(Cais_Standard_Error); 
  17572.         Initialize(Cais_Current_Input); 
  17573.         Initialize(Cais_Current_Output); 
  17574.         Initialize(Cais_Current_Error); 
  17575.  
  17576.         Set_Contents_File_Name(Cais_Standard_Input, "/dev/tty"); 
  17577.         Set_Contents_File_Name(Cais_Standard_Output, "/dev/tty"); 
  17578.         Set_Contents_File_Name(Cais_Standard_Error, "/dev/tty"); 
  17579.         Set_Contents_File_Name(Cais_Current_Input, "/dev/tty"); 
  17580.         Set_Contents_File_Name(Cais_Current_Output, "/dev/tty"); 
  17581.         Set_Contents_File_Name(Cais_Current_Error, "/dev/tty"); 
  17582.  
  17583.         Standard.Text_Io.Open(Get_File_Type(Cais_Standard_Input).all, Standard.
  17584.             Text_Io.In_File, "/dev/tty"); 
  17585.         Standard.Text_Io.Open(Get_File_Type(Cais_Standard_Output).all, Standard.
  17586.             Text_Io.Out_File, "/dev/tty"); 
  17587.         Standard.Text_Io.Open(Get_File_Type(Cais_Standard_Error).all, Standard.
  17588.             Text_Io.Out_File, "/dev/tty"); 
  17589.         Standard.Text_Io.Open(Get_File_Type(Cais_Current_Input).all, Standard.
  17590.             Text_Io.In_File, "/dev/tty"); 
  17591.         Standard.Text_Io.Open(Get_File_Type(Cais_Current_Output).all, Standard.
  17592.             Text_Io.Out_File, "/dev/tty"); 
  17593.         Standard.Text_Io.Open(Get_File_Type(Cais_Current_Error).all, Standard.
  17594.             Text_Io.Out_File, "/dev/tty"); 
  17595.  
  17596.         File_Environment_Is_Open := True; 
  17597.     end Establish_File_Environment; 
  17598.  
  17599.  
  17600. ---------------------------    Check_Open    --------------------------------
  17601. --
  17602. --    Local procedure which checks that file has required status
  17603. --
  17604. -------------------------------------------------------------------------------
  17605.  
  17606.     procedure Check_Open(File            : File_Type; 
  17607.                          Required_Result : Boolean) is 
  17608.     begin
  17609.         if (Is_Open(File) /= Required_Result) then 
  17610.             raise Cais.Io_Definitions.Status_Error; 
  17611.         end if; 
  17612.     end Check_Open; 
  17613.  
  17614. ---------------------------    Check_Open    --------------------------------
  17615. --
  17616. --    Local procedure which checks that node has required status
  17617. --
  17618. -------------------------------------------------------------------------------
  17619.  
  17620.     procedure Check_Open(Node            : Cais.Node_Type; 
  17621.                          Required_Result : Boolean) is 
  17622.     begin
  17623.         if (Is_Open(Node) /= Required_Result) then 
  17624.             raise Node_Definitions.Status_Error; 
  17625.         end if; 
  17626.     end Check_Open; 
  17627.  
  17628.  
  17629. ---------------------------    Check_Not_Mode    --------------------------------
  17630. --
  17631. --    Local procedure which checks that mode is not in array of
  17632. --    excluded modes
  17633. --
  17634. -------------------------------------------------------------------------------
  17635.  
  17636.     procedure Check_Not_Mode(File      : File_Type; 
  17637.                              Bad_Modes : Mode_Array) is 
  17638.     begin
  17639.         for I in Bad_Modes'range loop
  17640.             if Bad_Modes(I) = Mode(File) then 
  17641.                 raise Mode_Error; 
  17642.             end if; 
  17643.         end loop; 
  17644.     end Check_Not_Mode; 
  17645.  
  17646.  
  17647.  
  17648. ---------------------------- Validate_Mode -----------------------------------
  17649. --
  17650. --    Local procedure which checks that Mode and intent of file_node
  17651. --    specified by File are consistent, and determines corresponding
  17652. --    Text_Io File_Mode.
  17653. --
  17654. -------------------------------------------------------------------------------
  17655.  
  17656.  
  17657.     procedure Validate_Mode(File     : File_Type; 
  17658.                             Mode     : File_Mode; 
  17659.                             Textmode : in out Standard.Text_Io.File_Mode) is 
  17660.         Intent   : Intention(Pragmatics.Intent_Count); 
  17661.         Intended : Intention(1 .. 2); 
  17662.     begin
  17663.                                                         --Determine mode and
  17664.                                                         --check intentions
  17665.         Get_Intent(File, Intent); 
  17666.         case Mode is 
  17667.             when Cais.Text_Io.In_File => 
  17668.                 Textmode := Standard.Text_Io.In_File; 
  17669.                 Check_Intentions(Intent, Read_Contents); 
  17670.             when Cais.Text_Io.Out_File => 
  17671.                 Textmode := Standard.Text_Io.Out_File; 
  17672.                 Check_Intentions(Intent, Write_Contents); 
  17673.             when Cais.Text_Io.Inout_File => 
  17674.                 Textmode := Standard.Text_Io.Out_File; 
  17675.                 Check_Intentions(Intent, (1 => Read_Contents, 2 => 
  17676.                     Write_Contents)); 
  17677.             when Cais.Text_Io.Append_File => 
  17678.                 Textmode := Standard.Text_Io.Out_File; 
  17679.                 Check_Intentions(Intent, Append_Contents); 
  17680.         end case; 
  17681.  
  17682.     end Validate_Mode; 
  17683.  
  17684. ---------------------------- Set_For_Append -----------------------------------
  17685. --
  17686. --    Local procedure which positions a file opened in Append_File
  17687. --    mode.  
  17688. --
  17689. -------------------------------------------------------------------------------
  17690.  
  17691.     procedure Set_For_Append(File : in out File_Type) is separate; 
  17692.  
  17693. --------------------------------------------------------------------------
  17694. --
  17695. --    Separate procedure Create
  17696. --
  17697. --------------------------------------------------------------------------
  17698.  
  17699.     procedure Create(File           : in out File_Type; 
  17700.                      Base           : in out Node_Type; 
  17701.                      Key            : Relationship_Key := Latest_Key; 
  17702.                      Relation       : Relation_Name := Default_Relation; 
  17703.                      Mode           : File_Mode := Inout_File; 
  17704.                      Form           : List_Type := Empty_List; 
  17705.                      Attributes     : List_Type := Empty_List; 
  17706.                      Access_Control : List_Type := Empty_List; 
  17707.                      Level          : List_Type := Empty_List) is separate; 
  17708.  
  17709.  
  17710.  
  17711. -------------------------------------------------------------------------------
  17712. --
  17713. --    Alternate interface using Name (pathname) rather than Base, Relation,
  17714. --    and Key to refer to file node.
  17715. --
  17716. -------------------------------------------------------------------------------
  17717.  
  17718.     procedure Create(File           : in out File_Type; 
  17719.                      Name           : Name_String; 
  17720.                      Mode           : File_Mode := Inout_File; 
  17721.                      Form           : List_Type := Empty_List; 
  17722.                      Attributes     : List_Type := Empty_List; 
  17723.                      Access_Control : List_Type := Empty_List; 
  17724.                      Level          : List_Type := Empty_List) is 
  17725.         Base : Node_Type; 
  17726.     begin
  17727.         Open(Base, Base_Path(Name), (1 => Append_Relationships)); 
  17728.         Create(File, Base, Last_Key(Name), Last_Relation(Name), Mode, Form, 
  17729.             Attributes, Access_Control, Level); 
  17730.         Close(Base); 
  17731.     exception
  17732.         when others => 
  17733.         if Is_Open (File)
  17734.         then
  17735.         Close (File);
  17736.         end if;
  17737.  
  17738.             Close(Base); 
  17739.             raise; 
  17740.  
  17741.     end Create; 
  17742.  
  17743.  
  17744. --------------------------------------------------------------------------
  17745. --
  17746. --    Separate procedure Open
  17747. --
  17748. --------------------------------------------------------------------------
  17749.     procedure Open(File : in out File_Type; 
  17750.                    Node : Node_Type; 
  17751.                    Mode : File_Mode) is separate; 
  17752.  
  17753.  
  17754. -------------------------------------------------------------------------------
  17755. --
  17756. --    Alternate interface using Name (pathname) rather than Base, Relation,
  17757. --    and Key to refer to file node.
  17758. --
  17759. -------------------------------------------------------------------------------
  17760.  
  17761.     procedure Open(File : in out File_Type; 
  17762.                    Name : Name_String; 
  17763.                    Mode : File_Mode) is 
  17764.         Node : Node_Type; 
  17765.     begin
  17766.         case Mode is 
  17767.             when In_File => 
  17768.                 Open(Node, Name, (1 => Read_Contents)); 
  17769.             when Out_File => 
  17770.                 Open(Node, Name, (1 => Write_Contents)); 
  17771.             when Inout_File => 
  17772.                 Open(Node, Name, (1 => Read_Contents, 2 => Write_Contents)); 
  17773.             when Append_File => 
  17774.                 Open(Node, Name, (1 => Append_Contents)); 
  17775.         end case; 
  17776.         Open(File, Node, Mode); 
  17777.         Close(Node); 
  17778.     exception
  17779.         when others => 
  17780.         if Is_Open (File)
  17781.         then
  17782.         Close (File);
  17783.         end if;
  17784.  
  17785.             Close(Node); 
  17786.             raise; 
  17787.  
  17788.     end Open; 
  17789.  
  17790. --------------------------------------------------------------------------
  17791. --
  17792. --    Separate procedure Close
  17793. --
  17794. --------------------------------------------------------------------------
  17795.     procedure Close(File : in out File_Type) is separate; 
  17796.  
  17797. --------------------------------------------------------------------------
  17798. --
  17799. --    Separate procedure Delete
  17800. --
  17801. --------------------------------------------------------------------------
  17802.     procedure Delete(File : in out File_Type) is separate; 
  17803.  
  17804. ----------------------     Reset     ----------------------
  17805. --
  17806. --  Purpose:
  17807. --  -------
  17808. --    Reset a CAIS file.
  17809. --
  17810. --  Parameters:
  17811. --  ----------
  17812. --    File    An open file handle on the file being reset.
  17813. --
  17814. --  Exceptions:
  17815. --  ----------
  17816. --    Use_Error
  17817. --        raised if the node associated with the file identified
  17818. --        by File has a value of Terminal or Magnetic_Tape for
  17819. --        the attribute File_Kind and the Mode is Append_File.
  17820. --
  17821. --  Notes:
  17822. --  -----
  17823. --    This procedure is defined in section 5.3.4.5 of MIL-STD-CAIS,
  17824. --    dated 31 January 1985.
  17825. ---------------------------------------------------------------------
  17826.  
  17827.     procedure Reset(File : in out File_Type) is 
  17828.     begin
  17829.         Check_Open(File, True);   -- Status_Error if File is not open
  17830.         Standard.Text_Io.Reset(Get_File_Type(File).all); 
  17831.     end Reset; 
  17832.  
  17833. ----------------------     Reset     ----------------------
  17834. --
  17835. --  Purpose:
  17836. --  -------
  17837. --    Reset the file mode of a CAIS file.
  17838. --
  17839. --  Parameters:
  17840. --  ----------
  17841. --    File    An open file handle on the file being reset.
  17842. --    Mode    Indicates the mode of the file.
  17843. --
  17844. --  Exceptions:
  17845. --  ----------
  17846. --    Use_Error
  17847. --        raised if the node associated with the file identified
  17848. --        by File has a value of Terminal or Magnetic_Tape for
  17849. --        the attribute File_Kind and the Mode is Append_File.
  17850. --
  17851. --  Notes:
  17852. --  -----
  17853. --    This procedure is defined in section 5.3.4.5 of MIL-STD-CAIS,
  17854. --    dated 31 January 1985.
  17855. ---------------------------------------------------------------------
  17856.  
  17857.     procedure Reset(File : in out File_Type; 
  17858.                     Mode : File_Mode) is separate; 
  17859.  
  17860. ----------------------     Mode     ----------------------
  17861. --
  17862. --  Purpose:
  17863. --  -------
  17864. --    Returns the current mode of the current CAIS file.
  17865. --
  17866. --  Parameters:
  17867. --  ----------
  17868. --    File    open file handle.
  17869. --
  17870. --  Exceptions:
  17871. --  ----------
  17872. --    Status_Error
  17873. --        raised if file handle is not open.
  17874. --
  17875. --  Notes:
  17876. --  -----
  17877. --    Semantics correspond to Ada LRM, Section 14.2.1
  17878. --
  17879. ---------------------------------------------------------------------
  17880.  
  17881.     function Mode(File : File_Type) return File_Mode is 
  17882.         Mode : File_Mode; 
  17883.     begin
  17884.         Check_Open(File, True);   -- Status_Error if File is not open
  17885.         Cais.Io_Definitions.Get_Mode(File, Mode); 
  17886.         return Mode; 
  17887.     exception
  17888.     -- exceptions that are propagated
  17889.         when Cais.Io_Definitions.Status_Error | Cais.Io_Definitions.Device_Error
  17890.             => 
  17891.             raise; 
  17892.  
  17893.     -- predefined exceptions (propagated with trace)
  17894.         when Constraint_Error | Tasking_Error | Program_Error | Storage_Error | 
  17895.             Numeric_Error => 
  17896.             Trace.Report("PREDEFINED EXCEPTION in Cais.Text_Io.Mode "); 
  17897.             raise; 
  17898.  
  17899.     -- unanticipated exceptions
  17900.         when others => 
  17901.             Trace.Report("UNANTICIPATED EXCEPTION in Cais.Text_Io.Mode "); 
  17902.             raise Trace.Assertion_Violation; 
  17903.  
  17904.     end Mode; 
  17905.  
  17906. ----------------------     Name     ----------------------
  17907. --
  17908. --  Purpose:
  17909. --  -------
  17910. --    Returns a string containing the name of the CAIS file 
  17911. --    node currently associated with the file handle.
  17912. --
  17913. --  Parameters:
  17914. --  ----------
  17915. --    File    open file handle.
  17916. --
  17917. --  Exceptions:
  17918. --  ----------
  17919. --    Status_Error
  17920. --        raised if file handle is not open.
  17921. --
  17922. --  Notes:
  17923. --  -----
  17924. --    Semantics correspond to Ada LRM, Section 14.2.1
  17925. --
  17926. ---------------------------------------------------------------------
  17927.  
  17928.     function Name(File : File_Type) return String is 
  17929.         File_Node_Name : String(1 .. Pragmatics.Max_Name_String); 
  17930.         Last           : Natural; 
  17931.     begin
  17932.         Check_Open(File, True);   -- Status_Error if File is not open
  17933.         Get_Name(File, File_Node_Name, Last); 
  17934.         return File_Node_Name(1 .. Last); 
  17935.     exception
  17936.     -- exceptions that are propagated
  17937.         when Cais.Io_Definitions.Status_Error | Cais.Io_Definitions.Device_Error
  17938.             => 
  17939.             raise; 
  17940.  
  17941.     -- predefined exceptions (propagated with trace)
  17942.         when Constraint_Error | Tasking_Error | Program_Error | Storage_Error | 
  17943.             Numeric_Error => 
  17944.             Trace.Report("PREDEFINED EXCEPTION in Cais.Text_Io.Name "); 
  17945.             raise; 
  17946.  
  17947.     -- unanticipated exceptions
  17948.         when others => 
  17949.             Trace.Report("UNANTICIPATED EXCEPTION in Cais.Text_Io.Name "); 
  17950.             raise Trace.Assertion_Violation; 
  17951.  
  17952.     end Name; 
  17953.  
  17954. ----------------------     Form     ----------------------
  17955. --
  17956. --  Purpose:
  17957. --  -------
  17958. --    Returns the form string for the external file currently
  17959. --    associated with the given file.
  17960. --
  17961. --  Parameters:
  17962. --  ----------
  17963. --    File    open file handle.
  17964. --
  17965. --  Exceptions:
  17966. --  ----------
  17967. --    Status_Error
  17968. --        raised if file handle is not open.
  17969. --
  17970. --  Notes:
  17971. --  -----
  17972. --    Semantics correspond to Ada LRM, Section 14.2.1
  17973. --
  17974. ---------------------------------------------------------------------
  17975.  
  17976.     function Form(File : File_Type) return String is 
  17977.     begin
  17978.         Check_Open(File, True);   -- Status_Error if File is not open
  17979.         return Standard.Text_Io.Form(Get_File_Type(File).all); 
  17980.     exception
  17981.     -- exceptions that are propagated
  17982.         when Cais.Io_Definitions.Status_Error | Cais.Io_Definitions.Device_Error
  17983.             => 
  17984.             raise; 
  17985.  
  17986.     -- predefined exceptions (propagated with trace)
  17987.         when Constraint_Error | Tasking_Error | Program_Error | Storage_Error | 
  17988.             Numeric_Error => 
  17989.             Trace.Report("PREDEFINED EXCEPTION in Cais.Text_Io.Form "); 
  17990.             raise; 
  17991.  
  17992.     -- unanticipated exceptions
  17993.         when others => 
  17994.             Trace.Report("UNANTICIPATED EXCEPTION in Cais.Text_Io.Form "); 
  17995.             raise Trace.Assertion_Violation; 
  17996.  
  17997.     end Form; 
  17998.  
  17999.  
  18000. ----------------------     Is_Open     ----------------------
  18001. --
  18002. --  Purpose:
  18003. --  -------
  18004. --    Returns TRUE if the file handle is open, otherwise returns FALSE.
  18005. --
  18006. --  Parameters:
  18007. --  ----------
  18008. --    File    file handle.
  18009. --
  18010. --  Exceptions:
  18011. --  ----------
  18012. --    None.
  18013. --
  18014. --  Notes:
  18015. --  -----
  18016. --    Semantics correspond to Ada LRM, Section 14.2.1
  18017. --
  18018. ---------------------------------------------------------------------
  18019.  
  18020.     function Is_Open(File : File_Type) return Boolean is 
  18021.     begin
  18022.         return (not Un_Initialized(File)) and then Standard.Text_Io.Is_Open(
  18023.             Get_File_Type(File).all); 
  18024.  
  18025.     exception
  18026.     -- exceptions that are propagated
  18027.         when Cais.Io_Definitions.Device_Error => 
  18028.             raise; 
  18029.  
  18030.     -- predefined exceptions (propagated with trace)
  18031.         when Constraint_Error | Tasking_Error | Program_Error | Storage_Error | 
  18032.             Numeric_Error => 
  18033.             Trace.Report("PREDEFINED EXCEPTION in Cais.Text_Io.Is_Open "); 
  18034.             raise; 
  18035.  
  18036.     -- unanticipated exceptions
  18037.         when others => 
  18038.             Trace.Report("UNANTICIPATED EXCEPTION in Cais.Text_Io.Is_Open "); 
  18039.             raise Trace.Assertion_Violation; 
  18040.  
  18041.     end Is_Open; 
  18042.  
  18043.  
  18044.  
  18045. --------------------------------------------------------------------------
  18046. --
  18047. --    Separate procedure Set_Input
  18048. --
  18049. --------------------------------------------------------------------------
  18050.     procedure Set_Input(File : File_Type) is separate; 
  18051.  
  18052.  
  18053. --------------------------------------------------------------------------
  18054. --
  18055. --    Separate procedure Set_Output
  18056. --
  18057. --------------------------------------------------------------------------
  18058.     procedure Set_Output(File : File_Type) is separate; 
  18059.  
  18060.  
  18061. --------------------------------------------------------------------------
  18062. --
  18063. --    Separate procedure Set_Error
  18064. --
  18065. --------------------------------------------------------------------------
  18066.     procedure Set_Error(File : File_Type) is separate; 
  18067.  
  18068.  
  18069. --------------------------------------------------------------------------
  18070. --
  18071. --    Separate function Standard_Input
  18072. --
  18073. --------------------------------------------------------------------------
  18074.     function Standard_Input return File_Type is separate; 
  18075.  
  18076.  
  18077.  
  18078. --------------------------------------------------------------------------
  18079. --
  18080. --    Separate function Standard_Output
  18081. --
  18082. --------------------------------------------------------------------------
  18083.     function Standard_Output return File_Type is separate; 
  18084.  
  18085.  
  18086. --------------------------------------------------------------------------
  18087. --
  18088. --    Separate function Standard_Error
  18089. --
  18090. --------------------------------------------------------------------------
  18091.     function Standard_Error return File_Type is separate; 
  18092.  
  18093.  
  18094. --------------------------------------------------------------------------
  18095. --
  18096. --    Separate function Current_Input
  18097. --
  18098. --------------------------------------------------------------------------
  18099.     function Current_Input return File_Type is separate; 
  18100.  
  18101.  
  18102. --------------------------------------------------------------------------
  18103. --
  18104. --    Separate function Current_Output
  18105. --
  18106. --------------------------------------------------------------------------
  18107.     function Current_Output return File_Type is separate; 
  18108.  
  18109.  
  18110. --------------------------------------------------------------------------
  18111. --
  18112. --    Separate function Current_Error
  18113. --
  18114. --------------------------------------------------------------------------
  18115.     function Current_Error return File_Type is separate; 
  18116.  
  18117.  
  18118. ----------------------     Set_Line_Length     ----------------------
  18119. --
  18120. --  Purpose:
  18121. --  -------
  18122. --    Sets the maximum line length of the specified output file to the
  18123. --    number of characters specified by To.  The value 0 for To specifies an
  18124. --    unbounded line length.
  18125. --
  18126. --  Parameters:
  18127. --  ----------
  18128. --    File    open file handle.
  18129. --    To    number to which bound is to be set.
  18130. --
  18131. --  Exceptions:
  18132. --  ----------
  18133. --    Status_Error
  18134. --        raised if file is not open.
  18135. --    Mode_Error
  18136. --        raised if mode of the file is not Out_File or Append_File.
  18137. --    Use_Error
  18138. --        raised if the specified line length is inappropriate for
  18139. --        the associated external file.
  18140. --
  18141. --  Notes:
  18142. --  -----
  18143. --    Semantics correspond to Ada LRM, Section 14.3.3
  18144. --
  18145. ---------------------------------------------------------------------
  18146.  
  18147.     procedure Set_Line_Length(File : File_Type; 
  18148.                               To   : Count) is 
  18149.     begin
  18150.         Check_Open(File, True);   -- Status_Error if File is not open
  18151.         Standard.Text_Io.Set_Line_Length(Get_File_Type(File).all, Standard.
  18152.             Text_Io.Count(To)); 
  18153.     exception
  18154.     -- exceptions that are propagated
  18155.         when Cais.Io_Definitions.Status_Error | Cais.Io_Definitions.Mode_Error
  18156.             | Cais.Io_Definitions.Device_Error | Cais.Io_Definitions.Use_Error
  18157.             => 
  18158.             raise; 
  18159.  
  18160.     -- predefined exceptions (propagated with trace)
  18161.         when Constraint_Error | Tasking_Error | Program_Error | Storage_Error | 
  18162.             Numeric_Error => 
  18163.             Trace.Report("PREDEFINED EXCEPTION in Cais.Text_Io.Set_Line_Length "
  18164.                 ); 
  18165.             raise; 
  18166.  
  18167.     -- unanticipated exceptions
  18168.         when others => 
  18169.             Trace.Report(
  18170.                 "UNANTICIPATED EXCEPTION in Cais.Text_Io.Set_Line_Length "); 
  18171.             raise Trace.Assertion_Violation; 
  18172.  
  18173.     end Set_Line_Length; 
  18174.  
  18175.  
  18176.  
  18177.     procedure Set_Line_Length(To : Count) is 
  18178.     begin
  18179.         Set_Line_Length(Current_Output, To); 
  18180.     end Set_Line_Length; 
  18181.  
  18182.  
  18183. ----------------------     Set_Page_Length     ----------------------
  18184. --
  18185. --  Purpose:
  18186. --  -------
  18187. --    Sets the maximum page length of the specified output file to the
  18188. --    number of lines specified by To.  The value 0 for To specifies an
  18189. --    unbounded page length.
  18190. --
  18191. --  Parameters:
  18192. --  ----------
  18193. --    File    open file handle.
  18194. --    To    number to which bound is to be set.
  18195. --
  18196. --  Exceptions:
  18197. --  ----------
  18198. --    Status_Error
  18199. --        raised if file is not open.
  18200. --    Mode_Error
  18201. --        raised if mode of the file is not Out_File or Append_File.
  18202. --    Use_Error
  18203. --        raised if the specified page length is inappropriate for
  18204. --        the associated external file.
  18205. --
  18206. --  Notes:
  18207. --  -----
  18208. --    Semantics correspond to Ada LRM, Section 14.3.3
  18209. --
  18210. ---------------------------------------------------------------------
  18211.  
  18212.     procedure Set_Page_Length(File : File_Type; 
  18213.                               To   : Count) is 
  18214.     begin
  18215.         Check_Open(File, True);   -- Status_Error if File is not open
  18216.         Standard.Text_Io.Set_Page_Length(Get_File_Type(File).all, Standard.
  18217.             Text_Io.Count(To)); 
  18218.     exception
  18219.     -- exceptions that are propagated
  18220.         when Cais.Io_Definitions.Status_Error | Cais.Io_Definitions.Device_Error
  18221.             | Cais.Io_Definitions.Mode_Error | Cais.Io_Definitions.Use_Error
  18222.             => 
  18223.             raise; 
  18224.  
  18225.     -- predefined exceptions (propagated with trace)
  18226.         when Constraint_Error | Tasking_Error | Program_Error | Storage_Error | 
  18227.             Numeric_Error => 
  18228.             Trace.Report("PREDEFINED EXCEPTION in Cais.Text_Io.Set_Page_Length "
  18229.                 ); 
  18230.             raise; 
  18231.  
  18232.     -- unanticipated exceptions
  18233.         when others => 
  18234.             Trace.Report(
  18235.                 "UNANTICIPATED EXCEPTION in Cais.Text_Io.Set_Page_Length "); 
  18236.             raise Trace.Assertion_Violation; 
  18237.  
  18238.     end Set_Page_Length; 
  18239.  
  18240.  
  18241.  
  18242.     procedure Set_Page_Length(To : Count) is 
  18243.     begin
  18244.         Set_Page_Length(Current_Output, To); 
  18245.     end Set_Page_Length; 
  18246.  
  18247.  
  18248.  
  18249. ----------------------     Line_Length     ----------------------
  18250. --
  18251. --  Purpose:
  18252. --  -------
  18253. --    Returns the line length currently set for the specified output file,
  18254. --    or zero if the line length is unbounded.
  18255. --
  18256. --  Parameters:
  18257. --  ----------
  18258. --    File    open file handle.
  18259. --
  18260. --  Exceptions:
  18261. --  ----------
  18262. --    Status_Error
  18263. --        raised if file is not open.
  18264. --    Mode_Error
  18265. --        raised if mode of the file is not Out_File or Append_File.
  18266. --
  18267. --  Notes:
  18268. --  -----
  18269. --    Semantics correspond to Ada LRM, Section 14.3.3
  18270. --
  18271. ---------------------------------------------------------------------
  18272.  
  18273.     function Line_Length(File : File_Type) return Count is 
  18274.     begin
  18275.         Check_Open(File, True);   -- Status_Error if File is not open
  18276.         return Count(Standard.Text_Io.Line_Length(Get_File_Type(File).all)); 
  18277.     exception
  18278.     -- exceptions that are propagated
  18279.         when Cais.Io_Definitions.Status_Error | Cais.Io_Definitions.Device_Error
  18280.             | Cais.Io_Definitions.Mode_Error => 
  18281.             raise; 
  18282.  
  18283.     -- predefined exceptions (propagated with trace)
  18284.         when Constraint_Error | Tasking_Error | Program_Error | Storage_Error | 
  18285.             Numeric_Error => 
  18286.             Trace.Report("PREDEFINED EXCEPTION in Cais.Text_Io.Line_Length "); 
  18287.             raise; 
  18288.  
  18289.     -- unanticipated exceptions
  18290.         when others => 
  18291.             Trace.Report("UNANTICIPATED EXCEPTION in Cais.Text_Io.Line_Length ")
  18292.                 ; 
  18293.             raise Trace.Assertion_Violation; 
  18294.  
  18295.     end Line_Length; 
  18296.  
  18297.  
  18298.  
  18299.     function Line_Length return Count is 
  18300.     begin
  18301.         return Line_Length(Current_Output); 
  18302.     end Line_Length; 
  18303.  
  18304.  
  18305. ----------------------     Page_Length     ----------------------
  18306. --
  18307. --  Purpose:
  18308. --  -------
  18309. --    Returns the page length currently set for the specified output file,
  18310. --    or zero if the page length is unbounded.
  18311. --
  18312. --  Parameters:
  18313. --  ----------
  18314. --    File    open file handle.
  18315. --
  18316. --  Exceptions:
  18317. --  ----------
  18318. --    Status_Error
  18319. --        raised if file is not open.
  18320. --    Mode_Error
  18321. --        raised if mode of the file is not Out_File or Append_File.
  18322. --
  18323. --  Notes:
  18324. --  -----
  18325. --    Semantics correspond to Ada LRM, Section 14.3.3
  18326. --
  18327. ---------------------------------------------------------------------
  18328.  
  18329.     function Page_Length(File : File_Type) return Count is 
  18330.     begin
  18331.         Check_Open(File, True);   -- Status_Error if File is not open
  18332.         return Count(Standard.Text_Io.Page_Length(Get_File_Type(File).all)); 
  18333.     exception
  18334.     -- exceptions that are propagated
  18335.         when Cais.Io_Definitions.Status_Error | Cais.Io_Definitions.Device_Error
  18336.             | Cais.Io_Definitions.Mode_Error => 
  18337.             raise; 
  18338.  
  18339.     -- predefined exceptions (propagated with trace)
  18340.         when Constraint_Error | Tasking_Error | Program_Error | Storage_Error | 
  18341.             Numeric_Error => 
  18342.             Trace.Report("PREDEFINED EXCEPTION in Cais.Text_Io.Page_Length "); 
  18343.             raise; 
  18344.  
  18345.     -- unanticipated exceptions
  18346.         when others => 
  18347.             Trace.Report("UNANTICIPATED EXCEPTION in Cais.Text_Io.Page_Length ")
  18348.                 ; 
  18349.             raise Trace.Assertion_Violation; 
  18350.  
  18351.     end Page_Length; 
  18352.  
  18353.  
  18354.  
  18355.     function Page_Length return Count is 
  18356.     begin
  18357.         return Page_Length(Current_Output); 
  18358.     end Page_Length; 
  18359.  
  18360.  
  18361.  
  18362. ----------------------     New_Line     ----------------------
  18363. --
  18364. --  Purpose:
  18365. --  -------
  18366. --    Outputs a line terminator and sets the current column
  18367. --    number to one.  Increments line number or if line
  18368. --    number exceeds maximum line for bounded page length,
  18369. --    outputs a page terminator, increments page number,
  18370. --    and sets line number to one.
  18371. --
  18372. --  Parameters:
  18373. --  ----------
  18374. --    File      open file handle.
  18375. --    Spacing   number of times New_Line action is performed.
  18376. --
  18377. --  Exceptions:
  18378. --  ----------
  18379. --    Status_Error
  18380. --        raised if file is not open.
  18381. --    Mode_Error
  18382. --        raised if mode of the file is not Out_File or Append_File.
  18383. --
  18384. --  Notes:
  18385. --  -----
  18386. --    Semantics correspond to Ada LRM, Section 14.3.4
  18387. --
  18388. ---------------------------------------------------------------------
  18389.  
  18390.     procedure New_Line(File    : File_Type; 
  18391.                        Spacing : Positive_Count := 1) is 
  18392.     begin
  18393.         Check_Open(File, True);   -- Status_Error if File is not open
  18394.         Standard.Text_Io.New_Line(Get_File_Type(File).all, Standard.Text_Io.
  18395.             Positive_Count(Spacing)); 
  18396.     exception
  18397.     -- exceptions that are propagated
  18398.         when Cais.Io_Definitions.Status_Error | Cais.Io_Definitions.Device_Error
  18399.             | Cais.Io_Definitions.Mode_Error => 
  18400.             raise; 
  18401.  
  18402.     -- predefined exceptions (propagated with trace)
  18403.         when Constraint_Error | Tasking_Error | Program_Error | Storage_Error | 
  18404.             Numeric_Error => 
  18405.             Trace.Report("PREDEFINED EXCEPTION in Cais.Text_Io.New_Line "); 
  18406.             raise; 
  18407.  
  18408.     -- unanticipated exceptions
  18409.         when others => 
  18410.             Trace.Report("UNANTICIPATED EXCEPTION in Cais.Text_Io.New_Line "); 
  18411.             raise Trace.Assertion_Violation; 
  18412.  
  18413.     end New_Line; 
  18414.  
  18415.  
  18416.  
  18417.     procedure New_Line(Spacing : Positive_Count := 1) is 
  18418.     begin
  18419.         New_Line(Current_Output, Spacing); 
  18420.     end New_Line; 
  18421.  
  18422.  
  18423. ----------------------     Skip_Line     ----------------------
  18424. --
  18425. --  Purpose:
  18426. --  -------
  18427. --    Reads and discards all characters until a line terminator has
  18428. --    been read.  Then sets the current column number to one.
  18429. --
  18430. --  Parameters:
  18431. --  ----------
  18432. --    File      open file handle.
  18433. --    Spacing   number of times Skip_Line action is to be performed.
  18434. --
  18435. --  Exceptions:
  18436. --  ----------
  18437. --    Status_Error
  18438. --        raised if file is not open.
  18439. --    Mode_Error
  18440. --        raised if mode of the file is not In_File.
  18441. --    End_Error
  18442. --        raised if attempt is made to read a file terminator.
  18443. --
  18444. --  Notes:
  18445. --  -----
  18446. --    Semantics correspond to Ada LRM, Section 14.3.4
  18447. --
  18448. ---------------------------------------------------------------------
  18449.  
  18450.     procedure Skip_Line(File    : File_Type; 
  18451.                         Spacing : Positive_Count := 1) is 
  18452.     begin
  18453.         Check_Open(File, True);   -- Status_Error if File is not open
  18454.         Standard.Text_Io.Skip_Line(Get_File_Type(File).all, Standard.Text_Io.
  18455.             Positive_Count(Spacing)); 
  18456.     exception
  18457.     -- exceptions that are propagated
  18458.         when Cais.Io_Definitions.Status_Error | Cais.Io_Definitions.Device_Error
  18459.             | Cais.Io_Definitions.Mode_Error | Cais.Io_Definitions.End_Error
  18460.             => 
  18461.             raise; 
  18462.  
  18463.     -- predefined exceptions (propagated with trace)
  18464.         when Constraint_Error | Tasking_Error | Program_Error | Storage_Error | 
  18465.             Numeric_Error => 
  18466.             Trace.Report("PREDEFINED EXCEPTION in Cais.Text_Io.Skip_Line "); 
  18467.             raise; 
  18468.  
  18469.     -- unanticipated exceptions
  18470.         when others => 
  18471.             Trace.Report("UNANTICIPATED EXCEPTION in Cais.Text_Io.Skip_Line "); 
  18472.             raise Trace.Assertion_Violation; 
  18473.  
  18474.     end Skip_Line; 
  18475.  
  18476.  
  18477.  
  18478.     procedure Skip_Line(Spacing : Positive_Count := 1) is 
  18479.     begin
  18480.         Skip_Line(Current_Input, Spacing); 
  18481.     end Skip_Line; 
  18482.  
  18483.  
  18484. ----------------------     End_Of_Line     ----------------------
  18485. --
  18486. --  Purpose:
  18487. --  -------
  18488. --    Returns True if a line terminator or a file terminator 
  18489. --    is next; otherwise returns False.
  18490. --
  18491. --  Parameters:
  18492. --  ----------
  18493. --    File    open file handle.
  18494. --
  18495. --  Exceptions:
  18496. --  ----------
  18497. --    Status_Error
  18498. --        raised if file is not open.
  18499. --    Mode_Error
  18500. --        raised if mode of the file is not In_File.
  18501. --
  18502. --  Notes:
  18503. --  -----
  18504. --    Semantics correspond to Ada LRM, Section 14.3.4
  18505. --
  18506. ---------------------------------------------------------------------
  18507.  
  18508.     function End_Of_Line(File : File_Type) return Boolean is 
  18509.     begin
  18510.         Check_Open(File, True);   -- Status_Error if File is not open
  18511.         return Standard.Text_Io.End_Of_Line(Get_File_Type(File).all); 
  18512.     exception
  18513.     -- exceptions that are propagated
  18514.         when Cais.Io_Definitions.Status_Error | Cais.Io_Definitions.Device_Error
  18515.             | Cais.Io_Definitions.Mode_Error => 
  18516.             raise; 
  18517.  
  18518.     -- predefined exceptions (propagated with trace)
  18519.         when Constraint_Error | Tasking_Error | Program_Error | Storage_Error | 
  18520.             Numeric_Error => 
  18521.             Trace.Report("PREDEFINED EXCEPTION in Cais.Text_Io.End_of_Line "); 
  18522.             raise; 
  18523.  
  18524.     -- unanticipated exceptions
  18525.         when others => 
  18526.             Trace.Report("UNANTICIPATED EXCEPTION in Cais.Text_Io.End_of_Line ")
  18527.                 ; 
  18528.             raise Trace.Assertion_Violation; 
  18529.  
  18530.     end End_Of_Line; 
  18531.  
  18532.  
  18533.  
  18534.     function End_Of_Line return Boolean is 
  18535.     begin
  18536.         return End_Of_Line(Current_Input); 
  18537.     end End_Of_Line; 
  18538.  
  18539.  
  18540. ----------------------     New_Page     ----------------------
  18541. --
  18542. --  Purpose:
  18543. --  -------
  18544. --    Outputs a line terminator if the current line is not
  18545. --    terminated or current page is empty.  Outputs a page
  18546. --    terminator and adds one to current page number. Sets 
  18547. --    the current column and line numbers to one.
  18548. --
  18549. --  Parameters:
  18550. --  ----------
  18551. --    File      open file handle.
  18552. --
  18553. --  Exceptions:
  18554. --  ----------
  18555. --    Status_Error
  18556. --        raised if file is not open.
  18557. --    Mode_Error
  18558. --        raised if mode of the file is not Out_File or Append_File.
  18559. --
  18560. --  Notes:
  18561. --  -----
  18562. --    Semantics correspond to Ada LRM, Section 14.3.4
  18563. --
  18564. ---------------------------------------------------------------------
  18565.  
  18566.     procedure New_Page(File : File_Type) is 
  18567.     begin
  18568.         Check_Open(File, True);   -- Status_Error if File is not open
  18569.         Standard.Text_Io.New_Page(Get_File_Type(File).all); 
  18570.     exception
  18571.     -- exceptions that are propagated
  18572.         when Cais.Io_Definitions.Status_Error | Cais.Io_Definitions.Device_Error
  18573.             | Cais.Io_Definitions.Mode_Error => 
  18574.             raise; 
  18575.  
  18576.     -- predefined exceptions (propagated with trace)
  18577.         when Constraint_Error | Tasking_Error | Program_Error | Storage_Error | 
  18578.             Numeric_Error => 
  18579.             Trace.Report("PREDEFINED EXCEPTION in Cais.Text_Io.New_Page "); 
  18580.             raise; 
  18581.  
  18582.     -- unanticipated exceptions
  18583.         when others => 
  18584.             Trace.Report("UNANTICIPATED EXCEPTION in Cais.Text_Io.New_Page "); 
  18585.             raise Trace.Assertion_Violation; 
  18586.  
  18587.     end New_Page; 
  18588.  
  18589.  
  18590.  
  18591.     procedure New_Page is 
  18592.     begin
  18593.         Cais.Text_Io.New_Page(Current_Input); 
  18594.     end New_Page; 
  18595.  
  18596.  
  18597. ----------------------     Skip_Page     ----------------------
  18598. --
  18599. --  Purpose:
  18600. --  -------
  18601. --    Reads and discards all characters until a page terminator has
  18602. --    been read.  Then adds one to the current page number and
  18603. --    sets the current column number and line numbers to one.
  18604. --
  18605. --  Parameters:
  18606. --  ----------
  18607. --    File      open file handle.
  18608. --
  18609. --  Exceptions:
  18610. --  ----------
  18611. --    Status_Error
  18612. --        raised if file is not open.
  18613. --    Mode_Error
  18614. --        raised if mode of the file is not In_File.
  18615. --    End_Error
  18616. --        raised if attempt is made to read a file terminator.
  18617. --
  18618. --  Notes:
  18619. --  -----
  18620. --    Semantics correspond to Ada LRM, Section 14.3.4
  18621. --
  18622. ---------------------------------------------------------------------
  18623.  
  18624.     procedure Skip_Page(File : File_Type) is 
  18625.     begin
  18626.         Check_Open(File, True);   -- Status_Error if File is not open
  18627.         Standard.Text_Io.Skip_Page(Get_File_Type(File).all); 
  18628.     exception
  18629.     -- exceptions that are propagated
  18630.         when Cais.Io_Definitions.Status_Error | Cais.Io_Definitions.Device_Error
  18631.             | Cais.Io_Definitions.Mode_Error | Cais.Io_Definitions.End_Error
  18632.             => 
  18633.             raise; 
  18634.  
  18635.     -- predefined exceptions (propagated with trace)
  18636.         when Constraint_Error | Tasking_Error | Program_Error | Storage_Error | 
  18637.             Numeric_Error => 
  18638.             Trace.Report("PREDEFINED EXCEPTION in Cais.Text_Io.Skip_Page "); 
  18639.             raise; 
  18640.  
  18641.     -- unanticipated exceptions
  18642.         when others => 
  18643.             Trace.Report("UNANTICIPATED EXCEPTION in Cais.Text_Io.Skip_Page "); 
  18644.             raise Trace.Assertion_Violation; 
  18645.  
  18646.     end Skip_Page; 
  18647.  
  18648.  
  18649.  
  18650.     procedure Skip_Page is 
  18651.     begin
  18652.         Cais.Text_Io.Skip_Page(Current_Input); 
  18653.     end Skip_Page; 
  18654.  
  18655.  
  18656. ----------------------     End_Of_Page     ----------------------
  18657. --
  18658. --  Purpose:
  18659. --  -------
  18660. --    Returns True if a line terminator and a page terminator
  18661. --    or a file terminator is next; otherwise returns False.
  18662. --
  18663. --  Parameters:
  18664. --  ----------
  18665. --    File    open file handle.
  18666. --
  18667. --  Exceptions:
  18668. --  ----------
  18669. --    Status_Error
  18670. --        raised if file is not open.
  18671. --    Mode_Error
  18672. --        raised if mode of the file is not In_File.
  18673. --
  18674. --  Notes:
  18675. --  -----
  18676. --    Semantics correspond to Ada LRM, Section 14.3.4
  18677. --
  18678. ---------------------------------------------------------------------
  18679.  
  18680.     function End_Of_Page(File : File_Type) return Boolean is 
  18681.     begin
  18682.         Check_Open(File, True);   -- Status_Error if File is not open
  18683.         return Standard.Text_Io.End_Of_Page(Get_File_Type(File).all); 
  18684.     exception
  18685.     -- exceptions that are propagated
  18686.         when Cais.Io_Definitions.Status_Error | Cais.Io_Definitions.Device_Error
  18687.             | Cais.Io_Definitions.Mode_Error => 
  18688.             raise; 
  18689.  
  18690.     -- predefined exceptions (propagated with trace)
  18691.         when Constraint_Error | Tasking_Error | Program_Error | Storage_Error | 
  18692.             Numeric_Error => 
  18693.             Trace.Report("PREDEFINED EXCEPTION in Cais.Text_Io.End_Of_Page "); 
  18694.             raise; 
  18695.  
  18696.     -- unanticipated exceptions
  18697.         when others => 
  18698.             Trace.Report("UNANTICIPATED EXCEPTION in Cais.Text_Io.End_Of_Page ")
  18699.                 ; 
  18700.             raise Trace.Assertion_Violation; 
  18701.  
  18702.     end End_Of_Page; 
  18703.  
  18704.  
  18705.  
  18706.     function End_Of_Page return Boolean is 
  18707.     begin
  18708.         return Cais.Text_Io.End_Of_Page(Current_Input); 
  18709.     end End_Of_Page; 
  18710.  
  18711.  
  18712. ----------------------     End_Of_File     ----------------------
  18713. --
  18714. --  Purpose:
  18715. --  -------
  18716. --    Returns True if a file terminator or the combination of a line 
  18717. --    terminator, page terminator, and a file terminator
  18718. --    is next; otherwise returns False.
  18719. --
  18720. --  Parameters:
  18721. --  ----------
  18722. --    File    open file handle.
  18723. --
  18724. --  Exceptions:
  18725. --  ----------
  18726. --    Status_Error
  18727. --        raised if file is not open.
  18728. --    Mode_Error
  18729. --        raised if mode of the file is not In_File.
  18730. --
  18731. --  Notes:
  18732. --  -----
  18733. --    Semantics correspond to Ada LRM, Section 14.3.4
  18734. --
  18735. ---------------------------------------------------------------------
  18736.  
  18737.     function End_Of_File(File : File_Type) return Boolean is 
  18738.     begin
  18739.         Check_Open(File, True);   -- Status_Error if File is not open
  18740.         return Standard.Text_Io.End_Of_File(Get_File_Type(File).all); 
  18741.     exception
  18742.     -- exceptions that are propagated
  18743.         when Cais.Io_Definitions.Status_Error | Cais.Io_Definitions.Device_Error
  18744.             | Cais.Io_Definitions.Mode_Error => 
  18745.             raise; 
  18746.  
  18747.     -- predefined exceptions (propagated with trace)
  18748.         when Constraint_Error | Tasking_Error | Program_Error | Storage_Error | 
  18749.             Numeric_Error => 
  18750.             Trace.Report("PREDEFINED EXCEPTION in Cais.Text_Io.End_Of_File "); 
  18751.             raise; 
  18752.  
  18753.     -- unanticipated exceptions
  18754.         when others => 
  18755.             Trace.Report("UNANTICIPATED EXCEPTION in Cais.Text_Io.End_Of_File ")
  18756.                 ; 
  18757.             raise Trace.Assertion_Violation; 
  18758.  
  18759.     end End_Of_File; 
  18760.  
  18761.  
  18762.  
  18763.     function End_Of_File return Boolean is 
  18764.     begin
  18765.         return Cais.Text_Io.End_Of_File(Current_Input); 
  18766.     end End_Of_File; 
  18767.  
  18768.  
  18769.  
  18770. ----------------------     Set_Col     ----------------------
  18771. --
  18772. --  Purpose:
  18773. --  -------
  18774. --    If mode is Out_File, outputs spaces until current column
  18775. --    equals To.  If To is less than current column, a New_Line
  18776. --    is performed first.
  18777. --
  18778. --    If mode is In_File, discards characters until next character
  18779. --    has column equal to To. 
  18780. --
  18781. --  Parameters:
  18782. --  ----------
  18783. --    File    open file handle.
  18784. --    To    column number.
  18785. --
  18786. --  Exceptions:
  18787. --  ----------
  18788. --    Status_Error
  18789. --        raised if file handle is not open.
  18790. --    Layout_Error
  18791. --        raised if mode is Out_File and To exceeds maximum
  18792. --        line length.
  18793. --    End_Error
  18794. --        raised if attempt is made to read file terminator.
  18795. --
  18796. --  Notes:
  18797. --  -----
  18798. --    Semantics correspond to Ada LRM, Section 14.3.4
  18799. --
  18800. ---------------------------------------------------------------------
  18801.  
  18802.     procedure Set_Col(File : File_Type; 
  18803.                       To   : Positive_Count) is 
  18804.     begin
  18805.         Check_Open(File, True);   -- Status_Error if File is not open
  18806.         Standard.Text_Io.Set_Col(Get_File_Type(File).all, Standard.Text_Io.Count
  18807.             (To)); 
  18808.     exception
  18809.     -- exceptions that are propagated
  18810.         when Cais.Io_Definitions.Status_Error | Cais.Io_Definitions.Device_Error
  18811.             | Cais.Io_Definitions.Layout_Error | Cais.Io_Definitions.End_Error
  18812.             => 
  18813.             raise; 
  18814.  
  18815.     -- predefined exceptions (propagated with trace)
  18816.         when Constraint_Error | Tasking_Error | Program_Error | Storage_Error | 
  18817.             Numeric_Error => 
  18818.             Trace.Report("PREDEFINED EXCEPTION in Cais.Text_Io.Set_Col "); 
  18819.             raise; 
  18820.  
  18821.     -- unanticipated exceptions
  18822.         when others => 
  18823.             Trace.Report("UNANTICIPATED EXCEPTION in Cais.Text_Io.Set_Col "); 
  18824.             raise Trace.Assertion_Violation; 
  18825.  
  18826.     end Set_Col; 
  18827.  
  18828.  
  18829.  
  18830.     procedure Set_Col(To : Positive_Count) is 
  18831.     begin
  18832.         Set_Col(Current_Output, To); 
  18833.     end Set_Col; 
  18834.  
  18835.  
  18836.  
  18837. ----------------------     Set_Line     ----------------------
  18838. --
  18839. --  Purpose:
  18840. --  -------
  18841. --    If mode is Out_File, performs New_Line until current line
  18842. --    equals To.  If To is less than current line, a New_Page
  18843. --    is performed first.
  18844. --
  18845. --    If mode is In_File, performs Skip_Line until current line number
  18846. --    is equal to To. 
  18847. --
  18848. --  Parameters:
  18849. --  ----------
  18850. --    File    open file handle.
  18851. --    To    column number.
  18852. --
  18853. --  Exceptions:
  18854. --  ----------
  18855. --    Status_Error
  18856. --        raised if file handle is not open.
  18857. --    Layout_Error
  18858. --        raised if mode is Out_File and To exceeds maximum
  18859. --        page length.
  18860. --    End_Error
  18861. --        raised if attempt is made to read file terminator.
  18862. --
  18863. --  Notes:
  18864. --  -----
  18865. --    Semantics correspond to Ada LRM, Section 14.3.4
  18866. --
  18867. ---------------------------------------------------------------------
  18868.  
  18869.     procedure Set_Line(File : File_Type; 
  18870.                        To   : Positive_Count) is 
  18871.     begin
  18872.         Check_Open(File, True);   -- Status_Error if File is not open
  18873.         Standard.Text_Io.Set_Line(Get_File_Type(File).all, Standard.Text_Io.
  18874.             Positive_Count(To)); 
  18875.     exception
  18876.     -- exceptions that are propagated
  18877.         when Cais.Io_Definitions.Status_Error | Cais.Io_Definitions.Device_Error
  18878.             | Cais.Io_Definitions.Layout_Error | Cais.Io_Definitions.End_Error
  18879.             => 
  18880.             raise; 
  18881.  
  18882.     -- predefined exceptions (propagated with trace)
  18883.         when Constraint_Error | Tasking_Error | Program_Error | Storage_Error | 
  18884.             Numeric_Error => 
  18885.             Trace.Report("PREDEFINED EXCEPTION in Cais.Text_Io.Set_Line "); 
  18886.             raise; 
  18887.  
  18888.     -- unanticipated exceptions
  18889.         when others => 
  18890.             Trace.Report("UNANTICIPATED EXCEPTION in Cais.Text_Io.Set_Line "); 
  18891.             raise Trace.Assertion_Violation; 
  18892.  
  18893.     end Set_Line; 
  18894.  
  18895.  
  18896.  
  18897.     procedure Set_Line(To : Positive_Count) is 
  18898.     begin
  18899.         Set_Line(Current_Output, To); 
  18900.     end Set_Line; 
  18901.  
  18902.  
  18903. ----------------------     Col     ----------------------
  18904. --
  18905. --  Purpose:
  18906. --  -------
  18907. --    Returns the current column number.
  18908. --
  18909. --  Parameters:
  18910. --  ----------
  18911. --    File    open file handle.
  18912. --
  18913. --  Exceptions:
  18914. --  ----------
  18915. --    Status_Error
  18916. --        raised if file is not open.
  18917. --    Layout_Error
  18918. --        raised if this number exceeds Count'Last.
  18919. --
  18920. --  Notes:
  18921. --  -----
  18922. --    Semantics correspond to Ada LRM, Section 14.3.4
  18923. --
  18924. ---------------------------------------------------------------------
  18925.  
  18926.     function Col(File : File_Type) return Positive_Count is 
  18927.     begin
  18928.         Check_Open(File, True);   -- Status_Error if File is not open
  18929.         return Positive_Count(Standard.Text_Io.Col(Get_File_Type(File).all)); 
  18930.     exception
  18931.     -- exceptions that are propagated
  18932.         when Cais.Io_Definitions.Status_Error | Cais.Io_Definitions.Device_Error
  18933.             | Cais.Io_Definitions.Layout_Error => 
  18934.             raise; 
  18935.  
  18936.     -- predefined exceptions (propagated with trace)
  18937.         when Constraint_Error | Tasking_Error | Program_Error | Storage_Error | 
  18938.             Numeric_Error => 
  18939.             Trace.Report("PREDEFINED EXCEPTION in Cais.Text_Io.Col "); 
  18940.             raise; 
  18941.  
  18942.     -- unanticipated exceptions
  18943.         when others => 
  18944.             Trace.Report("UNANTICIPATED EXCEPTION in Cais.Text_Io.Col "); 
  18945.             raise Trace.Assertion_Violation; 
  18946.  
  18947.     end Col; 
  18948.  
  18949.  
  18950.  
  18951.     function Col return Positive_Count is 
  18952.     begin
  18953.         return Col(Current_Output); 
  18954.     end Col; 
  18955.  
  18956.  
  18957. ----------------------     Line     ----------------------
  18958. --
  18959. --  Purpose:
  18960. --  -------
  18961. --    Returns the current line number.
  18962. --
  18963. --  Parameters:
  18964. --  ----------
  18965. --    File    open file handle.
  18966. --
  18967. --  Exceptions:
  18968. --  ----------
  18969. --    Status_Error
  18970. --        raised if file is not open.
  18971. --    Layout_Error
  18972. --        raised if this number exceeds Count'Last.
  18973. --
  18974. --  Notes:
  18975. --  -----
  18976. --    Semantics correspond to Ada LRM, Section 14.3.4
  18977. --
  18978. ---------------------------------------------------------------------
  18979.  
  18980.     function Line(File : File_Type) return Positive_Count is 
  18981.     begin
  18982.         Check_Open(File, True);   -- Status_Error if File is not open
  18983.         return Positive_Count(Standard.Text_Io.Line(Get_File_Type(File).all)); 
  18984.     exception
  18985.     -- exceptions that are propagated
  18986.         when Cais.Io_Definitions.Status_Error | Cais.Io_Definitions.Device_Error
  18987.             | Cais.Io_Definitions.Layout_Error => 
  18988.             raise; 
  18989.  
  18990.     -- predefined exceptions (propagated with trace)
  18991.         when Constraint_Error | Tasking_Error | Program_Error | Storage_Error | 
  18992.             Numeric_Error => 
  18993.             Trace.Report("PREDEFINED EXCEPTION in Cais.Text_Io.Line "); 
  18994.             raise; 
  18995.  
  18996.     -- unanticipated exceptions
  18997.         when others => 
  18998.             Trace.Report("UNANTICIPATED EXCEPTION in Cais.Text_Io.Line "); 
  18999.             raise Trace.Assertion_Violation; 
  19000.  
  19001.     end Line; 
  19002.  
  19003.  
  19004.  
  19005.     function Line return Positive_Count is 
  19006.     begin
  19007.         return Line(Current_Output); 
  19008.     end Line; 
  19009.  
  19010.  
  19011. ----------------------     Page     ----------------------
  19012. --
  19013. --  Purpose:
  19014. --  -------
  19015. --    Returns the current page number.
  19016. --
  19017. --  Parameters:
  19018. --  ----------
  19019. --    File    open file handle.
  19020. --
  19021. --  Exceptions:
  19022. --  ----------
  19023. --    Status_Error
  19024. --        raised if file is not open.
  19025. --    Layout_Error
  19026. --        raised if this number exceeds Count'Last.
  19027. --
  19028. --  Notes:
  19029. --  -----
  19030. --    Semantics correspond to Ada LRM, Section 14.3.4
  19031. --
  19032. ---------------------------------------------------------------------
  19033.  
  19034.     function Page(File : File_Type) return Positive_Count is 
  19035.     begin
  19036.         Check_Open(File, True);   -- Status_Error if File is not open
  19037.         return Positive_Count(Standard.Text_Io.Page(Get_File_Type(File).all)); 
  19038.     exception
  19039.     -- exceptions that are propagated
  19040.         when Cais.Io_Definitions.Status_Error | Cais.Io_Definitions.Device_Error
  19041.             | Cais.Io_Definitions.Layout_Error => 
  19042.             raise; 
  19043.  
  19044.     -- predefined exceptions (propagated with trace)
  19045.         when Constraint_Error | Tasking_Error | Program_Error | Storage_Error | 
  19046.             Numeric_Error => 
  19047.             Trace.Report("PREDEFINED EXCEPTION in Cais.Text_Io.Page "); 
  19048.             raise; 
  19049.  
  19050.     -- unanticipated exceptions
  19051.         when others => 
  19052.             Trace.Report("UNANTICIPATED EXCEPTION in Cais.Text_Io.Page "); 
  19053.             raise Trace.Assertion_Violation; 
  19054.  
  19055.     end Page; 
  19056.  
  19057.  
  19058.  
  19059.     function Page return Positive_Count is 
  19060.     begin
  19061.         return Page(Current_Output); 
  19062.     end Page; 
  19063.  
  19064.  
  19065.  
  19066. ----------------------     Get     ----------------------
  19067. --
  19068. --  Purpose:
  19069. --  -------
  19070. --    This procedure reads characters from the specified
  19071. --    text file into the item parameter.
  19072. --
  19073. --  Parameters:
  19074. --  ----------
  19075. --    File    open file handle.
  19076. --    Item    out parameter of type Character.
  19077. --
  19078. --  Exceptions:
  19079. --  ----------
  19080. --    Status_Error
  19081. --        raised if File is not open.
  19082. --    Mode_Error
  19083. --        raised if file mode is not In_File.
  19084. --    End_Error
  19085. --        raised if attempt is made to skip file terminator.
  19086. --    Data_Error
  19087. --        raised if the sequence input is not a lexical element
  19088. --        corresponding to the item type.
  19089. --
  19090. --  Notes:
  19091. --  -----
  19092. --    This procedure is defined in section 5.3.4.6 of MIL-STD-CAIS,
  19093. --    dated 31 January 1985.
  19094. --
  19095. ---------------------------------------------------------------------
  19096.  
  19097.     procedure Get(File : File_Type; 
  19098.                   Item : in out Character) is 
  19099.     begin
  19100.         Check_Open(File, True);   -- Status_Error if File is not open
  19101.         Standard.Text_Io.Get(Get_File_Type(File).all, Item); 
  19102.     exception
  19103.  
  19104.     -- exceptions that are propagated
  19105.         when Cais.Io_Definitions.Status_Error | Cais.Io_Definitions.Device_Error
  19106.             | Cais.Io_Definitions.Mode_Error | Cais.Io_Definitions.End_Error | 
  19107.             Cais.Io_Definitions.Data_Error => 
  19108.             raise; 
  19109.  
  19110.     -- predefined exceptions (propagated with trace)
  19111.         when Constraint_Error | Tasking_Error | Program_Error | Storage_Error | 
  19112.             Numeric_Error => 
  19113.             Trace.Report("PREDEFINED EXCEPTION in Cais.Text_Io.Get "); 
  19114.             raise; 
  19115.  
  19116.     -- unanticipated exceptions
  19117.         when others => 
  19118.             Trace.Report("UNANTICIPATED EXCEPTION in Cais.Text_Io.Get "); 
  19119.             raise Trace.Assertion_Violation; 
  19120.  
  19121.     end Get; 
  19122.  
  19123.  
  19124.     procedure Get(Item : in out Character) is 
  19125.     begin
  19126.         Get(Current_Input, Item); 
  19127.     end Get; 
  19128.  
  19129. ----------------------     Put     ----------------------
  19130. --
  19131. --  Purpose:
  19132. --  -------
  19133. --    This procedure writes characters to the specified file.
  19134. --
  19135. --  Parameters:
  19136. --  ----------
  19137. --    File    open file handle.
  19138. --    Item    in parameter of type Character.
  19139. --
  19140. --  Exceptions:
  19141. --  ----------
  19142. --    Status_Error
  19143. --        raised if File is not open.
  19144. --    Mode_Error
  19145. --        raised if file mode is not Out_File or Append_File.
  19146. --    Layout_Error
  19147. --        raised if the number of characters to be output 
  19148. --        exceeds the maximum line length.
  19149. --
  19150. --  Notes:
  19151. --  -----
  19152. --    This procedure is defined in section 5.3.4.6 of MIL-STD-CAIS,
  19153. --    dated 31 January 1985.
  19154. --
  19155. ---------------------------------------------------------------------
  19156.  
  19157.     procedure Put(File : File_Type; 
  19158.                   Item : Character) is 
  19159.     begin
  19160.         Check_Open(File, True);   -- Status_Error if File is not open
  19161.         Standard.Text_Io.Put(Get_File_Type(File).all, Item); 
  19162.     exception
  19163.  
  19164.     -- exceptions that are propagated
  19165.         when Cais.Io_Definitions.Status_Error | Cais.Io_Definitions.Device_Error
  19166.             | Cais.Io_Definitions.Mode_Error | Cais.Io_Definitions.Layout_Error
  19167.             => 
  19168.             raise; 
  19169.  
  19170.     -- predefined exceptions (propagated with trace)
  19171.         when Constraint_Error | Tasking_Error | Program_Error | Storage_Error | 
  19172.             Numeric_Error => 
  19173.             Trace.Report("PREDEFINED EXCEPTION in Cais.Text_Io.Put "); 
  19174.             raise; 
  19175.  
  19176.     -- unanticipated exceptions
  19177.         when others => 
  19178.             Trace.Report("UNANTICIPATED EXCEPTION in Cais.Text_Io.Put "); 
  19179.             raise Trace.Assertion_Violation; 
  19180.  
  19181.     end Put; 
  19182.  
  19183.  
  19184.     procedure Put(Item : Character) is 
  19185.     begin
  19186.         Put(Current_Output, Item); 
  19187.     end Put; 
  19188.  
  19189. ----------------------     Get     ----------------------
  19190. --
  19191. --  Purpose:
  19192. --  -------
  19193. --    This procedure reads characters from the specified
  19194. --    text file into the item parameter.
  19195. --    The number of Get character operations is determined by
  19196. --    the length of the string.
  19197. --
  19198. --  Parameters:
  19199. --  ----------
  19200. --    File    open file handle.
  19201. --    Item    out parameter of type String.
  19202. --
  19203. --  Exceptions:
  19204. --  ----------
  19205. --    Status_Error
  19206. --        raised if File is not open.
  19207. --    Mode_Error
  19208. --        raised if file mode is not In_File.
  19209. --    End_Error
  19210. --        raised if attempt is made to skip file terminator.
  19211. --    Data_Error
  19212. --        raised if the sequence input is not a lexical element
  19213. --        corresponding to the item type.
  19214. --
  19215. --  Notes:
  19216. --  -----
  19217. --    This procedure is defined in section 5.3.4.6 of MIL-STD-CAIS,
  19218. --    dated 31 January 1985.
  19219. --
  19220. ---------------------------------------------------------------------
  19221.  
  19222.     procedure Get(File : File_Type; 
  19223.                   Item : in out String) is 
  19224.     begin
  19225.         Check_Open(File, True);   -- Status_Error if File is not open
  19226.         Standard.Text_Io.Get(Get_File_Type(File).all, Item); 
  19227.  
  19228.     exception
  19229.  
  19230.     -- exceptions that are propagated
  19231.         when Cais.Io_Definitions.Status_Error | Cais.Io_Definitions.Device_Error
  19232.             | Cais.Io_Definitions.Mode_Error | Cais.Io_Definitions.End_Error | 
  19233.             Cais.Io_Definitions.Data_Error => 
  19234.             raise; 
  19235.  
  19236.     -- predefined exceptions (propagated with trace)
  19237.         when Constraint_Error | Tasking_Error | Program_Error | Storage_Error | 
  19238.             Numeric_Error => 
  19239.             Trace.Report("PREDEFINED EXCEPTION in Cais.Text_Io.Get "); 
  19240.             raise; 
  19241.  
  19242.     -- unanticipated exceptions
  19243.         when others => 
  19244.             Trace.Report("UNANTICIPATED EXCEPTION in Cais.Text_Io.Get "); 
  19245.             raise Trace.Assertion_Violation; 
  19246.  
  19247.     end Get; 
  19248.  
  19249.  
  19250.     procedure Get(Item : in out String) is 
  19251.     begin
  19252.         Get(Current_Input, Item); 
  19253.     end Get; 
  19254.  
  19255. ----------------------     Put     ----------------------
  19256. --
  19257. --  Purpose:
  19258. --  -------
  19259. --    This procedure writes characters to the specified file.
  19260. --    The number of Put character operations is determined by
  19261. --    the length of the string.
  19262. --
  19263. --  Parameters:
  19264. --  ----------
  19265. --    File    open file handle.
  19266. --    Item    in parameter of type String.
  19267. --
  19268. --  Exceptions:
  19269. --  ----------
  19270. --    Status_Error
  19271. --        raised if File is not open.
  19272. --    Mode_Error
  19273. --        raised if file mode is not Out_File or Append_File.
  19274. --    Layout_Error
  19275. --        raised if the number of characters to be output 
  19276. --        exceeds the maximum line length.
  19277. --
  19278. --  Notes:
  19279. --  -----
  19280. --    This procedure is defined in section 5.3.4.6 of MIL-STD-CAIS,
  19281. --    dated 31 January 1985.
  19282. --
  19283. ---------------------------------------------------------------------
  19284.  
  19285.     procedure Put(File : File_Type; 
  19286.                   Item : String) is 
  19287.     begin
  19288.         Check_Open(File, True);   -- Status_Error if File is not open
  19289.         Standard.Text_Io.Put(Get_File_Type(File).all, Item); 
  19290.  
  19291.     exception
  19292.  
  19293.     -- exceptions that are propagated
  19294.         when Cais.Io_Definitions.Status_Error | Cais.Io_Definitions.Device_Error
  19295.             | Cais.Io_Definitions.Mode_Error | Cais.Io_Definitions.Layout_Error
  19296.             => 
  19297.             raise; 
  19298.  
  19299.     -- predefined exceptions (propagated with trace)
  19300.         when Constraint_Error | Tasking_Error | Program_Error | Storage_Error | 
  19301.             Numeric_Error => 
  19302.             Trace.Report("PREDEFINED EXCEPTION in Cais.Text_Io.Put "); 
  19303.             raise; 
  19304.  
  19305.     -- unanticipated exceptions
  19306.         when others => 
  19307.             Trace.Report("UNANTICIPATED EXCEPTION in Cais.Text_Io.Put "); 
  19308.             raise Trace.Assertion_Violation; 
  19309.  
  19310.     end Put; 
  19311.  
  19312.  
  19313.     procedure Put(Item : String) is 
  19314.     begin
  19315.         Put(Current_Output, Item); 
  19316.     end Put; 
  19317.  
  19318. ----------------------     Get_Line     ----------------------
  19319. --
  19320. --  Purpose:
  19321. --  -------
  19322. --    This procedure reads successive characters from the specified
  19323. --    text file into the item parameter.  Reading stops if the end
  19324. --    of line is met.
  19325. --
  19326. --  Parameters:
  19327. --  ----------
  19328. --    File    open file handle.
  19329. --    Item    out parameter of type String.
  19330. --
  19331. --  Exceptions:
  19332. --  ----------
  19333. --    Status_Error
  19334. --        raised if File is not open.
  19335. --    Mode_Error
  19336. --        raised if file mode is not In_File.
  19337. --    End_Error
  19338. --        raised if attempt is made to skip file terminator.
  19339. --    Data_Error
  19340. --        raised if the sequence input is not a lexical element
  19341. --        corresponding to the item type.
  19342. --
  19343. --  Notes:
  19344. --  -----
  19345. --    Semantics correspond to Ada LRM, Section 14.3.6.
  19346. --
  19347. ---------------------------------------------------------------------
  19348.  
  19349.     procedure Get_Line(File : File_Type; 
  19350.                        Item : in out String; 
  19351.                        Last : in out Natural) is 
  19352.     begin
  19353.         Check_Open(File, True);   -- Status_Error if File is not open
  19354.         Standard.Text_Io.Get_Line(Get_File_Type(File).all, Item, Last); 
  19355.  
  19356.     exception
  19357.  
  19358.     -- exceptions that are propagated
  19359.         when Cais.Io_Definitions.Status_Error | Cais.Io_Definitions.Device_Error
  19360.             | Cais.Io_Definitions.Mode_Error | Cais.Io_Definitions.End_Error | 
  19361.             Cais.Io_Definitions.Data_Error => 
  19362.             raise; 
  19363.  
  19364.     -- predefined exceptions (propagated with trace)
  19365.         when Constraint_Error | Tasking_Error | Program_Error | Storage_Error | 
  19366.             Numeric_Error => 
  19367.             Trace.Report("PREDEFINED EXCEPTION in Cais.Text_Io.Get_Line "); 
  19368.             raise; 
  19369.  
  19370.     -- unanticipated exceptions
  19371.         when others => 
  19372.             Trace.Report("UNANTICIPATED EXCEPTION in Cais.Text_Io.Get_Line "); 
  19373.             raise Trace.Assertion_Violation; 
  19374.  
  19375.     end Get_Line; 
  19376.  
  19377.  
  19378.     procedure Get_Line(Item : in out String; 
  19379.                        Last : in out Natural) is 
  19380.     begin
  19381.         Get_Line(Current_Input, Item, Last); 
  19382.     end Get_Line; 
  19383.  
  19384. ----------------------     Put_Line     ----------------------
  19385. --
  19386. --  Purpose:
  19387. --  -------
  19388. --    This procedure calls procedure Put for the given string,
  19389. --    then New_Line, with a spacing of one.
  19390. --
  19391. --  Parameters:
  19392. --  ----------
  19393. --    File    open file handle.
  19394. --    Item    in parameter of type String.
  19395. --
  19396. --  Exceptions:
  19397. --  ----------
  19398. --    Status_Error
  19399. --        raised if File is not open.
  19400. --    Mode_Error
  19401. --        raised if file mode is not Out_File or Append_File.
  19402. --
  19403. --  Notes:
  19404. --  -----
  19405. --    Semantics correspond to Ada LRM, Section 14.3.6
  19406. --
  19407. ---------------------------------------------------------------------
  19408.  
  19409.     procedure Put_Line(File : File_Type; 
  19410.                        Item : String) is 
  19411.     begin
  19412.         Check_Open(File, True);   -- Status_Error if File is not open
  19413.         Standard.Text_Io.Put_Line(Get_File_Type(File).all, Item); 
  19414.     exception
  19415.  
  19416.     -- exceptions that are propagated
  19417.         when Cais.Io_Definitions.Status_Error | Cais.Io_Definitions.Device_Error
  19418.             | Cais.Io_Definitions.Mode_Error | Cais.Io_Definitions.Layout_Error
  19419.             => 
  19420.             raise; 
  19421.  
  19422.     -- predefined exceptions (propagated with trace)
  19423.         when Constraint_Error | Tasking_Error | Program_Error | Storage_Error | 
  19424.             Numeric_Error => 
  19425.             Trace.Report("PREDEFINED EXCEPTION in Cais.Text_Io.Put_Line "); 
  19426.             raise; 
  19427.  
  19428.     -- unanticipated exceptions
  19429.         when others => 
  19430.             Trace.Report("UNANTICIPATED EXCEPTION in Cais.Text_Io.Put_Line "); 
  19431.             raise Trace.Assertion_Violation; 
  19432.  
  19433.     end Put_Line; 
  19434.  
  19435.  
  19436.     procedure Put_Line(Item : String) is 
  19437.     begin
  19438.         Put_Line(Current_Output, Item); 
  19439.     end Put_Line; 
  19440.  
  19441. --------------------------------------------------------------------------
  19442. --
  19443. --    Separate generic package bodies
  19444. --        Integer_Io
  19445. --        Enumeration_Io
  19446. --        Fixed_Io
  19447. --        Float_Io
  19448. --
  19449. --------------------------------------------------------------------------
  19450.  
  19451. -- generic package for Input-Output of Integer Types
  19452.  
  19453.     package body Integer_Io is separate; 
  19454.  
  19455. -- generic package for Input-Output of Floating Point Types
  19456.  
  19457.     package body Float_Io is separate; 
  19458.  
  19459. -- generic package for Input-Output of Fixed Point Types
  19460.  
  19461.     package body Fixed_Io is separate; 
  19462.  
  19463. -- generic package for Input-Output of Enumeration Types
  19464.  
  19465.     package body Enumeration_Io is separate; 
  19466.  
  19467. -----------------------------------------------------------------------------
  19468. end Text_Io; 
  19469. -----------------------------------------------------------------------------
  19470. --::::::::::::::
  19471. --cais_utilities_body.a
  19472. --::::::::::::::
  19473.  
  19474. ----------------------------------------------------------------------
  19475. --                   C A I S _ U T I L I T I E S
  19476. --                          (Package Body)
  19477. --
  19478. --
  19479. --               A Collection of Miscellaneous Utility Routines 
  19480. --
  19481. --
  19482. --
  19483. --
  19484. --                  Ada Software Engineering Group
  19485. --                      The MITRE Corporation
  19486. --                         McLean, VA 22102
  19487. --
  19488. --
  19489. --                   Mon Jul  8 21:21:18 EDT 1985
  19490. --
  19491. --                 (Unclassified and uncopyrighted)
  19492. --
  19493. ----------------------------------------------------------------------
  19494.  
  19495. ----------------------------------------------------------------------
  19496. --                   C A I S _ U T I L I T I E S
  19497. --
  19498. --  Purpose:
  19499. --  -------
  19500. --    This package serves to collect together various simple utilities
  19501. --    used in the CAIS prototype.  None of the utilities use "internals"
  19502. --    knowledge, i.e. all the interfaces that are used by these routines
  19503. --    are either in the externally visible MIL-STD-CAIS specification or
  19504. --    are in standard libraries.
  19505. --
  19506. --  Usage:
  19507. --  -----
  19508. --    TBS
  19509. --
  19510. --  Example:
  19511. --  -------
  19512. --    The procedure String_To_Simple_List and Simple_List_To_String
  19513. --    are useful for avoiding the error-prone manipulation of String
  19514. --    Items in List_Utilities (and working with the leading and trailing
  19515. --    embedded "s). 
  19516. --
  19517. --  Notes:
  19518. --  -----
  19519. --
  19520. --  Revision History:
  19521. --  ----------------
  19522. --
  19523. -------------------------------------------------------------------
  19524. with Character_Set; use Character_Set; 
  19525. with Sequential_Io; 
  19526.  
  19527. separate(Cais)
  19528. package body Cais_Utilities is 
  19529.  
  19530.     use Trace; 
  19531.     use Pragmatics; 
  19532.     use Node_Management; 
  19533.  
  19534.  
  19535.     procedure String_To_Simple_List(Str  : String; 
  19536.                                     List : in out List_Type) is 
  19537.  
  19538.         Offset   : Integer; 
  19539.         Tmp_List : List_Type; 
  19540.     begin
  19541.         Offset := Last_Non_Space(Str); 
  19542.         Copy(List, Empty_List); 
  19543.         Copy(Tmp_List, Empty_List); 
  19544.         String_Items.Insert(List => Tmp_List, List_Item => Str(Str'First .. 
  19545.             Offset), Position => 0); 
  19546.         Insert(List => List, List_Item => Tmp_List, Position => 0); 
  19547.     end String_To_Simple_List; 
  19548.  
  19549.     procedure Simple_List_To_String(List : List_Type; 
  19550.                                     Str  : in out String) is 
  19551.  
  19552.         Tmp_List   : List_Type; 
  19553.         Tmp_String : String(1 .. Str'Length); 
  19554.         Len        : Natural; 
  19555.     begin
  19556.         Str(Str'range ) := (others => ' '); 
  19557.         Extract(List => List, Position => 1, List_Item => Tmp_List); 
  19558.         Len := Text_Length(Tmp_List, 1); 
  19559.         Tmp_String(1 .. Len) := String_Items.Extract(List => Tmp_List, Position
  19560.             => 1); 
  19561.         Str(Str'First .. Str'First + Len - 1) := Tmp_String(1 .. Len); 
  19562.  
  19563.     end Simple_List_To_String; 
  19564.  
  19565.  
  19566. ----------------------  C H E C K _ I N T E N T I O N S ------------------
  19567. --
  19568. --  Purpose: 
  19569. --  ------- 
  19570. --    This procedure checks that a Node has been opened with an
  19571. --    intent that explicitly or implicitly grants the priveledges of
  19572. --    Intent specified as a parameter.
  19573. --
  19574. --  Parameters:
  19575. --  ----------
  19576. --    Node      is the Node to be accessed
  19577. --    Intent    is the stated intention for accessing the node
  19578. --
  19579. --  Exceptions:
  19580. --  ----------
  19581. --    Node_Definitions.INTENT_VIOLATION  - if the specified intent
  19582. --        is not explicitly or implicitly granted by the current
  19583. --        Intention of the Node
  19584. --    Node_Definitions.USE_ERROR        - if Node is not an open node handle
  19585. --
  19586. --  Notes:
  19587. --  -----
  19588. --
  19589. ---------------------------------------------------------------------------
  19590.     procedure Check_Intentions(Node     : in Node_Type; 
  19591.                                Intended : in Intent_Specification) is 
  19592.  
  19593.         Intent : Intention(Node_Management.Intent_Of(Node)'range ); 
  19594.     begin
  19595.         Intent := Node_Management.Intent_Of(Node); 
  19596.         Check_Intentions(Intent, Intended); 
  19597.     end Check_Intentions; 
  19598.  
  19599. ----------------------  C H E C K _ I N T E N T I O N S ------------------
  19600. --
  19601. --  Purpose: 
  19602. --  ------- 
  19603. --    This procedure checks that a Node has been opened with an
  19604. --    intent that explicitly or implicitly grants the priveledges of
  19605. --    Intent specified as a parameter.
  19606. --
  19607. --  Parameters:
  19608. --  ----------
  19609. --    Node      is the Node to be accessed
  19610. --    Intent    is the stated intention for accessing the node
  19611. --
  19612. --  Exceptions:
  19613. --  ----------
  19614. --    Node_Definitions.INTENT_VIOLATION  - if the specified intent
  19615. --        is not explicitly or implicitly granted by the current
  19616. --        Intention of the Node
  19617. --    Node_Definitions.USE_ERROR        - if Node is not an open node handle
  19618. --
  19619. --  Notes:
  19620. --  -----
  19621. --
  19622. ---------------------------------------------------------------------------
  19623.     procedure Check_Intentions(Intent   : in Intention; 
  19624.                                Intended : in Intent_Specification) is 
  19625.  
  19626.  
  19627.     begin
  19628.         for I in Intent'range loop
  19629.             if Intent(I) = Intended then 
  19630.                 return;         --Intent is valid
  19631.             end if; 
  19632.             case Intended is            --Check for implicit matches
  19633.                 when Existence => 
  19634.                     null; 
  19635.                 when Read => 
  19636.                     if Intent(I) = Exclusive_Read_Relationships then 
  19637.                         return; --Intent is valid
  19638.                     end if; 
  19639.                 when Exclusive_Read => 
  19640.                     null; 
  19641.                 when Write => 
  19642.                     if Intent(I) = Exclusive_Write then 
  19643.                         return; --Intent is valid
  19644.                     end if; 
  19645.                 when Exclusive_Write => 
  19646.                     null; 
  19647.                 when Read_Contents => 
  19648.                     if Intent(I) = Exclusive_Read_Contents or Intent(I) = Read
  19649.                         or Intent(I) = Exclusive_Read then 
  19650.                         return; --Intent is valid
  19651.                     end if; 
  19652.                 when Exclusive_Read_Contents => 
  19653.                     if Intent(I) = Exclusive_Read then 
  19654.                         return; --Intent is valid
  19655.                     end if; 
  19656.                 when Write_Contents => 
  19657.                     if Intent(I) = Exclusive_Write_Contents or Intent(I) = Write
  19658.                         or Intent(I) = Exclusive_Write then 
  19659.                         return; --Intent is valid
  19660.                     end if; 
  19661.                 when Exclusive_Write_Contents => 
  19662.                     if Intent(I) = Exclusive_Write then 
  19663.                         return; --Intent is valid
  19664.                     end if; 
  19665.                 when Append_Contents => 
  19666.                     if Intent(I) = Exclusive_Append_Contents or Intent(I) = 
  19667.                         Write_Contents or Intent(I) = Exclusive_Write_Contents
  19668.                         or Intent(I) = Write or Intent(I) = Exclusive_Write
  19669.                         then 
  19670.                         return; --Intent is valid
  19671.                     end if; 
  19672.                 when Exclusive_Append_Contents => 
  19673.                     if Intent(I) = Exclusive_Write_Contents or Intent(I) = 
  19674.                         Exclusive_Write then 
  19675.                         return; --Intent is valid
  19676.                     end if; 
  19677.                 when Read_Attributes => 
  19678.                     if Intent(I) = Exclusive_Read_Attributes or Intent(I) = Read
  19679.                         or Intent(I) = Exclusive_Read then 
  19680.                         return; --Intent is valid
  19681.                     end if; 
  19682.                 when Exclusive_Read_Attributes => 
  19683.                     if Intent(I) = Exclusive_Read then 
  19684.                         return; --Intent is valid
  19685.                     end if; 
  19686.                 when Write_Attributes => 
  19687.                     if Intent(I) = Exclusive_Write_Attributes or Intent(I) = 
  19688.                         Write or Intent(I) = Exclusive_Write then 
  19689.                         return; --Intent is valid
  19690.                     end if; 
  19691.                 when Exclusive_Write_Attributes => 
  19692.                     if Intent(I) = Exclusive_Write then 
  19693.                         return; --Intent is valid
  19694.                     end if; 
  19695.                 when Append_Attributes => 
  19696.                     if Intent(I) = Exclusive_Append_Attributes or Intent(I) = 
  19697.                         Write_Attributes or Intent(I) = 
  19698.                         Exclusive_Write_Attributes or Intent(I) = Write or 
  19699.                         Intent(I) = Exclusive_Write then 
  19700.                         return; --Intent is valid
  19701.                     end if; 
  19702.                 when Exclusive_Append_Attributes => 
  19703.                     if Intent(I) = Exclusive_Write_Attributes or Intent(I) = 
  19704.                         Exclusive_Write then 
  19705.                         return; --Intent is valid
  19706.                     end if; 
  19707.                 when Read_Relationships => 
  19708.                     if Intent(I) = Exclusive_Read_Relationships or Intent(I) = 
  19709.                         Read or Intent(I) = Exclusive_Read then 
  19710.                         return; --Intent is valid
  19711.                     end if; 
  19712.                 when Exclusive_Read_Relationships => 
  19713.                     if Intent(I) = Exclusive_Read then 
  19714.                         return; --Intent is valid
  19715.                     end if; 
  19716.                 when Write_Relationships => 
  19717.                     if Intent(I) = Exclusive_Write_Relationships or Intent(I) = 
  19718.                         Write or Intent(I) = Exclusive_Write then 
  19719.                         return; --Intent is valid
  19720.                     end if; 
  19721.                 when Exclusive_Write_Relationships => 
  19722.                     if Intent(I) = Exclusive_Write then 
  19723.                         return; --Intent is valid
  19724.                     end if; 
  19725.                 when Append_Relationships => 
  19726.                     if Intent(I) = Exclusive_Append_Relationships or Intent(I)
  19727.                         = Write_Relationships or Intent(I) = 
  19728.                         Exclusive_Write_Relationships or Intent(I) = Write or 
  19729.                         Intent(I) = Exclusive_Write then 
  19730.                         return; --Intent is valid
  19731.                     end if; 
  19732.                 when Exclusive_Append_Relationships => 
  19733.                     if Intent(I) = Exclusive_Write_Relationships or Intent(I) = 
  19734.                         Exclusive_Write then 
  19735.                         return; --Intent is valid
  19736.                     end if; 
  19737.                 when Control => 
  19738.                     if Intent(I) = Exclusive_Control then 
  19739.                         return; --Intent is valid
  19740.                     end if; 
  19741.                 when Exclusive_Control => 
  19742.                     null; 
  19743.                 when Execute => 
  19744.                     null; 
  19745.             end case;   --  Case Intended is
  19746.  
  19747.         end loop;       -- for I in Intent'range loop
  19748.  
  19749.         -- if we get here, there has not been an explicit or implicit
  19750.         -- match for the entire Intention array of the node.
  19751.         raise Node_Definitions.Intent_Violation; 
  19752.  
  19753.     end Check_Intentions; 
  19754.  
  19755.  
  19756. ----------------------  C H E C K _ I N T E N T I O N S ------------------
  19757. --
  19758. --  Purpose: 
  19759. --  ------- 
  19760. --    This procedure checks that the first parameter is an
  19761. --    Intent that explicitly or implicitly grants the privileges of
  19762. --    Intended specified as the second parameter.
  19763. --
  19764. --  Parameters:
  19765. --  ----------
  19766. --    Intent    is the Intent allowable
  19767. --    Intended  is the stated Intention array for accessing the node
  19768. --
  19769. --  Exceptions:
  19770. --  ----------
  19771. --    Node_Definitions.INTENT_VIOLATION  - if the specified intention
  19772. --        is not explicitly or implicitly granted by the allowable
  19773. --        Intention 
  19774. --
  19775. --  Notes:
  19776. --  -----
  19777. --    This procedure overloads the procedure which checks a single 
  19778. --    intent specification.
  19779. --
  19780. ---------------------------------------------------------------------------
  19781.  
  19782.  
  19783.     procedure Check_Intentions(Intent   : in Intention; 
  19784.                                Intended : in Intention) is 
  19785.  
  19786.     begin
  19787.         for I in Intended'range loop
  19788.             Check_Intentions(Intent, Intended(I)); 
  19789.         end loop; 
  19790.         return;         --Intended is valid
  19791.  
  19792.     end Check_Intentions; 
  19793.  
  19794.  
  19795. ----------------------   Predefined   ------------------------------
  19796. --
  19797. --  Purpose: This function checks that an attribute defined by the user
  19798. --  -------  is not identical to one of the predefined CAIS attributes
  19799. --
  19800. --  Parameters:
  19801. --  ----------
  19802. --    Name      is the attribute being defined by the user
  19803. --
  19804. --  Exceptions:
  19805. --  ----------
  19806. --   None
  19807. --
  19808. --  Notes:
  19809. --  -----
  19810. --   Uses the CAIS package body variables Predefined_Attributes and
  19811. --   Predefined_Relations
  19812. ---------------------------------------------------------------------------
  19813.     function Predefined(Name : String; 
  19814.                         Kind : Predefined_Kind) return Boolean is 
  19815.         Pos : Position_Count;   --unused value needed for Position_By_Name
  19816.     begin
  19817.         case Kind is 
  19818.             when Attribute => 
  19819.                 Pos := Position_By_Name(Cais.Predefined_Attributes, Name); 
  19820.                 return True;    --will only be executed if Name is found
  19821.                                 --in Predefined_Attributes, otherwise the
  19822.                                 --exception Search_Error is raised.  See below.
  19823.             when Relation => 
  19824.                 Pos := Position_By_Name(Cais.Predefined_Relations, Name); 
  19825.                 return True;    --will only be executed if Name is found
  19826.                                 --in Predefined_Attributes, otherwise the
  19827.                                 --exception Search_Error is raised.  See below.
  19828.         end case; 
  19829.  
  19830.     exception
  19831.         -- exceptions that are trapped (nothing propogated)
  19832.         when Search_Error => 
  19833.             return False;       --All is right, Name was not predefined
  19834.  
  19835.         -- exceptions that are propogated
  19836.             -- NONE
  19837.  
  19838.         -- exceptions that are mapped to other exceptions
  19839.             -- NONE
  19840.  
  19841.         -- predefined exceptions (propogated with trace)
  19842.         when Constraint_Error | Tasking_Error | Program_Error | Storage_Error | 
  19843.             Numeric_Error => 
  19844.             Trace.Report("PREDEFINED EXCEPTION in " & 
  19845.                 "Cais_Utilities.Predefined"); 
  19846.             raise; 
  19847.  
  19848.         -- unanticipated exceptions
  19849.         when others => 
  19850.             Trace.Report("UNANTICIPATED EXCEPTION in " & 
  19851.                 "Cais_Utilities.Predefined"); 
  19852.             raise Trace.Assertion_Violation; 
  19853.  
  19854.     end Predefined; 
  19855.  
  19856. ----------------------      Copy      ----------------------
  19857. --
  19858. --  Purpose:
  19859. --  -------
  19860. --    This procedure copies to host (Ada) files byte by byte.
  19861. --
  19862. --  Parameters:
  19863. --  ----------
  19864. --    From_File    string identifying the file to be copied
  19865. --    To_File     string identifying the file to be written
  19866. --
  19867. --  Exceptions:
  19868. --  ----------
  19869. --    I/O errors other than End_Error are propogated.
  19870. --  Notes:
  19871. --  -----
  19872. --    Uses Sequential_Io.
  19873. --
  19874. ---------------------------------------------------------------------
  19875.  
  19876.     procedure Copy(From_File : in String; 
  19877.                    To_File   : in String)
  19878.  
  19879.     is 
  19880.         package Byte_Io is 
  19881.             new Standard.Sequential_Io(Tiny_Integer); 
  19882.  
  19883.         Length  : Natural; 
  19884.         From_Io : Byte_Io.File_Type; 
  19885.         To_Io   : Byte_Io.File_Type; 
  19886.         Byte    : Tiny_Integer; 
  19887.  
  19888.     begin
  19889.         Byte_Io.Open(From_Io, Byte_Io.In_File, From_File); 
  19890.         Byte_Io.Open(To_Io, Byte_Io.Out_File, To_File); 
  19891.  
  19892.         begin
  19893.             loop
  19894.                 Byte_Io.Read(From_Io, Byte); 
  19895.                 Byte_Io.Write(To_Io, Byte); 
  19896.             end loop; 
  19897.         exception
  19898.             when Byte_Io.End_Error => 
  19899.                 Byte_Io.Close(From_Io); 
  19900.                 Byte_Io.Close(To_Io); 
  19901.         end; 
  19902.     exception
  19903.         -- exceptions that are trapped (nothing propagated)
  19904.         --    End_Error
  19905.         -- exceptions that are propagated
  19906.  
  19907.         -- all other exceptions (propagated with trace)
  19908.         when others => 
  19909.             Trace.Report("UNEXPECTED EXCEPTION in File_To_File Copy"); 
  19910.             raise; 
  19911.     end Copy; 
  19912.  
  19913.  
  19914. function Valid_Relation_Name (Name : String) return Boolean is
  19915.     Dummy_Token : List_Utilities.Token_Type;
  19916.     Last_Char   : Natural;
  19917. begin
  19918.     Last_Char := Character_Set.Last_Non_Space (Name);
  19919.     if Last_Char = 0 then -- blank string...
  19920.     return False;
  19921.     end if;
  19922.  
  19923.     List_Utilities.Identifier_Items.To_Token (
  19924.     Identifier => Name (1 .. Last_Char),
  19925.     Token => Dummy_Token);
  19926.     -- If we get here, it is clearly ok
  19927.     return True;
  19928. exception
  19929.     when Node_Definitions.Use_Error => -- see if it's a "."
  19930.     if Name'Last > 0 and then
  19931.         Last_Char = 1 and then
  19932.         Name (1) = '.' then
  19933.         return True;
  19934.     else
  19935.         return False;
  19936.     end if;
  19937.     when others =>
  19938.     Trace.Report ("Valid_Relation Name raised unexpected exception");
  19939.     raise Trace.Assertion_Violation;
  19940. end Valid_Relation_Name;
  19941.  
  19942.  
  19943. function Valid_Relation_Key (Name : String) return Boolean is
  19944.     Dummy_Token : List_Utilities.Token_Type;
  19945.     Last_Char   : Natural;
  19946.  
  19947. begin
  19948.  
  19949.     Last_Char := Character_Set.Last_Non_Space (Name);
  19950.     if Last_Char = 0 then -- blank string...
  19951.     return True;
  19952.     end if;
  19953.  
  19954.     if Name (Last_Char) = '#' then
  19955.     if Last_Char = 1 then
  19956.         return True;
  19957.     else
  19958.         List_Utilities.Identifier_Items.To_Token (
  19959.         Identifier => Name (1 .. Last_Char -1),
  19960.         Token => Dummy_Token);
  19961.     end if;
  19962.     else
  19963.     List_Utilities.Identifier_Items.To_Token (
  19964.         Identifier => Name (1 .. Last_Char),
  19965.         Token => Dummy_Token);
  19966.     -- If we get here, it is clearly ok
  19967.     end if;
  19968.     return True;
  19969. exception
  19970.     when Node_Definitions.Use_Error => 
  19971.     return False;
  19972.     when others =>
  19973.     Trace.Report ("Valid_Relation_Key raised unexpected exception");
  19974.     raise Trace.Assertion_Violation;
  19975. end Valid_Relation_Key;
  19976. end Cais_Utilities; 
  19977. --::::::::::::::
  19978. --copy_node.a
  19979. --::::::::::::::
  19980.  
  19981.  
  19982.  
  19983. ----------------------------------------------------------------------
  19984. --                       C O P Y _ N O D E    
  19985. --           (Separate procedure in Node_Management)
  19986. --
  19987. --
  19988. --  Copies one node (without relationships) to a newly created node
  19989. --
  19990. --
  19991. --
  19992. --
  19993. --                  Ada Software Engineering Group
  19994. --                      The MITRE Corporation
  19995. --                         McLean, VA 22102
  19996. --
  19997. --
  19998. --                   Wed Jun 26 09:10:14 EDT 1985
  19999. --
  20000. --                 (Unclassified and uncopyrighted)
  20001. --
  20002. ----------------------------------------------------------------------
  20003.  
  20004. --------------------       C O P Y _ N O D E       -------------------
  20005. --
  20006. --  Purpose:
  20007. --  -------
  20008. --    These procedures copy a file or structural node THAT DOES NOT HAVE
  20009. --    EMANATING PRIMARY RELATIONSHIPS.  The node copied is identified by
  20010. --    the open node handle "From" and is copied to a newly created node.
  20011. --    The new node is identified by the combination of the To_Base, To_Key,
  20012. --    and To_Relation parameters.  The newly created node is of the same
  20013. --    kind as the node identified by From. If the node is a file node, its
  20014. --    contents are also copied, i.e., a new copied file is created.  Any
  20015. --    secondary relationships emanating from the original node, excepting
  20016. --    the relation of the predefined relation parent(which is appropriately
  20017. --    adjusted), are recreated in the copy.  If the target of the original
  20018. --    nodes relationship IS THE NODE ITSELF, THEN THE COPY HAS AN ANALOGOUS
  20019. --    RELATION TO ITSELF.  Any other secondary relationship whose target is
  20020. --    the original node is unaffected.  All attributes of the From node are
  20021. --    also copied.  Regardless of any locks on the node identified by From,
  20022. --    the newly creasted node is unlucked.
  20023. --
  20024. --  Parameters:
  20025. --  ----------
  20026. --    From      - an open node handle to the node to be copied.
  20027. --    To_Base   - open node handle to a base node for identification of the
  20028. --          node to be created.
  20029. --    To_Key    - the relationship key for identification of the node to be
  20030. --              - created.
  20031. --    To_Relation  - the relation name for identification of the node to be
  20032. --                created.
  20033. --
  20034. --  Exceptions:
  20035. --  ----------
  20036. --    Name_Error        - raised if the new node identification is illegal
  20037. --                        or if a node already exists with the identification
  20038. --                        given for the new node.
  20039. --    Use_Error         - is raised if the origianl node is not a file or
  20040. --              structural node or if any primary relationships
  20041. --              emanate from the original node.  Use_Error is also
  20042. --              raised if the To_Relation is the name of a predefined
  20043. --              relation that cannot be modified or created by the
  20044. --              user.
  20045. --    Status_Error      - is raised if the Node_Handles From and To_Base are
  20046. --              not both open.
  20047. --    Intent_Violation  - is raised if "From" was not opened with an intent
  20048. --                        establishing the right to read contents, attributes
  20049. --              and relationships, or if To_Base was not opened with
  20050. --              the right to append relationships. Intent_Violation
  20051. --              is not raised if the conditions for name error are
  20052. --              present.
  20053. --    Security_Violation -is raised if the attempt to obtain access to the
  20054. --                        node with the specified intent represents a 
  20055. --                        violation of mandatory access controls for the
  20056. --                        CAIS.  Security_Violation is raised only if the
  20057. --                        conditions for other exceptions are not present.
  20058. --
  20059. --  Notes:   CAIS 5.1.2.18
  20060. --  -----
  20061. --
  20062. ---------------------------------------------------------------------
  20063. separate(Cais.Node_Management)
  20064. procedure Copy_Node(From        : Node_Type; 
  20065.                     To_Base     : in out Node_Type; 
  20066.                     To_Key      : Relationship_Key; 
  20067.                     To_Relation : Relation_Name := Default_Relation) is 
  20068.     use Identifier_Items; 
  20069.  
  20070.     New_Node      : Node_Type; 
  20071.  
  20072.     Access_List   : List_Type; 
  20073.     Level         : List_Type; 
  20074.     Attr          : List_Type; 
  20075.     Rel_Att       : List_Type; 
  20076.     Relations     : List_Type; 
  20077.     Relationships : List_Type; 
  20078.  
  20079.     Parent_Token  : Token_Type; 
  20080.     Syntax_Check  : Token_Type; 
  20081.     Rel           : Token_Type; 
  20082.     Key           : Token_Type; 
  20083.  
  20084.     Shadow_File   : String(1 .. Max_Shadow_File_Length); 
  20085.     Self          : String(1 .. Max_Shadow_File_Length); 
  20086.     New_Self      : String(1 .. Max_Shadow_File_Length); 
  20087.     Old_Contents  : String(1 .. Max_Shadow_File_Length); 
  20088.     New_Contents  : String(1 .. Max_Shadow_File_Length); 
  20089.     Size1         : Integer range 1 .. Max_Shadow_File_Length := 1; 
  20090.     Size2         : Integer range 1 .. Max_Shadow_File_Length := 1; 
  20091.     Kind          : Node_Kind; 
  20092.     Primary       : Boolean := True; 
  20093.  
  20094. begin
  20095.     if not Is_Open(From) then                           --From and Base must be
  20096.         raise Node_Definitions.Status_Error;            --open. Create checks
  20097.     end if;                                             --Base.
  20098.  
  20099.  
  20100.  
  20101.     -- Make sure that Name_Error conditions don't exist for the target.
  20102.     -- Note Create also checks for existence of the relationship.  This
  20103.     -- check is made here so that the Intent of the From node
  20104.     -- may be checked in the order required by MIL-STD-CAIS
  20105.     Check_Name : begin
  20106.       --First Check for syntax errors in the Relation and Key parameter
  20107.       --To_Token raises Use_Error for improper syntax
  20108.         To_Token(To_Relation, Syntax_Check); 
  20109.         To_Token(To_Key, Syntax_Check); 
  20110.  
  20111.       --Now Make sure the relationship doesn't exist.
  20112.         Node_Representation.Get_A_Relationship(Node => To_Base, Rel_Name => 
  20113.             To_Relation, Rel_Key => To_Key, Rel_Attributes => Rel_Att, Primary
  20114.             => Primary, Shadow_File => Shadow_File); 
  20115.         -- if we get here, the specified relationship already exists.
  20116.         -- This procedure call is history...
  20117.         raise Node_Definitions.Name_Error; 
  20118.     exception
  20119.         when Node_Definitions.Use_Error => 
  20120.             raise Node_Definitions.Name_Error; 
  20121.         when No_Such_Relation | No_Such_Relationship => 
  20122.             null;  -- the relationship does NOT exist...
  20123.     end Check_Name; 
  20124.  
  20125.  
  20126.                         --Check File Kind. Create same kind of node or
  20127.                         --raise Use_Error for process nodes. Create checks
  20128.                         --that To_Relation is not predefined
  20129.     Kind := Get_Kind(From); 
  20130.     if Kind = Structural or else Kind = File then 
  20131.  
  20132.         Cais_Utilities.Check_Intentions(From, Read);    --Insure proper intent
  20133.         Cais_Utilities.Check_Intentions(To_Base, Append_Relationships); 
  20134.  
  20135.  
  20136.         Get_Node_Relations(From, Relations);            --Check for Primary
  20137.                                                         --Relationships on
  20138.                                                         --each relation
  20139.         for I in 1 .. Length(Relations) loop
  20140.             Item_Name(Relations, I, Rel); 
  20141.             Extract(Relations, I, Relationships); 
  20142.  
  20143.             for J in 1 .. Length(Relationships) loop
  20144.                 Item_Name(Relationships, J, Key); 
  20145.                 Get_A_Relationship(From, To_Text(Rel), To_Text(Key), Shadow_File
  20146.                     , Rel_Att, Primary); 
  20147.                 if Primary then --Error: Primary Relationship not allowed
  20148.                     raise Node_Definitions.Use_Error; 
  20149.                 end if; 
  20150.             end loop; 
  20151.         end loop; 
  20152.  
  20153.  
  20154.                         --Obtain old Node information to be copied
  20155.         Get_Node_Access_Control(From, Access_List); 
  20156.         Get_Node_Level(From, Level); 
  20157.         Get_Node_Attributes(From, Attr); 
  20158.  
  20159.         Create_Node(New_Node, To_Base, Kind, Attr, Empty_List, Empty_List, (1
  20160.             => Exclusive_Write, 2 => Read_Relationships), Access_List, Level, 
  20161.             To_Key, To_Relation); 
  20162.     else 
  20163.         raise Node_Definitions.Use_Error; 
  20164.     end if; 
  20165.  
  20166.     Get_Shadow_File_Name(From, Self, Size1); 
  20167.     Get_Shadow_File_Name(New_Node, New_Self, Size1); 
  20168.  
  20169.                                 --Now update relationships, making appropriate
  20170.                                 --changes to self-references and ignoring the
  20171.                                 --parent relationship
  20172.     To_Token("PARENT", Parent_Token); 
  20173.     Get_Node_Relations(From, Relations); 
  20174.                                 --for each relation
  20175.     for I in 1 .. Length(Relations) loop
  20176.         Item_Name(Relations, I, Rel); 
  20177.         Extract(Relations, I, Relationships); 
  20178.  
  20179.         if not Is_Equal(Rel, Parent_Token) then         --for each relationship
  20180.             for J in 1 .. Length(Relationships) loop
  20181.                 Item_Name(Relationships, J, Key); 
  20182.                 Get_A_Relationship(From, To_Text(Rel), To_Text(Key), Shadow_File
  20183.                     , Rel_Att, Primary); 
  20184.                                 --copy 2ndary rel looking for self-references
  20185.                 if Shadow_File = Self then 
  20186.                     Set_A_Relationship(New_Node, To_Text(Rel), To_Text(Key), 
  20187.                         Rel_Att, Primary, New_Self); 
  20188.                 else 
  20189.                     Set_A_Relationship(New_Node, To_Text(Rel), To_Text(Key), 
  20190.                         Rel_Att, Primary, Shadow_File); 
  20191.                 end if; 
  20192.             end loop; 
  20193.         end if; 
  20194.     end loop; 
  20195.  
  20196.                         --If this is a File_Node, copy the Contents_File
  20197.     if Kind = File then 
  20198.         Get_Contents_File_Name(From, Old_Contents, Size1); 
  20199.  
  20200.         Cais_Host_Dependent.Get_Unique_Filename(New_Contents, Size2); 
  20201.         Set_Contents_File_Name(New_Node, New_Contents(1 .. Size2)); 
  20202.         Cais_Utilities.Copy(Old_Contents(1 .. Size1), New_Contents(1 .. Size2))
  20203.             ; 
  20204.     end if; 
  20205.  
  20206.     Write_Shadow_File(New_Node); 
  20207.  
  20208. end Copy_Node; 
  20209. --::::::::::::::
  20210. --copy_tree.a
  20211. --::::::::::::::
  20212.  
  20213.  
  20214. ----------------------------------------------------------------------
  20215. --                       C O P Y _ T R E E    
  20216. --           (Separate procedure in Node_Management)
  20217. --
  20218. --
  20219. --  Copies the primary relationships (+ associated nodes) of one node to another
  20220. --
  20221. --
  20222. --
  20223. --
  20224. --                  Ada Software Engineering Group
  20225. --                      The MITRE Corporation
  20226. --                         McLean, VA 22102
  20227. --
  20228. --
  20229. --                   Wed Jun 26 09:10:14 EDT 1985
  20230. --
  20231. --                 (Unclassified and uncopyrighted)
  20232. --
  20233. ----------------------------------------------------------------------
  20234.  
  20235. ------------------       C O P Y _ T R E E       ------------------------
  20236. --
  20237. --  Purpose:
  20238. --  -------
  20239. --    These procedures copy a tree of file or structural nodes formed by the
  20240. --    primary relationships emanating from the node identified by the open node
  20241. --    handle From.  Primary relationships are recreated between corresponding
  20242. --    copied nodes.  The root node of the newly created tree corresponding to
  20243. --    the From node is the node identified by the combination of the To_Base,
  20244. --    To_Key, and To_Relation parameters.  If an exception is raised by the
  20245. --    procedure none of the nodes are copied.  Secondary relationships,
  20246. --    attributes, and node contents are copied as described for Copy_Node with
  20247. --    the following additional rules: secondary relationships between two nodes
  20248. --    which are both copied are recreated between the two copies.  Secondary
  20249. --    relationships emanating from a node which is copied, but which refer to
  20250. --    nodes outside the tree being copied, are copied so that they emanate from
  20251. --    the copy, but still refer to the original target node.  Secondary
  20252. --    relationships emanating from a node which is not copied, but which refer
  20253. --    to nodes inside the tree being copied, are unaffected.  If the node
  20254. --    identified by To_Base is part of the tree being copied, then the copy of
  20255. --    the node identified by From will not be copied recursively.
  20256. --
  20257. --  Parameters:
  20258. --  ----------
  20259. --    From      - an open node handle to the root node of the tree to be copied.
  20260. --    To_Base   - open node handle to a base node for identification of the
  20261. --          node to be created as root of the new tree.
  20262. --    To_Key    - the relationship key for identification of the node to be
  20263. --              - created as root of the new tree.
  20264. --    To_Relation  - the relation name for identification of the node to be
  20265. --                created as root of the new tree.
  20266. --
  20267. --  Exceptions:
  20268. --  ----------
  20269. --    Name_Error        - raised if the new node identification is illegal
  20270. --                        or if a node already exists with the identification
  20271. --                        given for the new node to be created as a copy of
  20272. --              the node identified by From.
  20273. --    Use_Error         - is raised if the origianl node is not a file or
  20274. --              structural node.  Use_Error is also raised if the
  20275. --              To_Relation is the name of a predefined relation
  20276. --              that cannot be modified or created by the user.
  20277. --    Status_Error      - is raised if the Node_Handles From and To_Base are
  20278. --              not both open.
  20279. --    Lock_Error    - is raised if any node to be copied except the node
  20280. --              identified by From is locked against read access to
  20281. --              attributes, relationships, or contents.
  20282. --    Intent_Violation  - is raised if "From" was not opened with an intent
  20283. --                        establishing the right to read contents, attributes
  20284. --              and relationships, or if To_Base was not opened with
  20285. --              the right to append relationships. Intent_Violation
  20286. --              is not raised if the conditions for name error are
  20287. --              present.
  20288. --    Access_Violation     - is raised if the current process' discretionary
  20289. --              access control rights are insufficient to obtain
  20290. --              access to each node to be copied with intent Read.
  20291. --              Access_Violation is not raised if conditions for
  20292. --              Name_Error are present.
  20293. --    Security_Violation -is raised if the operations represents a 
  20294. --                        violation of mandatory access controls for the
  20295. --                        CAIS.  Security_Violation is raised only if the
  20296. --                        conditions for other exceptions are not present.
  20297. --
  20298. --  Notes:   CAIS 5.1.2.19
  20299. --  -----
  20300. --
  20301. ---------------------------------------------------------------------
  20302. separate(Cais.Node_Management)
  20303. procedure Copy_Tree(From        : Node_Type; 
  20304.                     To_Base     : in out Node_Type; 
  20305.                     To_Key      : Relationship_Key; 
  20306.                     To_Relation : Relation_Name := Default_Relation) is 
  20307.  
  20308.     use Identifier_Items; 
  20309.  
  20310.     Old_Shadow_File : String(1 .. Max_Shadow_File_Length); 
  20311.     New_Shadow_File : String(1 .. Max_Shadow_File_Length); 
  20312.     Shadow_File     : String(1 .. Max_Shadow_File_Length); 
  20313.     Syntax_Check    : Token_Type; 
  20314.     Rel_Attr        : List_Type; 
  20315.     Primary         : Boolean := True; 
  20316.     Size            : Natural range 1 .. Max_Shadow_File_Length := 1; 
  20317.     New_Node        : Node_Type; 
  20318.     Kind            : Node_Kind; 
  20319.  
  20320.     package Shadows is 
  20321.         procedure Save_Shadows(New_Shadow : String; 
  20322.                                Old_Shadow : String); 
  20323.         function Check_Shadow(Shadow : String) return String; 
  20324.     end Shadows; 
  20325.  
  20326.     package body Shadows is 
  20327.         type Shadow_Pair; 
  20328.         type Shadow_List is access Shadow_Pair; 
  20329.         type Shadow_Pair is 
  20330.             record
  20331.                 New_Shadow  : String(1 .. Max_Shadow_File_Length); 
  20332.                 Old_Shadow  : String(1 .. Max_Shadow_File_Length); 
  20333.                 Next_Shadow : Shadow_List; 
  20334.             end record; 
  20335.         Shadows : Shadow_List; 
  20336.  
  20337.         procedure Save_Shadows(New_Shadow : String; 
  20338.                                Old_Shadow : String) is 
  20339.             New_Record : Shadow_List := new Shadow_Pair'(New_Shadow, Old_Shadow
  20340.                 , Shadows); 
  20341.         begin
  20342.             Shadows := New_Record; 
  20343.         end Save_Shadows; 
  20344.  
  20345.         function Check_Shadow(Shadow : String) return String is 
  20346.             Cursor : Shadow_List := Shadows; 
  20347.         begin
  20348.             while Cursor /= null loop
  20349.                 if Shadow = Cursor.Old_Shadow then 
  20350.                     return Cursor.New_Shadow; 
  20351.                 end if; 
  20352.                 Cursor := Cursor.Next_Shadow; 
  20353.             end loop; 
  20354.             return Shadow; 
  20355.         end Check_Shadow; 
  20356.     end Shadows; 
  20357.     use Shadows; 
  20358.  
  20359.     procedure Copy_Any_Node(From        : Node_Type; 
  20360.                             To_Base     : in out Node_Type; 
  20361.                             To_Key      : Relationship_Key; 
  20362.                             To_Relation : Relation_Name; 
  20363.                             New_Node    : in out Node_Type) is 
  20364.         Kind        : Node_Kind; 
  20365.         Access_List : List_Type; 
  20366.         Level       : List_Type; 
  20367.         Attr        : List_Type; 
  20368.         Relations   : List_Type; 
  20369.     begin
  20370.         Kind := Get_Kind(From); 
  20371.         Get_Node_Access_Control(From, Access_List); 
  20372.         Get_Node_Level(From, Level); 
  20373.         Get_Node_Attributes(From, Attr); 
  20374.  
  20375.         Create_Node(New_Node, To_Base, Kind, Attr, Empty_List, Empty_List, (1
  20376.             => Read, 2 => Exclusive_Write), Access_List, Level, To_Key, 
  20377.             To_Relation); 
  20378.     end Copy_Any_Node; 
  20379.  
  20380.  
  20381.     procedure Mark_Tree(Node : Node_Type) is 
  20382.         Node_To_Copy  : Node_Type; 
  20383.         Relation_List : List_Type; 
  20384.         Key_List      : List_Type; 
  20385.         Rel_Name      : Token_Type; 
  20386.         Key_Name      : Token_Type; 
  20387.         Rel_Attr      : List_Type; 
  20388.         Primary       : Boolean := True; 
  20389.         Shadow_File   : String(1 .. Max_Shadow_File_Length); 
  20390.     begin
  20391.         Get_Node_Relations(Node, Relation_List); 
  20392.         for I in 1 .. Length(Relation_List) loop
  20393.             Item_Name(Relation_List, I, Rel_Name); 
  20394.             Extract(Relation_List, I, Key_List); 
  20395.             for J in 1 .. Length(Key_List) loop
  20396.                 Item_Name(Key_List, J, Key_Name); 
  20397.                 Get_A_Relationship(Node, To_Text(Rel_Name), To_Text(Key_Name), 
  20398.                     Shadow_File, Rel_Attr, Primary); 
  20399.                 if Primary then 
  20400.                     --!TBD Mark_Access(Shadow_File, Read);
  20401.  
  20402.                     Set_Shadow_File_Name(Node_To_Copy, Shadow_File); 
  20403.                     Read_Shadow_File(Node_To_Copy); 
  20404.                     Mark_Tree(Node_To_Copy);            --Recursive Call!!
  20405.                 end if; 
  20406.             end loop;       --check all keys
  20407.         end loop;               --check all relations
  20408.     end Mark_Tree; 
  20409.     procedure Copy_Sub_Tree(From              : Node_Type; 
  20410.                             To_Base           : in out Node_Type; 
  20411.                             To_Key            : Relationship_Key; 
  20412.                             To_Relation       : Relation_Name; 
  20413.                             Node_Just_Created : in out Node_Type) is 
  20414.         New_Node_Copied  : Node_Type; 
  20415.         Old_Node_To_Copy : Node_Type; 
  20416.         Relation_List    : List_Type; 
  20417.         Key_List         : List_Type; 
  20418.         Rel_Name         : Token_Type; 
  20419.         Key_Name         : Token_Type; 
  20420.         Rel_Attr         : List_Type; 
  20421.         Primary          : Boolean := True; 
  20422.         Old_Shadow_File  : String(1 .. Max_Shadow_File_Length); 
  20423.         New_Shadow_File  : String(1 .. Max_Shadow_File_Length); 
  20424.         New_Contents     : String(1 .. Max_Shadow_File_Length); 
  20425.         Old_Contents     : String(1 .. Max_Shadow_File_Length); 
  20426.         Size             : Natural range 1 .. Max_Shadow_File_Length := 1; 
  20427.         Size1            : Natural range 1 .. Max_Shadow_File_Length := 1; 
  20428.         Size2            : Natural range 1 .. Max_Shadow_File_Length := 1; 
  20429.     begin
  20430.         Copy_Any_Node(From, To_Base, To_Key, To_Relation, Node_Just_Created); 
  20431.                         --If this is a File_Node, copy the Contents_File
  20432.         if Get_Kind(From) = File then 
  20433.             Get_Contents_File_Name(From, Old_Contents, Size1); 
  20434.             Cais_Host_Dependent.Get_Unique_Filename(New_Contents, Size2); 
  20435.             Set_Contents_File_Name(Node_Just_Created, New_Contents(1 .. Size2))
  20436.                 ; 
  20437.             Cais_Utilities.Copy(Old_Contents(1 .. Size1), New_Contents(1 .. 
  20438.                 Size2)); 
  20439.         end if; 
  20440.  
  20441.  
  20442.         Get_Node_Relations(From, Relation_List); 
  20443.         for I in 1 .. Length(Relation_List) loop
  20444.             Item_Name(Relation_List, I, Rel_Name); 
  20445.             Extract(Relation_List, I, Key_List); 
  20446.             for J in 1 .. Length(Key_List) loop
  20447.                 Item_Name(Key_List, J, Key_Name); 
  20448.                 Get_A_Relationship(From, To_Text(Rel_Name), To_Text(Key_Name), 
  20449.                     Old_Shadow_File, Rel_Attr, Primary); 
  20450.                 if Primary then 
  20451.                     Open(Old_Node_To_Copy, From, To_Text(Key_Name), To_Text(
  20452.                         Rel_Name)); 
  20453.                     Copy_Sub_Tree(Old_Node_To_Copy, Node_Just_Created, To_Text(
  20454.                         Key_Name), To_Text(Rel_Name), New_Node_Copied); 
  20455.                                                          --Recursive Call!!
  20456.  
  20457.                     Get_Shadow_File_Name(New_Node_Copied, New_Shadow_File, Size)
  20458.                         ; 
  20459.                     Save_Shadows(New_Shadow_File, Old_Shadow_File); 
  20460.  
  20461.                     Close(Old_Node_To_Copy); 
  20462.                     Close(New_Node_Copied); 
  20463.                 end if; 
  20464.             end loop;       --check all keys
  20465.         end loop;               --check all relations
  20466.     end Copy_Sub_Tree; 
  20467.  
  20468.  
  20469.     procedure Add_Relationships(From   : Node_Type; 
  20470.                                 Target : in out Node_Type) is 
  20471.         Next_From     : Node_Type; 
  20472.         Next_Target   : Node_Type; 
  20473.  
  20474.         Relation_List : List_Type; 
  20475.         Key_List      : List_Type; 
  20476.         Rel_Name      : Token_Type; 
  20477.         Key_Name      : Token_Type; 
  20478.         Rel_Attr      : List_Type; 
  20479.         Primary       : Boolean := True; 
  20480.         Shadow_File   : String(1 .. Max_Shadow_File_Length); 
  20481.         Size          : Natural range 1 .. Max_Shadow_File_Length := 1; 
  20482.     begin
  20483.         Get_Node_Relations(From, Relation_List); 
  20484.         for I in 1 .. Length(Relation_List) loop
  20485.             Item_Name(Relation_List, I, Rel_Name); 
  20486.             Extract(Relation_List, I, Key_List); 
  20487.             for J in 1 .. Length(Key_List) loop
  20488.                 Item_Name(Key_List, J, Key_Name); 
  20489.  
  20490.                 Get_A_Relationship(From, To_Text(Rel_Name), To_Text(Key_Name), 
  20491.                     Shadow_File, Rel_Attr, Primary); 
  20492.                 if Primary then 
  20493.                     Open(Next_From, From, To_Text(Key_Name), To_Text(Rel_Name))
  20494.                         ; 
  20495.                     Open(Next_Target, Target, To_Text(Key_Name), To_Text(
  20496.                         Rel_Name), (1 => Read, 2 => Write_Relationships)); 
  20497.  
  20498.                     Get_Shadow_File_Name(Next_Target, Shadow_File, Size); 
  20499.                     Set_A_Relationship(Target, To_Text(Rel_Name), To_Text(
  20500.                         Key_Name), Rel_Attr, Primary, Shadow_File); 
  20501.                     Add_Relationships(Next_From, Next_Target); 
  20502.                                                               --Recursive Call!!
  20503.                     Close(Next_From); 
  20504.                 else 
  20505.                     Set_A_Relationship(Target, To_Text(Rel_Name), To_Text(
  20506.                         Key_Name), Rel_Attr, Primary, Check_Shadow(Shadow_File))
  20507.                         ; 
  20508.                 end if; 
  20509.             end loop;       --check all keys
  20510.         end loop;               --check all relations
  20511.         Close(Target); 
  20512.     end Add_Relationships; 
  20513.  
  20514.  
  20515. begin
  20516.     if not Is_Open(From) then                           --From and Base must be
  20517.         raise Node_Definitions.Status_Error;            --open. Create checks
  20518.     end if;                                             --Base.
  20519.  
  20520.  
  20521.     -- Make sure that Name_Error conditions don't exist for the target.
  20522.     -- Note Create also checks for existence of the relationship.  This
  20523.     -- check is made here so that the Intent of the From node
  20524.     -- may be checked in the order required by MIL-STD-CAIS
  20525.     Check_Name : begin
  20526.       --First Check for syntax errors in the Relation and Key parameter
  20527.       --To_Token raises Use_Error for improper syntax
  20528.         To_Token(To_Relation, Syntax_Check); 
  20529.         To_Token(To_Key, Syntax_Check); 
  20530.  
  20531.       --Now Make sure the relationship doesn't exist.
  20532.         Node_Representation.Get_A_Relationship(Node => To_Base, Rel_Name => 
  20533.             To_Relation, Rel_Key => To_Key, Rel_Attributes => Rel_Attr, Primary
  20534.             => Primary, Shadow_File => Shadow_File); 
  20535.         -- if we get here, the specified relationship already exists.
  20536.         -- This procedure call is history...
  20537.         raise Node_Definitions.Name_Error; 
  20538.     exception
  20539.         when Node_Definitions.Use_Error => 
  20540.             raise Node_Definitions.Name_Error; 
  20541.         when No_Such_Relation | No_Such_Relationship => 
  20542.             null;  -- the relationship does NOT exist...
  20543.     end Check_Name; 
  20544.  
  20545.                         --Check File Kind. Create same kind of node or
  20546.                         --raise Use_Error for process nodes. Create checks
  20547.                         --Base and checks that To_Relation is not predefined
  20548.     Kind := Get_Kind(From); 
  20549.     if Kind /= Structural and then Kind /= File then 
  20550.         raise Node_Definitions.Use_Error; 
  20551.     end if; 
  20552.  
  20553.     Cais_Utilities.Check_Intentions(From, Read);        --Insure proper intent
  20554.                                                         --Create checks Base.
  20555.  
  20556.  
  20557.     --First recurse thru the tree marking each node, and locking access
  20558.     Mark_Tree(From);                                    --Recursive procedure!!
  20559.  
  20560.     --Now that access to all nodes is guaranteed, recursively copy them
  20561.     Copy_Sub_Tree(From, To_Base, To_Key, To_Relation, New_Node); 
  20562.                                                         --Recursive procedure!!
  20563.     Get_Shadow_File_Name(From, Old_Shadow_File, Size); 
  20564.     Get_Shadow_File_Name(New_Node, New_Shadow_File, Size); 
  20565.     Save_Shadows(New_Shadow_File, Old_Shadow_File); 
  20566.  
  20567.     --Now Adjust relationships by copying attributes for Primary ones and
  20568.     --    by copying 2ndary ones with updated references within the tree.
  20569.     Add_Relationships(From, New_Node); 
  20570.                                                         --Recursive procedure!!
  20571.  
  20572. end Copy_Tree; 
  20573. --::::::::::::::
  20574. --create_node.a
  20575. --::::::::::::::
  20576.  
  20577. ----------------------------------------------------------------------
  20578. --                      C R E A T E _ N O D E
  20579. --              (Separate procedure in Node_Internals)
  20580. --
  20581. --
  20582. --                    Creates a node and installs the
  20583. --                       primary relationship to it.
  20584. --
  20585. --
  20586. --
  20587. --
  20588. --                  Ada Software Engineering Group
  20589. --                      The MITRE Corporation
  20590. --                         McLean, VA 22102
  20591. --
  20592. --
  20593. --                   Tue Jul 16 13:28:05 EDT 1985
  20594. --
  20595. --                 (Unclassified and uncopyrighted)
  20596. --
  20597. ----------------------------------------------------------------------
  20598. ----------------------  C R E A T E _ N O D E  ----------------------
  20599. --
  20600. --  Purpose:
  20601. --  -------
  20602. --    This procedure creates a node and installs the 
  20603. --    primary relationship to it.  The relation name and relationship
  20604. --    key of the primary relationship to the node and the base node
  20605. --    from which it emanates are given by the parameters Relation,
  20606. --    Key, and Base.  An open node handle to the newly created node
  20607. --    with WRITE intent is returned in Node.
  20608. --
  20609. --  Parameters:
  20610. --  ----------
  20611. --    Node        closed node handle to be opened to the new node
  20612. --    Base        open node handle to the node from which the primary
  20613. --            relationship to the new node is to emanate
  20614. --    Kind        the Node_Kind of the new node
  20615. --    Internals_Attributes  Node attributes that are NOT settable
  20616. --                by the user or that are part of the implementation.
  20617. --    User_Attributes  Node attributes that are settable by the user.
  20618. --    Key         relationship key of the primary relation to be created
  20619. --    Relation    relation name of the primary relation to be created
  20620. --
  20621. --  Exceptions:  (All Node_Definitions.-)
  20622. --  ----------
  20623. --    NAME_ERROR        - if a node exists for the node identification
  20624. --                        given, if the node identification is illegal.
  20625. --    SECURITY_VIOLATION  if the operation violates mandatory access
  20626. --                        controls; raised only if conditions for other
  20627. --                        exceptions are not met.
  20628. --    USE_ERROR         if the User_Attributes list includes invalid
  20629. --                      node attributes or attributes not user-settable.
  20630. --
  20631. --  Notes:
  20632. --  -----
  20633. --     The calling routine is responsible for creating the 
  20634. --     contents file if this is a FILE node.
  20635. --
  20636. ---------------------------------------------------------------------
  20637.  
  20638. separate(Cais.Node_Internals)
  20639. procedure Create_Node(Node                 : in out Node_Type; 
  20640.                       Base                 : in out Node_Type; 
  20641.                       Kind                 : Node_Kind; 
  20642.                       Internals_Attributes : List_Type; 
  20643.                       User_Attributes      : List_Type; 
  20644.                       Internals_Relations  : List_Type; 
  20645.                       Intent               : Intention; 
  20646.                       Access_Control       : List_Type; 
  20647.                       Level                : List_Type; 
  20648.                       Key                  : String; 
  20649.                       Relation             : String) is 
  20650.  
  20651.     use Pragmatics; 
  20652.     use Cais_Internals_Exceptions; 
  20653.     use Cais_Host_Dependent; 
  20654.     use Trace; 
  20655.     use Cais_Utilities; 
  20656.     use Attributes; 
  20657.  
  20658.  
  20659.     Shadow_File       : String(1 .. Max_Shadow_File_Length); 
  20660.     New_Shadow_File   : String(1 .. Max_Shadow_File_Length); 
  20661.     Shadow_Length     : Natural; 
  20662.     Is_Primary        : Boolean; 
  20663.     Rel_Attributes    : List_Type; 
  20664.     Simple_List       : List_Type; 
  20665.     Base_Attributes   : List_Type; 
  20666.     New_Shadow_Length : Natural; 
  20667.  
  20668. begin
  20669.     if Node_Representation.Open_Status(Node) or not Node_Representation.
  20670.         Open_Status(Base) then 
  20671.         raise Node_Definitions.Status_Error; 
  20672.     end if; 
  20673.     Cais_Utilities.Check_Intentions(Base, Append_Relationships); 
  20674.  
  20675.     -- Verify that the Key and Rel strings are syntactically valid
  20676.     if not Valid_Relation_Name (Relation) or
  20677.     not Valid_Relation_Key (Key) then
  20678.     raise Node_Definitions.Name_Error;
  20679.     end if;
  20680.  
  20681.     -- verify that the specified relation is not a predefined one that
  20682.     -- the user cannot set.
  20683.     if Predefined(Relation, Cais_Utilities.Relation) then 
  20684.         raise Node_Definitions.Use_Error; 
  20685.     end if; 
  20686.  
  20687.     -- see if rel and key for base refer to existing node
  20688.     Check_Relationship : begin
  20689.         Node_Representation.Get_A_Relationship(Node => Base, Rel_Name => 
  20690.             Relation, Rel_Key => Key, Rel_Attributes => Base_Attributes, Primary
  20691.             => Is_Primary, Shadow_File => Shadow_File); 
  20692.         -- if we get here, the specified relationship already exists.
  20693.         -- This procedure call is history...
  20694.         raise Node_Definitions.Name_Error; 
  20695.     exception
  20696.         -- exceptions that are trapped (nothing propogated)
  20697.         when No_Such_Relation | No_Such_Relationship => 
  20698.             null;  -- the relationship does NOT exist...
  20699.  
  20700.         -- exceptions that are propogated
  20701.         when Name_Error => 
  20702.             raise; 
  20703.  
  20704.         -- exceptions that are mapped to other exceptions
  20705.         when Use_Error =>   -- something was wrong with the rel or key
  20706.             raise Name_Error; 
  20707.         -- predefined exceptions (propogated with trace)
  20708.         when Constraint_Error | Tasking_Error | Program_Error | Storage_Error | 
  20709.             Numeric_Error => 
  20710.             Trace.Report("PREDEFINED EXCEPTION in Node_Internals.Create_Node"); 
  20711.             raise; 
  20712.         -- unanticipated exceptions
  20713.         when others => 
  20714.             Trace.Report("UNANTICIPATED EXCEPTION in Node_Internals.Create_Node"
  20715.                 ); 
  20716.             raise Trace.Assertion_Violation; 
  20717.     end Check_Relationship; 
  20718.  
  20719.     -- Set the supplied values for the new node
  20720.     Set_Open(Node, True); 
  20721.     Set_Intent(Node, (1 => Append_Attributes)); 
  20722.     Set_Node_Level(Node, Level); 
  20723.     Set_Kind(Node, Kind); 
  20724.     Set_Node_Access_Control(Node, Access_Control); 
  20725.     Set_Node_Relations(Node, Internals_Relations); 
  20726.     Set_Node_Attributes(Node, Internals_Attributes); 
  20727.  
  20728.     -- build a pathname from the base, relation, and key...
  20729.     Build_Name : declare
  20730.         Name                                : String(1 .. Max_Name_String); 
  20731.         Name_Length, Rel_Length, Key_Length : Natural; 
  20732.     begin
  20733.         Get_Pathname(Base, Name, Name_Length); 
  20734.         Rel_Length := Last_Non_Space(Relation); 
  20735.         Key_Length := Last_Non_Space(Key); 
  20736.         Set_Pathname(Node, Name(1 .. Name_Length) & "'" & Relation(Relation'
  20737.             First .. Rel_Length) & "(" & Key(Key'First .. Key_Length) & ")"); 
  20738.     end Build_Name; 
  20739.  
  20740.     -- loop through User_Attributes, using create to add them...
  20741.     Add_Attributes : declare
  20742.         Attribute_Token : Token_Type; 
  20743.         Attribute_Count : List_Utilities.Count; 
  20744.         Attribute_Value : List_Type; 
  20745.     begin
  20746.         for I in 1 .. Length(User_Attributes) loop
  20747.             Extract(User_Attributes, I, Attribute_Value); 
  20748.             Item_Name(User_Attributes, I, Attribute_Token); 
  20749.             Create_Node_Attribute(Node, Identifier_Items.To_Text(Attribute_Token
  20750.                 ), Attribute_Value); 
  20751.         end loop; 
  20752.     exception
  20753.         -- Use_Error is raised if the attribute is predefined or exists
  20754.         when Node_Definitions.Use_Error => 
  20755.             raise; 
  20756.         when others => 
  20757.             Trace.Report("Node_Internals.Create_Node add_attributes"); 
  20758.             raise Trace.Assertion_Violation; 
  20759.     end Add_Attributes; 
  20760.  
  20761.     -- create a shadow file for the new node
  20762.     Cais_Host_Dependent.Get_Unique_Filename(New_Shadow_File, New_Shadow_Length)
  20763.         ; 
  20764.     Set_Shadow_File_Name(Node, New_Shadow_File(1 .. New_Shadow_Length)); 
  20765.  
  20766.     -- Attributes of the Parent relation are the Kind (standard for all
  20767.     -- relations), and the primary relationship and key from the parent
  20768.     -- node that designates this new node
  20769.     Get_Shadow_File_Name(Base, Shadow_File, Shadow_Length); 
  20770.     Copy(Rel_Attributes, Empty_List); 
  20771.     Cais_Utilities.String_To_Simple_List(Node_Kind'Image(Get_Kind(Base)), 
  20772.         Simple_List); 
  20773.     Insert(Rel_Attributes, Simple_List, "Kind", 0); 
  20774.     Cais_Utilities.String_To_Simple_List(Relation, Simple_List); 
  20775.     Insert(Rel_Attributes, Simple_List, "Primary_Relation", 0); 
  20776.     Cais_Utilities.String_To_Simple_List(Key, Simple_List); 
  20777.     Insert(Rel_Attributes, Simple_List, "Primary_Key", 0); 
  20778.     Set_A_Relationship(Node => Node, Rel_Name => "Parent", Rel_Key => "", 
  20779.         Rel_Attributes => Rel_Attributes, Primary => False, Shadow_File => 
  20780.         Shadow_File(1 .. Shadow_Length)); 
  20781.  
  20782.     Write_Shadow_File(Node); 
  20783.  
  20784.     -- Leave node open with requested intent
  20785.     Set_Intent(Node, (1 => Existence)); -- Reset first association
  20786.     Set_Intent(Node, Intent); 
  20787.  
  20788.     -- Add this primary relationship to the Base node
  20789.     Cais_Utilities.String_To_Simple_List(Node_Kind'Image(Kind), Simple_List); 
  20790.     Copy(Rel_Attributes, Empty_List); 
  20791.     Insert(Rel_Attributes, Simple_List, "Kind", 0); 
  20792.     Set_A_Relationship(Node => Base, Rel_Name => Relation, Rel_Key => Key, 
  20793.         Rel_Attributes => Rel_Attributes, Primary => True, Shadow_File => 
  20794.         New_Shadow_File(1 .. New_Shadow_Length)); 
  20795.     Write_Shadow_File(Base); 
  20796.  
  20797. exception
  20798.     -- exceptions that are trapped (nothing propagated)
  20799.     -- exceptions that are propagated
  20800.     when Node_Definitions.Status_Error | Node_Definitions.Use_Error | 
  20801.         Node_Definitions.Intent_Violation | Node_Definitions.Name_Error | 
  20802.         Node_Definitions.Security_Violation => 
  20803.         Set_Open(Node, False); 
  20804.         raise; 
  20805.     -- exceptions that are mapped to other exceptions
  20806.     when Cais_Internals_Exceptions.No_Such_Shadow_File => 
  20807.         Set_Open(Node, False); 
  20808.         raise Node_Definitions.Name_Error; 
  20809.     -- predefined exceptions (propagated with trace)
  20810.     when Constraint_Error | Tasking_Error | Program_Error | Storage_Error | 
  20811.         Numeric_Error => 
  20812.         Set_Open(Node, False); 
  20813.         Trace.Report("PREDEFINED EXCEPTION in Node_Internals.Create_Node "); 
  20814.         raise; 
  20815.     -- unanticipated exceptions
  20816.     when others => 
  20817.         Set_Open(Node, False); 
  20818.         Trace.Report("UNANTICIPATED EXCEPTION in Node_Internals.Create_Node "); 
  20819.         raise Trace.Assertion_Violation; 
  20820.  
  20821. end Create_Node; 
  20822. --::::::::::::::
  20823. --cset.a
  20824. --::::::::::::::
  20825. -------- SIMTEL20 Ada Software Repository Prologue ------------
  20826. --                                                           -*
  20827. -- Unit name    : CHARACTER_SET
  20828. -- Version      : 1.1
  20829. -- Author       : Richard Conn
  20830. --              : Texas Instruments, Ada Technology Branch
  20831. --              : PO Box 801, MS 8007
  20832. --              : McKinney, TX  75069
  20833. -- DDN Address  : RCONN at SIMTEL20
  20834. -- Copyright    : (c) 1985 Richard Conn
  20835. -- Date created : 15 Feb 85
  20836. -- Release date : 15 Feb 85
  20837. -- Last update  : 25 Feb 85
  20838. -- Machine/System Compiled/Run on : DG MV 10000, ROLM ADE
  20839. --                                                           -*
  20840. ---------------------------------------------------------------
  20841. --                                                           -*
  20842. -- Keywords     :
  20843. ----------------: character, character set
  20844. --
  20845. -- Abstract     : CHARACTER_SET provides a number of test routines
  20846. ----------------: which determine if a given character falls into
  20847. -- a particular class of characters.  See the visible section for
  20848. -- details.  It also provides routines for character and string
  20849. -- letter case conversion (to lower case, to upper case) and for
  20850. -- naming control characters.
  20851. --                                                           -*
  20852. ------------------ Revision history ---------------------------
  20853. --                                                           -*
  20854. -- DATE         VERSION AUTHOR                  HISTORY
  20855. -- 2/15/85      1.0     Richard Conn            Initial Release
  20856. -- 2/25/85      1.1     Richard Conn            Cosmetic, Readability Changes
  20857. -- 4/10/85      1.2     C. Howell           added Last_Non_Space
  20858. ------------------ Distribution and Copyright -----------------
  20859. --                                                           -*
  20860. -- This prologue must be included in all copies of this software.
  20861. --
  20862. -- This software is copyright by the author.
  20863. --
  20864. -- This software is released to the Ada community.
  20865. -- This software is released to the Public Domain (note:
  20866. --   software released to the Public Domain is not subject
  20867. --   to copyright protection).
  20868. -- Restrictions on use or distribution:  NONE
  20869. --                                                           -*
  20870. ------------------ Disclaimer ---------------------------------
  20871. --                                                           -*
  20872. -- This software and its documentation are provided "AS IS" and
  20873. -- without any expressed or implied warranties whatsoever.
  20874. -- No warranties as to performance, merchantability, or fitness
  20875. -- for a particular purpose exist.
  20876. --
  20877. -- Because of the diversity of conditions and hardware under
  20878. -- which this software may be used, no warranty of fitness for
  20879. -- a particular purpose is offered.  The user is advised to
  20880. -- test the software thoroughly before relying on it.  The user
  20881. -- must assume the entire risk and liability of using this
  20882. -- software.
  20883. --
  20884. -- In no event shall any person or organization of people be
  20885. -- held responsible for any direct, indirect, consequential
  20886. -- or inconsequential damages or lost profits.
  20887. --                                                           -*
  20888. -------------------END-PROLOGUE--------------------------------
  20889. -- 
  20890. -- Components Package CHARACTER_SET
  20891. -- by Richard Conn, TI Ada Technology Branch
  20892. -- Version 1.1, Date 25 Feb 85
  20893. -- Version 1.0, Date 13 Feb 85
  20894. -- 
  20895. package CHARACTER_SET is
  20896.  
  20897. -- 
  20898. -- These routines test for the following subsets of ASCII
  20899. -- 
  20900. -- Routine              Subset tested for
  20901. -- =======              =================
  20902. -- ALPHA                'a'..'z' | 'A'..'Z'
  20903. -- ALPHA_NUMERIC        ALPHA | '0'..'9'
  20904. -- CONTROL              < ' ' | DEL
  20905. -- DIGIT                '0'..'9'
  20906. -- GRAPHIC              ' ' < ch < DEL (does not include space)
  20907. -- HEXADECIMAL          DIGIT | 'A'..'F' | 'a'..'f'
  20908. -- LOWER                'a'..'z'
  20909. -- PRINTABLE            GRAPHIC | ' '
  20910. -- PUNCTUATION          GRAPHIC and not ALPHA_NUMERIC
  20911. -- SPACE                HT | LF | VT | FF | CR | ' '
  20912. -- UPPER                'A'..'Z'
  20913. -- 
  20914.     function IS_ALPHA         (CH : CHARACTER) return BOOLEAN;
  20915.     function IS_ALPHA_NUMERIC (CH : CHARACTER) return BOOLEAN;
  20916.     function IS_CONTROL       (CH : CHARACTER) return BOOLEAN;
  20917.     function IS_DIGIT         (CH : CHARACTER) return BOOLEAN;
  20918.     function IS_GRAPHIC       (CH : CHARACTER) return BOOLEAN;
  20919.     function IS_HEXADECIMAL   (CH : CHARACTER) return BOOLEAN;
  20920.     function IS_LOWER         (CH : CHARACTER) return BOOLEAN;
  20921.     function IS_PRINTABLE     (CH : CHARACTER) return BOOLEAN;
  20922.     function IS_PUNCTUATION   (CH : CHARACTER) return BOOLEAN;
  20923.     function IS_SPACE         (CH : CHARACTER) return BOOLEAN;
  20924.     function IS_UPPER         (CH : CHARACTER) return BOOLEAN;
  20925.  
  20926. -- 
  20927. -- These routines convert characters and strings to upper- or lower-case
  20928. -- 
  20929.     function  TO_LOWER (CH : CHARACTER) return CHARACTER;
  20930.     procedure TO_LOWER (CH : in out CHARACTER);
  20931.     procedure TO_LOWER (STR : in out STRING);
  20932.     function  TO_UPPER (CH : CHARACTER) return CHARACTER;
  20933.     procedure TO_UPPER (CH : in out CHARACTER);
  20934.     procedure TO_UPPER (STR : in out STRING);
  20935.  
  20936. -- 
  20937. -- These routines return the names of the control characters
  20938. -- 
  20939.     subtype CONTROL_CHARACTER_NAME_2 is STRING (1 .. 2);
  20940.     subtype CONTROL_CHARACTER_NAME_3 is STRING (1 .. 3);
  20941. -- 
  20942.     function CC_NAME_2 (CH : CHARACTER) return CONTROL_CHARACTER_NAME_2;
  20943.     function CC_NAME_3 (CH : CHARACTER) return CONTROL_CHARACTER_NAME_3;
  20944.  
  20945. -- This routine returns the offset (from the first character) of the
  20946. -- last non_space character.   CCH 4/10/85
  20947.     function Last_Non_Space (Str : String) return Integer;
  20948.  
  20949.  
  20950. end CHARACTER_SET;
  20951.  
  20952. package body CHARACTER_SET is
  20953.  
  20954.     function IS_ALPHA (CH : CHARACTER) return BOOLEAN is
  20955.     begin
  20956.         case CH is
  20957.             when 'a' .. 'z' => 
  20958.                 return TRUE;
  20959.             when 'A' .. 'Z' => 
  20960.                 return TRUE;
  20961.             when others => 
  20962.                 return FALSE;
  20963.         end case;
  20964.     end IS_ALPHA;
  20965.  
  20966.     function IS_ALPHA_NUMERIC (CH : CHARACTER) return BOOLEAN is
  20967.     begin
  20968.         case CH is
  20969.             when 'a' .. 'z' => 
  20970.                 return TRUE;
  20971.             when 'A' .. 'Z' => 
  20972.                 return TRUE;
  20973.             when '0' .. '9' => 
  20974.                 return TRUE;
  20975.             when others => 
  20976.                 return FALSE;
  20977.         end case;
  20978.     end IS_ALPHA_NUMERIC;
  20979.  
  20980.     function IS_CONTROL (CH : CHARACTER) return BOOLEAN is
  20981.     begin
  20982.         if CH < ' ' or CH = ASCII.DEL then
  20983.             return TRUE;
  20984.         else
  20985.             return FALSE;
  20986.         end if;
  20987.     end IS_CONTROL;
  20988.  
  20989.     function IS_DIGIT (CH : CHARACTER) return BOOLEAN is
  20990.     begin
  20991.         if CH in '0' .. '9' then
  20992.             return TRUE;
  20993.         else
  20994.             return FALSE;
  20995.         end if;
  20996.     end IS_DIGIT;
  20997.  
  20998.     function IS_GRAPHIC (CH : CHARACTER) return BOOLEAN is
  20999.     begin
  21000.         if CH > ' ' and CH < ASCII.DEL then
  21001.             return TRUE;
  21002.         else
  21003.             return FALSE;
  21004.         end if;
  21005.     end IS_GRAPHIC;
  21006.  
  21007.     function IS_HEXADECIMAL (CH : CHARACTER) return BOOLEAN is
  21008.     begin
  21009.         case CH is
  21010.             when '0' .. '9' => 
  21011.                 return TRUE;
  21012.             when 'A' .. 'F' | 'a' .. 'f' => 
  21013.                 return TRUE;
  21014.             when others => 
  21015.                 return FALSE;
  21016.         end case;
  21017.     end IS_HEXADECIMAL;
  21018.  
  21019.     function IS_LOWER (CH : CHARACTER) return BOOLEAN is
  21020.     begin
  21021.         if CH in 'a' .. 'z' then
  21022.             return TRUE;
  21023.         else
  21024.             return FALSE;
  21025.         end if;
  21026.     end IS_LOWER;
  21027.  
  21028.     function IS_PRINTABLE (CH : CHARACTER) return BOOLEAN is
  21029.     begin
  21030.         if CH >= ' ' and CH < ASCII.DEL then
  21031.             return TRUE;
  21032.         else
  21033.             return FALSE;
  21034.         end if;
  21035.     end IS_PRINTABLE;
  21036.  
  21037.     function IS_PUNCTUATION (CH : CHARACTER) return BOOLEAN is
  21038.     begin
  21039.         if (CH > ' ') and (CH < ASCII.DEL) and (not IS_ALPHA_NUMERIC (CH)) then
  21040.             return TRUE;
  21041.         else
  21042.             return FALSE;
  21043.         end if;
  21044.     end IS_PUNCTUATION;
  21045.  
  21046.     function IS_SPACE (CH : CHARACTER) return BOOLEAN is
  21047.     begin
  21048.         case CH is
  21049.             when ASCII.HT => 
  21050.                 return TRUE;
  21051.             when ASCII.LF => 
  21052.                 return TRUE;
  21053.             when ASCII.VT => 
  21054.                 return TRUE;
  21055.             when ASCII.FF => 
  21056.                 return TRUE;
  21057.             when ASCII.CR => 
  21058.                 return TRUE;
  21059.             when ' ' => 
  21060.                 return TRUE;
  21061.             when others => 
  21062.                 return FALSE;
  21063.         end case;
  21064.     end IS_SPACE;
  21065.  
  21066.     function IS_UPPER (CH : CHARACTER) return BOOLEAN is
  21067.     begin
  21068.         if CH in 'A' .. 'Z' then
  21069.             return TRUE;
  21070.         else
  21071.             return FALSE;
  21072.         end if;
  21073.     end IS_UPPER;
  21074.  
  21075.     function TO_LOWER (CH : CHARACTER) return CHARACTER is
  21076.     begin
  21077.         if IS_UPPER (CH) then
  21078.             return CHARACTER'VAL
  21079.                      (CHARACTER'POS (CH) - CHARACTER'POS ('A') +
  21080.                       CHARACTER'POS ('a'));
  21081.         else
  21082.             return CH;
  21083.         end if;
  21084.     end TO_LOWER;
  21085.  
  21086.     procedure TO_LOWER (CH : in out CHARACTER) is
  21087.     begin
  21088.         if IS_UPPER (CH) then
  21089.             CH := TO_LOWER (CH);
  21090.         end if;
  21091.     end TO_LOWER;
  21092.  
  21093.     procedure TO_LOWER (STR : in out STRING) is
  21094.     begin
  21095.         for I in STR'FIRST .. STR'LAST loop
  21096.             STR (I) := TO_LOWER (STR (I));
  21097.         end loop;
  21098.     end TO_LOWER;
  21099.  
  21100.     function TO_UPPER (CH : CHARACTER) return CHARACTER is
  21101.     begin
  21102.         if IS_LOWER (CH) then
  21103.             return CHARACTER'VAL
  21104.                      (CHARACTER'POS (CH) - CHARACTER'POS ('a') +
  21105.                       CHARACTER'POS ('A'));
  21106.         else
  21107.             return CH;
  21108.         end if;
  21109.     end TO_UPPER;
  21110.  
  21111.     procedure TO_UPPER (CH : in out CHARACTER) is
  21112.     begin
  21113.         if IS_LOWER (CH) then
  21114.             CH := TO_UPPER (CH);
  21115.         end if;
  21116.     end TO_UPPER;
  21117.  
  21118.     procedure TO_UPPER (STR : in out STRING) is
  21119.     begin
  21120.         for I in STR'FIRST .. STR'LAST loop
  21121.             STR (I) := TO_UPPER (STR (I));
  21122.         end loop;
  21123.     end TO_UPPER;
  21124.  
  21125.     function CC_NAME_2 (CH : CHARACTER) return CONTROL_CHARACTER_NAME_2 is
  21126.         NAME : CONTROL_CHARACTER_NAME_2;
  21127.     begin
  21128.         case CH is
  21129.             when ASCII.NUL =>  NAME := "^@";
  21130.             when ASCII.SOH =>  NAME := "^A";
  21131.             when ASCII.STX =>  NAME := "^B";
  21132.             when ASCII.ETX =>  NAME := "^C";
  21133.             when ASCII.EOT =>  NAME := "^D";
  21134.             when ASCII.ENQ =>  NAME := "^E";
  21135.             when ASCII.ACK =>  NAME := "^F";
  21136.             when ASCII.BEL =>  NAME := "^G";
  21137.             when ASCII.BS =>  NAME := "^H";
  21138.             when ASCII.HT =>  NAME := "^I";
  21139.             when ASCII.LF =>  NAME := "^J";
  21140.             when ASCII.VT =>  NAME := "^K";
  21141.             when ASCII.FF =>  NAME := "^L";
  21142.             when ASCII.CR =>  NAME := "^M";
  21143.             when ASCII.SO =>  NAME := "^N";
  21144.             when ASCII.SI =>  NAME := "^O";
  21145.             when ASCII.DLE =>  NAME := "^P";
  21146.             when ASCII.DC1 =>  NAME := "^Q";
  21147.             when ASCII.DC2 =>  NAME := "^R";
  21148.             when ASCII.DC3 =>  NAME := "^S";
  21149.             when ASCII.DC4 =>  NAME := "^T";
  21150.             when ASCII.NAK =>  NAME := "^U";
  21151.             when ASCII.SYN =>  NAME := "^V";
  21152.             when ASCII.ETB =>  NAME := "^W";
  21153.             when ASCII.CAN =>  NAME := "^X";
  21154.             when ASCII.EM =>  NAME := "^Y";
  21155.             when ASCII.SUB =>  NAME := "^Z";
  21156.             when ASCII.ESC =>  NAME := "^[";
  21157.             when ASCII.FS =>  NAME := "^\";
  21158.             when ASCII.GS =>  NAME := "^]";
  21159.             when ASCII.RS =>  NAME := "^^";
  21160.             when ASCII.US =>  NAME := "^_";
  21161.             when ASCII.DEL =>  NAME := "^`";
  21162.             when others => 
  21163.                 NAME := "  ";
  21164.                 NAME (2) := CH;
  21165.         end case;
  21166.         return NAME;
  21167.     end CC_NAME_2;
  21168.  
  21169.     function CC_NAME_3 (CH : CHARACTER) return CONTROL_CHARACTER_NAME_3 is
  21170.         NAME : CONTROL_CHARACTER_NAME_3;
  21171.     begin
  21172.         case CH is
  21173.             when ASCII.NUL =>  NAME := "NUL";
  21174.             when ASCII.SOH =>  NAME := "SOH";
  21175.             when ASCII.STX =>  NAME := "STX";
  21176.             when ASCII.ETX =>  NAME := "ETX";
  21177.             when ASCII.EOT =>  NAME := "EOT";
  21178.             when ASCII.ENQ =>  NAME := "ENQ";
  21179.             when ASCII.ACK =>  NAME := "ACK";
  21180.             when ASCII.BEL =>  NAME := "BEL";
  21181.             when ASCII.BS =>  NAME := "BS ";
  21182.             when ASCII.HT =>  NAME := "HT ";
  21183.             when ASCII.LF =>  NAME := "LF ";
  21184.             when ASCII.VT =>  NAME := "VT ";
  21185.             when ASCII.FF =>  NAME := "FF ";
  21186.             when ASCII.CR =>  NAME := "CR ";
  21187.             when ASCII.SO =>  NAME := "SO ";
  21188.             when ASCII.SI =>  NAME := "SI ";
  21189.             when ASCII.DLE =>  NAME := "DLE";
  21190.             when ASCII.DC1 =>  NAME := "DC1";
  21191.             when ASCII.DC2 =>  NAME := "DC2";
  21192.             when ASCII.DC3 =>  NAME := "DC3";
  21193.             when ASCII.DC4 =>  NAME := "DC4";
  21194.             when ASCII.NAK =>  NAME := "NAK";
  21195.             when ASCII.SYN =>  NAME := "SYN";
  21196.             when ASCII.ETB =>  NAME := "ETB";
  21197.             when ASCII.CAN =>  NAME := "CAN";
  21198.             when ASCII.EM =>  NAME := "EM ";
  21199.             when ASCII.SUB =>  NAME := "SUB";
  21200.             when ASCII.ESC =>  NAME := "ESC";
  21201.             when ASCII.FS =>  NAME := "FS ";
  21202.             when ASCII.GS =>  NAME := "GS ";
  21203.             when ASCII.RS =>  NAME := "RS ";
  21204.             when ASCII.US =>  NAME := "US ";
  21205.             when ASCII.DEL =>  NAME := "DEL";
  21206.             when others => 
  21207.                 NAME := "   ";
  21208.                 NAME (2) := CH;
  21209.         end case;
  21210.         return NAME;
  21211.     end CC_NAME_3;
  21212.  
  21213. -- This routine returns the offset (from the first character) of the
  21214. -- last non_space character.   CCH 4/10/85
  21215.     function Last_Non_Space (Str : String) return Integer is
  21216.     Tmp : Integer;
  21217.     begin
  21218.     Tmp := Str'last ;
  21219.     for I in reverse Str'range loop
  21220.         exit when not Is_Space (Str(I)) ;
  21221.         Tmp := Tmp - 1;
  21222.     end loop;
  21223.     return (Tmp);
  21224.     end Last_Non_Space;
  21225.  
  21226. end CHARACTER_SET;
  21227. --::::::::::::::
  21228. --delete_node.a
  21229. --::::::::::::::
  21230.  
  21231. ----------------------------------------------------------------------
  21232. --                     D E L E T E _ N O D E
  21233. --           (Separate procedure in Node_Management)
  21234. --
  21235. --
  21236. --               Deletes the primary relationship to a node.
  21237. --
  21238. --
  21239. --
  21240. --
  21241. --                  Ada Software Engineering Group
  21242. --                      The MITRE Corporation
  21243. --                         McLean, VA 22102
  21244. --
  21245. --
  21246. --                   Wed Jun 26 09:10:14 EDT 1985
  21247. --
  21248. --                 (Unclassified and uncopyrighted)
  21249. --
  21250. ----------------------------------------------------------------------
  21251.  
  21252. ----------------------   D E L E T E _ N O D E ----------------------
  21253. --
  21254. --  Purpose:
  21255. --  -------
  21256. --    This procedure deletes the primary relationship to a node
  21257. --    identified by Node.  The node becomes unobtainable.  The node
  21258. --    handle Node is closed.  If the node is a process node and the
  21259. --    process is not yet terminated (see Section 5.2 of MIL-STD-CAIS),
  21260. --    Delete_Node aborts the process.
  21261. --
  21262. --  Parameters:
  21263. --  ----------
  21264. --    Node  - an open node handle to the node which is the target of
  21265. --            the primary relationship to be deleted.
  21266. --
  21267. --  Exceptions:
  21268. --  ----------
  21269. --    (all defined in Node_Definitions)
  21270. --    Name_Error          - if parent node of Node is inaccessable
  21271. --    Use_Error           - if any primary Relationships emanate from Node
  21272. --    Status_Error        - if Node is not open
  21273. --    Lock_Error          - if access, with intent Write_Relationships,
  21274. --                          to the parent of the node to be deleted
  21275. --                          cannot be obtained due to an existing lock
  21276. --                          on the node.
  21277. --    Intent_Violation    - if the node handle Node was not opened with
  21278. --                          an intent including Exclusive_Write and 
  21279. --                          Read_Relationships.
  21280. --    Access_Violation    - if the current process does not have sufficient
  21281. --                          discretionary access control rights to obtain
  21282. --                          access to the parent of the node to be deleted
  21283. --                          with intent Write_Relationships and the
  21284. --                          conditions for Name_Error are not present.
  21285. --    Security_Violation  - if the operation represents a violation of
  21286. --                          mandatory access controls.  Security_Violation
  21287. --                          is raised only if the conditions for other
  21288. --                          exceptions are not present.
  21289. --
  21290. --  Notes:
  21291. --  -----
  21292. --    MIL-STD-CAIS 5.1.2.21
  21293. ---------------------------------------------------------------------
  21294.  
  21295. separate(Cais.Node_Management)
  21296. procedure Delete_Node(Node : in out Node_Type) is 
  21297.  
  21298.     use Attributes; 
  21299.     use List_Utilities; 
  21300.     use Standard.Text_Io; 
  21301.  
  21302.  
  21303.     Parent_Node      : Node_Type; 
  21304.     Shadow_File      : String(1 .. Max_Shadow_File_Length); 
  21305.     Contents_File    : String(1 .. Max_Contents_File_Length); 
  21306.     Name_Length      : Natural; 
  21307.     Node_Relations   : List_Type; 
  21308.     Simple_List      : List_Type; 
  21309.     Primary_Key      : String(1 .. Max_Relationship_Key); 
  21310.     Phyl             : File_Type; 
  21311.     Primary_Relation : String(1 .. Max_Relationship_Name); 
  21312. begin
  21313.  
  21314.     -- check_intentions for Exclusive_Write and Read_Relationships
  21315.     -- (Status_Error is raised if the node is not open...)
  21316.     Cais_Utilities.Check_Intentions(Node, Exclusive_Write); 
  21317.     Cais_Utilities.Check_Intentions(Node, Read_Relationships); 
  21318.  
  21319.     -- if any of the relationships emanating from this node are
  21320.     -- primary relationships, raise Node_Definitions.Use_Error
  21321.     Check_For_Primary : declare
  21322.         Relationship, Relation : List_Type; 
  21323.     begin
  21324.         Get_Node_Relations(Node, Node_Relations); 
  21325.         for Relation_Count in 1 .. Length(Node_Relations) loop
  21326.             Extract(Node_Relations, Relation_Count, Relation); 
  21327.             for Relationship_Count in 1 .. Length(Relation) loop
  21328.                 Extract(Relation, Relationship_Count, Relationship); 
  21329.                 Test_Relationship : begin
  21330.                     Replace(Relationship, Empty_List, Node_Representation.
  21331.                         Primary_Rel); 
  21332.                     -- if we get here, there IS a primary relationship
  21333.                     -- from this node.  Time to raise the exception
  21334.                     raise Node_Definitions.Use_Error; 
  21335.                 exception
  21336.                     when Search_Error => 
  21337.                         -- Primary_Rel was not found (good!)
  21338.                         null; 
  21339.                 end Test_Relationship; 
  21340.             end loop; --for Relationship_Count in 1 .. Length (Relation) 
  21341.         end loop;  -- for i in 1 .. Length (Node_Relations)
  21342.     end Check_For_Primary; 
  21343.  
  21344.  
  21345.     -- get primary rel from parent to this node...
  21346.     Get_Path_Attribute(Base => Node, Key => "", Relation => "Parent", Attribute
  21347.         => "Primary_Relation", Value => Simple_List); 
  21348.     Cais_Utilities.Simple_List_To_String(Simple_List, Primary_Relation); 
  21349.     Get_Path_Attribute(Base => Node, Key => "", Relation => "Parent", Attribute
  21350.         => "Primary_Key", Value => Simple_List); 
  21351.     Cais_Utilities.Simple_List_To_String(Simple_List, Primary_Key); 
  21352.  
  21353.  
  21354.     Open(Node => Parent_Node, Base => Node, Key => "", Relation => "Parent", 
  21355.         Intent => (1 => Read_Relationships, 2 => Write_Relationships)); 
  21356.  
  21357.     -- remove the primary rel pointing to this node
  21358.     Delete_A_Relationship(Node => Parent_Node, Rel_Name => Primary_Relation, 
  21359.         Rel_Key => Primary_Key); 
  21360.     Write_Shadow_File(Parent_Node); 
  21361.  
  21362.     Get_Shadow_File_Name(Node, Shadow_File, Name_Length); 
  21363.     if Name_Length > 1 then 
  21364.         Open(Phyl, Out_File, Shadow_File(1 .. Name_Length)); 
  21365.         Delete(Phyl); 
  21366.     end if; 
  21367.  
  21368.     Get_Contents_File_Name(Node, Contents_File, Name_Length); 
  21369.     if Name_Length > 1 then 
  21370.         Open(Phyl, Out_File, Contents_File(1 .. Name_Length)); 
  21371.         Delete(Phyl); 
  21372.     end if; 
  21373.  
  21374.     Set_Open(Node, False); 
  21375.  
  21376. end Delete_Node; 
  21377. --::::::::::::::
  21378. --delete_tree.a
  21379. --::::::::::::::
  21380.  
  21381.  
  21382. ----------------------------------------------------------------------
  21383. --                   D E L E T E _ T R E E    
  21384. --           (Separate procedure in Node_Management)
  21385. --
  21386. --
  21387. --  Deletes the all nodes emanating from a given node (+ associated subtrees)
  21388. --
  21389. --
  21390. --
  21391. --
  21392. --                  Ada Software Engineering Group
  21393. --                      The MITRE Corporation
  21394. --                         McLean, VA 22102
  21395. --
  21396. --
  21397. --                   Wed Jun 26 09:10:14 EDT 1985
  21398. --
  21399. --                 (Unclassified and uncopyrighted)
  21400. --
  21401. ----------------------------------------------------------------------
  21402. ----------------------   D E L E T E _ T R E E ----------------------
  21403. --
  21404. --  Purpose:
  21405. --  -------
  21406. --    This procedure effectively performs the Delete_Node operation for
  21407. --    a specified node and recursively applies Delete_Tree to all nodes
  21408. --    reachable by a unique primary pathname from the designated node.
  21409. --    The nodes whose primary relationships are to be deleted are opened
  21410. --    with intent Exclusive_Write, thus locking them for other operations.
  21411. --    The order in which the deletions of primary relationships is performed
  21412. --    is not specified.  If the Delete_Tree operation raises an exception,
  21413. --    none of the primary relationships is deleted.
  21414. --
  21415. --  Parameters:
  21416. --  ----------
  21417. --    Node  - an open node handle to the node at the root of the tree 
  21418. --            whose primary relationships are to be deleted.
  21419. --
  21420. --  Exceptions:
  21421. --  ----------
  21422. --    (all defined in Node_Definitions)
  21423. --    Name_Error          - if parent node of Node or any of the target nodes of
  21424. --                primary relationships to be deleted are inaccessable
  21425. --    Use_Error           - if the primary Relationship of Node belongs to a
  21426. --                predefined relation that cannot be modified by the
  21427. --                user.
  21428. --    Status_Error        - if Node is not open
  21429. --    Lock_Error          - if access, with intent Write_Relationships,
  21430. --                          to the parent of the "Node" cannot be obtained due
  21431. --                to an existing lock or if a node handle identifying
  21432. --                any node whose unique primary path traverses the
  21433. --                node identified by Node cannot be opened with intent
  21434. --                Exclisive_Write.
  21435. --    Intent_Violation    - if the node handle Node was not opened with
  21436. --                          an intent including Exclusive_Write and 
  21437. --                          Read_Relationships.
  21438. --    Access_Violation    - if the current process does not have sufficient
  21439. --                          discretionary access control rights to obtain
  21440. --                          access to the parent of the node specified by Node
  21441. --                          with intent Write_Relationships or to obtain 
  21442. --                access to any target node of a primary relationship
  21443. --                to be deleted with the intent Exclusive_Write and
  21444. --                the conditions for Name_Error are not present.
  21445. --    Security_Violation  - if the operation represents a violation of
  21446. --                          mandatory access controls.  Security_Violation
  21447. --                          is raised only if the conditions for other
  21448. --                          exceptions are not present.
  21449. --
  21450. --  Notes:
  21451. --  -----
  21452. --    MIL-STD-CAIS 5.1.2.22
  21453. --     Locking support will have to be added here...
  21454. ---------------------------------------------------------------------
  21455. separate(Cais.Node_Management)
  21456. procedure Delete_Tree(Node : in out Node_Type) is 
  21457.     use Attributes; 
  21458.     use Identifier_Items; 
  21459.     Parent_Node      : Node_Type; 
  21460.     Primary_Relation : String(1 .. Max_Relationship_Name); 
  21461.     Primary_Key      : String(1 .. Max_Relationship_Key); 
  21462.     Simple_List      : List_Type; 
  21463.  
  21464.  
  21465.     package Shadows is 
  21466.         procedure Save_Shadows(Shadow : String); 
  21467.         procedure Delete_Shadows; 
  21468.     end Shadows; 
  21469.  
  21470.     package body Shadows is 
  21471.         type Shadow_Link; 
  21472.         type Shadow_List is access Shadow_Link; 
  21473.         type Shadow_Link is 
  21474.             record
  21475.                 A_Shadow    : String(1 .. Max_Shadow_File_Length); 
  21476.                 Next_Shadow : Shadow_List; 
  21477.             end record; 
  21478.         Shadows : Shadow_List; 
  21479.  
  21480.         procedure Save_Shadows(Shadow : String) is 
  21481.             New_Record : Shadow_List := new Shadow_Link'(Shadow, Shadows); 
  21482.         begin
  21483.             Shadows := New_Record; 
  21484.         end Save_Shadows; 
  21485.  
  21486.         procedure Delete_Shadows is 
  21487.             Current_Record : Shadow_List := Shadows; 
  21488.             Phyl           : File_Type; 
  21489.         begin
  21490.             while Current_Record /= null loop
  21491.                 Open(Phyl, Out_File, Current_Record.A_Shadow(1 .. Last_Non_Space
  21492.                     (Current_Record.A_Shadow))); 
  21493.                 Delete(Phyl); 
  21494.  
  21495.                 Current_Record := Current_Record.Next_Shadow; 
  21496.             end loop; 
  21497.         end Delete_Shadows; 
  21498.  
  21499.     end Shadows; 
  21500.     use Shadows; 
  21501.     procedure Mark_Tree(Node : Node_Type) is 
  21502.         Node_To_Copy  : Node_Type; 
  21503.         Relation_List : List_Type; 
  21504.         Key_List      : List_Type; 
  21505.         Rel_Name      : Token_Type; 
  21506.         Key_Name      : Token_Type; 
  21507.         Rel_Attr      : List_Type; 
  21508.         Primary       : Boolean; 
  21509.         Shadow_File   : String(1 .. Max_Shadow_File_Length); 
  21510.         Size          : Natural; 
  21511.     begin
  21512.         Get_Shadow_File_Name(Node, Shadow_File, Size); 
  21513.         Save_Shadows(Shadow_File); 
  21514.         if Get_Kind(Node) = File then 
  21515.             Get_Contents_File_Name(Node, Shadow_File, Size); 
  21516.             Save_Shadows(Shadow_File); 
  21517.         end if; 
  21518.  
  21519.         Get_Node_Relations(Node, Relation_List); 
  21520.         for I in 1 .. Length(Relation_List) loop
  21521.             Item_Name(Relation_List, I, Rel_Name); 
  21522.             Extract(Relation_List, I, Key_List); 
  21523.             for J in 1 .. Length(Key_List) loop
  21524.                 Item_Name(Key_List, J, Key_Name); 
  21525.                 Get_A_Relationship(Node, To_Text(Rel_Name), To_Text(Key_Name), 
  21526.                     Shadow_File, Rel_Attr, Primary); 
  21527.                 if Primary then 
  21528.                 --!hack --Reports both Lock Error and Access_Violations
  21529.                 --!hack Mark_Access(Shadow_File, Exclusive_Write);
  21530.  
  21531.                     Set_Shadow_File_Name(Node_To_Copy, Shadow_File); 
  21532.                     begin
  21533.                         --Gaurd against non-existant shadow file for node
  21534.                         Read_Shadow_File(Node_To_Copy); 
  21535.                     exception
  21536.                         when No_Such_Shadow_File => 
  21537.                             raise Node_Definitions.Name_Error; 
  21538.                     end; 
  21539.                     Mark_Tree(Node_To_Copy);            --Recursive Call!!
  21540.                 end if; 
  21541.             end loop;       --check all keys
  21542.         end loop;       --check all relations
  21543.     end Mark_Tree; 
  21544.  
  21545. begin
  21546. --************           Check for exceptional conditions        **************
  21547.     --make sure Node is open
  21548.     if not Is_Open(Node) then 
  21549.         raise Node_Definitions.Status_Error; 
  21550.     end if; 
  21551.  
  21552.     -- get primary rel from parent to this node. Verify it isn't predefined
  21553.     Get_Path_Attribute(Node, "", "Parent", "Primary_Relation", Simple_List); 
  21554.     Cais_Utilities.Simple_List_To_String(Simple_List, Primary_Relation); 
  21555.     Get_Path_Attribute(Node, "", "Parent", "Primary_Key", Simple_List); 
  21556.     Cais_Utilities.Simple_List_To_String(Simple_List, Primary_Key); 
  21557.     if Predefined(Primary_Relation, Cais_Utilities.Relation) then 
  21558.         raise Node_Definitions.Use_Error; 
  21559.     end if; 
  21560.  
  21561.  
  21562.     --First recurse thru the tree marking each node, locking access,
  21563.     --creating a list of all shadow_files (and content_files) to be deleted
  21564.     Mark_Tree(Node);                            --Recursive procedure!!
  21565.  
  21566.  
  21567.  
  21568.  
  21569.  
  21570.     --Next destroy primary links in parent of the top node in the tree
  21571.  
  21572.     -- check_intentions for Exclusive_Write and Read_Relationships
  21573.     Cais_Utilities.Check_Intentions(Node, Exclusive_Write); 
  21574.     Cais_Utilities.Check_Intentions(Node, Read_Relationships); 
  21575.  
  21576.  
  21577.     -- remove the primary rel pointing to this node. Lock_Error, Access Viol.
  21578.     Open(Parent_Node, Node, "", "Parent", (1 => Read_Relationships, 2 => 
  21579.         Write_Relationships)); 
  21580.     Delete_A_Relationship(Parent_Node, Primary_Relation, Primary_Key); 
  21581.     Write_Shadow_File(Parent_Node); 
  21582.     Close(Parent_Node); 
  21583.  
  21584.  
  21585.  
  21586.     --Now, Simply delete all shadow and content files
  21587.     Delete_Shadows; 
  21588.  
  21589. end Delete_Tree; 
  21590. --::::::::::::::
  21591. --delete_user.a
  21592. --::::::::::::::
  21593. ----------------------------------------------------------------------
  21594. --                     D E L E T E _ U S E R
  21595. --
  21596. --
  21597. --               CAIS tool to delete a user from the CAIS 
  21598. --
  21599. --
  21600. --
  21601. --
  21602. --                  Ada Software Engineering Group
  21603. --                      The MITRE Corporation
  21604. --                         McLean, VA 22102
  21605. --
  21606. --                   Thu Feb 20 00:47:23 EST 1986
  21607. --                   
  21608. --
  21609. --                 (Unclassified and uncopyrighted)
  21610. --
  21611. ----------------------------------------------------------------------
  21612. with Text_IO;
  21613. separate (Cais)
  21614. procedure Delete_User is
  21615.  
  21616. begin
  21617.     Standard.Text_Io.Put_Line ("Sorry, Delete_User is not working.");
  21618. end Delete_User;
  21619. --::::::::::::::
  21620. --direct_io_definitions_body.a
  21621. --::::::::::::::
  21622.  
  21623. ----------------------------------------------------------------------
  21624. --                 D I R E C T _ I O _ D E F I N I T I O N S
  21625. --                            (Package Body)
  21626. --
  21627. --
  21628. --               This Package Defines the Types and Exceptions
  21629. --                      Associated with Direct File Handles
  21630. --
  21631. --
  21632. --                  Ada Software Engineering Group
  21633. --                      The MITRE Corporation
  21634. --                         McLean, VA 22102
  21635. --
  21636. --
  21637. --             Wed Oct  9 14:08:19 EDT 1985
  21638. --
  21639. --                 (Unclassified and uncopyrighted)
  21640. --
  21641. ----------------------------------------------------------------------
  21642. ----------------------------------------------------------------------
  21643. --              D I R E C T _ I O _ D E F I N I T I O N S
  21644. --
  21645. --  Purpose:
  21646. --  -------
  21647. --      This package defines the types and exceptions associated with 
  21648. --      Direct_Io file handles.
  21649. --
  21650. --  Usage:
  21651. --  -----
  21652. --    Package Cais.Direct_Io instantiates this package to produce
  21653. --    a new package Dir_Io_Definitions nested in the Cais.Direct_Io 
  21654. --    specification.  For direct use of the base types and exceptions 
  21655. --    used by Cais.Direct_Io, the user can refer to the instantiated 
  21656. --    package.
  21657. --
  21658. --  Notes:
  21659. --  -----
  21660. --    This package  is added to the CAIS implementation
  21661. --    to provide distinct File_Types for each CAIS.Direct_Io
  21662. --    instantiation.  This is an alternative to the present 
  21663. --    CAIS file handle usage, which differs substantially from 
  21664. --    standard Ada Input/Output.
  21665. --    Ada generic I/O packages permit an unbounded number of 
  21666. --    file types to be constructed.  The CAIS requires a single
  21667. --    file type to hide all file types, for use by  text and generic
  21668. --    instantiations of direct and sequential IO packages.
  21669. --    This implementation follows Ada.
  21670. --
  21671. --      The     use     of     a     limited     private     type
  21672. --      (Direct_Io_Definitions.File_Type)  implies  the addition of
  21673. --      subprograms to manipulate  that  type  (e.g.  to  set  or
  21674. --      extract  the  contents of an object of that type).  These
  21675. --      are in this specification, although they are additions to
  21676. --      the  CAIS  specification  for  this  package.  
  21677. --    
  21678. --      This is a version of the package Cais.IO_Definitions,
  21679. --      specified in MIL-STD-CAIS section 5.3.1
  21680. --
  21681. --  Revision History:
  21682. --  ----------------
  21683. --    None.
  21684. --
  21685. -------------------------------------------------------------------
  21686. with Unchecked_Deallocation; 
  21687.  
  21688. separate(Cais)
  21689. package body Direct_Io_Definitions is 
  21690.  
  21691.     use List_Utilities; 
  21692.  
  21693. ---------------------------------  Is_Space  ---------------------------------
  21694. --
  21695. --    Local version of  function from package Character_Set
  21696. --
  21697. -------------------------------------------------------------------------------
  21698.  
  21699.     function Is_Space(Ch : Character) return Boolean is 
  21700.     begin
  21701.         case Ch is 
  21702.             when Ascii.Ht => 
  21703.                 return True; 
  21704.             when Ascii.Lf => 
  21705.                 return True; 
  21706.             when Ascii.Vt => 
  21707.                 return True; 
  21708.             when Ascii.Ff => 
  21709.                 return True; 
  21710.             when Ascii.Cr => 
  21711.                 return True; 
  21712.             when ' ' => 
  21713.                 return True; 
  21714.             when others => 
  21715.                 return False; 
  21716.         end case; 
  21717.     end Is_Space; 
  21718.  
  21719.  
  21720. -------------------------  Last_Non_Space  ------------------------------------
  21721. --
  21722. --    Local version of  function from package Character_Set
  21723. --
  21724. -------------------------------------------------------------------------------
  21725.  
  21726.     function Last_Non_Space(Str : String) return Integer is 
  21727.         Tmp : Integer; 
  21728.     begin
  21729.         Tmp := Str'Last; 
  21730.         for I in reverse Str'range loop
  21731.             exit when not Is_Space(Str(I)); 
  21732.             Tmp := Tmp - 1; 
  21733.         end loop; 
  21734.         return (Tmp); 
  21735.     end Last_Non_Space; 
  21736.  
  21737.  
  21738. ---------------------------------  Free  --------------------------------------
  21739. --
  21740. --    Local procedure for deallocating File_Type
  21741. --
  21742. -------------------------------------------------------------------------------
  21743.  
  21744.     procedure Free is 
  21745.         new Unchecked_Deallocation(File_Rec, File_Type); 
  21746. ----------------------- Initialize ----------------------------
  21747. --
  21748. --  Purpose:
  21749. --  -------
  21750. --    Internal function to allocate file handle.
  21751. --
  21752. --  Parameters:
  21753. --  ----------
  21754. --    FT    (access to) file handle record.
  21755. --
  21756. --  Exceptions:
  21757. --  ----------
  21758. --    None raised.
  21759. --
  21760. --  Notes:
  21761. --  -----
  21762. --    File_Recs are allocated from heap.
  21763. --
  21764. ---------------------------------------------------------------------
  21765.  
  21766.     procedure Initialize(Ft : in out File_Type) is 
  21767.     begin
  21768.         Ft := new File_Rec; 
  21769.     end Initialize; 
  21770.  
  21771. ----------------------- Deallocate ----------------------------
  21772. --
  21773. --  Purpose:
  21774. --  -------
  21775. --    Internal function to deallocate file handle.
  21776. --
  21777. --  Parameters:
  21778. --  ----------
  21779. --    FT    (access to) file handle record.
  21780. --
  21781. --  Exceptions:
  21782. --  ----------
  21783. --    None raised.
  21784. --
  21785. --  Notes:
  21786. --  -----
  21787. --    File_Recs are released to heap via unchecked deallocation.
  21788. --
  21789. ---------------------------------------------------------------------
  21790.  
  21791.     procedure Deallocate(Ft : in out File_Type) is 
  21792.     begin
  21793.         Free(Ft); 
  21794.         null; 
  21795.     end Deallocate; 
  21796.  
  21797. ----------------------- Un_Initialized ----------------------------
  21798. --
  21799. --  Purpose:
  21800. --  -------
  21801. --    Internal function to test whether file has been
  21802. --    initialized.  Returns True if not initialized,
  21803. --    otherwise returns False.
  21804. --
  21805. --  Parameters:
  21806. --  ----------
  21807. --    FT    (access to) file handle record.
  21808. --
  21809. --  Exceptions:
  21810. --  ----------
  21811. --    None raised.
  21812. --
  21813. --  Notes:
  21814. --  -----
  21815. --    Handle is checked for null reference.
  21816. --
  21817. ---------------------------------------------------------------------
  21818.  
  21819.     function Un_Initialized(Ft : File_Type) return Boolean is 
  21820.     begin
  21821.         return (Ft = null); 
  21822.     end Un_Initialized; 
  21823.  
  21824. ----------------------- Assign ----------------------------
  21825. --
  21826. --  Purpose:
  21827. --  -------
  21828. --    Internal procedure to copy one file handle record to
  21829. --    another.
  21830. --
  21831. --  Parameters:
  21832. --  ----------
  21833. --    From    (access to) source file handle record.
  21834. --    To    (access to) target file handle record.
  21835. --
  21836. --  Exceptions:
  21837. --  ----------
  21838. --    None raised.
  21839. --
  21840. --  Notes:
  21841. --  -----
  21842. --    If the target file handle is uninitialized, Assign initializes
  21843. --    it before copying the components of the record.
  21844. --
  21845. ---------------------------------------------------------------------
  21846.  
  21847.     procedure Assign(From : File_Type; 
  21848.                      To   : in out File_Type) is 
  21849.     begin
  21850.         if Un_Initialized(To) then 
  21851.             Initialize(To); 
  21852.         end if; 
  21853.         To.Fd := From.Fd; 
  21854.         To.Shadow_File_Name := From.Shadow_File_Name; 
  21855.         To.Contents_File_Name := From.Contents_File_Name; 
  21856.         To.Intent := From.Intent; 
  21857.         To.Intent_Size := From.Intent_Size; 
  21858.         To.Mode := From.Mode; 
  21859.         To.Name := From.Name; 
  21860.         Copy(To.Form, From.Form); 
  21861.     end Assign; 
  21862. -----------------------  Get_File_Type ----------------------------
  21863. --
  21864. --  Purpose:
  21865. --  -------
  21866. --    Internal function to fetch (access to) the Ada file descriptor 
  21867. --    for the contents file from the CAIS file handle.
  21868. --
  21869. --  Parameters:
  21870. --  ----------
  21871. --    FT    initialized file handle.
  21872. --
  21873. --  Exceptions:
  21874. --  ----------
  21875. --    Status_Error
  21876. --        raised if file handle has not been initialized.
  21877. --
  21878. --  Notes:
  21879. --  -----
  21880. --    The file descriptor is implemented as an Ada Direct_Io.File_Type,
  21881. --    The access value returned is of type Direct_File_Ptr.
  21882. --
  21883. ---------------------------------------------------------------------
  21884.  
  21885.     function Get_File_Type(Ft : File_Type) return Direct_File_Ptr is 
  21886.     begin
  21887.         if Un_Initialized(Ft) then 
  21888.             raise Status_Error; 
  21889.         end if; 
  21890.         return Ft.Fd; 
  21891.     end Get_File_Type; 
  21892.  
  21893. -----------------------  Set_File_Type ----------------------------
  21894. --
  21895. --  Purpose:
  21896. --  -------
  21897. --    Internal procedure to store (access to) an Ada file descriptor 
  21898. --    for the contents file into the CAIS file handle.
  21899. --
  21900. --  Parameters:
  21901. --  ----------
  21902. --    FT    initialized file handle.
  21903. --    DFD    access to the Direct_Io file descriptor.
  21904. --
  21905. --  Exceptions:
  21906. --  ----------
  21907. --    Status_Error
  21908. --        raised if file handle has not been initialized.
  21909. --
  21910. --  Notes:
  21911. --  -----
  21912. --    The file descriptor is implemented as an Ada Direct_Io.File_Type.
  21913. --    The access parameter is of type Direct_File_Ptr.
  21914. --
  21915. ---------------------------------------------------------------------
  21916.  
  21917.     procedure Set_File_Type(Ft  : in out File_Type; 
  21918.                             Dfd : Direct_File_Ptr) is 
  21919.     begin
  21920.         if Un_Initialized(Ft) then 
  21921.             raise Status_Error; 
  21922.         end if; 
  21923.         Ft.Fd := Dfd; 
  21924.     end Set_File_Type; 
  21925.  
  21926. -----------------------  Get_Shadow_File_Name ----------------------------
  21927. --
  21928. --  Purpose:
  21929. --  -------
  21930. --    Internal procedure to fetch the name of the shadow file
  21931. --    from the CAIS file handle.
  21932. --    The file name and its length are returned in parameters
  21933. --    Name and Lastchar, respectively.
  21934. --
  21935. --  Parameters:
  21936. --  ----------
  21937. --    FT      initialized file handle.
  21938. --    Name      name string.
  21939. --    Lastchar  index of last non-blank character in Name.
  21940. --    
  21941. --
  21942. --  Exceptions:
  21943. --  ----------
  21944. --    None raised.
  21945. --
  21946. --  Notes:
  21947. --  -----
  21948. --    The shadow file contains the node image for the
  21949. --    CAIS file node, and its attributes and relationships.
  21950. --
  21951. ---------------------------------------------------------------------
  21952.  
  21953.     procedure Get_Shadow_File_Name(Ft       : File_Type; 
  21954.                                    Name     : in out String; 
  21955.                                    Lastchar : in out Natural) is 
  21956.  
  21957.         Last : Natural; 
  21958.     begin
  21959.         Last := Last_Non_Space(Ft.Shadow_File_Name); 
  21960.         Name(1 .. Last) := Ft.Shadow_File_Name(1 .. Last); 
  21961.         Lastchar := Last; 
  21962.     end Get_Shadow_File_Name; 
  21963.  
  21964. -----------------------  Set_Shadow_File_Name ----------------------------
  21965. --
  21966. --  Purpose:
  21967. --  -------
  21968. --    Internal procedure to store the name of the shadow file
  21969. --    into the CAIS file handle.
  21970. --
  21971. --  Parameters:
  21972. --  ----------
  21973. --    FT      initialized file handle.
  21974. --    Name      name string.
  21975. --    
  21976. --
  21977. --  Exceptions:
  21978. --  ----------
  21979. --    None raised.
  21980. --
  21981. --  Notes:
  21982. --  -----
  21983. --    The shadow file contains the node image for the
  21984. --    CAIS file node, and its attributes and relationships.
  21985. --
  21986. ---------------------------------------------------------------------
  21987.  
  21988.     procedure Set_Shadow_File_Name(Ft   : in out File_Type; 
  21989.                                    Name : String) is 
  21990.  
  21991.         Lastchar : Natural; 
  21992.     begin
  21993.         Lastchar := Last_Non_Space(Name); 
  21994.         Ft.Shadow_File_Name := (others => ' '); 
  21995.         Ft.Shadow_File_Name(1 .. Lastchar) := Name(1 .. Lastchar); 
  21996.     end Set_Shadow_File_Name; 
  21997.  
  21998. -----------------------  Get_Contents_File_Name ----------------------------
  21999. --
  22000. --  Purpose:
  22001. --  -------
  22002. --    Internal procedure to fetch the name of the contents file
  22003. --    from the CAIS file handle.
  22004. --    The file name and its length are returned in parameters
  22005. --    Name and Lastchar, respectively.
  22006. --
  22007. --  Parameters:
  22008. --  ----------
  22009. --    FT      initialized file handle.
  22010. --    Name      name string.
  22011. --    Lastchar  index of last non-blank character in Name.
  22012. --    
  22013. --
  22014. --  Exceptions:
  22015. --  ----------
  22016. --    None raised.
  22017. --
  22018. --  Notes:
  22019. --  -----
  22020. --    The contents file holds the actual file contents for the
  22021. --    CAIS file node.
  22022. --
  22023. ---------------------------------------------------------------------
  22024.  
  22025.     procedure Get_Contents_File_Name(Ft       : File_Type; 
  22026.                                      Name     : in out String; 
  22027.                                      Lastchar : in out Natural) is 
  22028.  
  22029.         Last : Natural; 
  22030.     begin
  22031.         Last := Last_Non_Space(Ft.Contents_File_Name); 
  22032.         Name(1 .. Last) := Ft.Contents_File_Name(1 .. Last); 
  22033.         Lastchar := Last; 
  22034.     end Get_Contents_File_Name; 
  22035.  
  22036. -----------------------  Set_Contents_File_Name ----------------------------
  22037. --
  22038. --  Purpose:
  22039. --  -------
  22040. --    Internal procedure to store the name of the contents file
  22041. --    into the CAIS file handle.
  22042. --
  22043. --  Parameters:
  22044. --  ----------
  22045. --    FT      initialized file handle.
  22046. --    Name      name string.
  22047. --    
  22048. --
  22049. --  Exceptions:
  22050. --  ----------
  22051. --    None raised.
  22052. --
  22053. --  Notes:
  22054. --  -----
  22055. --    The contents file holds the actual file contents for the
  22056. --    CAIS file node.
  22057. --
  22058. ---------------------------------------------------------------------
  22059.  
  22060.     procedure Set_Contents_File_Name(Ft   : in out File_Type; 
  22061.                                      Name : String) is 
  22062.  
  22063.         Lastchar : Natural; 
  22064.     begin
  22065.         Lastchar := Last_Non_Space(Name); 
  22066.         Ft.Contents_File_Name := (others => ' '); 
  22067.         Ft.Contents_File_Name(1 .. Lastchar) := Name(1 .. Lastchar); 
  22068.     end Set_Contents_File_Name; 
  22069.  
  22070. -----------------------  Get_Intent ----------------------------
  22071. --
  22072. --  Purpose:
  22073. --  -------
  22074. --    Internal procedure to fetch the intention of the node handle,
  22075. --    from the CAIS file handle.
  22076. --
  22077. --  Parameters:
  22078. --  ----------
  22079. --    FT      initialized file handle.
  22080. --    Intent      intention array.
  22081. --    
  22082. --
  22083. --  Exceptions:
  22084. --  ----------
  22085. --    None raised.
  22086. --
  22087. --  Notes:
  22088. --  -----
  22089. --    The intention returned is the intention with which the node
  22090. --    handle was opened to the file node.  When the file handle is
  22091. --    opened via the node handle, the intention is copied to the 
  22092. --    file handle.
  22093. --
  22094. ---------------------------------------------------------------------
  22095.  
  22096.     procedure Get_Intent(Ft     : File_Type; 
  22097.                          Intent : in out Intention) is 
  22098.     begin
  22099.         Intent := Ft.Intent(1 .. Ft.Intent_Size); 
  22100.     end Get_Intent; 
  22101.  
  22102. -----------------------  Set_Intent ----------------------------
  22103. --
  22104. --  Purpose:
  22105. --  -------
  22106. --    Internal procedure to store the intention of the node handle,
  22107. --    into the CAIS file handle.
  22108. --
  22109. --  Parameters:
  22110. --  ----------
  22111. --    FT      initialized file handle.
  22112. --    Intent      intention array.
  22113. --    
  22114. --
  22115. --  Exceptions:
  22116. --  ----------
  22117. --    None raised.
  22118. --
  22119. --  Notes:
  22120. --  -----
  22121. --    The intention to be stored is the intention with which the node
  22122. --    handle was opened to the file node.  When the file handle is
  22123. --    opened via the node handle, the intention is copied to the 
  22124. --    file handle.
  22125. --
  22126. ---------------------------------------------------------------------
  22127.  
  22128.     procedure Set_Intent(Ft     : in out File_Type; 
  22129.                          Intent : Intention) is 
  22130.     begin
  22131.         Ft.Intent(Intent'range ) := Intent; 
  22132.         Ft.Intent_Size := Intent'Last; 
  22133.     end Set_Intent; 
  22134.  
  22135. -----------------------  Get_Mode ----------------------------
  22136. --
  22137. --  Purpose:
  22138. --  -------
  22139. --    Internal procedure to fetch the file mode
  22140. --    from the CAIS file handle.
  22141. --
  22142. --  Parameters:
  22143. --  ----------
  22144. --    FT      initialized file handle.
  22145. --    Mode      file mode.
  22146. --    
  22147. --
  22148. --  Exceptions:
  22149. --  ----------
  22150. --    None raised.
  22151. --
  22152. --  Notes:
  22153. --  -----
  22154. --    The mode returned is the mode with which the file handle
  22155. --    was opened.
  22156. --
  22157. ---------------------------------------------------------------------
  22158.  
  22159.     procedure Get_Mode(Ft   : File_Type; 
  22160.                        Mode : in out File_Mode) is 
  22161.     begin
  22162.         Mode := Ft.Mode; 
  22163.     end Get_Mode; 
  22164.  
  22165. -----------------------  Set_Mode ----------------------------
  22166. --
  22167. --  Purpose:
  22168. --  -------
  22169. --    Internal procedure to store the file mode
  22170. --    into the CAIS file handle.
  22171. --
  22172. --  Parameters:
  22173. --  ----------
  22174. --    FT      initialized file handle.
  22175. --    Mode      file mode.
  22176. --    
  22177. --
  22178. --  Exceptions:
  22179. --  ----------
  22180. --    None raised.
  22181. --
  22182. --  Notes:
  22183. --  -----
  22184. --    The mode to be stored is the mode with which the file handle
  22185. --    is being opened (or reset).
  22186. --
  22187. ---------------------------------------------------------------------
  22188.  
  22189.     procedure Set_Mode(Ft   : in out File_Type; 
  22190.                        Mode : File_Mode) is 
  22191.     begin
  22192.         Ft.Mode := Mode; 
  22193.     end Set_Mode; 
  22194.  
  22195. -----------------------  Get_Name ----------------------------
  22196. --
  22197. --  Purpose:
  22198. --  -------
  22199. --    Internal procedure to fetch the pathname of the file node 
  22200. --    from the CAIS file handle.
  22201. --
  22202. --  Parameters:
  22203. --  ----------
  22204. --    FT      initialized file handle.
  22205. --    Name      name string.
  22206. --    Lastchar  index of last non-blank character in Name.
  22207. --    
  22208. --
  22209. --  Exceptions:
  22210. --  ----------
  22211. --    None raised.
  22212. --
  22213. --  Notes:
  22214. --  -----
  22215. --    The pathname returned is the pathname from the node handle
  22216. --    through which the file handle was opened.
  22217. --
  22218. ---------------------------------------------------------------------
  22219.  
  22220.     procedure Get_Name(Ft       : File_Type; 
  22221.                        Name     : in out String; 
  22222.                        Lastchar : in out Natural) is 
  22223.  
  22224.         Last : Natural; 
  22225.     begin
  22226.         Last := Last_Non_Space(Ft.Name); 
  22227.         Name(1 .. Last) := Ft.Name(1 .. Last); 
  22228.         Lastchar := Last; 
  22229.     end Get_Name; 
  22230.  
  22231. -----------------------  Set_Name ----------------------------
  22232. --
  22233. --  Purpose:
  22234. --  -------
  22235. --    Internal procedure to store the pathname of the file node 
  22236. --    into the CAIS file handle.
  22237. --
  22238. --  Parameters:
  22239. --  ----------
  22240. --    FT      initialized file handle.
  22241. --    Name      name string.
  22242. --    
  22243. --
  22244. --  Exceptions:
  22245. --  ----------
  22246. --    None raised.
  22247. --
  22248. --  Notes:
  22249. --  -----
  22250. --    The pathname to be stored is the pathname from the node handle
  22251. --    through which the file handle is being opened.
  22252. --
  22253. ---------------------------------------------------------------------
  22254.  
  22255.     procedure Set_Name(Ft   : in out File_Type; 
  22256.                        Name : String) is 
  22257.  
  22258.         Lastchar : Natural; 
  22259.     begin
  22260.         Lastchar := Last_Non_Space(Name); 
  22261.         Ft.Name := (others => ' '); 
  22262.         Ft.Name(1 .. Lastchar) := Name(1 .. Lastchar); 
  22263.     end Set_Name; 
  22264.  
  22265. -----------------------  Get_Form ----------------------------
  22266. --
  22267. --  Purpose:
  22268. --  -------
  22269. --    Internal function which returns the form list of the file node 
  22270. --    from the CAIS file handle.
  22271. --
  22272. --  Parameters:
  22273. --  ----------
  22274. --    FT      initialized file handle.
  22275. --    
  22276. --
  22277. --  Exceptions:
  22278. --  ----------
  22279. --    None raised.
  22280. --
  22281. --  Notes:
  22282. --  -----
  22283. --    Conversion between form strings for external files and the
  22284. --    CAIS form is not implemented in the prototype.
  22285. --
  22286. ---------------------------------------------------------------------
  22287.  
  22288.     function Get_Form(Ft : File_Type) return List_Type is 
  22289.     begin
  22290.         return Ft.Form; 
  22291.     end Get_Form; 
  22292.  
  22293. -----------------------  Set_Form ----------------------------
  22294. --
  22295. --  Purpose:
  22296. --  -------
  22297. --    Internal procedure which stores the form list of the file node 
  22298. --    into the CAIS file handle.
  22299. --
  22300. --  Parameters:
  22301. --  ----------
  22302. --    FT      initialized file handle.
  22303. --    Form      list of form entries.
  22304. --    
  22305. --
  22306. --  Exceptions:
  22307. --  ----------
  22308. --    None raised.
  22309. --
  22310. --  Notes:
  22311. --  -----
  22312. --    Conversion between form strings for external files and the
  22313. --    CAIS form is not implemented in the prototype.
  22314. --
  22315. ---------------------------------------------------------------------
  22316.  
  22317.     procedure Set_Form(Ft   : in out File_Type; 
  22318.                        Form : List_Type) is 
  22319.     begin
  22320.         Copy(Ft.Form, Form); 
  22321.     end Set_Form; 
  22322.  
  22323. ---------------------------------------------------------------------
  22324. end Direct_Io_Definitions; 
  22325. ---------------------------------------------------------------------
  22326. --::::::::::::::
  22327. --dump.a
  22328. --::::::::::::::
  22329.  
  22330.  
  22331. ----------------------------------------------------------------------
  22332. --                             D U M P
  22333. --           (Separate Procedure from Package List_Utilities)
  22334. --
  22335. --          Prints the values of components internal to a list
  22336. --
  22337. --
  22338. --                  Ada Software Engineering Group
  22339. --                      The MITRE Corporation
  22340. --                         McLean, VA 22102
  22341. --
  22342. --
  22343. --                   Wed Oct  9 13:23:55 EDT 1985
  22344. --
  22345. --                 (Unclassified and uncopyrighted)
  22346. --
  22347. ----------------------------------------------------------------------
  22348. ----------------------       D U M P       --------------------------
  22349. --
  22350. --  Purpose:
  22351. --  -------
  22352. --    This procedure is a debugging aid.  It simply prints the text for
  22353. --    each item in a list.
  22354. --
  22355. --  Parameters:
  22356. --  ----------
  22357. --    List    The object of List_Type to be dumped.
  22358. --
  22359. --  Exceptions:
  22360. --  ----------
  22361. --    None
  22362. --
  22363. --  Notes:
  22364. --  -----
  22365. --
  22366. ---------------------------------------------------------------------
  22367.  
  22368. separate(Cais.List_Utilities)
  22369. procedure Dump(List : in List_Type) is 
  22370.  
  22371.     use Standard.Text_Io; 
  22372.  
  22373.     Current : List_Type := List; 
  22374.     Blank   : constant String(1 .. 15) := "               "; 
  22375.     function Slength(S : String) return Natural is 
  22376.     begin
  22377.         return S'Length; 
  22378.     end Slength; 
  22379. begin
  22380.     while Current /= null loop
  22381.         New_Line; 
  22382.         Put(Item_Kind'Image(Current.Kind)); 
  22383.         Put(Blank(1 .. 15 - Slength(Item_Kind'Image(Current.Kind))));  --!
  22384. --! not allowed by current version of VADS:
  22385. --!    put(BLANK(1..15-Item_Kind'image(Current.Kind)'length));
  22386. --!------------------------^A                                              ###
  22387. --!--### A:error: LRM 4.1: prefix must be a name or function call
  22388.  
  22389.         if Current.Name /= null then 
  22390.             Put(Retrieve(Current.Name)); 
  22391.             Put(Blank(1 .. 15 - Length(Current.Name))); 
  22392.         else 
  22393.             Put(Blank(1 .. 15)); 
  22394.         end if; 
  22395.  
  22396.         if Current.Kind = List_Item then 
  22397.             Put("*****"); 
  22398.             Dump(Current.List); 
  22399.             Put_Line("*****END OF LIST****"); 
  22400.         else 
  22401.             Put(Retrieve(Current.Element)); 
  22402.             Put(Blank(1 .. 15 - Length(Current.Element))); 
  22403.         end if; 
  22404.  
  22405.         Current := Current.Next_Item; 
  22406.     end loop; 
  22407.     New_Line; 
  22408. end Dump; 
  22409. --::::::::::::::
  22410. --file_import_export_body.a
  22411. --::::::::::::::
  22412.  
  22413.  
  22414. ----------------------------------------------------------------------
  22415. --          Package  F I L E _ I M P O R T _ E X P O R T
  22416. --            (Package Body)
  22417. --
  22418. --        Operations to Transfer Files Between
  22419. --          the CAIS and Host Environments
  22420. --
  22421. --
  22422. --
  22423. --                  Ada Software Engineering Group
  22424. --                      The MITRE Corporation
  22425. --                         McLean, VA 22102
  22426. --
  22427. --
  22428. --             Wed Oct  9 13:33:54 EDT 1985
  22429. --
  22430. --                 (Unclassified and uncopyrighted)
  22431. --
  22432. ----------------------------------------------------------------------
  22433. ----------------------------------------------------------------------
  22434. --               F I L E _ I M P O R T _ E X P O R T
  22435. --
  22436. --  Purpose:
  22437. --  -------
  22438. --        The CAIS allows a particular CAIS implementation to
  22439. --        maintain files separately from files maintained by
  22440. --        the host file system.  This package provides the
  22441. --        capability to transfer files between these two systems.
  22442. --
  22443. --  Usage:
  22444. --  -----
  22445. --        The operations contained in this package are
  22446. --        Import which transfers a file from the host file 
  22447. --        system into a CAIS file node, and Export which 
  22448. --        transfers the contents of a CAIS file node to a 
  22449. --        host file.
  22450. --
  22451. --  Notes:
  22452. --  -----
  22453. --        This is a version of the package CAIS.FILE_IMPORT_EXPORT, 
  22454. --        specified in MIL-STD-CAIS section 5.3.10; all references 
  22455. --        to the CAIS specification refer to the CAIS specification
  22456. --        dated 31 January 1985.
  22457. --
  22458. --  Revision History:
  22459. --  ----------------
  22460. --        None.
  22461. --
  22462. -------------------------------------------------------------------
  22463.  
  22464.  
  22465. with Sequential_Io; 
  22466.  
  22467. separate(Cais)
  22468. package body File_Import_Export is 
  22469.  
  22470.     use Node_Management; 
  22471.     use Node_Definitions; 
  22472.     use Node_Representation; 
  22473.     use Cais.Io_Definitions; 
  22474.  
  22475. ----------------------     Import     ----------------------
  22476. --
  22477. --  Purpose:
  22478. --  -------
  22479. --    This procedure searches for a file in the host file system
  22480. --    named Host_File_Name and copies its contents into a CAIS
  22481. --    file which is the contents of the node identified by Node.
  22482. --
  22483. --  Parameters:
  22484. --  ----------
  22485. --    Node        open node handle on the file node.
  22486. --    Host_File_Name    name of the host file to be copied.
  22487. --
  22488. --  Exceptions:
  22489. --  ----------
  22490. --    Name_Error
  22491. --        raised if the node identified by Node is inaccessible.
  22492. --    Use_Error
  22493. --        raised if Host_File_Name noes not adhere to the
  22494. --        required syntax for file names in the host file system
  22495. --        or if Host_File_Name does not exist in the host file
  22496. --        system.
  22497. --
  22498. --        also raised if File is not the value of the attribute
  22499. --        Kind of the node identified by Node.
  22500. --    Status_Error
  22501. --        raised if Node is not an open node handle.
  22502. --    Intent_Violation
  22503. --        raised if Node was not opened with an intent establishing
  22504. --        the right to write contents.
  22505. --    Security_Violation
  22506. --        raised if the operation represents a violation of mandatory
  22507. --        access controls.  Security_Violation is raised only if the
  22508. --        conditions for other exceptions are not present.
  22509. --
  22510. --  Notes:
  22511. --  -----
  22512. --    Semantics are defined in cais_MIL-STD Section 5.3.10.1
  22513. --
  22514. ---------------------------------------------------------------------
  22515.  
  22516.     procedure Import(Node           : in out Node_Type; 
  22517.                      Host_File_Name : in String)
  22518.  
  22519.     is 
  22520.         package Byte_Io is 
  22521.             new Standard.Sequential_Io(Tiny_Integer); 
  22522.  
  22523.         Contents_File_Name : Name_String(1 .. Pragmatics.Max_Name_String); 
  22524.         Length             : Natural; 
  22525.         Host_File          : Byte_Io.File_Type; 
  22526.         Contents_File      : Byte_Io.File_Type; 
  22527.         Byte               : Tiny_Integer; 
  22528.  
  22529.     begin
  22530.         if not Node_Management.Is_Open(Node) then 
  22531.             raise Node_Definitions.Status_Error; 
  22532.         --elsif not Node_Management.Is_Obtainable(Node) then
  22533.             --raise Name_Error;
  22534.         end if; 
  22535.  
  22536.         Get_Contents_File_Name(Node, Contents_File_Name, Length); 
  22537.  
  22538.         Byte_Io.Open(Host_File, Byte_Io.In_File, Host_File_Name); 
  22539.         Byte_Io.Open(Contents_File, Byte_Io.Out_File, Contents_File_Name(1 .. 
  22540.             Length)); 
  22541.  
  22542.         begin
  22543.             loop
  22544.                 Byte_Io.Read(Host_File, Byte); 
  22545.                 Byte_Io.Write(Contents_File, Byte); 
  22546.             end loop; 
  22547.         exception
  22548.             when End_Error => 
  22549.                 Byte_Io.Close(Host_File); 
  22550.                 Byte_Io.Close(Contents_File); 
  22551.             when others => 
  22552.                 raise; 
  22553.         end; 
  22554.     exception
  22555.         -- exceptions that are trapped (nothing propagated)
  22556.         --    End_Error
  22557.         -- exceptions that are propagated
  22558.         when Cais.Io_Definitions.Name_Error | Cais.Io_Definitions.Use_Error | 
  22559.             Cais.Io_Definitions.Status_Error | Cais.Io_Definitions.Mode_Error | 
  22560.             Cais.Io_Definitions.Device_Error | Cais.Io_Definitions.End_Error | 
  22561.             Cais.Io_Definitions.Data_Error | Cais.Io_Definitions.Layout_Error | 
  22562.             Node_Definitions.Name_Error | Node_Definitions.Use_Error | 
  22563.             Node_Definitions.Status_Error | Node_Definitions.Lock_Error | 
  22564.             Node_Definitions.Intent_Violation | Node_Definitions.
  22565.             Access_Violation | Node_Definitions.Security_Violation => 
  22566.             raise; 
  22567.  
  22568.  
  22569.         -- exceptions that are mapped to other exceptions
  22570.         -- predefined exceptions (propagated with trace)
  22571.         when Constraint_Error | Tasking_Error | Program_Error | Storage_Error | 
  22572.             Numeric_Error => 
  22573.             Trace.Report("PREDEFINED EXCEPTION in File_Import_Export.Import "); 
  22574.             raise; 
  22575.         -- unanticipated exceptions
  22576.         when others => 
  22577.             Trace.Report("UNANTICIPATED EXCEPTION in File_Import_Export.Import "
  22578.                 ); 
  22579.             raise Trace.Assertion_Violation; 
  22580.     end Import; 
  22581.  
  22582. -------------------------------------------------------------------------------
  22583. --
  22584. --    Alternate interface using Name (pathname) rather than Base, Relation,
  22585. --    and Key to refer to file node.
  22586. --
  22587. -------------------------------------------------------------------------------
  22588.  
  22589.     procedure Import(Name           : in Node_Definitions.Name_String; 
  22590.                      Host_File_Name : in String) is 
  22591.         Node : Node_Type; 
  22592.     begin
  22593.         Node_Management.Open(Node, Name, (1 => Write_Contents)); 
  22594.         Import(Node, Host_File_Name); 
  22595.         Node_Management.Close(Node); 
  22596.     exception
  22597.         when others => 
  22598.             Node_Management.Close(Node); 
  22599.             raise; 
  22600.     end Import; 
  22601.  
  22602. ----------------------     Export     ----------------------
  22603. --
  22604. --  Purpose:
  22605. --  -------
  22606. --    This procedure creates a new file named Host_File_Name in
  22607. --    the host file system and copies the contents of the file
  22608. --    node identified by Node into it.
  22609. --
  22610. --  Parameters:
  22611. --  ----------
  22612. --    Node        open node handle on the file node.
  22613. --    Host_File_Name    name of the host file to be created.
  22614. --
  22615. --  Exceptions:
  22616. --  ----------
  22617. --    Name_Error
  22618. --        raised if the node identified by Node is inaccessible.
  22619. --    Use_Error
  22620. --        raised if Host_File_Name noes not adhere to the
  22621. --        required syntax for file names in the host file system
  22622. --        or if Host_File_Name cannot be created in the host file
  22623. --        system.
  22624. --
  22625. --        also raised if File is not the value of the attribute
  22626. --        Kind of the node identified by Node.
  22627. --    Status_Error
  22628. --        raised if Node is not an open node handle.
  22629. --    Intent_Violation
  22630. --        raised if Node was not opened with an intent establishing
  22631. --        the right to read contents.
  22632. --
  22633. --  Notes:
  22634. --  -----
  22635. --    Semantics are defined in cais_MIL-STD Section 5.3.10.2
  22636. --
  22637. ---------------------------------------------------------------------
  22638.  
  22639.     procedure Export(Node           : in out Node_Type; 
  22640.                      Host_File_Name : in String)
  22641.  
  22642.     is 
  22643.         package Byte_Io is 
  22644.             new Standard.Sequential_Io(Tiny_Integer); 
  22645.  
  22646.         Contents_File_Name : Name_String(1 .. Pragmatics.Max_Name_String); 
  22647.         Length             : Natural; 
  22648.         Host_File          : Byte_Io.File_Type; 
  22649.         Contents_File      : Byte_Io.File_Type; 
  22650.         Byte               : Tiny_Integer; 
  22651.  
  22652.     begin
  22653.         if not Node_Management.Is_Open(Node) then 
  22654.             raise Node_Definitions.Status_Error; 
  22655.         end if; 
  22656.  
  22657.         Get_Contents_File_Name(Node, Contents_File_Name, Length); 
  22658.  
  22659.         Byte_Io.Create(Host_File, Byte_Io.Out_File, Host_File_Name); 
  22660.         Byte_Io.Open(Contents_File, Byte_Io.In_File, Contents_File_Name(1 .. 
  22661.             Length)); 
  22662.  
  22663.         begin
  22664.             loop
  22665.                 Byte_Io.Read(Contents_File, Byte); 
  22666.                 Byte_Io.Write(Host_File, Byte); 
  22667.             end loop; 
  22668.         exception
  22669.             when End_Error => 
  22670.                 Byte_Io.Close(Host_File); 
  22671.                 Byte_Io.Close(Contents_File); 
  22672.             when others => 
  22673.                 raise; 
  22674.         end; 
  22675.  
  22676.     exception
  22677.     -- exceptions that are trapped (nothing propagated)
  22678.     -- exceptions that are propagated
  22679.         when Cais.Io_Definitions.Name_Error | Cais.Io_Definitions.Use_Error | 
  22680.             Cais.Io_Definitions.Status_Error | Cais.Io_Definitions.Mode_Error | 
  22681.             Cais.Io_Definitions.Device_Error | Cais.Io_Definitions.End_Error | 
  22682.             Cais.Io_Definitions.Data_Error | Cais.Io_Definitions.Layout_Error | 
  22683.             Node_Definitions.Name_Error | Node_Definitions.Use_Error | 
  22684.             Node_Definitions.Status_Error | Node_Definitions.Lock_Error | 
  22685.             Node_Definitions.Intent_Violation | Node_Definitions.
  22686.             Access_Violation | Node_Definitions.Security_Violation => 
  22687.             raise; 
  22688.  
  22689.     -- exceptions that are mapped to other exceptions
  22690.     -- predefined exceptions (propagated with trace)
  22691.         when Constraint_Error | Tasking_Error | Program_Error | Storage_Error | 
  22692.             Numeric_Error => 
  22693.             Trace.Report("PREDEFINED EXCEPTION in File_Import_Export.Export "); 
  22694.             raise; 
  22695.     -- unanticipated exceptions
  22696.         when others => 
  22697.             Trace.Report("UNANTICIPATED EXCEPTION in File_Import_Export.Export "
  22698.                 ); 
  22699.             raise Trace.Assertion_Violation; 
  22700.  
  22701.     end Export; 
  22702.  
  22703. -------------------------------------------------------------------------------
  22704. --
  22705. --    Alternate interface using Name (pathname) rather than Base, Relation,
  22706. --    and Key to refer to file node.
  22707. --
  22708. -------------------------------------------------------------------------------
  22709.  
  22710.     procedure Export(Name           : in Node_Definitions.Name_String; 
  22711.                      Host_File_Name : in String) is 
  22712.         Node : Node_Type; 
  22713.     begin
  22714.         Node_Management.Open(Node, Name, (1 => Read_Contents)); 
  22715.         Export(Node, Host_File_Name); 
  22716.         Node_Management.Close(Node); 
  22717.     exception
  22718.         when others => 
  22719.             Node_Management.Close(Node); 
  22720.             raise; 
  22721.     end Export; 
  22722.  
  22723.  
  22724. -----------------------------------------------------------------------
  22725. end File_Import_Export; 
  22726. -----------------------------------------------------------------------
  22727. --::::::::::::::
  22728. --form_terminal_body.a
  22729. --::::::::::::::
  22730. separate(Cais)
  22731. package body Form_Terminal is 
  22732.     use Node_Definitions; 
  22733.     use Io_Definitions; 
  22734.     use Io_Control; 
  22735.  
  22736.     function Maximum_Function_Key(Terminal : File_Type) return Natural is 
  22737.     begin
  22738.         Trace.Assert_Fatal(False, "Maximum_Function_Key is NOT implemented"); 
  22739.         return 0; 
  22740.     end Maximum_Function_Key; 
  22741.  
  22742.     function Maximum_Function_Key return Natural is 
  22743.     begin
  22744.         Trace.Assert_Fatal(False, "Maximum_Function_Key is NOT implemented"); 
  22745.         return 0; 
  22746.     end Maximum_Function_Key; 
  22747.  
  22748.     procedure Define_Qualified_Area(Form       : in out Form_Type; 
  22749.                                     Intensity  : Area_Intensity := Normal; 
  22750.                                     Protection : Area_Protection := Protected; 
  22751.                                     Input      : Area_Input := 
  22752.                                         Graphic_Characters; 
  22753.                                     Value      : Area_Value := No_Fill) is 
  22754.     begin
  22755.         Trace.Assert_Fatal(False, "Define_Qualified_Area is NOT implemented"); 
  22756.     end Define_Qualified_Area; 
  22757.  
  22758.     procedure Remove_Area_Qualifier(Form : in out Form_Type) is 
  22759.     begin
  22760.         Trace.Assert_Fatal(False, "Remove_Area_Qualifier is NOT implemented"); 
  22761.     end Remove_Area_Qualifier; 
  22762.  
  22763.     procedure Set_Position(Form     : in out Form_Type; 
  22764.                            Position : Position_Type) is 
  22765.     begin
  22766.         Trace.Assert_Fatal(False, "Set_Position is NOT implemented"); 
  22767.     end Set_Position; 
  22768.  
  22769.     procedure Next_Qualified_Area(Form  : in out Form_Type; 
  22770.                                   Count : Positive := 1) is 
  22771.     begin
  22772.         Trace.Assert_Fatal(False, "Next_Qualified_Area is NOT implemented"); 
  22773.     end Next_Qualified_Area; 
  22774.  
  22775.     procedure Put(Form : in out Form_Type; 
  22776.                   Item : Printable_Character) is 
  22777.     begin
  22778.         Trace.Assert_Fatal(False, "Put is NOT implemented"); 
  22779.     end Put; 
  22780.  
  22781.     procedure Put(Form : in out Form_Type; 
  22782.                   Item : String) is 
  22783.     begin
  22784.         Trace.Assert_Fatal(False, "Put is NOT implemented"); 
  22785.     end Put; 
  22786.  
  22787.     procedure Erase_Area(Form : in out Form_Type) is 
  22788.     begin
  22789.         Trace.Assert_Fatal(False, "Erase_Area is NOT implemented"); 
  22790.     end Erase_Area; 
  22791.  
  22792.     procedure Erase_Form(Form : in out Form_Type) is 
  22793.     begin
  22794.         Trace.Assert_Fatal(False, "Erase_Form is NOT implemented"); 
  22795.     end Erase_Form; 
  22796.  
  22797.     procedure Activate(Terminal : File_Type; 
  22798.                        Form     : in out Form_Type) is 
  22799.     begin
  22800.         Trace.Assert_Fatal(False, "Activate is NOT implemented"); 
  22801.     end Activate; 
  22802.  
  22803.     procedure Get(Form : in out Form_Type; 
  22804.                   Item : in out Printable_Character) is 
  22805.     begin
  22806.         Trace.Assert_Fatal(False, "Get is NOT implemented"); 
  22807.     end Get; 
  22808.  
  22809.     procedure Get(Form : in out Form_Type; 
  22810.                   Item : in out String) is 
  22811.     begin
  22812.         Trace.Assert_Fatal(False, "Get is NOT implemented"); 
  22813.     end Get; 
  22814.  
  22815.     function Is_Form_Updated(Form : Form_Type) return Boolean is 
  22816.     begin
  22817.         Trace.Assert_Fatal(False, "Is_Form_Updated is NOT implemented"); 
  22818.         return False; 
  22819.     end Is_Form_Updated; 
  22820.  
  22821.     function Termination_Key(Form : Form_Type) return Natural is 
  22822.     begin
  22823.         Trace.Assert_Fatal(False, "Termination_Key is NOT implemented"); 
  22824.         return 0; 
  22825.     end Termination_Key; 
  22826.  
  22827.     function Form_Size(Form : Form_Type) return Position_Type is 
  22828.     begin
  22829.         Trace.Assert_Fatal(False, "Form_Size is NOT implemented"); 
  22830.         return (Row => 0, Column => 0); 
  22831.     end Form_Size; 
  22832.  
  22833.     function Terminal_Size(Terminal : File_Type) return Position_Type is 
  22834.     begin
  22835.         Trace.Assert_Fatal(False, "Terminal_Size is NOT implemented"); 
  22836.         return (Row => 0, Column => 0); 
  22837.     end Terminal_Size; 
  22838.  
  22839.     function Terminal_Size return Position_Type is 
  22840.     begin
  22841.         Trace.Assert_Fatal(False, "Terminal_Size is NOT implemented"); 
  22842.         return (Row => 0, Column => 0); 
  22843.     end Terminal_Size; 
  22844.  
  22845.     function Area_Qualifier_Requires_Space(Form : Form_Type) return Boolean is 
  22846.     begin
  22847.         Trace.Assert_Fatal(False, 
  22848.             "Area_Qualifier_Requires_Space  is NOT implemented"); 
  22849.         return False; 
  22850.     end Area_Qualifier_Requires_Space; 
  22851.  
  22852.     function Area_Qualifier_Requires_Space(Terminal : File_Type) return Boolean
  22853.         is 
  22854.     begin
  22855.         Trace.Assert_Fatal(False, 
  22856.             "Area_Qualifier_Requires_Space  is NOT implemented"); 
  22857.         return False; 
  22858.     end Area_Qualifier_Requires_Space; 
  22859.  
  22860.     function Area_Qualifier_Requires_Space return Boolean is 
  22861.     begin
  22862.         Trace.Assert_Fatal(False, 
  22863.             "Area_Qualifier_Requires_Space  is NOT implemented"); 
  22864.         return False; 
  22865.     end Area_Qualifier_Requires_Space; 
  22866.  
  22867.  
  22868. end Form_Terminal; 
  22869. --::::::::::::::
  22870. --generic_list.a
  22871. --::::::::::::::
  22872.  
  22873. -------- SIMTEL20 Ada Software Repository Prologue ------------
  22874. --                                                           -*
  22875. -- Unit name    : generic package LINKED_LIST
  22876. -- Version      : 1.0
  22877. -- Author       : Richard Conn
  22878. --              : Texas Instruments
  22879. --              : PO Box 801, Mail Stop 8007
  22880. --              : McKinney, TX  75069
  22881. -- DDN Address  : RCONN@SIMTEL20
  22882. -- Copyright    : (c) 1984 Richard Conn
  22883. -- Date created :  OCTOBER 2, 1984
  22884. -- Release date :  NOVEMBER 29, 1984
  22885. -- Last update  :  CONN NOVEMBER 29, 1984
  22886. --                                                           -*
  22887. ---------------------------------------------------------------
  22888. --                                                           -*
  22889. -- Keywords     :  DOUBLY-LINKED LIST
  22890. ----------------:  LIST MANIPULATION
  22891. --
  22892. -- Abstract     :  This package provides a number of routines
  22893. ----------------:  which can be used to manipulate a doubly-
  22894. ----------------:  linked list.  See the visible section for
  22895. ----------------:  a rather complete set of documentation on
  22896. ----------------:  the routines.
  22897. ----------------:  
  22898. ----------------:  Each element of the list is of the following
  22899. ----------------:  structure:
  22900. ----------------:     RECORD
  22901. ----------------:      contents: element_object;  -- data
  22902. ----------------:      next:     element_pointer; -- ptr
  22903. ----------------:    previous: element_pointer; -- ptr
  22904. ----------------:     END RECORD;
  22905. ----------------:
  22906. --                                                           -*
  22907. ------------------ Revision history ---------------------------
  22908. --                                                           -*
  22909. -- DATE         VERSION    AUTHOR                  HISTORY
  22910. -- 11/29/84       1.0    Richard Conn        Initial Release
  22911. --                                                           -*
  22912. ------------------ Distribution and Copyright -----------------
  22913. --                                                           -*
  22914. -- This prologue must be included in all copies of this software.
  22915. --
  22916. -- This software is copyright by the author.
  22917. --
  22918. -- This software is released to the Ada community.
  22919. -- This software is released to the Public Domain (note:
  22920. --   software released to the Public Domain is not subject
  22921. --   to copyright protection).
  22922. -- Restrictions on use or distribution:  NONE
  22923. --                                                           -*
  22924. ------------------ Disclaimer ---------------------------------
  22925. --                                                           -*
  22926. -- This software and its documentation are provided "AS IS" and
  22927. -- without any expressed or implied warranties whatsoever.
  22928. -- No warranties as to performance, merchantability, or fitness
  22929. -- for a particular purpose exist.
  22930. --
  22931. -- Because of the diversity of conditions and hardware under
  22932. -- which this software may be used, no warranty of fitness for
  22933. -- a particular purpose is offered.  The user is advised to
  22934. -- test the software thoroughly before relying on it.  The user
  22935. -- must assume the entire risk and liability of using this
  22936. -- software.
  22937. --
  22938. -- In no event shall any person or organization of people be
  22939. -- held responsible for any direct, indirect, consequential
  22940. -- or inconsequential damages or lost profits.
  22941. --                                                           -*
  22942. -------------------END-PROLOGUE--------------------------------
  22943.  
  22944. -- 
  22945. -- Generic Package to Handle Doubly-Linked Lists
  22946. --    by Richard Conn, TI Ada Technology Branch
  22947. -- 
  22948. -- The purpose of this package is to provide a software component
  22949. -- which can be generically instantiated to handle any type of
  22950. -- doubly-linked list.  The set of routines provided in this package
  22951. -- are general-purpose in nature and manipulate the elements of a
  22952. -- doubly-linked list without regard to their contents.  Each element
  22953. -- of the list is of the following structure:
  22954. -- 
  22955. --    record
  22956. --      content  : element_object;  -- the data in the list element
  22957. --      next     : element_pointer; -- pointer to the next element
  22958. --      previous : element_pointer; -- pointer to the previous element
  22959. --    end record;
  22960. -- 
  22961.  
  22962. with Unchecked_Deallocation;
  22963. generic
  22964.     type element_object is private;
  22965.  
  22966.  
  22967. package generic_list is
  22968.  
  22969. -- 
  22970. -- The following type declarations are used throughout is package
  22971. -- and are needed by the programs which WITH this package.
  22972. -- 
  22973.  
  22974.     type list_element;
  22975.     type element_pointer is access list_element;
  22976.     type list_element is
  22977.         record
  22978.             content  : element_object; -- the generic object
  22979.             next     : element_pointer;
  22980.             previous : element_pointer;
  22981.         end record;
  22982.  
  22983.     type Element_Rec is record             -- CCH 2 April 85
  22984.     First_Element   : Element_Pointer;
  22985.     Last_Element    : Element_Pointer;
  22986.     Current_Element : Element_Pointer;
  22987.     end record;
  22988.  
  22989.     type List is access Element_Rec;       -- CCH 2 April 85
  22990.  
  22991.  
  22992. -- 
  22993. -- The following procedures and functions initialize the list and
  22994. -- return pointers to the three list elements which are continuously
  22995. -- tracked by the routines in this package.  These list elements
  22996. -- are:
  22997. -- 
  22998. --    first_element       the first element in the list
  22999. --    last_element        the last element in the list
  23000. --    current_element     the current element in the list
  23001. -- 
  23002.  
  23003.     procedure initialize_list (L : out List);
  23004.     function  return_first_element (L : List)   return element_pointer;
  23005.     function  return_last_element  (L : List)   return element_pointer;
  23006.     function  return_current_element (L : List) return element_pointer;
  23007.     function  return_first_element (L : List)   return element_object;
  23008.     function  return_last_element (L : List)    return element_object;
  23009.     function  return_current_element (L : List) return element_object;
  23010.  
  23011. -- 
  23012. -- The following procedures and functions manipulate the current
  23013. -- element pointer.  The following table outlines their functions:
  23014. -- 
  23015. --    set_first           the first element becomes the current element
  23016. --    set_last            the last element becomes the current element
  23017. --    current_index       return the number of the current element
  23018. --                          (ordinal); 0 returned if list is empty
  23019. --    current_next        set current element to next element in the
  23020. --                          list; return TRUE if done or FALSE if
  23021. --                          already at end of list
  23022. --    current_previous    set current element to previous element in the
  23023. --                          list; return TRUE if done or FALSE if
  23024. --                          already at front of list
  23025. --    set_current_index   set the Nth element as the current element;
  23026. --                          return TRUE if done or FALSE if end of list
  23027. --                          encountered, in which case the last element
  23028. --                          becomes the current element
  23029. -- 
  23030.  
  23031.     procedure set_first (L : List);
  23032.     procedure set_last (L : List);
  23033.     function  current_index (L : List)     return natural;
  23034.     function  current_next (L : List)      return boolean;
  23035.     function  current_previous (L : List)  return boolean;
  23036.     function  set_current_index (L : List;
  23037.     index : natural) return boolean;
  23038.  
  23039. -- 
  23040. -- The following functions return the index of the last element in
  23041. -- the list and indicate if the list is empty or not.
  23042. -- 
  23043. --    last_index          return the number of the last element
  23044. --                          (ordinal); 0 returned if list is empty
  23045. --    list_empty          return TRUE if the list is empty; FALSE if
  23046. --                          the list is not empty
  23047. --    at_end_of_list      return TRUE if the current_element is also
  23048. --                          the last_element; return FALSE if not
  23049. --    at_front_of_list    return TRUE if the current_element is also
  23050. --                          the first_element; return FALSE if not
  23051. -- 
  23052.  
  23053.     function last_index (L : List)       return natural;
  23054.     function list_empty (L : List)       return boolean;
  23055.     function at_end_of_list (L : List)   return boolean;
  23056.     function at_front_of_list (L : List) return boolean;
  23057.  
  23058. -- 
  23059. -- The following procedures and functions are used to manipulate
  23060. -- the elements in the list.
  23061. -- 
  23062. --    append_element       append the indicated element after the
  23063. --                           current_element in the list; the
  23064. --                           current_element is set to the new
  23065. --                           element
  23066. --    insert_element       insert the indicated element before the
  23067. --                           current_element in the list; the
  23068. --                           current_element is unchanged
  23069. --    delete_element       delete the current_element from the list;
  23070. --                           the next element is the new current_element
  23071. --                           unless there is no next element, in which
  23072. --                           case the previous element is the new
  23073. --                           current_element
  23074. -- 
  23075.  
  23076.     procedure append_element (L : List;
  23077.     element : element_pointer);
  23078.     procedure append_element (L : List;
  23079.     element : element_object);
  23080.     procedure insert_element (L : List;
  23081.     element : element_pointer);
  23082.     procedure insert_element (L : List;
  23083.     element : element_object);
  23084.     procedure delete_element (L : List);
  23085.  
  23086. -- 
  23087. -- The following function and procedure are used to dynamically
  23088. -- create new elements and to free the space occupied by unneeded
  23089. -- elements.
  23090. -- 
  23091. --    new_element        returns a pointer to a new list_element
  23092. --    free_element       frees the indicated list_element
  23093. -- 
  23094.  
  23095.     function  new_element  return element_pointer;
  23096.  procedure free_element is new unchecked_deallocation
  23097.     (list_element, element_pointer);
  23098.  
  23099. end generic_list;
  23100.  
  23101.  
  23102. -- 
  23103. -- BODY of generic_list
  23104. -- 
  23105. package body generic_list is
  23106.  
  23107. -- 
  23108. -- Definition of the three element pointers
  23109. -- 
  23110.  
  23111. -- 
  23112. -- Procedure to initialize the list
  23113. --    All element pointers are initialized to null
  23114. -- 
  23115.     procedure initialize_list (L : out List) is
  23116.     begin
  23117.     L := new Element_Rec;
  23118.     end initialize_list;
  23119.  
  23120. -- 
  23121. -- Functions to return element pointers
  23122. -- 
  23123.     function return_first_element (L : List) return element_pointer is
  23124.     begin
  23125.         return L.first_element;
  23126.     end return_first_element;
  23127.  
  23128.     function return_first_element (L : List) return element_object is
  23129.     begin
  23130.         return L.first_element.content;
  23131.     end return_first_element;
  23132.  
  23133.     function return_last_element (L : List) return element_pointer is
  23134.     begin
  23135.         return L.last_element;
  23136.     end return_last_element;
  23137.  
  23138.     function return_last_element (L : List) return element_object is
  23139.     begin
  23140.         return L.last_element.content;
  23141.     end return_last_element;
  23142.  
  23143.     function return_current_element (L : List) return element_pointer is
  23144.     begin
  23145.         return L.current_element;
  23146.     end return_current_element;
  23147.  
  23148.     function return_current_element (L : List) return element_object is
  23149.     begin
  23150.         return L.current_element.content;
  23151.     end return_current_element;
  23152.  
  23153. -- 
  23154. -- Current element pointer manipulation
  23155. -- 
  23156.     procedure set_first (L : List) is
  23157.     begin
  23158.         L.current_element := L.first_element;
  23159.     end set_first;
  23160.  
  23161.     procedure set_last (L : List) is
  23162.     begin
  23163.         L.current_element := L.last_element;
  23164.     end set_last;
  23165.  
  23166.     function current_index (L : List) return natural is
  23167.         local_element : element_pointer;
  23168.         index         : natural;
  23169.     begin
  23170.         index := 0; -- initialize counter and set empty list return
  23171.         if L.current_element /= null then
  23172.             local_element := L.first_element; -- point to first element
  23173.             index := 1;
  23174.             while local_element /= L.current_element loop
  23175.                 exit when local_element = null; -- error trap
  23176.                 local_element := local_element.next;
  23177.                 index := index + 1;
  23178.             end loop;
  23179.         end if;
  23180.         return index;
  23181.     end current_index;
  23182.  
  23183.     function current_next (L : List) return boolean is
  23184.     begin
  23185.         if L.current_element = L.last_element then
  23186.             return FALSE;
  23187.         else
  23188.             L.current_element := L.current_element.next;
  23189.             return TRUE;
  23190.         end if;
  23191.     end current_next;
  23192.  
  23193.     function current_previous (L : List) return boolean is
  23194.     begin
  23195.         if L.current_element = L.first_element then
  23196.             return FALSE;
  23197.         else
  23198.             L.current_element := L.current_element.previous;
  23199.             return TRUE;
  23200.         end if;
  23201.     end current_previous;
  23202.  
  23203.     function  set_current_index (L : List;
  23204.     index : natural) return boolean is
  23205.     begin
  23206.         L.current_element := L.first_element; -- start at first element
  23207.         if index <= 1 then
  23208.             return TRUE;
  23209.         else
  23210.             for counter in 1 .. index - 1 loop
  23211.                 if L.current_element = L.last_element then
  23212.                     return FALSE;
  23213.                     exit;      -- this exit may not be necessary
  23214.                 else
  23215.                     L.current_element := L.current_element.next;
  23216.                 end if;
  23217.             end loop;
  23218.             return TRUE;
  23219.         end if;
  23220.     end set_current_index;
  23221.  
  23222. -- 
  23223. -- Return the index of the last element in the list
  23224. -- 
  23225.     function last_index (L : List) return natural is
  23226.         current_save : element_pointer;
  23227.         index        : natural;
  23228.     begin
  23229.         current_save := L.current_element;
  23230.         L.current_element := L.last_element;
  23231.         index := current_index(L);
  23232.         L.current_element := current_save;
  23233.         return index;
  23234.     end last_index;
  23235.  
  23236. -- 
  23237. -- Determine if the list is empty; return TRUE if so, FALSE if not
  23238. -- 
  23239.     function list_empty (L : List) return boolean is
  23240.     begin
  23241.         if L.first_element = null then
  23242.             return TRUE; -- list is empty
  23243.         else
  23244.             return FALSE; -- list is not empty
  23245.         end if;
  23246.     end list_empty;
  23247.  
  23248. -- 
  23249. -- Determine if at first element in list; return TRUE if so
  23250. -- 
  23251.     function at_front_of_list (L : List) return boolean is
  23252.     begin
  23253.         if L.current_element = L.first_element then
  23254.             return TRUE;
  23255.         else
  23256.             return FALSE;
  23257.         end if;
  23258.     end at_front_of_list;
  23259.  
  23260. -- 
  23261. -- Determine if at last element in list; return TRUE if so
  23262. -- 
  23263.     function at_end_of_list (L : List) return boolean is
  23264.     begin
  23265.         if L.current_element = L.last_element then
  23266.             return TRUE;
  23267.         else
  23268.             return FALSE;
  23269.         end if;
  23270.     end at_end_of_list;
  23271.  
  23272. -- 
  23273. -- Procedures to manipulate elements in list
  23274. --  These procedures insert elements into the list and
  23275. --  delete elements from the list
  23276. -- 
  23277.     procedure append_element (L : List;
  23278.     element : element_pointer) is
  23279.     begin
  23280.         if list_empty (L) then
  23281.             L.first_element := element;
  23282.             L.last_element := element;
  23283.             L.current_element := element;
  23284.             element.next := null;
  23285.             element.previous := null;
  23286.         else
  23287.             element.next := L.current_element.next;
  23288.             L.current_element.next := element;
  23289.             element.previous := L.current_element;
  23290.             if element.next /= null then
  23291.                 element.next.previous := element;
  23292.             else
  23293.                 L.last_element := element;
  23294.             end if;
  23295.         end if;
  23296.         L.current_element := element;
  23297.     end append_element;
  23298.  
  23299.     procedure append_element (L : List;
  23300.     element : element_object) is
  23301.  
  23302.         loc_element : element_pointer;
  23303.     begin
  23304.         loc_element := new_element;
  23305.         loc_element.content := element;
  23306.         append_element (L, loc_element);
  23307.     end append_element;
  23308.  
  23309.     procedure insert_element (L : List;
  23310.     element : element_pointer) is
  23311.     begin
  23312.         if list_empty (L) then
  23313.             L.first_element := element;
  23314.             L.last_element := element;
  23315.             L.current_element := element;
  23316.             element.next := null;
  23317.             element.previous := null;
  23318.         else
  23319.             element.previous := L.current_element.previous;
  23320.             L.current_element.previous := element;
  23321.             element.next := L.current_element;
  23322.             if element.previous /= null then
  23323.                 element.previous.next := element;
  23324.             else
  23325.                 L.first_element := element;
  23326.             end if;
  23327.         end if;
  23328.     end insert_element;
  23329.  
  23330.     procedure insert_element (L: List;
  23331.     element : element_object) is
  23332.  
  23333.         loc_element : element_pointer;
  23334.     begin
  23335.         loc_element := new_element;
  23336.         loc_element.content := element;
  23337.         insert_element (L, loc_element);
  23338.     end insert_element;
  23339.  
  23340.     procedure delete_element (L : List) is
  23341.         temp_element : element_pointer;
  23342.     begin
  23343.         if not list_empty (L) then
  23344.  
  23345.             if L.current_element = L.first_element then
  23346.                 L.first_element := L.current_element.next;
  23347.             else
  23348.                 L.current_element.previous.next := L.current_element.next;
  23349.             end if;
  23350.  
  23351.             if L.current_element = L.last_element then
  23352.                 L.last_element := L.current_element.previous;
  23353.                 temp_element := L.last_element;
  23354.             else
  23355.                 L.current_element.next.previous := L.current_element.previous;
  23356.                 temp_element := L.current_element.next;
  23357.             end if;
  23358.  
  23359.             free_element (L.current_element);
  23360.             L.current_element := temp_element;
  23361.         end if;
  23362.     end delete_element;
  23363.  
  23364. -- 
  23365. -- Memory management routines
  23366. --   Obtain a new list element and free old, unneeded list elements
  23367. -- 
  23368.     function new_element return element_pointer is
  23369.     begin
  23370.         return (new list_element);
  23371.     end new_element;
  23372.  
  23373.     -- procedure free_element (element : element_pointer) is
  23374. -- 
  23375. -- This procedure is a dummy for now; the following generic
  23376. -- instantiation is what it should be, but there is a bug in my
  23377. -- Ada compiler which prevents this instatiation from working
  23378. -- 
  23379.  
  23380.     -- begin
  23381.         -- null;
  23382.     -- end free_element;
  23383.  
  23384. end generic_list;
  23385.  
  23386. --::::::::::::::
  23387. --generic_stack.a
  23388. --::::::::::::::
  23389.  
  23390. ----------------------------------------------------------------------
  23391. --                          GENERIC_STACK       
  23392. --               (Generic Package Specification and Body)
  23393. --
  23394. --
  23395. --             Generic Package for Simple Stack Services
  23396. --
  23397. --
  23398. --                           Chuck Howell
  23399. --
  23400. --
  23401. --
  23402. --                  Ada Software Engineering Group
  23403. --                      The MITRE Corporation
  23404. --                         McLean, VA 22102
  23405. --
  23406. --
  23407. --                   Mon Apr  1 12:32:16 EST 1985
  23408. --
  23409. --                 (Unclassified and uncopyrighted)
  23410. --
  23411. ----------------------------------------------------------------------
  23412.  
  23413. ----------------------------------------------------------------------
  23414. --
  23415. --  Purpose:
  23416. --  -------
  23417. --
  23418. --  Usage:
  23419. --  -----
  23420. --
  23421. --  Example:
  23422. --  -------
  23423. --
  23424. --  Notes:
  23425. --  -----
  23426. --    Changed type Node to type Stack_Record, and removed superflous
  23427. --    else statements in Pop and Top.
  23428. --
  23429. --  Revision History:
  23430. --  ----------------
  23431. --
  23432. -------------------------------------------------------------------
  23433.  
  23434. generic 
  23435.     type Item is private;
  23436. package Generic_Stack is
  23437.  
  23438.     type Stack is private;
  23439.  
  23440.     procedure Push (
  23441.     L : in out Stack;
  23442.     I : Item);
  23443.     
  23444.     procedure Pop (
  23445.     L : in out Stack);
  23446.     
  23447.     function Top (
  23448.     L : Stack )
  23449.     return Item;
  23450.     
  23451.     function Stack_Count (
  23452.     L : Stack)
  23453.     return Natural;
  23454.  
  23455.     UNDERFLOW : exception;
  23456.     
  23457. private
  23458.     type Stack_Record;
  23459.     type Stack is access Stack_Record;
  23460.     type Stack_Record is record
  23461.     Head : Item;
  23462.     Tail : Stack;
  23463.     end record;
  23464. end Generic_Stack;
  23465.  
  23466.  
  23467. package body Generic_Stack is
  23468.  
  23469.     Count : Natural := 0;
  23470.  
  23471.     procedure Push (
  23472.     L : in out Stack;
  23473.     I : Item) is
  23474.     begin
  23475.     L := new Stack_Record'(Head=> I, Tail=> L);
  23476.     Count := Count + 1;
  23477.     end Push;
  23478.     
  23479.     procedure Pop (
  23480.     L : in out Stack) is
  23481.     begin
  23482.     if L = null then
  23483.         raise UNDERFLOW;
  23484.     end if;
  23485.     Count := Count - 1;
  23486.     L := L.Tail;
  23487.     end Pop;
  23488.     
  23489.     function Top (
  23490.     L : Stack )
  23491.     return Item is
  23492.     begin
  23493.     if L = null then
  23494.         raise UNDERFLOW;
  23495.     end if;
  23496.     return L.Head;
  23497.     end Top;
  23498.  
  23499.     function Stack_Count (
  23500.     L : Stack)
  23501.     return Natural is
  23502.     begin
  23503.     return Count;
  23504.     end Stack_Count;
  23505.  
  23506. end Generic_Stack;
  23507. --::::::::::::::
  23508. --get_identifier.a
  23509. --::::::::::::::
  23510.  
  23511. ----------------------------------------------------------------------
  23512. --                     G E T _ I D E N T I F I E R
  23513. --
  23514. --           Separate subprogram in package Node_Internals
  23515. --
  23516. --
  23517. --
  23518. --
  23519. --                  Ada Software Engineering Group
  23520. --                      The MITRE Corporation
  23521. --                         McLean, VA 22102
  23522. --
  23523. --
  23524. --                   Thu Apr 11 17:27:08 EST 1985
  23525. --
  23526. --                 (Unclassified and uncopyrighted)
  23527. --
  23528. ----------------------------------------------------------------------
  23529.  
  23530. ----------------------  G E T _ I D E N T I F I E R -----------------
  23531. --
  23532. --  Purpose:
  23533. --  -------
  23534. --    This procedure is a simple "lexer" service; it returns the next
  23535. --    lexical unit in the given pathname, and determines the token class.
  23536. --
  23537. --  Parameters:
  23538. --  ----------
  23539. --    Path  - the pathname from which the next lexical unit is to be
  23540. --            extracted.
  23541. --    Id    - the token that was extracted.
  23542. --
  23543. --  Exceptions:
  23544. --  ----------
  23545. --    Cais_Internals_Exceptions.Internal_Error - any exception raised
  23546. --        during execution here is an internal error.
  23547. --
  23548. --  Notes:
  23549. --  -----
  23550. --
  23551. ---------------------------------------------------------------------
  23552.  
  23553. separate(Cais.Node_Internals)
  23554. procedure Get_Identifier(Path : in out Pathname; 
  23555.                          Id   : in out Token) is 
  23556.  
  23557.     Tok_Len : Positive := 1; 
  23558.  
  23559. begin
  23560.     for I in Path.Index + 1 .. Path.Size loop
  23561.         case Path.Str_Buf(I) is 
  23562.             when 'a' .. 'z' | 'A' .. 'Z' | '0' .. '9' => 
  23563.                 Tok_Len := Tok_Len + 1; 
  23564.             when '_' => 
  23565.                 if I = Path.Size then  -- can't end on _
  23566.                     Id.Class := Other; 
  23567.                     return; 
  23568.                 end if; 
  23569.                 case Path.Str_Buf(I + 1) is 
  23570.                     when 'a' .. 'z' | 'A' .. 'Z' | '0' .. '9' => 
  23571.                         Tok_Len := Tok_Len + 1; 
  23572.                     when others => 
  23573.                         Id.Class := Other; 
  23574.                         return; 
  23575.                 end case; 
  23576.             when '(' | ')' | ':' | '#' | ''' | '.' => 
  23577.                 exit; 
  23578.             when others => 
  23579.                 Id.Class := Other; 
  23580.                 return; 
  23581.         end case; 
  23582.     end loop; 
  23583.  
  23584.     Id.Class := Identifier; 
  23585.     To_Upper(Path.Str_Buf(Path.Index .. Path.Index + (Tok_Len - 1))); 
  23586.     Id.Value(1 .. Tok_Len) := Path.Str_Buf(Path.Index .. Path.Index + (Tok_Len -
  23587.                   1)); 
  23588.     Id.Last_Char := Tok_Len; 
  23589.     Path.Index := Path.Index + Tok_Len; 
  23590.  
  23591. exception
  23592.     when others => 
  23593.         Trace.Report("Unhandled exception in Get_Identifier"); 
  23594.         raise Trace.Assertion_Violation; 
  23595. end Get_Identifier; 
  23596. --::::::::::::::
  23597. --get_next_token.a
  23598. --::::::::::::::
  23599.  
  23600. ----------------------------------------------------------------------
  23601. --                     G E T _ N E X T _ T O K E N
  23602. --
  23603. --
  23604. --           Separate subprogram in package Node_Internals
  23605. --
  23606. --
  23607. --
  23608. --
  23609. --                  Ada Software Engineering Group
  23610. --                      The MITRE Corporation
  23611. --                         McLean, VA 22102
  23612. --
  23613. --
  23614. --                   Thu Apr 11 17:27:08 EST 1985
  23615. --
  23616. --                 (Unclassified and uncopyrighted)
  23617. --
  23618. ----------------------------------------------------------------------
  23619.  
  23620. ----------------------  G E T _ N E X T _ T O K E N -----------------
  23621. --
  23622. --  Purpose:
  23623. --  -------
  23624. --    This procedure extracts the next token from the given pathname.
  23625. --
  23626. --  Parameters:
  23627. --  ----------
  23628. --    From  - the pathname analyzed.
  23629. --    Next  - the token returned.
  23630. --
  23631. --  Exceptions:
  23632. --  ----------
  23633. --    Cais_Internals_Exceptions.Internal_Error  - any exception raised
  23634. --         here indicates an error in the implementation.
  23635. --
  23636. --  Notes:
  23637. --  -----
  23638. --    None.
  23639. --
  23640. ---------------------------------------------------------------------
  23641. separate(Cais.Node_Internals)
  23642. procedure Get_Next_Token(From : in out Pathname; 
  23643.                          Next : in out Token) is 
  23644. begin
  23645.  
  23646.     -- "Reset" The output token
  23647.     Next.Value := (others => ' '); 
  23648.     Next.Last_Char := 1; 
  23649.  
  23650.     if From.Index > From.Size then 
  23651.         Next.Class := End_Of_Pathname; 
  23652.         return; 
  23653.     end if; 
  23654.  
  23655.     case From.Str_Buf(From.Index) is 
  23656.         when '(' => 
  23657.             Next.Class := Left_Paren; 
  23658.             Next.Value(1) := '('; 
  23659.             From.Index := From.Index + 1; 
  23660.         when ')' => 
  23661.             Next.Class := Right_Paren; 
  23662.             Next.Value(1) := ')'; 
  23663.             From.Index := From.Index + 1; 
  23664.         when ':' => 
  23665.             Next.Class := Colon; 
  23666.             Next.Value(1) := ':'; 
  23667.             From.Index := From.Index + 1; 
  23668.         when '#' => 
  23669.             Next.Class := Sharp; 
  23670.             Next.Value(1) := '#'; 
  23671.             From.Index := From.Index + 1; 
  23672.         when ''' => 
  23673.             Next.Class := Tic; 
  23674.             Next.Value(1) := '''; 
  23675.             From.Index := From.Index + 1; 
  23676.         when '.' => 
  23677.             Next.Class := Dot; 
  23678.             Next.Value(1) := '.'; 
  23679.             From.Index := From.Index + 1; 
  23680.         when 'A' .. 'Z' | 'a' .. 'z' => 
  23681.             Get_Identifier(From, Next); 
  23682.         when ' ' | Ascii.Ht => 
  23683.             Skip_Whitespace(From); 
  23684.             if From.Index <= From.Size then 
  23685.                 Next.Class := Other; 
  23686.             else 
  23687.                 Next.Class := End_Of_Pathname; 
  23688.             end if; 
  23689.         when others => 
  23690.             Next.Class := Other; 
  23691.     end case; 
  23692.  
  23693. exception
  23694.     when others => 
  23695.         Trace.Report("Unhandled exception in Get_Next_Token"); 
  23696.         raise Trace.Assertion_Violation; 
  23697. end Get_Next_Token; 
  23698. --::::::::::::::
  23699. --get_parsed_pn.a
  23700. --::::::::::::::
  23701.  
  23702. ----------------------------------------------------------------------
  23703. --                     G E T _ P A R S E D _ P N
  23704. --
  23705. --
  23706. --           Separate subprogram in package Node_Internals
  23707. --
  23708. --
  23709. --
  23710. --
  23711. --                  Ada Software Engineering Group
  23712. --                      The MITRE Corporation
  23713. --                         McLean, VA 22102
  23714. --
  23715. --
  23716. --                   Tue May 14 13:13:27 EDT 1985
  23717. --
  23718. --                 (Unclassified and uncopyrighted)
  23719. --
  23720. ----------------------------------------------------------------------
  23721.  
  23722. ----------------------  G E T _ P A R S E D _ P N  ------------------
  23723. --
  23724. --  Purpose:
  23725. --  -------
  23726. --    Given a name string, this procedure will "parse"it into the
  23727. --    consituent CAIS pathname components. 
  23728. --
  23729. --  Parameters:
  23730. --  ----------
  23731. --    Name    - the string to be parsed
  23732. --    Result  - the fully parsed components.
  23733. --
  23734. --  Exceptions:
  23735. --  ----------
  23736. --    Cais_Internals_Exceptions.Pathname_Syntax_Error  - if the supplied
  23737. --       string is not a syntactically valid pathname.
  23738. --    Cais_Internals_Exceptions.Internal_Error  - if the parse stack
  23739. --      becomes garbled.
  23740. --
  23741. --  Notes:
  23742. --  -----
  23743. --    None.
  23744. --
  23745. ---------------------------------------------------------------------
  23746.  
  23747. separate(Cais.Node_Internals)
  23748. procedure Get_Parsed_Pn(Name   : Node_Definitions.Name_String; 
  23749.                         Result : in out Parsed_Pn) is 
  23750.  
  23751.     use Node_Representation.Pn_Comp_List; 
  23752.  
  23753.     Parse_Stack    : Symbol_Stack.Stack; 
  23754.     Path           : Pathname(Name'Length); 
  23755.     Latest_Token   : Token; 
  23756.     Tmp_Pn_Rec     : Pn_Rec; 
  23757.     Current_Symbol : Parse_Symbol; 
  23758.  
  23759.  
  23760.     procedure Reset_Pn_Rec(Rec : in out Pn_Rec) is 
  23761.     begin
  23762.         Rec.Rel_Name := (others => ' '); 
  23763.         Rec.Rel_Key := (others => ' '); 
  23764.         Rec.Latest_Key := False; 
  23765.     end Reset_Pn_Rec; 
  23766.  
  23767. begin
  23768.     Initialize_List(Result.L); 
  23769.     Path := Convert_To_Pn(Name); 
  23770.  
  23771.     Get_Next_Token(Path, Latest_Token); 
  23772.     case Latest_Token.Class is    -- Much better diagnostics needed
  23773.         when Tic => 
  23774.             Push(Parse_Stack, Element_Set); 
  23775.         when Colon =>  -- must be only pathname element
  23776.             Tmp_Pn_Rec.Rel_Name := Latest_Token.Value; 
  23777.             Get_Next_Token(Path, Latest_Token); 
  23778.             if Latest_Token.Class /= End_Of_Pathname then 
  23779.                 raise Pathname_Syntax_Error; 
  23780.             else 
  23781.                 Append_Element(Result.L, Tmp_Pn_Rec); 
  23782.                 return; 
  23783.             end if; 
  23784.         when Sharp => 
  23785.             Tmp_Pn_Rec.Rel_Name(1 .. 12) := "CURRENT_NODE"; 
  23786.             Tmp_Pn_Rec.Latest_Key := False; 
  23787.             Append_Element(Result.L, Tmp_Pn_Rec); 
  23788.             Reset_Pn_Rec(Tmp_Pn_Rec); 
  23789.             Tmp_Pn_Rec.Rel_Name(1 .. 3) := "DOT"; 
  23790.             Tmp_Pn_Rec.Latest_Key := True; 
  23791.             Append_Element(Result.L, Tmp_Pn_Rec); 
  23792.             Reset_Pn_Rec(Tmp_Pn_Rec); 
  23793.             Push(Parse_Stack, Element_Set); 
  23794.             Get_Next_Token(Path, Latest_Token); 
  23795.         when Identifier => 
  23796.             Tmp_Pn_Rec.Rel_Name(1 .. 12) := "CURRENT_NODE"; 
  23797.             Tmp_Pn_Rec.Latest_Key := False; 
  23798.             Append_Element(Result.L, Tmp_Pn_Rec); 
  23799.             Reset_Pn_Rec(Tmp_Pn_Rec); 
  23800.             Tmp_Pn_Rec.Rel_Name(1 .. 3) := "DOT"; 
  23801.             Tmp_Pn_Rec.Rel_Key := Latest_Token.Value; 
  23802.             Get_Next_Token(Path, Latest_Token); 
  23803.             if Latest_Token.Class = Sharp then 
  23804.                 Tmp_Pn_Rec.Latest_Key := True; 
  23805.                 Get_Next_Token(Path, Latest_Token); 
  23806.             end if; 
  23807.             Push(Parse_Stack, Element_Set); 
  23808.             Append_Element(Result.L, Tmp_Pn_Rec); 
  23809.             Reset_Pn_Rec(Tmp_Pn_Rec); 
  23810.         when Dot => 
  23811.             Tmp_Pn_Rec.Rel_Name(1 .. 3) := "DOT"; 
  23812.             Get_Next_Token(Path, Latest_Token); 
  23813.             Push(Parse_Stack, Relationship_Key); 
  23814.             Push(Parse_Stack, Element_Set); 
  23815.         when Left_Paren | Right_Paren | End_Of_Pathname | Other => 
  23816.             raise Pathname_Syntax_Error; 
  23817.     end case; 
  23818.  
  23819.     loop
  23820.         Current_Symbol := Top(Parse_Stack); 
  23821.         case Current_Symbol is 
  23822.             when Relationship_Key => 
  23823.                 if Latest_Token.Class = Sharp then 
  23824.                     Tmp_Pn_Rec.Latest_Key := True; 
  23825.                     Append_Element(Result.L, Tmp_Pn_Rec); 
  23826.                     Reset_Pn_Rec(Tmp_Pn_Rec); 
  23827.                     Get_Next_Token(Path, Latest_Token); 
  23828.                     Pop(Parse_Stack); 
  23829.                 elsif Latest_Token.Class = Identifier then 
  23830.                     Tmp_Pn_Rec.Rel_Key := Latest_Token.Value; 
  23831.                     Get_Next_Token(Path, Latest_Token); 
  23832.                     if Latest_Token.Class = Sharp then 
  23833.                         Tmp_Pn_Rec.Latest_Key := True; 
  23834.                         Get_Next_Token(Path, Latest_Token); 
  23835.                     end if; 
  23836.                     Append_Element(Result.L, Tmp_Pn_Rec); 
  23837.                     Reset_Pn_Rec(Tmp_Pn_Rec); 
  23838.                     Pop(Parse_Stack); 
  23839.                 else 
  23840.                     if Tmp_Pn_Rec.Rel_Name(1 .. 4) = "DOT " then 
  23841.                         raise Pathname_Syntax_Error; 
  23842.                     end if; 
  23843.                     Append_Element(Result.L, Tmp_Pn_Rec); 
  23844.                     Reset_Pn_Rec(Tmp_Pn_Rec); 
  23845.                     Pop(Parse_Stack); 
  23846.                 end if; -- Latest_Token.Class = SHARP then
  23847.             when Element_Set => 
  23848.                 if Latest_Token.Class = End_Of_Pathname then 
  23849.                     exit; -- done parsing
  23850.                 elsif Latest_Token.Class = Tic then 
  23851.                     Get_Next_Token(Path, Latest_Token); 
  23852.                     if Latest_Token.Class /= Identifier then 
  23853.                         raise Pathname_Syntax_Error; 
  23854.                     end if; 
  23855.                     Tmp_Pn_Rec.Rel_Name := Latest_Token.Value; 
  23856.                     Get_Next_Token(Path, Latest_Token); 
  23857.                     Push(Parse_Stack, Paren_Relationship_Key); 
  23858.                 elsif Latest_Token.Class = Dot then 
  23859.                     Tmp_Pn_Rec.Rel_Name(1 .. 3) := "DOT"; 
  23860.                     Push(Parse_Stack, Relationship_Key); 
  23861.                     Get_Next_Token(Path, Latest_Token); 
  23862.                 else 
  23863.                     raise Pathname_Syntax_Error; 
  23864.                 end if; -- Latest_Token.Class = END_OF_PATHNAME then
  23865.             when Relation_Name => 
  23866.                 if Latest_Token.Class /= Identifier then 
  23867.                     raise Pathname_Syntax_Error; 
  23868.                 end if; 
  23869.                 Tmp_Pn_Rec.Rel_Name := Latest_Token.Value; 
  23870.                 Get_Next_Token(Path, Latest_Token); 
  23871.                 Pop(Parse_Stack); 
  23872.             when Paren_Relationship_Key => 
  23873.                 if Latest_Token.Class /= Left_Paren then 
  23874.                 -- assume there is no ( Relationship_key )
  23875.                     Pop(Parse_Stack); 
  23876.                     Append_Element(Result.L, Tmp_Pn_Rec); 
  23877.                     Reset_Pn_Rec(Tmp_Pn_Rec); 
  23878.                 else  -- Latest_Token.Class = LEFT_PAREN
  23879.                     Pop(Parse_Stack); 
  23880.                     Get_Next_Token(Path, Latest_Token); 
  23881.                     Push(Parse_Stack, Right_Paren); 
  23882.                     Push(Parse_Stack, Relationship_Key); 
  23883.                 end if; -- Latest_Token.Class /= LEFT_PAREN then
  23884.             when Right_Paren => 
  23885.                 if Latest_Token.Class /= Right_Paren then 
  23886.                     raise Pathname_Syntax_Error; 
  23887.                 end if; 
  23888.                 Pop(Parse_Stack); 
  23889.                 Get_Next_Token(Path, Latest_Token); 
  23890.             when others => 
  23891.                 Trace.Report("Pathname Parser: Internal Error"); 
  23892.                 Trace.Report("Top of Parse_Stack:" & Parse_Symbol'Image(
  23893.                     Current_Symbol)); 
  23894.                 raise Trace.Assertion_Violation; 
  23895.         end case; 
  23896.     end loop; 
  23897.  
  23898. end Get_Parsed_Pn; 
  23899. --::::::::::::::
  23900. --get_unique_filename.a
  23901. --::::::::::::::
  23902.  
  23903. ----------------------------------------------------------------------
  23904. --                 G E T _ U N I Q U E _ F I L E N A M E            
  23905. --
  23906. --             Separate Subprogram in Cais_Host_Dependent
  23907. --
  23908. --
  23909. --
  23910. --
  23911. --                  Ada Software Engineering Group
  23912. --                      The MITRE Corporation
  23913. --                         McLean, VA 22102
  23914. --
  23915. --
  23916. --                   Thu Mar 06 06:09:19 EST 1986
  23917. --
  23918. --                 (Unclassified and uncopyrighted)
  23919. --
  23920. ----------------------------------------------------------------------
  23921. -----------------  G E T _ U N I Q U E _ F I L E N A M E -------------
  23922. --
  23923. --  Purpose:
  23924. --  -------
  23925. --    This routine is used generate a filename that is unique for the
  23926. --    CAIS "Host Directory" (the shadowdir directory).  The
  23927. --    name of the shadowdir directory (Cais_Host_Dependent.Cais_Host_Directory)
  23928. --    is used as part of a template passed to create_uniq.
  23929. --    The filename returned is fully qualified.  The new file is
  23930. --    given a file protection mask of 777 (i.e. rwxrwxrwx).
  23931. --
  23932. --  Parameters:
  23933. --  ----------
  23934. --    Name   -  name of new file
  23935. --    Length - number of significant characters in Name
  23936. --
  23937. --  Exceptions:
  23938. --  ----------
  23939. --    Cais_Internals_Exceptions.Internal_Error - if create_uniq fails
  23940. --
  23941. --  Notes:
  23942. --  -----
  23943. --
  23944. ---------------------------------------------------------------------
  23945.  
  23946. with System;
  23947.  
  23948. separate(Cais.Cais_Host_Dependent)
  23949. procedure Get_Unique_Filename(Name   : in out String; 
  23950.                               Length : in out Natural) is 
  23951.  
  23952.  
  23953.     Result : Integer;
  23954.     Template : constant String := ".CAISXXXXXX";
  23955.     function Create_Uniq (Name : System.Address) return Integer;
  23956.     pragma Interface (C, Create_Uniq);
  23957.  
  23958. begin
  23959.     Length := Cais_Host_Directory'length + Template'length;
  23960.     declare
  23961.     Tmp_Name : String (1 .. Length);
  23962.     begin
  23963.     Tmp_Name := Cais_Host_Directory & Template;
  23964.     Result := Create_Uniq (Tmp_Name'address);
  23965.     if Result = -1 then
  23966.         Trace.Report ("Get_Unique_Filename: create_uniq failed");
  23967.         raise Trace.Assertion_Violation;
  23968.     end if;
  23969.     Name (1 .. Length) := Tmp_Name;
  23970.     end;
  23971. end Get_Unique_Filename; 
  23972. --::::::::::::::
  23973. --get_user_prefix.a
  23974. --::::::::::::::
  23975.  
  23976. ----------------------------------------------------------------------
  23977. --                    G E T _ U S E R _ P R E F I X
  23978. --             (separate subprogram in CAIS_Host_Dependant)
  23979. --
  23980. --
  23981. --
  23982. --
  23983. --
  23984. --
  23985. --                  Ada Software Engineering Group
  23986. --                      The MITRE Corporation
  23987. --                         McLean, VA 22102
  23988. --
  23989. --
  23990. --                   Mon Jun 17 07:51:04 EDT 1985
  23991. --
  23992. --                 (Unclassified and uncopyrighted)
  23993. --
  23994. ----------------------------------------------------------------------
  23995.  
  23996. -----------------  G E T _ U S E R _ P R E F I X  -------------------
  23997. --
  23998. --  Purpose:
  23999. --  -------
  24000. --    Given a particular CAIS user id, this subprogram returns the
  24001. --    fully qualified host filename for the "user prefix"; this is
  24002. --    the prefix to be added to all references to host files (shadow
  24003. --    files) specific to that user.
  24004. --
  24005. --  Parameters:
  24006. --  ----------
  24007. --    Userid   - string that is the specified CAIS user.
  24008. --
  24009. --  Exceptions:
  24010. --  ----------
  24011. --     Cais_Internals_Exceptions.No_Such_User - if the specified
  24012. --         user is not in the system node.
  24013. --
  24014. --  Notes:
  24015. --  -----
  24016. --    None.
  24017. --
  24018. ---------------------------------------------------------------------
  24019. with Character_Set; use Character_Set; 
  24020.  
  24021.  
  24022. separate(Cais.Cais_Host_Dependent)
  24023. function Get_User_Prefix(Userid : String) return String is 
  24024.  
  24025.     use Node_Definitions; 
  24026.     use Node_Representation; 
  24027.     use List_Utilities; 
  24028.     use Pragmatics; 
  24029.     use Cais_Internals_Exceptions; 
  24030.     use Node_Internals; 
  24031.     use Cais_Utilities; 
  24032.  
  24033.  
  24034.     System_Node : Node_Type; 
  24035.     User_List   : List_Type; 
  24036.     Prefix      : String(1 .. Max_User_Prefix_Length) := (others => ' '); 
  24037.     Attributes  : List_Type; 
  24038.     Tmp_List    : List_Type; 
  24039.     Is_Primary  : Boolean; 
  24040.     Shadow_File : String(1 .. Max_Shadow_File_Length); 
  24041.  
  24042. begin
  24043.     Set_Shadow_File_Name(System_Node, Cais_System_Node); 
  24044.     Read_Shadow_File(System_Node); 
  24045.     Get_A_Relationship(Node => System_Node, Rel_Name => "User", Rel_Key => 
  24046.         Userid, Rel_Attributes => Attributes, Primary => Is_Primary, Shadow_File
  24047.         => Shadow_File); 
  24048.  
  24049.     Extract(List => Attributes, List_Item => Tmp_List, Named => "User_Prefix"); 
  24050.     Simple_List_To_String(Tmp_List, Prefix); 
  24051.     return Prefix(1 .. Last_Non_Space(Prefix)); 
  24052.  
  24053. exception
  24054.  
  24055.     when No_Such_Relationship => 
  24056.         raise No_Such_User; 
  24057.  
  24058. end Get_User_Prefix; 
  24059. --::::::::::::::
  24060. --get_userid.a
  24061. --::::::::::::::
  24062.  
  24063. ----------------------------------------------------------------------
  24064. --                        G E T _ U S E R I D
  24065. --
  24066. --
  24067. --               Separate subprogram in package Cais_Host_Dependent
  24068. --
  24069. --
  24070. --
  24071. --
  24072. --                  Ada Software Engineering Group
  24073. --                      The MITRE Corporation
  24074. --                         McLean, VA 22102
  24075. --
  24076. --
  24077. --                   Mon Jul  8 22:28:05 EDT 1985
  24078. --
  24079. --                 (Unclassified and uncopyrighted)
  24080. --
  24081. ----------------------------------------------------------------------
  24082.  
  24083. -------------------     G E T _ U S E R I D       --------------------
  24084. --
  24085. --  Purpose:
  24086. --  -------
  24087. --    This routine determines the CAIS userid for the calling process.
  24088. --
  24089. --  Parameters:
  24090. --  ----------
  24091. --    None (returns a string representing the userid).
  24092. --
  24093. --  Exceptions:
  24094. --  ----------
  24095. --    Cais_Internals_Exceptions.Cais_Userid_Undefined  if the current
  24096. --       process (user) does not have a CAIS userid defined.
  24097. --
  24098. --  Notes:
  24099. --  -----
  24100. --    In this Unix implementation, the userid is defined by setting
  24101. --    an environment variable.
  24102. --    For example, in the user's .login, a "setenv CAIS_USERID howell"
  24103. --    for the particular user.
  24104. --
  24105. ---------------------------------------------------------------------
  24106. with System; 
  24107. with Character_Set; 
  24108. separate(Cais.Cais_Host_Dependent)
  24109. function Get_Userid return String is 
  24110.  
  24111.     use Cais_Internals_Exceptions; 
  24112.  
  24113.     My_Name : String(1 .. Pragmatics.Max_Userid_Length) := (others => ' '); 
  24114.     procedure Cget_Userid(Name : System.Address); 
  24115.     pragma Interface(C, Cget_Userid); 
  24116.  
  24117. begin
  24118.  
  24119.     Cget_Userid(My_Name'Address); 
  24120.     if My_Name(1) /= '!' then 
  24121.         return My_Name(1 .. Character_Set.Last_Non_Space(My_Name)); 
  24122.     else 
  24123.         raise Cais_Userid_Undefined; 
  24124.     end if; 
  24125.  
  24126. end Get_Userid; 
  24127. --::::::::::::::
  24128. --identifier_items.a
  24129. --::::::::::::::
  24130.  
  24131. ----------------------------------------------------------------------
  24132. --                 I D E N T I F I E R _ I T E M S
  24133. --            Separate Package Body from List_Utilities
  24134. --
  24135. --             Operations for identifiers within Lists
  24136. --
  24137. --
  24138. --                  Ada Software Engineering Group
  24139. --                      The MITRE Corporation
  24140. --                         McLean, VA 22102
  24141. --
  24142. --
  24143. --                   Wed Oct  9 13:35:49 EDT 1985
  24144. --
  24145. --                 (Unclassified and uncopyrighted)
  24146. --
  24147. ----------------------------------------------------------------------
  24148. ----------------------------------------------------------------------
  24149. --                 I D E N T I F I E R _ I T E M S
  24150. --
  24151. --  Purpose:
  24152. --  -------
  24153. --    This package provides Extract, Replace, Insert, and Position_By_Value
  24154. --    operations on identifier items within lists.  It also provides To_Text,
  24155. --    To_Token, and Is_equal operations for manipulating identifiers directly.
  24156. --
  24157. --  Usage:
  24158. --  -----
  24159. --    Tokens must conform to Ada syntax rules for names.  Upper and lower
  24160. --    case is not significant within a Token.  They are used as names
  24161. --    in named lists.  In CAIS, they are used for relations, keys, and
  24162. --    attribute names.
  24163. --
  24164. --  Example:
  24165. --  -------
  24166. --            To_Token("Ada_Name", Token);
  24167. --            Insert(Some_List,Token,5);
  24168. --            Insert(Some_List,"Name_of_Token",Token,3);
  24169. --
  24170. --  Notes: MIL_STD CAIS 5.4.1.20
  24171. --  -----
  24172. --    The package name was changed to identifier_Items so as not to conflict
  24173. --    with the enumeral Identifier_Items.
  24174. --
  24175. --  Revision History:
  24176. --  ----------------
  24177. --
  24178. -------------------------------------------------------------------
  24179. separate(Cais.List_Utilities)
  24180. package body Identifier_Items is 
  24181. ---------------------T O _ T O K E N----------------------------
  24182. --
  24183. -- Purpose: 
  24184. -- -------
  24185. --     Converts the string representation of an identifier into
  24186. --     the corresponding internal token representation.
  24187. --
  24188. -- Parameters:
  24189. -- ----------
  24190. --     Identifier is the character string to be converted to token format
  24191. --     Token      is validated token format of the Identifier
  24192. --
  24193. -- Exceptions: 
  24194. -- ----------  
  24195. --     Use_Error    indicates the identifier violates Ada syntax rules
  24196. --
  24197. -- Notes: MIL_STD CAIS 5.4.1.20.1
  24198. -- -----  
  24199. --
  24200. -------------------------------------------------------------------
  24201.     procedure To_Token(Identifier : in Namestring; 
  24202.                        Token      : in out Token_Type) is 
  24203.     begin
  24204.         Validate_Item(Identifier, Identifier_Item, Token); 
  24205.     end To_Token; 
  24206. ---------------------T O _ T E X T------------------------------
  24207. --
  24208. -- Purpose: 
  24209. -- -------
  24210. --     Returns the external representation of the value of the List_Item
  24211. --     paramater.  The external representation is the identifier in 
  24212. --     upper case letters adhering to Ada syntax for identifiers.
  24213. --
  24214. -- Parameters:
  24215. -- ----------
  24216. --     List_Item is a token containing an Identifier to be changed to a string
  24217. --
  24218. -- Exceptions: 
  24219. -- ----------  
  24220. --     None
  24221. --
  24222. -- Notes: MIL_STD CAIS 5.4.1.20.2
  24223. -- -----  
  24224. --
  24225. -------------------------------------------------------------------
  24226.     function To_Text(List_Item : in Token_Type) return Namestring is 
  24227.     begin
  24228.         return Retrieve(List_Item); 
  24229.     end To_Text; 
  24230. ---------------------I S _ E Q U A L----------------------------------
  24231. --
  24232. -- Purpose: 
  24233. -- -------
  24234. --     Returns true if the two token represent Ada identifiers
  24235. --     whose string representation is equal under string comparison 
  24236. --     excepting diffed of two tokens being compared
  24237. --
  24238. -- Parameters:
  24239. -- ----------
  24240. --    Token1 is the 1st token to be compared
  24241. --    Token2 is the 2nd token to be compared
  24242. --    return TRUE if tokens match independent of case
  24243. --
  24244. -- Exceptions: 
  24245. -- ----------  
  24246. --     None
  24247. --
  24248. -- Notes: MIL_STD CAIS 5.4.1.20.4
  24249. -- -----  
  24250. --
  24251. -------------------------------------------------------------------
  24252.     function Is_Equal(Token1 : in Token_Type; 
  24253.                       Token2 : in Token_Type) return Boolean is 
  24254.     begin
  24255.         return V_String.Is_Equal(Token1, Token2); 
  24256.     end Is_Equal; 
  24257. ---------------------E X T R A C T----IDENTIFIER--POSITIONAL--------
  24258. --
  24259. -- Purpose: 
  24260. -- -------
  24261. --     Returns the Identifier item from the nth position of the list without
  24262. --     removing it.  Use_Error indicates unsuccessful extraction.
  24263. --
  24264. -- Parameters:
  24265. -- ----------
  24266. --     List       is the unnamed list of interest
  24267. --     Position   is the position o-            
  24268. -- Exceptions: 
  24269. -- ----------  
  24270. --     Use_Error        indicates an empty or named list or that
  24271. --            position exceeds the length of the list
  24272. --
  24273. -- Notes: MIL_STD CAIS 5.4.1.20.4
  24274. -- -----  
  24275. --
  24276. -------------------------------------------------------------------
  24277.  
  24278.     procedure Extract(List     : in List_Type; 
  24279.                       Position : in Position_Count; 
  24280.                       Token    : in out Token_Type) is 
  24281.         Current : List_Type;      --ptr to named item
  24282.     begin
  24283.         if List = null then 
  24284.             raise Use_Error; 
  24285.         else 
  24286.             Find(List, Position, Current); 
  24287.             if Current.Kind /= Identifier_Item then 
  24288.                 raise Use_Error; 
  24289.             else 
  24290.                 Copy(Token, Current.Element); 
  24291.             end if; 
  24292.         end if; 
  24293.     end Extract; 
  24294. ---------------------E X T R A C T----IDENTIFIER--NAME--------------
  24295. --
  24296. -- Purpose: 
  24297. -- -------
  24298. --     Returns the named identifier item from the list without removing it.
  24299. --     Use_Error and Search_Error indicate unsuccessful extraction.
  24300. --
  24301. -- Parameters:
  24302. -- ----------
  24303. --     List       is the unnamed list of interest
  24304. --     Name       is the Name of the identifier to be extracted
  24305. --     Token      is the value of the selected identifier in token format
  24306. --            
  24307. -- Exceptions: 
  24308. -- ----------  
  24309. --     Search_error     indicates Named item not found
  24310. --     Use_Error        indicates an empty or positional list
  24311. --
  24312. -- Notes: MIL_STD CAIS 5.4.1.20.4
  24313. -- -----  
  24314. --    
  24315. -------------------------------------------------------------------
  24316.  
  24317.     procedure Extract(List  : in List_Type; 
  24318.                       Named : in Namestring; 
  24319.                       Token : in out Token_Type) is 
  24320.         Current : List_Type;      --ptr too named item
  24321.     begin
  24322.         if List = null then 
  24323.             raise Use_Error; 
  24324.         else 
  24325.             Find(List, Named, Current); 
  24326.             if Current.Kind /= Identifier_Item then 
  24327.                 raise Use_Error; 
  24328.             else 
  24329.                 Copy(Token, Current.Element); 
  24330.             end if; 
  24331.         end if; 
  24332.     end Extract; 
  24333. ---------------------E X T R A C T----IDENTIFIER--NAME-TOKEN--------
  24334. --
  24335. -- Purpose: 
  24336. -- -------
  24337. --     Returns the named identifier item from the list without removing it.
  24338. --     Use_Error and Search_Error indicate unsuccessful extraction.
  24339. --
  24340. -- Parameters:
  24341. -- ----------
  24342. --     List       is the unnamed list of interest
  24343. --     Name       is the Name (in token form) of the identifier to be extracted
  24344. --     Token      is the value of the selected identifier in token format
  24345. --            
  24346. -- Exceptions: 
  24347. -- ----------  
  24348. --     Search_error     indicates Named item not found
  24349. --     Use_Error        indicates an empty or positional list
  24350. --
  24351. -- Notes: MIL_STD CAIS 5.4.1.20.4
  24352. -- -----  
  24353. --    
  24354. -------------------------------------------------------------------
  24355.  
  24356.     procedure Extract(List  : in List_Type; 
  24357.                       Named : in Token_Type; 
  24358.                       Token : in out Token_Type) is 
  24359.         Current : List_Type;      --ptr to named item
  24360.     begin
  24361.         Extract(List, Retrieve(Named), Token); 
  24362.     end Extract; 
  24363. --------------------R E P L A C E--IDENTIFIER---POSITIONAL--------------
  24364. --
  24365. -- Purpose: 
  24366. -- -------
  24367. --     Replaces an identifier item in a positional list.  The new item
  24368. --     must be of the same item kind as the one being replaced.
  24369. --
  24370. -- Parameters:
  24371. -- ----------
  24372. --     List       is the unnamed list of interest
  24373. --     List_Item  is the replacement value for an identifier item
  24374. --     Position   is the position of the identifier in list to be replaced
  24375. --
  24376. -- Exceptions: 
  24377. -- ----------  
  24378. --     Use_Error        is raised if item kinds do not match,
  24379. --                      or if position exceeds list length.
  24380. --
  24381. -- Notes:  MIL_STD CAIS 5.4.1.20.5
  24382. -- -----
  24383. --
  24384. ----------------------------------------------------------------
  24385.  
  24386.     procedure Replace(List      : in out List_Type; 
  24387.                       List_Item : in Token_Type; 
  24388.                       Position  : in Position_Count) is 
  24389.         Current : List_Type;   --ptr to list element being modified
  24390.     begin
  24391.         Find(List, Position, Current); 
  24392.         if Current.Kind = Identifier_Item then 
  24393.             Validate_Item(Retrieve(List_Item), Identifier_Item, Current.Element)
  24394.                 ; 
  24395.         else 
  24396.             raise Use_Error; 
  24397.         end if; 
  24398.     end Replace; 
  24399. --------------------R E P L A C E--IDENTIFIER---NAMED------------------
  24400. --
  24401. -- Purpose: 
  24402. -- -------
  24403. --     Replaces an item in a named list.  The new item
  24404. --     must be of the same item kind as the one being replaced.
  24405. --
  24406. -- Parameters:
  24407. -- ----------
  24408. --     List       is the named list of interest
  24409. --     List_Item  is the replacement value for an identifier_item in list
  24410. --     Named      is the name of an identifier in list which will be replaced
  24411. --
  24412. -- Exceptions: 
  24413. -- ----------  
  24414. --     Use_Error        is raised if item kinds do not match.
  24415. --     Search_Error     is raised if Named item is not found.
  24416. --
  24417. -- Notes:  MIL_STD CAIS 5.4.1.20.5
  24418. -- -----
  24419. --
  24420. ----------------------------------------------------------------
  24421.  
  24422.     procedure Replace(List      : in out List_Type; 
  24423.                       List_Item : in Token_Type; 
  24424.                       Named     : in Namestring) is 
  24425.         Current : List_Type;       --ptr to list element being modified
  24426.     begin
  24427.         Find(List, Named, Current); 
  24428.         if Current.Kind = Identifier_Item then --enumeration
  24429.             Validate_Item(Retrieve(List_Item), Identifier_Item, Current.Element)
  24430.                 ; 
  24431.         else 
  24432.             raise Use_Error; 
  24433.         end if; 
  24434.     end Replace; 
  24435. --------------------R E P L A C E--IDENTIFIER---NAMED--TOKEN----------------
  24436. --
  24437. -- Purpose: 
  24438. -- -------
  24439. --     Replaces an identifier item in a named list.  The new item
  24440. --     must be of the same item kind as the one being replaced.
  24441. --
  24442. -- Parameters:
  24443. -- ----------
  24444. --     List       is the named list of interest
  24445. --     List_Item  is the replacement value for an identifier in List
  24446. --     Named      is the name (in token format) of an identifier in List which
  24447. --                will be replaced
  24448. --
  24449. -- Exceptions: 
  24450. -- ----------  
  24451. --     Use_Error        is raised if item kinds do not match.
  24452. --     Search_Error     is raised if Named item is not found.
  24453. --
  24454. -- Notes:  MIL_STD CAIS 5.4.1.20.5
  24455. -- -----
  24456. --
  24457. ----------------------------------------------------------------
  24458.  
  24459.     procedure Replace(List      : in out List_Type; 
  24460.                       List_Item : in Token_Type; 
  24461.                       Named     : in Token_Type) is 
  24462.     begin
  24463.         Replace(List, List_Item, Retrieve(Named)); 
  24464.     end Replace; 
  24465. -----------------I N S E R T--IDENTIFIER--POSITIONAL-----------------
  24466. --
  24467. -- Purpose: 
  24468. -- -------
  24469. --     Inserts an identifier item into a positional list.  Use_Error
  24470. --     or Search_Error may be raised indicating identifier item has
  24471. --     not been inserted.
  24472. --
  24473. -- Parameters:
  24474. -- ----------
  24475. --     List       is the named list of interest
  24476. --     List_Item  is the replacement value for an identifier in List
  24477. --     Position   is the position of the item after which the Identifier is
  24478. --                inserted
  24479. -- Exceptions: 
  24480. -- ----------  
  24481. --     Use_Error     is raised if this is a named list,
  24482. --                   or if position exceeds size of list
  24483. --
  24484. -- Notes: MIL_STD CAIS 5.4.1.20.6
  24485. -- -----
  24486. --
  24487. ----------------------------------------------------------------
  24488.  
  24489.     procedure Insert(List      : in out List_Type; 
  24490.                      List_Item : in Token_Type; 
  24491.                      Position  : in Count) is 
  24492.         Current  : List_Type;       --ptr to list item to insert after
  24493.         New_Item : List_Type;       --ptr to area where new list item is built
  24494.  
  24495.     begin
  24496.         if Position /= 0 then 
  24497.             Find(List, Position, Current); 
  24498.         elsif List /= null and then List.Name /= null then 
  24499.             raise Use_Error;            --Mixed Named/Positional Items
  24500.         end if; 
  24501.         New_Item := new Item_Descriptor; 
  24502.         Validate_Item(Retrieve(List_Item), Identifier_Item, New_Item.Element); 
  24503.  
  24504.         --store value fields
  24505.         New_Item.Name := null; 
  24506.         New_Item.Kind := Identifier_Item; 
  24507.  
  24508.     end Insert; 
  24509. -----------------I N S E R T--IDENTIFIER--NAMED----------------------
  24510. --
  24511. -- Purpose: 
  24512. -- -------
  24513. --     Inserts an identifier item into a named list.  Specifying Position
  24514. --     as zero results in the identifier being at the head of the List.
  24515. --     Use_Error or Search_Error may be raised indicating identifier item
  24516. --     has not been inserted.
  24517. --
  24518. -- Parameters:
  24519. -- ----------
  24520. --     List       is the named list of interest
  24521. --     List_Item  is the identifier value to be inserted
  24522. --     Named      is the name of an identifier in List which will be replaced
  24523. --     Position   is the position of the item after which the Identifier is
  24524. --                inserted
  24525. -- Exceptions: 
  24526. -- ----------  
  24527. --     Use_Error     is raised if this is a positional list,
  24528. --                   or if position exceeds the size of the list.
  24529. --
  24530. -- Notes: MIL_STD CAIS 5.4.1.20.6
  24531. -- -----
  24532. --
  24533. ----------------------------------------------------------------
  24534.     procedure Insert(List      : in out List_Type; 
  24535.                      List_Item : in Token_Type; 
  24536.                      Named     : in Namestring; 
  24537.                      Position  : in Count) is 
  24538.         Current  : List_Type;       --ptr to list item to insert after
  24539.         New_Item : List_Type;       --ptr to area where new list item is built
  24540.     begin
  24541.         if Position /= 0 then 
  24542.             Find_All(List, Position, Current); 
  24543.         end if; 
  24544.         if List /= null and then List.Name = null then 
  24545.             raise Use_Error;            --Mixed Named/Positional Items
  24546.         end if; 
  24547.         New_Item := new Item_Descriptor; 
  24548.  
  24549.         --store value fields
  24550.         New_Item.Kind := Identifier_Item; 
  24551.         Validate_Item(Named, Identifier_Item, New_Item.Name); 
  24552.         Validate_Item(Retrieve(List_Item), Identifier_Item, New_Item.Element); 
  24553.  
  24554.         --now set up pointers
  24555.         if Position /= 0 then 
  24556.             New_Item.Next_Item := Current.Next_Item;    --simple item
  24557.             Current.Next_Item := New_Item; 
  24558.         else 
  24559.             New_Item.Next_Item := List;                 --head item
  24560.             List := New_Item; 
  24561.         end if; 
  24562.     end Insert; 
  24563. -----------------I N S E R T--IDENTIFIER--NAMED---TOKEN-------------
  24564. --
  24565. -- Purpose: 
  24566. -- -------
  24567. --     Inserts an identifier item into a named list.  Specifying Position
  24568. --     as zero results in the identifier being at the head of the List.
  24569. --     Use_Error or Search_Error may be raised indicating identifier item
  24570. --     has not been inserted.
  24571. --
  24572. -- Parameters:
  24573. -- ----------
  24574. --     List       is the named list of interest
  24575. --     List_Item  is the identifier value to be inserted
  24576. --     Named      is the name (in token format) of an identifier in List which
  24577. --                will be replaced
  24578. --     Position   is the position of the item after which the Identifier is
  24579. --                inserted
  24580. -- Exceptions: 
  24581. -- ----------  
  24582. --     Use_Error     is raised if this is a positional list,
  24583. --                   or if position exceeds the size of the list.
  24584. --
  24585. -- Notes: MIL_STD CAIS 5.4.1.20.6
  24586. -- -----
  24587. --
  24588. ----------------------------------------------------------------
  24589.  
  24590.     procedure Insert(List      : in out List_Type; 
  24591.                      List_Item : in Token_Type; 
  24592.                      Named     : in Token_Type; 
  24593.                      Position  : in Count) is 
  24594.     begin
  24595.         Insert(List, List_Item, Retrieve(Named), Position); 
  24596.     end Insert; 
  24597. -----------P O S I T I O N _ B Y _ V A L U E------IDENTIFIER----------
  24598. --
  24599. -- Purpose:
  24600. -- -------  
  24601. --     Returns the position at which the next identifier_item of the given
  24602. --     value is located. the search begins at the Start_Position and ends
  24603. --     when either an item of Value is found, the last item of the list
  24604. --     has been examined, or the item at the End_Position has been 
  24605. --     examined, whichever comes first.
  24606. --
  24607. -- Parameters:
  24608. -- ----------
  24609. --     List           is the list_type of interest
  24610. --     Value          is the value of identifier being looked for
  24611. --     Start_Position is the position of the starting item in the search
  24612. --     End_Position   is the position of the ending   item in the search
  24613. --     return         the position of an item whose value matches
  24614. --
  24615. -- Exceptions:
  24616. -- ----------
  24617. --     Use_Error     raised if Start<End or Start > length of list
  24618. --     Search_Error  raised if Value not found in specified range
  24619. --
  24620. -- Notes: MIL_STD CAIS 5.4.1.20.7
  24621. -- -----
  24622. --
  24623. ----------------------------------------------------------------
  24624.     function Position_By_Value(List           : in List_Type; 
  24625.                                Value          : in Token_Type; 
  24626.                                Start_Position : in Position_Count := 
  24627.                                    Position_Count'First; 
  24628.                                End_Position   : in Position_Count := 
  24629.                                    Position_Count'Last) return Position_Count
  24630.         is 
  24631.         Pos     : Position_Count := 1; 
  24632.         Current : List_Type := List; 
  24633.  
  24634.     begin
  24635.         if Start_Position > End_Position then   --Valid Range??
  24636.             raise Use_Error; 
  24637.         end if; 
  24638.  
  24639.         while Pos < Start_Position loop         --Move to Start
  24640.             if Current = null then                  --End of list
  24641.                 raise Use_Error; 
  24642.             end if; 
  24643.  
  24644.             Pos := Pos + 1; 
  24645.             Current := Current.Next_Item; 
  24646.         end loop; 
  24647.  
  24648.         while Pos <= End_Position loop          --Check each item in range
  24649.             if Current = null then                  --End of List?
  24650.                 raise Search_Error; 
  24651.             end if; 
  24652.  
  24653.             if Current.Kind = Identifier_Item and then Is_Equal(Current.Element
  24654.                 , Value) then 
  24655.                 return Pos;                         --Match found
  24656.             end if; 
  24657.  
  24658.             Pos := Pos + 1; 
  24659.             Current := Current.Next_Item; 
  24660.         end loop; 
  24661.  
  24662.         raise Search_Error;                             --!!!No match
  24663.     end Position_By_Value; 
  24664.  
  24665. end Identifier_Items; 
  24666. --::::::::::::::
  24667. --invoke_process.a
  24668. --::::::::::::::
  24669.  
  24670.  
  24671. ----------------------------------------------------------------------
  24672. --                            Invoke_Process
  24673. --
  24674. --
  24675. --               Separate subprogram in package Process_Control
  24676. --
  24677. --
  24678. --
  24679. --
  24680. --
  24681. --                  Ada Software Engineering Group
  24682. --                      The MITRE Corporation
  24683. --                         McLean, VA 22102
  24684. --
  24685. --
  24686. --                   Wed Aug 21 21:16:42 EST 1985
  24687. --
  24688. --                 (Unclassified and uncopyrighted)
  24689. --
  24690. ----------------------------------------------------------------------
  24691.  
  24692. ----------------- I N V O K E _ P R O C E S S  ----------------------
  24693. --
  24694. --  Purpose:
  24695. --  -------
  24696. --    This procedure creates a new process node whose contents represent
  24697. --    the execution of the program contained in the specified file node.
  24698. --    Control returns to the calling task after the new process is 
  24699. --    terminated.  
  24700. --
  24701. --  Parameters:
  24702. --  ----------
  24703. --    Node              - node handle returned open on the new process node
  24704. --    File_Node         - open node handle on the file node containing the
  24705. --                        executable image whose execution will be 
  24706. --                        represented by the new process
  24707. --    Results_Returned  - list of results which are represented by strings
  24708. --                        from the new process.  
  24709. --    Status            - the process status of the process.  
  24710. --    Input_Parameters  - a list containing process parameter information.
  24711. --    Key               - the relationship key of the primary relationship
  24712. --                        from the current process node to the new process
  24713. --                        node.
  24714. --    Relation          - the relation name of the primary relationship
  24715. --                        from the current process node to the new node.
  24716. --    Access_Control    - defines the initial access control information
  24717. --                        associated with the created node.
  24718. --    Level             - defines the classification label for the created
  24719. --                        node.
  24720. --    Attributes        - a list which can be used to set attributes of the
  24721. --                        new node.
  24722. --    Input_File        - pathname for standard input for the new process
  24723. --    Output_File       - pathname for standard output for the new process
  24724. --    Error_File        - pathname for error output for the new process
  24725. --    Environment_Node  - the node the new process will have as its current
  24726. --                        node
  24727. --    Time_Limit        - the limit on the time that the calling task will
  24728. --                        be suspended awaiting the new process.  When
  24729. --                        the limit is exceeded, the calling task resumes
  24730. --                        execution.
  24731.  
  24732. --
  24733. --  Exceptions:
  24734. --  ----------
  24735. --    Name_Error        - raised if a node alreadyt exists for the 
  24736. --                        relationship specified by Key and Relation.
  24737. --                        Name_Error is also raised if any of the nodes
  24738. --                        identified by Input_File, Output_File,
  24739. --                        Error_File, or Environment_Node do not exist.
  24740. --                        It is also raised if Key or Relation is 
  24741. --                        syntactically illegal or if any node identifying
  24742. --                        a group specified in the given  Access_Control
  24743. --                        parameter is unobtainable or inaccessible.
  24744. --    Use_Error         - is raised if it can be determined that the node
  24745. --                        indicated by File_Node does not contain an executable
  24746. --                        image.  Use_Error is also raised if any of the
  24747. --                        parameters Input_Paramters, Level, Access_Control,
  24748. --                        or Attributes is syntactically illegal.  Use_Error
  24749. --                        is also raised if Relation is the name of a 
  24750. --                        predefined relation or if the Attributes parameter
  24751. --                        contains references to a predefined attribute which
  24752. --                        cannot be modified or created by the user.
  24753. --    Status_Error      - is raised if Node is an open node handle prior to 
  24754. --                        the call or if File_Node is not an open node handle.
  24755. --    Lock_Error        - is raised if access with intent Append_Relationships
  24756. --                        cannot be obtained to the current process node due
  24757. --                        to an existing lock on the node.
  24758. --    Intent_Violation  - is raised if the node designated by File_Node was
  24759. --                        not opened with an intent establishing the right
  24760. --                        to execute contents.
  24761. --
  24762. --  Notes:   MIL-STD-CAIS 5.2.2.3
  24763. --  -----
  24764. --
  24765. ---------------------------------------------------------------------
  24766.  
  24767.  
  24768.  
  24769. with System; 
  24770.  
  24771. separate(Cais.Process_Control)
  24772. procedure Invoke_Process(Node             : in out Node_Type; 
  24773.                          File_Node        : Node_Type; 
  24774.                          Results_Returned : in out Results_List; 
  24775.                          Status           : in out Process_Status; 
  24776.                          Input_Parameters : Parameter_List; 
  24777.                          Key              : Relationship_Key := Latest_Key; 
  24778.                          Relation         : Relation_Name := Default_Relation; 
  24779.                          Access_Control   : List_Type := Empty_List; 
  24780.                          Level            : List_Type := Empty_List; 
  24781.                          Attributes       : List_Type := Empty_List; 
  24782.                          Input_File       : Name_String := Current_Input; 
  24783.                          Output_File      : Name_String := Current_Output; 
  24784.                          Error_File       : Name_String := Current_Error; 
  24785.                          Environment_Node : Name_String := Current_Node; 
  24786.                          Time_Limit       : Duration := Duration'Last) is 
  24787.  
  24788.  
  24789.     use Pragmatics; 
  24790.  
  24791.     Result : Integer; 
  24792.     Pgm    : String(1 .. Pragmatics.Max_Contents_File_Length); 
  24793.     Length : Positive; 
  24794.  
  24795.     function Simple_Fork(Pgmname : System.Address; 
  24796.                          Chars   : Positive) return Integer; 
  24797.     pragma Interface(C, Simple_Fork); 
  24798.  
  24799. begin
  24800.  
  24801.     if Node_Representation.Open_Status(Node) then 
  24802.         raise Node_Definitions.Status_Error; 
  24803.     end if; 
  24804.  
  24805.     Node_Representation.Get_Contents_File_Name(File_Node, Pgm, Length); 
  24806.     Result := Simple_Fork(Pgm'Address, Length); 
  24807.     if Result =  -1 then 
  24808.         raise Node_Definitions.Use_Error; 
  24809.     end if; 
  24810.  
  24811. exception
  24812.     -- exceptions that are trapped (nothing propagated)
  24813.         -- NONE.
  24814.     -- exceptions that are propagated
  24815.     when Node_Definitions.Use_Error | Node_Definitions.Status_Error => 
  24816.         raise; 
  24817.     -- exceptions that are mapped to other exceptions
  24818.         -- NONE.
  24819.     -- predefined exceptions (propagated with trace)
  24820.     when Constraint_Error | Tasking_Error | Program_Error | Storage_Error | 
  24821.         Numeric_Error => 
  24822.         Trace.Report("PREDEFINED EXCEPTION in Invoke_Process "); 
  24823.         raise; 
  24824.     -- unanticipated exceptions
  24825.     when others => 
  24826.         Trace.Report("UNANTICIPATED EXCEPTION in Invoke_Process "); 
  24827.         raise Trace.Assertion_Violation; 
  24828.  
  24829. end Invoke_Process; 
  24830. --::::::::::::::
  24831. --io_control_body.a
  24832. --::::::::::::::
  24833. with Trace; 
  24834. separate(Cais)
  24835. package body Io_Control is 
  24836.     use Io_Definitions; 
  24837.     use Node_Definitions; 
  24838.     use List_Utilities; 
  24839.  
  24840.     procedure Open_File_Node(File       : File_Type; 
  24841.                              Node       : in out Node_Type; 
  24842.                              Intent     : Intention; 
  24843.                              Time_Limit : Duration := No_Delay) is 
  24844.     begin
  24845.         Trace.Assert_Fatal(False, "Open_File_Node is NOT implemented"); 
  24846.     end Open_File_Node; 
  24847.  
  24848.     procedure Synchronize(File : File_Type) is 
  24849.     begin
  24850.         Trace.Assert_Fatal(False, "Synchronize is NOT implemented"); 
  24851.     end Synchronize; 
  24852.  
  24853.     procedure Set_Log(File     : File_Type; 
  24854.                       Log_File : File_Type) is 
  24855.     begin
  24856.         Trace.Assert_Fatal(False, "Set_Log is NOT implemented"); 
  24857.     end Set_Log; 
  24858.  
  24859.     procedure Clear_Log(File : File_Type) is 
  24860.     begin
  24861.         Trace.Assert_Fatal(False, "Clear_Log is NOT implemented"); 
  24862.     end Clear_Log; 
  24863.  
  24864.     function Logging(File : File_Type) return Boolean is 
  24865.     begin
  24866.         Trace.Assert_Fatal(False, "Logging is NOT implemented"); 
  24867.         return False; 
  24868.     end Logging; 
  24869.  
  24870.     function Get_Log(File : File_Type) return File_Type is 
  24871.     begin
  24872.         Trace.Assert_Fatal(False, "Get_Log is NOT implemented"); 
  24873.         return File; 
  24874.     end Get_Log; 
  24875.  
  24876.     function Number_Of_Elements(File : File_Type) return Natural is 
  24877.     begin
  24878.         Trace.Assert_Fatal(False, "Number_Of_Elements is NOT implemented"); 
  24879.         return 1; 
  24880.     end Number_Of_Elements; 
  24881.  
  24882.     procedure Set_Prompt(Terminal : File_Type; 
  24883.                          Prompt   : String) is 
  24884.     begin
  24885.         Trace.Assert_Fatal(False, "Set_Prompt is NOT implemented"); 
  24886.     end Set_Prompt; 
  24887.  
  24888.     function Get_Prompt(Terminal : File_Type) return String is 
  24889.     begin
  24890.         Trace.Assert_Fatal(False, "Get_Prompt is NOT implemented"); 
  24891.         return ""; 
  24892.     end Get_Prompt; 
  24893.  
  24894.     function Intercepted_Characters(Terminal : File_Type) return Character_Array
  24895.         is 
  24896.     begin
  24897.         Trace.Assert_Fatal(False, "Intercepted_Characters is NOT implemented"); 
  24898.         return (Character'First .. Character'Last => False); 
  24899.     end Intercepted_Characters; 
  24900.  
  24901.     procedure Enable_Function_Keys(Terminal : File_Type; 
  24902.                                    Enable   : Boolean) is 
  24903.     begin
  24904.         Trace.Assert_Fatal(False, "Enable_Function_Keys is NOT implemented"); 
  24905.     end Enable_Function_Keys; 
  24906.  
  24907.     function Function_Keys_Enabled(Terminal : File_Type) return Boolean is 
  24908.     begin
  24909.         Trace.Assert_Fatal(False, "Function_Keys_Enabled is NOT implemented"); 
  24910.         return False; 
  24911.     end Function_Keys_Enabled; 
  24912.  
  24913.     procedure Couple(Queue_Base     : Node_Type; 
  24914.                      Queue_Key      : Relationship_Key := Latest_Key; 
  24915.                      Queue_Relation : Relation_Name := Default_Relation; 
  24916.                      File_Node      : Node_Type; 
  24917.                      Form           : List_Type := Empty_List; 
  24918.                      Attributes     : List_Type; 
  24919.                                             -- intentionally no default
  24920.                      Access_Control : List_Type := Empty_List; 
  24921.                      Level          : List_Type := Empty_List) is 
  24922.     begin
  24923.         Trace.Assert_Fatal(False, "Couple is NOT implemented"); 
  24924.     end Couple; 
  24925.  
  24926.     procedure Couple(Queue_Name     : Name_String; 
  24927.                      File_Node      : Node_Type; 
  24928.                      Form           : List_Type := Empty_List; 
  24929.                      Attributes     : List_Type; 
  24930.                      Access_Control : List_Type := Empty_List; 
  24931.                      Level          : List_Type := Empty_List) is 
  24932.     begin
  24933.         Trace.Assert_Fatal(False, "Couple is NOT implemented"); 
  24934.     end Couple; 
  24935.  
  24936.     procedure Couple(Queue_Base     : Node_Type; 
  24937.                      Queue_Key      : Relationship_Key := Latest_Key; 
  24938.                      Queue_Relation : Relation_Name := Default_Relation; 
  24939.                      File_Name      : Name_String; 
  24940.                      Form           : List_Type := Empty_List; 
  24941.                      Attributes     : List_Type; 
  24942.                      Access_Control : List_Type := Empty_List; 
  24943.                      Level          : List_Type := Empty_List) is 
  24944.     begin
  24945.         Trace.Assert_Fatal(False, "Couple is NOT implemented"); 
  24946.     end Couple; 
  24947.  
  24948.     procedure Couple(Queue_Name     : Name_String; 
  24949.                      File_Name      : Name_String; 
  24950.                      Form           : List_Type := Empty_List; 
  24951.                      Attributes     : List_Type; 
  24952.                      Access_Control : List_Type := Empty_List; 
  24953.                      Level          : List_Type := Empty_List) is 
  24954.     begin
  24955.         Trace.Assert_Fatal(False, "Couple is NOT implemented"); 
  24956.     end Couple; 
  24957.  
  24958.  
  24959.  
  24960. end Io_Control; 
  24961. --::::::::::::::
  24962. --iterator_support_body.a
  24963. --::::::::::::::
  24964.  
  24965.  
  24966. ----------------------------------------------------------------------
  24967. --                      ITERATOR_SUPPORT
  24968. --                       (Package Body)
  24969. --
  24970. --
  24971. --      This Package provides routines which support the pattern
  24972. --          matching and sorting requirements of iterators
  24973. --
  24974. --
  24975. --                  Ada Software Engineering Group
  24976. --                      The MITRE Corporation
  24977. --                         McLean, VA 22102
  24978. --
  24979. --
  24980. --                   Wed Oct  9 14:27:30 EDT 1985
  24981. --
  24982. --                 (Unclassified and uncopyrighted)
  24983. ----------------------------------------------------------------------
  24984. ----------------------------------------------------------------------
  24985. --
  24986. --  Purpose:
  24987. --  --------
  24988. --    This   package  provides  routines  which  support  pattern  matching
  24989. --    (including * and ? wild card characters)  and the  creation of sorted
  24990. --    lists.  These  capabilities are  required  for the  implementation of
  24991. --    Node and Attribute Iterators.  The iterator is  implemented as a list
  24992. --    of the format defined by the  package  CAIS_list_utilities (CAIS  1.4
  24993. --    section  5.4).
  24994. --
  24995. --  Usage:
  24996. --  -----
  24997. --    Patterns are represented by character strings, which must conform  to
  24998. --    the rules for Ada identifiers except that wildcard characters  may be
  24999. --    included.  A routine is provided to validate patterns to these rules.
  25000. --    Another routine matches a token against a  pattern and another  finds
  25001. --    the lexicographic position within an already sorted list at which  to
  25002. --    insert a token.
  25003. --
  25004. --  Example:
  25005. --  -------
  25006. --    Verify_Pattern("*_body?");            --valid pattern
  25007. --    Verify_Pattern("*__spec");            --use_error __
  25008. --    Verify_Pattern("*.body?");            --use_error . no good
  25009. --                --checks attribute against pattern and if
  25010. --                --it matches saves it in alphabetized list
  25011. --    if Pattern_Match(Attribute,"T???") then
  25012. --        Insert(Found, Attribute, Lexical_Position(Found, Attribute));
  25013. --    end if;
  25014. --
  25015. --  Notes:
  25016. --  -----
  25017. --    This is a version of the package CAIS_ATTRIBUTES,  specified  in
  25018. --    MIL-STD-CAIS section 5.1.3; all references to the CAIS specification
  25019. --    refer to the MIL-STD-CAIS specification dated 31 January 1985.
  25020. --
  25021. --  Revision History:
  25022. --  ----------------
  25023. --    12-04-85    Removed reference to V_String.  The > function for
  25024. --            tokens was copied from V_String into Lexical_Position 
  25025. -------------------------------------------------------------------
  25026.  
  25027. separate(Cais)
  25028. package body Iterator_Support is 
  25029.  
  25030.     use List_Utilities; 
  25031.     use Node_Definitions; 
  25032.     use Identifier_Items; 
  25033. ----------------------   Lexical_Position     ---------------------------
  25034. --
  25035. --  Purpose: This function searches an alphebetized list returning the
  25036. --  -------  position at which the new named item should be inserted
  25037. --
  25038. --  Parameters:
  25039. --  ----------
  25040. --    List    is the named list being searched (names are assumed to be sorted)
  25041. --    Name    is the name of the new item to be inserted
  25042. --    returns Pos where the named item should be inserted
  25043. --
  25044. --  Exceptions:
  25045. --  ----------
  25046. --   None
  25047. --
  25048. --  Notes:
  25049. --  -----
  25050. --
  25051. ---------------------------------------------------------------------------
  25052.     function Lexical_Position(List : in List_Type; 
  25053.                               Name : in Token_Type) return Count is 
  25054.         Pos       : Count := Length(List); 
  25055.         List_Name : Token_Type; 
  25056.  
  25057.  
  25058. --------------------------------------------------------------------------
  25059. --   >  Compares two Tokens on a character-by-character basis. Longer
  25060. --    Tokens whose heads match another Token are considered >.
  25061. --    Greater means later in alphanumeric order.  That is:
  25062. --        z > a        zz > z      a2 > a1
  25063. --------------------------------------------------------------------------
  25064.         function ">"(L_Side : in Token_Type; 
  25065.                      R_Side : in Token_Type) return Boolean is 
  25066.             Left_Side    : String(1 .. To_Text(L_Side)'Length) := To_Text(L_Side
  25067.                 ); 
  25068.             Right_Side   : String(1 .. To_Text(R_Side)'Length) := To_Text(R_Side
  25069.                 ); 
  25070.             Minimum_Size : Integer; 
  25071.                                    --The smaller of the two sizes
  25072.             Greater_Than : Boolean; 
  25073.                                    --Holds comaprison results as each character
  25074.                                    --is checked
  25075.         begin
  25076.             if Left_Side'Length = 1 and then Left_Side(1) = Ascii.Nul then 
  25077.                                                                 --Left null
  25078.                 return False; 
  25079.             elsif Right_Side'Length = 1 and then Right_Side(1) = Ascii.Nul then 
  25080.                                                                 --Right null
  25081.                 return True; 
  25082.             else                                                --Two strings
  25083.                 if Left_Side'Length > Right_Side'Length then 
  25084.                     Minimum_Size := Right_Side'Length; 
  25085.                     Greater_Than := True;       --wins  if substrings match
  25086.                 else 
  25087.                     Minimum_Size := Left_Side'Length; 
  25088.                     Greater_Than := False;      --fails if substrings match
  25089.                 end if; 
  25090.  
  25091.                 for I in 1 .. Minimum_Size loop
  25092.                     if Left_Side(I) > Right_Side(I) then 
  25093.                         Greater_Than := True; 
  25094.                         exit; 
  25095.                     elsif Left_Side(I) < Right_Side(I) then 
  25096.                         Greater_Than := False; 
  25097.                         exit; 
  25098.                     end if; 
  25099.                 end loop; 
  25100.                 return Greater_Than; 
  25101.             end if; 
  25102.         end ">"; 
  25103.  
  25104.  
  25105.  
  25106.     begin
  25107.         for I in reverse 1 .. Length(List) loop
  25108.             Item_Name(List, I, List_Name); 
  25109.             exit when Name > List_Name; 
  25110.             Pos := Pos - 1; 
  25111.         end loop; 
  25112.         return Pos; 
  25113.     end Lexical_Position; 
  25114. ----------------------   Verify_Pattern   --------------------------------
  25115. --
  25116. --  Purpose: This procedure checks that a Pattern string conforms to the
  25117. --  -------  syntax for identifiers with the addition of wildcard characters
  25118. --           '?' and '*'.  It also allows trailing blanks and returns the
  25119. --           length of the pattern minus any trailing blanks.
  25120. --
  25121. --  Parameters:
  25122. --  ----------
  25123. --    Pattern      is the pattern string to be checked for conformance
  25124. --    Size       is returned with the length of Pattern less trailing ' 's
  25125. --
  25126. --  Exceptions:
  25127. --  ----------
  25128. --   Use_Error       is raised if the pattern fails conformance
  25129. --
  25130. --
  25131. --  Notes:
  25132. --  -----
  25133. --
  25134. ---------------------------------------------------------------------------
  25135.     procedure Verify_Pattern(Pattern : in String; 
  25136.                              Size    : in out Integer) is 
  25137.         Work_Pattern : String(Pattern'First .. Pattern'Last) := Pattern; 
  25138.         Token        : Token_Type; 
  25139.     begin
  25140.         Size := Pattern'Last;                   --Remove trailing blanks
  25141.         while Work_Pattern(Size) = ' ' loop
  25142.             if Size = Pattern'First then                --All blanks
  25143.                 raise Use_Error; 
  25144.             end if; 
  25145.         end loop; 
  25146.  
  25147.         for I in 1 .. Size loop                 --Convert wildcards
  25148.             if Work_Pattern(I) = '?' then 
  25149.                 Work_Pattern(I) := 'A'; 
  25150.             elsif Work_Pattern(I) = '*' then 
  25151.                 Work_Pattern(I) := 'A'; 
  25152.             end if; 
  25153.         end loop; 
  25154.                                                 --Check Syntax
  25155.         Identifier_Items.To_Token(Work_Pattern(Pattern'First .. Size), Token); 
  25156.  
  25157.     end Verify_Pattern; 
  25158. ----------------------   Pattern_Match   ---------------------------
  25159. --
  25160. --  Purpose: returns true if Canditate string conforms to the pattern
  25161. --  -------  which may contain ?s (any character) or *s (any string).
  25162. --
  25163. --  Parameters:
  25164. --  ----------
  25165. --    Candidate is a character string to be checked for conformance
  25166. --    Pattern   is a character string which defines conformance rules
  25167. --
  25168. --  Exceptions: None
  25169. --  ----------
  25170. --
  25171. --  Notes:
  25172. --  -----
  25173. --
  25174. ---------------------------------------------------------------------------
  25175.     function Pattern_Match(Candidate : in String; 
  25176.                                         --string to be checked
  25177.                            Pattern   : in String)
  25178.                                         --acceptance criteria
  25179.     return Boolean is 
  25180.         Can_Pos : Integer := 0;  --position of current character in Candidate
  25181.         Pat_Pos : Integer := 0;  --position of current character in Pattern
  25182.         Restart : Integer := 0;  --position in Pattern at which to resume
  25183.                                  --after a character mismatch
  25184.  
  25185.         procedure Get_Pattern_Pos is 
  25186.         begin
  25187.             Pat_Pos := Pat_Pos + 1;       --Get next pattern char, check for *
  25188.             while Pat_Pos <= Pattern'Length and then Pattern(Pat_Pos) = '*' loop
  25189.                                           --A string of *s is equivalent to a
  25190.                 Pat_Pos := Pat_Pos + 1;           --single *
  25191.                 Restart := Pat_Pos; 
  25192.             end loop; 
  25193.         end Get_Pattern_Pos; 
  25194.  
  25195.         function Character_Match        --performs a single character test
  25196.         return Boolean is               --for equality regardless of case
  25197.         begin                           --and always recognizing ? as a match
  25198.             if Pattern(Pat_Pos) = '?' then                        --wildcard
  25199.                 return True; 
  25200.             elsif Candidate(Can_Pos) = Pattern(Pat_Pos) then      --exact match
  25201.                 return True; 
  25202.             elsif Pattern(Pat_Pos) in 'a' .. 'z' and then Character'Val(
  25203.                 Character'Pos(Pattern(Pat_Pos)) - 32) =           --raise case
  25204.             Candidate(Can_Pos) then 
  25205.                 return True; 
  25206.                                                 --Note, there is no need
  25207.                                                 --to lower case since
  25208.                                                 --all candidates are 
  25209.                                                 --upper case
  25210.             else 
  25211.                 return False; 
  25212.             end if; 
  25213.         end Character_Match; 
  25214.  
  25215.     begin
  25216.         Get_Pattern_Pos;                    --Get 1st pattern char, check for *
  25217.  
  25218.                 --On each pass of this loop a new character is pulled
  25219.                 --from the candidate string.  On matches, a new
  25220.                 --character is pulled from the pattern.  On mismathches
  25221.                 --the pattern is reset to the most recent * or failure
  25222.                 --is reported.
  25223.         while Pat_Pos <= Pattern'Length loop
  25224.             Can_Pos := Can_Pos + 1;         --Get next candidate char
  25225.             if Can_Pos > Candidate'Length then 
  25226.                                             --Match fails because pattern
  25227.                 return False;               --still expects more characters
  25228.             end if; 
  25229.  
  25230.             if Character_Match then                             --char or wildcard match
  25231.                 Get_Pattern_Pos; 
  25232.                 if Pat_Pos > Pattern'Last and then      --after a match, if the
  25233.                 Can_Pos < Candidate'Last and then       --pattern is exhausted
  25234.                 Restart /= 0 then                       --and the candidate is
  25235.                     Pat_Pos := Restart;                 --not, and a * occurred
  25236.                 end if;                                 --restart.  But don't
  25237.                                                         --recheck this char.
  25238.                                                         --ex.  xxaa .vs. *a
  25239.  
  25240.             elsif Restart /= 0 then                     --*_string   match
  25241.                 Pat_Pos := Restart;                                --so reset pattern
  25242.                 if Character_Match then                    --recheck this char
  25243.                     Get_Pattern_Pos; 
  25244.                 end if; 
  25245.  
  25246.             else                                        --match fails
  25247.                 return False; 
  25248.             end if; 
  25249.         end loop; 
  25250.  
  25251.                 --At end of loop the pattern has been exhausted.
  25252.                 --A match occurs if candidate is also exhausted
  25253.                 --or if last pattern character was a *.
  25254.         if Can_Pos = Candidate'Length then 
  25255.             return True; 
  25256.         elsif Pattern(Pattern'Length) = '*' then 
  25257.             return True; 
  25258.         else 
  25259.             return False; 
  25260.         end if; 
  25261.     end Pattern_Match; 
  25262.  
  25263. end Iterator_Support; 
  25264. --::::::::::::::
  25265. --list_utilities_body.a
  25266. --::::::::::::::
  25267.  
  25268.  
  25269.  
  25270. ----------------------------------------------------------------------
  25271. --                   L I S T _ U T I L I T I E S
  25272. --                          (Package Body)
  25273. --
  25274. --           Operations for manipulating objects of List_Type
  25275. --
  25276. --
  25277. --                  Ada Software Engineering Group
  25278. --                      The MITRE Corporation
  25279. --                         McLean, VA 22102
  25280. --
  25281. --
  25282. --                   Tue Oct  8 16:40:23 EDT 1985
  25283. --
  25284. --                 (Unclassified and uncopyrighted)
  25285. --
  25286. ----------------------------------------------------------------------
  25287. ----------------------------------------------------------------------
  25288. --                   L I S T _ U T I L I T I E S
  25289. --
  25290. --  Purpose:
  25291. --  -------
  25292. --    List_Utilities provides operations for objects of List_Type.  These
  25293. --    objects are heterogeneous lists of string, integer, float, sub-list,
  25294. --    and list items.  Operations provided include Insert, Extract, Replace,
  25295. --    Delete, and a value search.  Conmversions to and from text are also
  25296. --    provided.  Lists may be named or unnamed.  Related packages are
  25297. --    String_Items, Identifier_Items, Integer_Items, and Float_Items.
  25298. --
  25299. --  Usage:
  25300. --  -----
  25301. --    Lists are used to represent attribute values and parameters in CAIS.
  25302. --    Implementations may use Lists to represent relationships.
  25303. --
  25304. --  Example:
  25305. --  -------
  25306. --        To_List("(Integers=>(1,2), Identifier=>Ada_Name)", Sample);
  25307. --        Extract(Sample, 1, Integer_List);
  25308. --
  25309. --  Notes:
  25310. --  -----
  25311. --    The visibility of the internal package V_String is questionable and
  25312. --    should possibly be hidden.
  25313. --
  25314. --  Revision History:
  25315. --  ----------------
  25316. --    12-01-85 Removed enclosing (and doubled) quotes from the internal
  25317. --         representation of string_items.  Quotes must now be added
  25318. --         for external representations of list.
  25319. --          #Validate_Items: avoided using Parse_Token on string_items
  25320. --          #To_Text: appende enclosing "s and doubled embedded "s
  25321. --          #Text_Length: increased count by (2 + No. of embedded "s)
  25322. --          #Text_Length(Items): now return Natural since length may be 0
  25323. --    12-01-85 Added specification for V_String which was removed from
  25324. --         List_Utilities-Spec.  V_String is now hidden in List_Utilities
  25325. -------------------------------------------------------------------
  25326.  
  25327. separate(Cais)
  25328. package body List_Utilities is 
  25329.  
  25330.     use Node_Definitions; 
  25331.  
  25332. --------------------------------------------------------------------------
  25333. --   S E P A R A T E     P A C K A G E   V _ S T R I N G
  25334. --Processing support for Token_Type
  25335. --------------------------------------------------------------------------
  25336.     package V_String is 
  25337.  
  25338.         procedure Store(String_Value : in String; 
  25339.                         Access_Key   : in out Token_Type); 
  25340.  
  25341.         function Retrieve(Access_Key : in Token_Type) return String; 
  25342.  
  25343.         function Length(Access_Key : in Token_Type) return Natural; 
  25344.  
  25345.         function Is_Equal(Left_Side  : in Token_Type; 
  25346.                           Right_Side : in Token_Type) return Boolean; 
  25347.  
  25348.         function ">"(Left_Side  : in Token_Type; 
  25349.                      Right_Side : in Token_Type) return Boolean; 
  25350.  
  25351.         function Is_Equal(Left_Side  : in Token_Type; 
  25352.                           Right_Side : in String) return Boolean; 
  25353.  
  25354.         procedure Copy(To   : in out Token_Type; 
  25355.                        From : in Token_Type); 
  25356.     end V_String; 
  25357.     package body V_String is separate; 
  25358.     use V_String; 
  25359.  
  25360.     procedure Dump(List : in List_Type) is separate; 
  25361.  
  25362. --------------P O S I T I O N _ O F------POSITIONAL ITEM------------------
  25363. --
  25364. -- Purpose: 
  25365. -- -------
  25366. --     Searches a list for the position corresponding to the item pointer
  25367. --
  25368. -- Parameters:
  25369. -- ----------
  25370. --     List       is the list_type to be searched, either named or positional
  25371. --     This_Item  is a ptr to an item within List
  25372. --     return     the position of This_Item within List
  25373. --            
  25374. -- Exceptions:
  25375. -- ----------
  25376. --     None
  25377. --
  25378. -- Notes: 
  25379. -- -----
  25380. --     Assumes that the item pointer validly points to an item within the
  25381. --     list.
  25382. --
  25383. ----------------------------------------------------------------
  25384.     function Position_Of(List      : List_Type; 
  25385.                                            --list to be searched
  25386.                          This_Item : in List_Type)
  25387.                                            --pointer to desired item
  25388.     return Position_Count is               --Position of desired item
  25389.         Position : Position_Count := 1; 
  25390.         Current  : List_Type := List; 
  25391.     begin
  25392.         while This_Item /= Current loop
  25393.             Position := Position + 1; 
  25394.             Current := Current.Next_Item; 
  25395.         end loop; 
  25396.         return Position; 
  25397.     end Position_Of; 
  25398.  
  25399. ------------------F I N D------POSITIONAL ITEM------------------
  25400. --
  25401. -- Purpose: 
  25402. -- -------
  25403. --     Searches an unnamed list for the nth item.
  25404. --
  25405. -- Parameters:
  25406. -- ----------
  25407. --      List       is the list to be searched, must be unnamed
  25408. --      Index      is the Position of desired item
  25409. --      Current    is the pointer computed for desired item
  25410. --            
  25411. --
  25412. -- Exceptions:
  25413. -- ----------
  25414. --     Use_Error        is raised if this is a named list
  25415. --                      or if Position > no. items in list
  25416. --
  25417. -- Notes: 
  25418. -- -----
  25419. --    None
  25420. --
  25421. ----------------------------------------------------------------
  25422.     procedure Find(List    : List_Type;    --list to be searched
  25423.                    Index   : Position_Count; 
  25424.                                            --Position of desired item
  25425.                    Current : in out List_Type) is 
  25426.                                            --pointer to desired item
  25427.     begin
  25428.         if List /= null and then List.Name /= null then 
  25429.             raise Use_Error;                            --Named List!!
  25430.         end if; 
  25431.  
  25432.         Current := List; 
  25433.         for I in 1 .. Index - 1 loop
  25434.             Current := Current.Next_Item; 
  25435.         end loop; 
  25436.         if Current = null then 
  25437.             raise Use_Error;                     --Position too high!!
  25438.         end if; 
  25439.     exception
  25440.         when Constraint_Error => 
  25441.             raise Use_Error; 
  25442.     end Find; 
  25443.  
  25444. ------------------F I N D _ A L L------POSITIONAL ITEM IN ANY LIST----
  25445. --
  25446. -- Purpose: 
  25447. -- -------
  25448. --     Searches either an unnamed or a named list for the nth item. 
  25449. --     This is identical to the Find for a positional list except that
  25450. --     here no Use_Error is raised.
  25451. --
  25452. -- Parameters:
  25453. -- ----------
  25454. --      List       is the list to be searched, may be either named or unnamed
  25455. --      Index      is the Position of desired item
  25456. --      Current    is the pointer computed for desired item
  25457. --            
  25458. --
  25459. -- Exceptions: 
  25460. -- ----------  
  25461. --      Use_Error     is raised if Position > no. items in list
  25462. --
  25463. -- Notes:
  25464. -- ----- 
  25465. --    None
  25466. --
  25467. ----------------------------------------------------------------
  25468.     procedure Find_All(List    : List_Type; --list to be searched
  25469.                        Index   : Position_Count; 
  25470.                                             --Position of desired item
  25471.                        Current : in out List_Type) is 
  25472.                                             --pointer to desired item
  25473.     begin
  25474.  
  25475.         Current := List; 
  25476.         for I in 1 .. Index - 1 loop
  25477.             Current := Current.Next_Item; 
  25478.         end loop; 
  25479.         if Current = null then 
  25480.             raise Use_Error;                     --Position too high!!
  25481.         end if; 
  25482.     exception
  25483.         when Constraint_Error => 
  25484.             raise Use_Error; 
  25485.     end Find_All; 
  25486. ------------------F I N D------NAMED      ITEM------------------
  25487. --
  25488. -- Purpose: 
  25489. -- -------
  25490. --     Searches an named list for the  item with matching name.
  25491. --    
  25492. --
  25493. --
  25494. -- Parameters:
  25495. -- ----------
  25496. --      List       is the list to be searched, must be named
  25497. --      Named      is the Name of desired item
  25498. --      Current    is the pointer computed for desired item
  25499. --            
  25500. --            
  25501. --
  25502. -- Exceptions: 
  25503. -- ----------  
  25504. --     Use_Error        is raised if this is an unnamed list
  25505. --     Search_Error     is raised if Position > no. items in list
  25506. --
  25507. --
  25508. -- Notes:    
  25509. -- -----
  25510. --     None
  25511. --
  25512. ----------------------------------------------------------------
  25513.     procedure Find(List    : List_Type;        --list to be searched
  25514.                    Named   : Namestring;      --Name of desired item
  25515.                    Current : in out List_Type) is 
  25516.                                                --pointer to desired item
  25517.  
  25518.     begin
  25519.         if List /= null and then List.Name = null then 
  25520.             raise Use_Error;                            --UNNamed List!!
  25521.         end if; 
  25522.  
  25523.         Current := List; 
  25524.         if Current = null then 
  25525.             raise Use_Error; 
  25526.         end if; 
  25527.         while not Is_Equal(Current.Name, Named) loop
  25528.             Current := Current.Next_Item; 
  25529.             if Current = null then 
  25530.                 raise Search_Error;                     --Position too high!!
  25531.             end if; 
  25532.         end loop; 
  25533.     end Find; 
  25534.  
  25535. -------------------N A M E _ C H E C K---NAME vs LIST-----------
  25536. --
  25537. -- Purpose:
  25538. -- ---------
  25539. --    Checks the provided name against each name in the list and 
  25540. --    raises use error if a match occurs.
  25541. --
  25542. -- Parameters:
  25543. -- ----------
  25544. --    List    is an existing named list whose names are searched
  25545. --    Named   is the candidate name being checked for uniqueness
  25546. --
  25547. -- Exceptions:
  25548. -- ----------
  25549. --    Use_Error is raised if Name matches any of the item names in list
  25550. --
  25551. -- Notes:
  25552. -- -----
  25553. --    None
  25554. ----------------------------------------------------------------
  25555.     procedure Name_Check(List  : in List_Type; 
  25556.                          Named : in Token_Type) is 
  25557.         Current : List_Type := List; 
  25558.     begin
  25559.         while Current /= null loop
  25560.             if Is_Equal(Current.Name, Named) then 
  25561.                 raise Use_Error; 
  25562.             end if; 
  25563.             Current := Current.Next_Item; 
  25564.         end loop; 
  25565.     end Name_Check; 
  25566. -------------------N A M E _ C H E C K---LIST vs LIST-----------
  25567. --
  25568. -- Purpose:
  25569. -- ---------
  25570. --    Checks each name in the first list against each name in the
  25571. --    second list and raises use error if a match occurs.
  25572. --
  25573. -- Parameters:
  25574. -- ----------
  25575. --    List1   is an existing named list whose names are searched
  25576. --    List2   is a second list whose names must be unique from List2
  25577. --
  25578. -- Exceptions:
  25579. -- ----------
  25580. --    Use_Error is propogated if any Name from List1 matches any
  25581. --              of the item names in list2
  25582. --
  25583. -- Notes:
  25584. -- -----
  25585. --    None
  25586. ----------------------------------------------------------------
  25587.     procedure Name_Check(List1 : in List_Type; 
  25588.                          List2 : in List_Type) is 
  25589.         Current : List_Type := List2; 
  25590.     begin
  25591.         while Current /= null and then Current.Name /= null loop
  25592.             Name_Check(List1, Current.Name); 
  25593.             Current := Current.Next_Item; 
  25594.         end loop; 
  25595.     end Name_Check; 
  25596. ------------------------------------------------------------------
  25597. --           D E C L A R E         P A R S E _ T O K E N (RECURSIVE)
  25598. ------------------------------------------------------------------
  25599.     procedure Parse_Token(List_Literal : in List_Text; 
  25600.                           Pos          : in out Natural; 
  25601.                           Token        : in out String; 
  25602.                           Token_Pos    : in out Natural; 
  25603.                           Token_Kind   : in out Item_Kind; 
  25604.                           Sublist      : in out List_Type); 
  25605.  
  25606.  
  25607.  
  25608. ----------------------------------------------------------------------
  25609. --           S E P A R A T E       P A R S E _ L I S T
  25610. ----------------------------------------------------------------------
  25611.     procedure Parse_List(List_Literal : in String; 
  25612.                                            --text being parsed
  25613.                          Pos          : in out Natural; 
  25614.                                            --next char to be viewed
  25615.                          List         : in out List_Type) is separate; 
  25616.  
  25617.  
  25618.  
  25619. ------------------------------------------------------------------
  25620. --           S E P A R A T E       P A R S E _ T O K E N
  25621. ------------------------------------------------------------------
  25622.     procedure Parse_Token(List_Literal : in List_Text; 
  25623.                           Pos          : in out Natural; 
  25624.                           Token        : in out String; 
  25625.                           Token_Pos    : in out Natural; 
  25626.                           Token_Kind   : in out Item_Kind; 
  25627.                           Sublist      : in out List_Type) is separate; 
  25628. ------------------V A L I D A T E - I T E M---------------------
  25629. --
  25630. -- Purpose:
  25631. -- ---------
  25632. --    Parses an input character string, determining the Item_Kind and
  25633. --    compares that against the desired Item_Kind.  If the string parses
  25634. --    properly and is of the proper Item_Kind, then Validate_Token returns
  25635. --    the token representation of string in Token.  Otherwise Use error is
  25636. --    raised.
  25637. --
  25638. -- Parameters:
  25639. -- ----------
  25640. --    List_Item     is the character string to be parsed
  25641. --    Kind_Of_Item  is the required Item_Type
  25642. --    Token         is the validated Token_Type which is returned
  25643. --   
  25644. -- Exceptions:
  25645. -- ----------
  25646. --    Use_Error is raised for illegally formed strings or for a string of
  25647. --              an Item_Kind other than the one desired
  25648. --
  25649. -- Notes: 
  25650. -- -----
  25651. --    None
  25652. ---------------------------------------------------------------------
  25653.     procedure Validate_Item(List_Item    : in String; 
  25654.                             Kind_Of_Item : in Item_Kind; 
  25655.                             Token        : in out Token_Type) is 
  25656.         Pos        : Natural := List_Item'First; 
  25657.                                     --set by Parse_Token to last char processed
  25658.         Token_Val  : String(1 .. List_Item'Length);  --value from Parse_Token
  25659.         Token_Size : Natural := 0;  --length of Token returned by Parse_Token
  25660.         Token_Kind : Item_Kind;     --kind of Token found by Parse_Token
  25661.         Sublist    : List_Type;     --required by Parse_Token, only for lists
  25662.     begin
  25663.         if Kind_Of_Item = String_Item then      --Don't check strings.  Quotes
  25664.             Store(List_Item, Token);            --aren't required except as
  25665.             return;                             --part of a list.  All strings
  25666.         end if;                                 --are valid.
  25667.  
  25668.  
  25669.         Parse_Token(List_Item & ')', Pos, Token_Val, Token_Size, Token_Kind, 
  25670.             Sublist); 
  25671.         if Token_Kind /= Kind_Of_Item or Pos <= List_Item'Length or
  25672.     (Token_Kind = Item_Kind'(List_Utilities.List_Item) and
  25673.     Pos > List_Item'Length) then
  25674.             raise Use_Error; 
  25675.         end if; 
  25676.  
  25677.         Store(Token_Val(1 .. Token_Size), Token); 
  25678.     end Validate_Item; 
  25679. -----------------------C O P Y----------------------------------
  25680. --
  25681. -- Purpose:
  25682. -- ---------
  25683. --    Returns in the the parameter T0_List a copy of the list value
  25684. --    of the parameter From_List.  Subsequent modification of either
  25685. --    list does not affect the other list.
  25686. --
  25687. -- Parameters:
  25688. -- ----------
  25689. --    To_List   is the list returned as a copy of the value of From_List
  25690. --    From_List is thew list to be copied.
  25691. --   
  25692. -- Exceptions:
  25693. -- ----------
  25694. --    None
  25695. --
  25696. -- Notes: MIL_STD CAIS 5.4.1.2
  25697. -- -----
  25698. --    None
  25699. ----------------------------------------------------------------
  25700.     procedure Copy(To_List   : in out List_Type; 
  25701.                    From_List : in List_Type) is 
  25702.         Local_List : List_Type;   --required because Merge is in out
  25703.     begin
  25704.         Merge(null, From_List, Local_List); 
  25705.         To_List := Local_List; 
  25706.     end Copy; 
  25707. ---------------------T O _ L I S T------------------------------
  25708. --
  25709. -- Purpose: 
  25710. -- -------
  25711. --     Converts the external representation of a list to List_Type
  25712. --     and returns the converted value.  This function establishes
  25713. --     the list to be of named, unnamed, or null kind.
  25714. --
  25715. -- Parameters:
  25716. -- ----------
  25717. --     List_Literal is the string representation to be converted to a list
  25718. --     List         is the List_Type internal representation of List_Literal
  25719. --            
  25720. --
  25721. -- Exceptions: 
  25722. -- ----------  
  25723. --     Use_Error is raised if ther is a syntax error.
  25724. --    
  25725. -- Notes:  MIL_STD CAIS 5.4.1.3
  25726. -- -----
  25727. --
  25728. ----------------------------------------------------------------
  25729.  
  25730.     procedure To_List(List_Literal : in List_Text; 
  25731.                       List         : in out List_Type) is 
  25732.         Size : constant Natural := List_Literal'Length; 
  25733.         Pos  : Natural := 1; 
  25734.     begin
  25735.         List := null;                      --Initialize to null list;
  25736.  
  25737.         Parse_List(List_Literal, Pos, List); 
  25738.         if Pos <= Size then                --illegal chars after list
  25739.             raise Use_Error; 
  25740.         end if; 
  25741.     end To_List; 
  25742.  
  25743.  
  25744. --------------------T O _ T E X T-------------------------------
  25745. --
  25746. -- Purpose: 
  25747. -- -------
  25748. --     Returns thje external representation of the value of
  25749. --     list, as defined in MIL_STD CAIS 5.4
  25750. --
  25751. --
  25752. -- Parameters:
  25753. -- ----------
  25754. --     List   is a list_type to be converted to text
  25755. --     return string representation of List
  25756. --
  25757. -- Exceptions: 
  25758. -- ----------  
  25759. --     None
  25760. --    
  25761. --
  25762. --
  25763. -- Notes: MIL_STD CAIS 5.4.1.4
  25764. -- -----
  25765. --
  25766. --
  25767. ----------------------------------------------------------------
  25768.  
  25769.     function To_Text(List : in List_Type) return List_Text is 
  25770.         Text     : String(1 .. Text_Length(List)); 
  25771.                                                   --work area
  25772.         Unquoted : String(1 .. Text_Length(List)); 
  25773.                                                   --string item without "
  25774.         Size     : Natural;                       --length of unquoted string
  25775.         Pos      : Positive := 2;                 --1st position to set
  25776.         Epos     : Natural;                       --End of text for this item
  25777.         Item     : List_Type := List;             --Item being processed;
  25778.     begin
  25779.         if List = null then 
  25780.             Text(1 .. 2) := "()"; 
  25781.         else 
  25782.             Text(1) := '('; 
  25783.  
  25784.             while Item /= null loop
  25785.                 if Item.Name /= null then       --add name text
  25786.                     Epos := Pos + Length(Item.Name) + 2; 
  25787.                     Text(Pos .. Epos - 3) := Retrieve(Item.Name); 
  25788.                     Text(Epos - 2 .. Epos - 1) := "=>"; 
  25789.                     Pos := Epos; 
  25790.                 end if; 
  25791.  
  25792.                                                                 --add item text
  25793.                 if Item.Kind = List_Item then           --list_item
  25794.                     Epos := Pos + Text_Length(Item.List); 
  25795.                     Text(Pos .. Epos - 1) := To_Text(Item.List); 
  25796.                 elsif Item.Kind = String_Item then      --string_item
  25797.                     Size := Length(Item.Element); 
  25798.                     Unquoted(1 .. Size) := Retrieve(Item.Element); 
  25799.                     Epos := Pos + Size + 2; 
  25800.                     Text(Pos) := '"'; 
  25801.                     Pos := Pos + 1; 
  25802.                     for I in 1 .. Size loop
  25803.                         Text(Pos) := Unquoted(I); 
  25804.                         Pos := Pos + 1; 
  25805.                         if Unquoted(I) = '"' then 
  25806.                             Text(Pos) := '"'; 
  25807.                             Pos := Pos + 1; 
  25808.                             Epos := Epos + 1; 
  25809.                         end if; 
  25810.                     end loop; 
  25811.                     Text(Pos) := '"'; 
  25812.                 else                                    --other items
  25813.                     Epos := Pos + Length(Item.Element); 
  25814.                     Text(Pos .. Epos - 1) := Retrieve(Item.Element); 
  25815.                 end if; 
  25816.  
  25817.                 Text(Epos) := ',';      --add comma separator
  25818.                 Pos := Epos + 1; 
  25819.                 Item := Item.Next_Item; 
  25820.             end loop; 
  25821.             Pos := Pos - 1;             --write over last ','
  25822.             Text(Pos) := ')'; 
  25823.         end if; 
  25824.         return Text(1 .. Pos); 
  25825.     end To_Text; 
  25826. --------------------I S _ E Q U A L-----------------------------
  25827. -- Purpose:
  25828. -- -------
  25829. --     returns True if the two lists are equal as determined by:
  25830. --    - Both lists are of the same kind (named, unnamed, or empty)
  25831. --    - Both lists contain the same number of items
  25832. --    - For each position, the values of list items at this position,
  25833. --      as obtained by Extract, are of the same kind and are equal
  25834. --      under the equality defined for this kind
  25835. --    - In thew case of named lists, for each position, the names of the
  25836. --      items at this position are equal under Token_Type equality
  25837. --
  25838. -- Parameters:
  25839. -- ----------
  25840. --        List1  is List_Type to be compared
  25841. --        List2  is List_Type to be compared
  25842. --        return TRUE if lists are of the same kind, have the same number
  25843. --         of items, and all corresponding names and items are equal
  25844. --
  25845. -- Exceptions:
  25846. -- ----------
  25847. --      None
  25848. --
  25849. -- Notes: MIL_STD CAIS 5.4.1.5
  25850. -- -----
  25851. --
  25852. ----------------------------------------------------------------
  25853.     function Is_Equal(List1 : in List_Type; 
  25854.                       List2 : in List_Type) return Boolean is 
  25855.         Item1 : List_Type := List1;  --ptr to an item in List1;
  25856.         Item2 : List_Type := List2;  --ptr to an item in List2;
  25857.     begin
  25858.         while Item1 /= null and Item2 /= null loop
  25859.                                                  --check each item for mismatch
  25860.             if Item1.Kind = Item2.Kind and                 --Kind
  25861.             Is_Equal(Item1.Name, Item2.Name) and           --Name
  25862.  
  25863.             ((Item1.Kind /= List_Item and then             --element
  25864.         Is_Equal(Item1.Element, Item2.Element)) or else 
  25865.  
  25866.             (Item1.Kind = List_Item and then               --List, if apropos
  25867.             Is_Equal(Item1.List, Item2.List))) then 
  25868.                 Item1 := Item1.Next_Item; 
  25869.                 Item2 := Item2.Next_Item; 
  25870.             else 
  25871.                 exit; 
  25872.             end if; 
  25873.         end loop; 
  25874.  
  25875.         if Item1 = null and Item2 = null then 
  25876.             return True; 
  25877.         else 
  25878.             return False; 
  25879.         end if; 
  25880.     end Is_Equal; 
  25881.  
  25882. --------------------D E L E T E----POSITIONAL ITEM--------------
  25883. --
  25884. -- Purpose: 
  25885. -- -------
  25886. --     Removes the list item at this position from the list
  25887. --
  25888. --
  25889. -- Parameters:
  25890. -- ----------
  25891. --     List     is the list from which an item is to be deleted, positional
  25892. --     Position is the position of the item to be deleted.
  25893. --            
  25894. --
  25895. -- Exceptions: 
  25896. -- ----------  
  25897. --     Use_Error    may be raised by Find if bad position
  25898. --
  25899. --
  25900. -- Notes: MIL_STD CAIS 5.4.1.6
  25901. -- -----
  25902. --
  25903. --
  25904. ----------------------------------------------------------------
  25905.  
  25906.     procedure Delete(List     : in out List_Type; 
  25907.                      Position : in Position_Count) is 
  25908.         Previous : List_Type;    --next is reset to point to item after current
  25909.         Current  : List_Type;    --item which is removed
  25910.  
  25911.     begin
  25912.         Find_All(List, Position, Current); 
  25913.         if Position = 1 then                 --head  item being deleted
  25914.             List := Current.Next_Item; 
  25915.         else                                 --other item being deleted
  25916.             Find_All(List, Position - 1, Previous); 
  25917.             Previous.Next_Item := Current.Next_Item; 
  25918.         end if; 
  25919.     end Delete; 
  25920. --------------------D E L E T E----NAMED     ITEM--------------
  25921. --
  25922. -- Purpose: 
  25923. -- -------
  25924. --     Removes the list item of this name  from the list
  25925. --
  25926. --
  25927. -- Parameters:
  25928. -- ----------
  25929. --     List     is the list from which an item is to be deleted, named
  25930. --     Named    is the name of the item to be deleted.
  25931. --            
  25932. --
  25933. -- Exceptions: 
  25934. -- ----------  
  25935. --     Search_Error    may be raised by find if name doesn't exist
  25936. --     Use_Error       may be raised by find if list is not named
  25937. --
  25938. --
  25939. -- Notes: MIL_STD CAIS 5.4.1.6
  25940. -- -----
  25941. --
  25942. --
  25943. ----------------------------------------------------------------
  25944.  
  25945.     procedure Delete(List  : in out List_Type; 
  25946.                      Named : in Namestring) is 
  25947.         Previous : List_Type;    --next is reset to point to item after current
  25948.         Current  : List_Type;    --item which is removed
  25949.         Position : Position_Count; --Used to find previous item
  25950.  
  25951.     begin
  25952.         Find(List, Named, Current); 
  25953.         Position := Position_Of(List, Current); 
  25954.         if Position = 1 then                 --head  item being deleted
  25955.             List := Current.Next_Item; 
  25956.         else                                 --other item being deleted
  25957.             Find_All(List, Position - 1, Previous); 
  25958.             Previous.Next_Item := Current.Next_Item; 
  25959.         end if; 
  25960.     end Delete; 
  25961. --------------------D E L E T E----NAMED  ITEM OF TOKEN TYPE---
  25962. --
  25963. -- Purpose: 
  25964. -- -------
  25965. --     Removes the list item of this name  from the list
  25966. --
  25967. --
  25968. -- Parameters:
  25969. -- ----------
  25970. --     List     is the list from which an item is to be deleted, named
  25971. --     Named    is the name (in token form) of the item to be deleted.
  25972. --            
  25973. --
  25974. -- Exceptions: 
  25975. -- ----------  
  25976. --     Search_Error    may be raised by find if name doesn't exist
  25977. --     Use_Error       may be raised by find if list is not named
  25978. --
  25979. --
  25980. -- Notes: MIL_STD CAIS 5.4.1.6
  25981. -- -----
  25982. --
  25983. --
  25984. ----------------------------------------------------------------
  25985.  
  25986.     procedure Delete(List  : in out List_Type; 
  25987.                      Named : in Token_Type) is 
  25988.  
  25989.     begin
  25990.         Delete(List, Retrieve(Named)); 
  25991.     end Delete; 
  25992. ---------------G E T _ L I S T _ K I N D----------------OF LIST-
  25993. --
  25994. -- Purpose:
  25995. -- -------
  25996. --     Returns the kind of list, either empty, unnamed, or named.
  25997. --
  25998. -- Parameters:
  25999. -- ----------
  26000. --     List    is the list_type being looked at
  26001. --     return  the kind of list, either empty, unnamed, or named
  26002. --
  26003. -- Exceptions: 
  26004. -- ----------  
  26005. --     None
  26006. --    
  26007. -- Notes: MIL_STD CAIS 5.4.1.7
  26008. -- -----
  26009. --
  26010. ----------------------------------------------------------------
  26011.  
  26012.     function Get_List_Kind(List : in List_Type) return List_Kind is 
  26013.  
  26014.  
  26015.     begin
  26016.         if List = null then 
  26017.             return Empty; 
  26018.         elsif List.Name = null then 
  26019.             return Unnamed; 
  26020.         else 
  26021.             return Named; 
  26022.         end if; 
  26023.     end Get_List_Kind; 
  26024. ----------------G E T _ I T E M _ K I N D------------OF UNNAMED ITEM--
  26025. --
  26026. -- Purpose:
  26027. -- -------
  26028. --     Returns the kind of a single list item within an unnamed list.
  26029. --     The item kinds are LIST_ITEM, STRING_ITEM, INTEGER_ITEM,
  26030. --     REAL_ITEM, and IDENTIFIER_ITEM.
  26031. --
  26032. -- Parameters:
  26033. -- ----------
  26034. --     List      is the unnamed list containing the item of interest
  26035. --     Position  is the position of the item of interest
  26036. --     return    the item_kind of the specified item
  26037. --            
  26038. -- Exceptions: 
  26039. -- ----------  
  26040. --     Use_Error       may be propogated by Find for no names or bad position
  26041. --
  26042. -- Notes: MIL_STD CAIS 5.4.1.8
  26043. --
  26044. ------------------------------------------------------------------------------
  26045.  
  26046.     function Get_Item_Kind(List     : in List_Type; 
  26047.                            Position : in Position_Count) return Item_Kind is 
  26048.  
  26049.         Previous : List_Type; --returned by find but unused
  26050.         Current  : List_Type; --set by Find to item in question
  26051.  
  26052.     begin
  26053.         Find_All(List, Position, Current); 
  26054.         return Current.Kind; 
  26055.     end Get_Item_Kind; 
  26056. ----------------G E T _ I T E M _ K I N D------------OF NAMED ITEM--
  26057. --
  26058. -- Purpose:
  26059. -- -------
  26060. --     Returns the kind of a single list item within a named list.
  26061. --     The item kinds are LIST_ITEM, STRING_ITEM, INTEGER_ITEM,
  26062. --     REAL_ITEM, and IDENTIFIER_ITEM.
  26063. --
  26064. -- Parameters:
  26065. -- ----------
  26066. --     List      is the named list containing the item of interest
  26067. --     Named     is the name of the item of interest
  26068. --     return    the item_kind of the specified item
  26069. --            
  26070. -- Exceptions: 
  26071. -- ----------  
  26072. --     Search_Error    may be propogated from Find if name doesn't exist
  26073. --     Use_Error       may be propogated by Find if list is unnamed
  26074. --
  26075. -- Notes: MIL_STD CAIS 5.4.1.8
  26076. -- -----
  26077. --
  26078. ----------------------------------------------------------------
  26079.  
  26080.     function Get_Item_Kind(List  : in List_Type; 
  26081.                            Named : in Namestring) return Item_Kind is 
  26082.  
  26083.         Previous : List_Type; --returned by find but unused
  26084.         Current  : List_Type; --set by Find to item in question
  26085.  
  26086.     begin
  26087.         Find(List, Named, Current); 
  26088.         return Current.Kind; 
  26089.     end Get_Item_Kind; 
  26090. ------------G E T _ I T E M _ K I N D--------OF NAMED ITEM-TOKEN---
  26091. --
  26092. -- Purpose:
  26093. -- -------
  26094. --     Returns the kind of a single list item within a named list.
  26095. --     The item kinds are LIST_ITEM, STRING_ITEM, INTEGER_ITEM,
  26096. --     REAL_ITEM, and IDENTIFIER_ITEM.
  26097. --
  26098. -- Parameters:
  26099. -- ----------
  26100. --     List      is the named list containing the item of interest
  26101. --     Named     is the name (in token form) of the item of interest
  26102. --     return    the item_kind of the specified item
  26103. --            
  26104. -- Exceptions: 
  26105. -- ----------  
  26106. --     Search_Error    may be propogated from Find if name doesn't exist
  26107. --     Use_Error       may be propogated by Find if list is unnamed
  26108. --    
  26109. -- Notes: MIL_STD CAIS 5.4.1.8
  26110. -- -----
  26111. --
  26112. ----------------------------------------------------------------
  26113.  
  26114.     function Get_Item_Kind(List  : in List_Type; 
  26115.                            Named : in Token_Type) return Item_Kind is 
  26116.  
  26117.     begin
  26118.         return Get_Item_Kind(List, Retrieve(Named)); 
  26119.     end Get_Item_Kind; 
  26120. -----------------------S P L I C E-----TEXT---------------------
  26121. --
  26122. -- Purpose:
  26123. -- -------
  26124. --     Inserts a list into a list.  The items in the list to be inserted
  26125. --     will become items in the resulting list.  Subsequent modifications
  26126. --     to the value of List or to the value of Sub_List do not affect the
  26127. --     other list.
  26128. --
  26129. -- Parameters:
  26130. -- ----------
  26131. --     List      is the list_type into which the Sub_List is to be added
  26132. --     Position  is the position within List at which Sub_List is added
  26133. --     Sub_List  is text which is an external representation of a string
  26134. --               a list_type is created from this string and added to list
  26135. --            
  26136. -- Exceptions:
  26137. -- ----------
  26138. --     Use_Error   is raised if List and Sub_List are not of the same kind
  26139. --           and neither of them is Empty; if Sub_List contains a
  26140. --           name identical to one in List; if Position is too large;
  26141. --           or if List_Text is of invalid format.
  26142. --
  26143. -- Notes: MIL_STD CAIS 5.4.1.9
  26144. -- -----
  26145. --
  26146. ----------------------------------------------------------------
  26147.  
  26148.    -- MIL_STD CAIS 5.4.1.9
  26149.     procedure Splice(List     : in out List_Type; 
  26150.                      Position : in Position_Count; 
  26151.                      Sub_List : in List_Text) is 
  26152.         Local_List : List_Type;  --temp for converted Sub_List
  26153.     begin
  26154.         To_List(Sub_List, Local_List); 
  26155.         Splice(List, Position, Local_List); 
  26156.     end Splice; 
  26157. -----------------------S P L I C E-----LIST---------------------
  26158. --
  26159. -- Purpose:
  26160. -- -------
  26161. --     Inserts a list into a list.  The items in the list to be inserted
  26162. --     will becomes items in the resulting list.  Subsequent modifications
  26163. --     to the value of List or to the value of Sub_List do not affect the
  26164. --     other list.
  26165. --
  26166. -- Parameters:
  26167. -- ----------
  26168. --     List      is the list_type into which the Sub_List is to be added
  26169. --     Position  is the position within List at which Sub_List is added
  26170. --     Sub_List  is an unchanged list_type, a copy of which is added to List
  26171. --            
  26172. -- Exceptions:
  26173. -- ----------
  26174. --     Use_Error   is raised if List and Sub_List are not of the same kind
  26175. --           and neither of them is Empty; if Sub_List contains a
  26176. --           name identical to one in List; or if Position is too large.
  26177. --
  26178. -- Notes: MIL_STD CAIS 5.4.1.9
  26179. -- -----
  26180. --
  26181. ----------------------------------------------------------------
  26182.     procedure Splice(List     : in out List_Type; 
  26183.                      Position : in Position_Count; 
  26184.                      Sub_List : in List_Type) is 
  26185.         Last    : List_Type;    --set to last item in Sub_List
  26186.         Head    : List_Type;    --set to Item in List at indicated Position
  26187.         Tail    : List_Type;    --set to Item in List at Position+1
  26188.         New_Sub : List_Type;    --copy of Sub_List to be inserted
  26189.  
  26190.     begin
  26191.      --Perform sanity checks for valid Splice parameters
  26192.         if Sub_List = null then                                 --No-op complete
  26193.             return; 
  26194.         elsif (List.Name = null and Sub_List.Name /= null) or   --mixed lists
  26195.         (List.Name /= null and Sub_List.Name = null) then 
  26196.             raise Use_Error; 
  26197.         else                                                    --Name conflict?
  26198.                                                                 --bad position?
  26199.             Name_Check(List, Sub_List); 
  26200.             Find_All(List, Position, Head);     --set end   of head section
  26201.             Tail := Head.Next_Item;             --set start of tail section
  26202.         end if; 
  26203.  
  26204.     --Splice is properly specified, so do it
  26205.                         --Copy the Sub_List so that it is never modified
  26206.         Copy(New_Sub, Sub_List); 
  26207.                         --Find the last position in Sub_List;
  26208.         Last := New_Sub; 
  26209.         while Last.Next_Item /= null loop
  26210.             Last := Last.Next_Item; 
  26211.         end loop; 
  26212.                         --Now reset appropriate pointers
  26213.         Head.Next_Item := New_Sub; 
  26214.         Last.Next_Item := Tail; 
  26215.     end Splice; 
  26216. ----------------------M E R G E---------------------------------
  26217. --
  26218. -- Purpose:
  26219. -- -------
  26220. --     Returns in result a list which is constructed from the
  26221. --     parameters Front and Back.  The lists Front and Back
  26222. --     lists are not modified by this procedure.
  26223. --
  26224. -- Parameters:
  26225. -- ----------
  26226. --     Front  : is a List_Type which is read but unchanged
  26227. --     Back   : is a List_Type which is read but unchanged
  26228. --     Result : is a new list_type made up of Front catenated to Back
  26229. --            
  26230. -- Exceptions: 
  26231. -- ----------  
  26232. --     Use_Error is raised if one list is named and one is not.
  26233. --    
  26234. -- Notes: MIL_STD CAIS 5.4.1.10
  26235. -- -----  
  26236. --     
  26237. ----------------------------------------------------------------
  26238.  
  26239.     procedure Merge(Front  : in List_Type; 
  26240.                     Back   : in List_Type; 
  26241.                     Result : in out List_Type) is 
  26242.         Current     : List_Type; --ptr to element in Front or Back to copy
  26243.         Copied_Item : List_Type; --result item where date has just been copied
  26244.         New_Item    : List_Type; --newly allocated item where data is copied
  26245.  
  26246.         procedure Copy_Item(From_Item : in List_Type; 
  26247.                             To_Item   : in out List_Type) is 
  26248.         begin
  26249.             To_Item.Kind := From_Item.Kind; 
  26250.             Copy(To_Item.Name, From_Item.Name); 
  26251.             Copy(To_Item.Element, From_Item.Element); 
  26252.             if From_Item.Kind = List_Item then 
  26253.                 Merge(null, From_Item.List, To_Item.List); 
  26254.             else 
  26255.                 To_Item.List := null; 
  26256.             end if; 
  26257.         end Copy_Item; 
  26258.  
  26259.  
  26260.     begin
  26261.         if (Front /= null and Back /= null) and then ((Front.Name = null and 
  26262.             Back.Name /= null) or (Front.Name /= null and Back.Name = null))
  26263.             then 
  26264.             raise Use_Error; 
  26265.         else 
  26266.             --first check for duplicate names
  26267.             Name_Check(Front, Back); 
  26268.  
  26269.             --copy over Front list
  26270.             Result := null; 
  26271.             Current := Front; 
  26272.             while Current /= null loop
  26273.                 Copied_Item := new Item_Descriptor; 
  26274.                 if Result = null then 
  26275.                     Result := Copied_Item; 
  26276.                 else 
  26277.                     New_Item.Next_Item := Copied_Item; 
  26278.                 end if; 
  26279.                 Copy_Item(Current, Copied_Item); 
  26280.  
  26281.                 --update pointers
  26282.                 Current := Current.Next_Item; 
  26283.                 New_Item := Copied_Item; 
  26284.             end loop; 
  26285.  
  26286.             --copy over Back list
  26287.             Current := Back; 
  26288.             while Current /= null loop
  26289.                 Copied_Item := new Item_Descriptor; 
  26290.                 if Result = null then 
  26291.                     Result := Copied_Item; 
  26292.                 else 
  26293.                     New_Item.Next_Item := Copied_Item; 
  26294.                 end if; 
  26295.                 Copy_Item(Current, Copied_Item); 
  26296.  
  26297.                 --update pointers
  26298.                 Current := Current.Next_Item; 
  26299.                 New_Item := Copied_Item; 
  26300.             end loop; 
  26301.         end if; 
  26302.  
  26303.     end Merge; 
  26304. -----------------S E T _ E X T R A C T--------------------------
  26305. --
  26306. -- Purpose:
  26307. -- -------
  26308. --     Extracts a (sub)list from a list.  The return value is a copy of the
  26309. --     list subset that starts at the item at Position and has Length items
  26310. --     in it.  If there are fewer than Length items in this part of the list,
  26311. --     the subset extends to the tail of the list.
  26312. --
  26313. -- Parameters:
  26314. -- ----------
  26315. --     List      is the list_type(unchanged) from which the sublist is read
  26316. --     Position  is position of the first item to be copied out
  26317. --     Length    is the number of items to be copied to the sublist
  26318. --     return    is the Text representation of the selected sublist
  26319. --            
  26320. -- Exceptions:
  26321. -- ----------
  26322. --     Use Error     is raised if Position is larger than the list length
  26323. --
  26324. -- Notes: MIL_STD CAIS 5.4.1.11
  26325. -- -----
  26326. --
  26327. ----------------------------------------------------------------
  26328.  
  26329.    -- MIL_STD CAIS 5.4.1.11
  26330.     function Set_Extract(List     : in List_Type; 
  26331.                          Position : in Position_Count; 
  26332.                          Length   : in Positive := Positive'Last) return
  26333.         List_Text is 
  26334.         Start          : List_Type; 
  26335.                                    --ptr to 1st  item to be extracted
  26336.         Stop           : List_Type; 
  26337.                                    --ptr to last item to be extracted
  26338.         Relink         : List_Type; 
  26339.                                    --ptr to item after the last one extracted
  26340.         Extracted_List : List_Type; 
  26341.                                    --ptr to the copied list of items
  26342.     begin
  26343.         Find_All(List, Position, Start);    --Find start of Extracted List
  26344.  
  26345.         Stop := Start;                  --Find stop  of Extracted List
  26346.         for I in 1 .. Length - 1 loop
  26347.             exit when Stop.Next_Item = null;   --Check for end of List
  26348.             Stop := Stop.Next_Item; 
  26349.         end loop; 
  26350.  
  26351.         Relink := Stop.Next_Item;       --Save this link and then break it
  26352.         Stop.Next_Item := null; 
  26353.  
  26354.         Copy(Extracted_List, Start);    --Copy list and mend the broken link
  26355.         Stop.Next_Item := Relink; 
  26356.  
  26357.         return To_Text(Extracted_List); 
  26358.     end Set_Extract; 
  26359. --------------------L E N G T H------OF LIST--------------------
  26360. --
  26361. -- Purpose:
  26362. -- -------
  26363. --     Returns a count of the number of items in List. If list
  26364. --     is empty, Length returns zero.
  26365. --
  26366. -- Parameters:
  26367. -- ----------
  26368. --     List   is the list_type whose items are being counted
  26369. --     return the number of items (note list_items count as a single item)
  26370. --            
  26371. -- Exceptions: 
  26372. -- ----------  
  26373. --     None
  26374. --    
  26375. -- Notes: MIL_STD CAIS 5.4.1.12
  26376. -- -----
  26377. --     None
  26378. --
  26379. ----------------------------------------------------------------
  26380.  
  26381.     function Length(List : in List_Type) return Count is 
  26382.  
  26383.         Counter      : Count; 
  26384.         Current_Item : List_Type; 
  26385.  
  26386.     begin
  26387.         Counter := 0; 
  26388.         Current_Item := List; 
  26389.         while Current_Item /= null loop
  26390.             Counter := Counter + 1; 
  26391.             Current_Item := Current_Item.Next_Item; 
  26392.         end loop; 
  26393.         return Counter; 
  26394.     end Length; 
  26395. ------------------T E X T _ L E N G T H----OF LIST--------------
  26396. --
  26397. -- Purpose:
  26398. -- -------
  26399. --     Returns the length of a string representing a list according
  26400. --     to the syntax prescribed in MIL_STD CAIS
  26401. --
  26402. -- Parameters:
  26403. -- ----------
  26404. --     List   is the list being examined
  26405. --     return the length of the string which is the external text for List
  26406. --            
  26407. -- Exceptions: 
  26408. -- ----------  
  26409. --     None
  26410. --    
  26411. -- Notes: MIL_STD CAIS 5.4.1.13
  26412. -- -----
  26413. --     None
  26414. --
  26415. ----------------------------------------------------------------
  26416.  
  26417.     function Text_Length(List : in List_Type) return Positive is 
  26418.         Pos  : Positive := 2;          --Count parenthesis
  26419.         Item : List_Type := List;      --Item being processed;
  26420.     begin
  26421.         while Item /= null loop
  26422.             if Item.Name /= null then 
  26423.                 Pos := Pos + Length(Item.Name) + 2;     --count names
  26424.             end if; 
  26425.  
  26426.             if Item.Kind = List_Item then 
  26427.                 Pos := Pos + Text_Length(Item.List);    --count list
  26428.             elsif Item.Kind = String_Item then          --for string items
  26429.                 Pos := Pos + Length(Item.Element) + 2;   --add 2 for enclosing "
  26430.                 declare
  26431.                     Element : String(1 .. Length(Item.Element)); 
  26432.                 begin
  26433.                     Element := Retrieve(Item.Element); 
  26434.                     for I in 1 .. Element'Length loop    --and check for "
  26435.                         if Element(I) = '"' then         --add 1 for doubling
  26436.                             Pos := Pos + 1; 
  26437.                         end if; 
  26438.                     end loop; 
  26439.                 end; 
  26440.             else 
  26441.                 Pos := Pos + Length(Item.Element);      --count other items
  26442.             end if; 
  26443.  
  26444.  
  26445.             Pos := Pos + 1;                              --count ','
  26446.             Item := Item.Next_Item; 
  26447.         end loop; 
  26448.         if List /= null then 
  26449.             Pos := Pos - 1;                     --remove count for last ','
  26450.         end if; 
  26451.         return Pos; 
  26452.     end Text_Length; 
  26453. ------------------T E X T - L E N G T H----OF POSITIONAL ITEM---
  26454. --
  26455. -- Purpose:
  26456. -- -------
  26457. --     Returns the length of a string representing a list item according
  26458. --     to the syntax prescribed in MIL_STD CAIS.  The item is found by
  26459. --     position within a list.
  26460. --
  26461. -- Parameters:
  26462. -- ----------
  26463. --     List     is the list being examined
  26464. --     Position is the position of the item being examined
  26465. --     return   the length of the string which is the external text for 
  26466. --        the item at the designated position
  26467. --            
  26468. -- Exceptions: 
  26469. -- ----------  
  26470. --     Use_Error is raised if position is not in range
  26471. --    
  26472. -- Notes: MIL_STD CAIS 5.4.1.13
  26473. -- -----
  26474. --     None
  26475. --
  26476. ----------------------------------------------------------------
  26477.  
  26478.     function Text_Length(List     : in List_Type; 
  26479.                          Position : in Position_Count) return Natural is 
  26480.         Pos  : Natural;          --Length to be returned
  26481.         Item : List_Type := List; --Item being processed;
  26482.     begin
  26483.         Find_All(List, Position, Item); 
  26484.         if Item.Kind = List_Item then 
  26485.             Pos := Text_Length(Item.List);     --count list
  26486.         else 
  26487.             Pos := Length(Item.Element);       --count item
  26488.         end if; 
  26489.  
  26490.         return Pos; 
  26491.     end Text_Length; 
  26492. ------------------T E X T - L E N G T H----OF NAMED ITEM--------
  26493. --
  26494. -- Purpose:
  26495. -- -------
  26496. --     Returns the length of a string representing a list item according
  26497. --     to the syntax prescribed in MIL_STD CAIS.  The item is found by
  26498. --     searching for the item name.
  26499. --
  26500. -- Parameters:
  26501. -- ----------
  26502. --     List     is the list being examined
  26503. --     Named    is the name of the item being examined
  26504. --     return   the length of the string which is the external text for 
  26505. --        the item of the designated name
  26506. --            
  26507. -- Exceptions: 
  26508. -- ----------  
  26509. --     Use_Error    is raised if this is an unnamed list
  26510. --     Search_Error is raised if a matching name is not found
  26511. --    
  26512. -- Notes: MIL_STD CAIS 5.4.1.13
  26513. -- -----
  26514. --     None
  26515. --
  26516. ----------------------------------------------------------------
  26517.  
  26518.     function Text_Length(List  : in List_Type; 
  26519.                          Named : in Namestring) return Natural is 
  26520.         Pos  : Natural;          --Length to be returned
  26521.         Item : List_Type := List; --Item being processed;
  26522.     begin
  26523.         Find(List, Named, Item); 
  26524.         if Item.Kind = List_Item then 
  26525.             Pos := Text_Length(Item.List);     --count list
  26526.         else 
  26527.             Pos := Length(Item.Element);       --count item
  26528.         end if; 
  26529.  
  26530.         return Pos; 
  26531.     end Text_Length; 
  26532. ------------------T E X T - L E N G T H----OF TOKEN_NAMED ITEM-------
  26533. --
  26534. -- Purpose:
  26535. -- -------
  26536. --     Returns the length of a string representing a list item according
  26537. --     to the syntax prescribed in MIL_STD CAIS.  The item is found by
  26538. --     searching for the named token.
  26539. --
  26540. -- Parameters:
  26541. -- ----------
  26542. --     List     is the list being examined
  26543. --     Named    is the name (in token format) of the item being examined
  26544. --     return   the length of the string which is the external text for 
  26545. --        the item of the designated name
  26546. --            
  26547. -- Exceptions: 
  26548. -- ----------  
  26549. --     None
  26550. --    
  26551. -- Notes: MIL_STD CAIS 5.4.1.13
  26552. -- -----
  26553. --     None
  26554. --
  26555. ----------------------------------------------------------------
  26556.  
  26557.     function Text_Length(List  : in List_Type; 
  26558.                          Named : in Token_Type) return Natural is 
  26559.     begin
  26560.         return Text_Length(List, Retrieve(Named)); 
  26561.     end Text_Length; 
  26562.  
  26563. ----------------------I T E M _ N A M E----PROCEDURE---------------
  26564. --
  26565. -- Purpose:
  26566. -- -------
  26567. --     Returns the name of the list item in a named list, specified
  26568. --     by position.
  26569. --
  26570. -- Parameters:
  26571. -- ----------
  26572. --     List       is the list_type of interest
  26573. --     Position   is the position of the item whose name is desired
  26574. --     Named      is the Name returned for the item
  26575. --            
  26576. -- Exceptions: 
  26577. -- ----------  
  26578. --     Use_Error    is raised if list is positional
  26579. --                  or if position exceeds the list length
  26580. --
  26581. -- Notes: MIL_STD CAIS 5.4.1.14
  26582. -- -----  
  26583. --     Again the CAIS 1.4 semantics are not explicit with respect to
  26584. --     null lists. Here, null lists are treated as in Insert, i.e. as
  26585. --     either named or positional
  26586. --
  26587. ----------------------------------------------------------------
  26588.  
  26589.     procedure Item_Name(List     : in List_Type; 
  26590.                         Position : in Position_Count; 
  26591.                         Named    : in out Token_Type) is 
  26592.         Current    : List_Type; --ptr to desired item in list
  26593.         Local_Name : Token_Type; 
  26594.                                 --required because Copy is in out
  26595.     begin
  26596.         Find_All(List, Position, Current); 
  26597.         Copy(Local_Name, Current.Name); 
  26598.         Named := Local_Name; 
  26599.     end Item_Name; 
  26600. ----------------P O S I T I O N _ B Y _ N A M E----STRING-------
  26601. --
  26602. -- Purpose:
  26603. -- -------
  26604. --     Returns the Position at which the given Named is located in the
  26605. --     List.  It may only be used with named lists.
  26606. --
  26607. -- Parameters:
  26608. -- ----------
  26609. --     List   is the list_type of interest
  26610. --     Named  is the Name of the item whose position is desired
  26611. --     return the position of the named item
  26612. --            
  26613. -- Exceptions:
  26614. -- ----------
  26615. --     Use_Error      is raised if List is not named
  26616. --     Search_Error   is raised if Named is not in the List
  26617. --
  26618. -- Notes: MIL_STD CAIS 5.4.1.15
  26619. -- -----
  26620. --
  26621. ----------------------------------------------------------------
  26622.  
  26623.    -- MIL_STD CAIS 5.4.1.15
  26624.     function Position_By_Name(List  : in List_Type; 
  26625.                               Named : in Namestring) return Position_Count is 
  26626.         Current : List_Type;  --Ptr to Named item
  26627.     begin
  26628.         Find(List, Named, Current); 
  26629.         return Position_Of(List, Current); 
  26630.     end Position_By_Name; 
  26631. ----------------P O S I T I O N _ B Y _ N A M E----TOKEN_TYPE---
  26632. --
  26633. -- Purpose:
  26634. -- -------
  26635. --     Returns the Position at which the given Named is located in the
  26636. --     List.  It may only be used with named lists.
  26637. --
  26638. -- Parameters:
  26639. -- ----------
  26640. --     List   is the list_type of interest
  26641. --     Named  is the Name(in token format) of the item whose position is desired
  26642. --     return the position of the named item
  26643. --            
  26644. -- Exceptions:
  26645. -- ----------
  26646. --     Use_Error      is raised if List is not named
  26647. --     Search_Error   is raised if Named is not in the List
  26648. --
  26649. -- Notes: MIL_STD CAIS 5.4.1.15
  26650. -- -----
  26651. --
  26652. ----------------------------------------------------------------
  26653.     function Position_By_Name(List  : in List_Type; 
  26654.                               Named : in Token_Type) return Position_Count is 
  26655.     begin
  26656.         return Position_By_Name(List, Retrieve(Named)); 
  26657.     end Position_By_Name; 
  26658. ---------------------E X T R A C T----NAME --LIS----------------
  26659. --
  26660. -- Purpose: 
  26661. -- -------
  26662. --     Returns the named List_Element from the list without removing it.
  26663. --     Use_Error, Search_Error, indicate unsuccessful extraction.
  26664. --
  26665. -- Parameters:
  26666. -- ----------
  26667. --     List      is the named list from which a list_item is to be selected
  26668. --     Named     is the name of the item to be copied
  26669. --     List_Item is a new list_type consisting of the extacted list
  26670. --            
  26671. -- Exceptions: 
  26672. -- ----------  
  26673. --     Search_error     indicates Named item not found
  26674. --     Use_Error        indicates an empty or positional list, or that
  26675. --                      item is not of list kind.
  26676. --
  26677. -- Notes: MIL_STD CAIS 5.4.1.16
  26678. -- -----  
  26679. --    
  26680. -------------------------------------------------------------------
  26681.  
  26682.     procedure Extract(List      : in List_Type; 
  26683.                       Named     : in Namestring; 
  26684.                       List_Item : in out List_Type) is 
  26685.         Current    : List_Type;   --ptr too named item
  26686.         Local_List : List_Type;   --required because Merge is in out
  26687.     begin
  26688.         if List = null then 
  26689.             raise Use_Error; 
  26690.         else 
  26691.             Find(List, Named, Current); 
  26692.             if Current.Kind /= Item_Kind'(List_Utilities.List_Item) then 
  26693.                 raise Use_Error; 
  26694.             else 
  26695.                 Merge(null, Current.List, Local_List); 
  26696.                 List_Item := Local_List; 
  26697.             end if; 
  26698.         end if; 
  26699.     end Extract; 
  26700. ---------------------E X T R A C T----TOKEN NAME----LIST--------
  26701. --
  26702. -- Purpose: 
  26703. -- -------
  26704. --     Returns the named List_Element from the list without removing it.
  26705. --     Use_Error, Search_Error, indicate unsuccessful extraction.
  26706. --
  26707. -- Parameters:
  26708. -- ----------
  26709. --     List      is the named list from which a list_item is to be selected
  26710. --     Named     is the name (in token form) of the item to be copied
  26711. --     List_Item is a new list_type consisting of the extacted list
  26712. --            
  26713. -- Exceptions: 
  26714. -- ----------  
  26715. --     Search_error     indicates Named item not found
  26716. --     Use_Error        indicates an empty or positional list
  26717. --
  26718. -- Notes: MIL_STD CAIS 5.4.1.16
  26719. -- -----  
  26720. --    
  26721. -------------------------------------------------------------------
  26722.  
  26723.     procedure Extract(List      : in List_Type; 
  26724.                       Named     : in Token_Type; 
  26725.                       List_Item : in out List_Type) is 
  26726.     begin
  26727.         Extract(List, Retrieve(Named), List_Item); 
  26728.     end Extract; 
  26729. ---------------------E X T R A C T----POSITIONAL ---------------------
  26730. --
  26731. -- Purpose: 
  26732. -- -------
  26733. --     Returns the nth List_Element from the positional list without
  26734. --     removing it.  Use_Error, Search_Error, imply unsuccessful extraction.
  26735. --
  26736. -- Parameters:
  26737. -- ----------
  26738. --     List      is the unnamed list from which a list_item is to be selected
  26739. --     Position  is the position of the item to be copied
  26740. --     List_Item is a new list_type consisting of the extacted list
  26741. --            
  26742. -- Exceptions: 
  26743. -- ----------  
  26744. --     Use_Error        indicates an empty or positional list
  26745. --                      or indicates Position exceeds list length
  26746. --
  26747. -- Notes: MIL_STD CAIS 5.4.1.16
  26748. -- ----- 
  26749. --     
  26750. ----------------------------------------------------------------
  26751.  
  26752.     procedure Extract(List      : in List_Type; 
  26753.                       Position  : in Position_Count; 
  26754.                       List_Item : in out List_Type) is 
  26755.         Current    : List_Type;   --ptr too named item
  26756.         Local_List : List_Type;   --required because merge is in out
  26757.     begin
  26758.         if List = null then 
  26759.             raise Use_Error; 
  26760.         else 
  26761.             Find_All(List, Position, Current); 
  26762.             if Current.Kind /= Item_Kind'(List_Utilities.List_Item) then 
  26763.                 raise Use_Error; 
  26764.             else 
  26765.                 Merge(null, Current.List, Local_List); 
  26766.                 List_Item := Local_List; 
  26767.             end if; 
  26768.         end if; 
  26769.     end Extract; 
  26770. --------------------R E P L A C E-----POSITIONAL--------------------
  26771. --
  26772. -- Purpose: 
  26773. -- -------
  26774. --     Replaces an item in a positional list.  The new item
  26775. --     must be of the same item kind as the one being replaced.
  26776. --
  26777. -- Parameters:
  26778. -- ----------
  26779. --     List       is the unnamed list of interest
  26780. --     List_Item  is the value of list_type which will replace an item in list
  26781. --     Position   is the position of a list_item in list which will be replaced
  26782. --            
  26783. -- Exceptions: 
  26784. -- ----------  
  26785. --     Use_Error     is raised if position exceeds list length.
  26786. --                   or if item kinds do not match.
  26787. --
  26788. -- Notes: MIL_STD CAIS 5.4.1.17
  26789. -- -----
  26790. --
  26791. ----------------------------------------------------------------
  26792.  
  26793.     procedure Replace(List      : in out List_Type; 
  26794.                       List_Item : in List_Type; 
  26795.                       Position  : in Position_Count) is 
  26796.         Current : List_Type;   --ptr to list element being modified
  26797.     begin
  26798.         Find_All(List, Position, Current); 
  26799.         if Current.Kind = List_Utilities.List_Item then --enumeration
  26800.             Merge(null, List_Item, Current.List);            --in parameter
  26801.         else 
  26802.             raise Use_Error; 
  26803.         end if; 
  26804.     end Replace; 
  26805. --------------------R E P L A C E-----NAMED-------------------------
  26806. --
  26807. -- Purpose: 
  26808. -- -------
  26809. --     Replaces an item in a named list.  The new item
  26810. --     must be of the same item kind as the one being replaced.
  26811. --
  26812. -- Parameters:
  26813. -- ----------
  26814. --     List       is the named list of interest
  26815. --     List_Item  is the value of list_type which will replace an item in list
  26816. --     Named      is the name of a list_item in list which will be replaced
  26817. --            
  26818. -- Exceptions: 
  26819. -- ----------  
  26820. --     Use_Error        is raised if item kinds do not match.
  26821. --     Search_Error     is raised if Named item is not found.
  26822. --
  26823. -- Notes: MIL_STD CAIS 5.4.1.17
  26824. -- -----
  26825. --
  26826. ----------------------------------------------------------------
  26827.  
  26828.     procedure Replace(List      : in out List_Type; 
  26829.                       List_Item : in List_Type; 
  26830.                       Named     : in Namestring) is 
  26831.         Current : List_Type;       --ptr to list element being modified
  26832.     begin
  26833.         Find(List, Named, Current); 
  26834.         if Current.Kind = Item_Kind'(List_Utilities.List_Item) then 
  26835.                                                         --enumeration
  26836.             Merge(null, List_Item, Current.List);       --parameter
  26837.         else 
  26838.             raise Use_Error; 
  26839.         end if; 
  26840.     end Replace; 
  26841. --------------------R E P L A C E-----NAMED----TOKEN----------------
  26842. --
  26843. -- Purpose: 
  26844. -- -------
  26845. --     Replaces an item in a named list.  The new item
  26846. --     must be of the same item kind as the one being replaced.
  26847. --
  26848. -- Parameters:
  26849. -- ----------
  26850. --     List       is the named list of interest
  26851. --     List_Item  is the value of list_type which will replace an item in list
  26852. --     Named      is the name (in token format) of a list_item in list which
  26853. --                will be replaced
  26854. --            
  26855. -- Exceptions: 
  26856. -- ----------  
  26857. --     Use_Error        is raised if item kinds do not match.
  26858. --     Search_Error     is raised if Named item is not found.
  26859. --
  26860. -- Notes: MIL_STD CAIS 5.4.1.17
  26861. -- -----
  26862. --
  26863. ----------------------------------------------------------------
  26864.  
  26865.     procedure Replace(List      : in out List_Type; 
  26866.                       List_Item : in List_Type; 
  26867.                       Named     : in Token_Type) is 
  26868.     begin
  26869.         Replace(List, List_Item, Retrieve(Named)); 
  26870.     end Replace; 
  26871. -----------------I N S E R T----POSITIONAL----------------------
  26872. -- Purpose: 
  26873. -- -------
  26874. --     Inserts a list item into a positional list.  Use_Error or Search_Error
  26875. --     may be raised indicating list item has not been inserted.
  26876. --
  26877. -- Parameters:
  26878. -- ----------
  26879. --     List       is the list_type of interest
  26880. --     List_Item  is the value to be added to list as a list_item
  26881. --     Position   is the position in list after which List_Item will be placed
  26882. --            
  26883. -- Exceptions: 
  26884. -- ----------  
  26885. --     Use_Error     is raised if this is a named list.
  26886. --                   or if position exceeds size of list
  26887. --
  26888. -- Notes: MIL_STD CAIS 5.4.1.18
  26889. -- -----
  26890. ----------------------------------------------------------------
  26891.     procedure Insert(List      : in out List_Type; 
  26892.                      List_Item : in List_Type; 
  26893.                      Position  : in Count) is 
  26894.         Current  : List_Type;       --ptr to list item to insert after
  26895.         New_Item : List_Type;       --ptr to area where new list item is built
  26896.     begin
  26897.         if Position /= 0 then 
  26898.             Find(List, Position, Current); 
  26899.         elsif List /= null and then List.Name /= null then 
  26900.             raise Use_Error;          --Mixed Named/Positional Items
  26901.         end if; 
  26902.         New_Item := new Item_Descriptor; 
  26903.  
  26904.         --store value fields
  26905.         New_Item.Name := null; 
  26906.         New_Item.Kind := Item_Kind'(List_Utilities.List_Item); 
  26907.                                                 --enumeration
  26908.         New_Item.List := List_Item;             --parameter
  26909.  
  26910.         --now set up pointers
  26911.         if Position /= 0 then 
  26912.             New_Item.Next_Item := Current.Next_Item;     --simple item
  26913.             Current.Next_Item := New_Item; 
  26914.         else 
  26915.             New_Item.Next_Item := List;                  --head item
  26916.             List := New_Item; 
  26917.         end if; 
  26918.     end Insert; 
  26919. -----------------I N S E R T----NAMED---STRING------------------
  26920. -- Purpose: 
  26921. -- -------
  26922. --     Inserts a list item into a named list.  Use_Error or Search_Error
  26923. --     may be raised indicating list item has not been inserted.
  26924. --
  26925. -- Parameters:
  26926. -- ----------
  26927. --     List       is the list_type of interest
  26928. --     List_Item  is the value to be added to list as a list_item
  26929. --     Named      is the string value of the name to be used for List-Item
  26930. --     Position   is the position in list after which List_Item will be placed
  26931. --            
  26932. -- Exceptions: 
  26933. -- ----------  
  26934. --     Use_Error     is raised if this is an unnamed list.
  26935. --                   or if position exceeds size of list
  26936. --
  26937. -- Notes: MIL_STD CAIS 5.4.1.18
  26938. -- -----
  26939. ----------------------------------------------------------------
  26940.     procedure Insert(List      : in out List_Type; 
  26941.                      List_Item : in List_Type; 
  26942.                      Named     : in Namestring; 
  26943.                      Position  : in Count) is 
  26944.         Current  : List_Type;      --ptr to list item to insert after
  26945.         New_Item : List_Type;      --ptr to area where new list item is built
  26946.         Token    : Token_Type;     --Name converted for Name_check
  26947.     begin
  26948.         if Position /= 0 then 
  26949.             Find_All(List, Position, Current); 
  26950.         end if; 
  26951.         if List /= null and then List.Name = null then 
  26952.             raise Use_Error;          --Mixed Named/Positional Items
  26953.         end if; 
  26954.         Identifier_Items.To_Token(Named, Token); 
  26955.         Name_Check(List, Token);        --Use_Error, if duplicate name
  26956.         New_Item := new Item_Descriptor; 
  26957.  
  26958.         --store value fields
  26959.         Validate_Item(Named, Identifier_Item, New_Item.Name); 
  26960.         New_Item.Kind := List_Utilities.List_Item;   --enumeration
  26961.         New_Item.List := List_Item;                          --parameter
  26962.  
  26963.         --now set up pointers
  26964.         if Position /= 0 then 
  26965.             New_Item.Next_Item := Current.Next_Item;     --simple item
  26966.             Current.Next_Item := New_Item; 
  26967.         else 
  26968.             New_Item.Next_Item := List;                  --head item
  26969.             List := New_Item; 
  26970.         end if; 
  26971.     end Insert; 
  26972. -----------------I N S E R T----NAMED---TOKEN-------------------
  26973. --
  26974. -- Purpose: 
  26975. -- -------
  26976. --     Inserts a list item into a named list.  Use_Error
  26977. --     or Search_Error may be raised indicating list item has
  26978. --     not been inserted.
  26979. --
  26980. -- Parameters:
  26981. -- ----------
  26982. --     List       is the list_type of interest
  26983. --     List_Item  is the value to be added to list as a list_item
  26984. --     Named      is the name value (in token form) to be used for List-Item
  26985. --     Position   is the position in list after which List_Item will be placed
  26986. --            
  26987. -- Exceptions: 
  26988. -- ----------  
  26989. --     Use_Error     is raised if this is an unnamed list.
  26990. --                   or if position exceeds size of list
  26991. --
  26992. -- Notes: MIL_STD CAIS 5.4.1.18
  26993. -- -----
  26994. --
  26995. ----------------------------------------------------------------
  26996.  
  26997.     procedure Insert(List      : in out List_Type; 
  26998.                      List_Item : in List_Type; 
  26999.                      Named     : in Token_Type; 
  27000.                      Position  : in Count) is 
  27001.     begin
  27002.         Insert(List, List_Item, Retrieve(Named), Position); 
  27003.     end Insert; 
  27004. -----------P O S I T I O N _ B Y _ V A L U E--------------------
  27005. --
  27006. -- Purpose:
  27007. -- -------  
  27008. --     Returns the position at which the next list_type item of the given
  27009. --     value is located. the search begins at the Start_Position and ends
  27010. --     when either an item of Value is found, the last item of the list
  27011. --     has been examined, or the item at the End_Position has been 
  27012. --     examined, whichever comes first.
  27013. --
  27014. -- Parameters:
  27015. -- ----------
  27016. --     List           is the list_type of interest
  27017. --     Value          is the value of list_type being looked for
  27018. --     Start_Position is the position of the starting item in the search
  27019. --     End_Position   is the position of the ending   item in the search
  27020. --     return         the position of an item whose value matches
  27021. --            
  27022. -- Exceptions:
  27023. -- ----------
  27024. --     Use_Error     raised if Start<End or Start > length of list
  27025. --     Search_Error  raised if Value not found in specified range
  27026. --
  27027. -- Notes: MIL_STD CAIS 5.4.1.19
  27028. -- -----
  27029. --
  27030. ----------------------------------------------------------------
  27031.  
  27032.   --MIL_STD CAIS 5.4.1.19
  27033.     function Position_By_Value(List           : in List_Type; 
  27034.                                Value          : in List_Type; 
  27035.                                Start_Position : in Position_Count := 
  27036.                                    Position_Count'First; 
  27037.                                End_Position   : in Position_Count := 
  27038.                                    Position_Count'Last) return Position_Count
  27039.         is 
  27040.         Pos     : Position_Count := 1; 
  27041.         Current : List_Type := List; 
  27042.  
  27043.     begin
  27044.         if Start_Position > End_Position then   --Valid Range??
  27045.             raise Use_Error; 
  27046.         end if; 
  27047.  
  27048.         while Pos < Start_Position loop         --Move to Start
  27049.             if Current = null then                  --End of list
  27050.                 raise Use_Error; 
  27051.             end if; 
  27052.  
  27053.             Pos := Pos + 1; 
  27054.             Current := Current.Next_Item; 
  27055.         end loop; 
  27056.  
  27057.         while Pos <= End_Position loop          --Check each item in range
  27058.             if Current = null then                  --End of List?
  27059.                 raise Search_Error; 
  27060.             end if; 
  27061.  
  27062.             if Current.Kind = List_Item and then Is_Equal(Current.List, Value)
  27063.                 then 
  27064.                 return Pos;                         --Match found
  27065.             end if; 
  27066.  
  27067.             Pos := Pos + 1; 
  27068.             Current := Current.Next_Item; 
  27069.         end loop; 
  27070.  
  27071.         raise Search_Error;                             --!!!No match
  27072.     end Position_By_Value; 
  27073.  
  27074.  
  27075. --------------------------------------------------------------------------
  27076. --   S E P A R A T E     P A C K A G E   I D E N T I F I E R _ I T E M
  27077. --MIL_STD CAIS 5.4.1.20
  27078. --------------------------------------------------------------------------
  27079.     package body Identifier_Items is separate; 
  27080.  
  27081.  
  27082.  
  27083.  
  27084. --------------------------------------------------------------------------
  27085. --   S E P A R A T E     P A C K A G E   S T R I N G _ I T E M
  27086. --MIL_STD CAIS 5.4.1.23
  27087. --------------------------------------------------------------------------
  27088.     package body String_Items is separate; 
  27089.  
  27090.  
  27091.  
  27092.  
  27093. end List_Utilities;  -- body
  27094. --::::::::::::::
  27095. --magnetic_tape_body.a
  27096. --::::::::::::::
  27097. separate(Cais)
  27098. package body Magnetic_Tape is 
  27099.     use Node_Definitions; 
  27100.     use Io_Definitions; 
  27101.  
  27102.  
  27103.     procedure Mount(Tape_Drive : File_Type; 
  27104.                     Tape_Name  : Reel_Name; 
  27105.                     Density    : Positive) is 
  27106.     begin
  27107.         Trace.Assert_Fatal(False, "Mount is NOT implemented"); 
  27108.     end Mount; 
  27109.  
  27110.     procedure Load_Unlabeled(Tape_Drive : File_Type; 
  27111.                              Density    : Positive; 
  27112.                              Block_Size : Positive) is 
  27113.     begin
  27114.         Trace.Assert_Fatal(False, "Load_Unlabeled is NOT implemented"); 
  27115.     end Load_Unlabeled; 
  27116.  
  27117.     procedure Initialize_Unlabeled(Tape_Drive : File_Type; 
  27118.                                    Density    : Positive; 
  27119.                                    Block_Size : Positive) is 
  27120.     begin
  27121.         Trace.Assert_Fatal(False, "Initialize_Unlabeled is NOT implemented"); 
  27122.     end Initialize_Unlabeled; 
  27123.  
  27124.     procedure Load_Labeled(Tape_Drive        : File_Type; 
  27125.                            Volume_Identifier : Volume_String; 
  27126.                            Density           : Positive; 
  27127.                            Block_Size        : Positive) is 
  27128.     begin
  27129.         Trace.Assert_Fatal(False, "Load_Labeled is NOT implemented"); 
  27130.     end Load_Labeled; 
  27131.  
  27132.     procedure Initialize_Labeled(Tape_Drive        : File_Type; 
  27133.                                  Volume_Identifier : Volume_String; 
  27134.                                  Density           : Positive; 
  27135.                                  Block_Size        : Positive; 
  27136.                                  Accessibility     : Character := ' ') is 
  27137.     begin
  27138.         Trace.Assert_Fatal(False, "Initialize_Labeled is NOT implemented"); 
  27139.     end Initialize_Labeled; 
  27140.  
  27141.     procedure Unload(Tape_Drive : File_Type) is 
  27142.     begin
  27143.         Trace.Assert_Fatal(False, "Unload is NOT implemented"); 
  27144.     end Unload; 
  27145.  
  27146.     procedure Dismount(Tape_Drive : File_Type) is 
  27147.     begin
  27148.         Trace.Assert_Fatal(False, "Dismount is NOT implemented"); 
  27149.     end Dismount; 
  27150.  
  27151.     function Is_Loaded(Tape_Drive : File_Type) return Boolean is 
  27152.     begin
  27153.         Trace.Assert_Fatal(False, "Is_Loaded is NOT implemented"); 
  27154.         return (False); 
  27155.     end Is_Loaded; 
  27156.  
  27157.     function Is_Mounted(Tape_Drive : File_Type) return Boolean is 
  27158.     begin
  27159.         Trace.Assert_Fatal(False, "Is_Mounted is NOT implemented"); 
  27160.         return (False); 
  27161.     end Is_Mounted; 
  27162.  
  27163.     function Tape_Status(Tape_Drive : File_Type) return Tape_Position is 
  27164.     begin
  27165.         Trace.Assert_Fatal(False, "Tape_Status is NOT implemented"); 
  27166.         return Other; 
  27167.     end Tape_Status; 
  27168.  
  27169.     procedure Rewind_Tape(Tape_Drive : File_Type) is 
  27170.     begin
  27171.         Trace.Assert_Fatal(False, "Rewind_Tape is NOT implemented"); 
  27172.     end Rewind_Tape; 
  27173.  
  27174.     procedure Skip_Tape_Marks(Tape_Drive : File_Type; 
  27175.                               Number     : Integer := 1; 
  27176.                               Tape_State : in out Tape_Position) is 
  27177.     begin
  27178.         Trace.Assert_Fatal(False, "Skip_Tape_Marks is NOT implemented"); 
  27179.     end Skip_Tape_Marks; 
  27180.  
  27181.     procedure Write_Tape_Mark(Tape_Drive : File_Type; 
  27182.                               Number     : Positive := 1; 
  27183.                               Tape_State : in out Tape_Position) is 
  27184.     begin
  27185.         Trace.Assert_Fatal(False, "Write_Tape_Mark is NOT implemented"); 
  27186.     end Write_Tape_Mark; 
  27187.  
  27188.     procedure Volume_Header(Tape_Drive        : File_Type; 
  27189.                             Volume_Identifier : Volume_String; 
  27190.                             Accessibility     : Character := ' ') is 
  27191.     begin
  27192.         Trace.Assert_Fatal(False, "Volume_Header is NOT implemented"); 
  27193.     end Volume_Header; 
  27194.  
  27195.     procedure File_Header(Tape_Drive      : File_Type; 
  27196.                           File_Identifier : File_String; 
  27197.                           Expiration_Date : String := " 99366"; 
  27198.                           Accessibility   : Character := ' ') is 
  27199.     begin
  27200.         Trace.Assert_Fatal(False, "File_Header is NOT implemented"); 
  27201.     end File_Header; 
  27202.  
  27203.     procedure End_File_Label(Tape_Drive : File_Type) is 
  27204.     begin
  27205.         Trace.Assert_Fatal(False, "End_File_Label is NOT implemented"); 
  27206.     end End_File_Label; 
  27207.  
  27208.     procedure Read_Label(Tape_Drive : File_Type; 
  27209.                          Label      : in out Label_String) is 
  27210.     begin
  27211.         Trace.Assert_Fatal(False, "Read_Label is NOT implemented"); 
  27212.     end Read_Label; 
  27213.  
  27214.  
  27215. end Magnetic_Tape; 
  27216. --::::::::::::::
  27217. --node_get_next.a
  27218. --::::::::::::::
  27219.  
  27220.  
  27221. ----------------------------------------------------------------------
  27222. --                         G E T _ N E X T
  27223. --           (Separate Procedure from Package Node_Management)
  27224. --
  27225. --            Returns node handle to next node in an iterator
  27226. --
  27227. --
  27228. --                  Ada Software Engineering Group
  27229. --                      The MITRE Corporation
  27230. --                         McLean, VA 22102
  27231. --
  27232. --
  27233. --                   Wed Oct  9 15:01:37 EDT 1985
  27234. --
  27235. --                 (Unclassified and uncopyrighted)
  27236. --
  27237. ----------------------------------------------------------------------
  27238. ----------------------          Get_Next       ----------------------
  27239. --
  27240. --  Purpose: Returns an open node handle to the next node in the iterator.
  27241. --  -------  If Next_Node is open prior to the call to Get_Next, it is
  27242. --         closed prior to being opened for the next node. Intent and
  27243. --         Time_Limit specify conditions under which Next_Node is opened.
  27244. --
  27245. --  Parameters:
  27246. --  ----------
  27247. --    Iterator   is a previously constructed node iterator.
  27248. --    Next_Node  is the node handle to be opened for the iterator's next node
  27249. --    Intent     is the intent with which Next_Node is to be opened
  27250. --    Time_Limit specifies the delay on waiting for the unlocking of the node
  27251. --               in accordance with the desired intent.
  27252. --
  27253. --  Exceptions:
  27254. --  ----------
  27255. --    Name_Error is raised if the node whose handle is to be returned is
  27256. --        unobtainable and the intent specified is other than Existence.
  27257. --
  27258. --    Use_Error is raised if the Iterator has not been previously set by the
  27259. --        procedure Iterate, or if the iterator is exhausted, i.e.,
  27260. --        More(Iterator) = false, or if Intent is an empty array.
  27261. --
  27262. --    Lock_Error is raised if the opening of the node handle is delayed beyond
  27263. --        the specified Time_Limit due to the existence of locks in conflict
  27264. --        with the specified intent.
  27265. --
  27266. --    Access_Violation is raised if the current process discretionary control
  27267. --        rights are insufficient to obtain access to the next node with the
  27268. --        specified intent.  Access_Violation is raised only if the conditions
  27269. --        for Name_Error are not present.
  27270. --
  27271. --    Security_Violation is raised if the current process' attempt to obtain
  27272. --        access to the next node with the specified Intent represents a 
  27273. --        violation of mandatory access controls for the CAIS.  Security_
  27274. --        Violation is raised only if the conditions for other exceptions are
  27275. --        not present.
  27276. --
  27277. --  Notes:CAIS 5.1.3.13
  27278. --  -----
  27279. --    
  27280. --  Revision History
  27281. --  ----------------
  27282. --    12-04-85    Removed references to V_String which is now hidden.
  27283. --            We now use Identifier_Items.To_Text(xx).
  27284. ---------------------------------------------------------------------
  27285. separate(Cais.Node_Management)
  27286. procedure Get_Next(   -- get open node handle to next node  in iterator
  27287.                    Iterator   : in out Node_Iterator; 
  27288.                                       -- see CAIS 1.4 5.1.2.25 for expl.
  27289.                    Next_Node  : in out Node_Type; 
  27290.                                           -- will be the open node handle
  27291.                    Intent     : in Intention := (1 => Existence); 
  27292.                                                  --intent for opening
  27293.                    Time_Limit : in Duration := No_Delay)
  27294.                                                  --time limit for opening
  27295. is 
  27296.  
  27297.     use Iterator_Support; 
  27298.  
  27299.     Value         : List_Type;                  --List of valid keys
  27300.     Relation_Name : Token_Type; 
  27301.     Key_Name      : Token_Type; 
  27302.  
  27303. begin
  27304.     if Iterator.Rel_Position < 0 or else                                --Poorly formed
  27305.     Iterator.List = null or else Iterator.Rel_Position > Length(Iterator.List.
  27306.         all) then 
  27307.         raise Node_Definitions.Use_Error; 
  27308.  
  27309.     else                                                        --get next Key
  27310.         Iterator.Key_Position := Iterator.Key_Position + 1; 
  27311.         Extract(Iterator.List.all, Iterator.Rel_Position, Value); 
  27312.  
  27313.         if Iterator.Rel_Position = Length(Iterator.List.all) and then Iterator.
  27314.             Key_Position > Length(Value) then 
  27315.             raise Node_Definitions.Use_Error;                   --Exhausted
  27316.         end if; 
  27317.  
  27318.         if Iterator.Key_Position > Length(Value) then             --new relation
  27319.             Iterator.Rel_Position := Iterator.Rel_Position + 1; 
  27320.             Iterator.Key_Position := 1; 
  27321.             Extract(Iterator.List.all, Iterator.Rel_Position, Value); 
  27322.         end if; 
  27323.  
  27324.         Item_Name(Iterator.List.all, Iterator.Rel_Position, Relation_Name); 
  27325.         Item_Name(Value, Iterator.Key_Position, Key_Name); 
  27326.  
  27327.       -- close node, if it is already open
  27328.         if Is_Open(Next_Node) then 
  27329.             Close(Next_Node); 
  27330.         end if; 
  27331.  
  27332.       -- build a pathname from the base, relation, and key...
  27333.         Open(Next_Node, Iterator.Base_Name(1 .. Iterator.Base_Name_Length) & "'"
  27334.             & Identifier_Items.To_Text(Relation_Name) & "(" & Identifier_Items.
  27335.             To_Text(Key_Name) & ")", Intent, Time_Limit); 
  27336.  
  27337.     end if; 
  27338. end Get_Next; 
  27339. --::::::::::::::
  27340. --node_internals_body.a
  27341. --::::::::::::::
  27342.  
  27343. ----------------------------------------------------------------------
  27344. --                    N O D E _ I N T E R N A L S
  27345. --                          (Package Body)
  27346. --
  27347. --
  27348. --             Services to Work With CAIS Pathnames and
  27349. --                    The Implementation of Nodes 
  27350. --
  27351. --
  27352. --
  27353. --                  Ada Software Engineering Group
  27354. --                      The MITRE Corporation
  27355. --                         McLean, VA 22102
  27356. --
  27357. --
  27358. --                   Mon May 20 13:58:36 EDT 1985
  27359. --
  27360. --                 (Unclassified and uncopyrighted)
  27361. --
  27362. ----------------------------------------------------------------------
  27363. ----------------------------------------------------------------------
  27364. --
  27365. --  Purpose:
  27366. --  -------
  27367. --      This package provides services to work with CAIS pathnames
  27368. --      and to support the implementation of CAIS nodes.
  27369. --
  27370. --  Usage:
  27371. --  -----
  27372. --    TBS
  27373. --
  27374. --  Example:
  27375. --  -------
  27376. --    TBS
  27377. --
  27378. --  Notes:
  27379. --  -----
  27380. --
  27381. --  Revision History:
  27382. --  ----------------
  27383. --
  27384. -------------------------------------------------------------------
  27385. with Trace; 
  27386. with Character_Set; use Character_Set; 
  27387. with Generic_Stack; 
  27388.  
  27389. separate(Cais)
  27390. package body Node_Internals is 
  27391.  
  27392.     use Pragmatics; 
  27393.     use Cais_Internals_Exceptions; 
  27394.  
  27395.     type Pathname(Size : Natural) is 
  27396.         record
  27397.             Str_Buf : String(1 .. Size); 
  27398.                                     -- String Buffer for Pathname image
  27399.             Index   : Natural := 1; -- Offset of current char in Str_Buf
  27400.         end record; 
  27401.  
  27402.  
  27403.     type Parse_Symbol is (Element_Set, Path_Element, Relation_Name, 
  27404.         Paren_Relationship_Key, Relationship_Key, 
  27405.  
  27406.     Identifier, Sharp, Colon, Left_Paren, Right_Paren, Tic, Dot, Other, 
  27407.         End_Of_Pathname); 
  27408.  
  27409.     subtype Token_Class is Parse_Symbol range Identifier .. End_Of_Pathname; 
  27410.  
  27411.     package Symbol_Stack is 
  27412.         new Generic_Stack(Parse_Symbol); 
  27413.     use Symbol_Stack; 
  27414.  
  27415.  
  27416.     type Token is 
  27417.         record
  27418.             Value     : String(1 .. Pragmatics.Max_Token_Size) := (others => ' '
  27419.                 );               -- Token image
  27420.             Class     : Token_Class; 
  27421.             Last_Char : Natural; 
  27422.                              -- offset of last char of image in Value
  27423.         end record; 
  27424.  
  27425. ----------------------  C O N V E R T _ T O _ P N -------------------
  27426. --
  27427. --  Purpose:
  27428. --  -------
  27429. --    This function converts a string containing a path to a pathname.
  27430. --
  27431. --  Parameters:
  27432. --  ----------
  27433. --    Name - string containing the path to be converted..
  27434. --
  27435. --  Exceptions:
  27436. --  ----------
  27437. --    None.
  27438. --
  27439. --  Notes:
  27440. --  -----
  27441. --
  27442. ---------------------------------------------------------------------
  27443.  
  27444.     function Convert_To_Pn(Name : Node_Definitions.Name_String) return Pathname
  27445.         is 
  27446.  
  27447.         Path : Pathname(Name'Length); 
  27448.     begin
  27449.         Path.Str_Buf := Name; 
  27450.         return Path; 
  27451.     exception
  27452.         when others => 
  27453.             Trace.Report("*** Unhandled exception in Convert_To_Pn ***"); 
  27454.             raise Trace.Assertion_Violation; 
  27455.     end Convert_To_Pn; 
  27456.  
  27457. ----------------------   S K I P _ W H I T E S P A C E --------------
  27458. --
  27459. --  Purpose:
  27460. --  -------
  27461. --    This procedure advances the index in a pathname past any
  27462. --    whitespace (blanks, tabs).
  27463. --
  27464. --  Parameters:
  27465. --  ----------
  27466. --    Name - the pathname to be updated.
  27467. --
  27468. --  Exceptions:
  27469. --  ----------
  27470. --    None.
  27471. --
  27472. --  Notes:
  27473. --  -----
  27474. --
  27475. ---------------------------------------------------------------------
  27476.  
  27477.     procedure Skip_Whitespace(Name : in out Pathname) is 
  27478.  
  27479.     begin
  27480.         for I in Name.Index .. Name.Size loop
  27481.             if Name.Str_Buf(I) /= ' ' and Name.Str_Buf(I) /= Ascii.Ht then 
  27482.                 Name.Index := I; 
  27483.                 return; 
  27484.             end if; 
  27485.         end loop; 
  27486.         -- if control gets here, there were no more non-blank 
  27487.         -- characters in the pathname.  Set Index past end of pathname
  27488.         -- so that Get_Next_Token knows it is at end of pathname.
  27489.         Name.Index := Name.Size + 1; 
  27490.         return; 
  27491.  
  27492.     exception
  27493.         when others => 
  27494.             Trace.Report("Unhandled exception in Skip_Whitespace"); 
  27495.             raise Trace.Assertion_Violation; 
  27496.     end Skip_Whitespace; 
  27497.  
  27498.  
  27499.     procedure Get_Identifier(Path : in out Pathname; 
  27500.                              Id   : in out Token) is separate; 
  27501.  
  27502.  
  27503.  
  27504.     procedure Get_Next_Token(From : in out Pathname; 
  27505.                              Next : in out Token) is separate; 
  27506.  
  27507.  
  27508.  
  27509.     procedure Get_Parsed_Pn(Name   : Node_Definitions.Name_String; 
  27510.                             Result : in out Parsed_Pn) is separate; 
  27511.  
  27512. ------------------- P N _ C O M P O N E N T _ C O U N T -------------
  27513. --
  27514. --  Purpose:
  27515. --  -------
  27516. --    This function returns the number of distinct pathname components
  27517. --    (i.e. pathname elements) in the given parsed pathname.
  27518. --
  27519. --  Parameters:
  27520. --  ----------
  27521. --    Pn - the parsed pathname to be examined.
  27522. --
  27523. --  Exceptions:
  27524. --  ----------
  27525. --    None.
  27526. --
  27527. --  Notes:
  27528. --  -----
  27529. --
  27530. ---------------------------------------------------------------------
  27531.  
  27532.     function Pn_Component_Count(Pn : Parsed_Pn) return Natural is 
  27533.  
  27534.     begin
  27535.         return Node_Representation.Pn_Comp_List.Last_Index(Pn.L); 
  27536.     exception
  27537.         when others => 
  27538.             Trace.Report("Unhandled exception in Pn_Component_Count"); 
  27539.             raise Trace.Assertion_Violation; 
  27540.     end Pn_Component_Count; 
  27541.  
  27542.  
  27543.  
  27544. --------------------  G E T _ P N _ C O M P O N E N T ---------------
  27545. --
  27546. --  Purpose:
  27547. --  -------
  27548. --    This procedure extracts the data associated with a specific
  27549. --    pathname component (i.e. pathname element).
  27550. --
  27551. --  Parameters:
  27552. --  ----------
  27553. --    Pn         - parsed pathname to be examined
  27554. --    Index      - offset of path element to be examined
  27555. --    Rel_Name   - Relation name of this path element
  27556. --    Rel_Key    - Relationship Key of this path element
  27557. --    Latest_Rel - boolean indicating if the relationship key
  27558. --                 ends with the latest key character (#)
  27559. --
  27560. --  Exceptions:
  27561. --  ----------
  27562. --    No_Such_Component - raised if "Index" does not refer to
  27563. --                        an existing component in the pathname.
  27564. --
  27565. --  Notes:
  27566. --  -----
  27567. --
  27568. ---------------------------------------------------------------------
  27569.  
  27570.     procedure Get_Pn_Component(Pn         : Parsed_Pn; 
  27571.                                Index      : Positive; 
  27572.                                Rel_Name   : in out String; 
  27573.                                Rel_Key    : in out String; 
  27574.                                Latest_Rel : in out Boolean) is 
  27575.  
  27576.         Tmp_Rec : Pn_Rec; 
  27577.  
  27578.     begin
  27579.  
  27580.         -- Set_Current_Index returns True if OK, 
  27581.         -- False if Index is too large
  27582.         if not Node_Representation.Pn_Comp_List.Set_Current_Index(Pn.L, Index)
  27583.             then 
  27584.             raise No_Such_Component; 
  27585.         end if; 
  27586.  
  27587.         Tmp_Rec := Node_Representation.Pn_Comp_List.Return_Current_Element(Pn.L)
  27588.             ; 
  27589.         Rel_Name := Tmp_Rec.Rel_Name(Tmp_Rec.Rel_Name'First .. Last_Non_Space(
  27590.             Tmp_Rec.Rel_Name)); 
  27591.         Rel_Key := Tmp_Rec.Rel_Key(Tmp_Rec.Rel_Key'First .. Last_Non_Space(
  27592.             Tmp_Rec.Rel_Key)); 
  27593.         Latest_Rel := Tmp_Rec.Latest_Key; 
  27594.  
  27595.     exception
  27596.         when No_Such_Component => 
  27597.             raise; 
  27598.         when others => 
  27599.             Trace.Report("Unhandled exception in Get_Pn_Component"); 
  27600.             raise Trace.Assertion_Violation; 
  27601.     end Get_Pn_Component; 
  27602.  
  27603.  
  27604.     procedure Create_Node(Node                 : in out Node_Type; 
  27605.                           Base                 : in out Node_Type; 
  27606.                           Kind                 : Node_Kind; 
  27607.                           Internals_Attributes : List_Type; 
  27608.                           User_Attributes      : List_Type; 
  27609.                           Internals_Relations  : List_Type; 
  27610.                           Intent               : Intention; 
  27611.                           Access_Control       : List_Type; 
  27612.                           Level                : List_Type; 
  27613.                           Key                  : String; 
  27614.                           Relation             : String) is separate; 
  27615.  
  27616.     procedure Read_Shadow_File(Node : in out Node_Type) is separate; 
  27617.  
  27618.     procedure Write_Shadow_File(Node : Node_Type) is separate; 
  27619.  
  27620. end Node_Internals; 
  27621. --::::::::::::::
  27622. --node_iterate.a
  27623. --::::::::::::::
  27624.  
  27625.  
  27626. ----------------------------------------------------------------------
  27627. --                          I T E R A T E
  27628. --              (Separate Procedure From Node_Management)
  27629. --
  27630. --      Creates node iterators given base, relation and key pattern
  27631. --
  27632. --
  27633. --                  Ada Software Engineering Group
  27634. --                      The MITRE Corporation
  27635. --                         McLean, VA 22102
  27636. --
  27637. --
  27638. --                   Thu Oct 10 07:55:05 EDT 1985
  27639. --
  27640. --                 (Unclassified and uncopyrighted)
  27641. --
  27642. ----------------------------------------------------------------------
  27643. --------------------------ITERATE-------------------------------------
  27644. --
  27645. --  Purpose:  Creates a set of nodes from the named node which match the
  27646. --  -------   provided key and relation patterns containing wild card
  27647. --            characters '*' to match any string and '?' to match any
  27648. --            character.
  27649. --
  27650. --  Parameters:
  27651. --  ----------
  27652. --   Iterator is the set of matching attributes
  27653. --   Node     is the node whose relationships are searched for matches
  27654. --   Kind     is the kind of nodes to include in the iterator
  27655. --   Key      is the string (with * and ?) which determines key matches
  27656. --   Relation is the string (with * and ?) which determines relation matches
  27657. --   Primary_Only  is a flag requesting only primary relationships be searched
  27658. --
  27659. --  Exceptions:
  27660. --  ----------
  27661. --   Use_Error        is raised if the Pattern in Key or Relation is
  27662. --              syntactically illegal
  27663. --   
  27664. --   Status_Error     is raised if the node is not an open node handle
  27665. --
  27666. --   Intent_Violation is rasied if Node is not open with the right to
  27667. --              read relationships.
  27668. --
  27669. --  Notes:
  27670. --  -----
  27671. --    CAIS 5.1.2.26
  27672. --
  27673. --  Change History:
  27674. --  --------------
  27675. --    01-08-86    Added checks for Kind and for Primary_Only
  27676. ---------------------------------------------------------------------
  27677. separate(Cais.Node_Management)
  27678. procedure Iterate(        -- build an iterator
  27679.                   Iterator     : in out Node_Iterator; 
  27680.                                           -- see CAIS 1.4 5.1.2.25 for expl.)
  27681.                   Node         : in Node_Type;    -- open node handle for desired node
  27682.                   Kind         : in Node_Kind; 
  27683.                                           -- kind of nodes to include
  27684.                   Key          : in Relationship_Key_Pattern := "*"; 
  27685.                                           -- pattern to select keys
  27686.                   Relation     : in Relation_Name_Pattern := Default_Relation; 
  27687.                                           -- pattern to select relations
  27688.                   Primary_Only : in Boolean := True) is 
  27689.  
  27690.     use Iterator_Support; 
  27691.     use Identifier_Items; 
  27692.  
  27693.     Relation_List : List_Type; 
  27694.     Relation_Name : Token_Type; 
  27695.     Relation_Size : Integer := 0; 
  27696.     Key_List      : List_Type; 
  27697.     Key_Name      : Token_Type; 
  27698.     Key_Size      : Integer := 0; 
  27699.     It_Key_List   : List_Type; 
  27700.  
  27701.     Rel_Attr      : List_Type; 
  27702.     Primary       : Boolean; 
  27703.     Shadow_File   : String(1 .. Max_Shadow_File_Length); 
  27704.  
  27705.  
  27706.     function Kind_Matches(Rel_Attr : List_Type; 
  27707.                           Kind     : Node_Kind) return Boolean is 
  27708.         Kind_Value : List_Type; 
  27709.         Kind_List  : List_Type; 
  27710.         Pos        : Position_Count; 
  27711.     begin
  27712.         Extract(Rel_Attr, "Kind", Kind_Value); 
  27713.         String_To_Simple_List(Node_Kind'Image(Kind), Kind_List); 
  27714.         if Is_Equal(Kind_Value, Kind_List) then
  27715.             return True; 
  27716.         else
  27717.             return False; 
  27718.     end if;
  27719.     end Kind_Matches; 
  27720.  
  27721.  
  27722. begin
  27723.     Verify_Pattern(Relation, Relation_Size);                    --Use_Error check
  27724.     Verify_Pattern(Key, Key_Size);                      --Use_Error check
  27725.     if not Is_Open(Node) then                           --Status_Error check
  27726.         raise Node_Definitions.Status_Error; 
  27727.     end if; 
  27728.     Check_Intentions(Node, Read_Relationships);         --Intent check
  27729.     Get_Node_Relations(Node, Relation_List); 
  27730.  
  27731.                                                         --Initialize Iterator
  27732.     Iterator.List := new List_Type; 
  27733.     Iterator.Rel_Position := 1; 
  27734.     Iterator.Key_Position := 0; 
  27735.     Get_Pathname(Node, Iterator.Base_Name, Iterator.Base_Name_Length); 
  27736.     Copy(Iterator.List.all, Empty_List); 
  27737.  
  27738.     for I in 1 .. Length(Relation_List) loop
  27739.         Item_Name(Relation_List, I, Relation_Name); 
  27740.         if Pattern_Match(To_Text(Relation_Name), Relation(Relation'First .. 
  27741.             Relation_Size)) then 
  27742.  
  27743.             Extract(Relation_List, I, Key_List);        --Relation matches, now
  27744.             for J in 1 .. Length(Key_List) loop         --check all keys
  27745.                 Item_Name(Key_List, J, Key_Name); 
  27746.                 if Pattern_Match(To_Text(Key_Name), Key(Key'First .. Key_Size))
  27747.                     then 
  27748.  
  27749.                   --Match!!  First check that Node kind is valid
  27750.                   --and that Primary_Only is satified
  27751.                     Get_A_Relationship(Node, To_Text(Relation_Name), To_Text(
  27752.                         Key_Name), Shadow_File, Rel_Attr, Primary); 
  27753.                     if Kind_Matches(Rel_Attr, Kind) and then ((not Primary_Only)
  27754.                         or Primary) then 
  27755.  
  27756.                     --Add Relation and Key to iterator
  27757.                     --If this relation is already in the iterator
  27758.                     --just add Key to its list.  Otherwise create
  27759.                     --list with just this key and add this relation
  27760.                     --to the iterator
  27761.                         begin
  27762.                             Extract(Iterator.List.all, Relation_Name, 
  27763.                                 It_Key_List); 
  27764.                         exception
  27765.                             when Search_Error | Node_Definitions.Use_Error => 
  27766.                                 Copy(It_Key_List, Empty_List); 
  27767.                                 Insert(Iterator.List.all, It_Key_List, 
  27768.                                     Relation_Name, Lexical_Position(Iterator.
  27769.                                     List.all, Relation_Name)); 
  27770.                         end; 
  27771.                         Insert(It_Key_List, Key_Name, Key_Name, Lexical_Position
  27772.                             (It_Key_List, Key_Name)); 
  27773.                         Replace(Iterator.List.all, It_Key_List, Relation_Name); 
  27774.                     end if; 
  27775.                          -- Primary and kind tests pass
  27776.                 end if;   --relation and key match
  27777.             end loop;       --check all keys
  27778.         end if;                       --relation matches
  27779.     end loop;                    --check all relations
  27780. end Iterate; 
  27781. --::::::::::::::
  27782. --node_management_body.a
  27783. --::::::::::::::
  27784.  
  27785. ----------------------------------------------------------------------
  27786. --             C A I S _ N O D E _ M A N A G E M E N T
  27787. --                         (Package Body)
  27788. --
  27789. --
  27790. --       Primitives For Manipulating Nodes and Their Relationships
  27791. --
  27792. --
  27793. --
  27794. --
  27795. --
  27796. --                  Ada Software Engineering Group
  27797. --                      The MITRE Corporation
  27798. --                         McLean, VA 22102
  27799. --
  27800. --
  27801. --                   Thu Sep 12 14:30:13 EDT 1985
  27802. --
  27803. --                 (Unclassified and uncopyrighted)
  27804. --
  27805. ----------------------------------------------------------------------
  27806.  
  27807. with Str_Pack; use Str_Pack; 
  27808. with Character_Set; use Character_Set; 
  27809. with Text_Io; 
  27810.  
  27811. separate(Cais)
  27812. package body Node_Management is 
  27813.  
  27814.     use Standard.Text_Io; 
  27815.     use Node_Internals; 
  27816.     use Node_Representation; 
  27817.     use Cais_Utilities; 
  27818.     use Cais_Internals_Exceptions; 
  27819.     use Cais_Host_Dependent; 
  27820.     use Trace; 
  27821.  
  27822.  
  27823. ------------------------       O P E N       ------------------------
  27824. --
  27825. --  Purpose:
  27826. --  -------
  27827. --    These procedure return an open node handle in "Node" to the
  27828. --    node identified by the pathname "Name" or "Base"/"Key"/"Relation",
  27829. --    respectively.  
  27830. --
  27831. --  Parameters:
  27832. --  ----------
  27833. --    Node      - a node handle, initially closed, to be opened to the
  27834. --                identified node
  27835. --    Name      - the pathname identifying the node to be opened
  27836. --    Base      - open node handle to a base node for identification
  27837. --    Key       - the relationship key for node identification
  27838. --    Relation  - the relation name for node identification
  27839. --    Intent    - the intent of subsequent operations on the node; the
  27840. --                actual parameter takes the form of an array aggregate
  27841. --    Time_Limit - specifies time limit for the delay on waiting for the 
  27842. --                unlocking of a node in accordance with the desired intent
  27843. --
  27844. --  Exceptions:
  27845. --  ----------
  27846. --    Name_Error        - raised if the pathname specified by "Name" is
  27847. --                        syntactically illegal or if any traversed node
  27848. --                        in the path specified by pathname is unobtainable,
  27849. --                        inaccessible, or non-existant, or if the relationship
  27850. --                        specified by "Relation" and "Key" or by the last
  27851. --                        path element of "Name" does not exist.  Name_Error
  27852. --                        is also raised if the node to which a handle is to
  27853. --                        be opened is inaccessible or unobtainable and the
  27854. --                        given "Intent" includes any intent other 
  27855. --                        than "Existence".
  27856. --    Use_Error         - is raised if the specified intent is an empty array.
  27857. --    Status_Error      - is raised if the Node_Handle "Node" is already
  27858. --                        open prior to the call on Open or if Base is not
  27859. --                        an open node handle.
  27860. --    Lock_Error        - is raised if the Open operation is delayed beyond
  27861. --                        the specified time limit due to the existance of
  27862. --                        locks in conflict with the specified Intent.  This
  27863. --                        includes any delays caused by locks on nodes
  27864. --                        traversed on the path specified by the pathname
  27865. --                        "Name", or locks on the node identified by "Base",
  27866. --                        preventing the reading of relationships emanating
  27867. --                        from these nodes.
  27868. --    Intent_Violation  - is raised if "Base" was not opened with an intent
  27869. --                        establishing the right to read relationships.
  27870. --    Access_Violation  - is raised if the current process's discretionary
  27871. --                        access control rights are insufficient to traverse
  27872. --                        the path specified by "Name" or by "Base", "Key",
  27873. --                        and "Relation" or to obtain access to the node
  27874. --                        consistent with the specified intent.  
  27875. --                        Access_Violation is raised only if the conditions
  27876. --                        for Name_Error are not present.
  27877. --    Security_Violation -is raised if the attempt to obtain access to the
  27878. --                        node with the specified intent represents a 
  27879. --                        violation of mandatory access controls for the
  27880. --                        CAIS.  Security_Violation is raised only if the
  27881. --                        conditions for other exceptions are not present.
  27882. --
  27883. --  Notes:   CAIS 5.1.2.1
  27884. --  -----
  27885. --
  27886. ---------------------------------------------------------------------
  27887.  
  27888.     use Character_Set; 
  27889.  
  27890.     procedure Open(Node       : in out Node_Type; 
  27891.                    Name       : Node_Definitions.Name_String; 
  27892.                    Intent     : Intention := (1 => Read); 
  27893.                    Time_Limit : Duration := No_Delay) is 
  27894.  
  27895.         use Cais_Host_Dependent; 
  27896.         use List_Utilities; 
  27897.         use Trace; 
  27898.  
  27899.         Pn            : Node_Representation.Parsed_Pn; 
  27900.         Rel_Name      : String(1 .. Max_Relationship_Name) := (others => ' '); 
  27901.         Rel_Key       : String(1 .. Max_Relationship_Key) := (others => ' '); 
  27902.         Path_Elements : Natural; 
  27903.         Shadow_File   : String(1 .. Max_Shadow_File_Length); 
  27904.         Attributes    : List_Type; 
  27905.         Primary       : Boolean; 
  27906.         Latest_Key    : Boolean; 
  27907.         Shadow_Length : Natural; 
  27908.  
  27909.     begin
  27910.  
  27911.         if Intent'Length = 0 then 
  27912.             raise Node_Definitions.Use_Error; 
  27913.         end if; 
  27914.         if Open_Status(Node) then 
  27915.             raise Node_Definitions.Status_Error; 
  27916.         end if; 
  27917.  
  27918.         Get_Parsed_Pn(Name, Pn); 
  27919.         Path_Elements := Node_Internals.Pn_Component_Count(Pn); 
  27920.  
  27921.     -- Begin navigating pathname from current process
  27922.         Set_Shadow_File_Name(Node, Cais_Host_Dependent.
  27923.             Current_Process_Shadow_File); 
  27924.         Node_Internals.Read_Shadow_File(Node); 
  27925.         Get_Pn_Component(Pn, 1, Rel_Name, Rel_Key, Latest_Key); 
  27926.         Get_A_Relationship(Node, Rel_Name, Rel_Key, Shadow_File, Attributes, 
  27927.             Primary); 
  27928.  
  27929.     -- Now navigate the pathname components to the last element
  27930.         for Index in 2 .. Path_Elements loop
  27931.             Set_Shadow_File_Name(Node, Shadow_File); 
  27932.             Rel_Name := (others => ' '); 
  27933.             Rel_Key := (others => ' '); 
  27934.             Shadow_File := (others => ' '); 
  27935.             Get_Pn_Component(Pn, Index, Rel_Name, Rel_Key, Latest_Key); 
  27936.             Node_Internals.Read_Shadow_File(Node); 
  27937.             Get_A_Relationship(Node, Rel_Name, Rel_Key, Shadow_File, Attributes
  27938.                 , Primary); 
  27939.         end loop; 
  27940.  
  27941.     -- Shadow_File now contains the name of the shadow file for the
  27942.     -- last pathname element; the values in this shadow file are
  27943.     -- returned in the opened node handle.
  27944.     -- This call to Read_Shadow_File is associated with its own
  27945.     -- exception handler, in case the shadow file does not exist
  27946.     -- and the Intent was only for existence.
  27947.  
  27948.  
  27949.         Set_Shadow_File_Name(Node, Shadow_File); 
  27950.  
  27951.         Existence_Check : begin
  27952.           -- block for exception handler
  27953.             Node_Internals.Read_Shadow_File(Node); 
  27954.         exception
  27955.             when No_Such_Shadow_File => 
  27956.             -- if the only intent for this open was Existence,
  27957.             -- return an open node handle; otherwise, raise a Name_Error
  27958.                 for I in Intent'range loop
  27959.                     if Intent(I) /= Existence then 
  27960.                         raise Node_Definitions.Name_Error; 
  27961.                     end if; 
  27962.                 end loop; 
  27963.             when others => 
  27964.                 raise; 
  27965.         end Existence_Check; 
  27966.  
  27967.     -- First check that we aren't about to allow the user to
  27968.     -- access the system node via CAIS interfaces...
  27969.         Shadow_Length := Character_Set.Last_Non_Space(Shadow_File); 
  27970.         if Shadow_File(1 .. Shadow_Length) = Cais_Host_Dependent.
  27971.             Cais_System_Node then 
  27972.         -- CAIS Spec 4.3.4.2(3) prohibits direct access to the
  27973.         -- System_Node. presumably this means that an attempt to
  27974.         -- Open it is an attempt to Open an inaccessible node, hence
  27975.         -- a Name_Error is raised by Open.
  27976.             raise Node_Definitions.Name_Error; 
  27977.         end if; 
  27978.  
  27979.         Set_Open(Node, True); 
  27980.         Set_Intent(Node, Intent); 
  27981.         Set_Pathname(Node, Name); 
  27982.  
  27983.     exception
  27984.     -- exceptions that are trapped (nothing propagated)
  27985.         -- NONE
  27986.     -- exceptions that are propagated
  27987.         when Node_Definitions.Name_Error | Node_Definitions.Use_Error | 
  27988.             Node_Definitions.Lock_Error | Node_Definitions.Status_Error | 
  27989.             Node_Definitions.Intent_Violation | Node_Definitions.
  27990.             Access_Violation | Node_Definitions.Security_Violation => 
  27991.             raise; 
  27992.     -- exceptions that are mapped to other exceptions
  27993.         when Pathname_Syntax_Error | No_Such_Relation | No_Such_Relationship | 
  27994.             No_Such_Shadow_File => 
  27995.             raise Node_Definitions.Name_Error; 
  27996.     -- predefined exceptions (propagated with trace)
  27997.         when Constraint_Error | Tasking_Error | Program_Error | Storage_Error | 
  27998.             Numeric_Error => 
  27999.             Trace.Report("PREDEFINED EXCEPTION in Node_Management.Open "); 
  28000.             raise; 
  28001.     -- unanticipated exceptions
  28002.         when others => 
  28003.             Trace.Report("UNANTICIPATED EXCEPTION in Node_Management.Open "); 
  28004.             raise Trace.Assertion_Violation; 
  28005.  
  28006.     end Open; 
  28007.  
  28008.     procedure Open(Node       : in out Node_Type; 
  28009.                    Base       : Node_Type; 
  28010.                    Key        : Relationship_Key; 
  28011.                    Relation   : Relation_Name := Default_Relation; 
  28012.                    Intent     : Intention := (1 => Read); 
  28013.                    Time_Limit : Duration := No_Delay) is 
  28014.  
  28015.         Attributes    : List_Utilities.List_Type; 
  28016.         Primary       : Boolean; 
  28017.         Shadow_File   : String(1 .. Max_Shadow_File_Length); 
  28018.         Shadow_Length : Natural; 
  28019.  
  28020.     begin
  28021.         if Intent'Length = 0 then 
  28022.             raise Node_Definitions.Use_Error; 
  28023.         end if; 
  28024.         if Open_Status(Node) or not Open_Status(Base) then 
  28025.             raise Node_Definitions.Status_Error; 
  28026.         end if; 
  28027.  
  28028.         Cais_Utilities.Check_Intentions(Base, Read_Relationships); 
  28029.  
  28030.         Get_A_Relationship(Base, Rel_Name => Relation, Rel_Key => Key, 
  28031.             Rel_Attributes => Attributes, Primary => Primary, Shadow_File => 
  28032.             Shadow_File); 
  28033.  
  28034.         -- Shadow_File now contains the name of the shadow file for
  28035.         -- node to be opened.  The values in this node are returned in
  28036.         -- the open node handle.
  28037.         -- First check that we aren't about to allow the user to
  28038.         -- access the system node via CAIS interfaces...
  28039.         Shadow_Length := Character_Set.Last_Non_Space(Shadow_File); 
  28040.         if Shadow_File(1 .. Shadow_Length) = Cais_Host_Dependent.
  28041.             Cais_System_Node then 
  28042.             -- CAIS Spec 4.3.4.2(3) prohibits direct access to the
  28043.             -- System_Node. presumably this means that an attempt to
  28044.             -- Open it is an attempt to Open an inaccessible node, hence
  28045.             -- a Name_Error is raised by Open.
  28046.             raise Node_Definitions.Name_Error; 
  28047.         end if; 
  28048.  
  28049.         Set_Shadow_File_Name(Node, Shadow_File); 
  28050.         Node_Internals.Read_Shadow_File(Node); 
  28051.         Set_Open(Node, True); 
  28052.         Set_Intent(Node, Intent); 
  28053.  
  28054.         -- build a pathname from the base, relation, and key...
  28055.         Build_Name : declare
  28056.             Name                                : String(1 .. Max_Name_String); 
  28057.             Name_Length, Rel_Length, Key_Length : Natural; 
  28058.         begin
  28059.             Get_Pathname(Base, Name, Name_Length); 
  28060.             Rel_Length := Last_Non_Space(Relation); 
  28061.             Key_Length := Last_Non_Space(Key); 
  28062.             Set_Pathname(Node, Name(1 .. Name_Length) & "'" & Relation(Relation'
  28063.                 First .. Rel_Length) & "(" & Key(Key'First .. Key_Length) & ")")
  28064.                 ; 
  28065.         end Build_Name; 
  28066.  
  28067.     exception
  28068.         when No_Such_Relation | No_Such_Relationship | No_Such_Shadow_File => 
  28069.             raise Node_Definitions.Name_Error; 
  28070.  
  28071.     end Open; 
  28072.  
  28073. ----------------------      C L O S E          ----------------------
  28074. --
  28075. --  Purpose:
  28076. --  -------
  28077. --    This procedure severs any association between the node handle
  28078. --    "Node" and the node, and releases any associated locks on the
  28079. --    node imposed by the intent of the node handle "Node".  Closing
  28080. --    an alReady closed node handle has no effect.
  28081. --
  28082. --  Parameters:
  28083. --  ----------
  28084. --    Node - node handle, initially open, to be closed.
  28085. --
  28086. --  Exceptions:
  28087. --  ----------
  28088. --    None.
  28089. --
  28090. --  Notes:
  28091. --  -----
  28092. --     CAIS 5.1.2.2
  28093. --
  28094. ---------------------------------------------------------------------
  28095.  
  28096.     procedure Close(Node : in out Node_Type) is 
  28097.         Shadow_File   : String(1 .. Max_Shadow_File_Length); 
  28098.         Shadow_Length : Natural; 
  28099.     begin
  28100.         if not Is_Open(Node) then 
  28101.             return; 
  28102.         end if; 
  28103.         Get_Shadow_File_Name(Node, Shadow_File, Shadow_Length); 
  28104.         if Cais_Host_Dependent.File_Exists(Shadow_File(1 .. Shadow_Length))
  28105.             then 
  28106.             Write_Shadow_File(Node); 
  28107.         end if; 
  28108.         Set_Open(Node, False); 
  28109.         -- when locks are implemented, release lock table entries
  28110.     end Close; 
  28111.  
  28112. ----------------------  C H A N G E _ I N T E N T -------------------
  28113. --
  28114. --  Purpose:
  28115. --  -------
  28116. --    This procedure changes the intention regarding the use of the node
  28117. --    handle "Node".  It is semantically equivalent to closing the node
  28118. --    handle an reopening the node handle to the same node with the 
  28119. --    "Intent" and "Time_Limit" paramters of Change_Intent, except that
  28120. --    Change_Intent guarantees to return an open node handle that refers
  28121. --    to the same node as the node handle input in "Node".  (See the issue
  28122. --    explained in the nore below).
  28123. --
  28124. --  Parameters:
  28125. --  ----------
  28126. --    Node      - an open node handle
  28127. --    Intent    - the intent of subsequent operations on the node; the
  28128. --                actual parameter takes the form of an array aggregate.
  28129. --    Time_Limit- specifies the time limit for the delay on waiting on
  28130. --                waiting for the unlocking of a node in accordance with
  28131. --                the desired intent.
  28132. --
  28133. --  Exceptions:
  28134. --  ----------
  28135. --    Name_Error        - is raised if the node handle "Node" refers to
  28136. --                        an unobtainable node and "Intent" contains any
  28137. --                        intent specification other than "Existence".
  28138. --    Status_Error      - is raised if the node handle "Node" is not an
  28139. --                        open node handle.
  28140. --    Lock_Error        - is raised if the operation is delayed beyond the
  28141. --                        specified time limit due to the existence of locks
  28142. --                        on the node in conflict with the specified "Intent".
  28143. --    Access_Violation  - is raised if the current process's discretionary
  28144. --                        access control rights are insufficient to obtain
  28145. --                        access to the node consistent with the specified
  28146. --                        intent.  Access_Violation is raised only of the
  28147. --                        condition for Name_Error is not present.
  28148. --    Security_Violation- is raised if an attempt to obtain access consistent
  28149. --                        with the intention "Intent" to the node specified
  28150. --                        by "Node" represents a violation of mandatory 
  28151. --                        access controls for the CAIS.  Security_Violation
  28152. --                        is raised only if the conditions for other exceptions
  28153. --                        are not present.
  28154. --
  28155. --  Notes:  CAIS 5.1.2.3 
  28156. --  -----
  28157. --    Use of the sequence of a Close and an Open operation instead of a
  28158. --    Change_Intent operation cannot guarantee that the same node is opened,
  28159. --    since relationships, and therefore the node identification, may have
  28160. --    changed since the previous Open on the Node.
  28161. --
  28162. ---------------------------------------------------------------------
  28163.  
  28164.     procedure Change_Intent(Node       : in out Node_Type; 
  28165.                             Intent     : Intention; 
  28166.                             Time_Limit : Duration := No_Delay) is 
  28167.     begin
  28168.         Assert_Fatal(False, "Change_Intent not implemented yet"); 
  28169.     end Change_Intent; 
  28170.  
  28171. ----------------------     I S _ O P E N       ----------------------
  28172. --
  28173. --  Purpose:
  28174. --  -------
  28175. --    This function returns True if the node handle "Node" is open;
  28176. --    otherwise, it returns FALSE.
  28177. --
  28178. --  Parameters:
  28179. --  ----------
  28180. --    Node - node handle
  28181. --
  28182. --  Exceptions:
  28183. --  ----------
  28184. --    None.
  28185. --
  28186. --  Notes:
  28187. --  -----
  28188. --     CAIS 5.1.2.4
  28189. --
  28190. ---------------------------------------------------------------------
  28191.  
  28192.     function Is_Open(Node : Node_Type) return Boolean is 
  28193.     begin
  28194.         return Node_Representation.Open_Status(Node); 
  28195.     end Is_Open; 
  28196.  
  28197.  
  28198. ----------------------     I N T E N T _ O F   ----------------------
  28199. --
  28200. --  Purpose:
  28201. --  -------
  28202. --    This function returns the intent with which the node handle
  28203. --    Node is open.
  28204. --
  28205. --  Parameters:
  28206. --  ----------
  28207. --    Node   - an open node handle.
  28208. --
  28209. --  Exceptions:
  28210. --  ----------
  28211. --    Node_Definitions.Status_Error - if the node handle is not open.
  28212. --
  28213. --  Notes:
  28214. --  -----
  28215. --   CAIS 5.1.2.5
  28216. --
  28217. ---------------------------------------------------------------------
  28218.  
  28219.     function Intent_Of(Node : Node_Type) return Intention is 
  28220.     begin
  28221.         return Node_Representation.Get_Intent(Node); 
  28222.     end Intent_Of; 
  28223.  
  28224.  
  28225. ----------------------        K I N D          ----------------------
  28226. --
  28227. --  Purpose:
  28228. --  -------
  28229. --    This function returns the kind of a node, either FILE, PROCESS,
  28230. --    or STRUCTURAL.
  28231. --
  28232. --  Parameters:
  28233. --  ----------
  28234. --    Node  - open node handle
  28235. --
  28236. --  Exceptions:
  28237. --  ----------
  28238. --    Node_Definitions.Status_Error  - if the node handle is not open.
  28239. --
  28240. --  Notes:
  28241. --  -----
  28242. --   CAIS 5.1.2.6
  28243. --
  28244. ---------------------------------------------------------------------
  28245.  
  28246.  
  28247.     function Kind(Node : Node_Type) return Node_Kind is 
  28248.     begin
  28249.         return Node_Representation.Get_Kind(Node); 
  28250.     end Kind; 
  28251.  
  28252.  
  28253. ------------------------ P R I M A R Y _ N A M E---------------------
  28254. --
  28255. --  Purpose:
  28256. --  -------
  28257. --    This function returns the unique primary name of the node identified
  28258. --    by NODE.
  28259. --
  28260. --  Parameters:
  28261. --  ----------
  28262. --    Node      - an open node handle identifying the node of interest
  28263. --
  28264. --  Exceptions:
  28265. --  ----------
  28266. --    Name_Error        - is raised if any node traversed on the primary
  28267. --                        path is inaccessible.
  28268. --    Status_Error      - is raised if the Node_Handle "Node" is not open.
  28269. --    Lock_Error        - is raised if access consistent with intent
  28270. --                        Read_Relationships to any node traversed on the
  28271. --                        primary path cannot be obtained due to an existing
  28272. --                        lock on the node.
  28273. --    Intent_Violation  - is raised if "Node" was not opened with an intent
  28274. --                        establishing the right to read relationships.
  28275. --    Access_Violation  - is raised if the current process's discretionary
  28276. --                        access control rights are insufficient to traverse
  28277. --                        the node's primary path.  Access_Violation is raised
  28278. --              only if the conditions for Name_Error are not present.
  28279. --
  28280. --  Notes:   CAIS 5.1.2.7
  28281. --  -----
  28282. --    Get_Parent may raise Access_Violations. What should be done??
  28283. --    Get_Parent could raise Name_Error because the Node system is
  28284. --        inconsistent.  How can this be detected from the end to
  28285. --        recursion because w'eve reached a top level node??
  28286. ---------------------------------------------------------------------
  28287.     function Primary_Name(Node : in Node_Type) return Name_String is 
  28288.         Parent      : Node_Type; 
  28289.         Shadow_File : String(1 .. Max_Shadow_File_Length); 
  28290.         Attributes  : List_Type; 
  28291.         Primary     : Boolean; 
  28292.  
  28293.         function Append(Base     : String; 
  28294.                         Relation : String; 
  28295.                         Key      : String) return String is 
  28296.         begin
  28297.             if Relation'Length = 3 and then Relation = "DOT" then 
  28298.                 return Base & "." & Key; 
  28299.             else 
  28300.                 return Base & "'" & Relation & "(" & Key & ")"; 
  28301.             end if; 
  28302.         end Append; 
  28303.     begin
  28304.  
  28305.         Get_A_Relationship(Node, "Parent", "", Shadow_File, Attributes, Primary)
  28306.             ; 
  28307.  
  28308.         if Last_Non_Space(Shadow_File) /= Cais_System_Node'Size or else 
  28309.             Shadow_File /= Cais_System_Node then 
  28310.  
  28311.             Get_Parent(Parent, Node, (1 => Read_Relationships)); 
  28312.                     --Raises Status, Lock, Intent, and Access Errors
  28313.                     --when appropriate! when the top-most level is 
  28314.                     --reached the recursion will be terminated.
  28315.                                         --Recursive call!!!!!!!
  28316.             return Append(Primary_Name(Parent), Primary_Relation(Node), 
  28317.                 Primary_Key(Node)); 
  28318.         else 
  28319.             return Append("", Primary_Relation(Node), Primary_Key(Node)); 
  28320.         end if; 
  28321.     end Primary_Name; 
  28322.  
  28323. ------------------------ P R I M A R Y _ K E Y ----------------------
  28324. --
  28325. --  Purpose:
  28326. --  -------
  28327. --    This function returns the relationship key of the last path
  28328. --    element of the unique primary name of the node identified by NODE.
  28329. --
  28330. --  Parameters:
  28331. --  ----------
  28332. --    Node      - an open node handle identifying the node of interest
  28333. --
  28334. --  Exceptions:
  28335. --  ----------
  28336. --    Name_Error        - is raised if the parent node of the node identified
  28337. --                        by "Node" is inaccessible.
  28338. --    Status_Error      - is raised if the Node_Handle "Node" is not open.
  28339. --    Lock_Error        - is raised if the parent node is locked against
  28340. --                        Read_Relationships.
  28341. --    Intent_Violation  - is raised if "Node" was not opened with an intent
  28342. --                        establishing the right to read relationships.
  28343. --    Access_Violation  - is raised if the current process's discretionary
  28344. --                        access control rights are insufficient to obtain
  28345. --              access to the node's parent consistent with intent
  28346. --              Read_Relationships.  Access_Violation is raised
  28347. --              only if the conditions for Name_Error are not present.
  28348. --
  28349. --  Notes:   CAIS 5.1.2.8
  28350. --  -----
  28351. --
  28352. ---------------------------------------------------------------------
  28353.     function Primary_Key(Node : in Node_Type) return Relationship_Key is 
  28354.  
  28355.         use Identifier_Items; 
  28356.  
  28357.         Parent_Node : Node_Type; 
  28358.         Attributes  : List_Type; 
  28359.         Primary     : Boolean; 
  28360.         Key_String  : String(1 .. Max_Relationship_Key); 
  28361.         Shadow_File : String(1 .. Max_Shadow_File_Length); 
  28362.         Key         : List_Type; 
  28363.     begin
  28364.         if not Is_Open(Node) then 
  28365.             raise Node_Definitions.Status_Error; 
  28366.         end if; 
  28367.         Check_Intentions(Node, Read_Relationships); 
  28368.  
  28369.         Get_A_Relationship(Node, "Parent", "", Shadow_File, Attributes, Primary)
  28370.             ; 
  28371.  
  28372.         --Open checks parent(other than System_Node) for existence and locks.
  28373.         if Last_Non_Space(Shadow_File) /= Cais_System_Node'Size or else 
  28374.             Shadow_File /= Cais_System_Node then 
  28375.             Open(Parent_Node, Node, "", "Parent", (1 => Read_Relationships)); 
  28376.             Close(Parent_Node); 
  28377.         end if; 
  28378.  
  28379.         Extract(Attributes, "Primary_Key", Key); 
  28380.         Simple_List_To_String(Key, Key_String); 
  28381.         return Key_String(1 .. Last_Non_Space(Key_String)); 
  28382.     end Primary_Key; 
  28383.  
  28384. ------------------- P R I M A R Y _ R E L A T I O N ------------------
  28385. --
  28386. --  Purpose:
  28387. --  -------
  28388. --    This function returns the relation name of the last path
  28389. --    element of the unique primary name of the node identified by NODE.
  28390. --
  28391. --  Parameters:
  28392. --  ----------
  28393. --    Node      - an open node handle identifying the node of interest
  28394. --
  28395. --  Exceptions:
  28396. --  ----------
  28397. --    Name_Error        - is raised if the parent node of the node identified
  28398. --                        by "Node" is inaccessible.
  28399. --    Status_Error      - is raised if the Node_Handle "Node" is not open.
  28400. --    Lock_Error        - is raised if the parent node is locked against
  28401. --                        Read_Relationships.
  28402. --    Intent_Violation  - is raised if "Node" was not opened with an intent
  28403. --                        establishing the right to read relationships.
  28404. --    Access_Violation  - is raised if the current process's discretionary
  28405. --                        access control rights are insufficient to obtain
  28406. --              access to the node's parent consistent with intent
  28407. --              Read_Relationships.  Access_Violation is raised
  28408. --              only if the conditions for Name_Error are not present.
  28409. --
  28410. --  Notes:   CAIS 5.1.2.9
  28411. --  -----
  28412. --
  28413. ---------------------------------------------------------------------
  28414.     function Primary_Relation(Node : in Node_Type) return Relation_Name is 
  28415.  
  28416.         use Identifier_Items; 
  28417.  
  28418.         Parent_Node : Node_Type; 
  28419.         Attributes  : List_Type; 
  28420.         Primary     : Boolean; 
  28421.         Rel_String  : String(1 .. Max_Relationship_Name); 
  28422.         Shadow_File : String(1 .. Max_Shadow_File_Length); 
  28423.         Relation    : List_Type; 
  28424.     begin
  28425.         if not Is_Open(Node) then 
  28426.             raise Node_Definitions.Status_Error; 
  28427.         end if; 
  28428.         Check_Intentions(Node, Read_Relationships); 
  28429.  
  28430.         Get_A_Relationship(Node, "Parent", "", Shadow_File, Attributes, Primary)
  28431.             ; 
  28432.  
  28433.         --Open checks parent(other than System_Node) for existence and locks.
  28434.         if Last_Non_Space(Shadow_File) /= Cais_System_Node'Size or else 
  28435.             Shadow_File /= Cais_System_Node then 
  28436.             Open(Parent_Node, Node, "", "Parent", (1 => Read_Relationships)); 
  28437.             Close(Parent_Node); 
  28438.         end if; 
  28439.  
  28440.         Extract(Attributes, "Primary_Relation", Relation); 
  28441.         Simple_List_To_String(Relation, Rel_String); 
  28442.         return Rel_String(1 .. Last_Non_Space(Rel_String)); 
  28443.     end Primary_Relation; 
  28444.  
  28445. ----------------------    P A T H _ K E Y      ----------------------
  28446. --
  28447. --  Purpose:
  28448. --  -------
  28449. --    This function returns the relationship key of the relationship
  28450. --    corresponding to the last path element of the pathname used
  28451. --    in opening this node handle.  Since a path element is a string,
  28452. --    the relationship key is returned even if the relationship has
  28453. --    been deleted.
  28454. --
  28455. --  Parameters:
  28456. --  ----------
  28457. --    Node      - an open node handle
  28458. --
  28459. --  Exceptions:
  28460. --  ----------
  28461. --    Status_Error      - raised if the node handle "Node" is not open.
  28462. --
  28463. --  Notes:   CAIS 5.1.2.10
  28464. --  -----
  28465. --
  28466. ---------------------------------------------------------------------
  28467.  
  28468.     function Path_Key(Node : Node_Type) return Relationship_Key is 
  28469.  
  28470.         Lastchar : Natural; 
  28471.         Name     : String(1 .. Pragmatics.Max_Name_String); 
  28472.  
  28473.     begin
  28474.         if not Is_Open(Node) then 
  28475.             raise Node_Definitions.Status_Error; 
  28476.         end if; 
  28477.  
  28478.         Node_Representation.Get_Pathname(Node, Name, Lastchar); 
  28479.         return Last_Key(Name(1 .. Lastchar)); 
  28480.     end Path_Key; 
  28481.  
  28482. ----------------------     P A T H _ R E L A T I O N ----------------
  28483. --
  28484. --  Purpose:
  28485. --  -------
  28486. --    This function returns the relation name of the relationship
  28487. --    corresponding to the last path element of the pathname used
  28488. --    in opening this node handle. 
  28489. --    The relationship key is returned even if the relationship has
  28490. --    been deleted.
  28491. --
  28492. --  Parameters:
  28493. --  ----------
  28494. --    Node      - an open node handle
  28495. --
  28496. --  Exceptions:
  28497. --  ----------
  28498. --    Status_Error      - raised if the node handle "Node" is not open.
  28499. --
  28500. --  Notes:   CAIS 5.1.2.11
  28501. --  -----
  28502. --
  28503. ---------------------------------------------------------------------
  28504.     function Path_Relation(Node : Node_Type) return Relation_Name is 
  28505.  
  28506.         Lastchar : Natural; 
  28507.         Name     : String(1 .. Pragmatics.Max_Name_String); 
  28508.  
  28509.     begin
  28510.         if not Is_Open(Node) then 
  28511.             raise Node_Definitions.Status_Error; 
  28512.         end if; 
  28513.  
  28514.         Node_Representation.Get_Pathname(Node, Name, Lastchar); 
  28515.         return Last_Relation(Name(1 .. Lastchar)); 
  28516.     end Path_Relation; 
  28517.  
  28518. ----------------------    B A S E _ P A T H    ----------------------
  28519. --
  28520. --  Purpose:
  28521. --  -------
  28522. --    This function returns the pathname obtained by deleting the last
  28523. --    path element from "Name".  It does not establish whether the
  28524. --    pathname identifies an existing node; only the syntactic properties
  28525. --    of the pathname are examined.  This function also checks the
  28526. --    legality of the pathname "Name".
  28527. --
  28528. --  Parameters:
  28529. --  ----------
  28530. --    Name      - a pathname (not necessarily identifying a node).
  28531. --
  28532. --  Exceptions:
  28533. --  ----------
  28534. --    Name_Error  - raised if Name is a syntactically illegal pathname.
  28535. --
  28536. --  Notes: CAIS 5.1.2.12
  28537. --  -----
  28538. --
  28539. ---------------------------------------------------------------------
  28540.  
  28541.     function Base_Path(Name : Name_String) return Name_String is 
  28542.  
  28543.         Pn         : Parsed_Pn; 
  28544.         Rel_Key    : Relationship_Key(1 .. Max_Relationship_Key); 
  28545.         Rel_Name   : Relation_Name(1 .. Max_Relationship_Name); 
  28546.         Dyn_Name   : Dynamic_String; 
  28547.         Dyn_Key    : Dynamic_String; 
  28548.         Latest_Key : Boolean; 
  28549.         Comp_Count : Natural; 
  28550.         Tmp_Dyn    : Dynamic_String; 
  28551.         Tmp_Str    : Name_String(1 .. Max_Name_String) := (others => ' '); 
  28552.  
  28553.     begin
  28554.         Get_Parsed_Pn(Name, Pn); 
  28555.  
  28556.         -- Must be at least one valid component, sice we didn't get a
  28557.         -- PATHNAME_SYNTAX_ERROR exception from Get_Parsed_PN...
  28558.         for I in 1 .. (Pn_Component_Count(Pn) - 1) loop
  28559.             Get_Pn_Component(Pn, I, Rel_Name, Rel_Key, Latest_Key); 
  28560.             Convert_To_Dynamic(Rel_Key, Dyn_Key); 
  28561.             Convert_To_Dynamic(Rel_Name, Dyn_Name); 
  28562.             Append(''', Tmp_Dyn); 
  28563.             if Length(Dyn_Name) = 0 then 
  28564.                 Append("DOT", Tmp_Dyn); 
  28565.             else 
  28566.                 Append(Dyn_Name, Tmp_Dyn); 
  28567.             end if; 
  28568.             if Latest_Key then 
  28569.                 Append('#', Dyn_Key); 
  28570.             end if; 
  28571.             if not Empty(Dyn_Key) then 
  28572.                 Append('(', Tmp_Dyn); 
  28573.                 Append(Dyn_Key, Tmp_Dyn); 
  28574.                 Append(')', Tmp_Dyn); 
  28575.             end if; 
  28576.         end loop; 
  28577.  
  28578.         if Length(Tmp_Dyn) = 0 then 
  28579.             return " "; 
  28580.         end if; 
  28581.         Convert_To_String(Tmp_Dyn, Tmp_Str); 
  28582.         return Tmp_Str(1 .. Length(Tmp_Dyn)); 
  28583.  
  28584.     exception
  28585.         when Pathname_Syntax_Error => 
  28586.             raise Node_Definitions.Name_Error; 
  28587.         when others => 
  28588.             raise; 
  28589.     end Base_Path; 
  28590. ----------------------   L A S T _ R E L A T I O N  -----------------
  28591. --
  28592. --  Purpose:
  28593. --  -------
  28594. --    This function returns the name of the relation of the last
  28595. --    path element of the pathname "Name".  It does not establish
  28596. --    whether the pathname identifies an existing node; only the
  28597. --    syntactic properties of the pathname are examined.  This function
  28598. --    also checks the syntactic legality of the pathname "Name".
  28599. --
  28600. --  Parameters:
  28601. --  ----------
  28602. --    Name   - a pathname, not necessarily identifying a node.
  28603. --
  28604. --  Exceptions:
  28605. --  ----------
  28606. --    Name_Error   - if name is syntactically illegal.
  28607. --
  28608. --  Notes:   CAIS 5.1.2.13
  28609. --  -----
  28610. --
  28611. ---------------------------------------------------------------------
  28612.  
  28613.     function Last_Relation(Name : Name_String) return Relation_Name is 
  28614.  
  28615.         Pn         : Parsed_Pn; 
  28616.         Rel_Key    : Relationship_Key(1 .. Max_Relationship_Key); 
  28617.         Rel_Name   : Relation_Name(1 .. Max_Relationship_Name); 
  28618.         Latest_Key : Boolean; 
  28619.         Comp_Count : Natural; 
  28620.  
  28621.     begin
  28622.         Get_Parsed_Pn(Name, Pn); 
  28623.         Comp_Count := Pn_Component_Count(Pn); 
  28624.  
  28625.         -- Must be at least one valid component, sice we didn't get a
  28626.         -- Pathname_Syntax_Error exception from Get_Parsed_Pn...
  28627.         Get_Pn_Component(Pn, Comp_Count, Rel_Name, Rel_Key, Latest_Key); 
  28628.         return (Rel_Name(1 .. Last_Non_Space(Rel_Name))); 
  28629.     exception
  28630.         when Pathname_Syntax_Error => 
  28631.             raise Node_Definitions.Name_Error; 
  28632.         when others => 
  28633.             raise; 
  28634.     end Last_Relation; 
  28635.  
  28636. ------------------------     L A S T _ K E Y     --------------------
  28637. --
  28638. --  Purpose:
  28639. --  -------
  28640. --    This function returns the name of the relationship key of the last
  28641. --    path element of the pathname "Name".  It does not establish
  28642. --    whether the pathname identifies an existing node; only the
  28643. --    syntactic properties of the pathname are examined.  This function
  28644. --    also checks the syntactic legality of the pathname "Name".
  28645. --
  28646. --  Parameters:
  28647. --  ----------
  28648. --    Name   - a pathname, not necessarily identifying a node.
  28649. --
  28650. --  Exceptions:
  28651. --  ----------
  28652. --    Name_Error   - if name is syntactically illegal.
  28653. --
  28654. --  Notes:   CAIS 5.1.2.14
  28655. --  -----
  28656. --
  28657. ---------------------------------------------------------------------
  28658.  
  28659.     function Last_Key(Name : Name_String) return Relationship_Key is 
  28660.  
  28661.         Pn         : Parsed_Pn; 
  28662.         Rel_Key    : Relationship_Key(1 .. Max_Relationship_Key); 
  28663.         Rel_Name   : Relation_Name(1 .. Max_Relationship_Name); 
  28664.         Latest_Key : Boolean; 
  28665.         Comp_Count : Natural; 
  28666.  
  28667.     begin
  28668.         Get_Parsed_Pn(Name, Pn); 
  28669.         Comp_Count := Pn_Component_Count(Pn); 
  28670.  
  28671.         -- Must be at least one valid component, sice we didn't get a
  28672.         -- Pathname_Syntax_Error exception from Get_Parsed_Pn...
  28673.         Get_Pn_Component(Pn, Comp_Count, Rel_Name, Rel_Key, Latest_Key); 
  28674.         if Latest_Key then 
  28675.             return (Rel_Key(1 .. Last_Non_Space(Rel_Key)) & '#'); 
  28676.         else 
  28677.             return (Rel_Key(1 .. Last_Non_Space(Rel_Key))); 
  28678.         end if; 
  28679.     exception
  28680.         when Pathname_Syntax_Error => 
  28681.             raise Node_Definitions.Name_Error; 
  28682.         when others => 
  28683.             raise; 
  28684.     end Last_Key; 
  28685.  
  28686. ----------------------   I S _ O B T A I N A B L E  -----------------
  28687. --
  28688. --  Purpose:
  28689. --  -------
  28690. --    This function returns False if the node identified by "Node"
  28691. --    is unobtainable or inaccessible.  It returns True otherwise.
  28692. --
  28693. --  Parameters:
  28694. --  ----------
  28695. --    Node - an open node handle identifying the node
  28696. --
  28697. --  Exceptions:
  28698. --  ----------
  28699. --    Status_Error  - raised if "Node" is not an open node handle.
  28700. --
  28701. --  Notes:  CAIS 5.1.2.15
  28702. --  -----
  28703. --     For now, only check if the shadow file still exists...
  28704. --     locking and access control will force changes in this routine
  28705. --
  28706. ---------------------------------------------------------------------
  28707.  
  28708.     function Is_Obtainable(Node : Node_Type) return Boolean is 
  28709.  
  28710.         Lastchar : Natural; 
  28711.         Name     : String(1 .. Pragmatics.Max_Name_String); 
  28712.  
  28713.     begin
  28714.         if not Is_Open(Node) then 
  28715.             raise Node_Definitions.Status_Error; 
  28716.         end if; 
  28717.  
  28718.         Node_Representation.Get_Shadow_File_Name(Node, Name, Lastchar); 
  28719.  
  28720.         Check_Exists : declare
  28721.             File : String(1 .. Lastchar); 
  28722.         begin
  28723.             File := Name(1 .. Lastchar); 
  28724.             return File_Exists(File); 
  28725.         end Check_Exists; 
  28726.  
  28727.     end Is_Obtainable; 
  28728.  
  28729. ----------------------     I S _ S A M E      -----------------------
  28730. --
  28731. --  Purpose:
  28732. --  -------
  28733. --    This function returns True if the nodes identified by its
  28734. --    arguments are the same node; otherwise, it returns FALSE.
  28735. --
  28736. --  Parameters:
  28737. --  ----------
  28738. --    Node1   - open node handle to a node
  28739. --    Node2   - open node handle to a node
  28740. --
  28741. --  Exceptions:
  28742. --  ----------
  28743. --    Status_Error  is raised if either of the node handles is not open.
  28744. --
  28745. --  Notes:
  28746. --  -----
  28747. --      This is a version of the function Is_Same,
  28748. --      specified in MIL-STD-CAIS 5.1.2.16; all references to 
  28749. --      the CAIS specification refer to the CAIS  specification 
  28750. --      dated 31 January 1985.
  28751. --
  28752. ---------------------------------------------------------------------
  28753.  
  28754.     function Is_Same(Node1 : Node_Type; 
  28755.                      Node2 : Node_Type) return Boolean is 
  28756.  
  28757.         Shadow1, Shadow2 : String(1 .. Max_Shadow_File_Length); 
  28758.         Len1, Len2       : Natural; 
  28759.     begin
  28760.         if not Open_Status(Node1) or not Open_Status(Node2) then 
  28761.             raise Node_Definitions.Status_Error; 
  28762.         end if; 
  28763.  
  28764.         Get_Shadow_File_Name(Node1, Shadow1, Len1); 
  28765.         Get_Shadow_File_Name(Node2, Shadow2, Len2); 
  28766.         if Len1 /= Len2 then 
  28767.             return False; 
  28768.         end if; 
  28769.  
  28770.         return (Shadow1(1 .. Len1) = Shadow2(1 .. Len2)); 
  28771.     end Is_Same; 
  28772. ----------------------------------------------------------------------
  28773. --        A D D I T I O N A L   I N T E R F A C E
  28774. ----------------------------------------------------------------------
  28775.     function Is_Same(Name1 : Name_String; 
  28776.                      Name2 : Name_String) return Boolean is 
  28777.         Node1, Node2 : Node_Type; 
  28778.         Result       : Boolean; 
  28779.     begin
  28780.         Open(Node1, Name1, (1 => Existence)); 
  28781.         begin
  28782.             Open(Node2, Name2, (1 => Existence)); 
  28783.         exception
  28784.             when others => 
  28785.                 Close(Node1); 
  28786.                 raise; 
  28787.         end; 
  28788.         Result := Is_Same(Node1, Node2); 
  28789.         Close(Node1); 
  28790.         Close(Node2); 
  28791.         return Result; 
  28792.     end Is_Same; 
  28793.  
  28794. ------------------------  G E T _ P A R E N T  ----------------------
  28795. --
  28796. --  Purpose:
  28797. --  -------
  28798. --    This procedure returns an open node handle in "Parent" to the parent
  28799. --    of the node identified by the open node handle "Node".  The intent
  28800. --    under which the node handle "Parent" is opened is specified by "Intent".
  28801. --    A call on Get_Parent is equivalent to a call:
  28802. --        Open(Parent, Node, "", Parent, Intent, Time_Limit);
  28803. --
  28804. --  Parameters:
  28805. --  ----------
  28806. --    Parent    - a node handle, initially closed, to be opened to the
  28807. --                parent node
  28808. --    Node      - an open handle identifying the node
  28809. --    Intent    - the intent of subsequent operations on the node "Parent";
  28810. --                the actual parameter takes the form of an array aggregate
  28811. --    Time_Limit - specifies time limit for the delay on waiting for the 
  28812. --                unlocking of the parent node in accordance with the desired
  28813. --        - intent
  28814. --
  28815. --  Exceptions:
  28816. --  ----------
  28817. --    Name_Error        - raised if the node identified by "Node" is a top
  28818. --              level node or if its parent node is inaccessible.
  28819. --    Use_Error         - is raised if the specified intent is an empty array.
  28820. --    Status_Error      - is raised if the Node_Handle "Parent" is already
  28821. --                        open prior to the call on or if "Node" is not
  28822. --                        an open node handle.
  28823. --    Lock_Error        - is raised if the opening of the Parent node is
  28824. --              delayed beyond the specified time limit due to
  28825. --              the existance of locks in conflict with the
  28826. --              specified Intent.
  28827. --    Intent_Violation  - is raised if "Node" was not opened with an intent
  28828. --                        establishing the right to read relationships.
  28829. --    Access_Violation  - is raised if the current process's discretionary
  28830. --                        access control rights are insufficient to obtain
  28831. --                        access to the parent node with the specified intent.  
  28832. --                        Access_Violation is raised only if the conditions
  28833. --                        for Name_Error are not present.
  28834. --    Security_Violation -is raised if the attempt to obtain access to the
  28835. --                        parent node with the specified intent represents a 
  28836. --                        violation of mandatory access controls for the
  28837. --                        CAIS.  Security_Violation is raised only if the
  28838. --                        conditions for other exceptions are not present.
  28839. --
  28840. --  Notes:   CAIS 5.1.2.17
  28841. --  -----
  28842. --
  28843. ---------------------------------------------------------------------
  28844.     procedure Get_Parent(Parent     : in out Node_Type; 
  28845.                          Node       : in Node_Type; 
  28846.                          Intent     : Intention := (1 => Read); 
  28847.                          Time_Limit : Duration := No_Delay) is 
  28848.     begin
  28849.         Open(Parent, Node, "", "Parent", Intent, Time_Limit); 
  28850.     end Get_Parent; 
  28851.  
  28852. ------------------------  C O P Y _ N O D E   ------------------------
  28853. --
  28854. --  Purpose:
  28855. --  -------
  28856. --    These procedures copy a file or structural node THAT DOES NOT HAVE
  28857. --    EMANATING PRIMARY RELATIONSHIPS.  The node copied is identified by
  28858. --    the open node handle "From" and is copied to a newly created node.
  28859. --    The new node is identified by the combination of the To_Base, To_Key,
  28860. --    and To_Relation parameters.  The newly created node is of the same
  28861. --    kind as the node identified by From. If the node is a file node, its
  28862. --    contents are also copied, i.e., a new copied file is created.  Any
  28863. --    secondary relationships emanating from the original node, excepting
  28864. --    the relation of the predefined relation parent(which is appropriately
  28865. --    adjusted), are recreated in the copy.  If the target of the original
  28866. --    nodes relationship IS THE NODE ITSELF, THEN THE COPY HAS AN ANALOGOUS
  28867. --    RELATION TO ITSELF.  Any other secondary relationship whose target is
  28868. --    the original node is unaffected.  All attributes of the From node are
  28869. --    also copied.  Regardless of any locks on the node identified by From,
  28870. --    the newly creasted node is unlucked.
  28871. --
  28872. --  Parameters:
  28873. --  ----------
  28874. --    From      - an open node handle to the node to be copied.
  28875. --    To_Base   - open node handle to a base node for identification of the
  28876. --          node to be created.
  28877. --    To_Key    - the relationship key for identification of the node to be
  28878. --              - created.
  28879. --    To_Relation  - the relation name for identification of the node to be
  28880. --                created.
  28881. --
  28882. --  Exceptions:
  28883. --  ----------
  28884. --    Name_Error        - raised if the new node identification is illegal
  28885. --                        or if a node already exists with the identification
  28886. --                        given for the new node.
  28887. --    Use_Error         - is raised if the origianl node is not a file or
  28888. --              structural node or if any primary relationships
  28889. --              emanate from the original node.  Use_Error is also
  28890. --              raised if the To_Relation is the name of a predefined
  28891. --              relation that cannot be modified or created by the
  28892. --              user.
  28893. --    Status_Error      - is raised if the Node_Handles From and To_Base are
  28894. --              not both open.
  28895. --    Intent_Violation  - is raised if "From" was not opened with an intent
  28896. --                        establishing the right to read contents, attributes
  28897. --              and relationships, or if To_Base was not opened with
  28898. --              the right to append relationships. Intent_Violation
  28899. --              is not raised if the conditions for name error are
  28900. --              present.
  28901. --    Security_Violation -is raised if the attempt to obtain access to the
  28902. --                        node with the specified intent represents a 
  28903. --                        violation of mandatory access controls for the
  28904. --                        CAIS.  Security_Violation is raised only if the
  28905. --                        conditions for other exceptions are not present.
  28906. --
  28907. --  Notes:   CAIS 5.1.2.18
  28908. --  -----
  28909. --
  28910. ---------------------------------------------------------------------
  28911.  
  28912.     procedure Copy_Node(From        : Node_Type; 
  28913.                         To_Base     : in out Node_Type; 
  28914.                         To_Key      : Relationship_Key; 
  28915.                         To_Relation : Relation_Name := Default_Relation) is 
  28916.         separate; 
  28917.  
  28918. ----------------------------------------------------------------------
  28919. --        A D D I T I O N A L   I N T E R F A C E
  28920. ----------------------------------------------------------------------
  28921.     procedure Copy_Node(From : in Node_Type; 
  28922.                         To   : in Name_String) is 
  28923.         To_Base : Node_Type; 
  28924.     begin
  28925.         Open(To_Base, Base_Path(To), (1 => Append_Relationships)); 
  28926.         Copy_Node(From, To_Base, Last_Key(To), Last_Relation(To)); 
  28927.         Close(To_Base); 
  28928.     exception
  28929.         when others => 
  28930.             Close(To_Base); 
  28931.             raise; 
  28932.     end Copy_Node; 
  28933.  
  28934. ------------------       C O P Y _ T R E E       ------------------------
  28935. --
  28936. --  Purpose:
  28937. --  -------
  28938. --    These procedures copy a tree of file or structural nodes formed by the
  28939. --    primary relationships emanating from the node identified by the open node
  28940. --    handle From.  Primary relationships are recreated between corresponding
  28941. --    copied nodes.  The root node of the newly created tree corresponding to
  28942. --    the From node is the node identified by the combination of the To_Base,
  28943. --    To_Key, and To_Relation parameters.  If an exception is raised by the
  28944. --    procedure none of the nodes are copied.  Secondary relationships,
  28945. --    attributes, and node contents are copied as described for Copy_Node with
  28946. --    the following additional rules: secondary relationships between two nodes
  28947. --    which are both copied are recreated between the two copies.  Secondary
  28948. --    relationships emanating from a node which is copied, but which refer to
  28949. --    nodes outside the tree being copied, are copied so that they emanate from
  28950. --    the copy, but still refer to the original target node.  Secondary
  28951. --    relationships emanating from a node which is not copied, but which refer
  28952. --    to nodes inside the tree being copied, are unaffected.  If the node
  28953. --    identified by To_Base is part of the tree being copied, then the copy of
  28954. --    the node identified by From will not be copied recursively.
  28955. --
  28956. --  Parameters:
  28957. --  ----------
  28958. --    From      - an open node handle to the root node of the tree to be copied.
  28959. --    To_Base   - open node handle to a base node for identification of the
  28960. --          node to be created as root of the new tree.
  28961. --    To_Key    - the relationship key for identification of the node to be
  28962. --              - created as root of the new tree.
  28963. --    To_Relation  - the relation name for identification of the node to be
  28964. --                created as root of the new tree.
  28965. --
  28966. --  Exceptions:
  28967. --  ----------
  28968. --    Name_Error        - raised if the new node identification is illegal
  28969. --                        or if a node already exists with the identification
  28970. --                        given for the new node to be created as a copy of
  28971. --              the node identified by From.
  28972. --    Use_Error         - is raised if the origianl node is not a file or
  28973. --              structural node.  Use_Error is also raised if the
  28974. --              To_Relation is the name of a predefined relation
  28975. --              that cannot be modified or created by the user.
  28976. --    Status_Error      - is raised if the Node_Handles From and To_Base are
  28977. --              not both open.
  28978. --    Lock_Error    - is raised if any node to be copied except the node
  28979. --              identified by From is locked against read access to
  28980. --              attributes, relationships, or contents.
  28981. --    Intent_Violation  - is raised if "From" was not opened with an intent
  28982. --                        establishing the right to read contents, attributes
  28983. --              and relationships, or if To_Base was not opened with
  28984. --              the right to append relationships. Intent_Violation
  28985. --              is not raised if the conditions for name error are
  28986. --              present.
  28987. --    Access_Violation     - is raised if the current process' discretionary
  28988. --              access control rights are insufficient to obtain
  28989. --              access to each node to be copied with intent Read.
  28990. --              Access_Violation is not raised if conditions for
  28991. --              Name_Error are present.
  28992. --    Security_Violation -is raised if the operations represents a 
  28993. --                        violation of mandatory access controls for the
  28994. --                        CAIS.  Security_Violation is raised only if the
  28995. --                        conditions for other exceptions are not present.
  28996. --
  28997. --  Notes:   CAIS 5.1.2.19
  28998. --  -----
  28999. --
  29000. ---------------------------------------------------------------------
  29001.  
  29002.     procedure Copy_Tree(From        : Node_Type; 
  29003.                         To_Base     : in out Node_Type; 
  29004.                         To_Key      : Relationship_Key; 
  29005.                         To_Relation : Relation_Name := Default_Relation) is 
  29006.         separate; 
  29007.  
  29008. ----------------------------------------------------------------------
  29009. --        A D D I T I O N A L   I N T E R F A C E
  29010. ----------------------------------------------------------------------
  29011.     procedure Copy_Tree(From : in Node_Type; 
  29012.                         To   : in Name_String) is 
  29013.         To_Base : Node_Type; 
  29014.     begin
  29015.         Open(To_Base, Base_Path(To), (1 => Append_Relationships)); 
  29016.         Copy_Tree(From, To_Base, Last_Key(To), Last_Relation(To)); 
  29017.         Close(To_Base); 
  29018.     exception
  29019.         when others => 
  29020.             Close(To_Base); 
  29021.             raise; 
  29022.     end Copy_Tree; 
  29023.  
  29024.  
  29025. ------------------------     R E N A M E     ------------------------
  29026. --
  29027. --  Purpose:
  29028. --  -------
  29029. --    These procedures rename a file or a structural node.  They delete
  29030. --    the Primary relationship to the node identified by "Node" and install
  29031. --    a new primary relationship to the node, emanating from the node
  29032. --    identified by "New_Base", with key and relation given by the New_KEy and
  29033. --    New_Relation parameters.  The parent relationship is changed accordingly.
  29034. --    This the unique primary path name of the node.  Existing secondary
  29035. --    relationships with the renamed node as target track the renaming, i.e.,
  29036. --    they have the renamed node as target.
  29037. --
  29038. --  Parameters:
  29039. --  ----------
  29040. --    Node      - an opened node handle to the node to be renamed.
  29041. --    New_Base  - open node handle to a base node from which the new primary
  29042. --          relationship to the renamed node emanates.
  29043. --    New_Key   - the relationship key for the new primary relationship
  29044. --    New_Relation  - the relation name for the new primary relationship
  29045. --
  29046. --  Exceptions:
  29047. --  ----------
  29048. --    Name_Error        - raised if the new node identification is illegal
  29049. --              or if a node already exists with the identification
  29050. --              given for the new node.
  29051. --    Use_Error         - is raised if the node identified by "Node" is not a
  29052. --              file or structural node or if the renaming cannot be
  29053. --              accomplished while still maintaining acircularity of
  29054. --              primary relationships (eg. if the new parent node
  29055. --              would be the renamed node).  Use Error is also raised
  29056. --              if New_Relation is the name of a predefined relation
  29057. --              that cannot be modified or createdby the user or if
  29058. --              the primary relationship to be deleted belongs to a
  29059. --              predefined relation that cannot be modified by the
  29060. --              user.
  29061. --    Status_Error      - is raised if the Node_Handle "Node" and "New_Base"
  29062. --                        are not open.
  29063. --    Lock_Error        - is raised if access with intent Write_Relationships,
  29064. --                        to the parent of the node to be renamed cannot be
  29065. --              obtained to due to an existing lock on the node.
  29066. --    Intent_Violation  - is raised if "Node" was not opened with an intent
  29067. --                        establishing the right to write relationships or
  29068. --              if "New_Base" was not opened with an intent
  29069. --                        establishing the right to append relationships.
  29070. --    Access_Violation  - is raised if the current process's discretionary
  29071. --                        access control rights are insufficient to obtain
  29072. --                        access to the parent of the node to be renamed 
  29073. --                        with intent Write_Relationships and the conditions
  29074. --              for Name_Error are not present.
  29075. --    Security_Violation -is raised if the operation represents a 
  29076. --                        violation of mandatory access controls for the
  29077. --                        CAIS.  Security_Violation is raised only if the
  29078. --                        conditions for other exceptions are not present.
  29079. --
  29080. --  Notes:   CAIS 5.1.2.20
  29081. --  -----
  29082. --
  29083. ---------------------------------------------------------------------
  29084.  
  29085.     procedure Rename(Node         : in out Node_Type; 
  29086.                      New_Base     : in out Node_Type; 
  29087.                      New_Key      : Relationship_Key; 
  29088.                      New_Relation : Relation_Name := Default_Relation) is 
  29089.         separate; 
  29090.  
  29091. ----------------------------------------------------------------------
  29092. --        A D D I T I O N A L   I N T E R F A C E
  29093. ----------------------------------------------------------------------
  29094.     procedure Rename(Node     : in out Node_Type; 
  29095.                      New_Name : Name_String) is 
  29096.         New_Base : Node_Type; 
  29097.     begin
  29098.         Open(New_Base, Base_Path(New_Name), (1 => Append_Relationships)); 
  29099.         Rename(Node, New_Base, Last_Key(New_Name), Last_Relation(New_Name)); 
  29100.         Close(New_Base); 
  29101.     exception
  29102.         when others => 
  29103.             Close(New_Base); 
  29104.             raise; 
  29105.     end Rename; 
  29106.  
  29107. ----------------------   D E L E T E _ N O D E ----------------------
  29108. --
  29109. --  Purpose:
  29110. --  -------
  29111. --    This procedure deletes the primary relationship to a node
  29112. --    identified by Node.  The node becomes unobtainable.  The node
  29113. --    handle Node is closed.  If the node is a process node and the
  29114. --    process is not yet terminated (see Section 5.2 of MIL-STD-CAIS),
  29115. --    Delete_Node aborts the process.
  29116. --
  29117. --  Parameters:
  29118. --  ----------
  29119. --    Node  - an open node handle to the node which is the target of
  29120. --            the primary relationship to be deleted.
  29121. --
  29122. --  Exceptions:
  29123. --  ----------
  29124. --    (all defined in Node_Definitions)
  29125. --    Name_Error          - if parent node of Node is inaccessable
  29126. --    Use_Error           - if any primary Relationships emanate from Node
  29127. --    Status_Error        - if Node is not open
  29128. --    Lock_Error          - if access, with intent Write_Relationships,
  29129. --                          to the parent of the node to be deleted
  29130. --                          cannot be obtained due to an existing lock
  29131. --                          on the node.
  29132. --    Intent_Violation    - if the node handle Node was not opened with
  29133. --                          an intent including Exclusive_Write and 
  29134. --                          Read_Relationships.
  29135. --    Access_Violation    - if the current process does not have sufficient
  29136. --                          discretionary access control rights to obtain
  29137. --                          access to the parent of the node to be deleted
  29138. --                          with intent Write_Relationships and the
  29139. --                          conditions for Name_Error are not present.
  29140. --    Security_Violation  - if the operation represents a violation of
  29141. --                          mandatory access controls.  Security_Violation
  29142. --                          is raised only if the conditions for other
  29143. --                          exceptions are not present.
  29144. --
  29145. --  Notes:
  29146. --  -----
  29147. --    MIL-STD-CAIS 5.1.2.21
  29148. --     Locking support will have to be added here...
  29149. ---------------------------------------------------------------------
  29150.     procedure Delete_Node(Node : in out Node_Type) is separate; 
  29151.  
  29152. --------------------------------------------------------------------------
  29153. --        A D D I T I O N A L   I N T E R F A C E
  29154. --------------------------------------------------------------------------
  29155.     procedure Delete_Node(Name : Name_String) is 
  29156.         Node : Node_Type; 
  29157.     begin
  29158.         Open(Node, Name, (Exclusive_Write, Read_Relationships)); 
  29159.         Delete_Node(Node); 
  29160.     exception
  29161.         when others => 
  29162.             Close(Node); 
  29163.             raise; 
  29164.     end Delete_Node; 
  29165.  
  29166. ----------------------   D E L E T E _ T R E E ----------------------
  29167. --
  29168. --  Purpose:
  29169. --  -------
  29170. --    This procedure effectively performs the Delete_Node operation for
  29171. --    a specified node and recursively applies Delete_Tree to all nodes
  29172. --    reachable by a unique primary pathname from the designated node.
  29173. --    The nodes whose primary relationships are to be deleted are opened
  29174. --    with intent Exclusive_Write, thus locking them for other operations.
  29175. --    The order in which the deletions of primary relationships is performed
  29176. --    is not specified.  If the Delete_Tree operation raises an exception,
  29177. --    none of the primary relationships is deleted.
  29178. --
  29179. --  Parameters:
  29180. --  ----------
  29181. --    Node  - an open node handle to the node at the root of the tree 
  29182. --            whose primary relationships are to be deleted.
  29183. --
  29184. --  Exceptions:
  29185. --  ----------
  29186. --    (all defined in Node_Definitions)
  29187. --    Name_Error          - if parent node of Node or any of the target nodes of
  29188. --                primary relationships to be deleted are inaccessable
  29189. --    Use_Error           - if the primary Relationship of Node belongs to a
  29190. --                predefined relation that cannot be modified by the
  29191. --                user.
  29192. --    Status_Error        - if Node is not open
  29193. --    Lock_Error          - if access, with intent Write_Relationships,
  29194. --                          to the parent of the "Node" cannot be obtained due
  29195. --                to an existing lock or if a node handle identifying
  29196. --                any node whose unique primary path traverses the
  29197. --                node identified by Node cannot be opened with intent
  29198. --                Exclisive_Write.
  29199. --    Intent_Violation    - if the node handle Node was not opened with
  29200. --                          an intent including Exclusive_Write and 
  29201. --                          Read_Relationships.
  29202. --    Access_Violation    - if the current process does not have sufficient
  29203. --                          discretionary access control rights to obtain
  29204. --                          access to the parent of the node specified by Node
  29205. --                          with intent Write_Relationships or to obtain 
  29206. --                access to any target node of a primary relationship
  29207. --                to be deleted with the intent Exclusive_Write and
  29208. --                the conditions for Name_Error are not present.
  29209. --    Security_Violation  - if the operation represents a violation of
  29210. --                          mandatory access controls.  Security_Violation
  29211. --                          is raised only if the conditions for other
  29212. --                          exceptions are not present.
  29213. --
  29214. --  Notes:
  29215. --  -----
  29216. --    MIL-STD-CAIS 5.1.2.22
  29217. --     Locking support will have to be added here...
  29218. ---------------------------------------------------------------------
  29219.     procedure Delete_Tree(Node : in out Node_Type) is separate; 
  29220.  
  29221. ----------------------------------------------------------------------
  29222. --        A D D I T I O N A L   I N T E R F A C E
  29223. ----------------------------------------------------------------------
  29224.     procedure Delete_Tree(Name : Name_String) is 
  29225.         Node : Node_Type; 
  29226.     begin
  29227.         Open(Node, Name, (Exclusive_Write, Append_Relationships)); 
  29228.         Delete_Tree(Node); 
  29229.     exception
  29230.         when others => 
  29231.             Close(Node); 
  29232.             raise; 
  29233.     end Delete_Tree; 
  29234.  
  29235. -------------------------   L I N K   -------------------------------
  29236. --
  29237. --  Purpose:
  29238. --  -------
  29239. --    This procedure creates a secondary relationship between two existing
  29240. --    The procedure takes a node handle "Node" on the target node, a
  29241. --    node handle "New_Base" on the source node, and an explicit key
  29242. --    "New_Key" and a relation name "New_Relation" for the relationship
  29243. --    to be established from "New_Base" to "Node".
  29244. --
  29245. --  Parameters:
  29246. --  ----------
  29247. --    Node        - open node handle to the node to which the new 
  29248. --                  secondary relationship points.
  29249. --    New_Base    - an open node handle to the base node from which the
  29250. --                  new secondary relationship to the node emanates.
  29251. --    New_Key     - the relationship key for the new secondary relationship
  29252. --    New_Relation - the relation name for the new secondary relationship
  29253. --
  29254. --  Exceptions:
  29255. --  ----------
  29256. --    Name_Error     - raised if the relationship key or the relation
  29257. --                     name are illegal or if a node already exists
  29258. --                     with the identification given by "New_Base",
  29259. --                     "New_Key", and "New_Relation".
  29260. --    Use_Eror       - raised if "New_Relation" is the name of a predefined
  29261. --                     relation that cannot be modified or created by the user.
  29262. --    Status_Error   - raised if the node handles "Node" and "New_Base" are
  29263. --                     not open.
  29264. --    Intent_Violation  - raised if "New_Base" was not opened with an intent
  29265. --                        establishing the right to append relationships.
  29266. --    Security_Violation - raised if the operation represents a violation
  29267. --                         of mandatory access controls.  Security_Violation
  29268. --                         is raised only if the conditions for other
  29269. --                         exceptions are not present.
  29270. --  Notes:   CAIS 5.1.2.23
  29271. --  -----
  29272. --
  29273. ---------------------------------------------------------------------
  29274.  
  29275.     procedure Link(Node         : in out Node_Type; 
  29276.                    New_Base     : in out Node_Type; 
  29277.                    New_Key      : Relationship_Key; 
  29278.                    New_Relation : Relation_Name := Default_Relation) is 
  29279.  
  29280.         Shadow_File    : String(1 .. Max_Shadow_File_Length); 
  29281.         Shadow_Length  : Natural; 
  29282.         Is_Primary     : Boolean; 
  29283.         Rel_Attributes : List_Type; 
  29284.         Simple_List    : List_Type; 
  29285.  
  29286.     begin
  29287.  
  29288.         if not Node_Representation.Open_Status(New_Base) or not 
  29289.             Node_Representation.Open_Status(Node) then 
  29290.             raise Node_Definitions.Status_Error; 
  29291.         end if; 
  29292.         Cais_Utilities.Check_Intentions(New_Base, Append_Relationships); 
  29293.  
  29294.         -- verify that the specified relation is not a predefined one that
  29295.         -- the user cannot set.
  29296.         if Predefined(New_Relation, Cais_Utilities.Relation) then 
  29297.             raise Node_Definitions.Use_Error; 
  29298.         end if; 
  29299.  
  29300.         -- see if relation and key refer to existing node
  29301.         Check_Relationship : begin
  29302.             Node_Representation.Get_A_Relationship(Node => New_Base, Rel_Name
  29303.                 => New_Relation, Rel_Key => New_Key, Rel_Attributes => 
  29304.                 Rel_Attributes, Primary => Is_Primary, Shadow_File => 
  29305.                 Shadow_File); 
  29306.             -- if we get here, the specified relationship alReady exists.
  29307.             -- This procedure call is history...
  29308.             raise Node_Definitions.Name_Error; 
  29309.         exception
  29310.             when No_Such_Relation | No_Such_Relationship => 
  29311.                 null;  -- the relationship does NOT exist...
  29312.  
  29313.         end Check_Relationship; 
  29314.  
  29315.         -- get the shadowfile name for node, set_a_relationship
  29316.         -- The new relationship has the path attribute Kind
  29317.         Get_Shadow_File_Name(Node, Shadow_File, Shadow_Length); 
  29318.         Copy(Rel_Attributes, Empty_List); 
  29319.         Cais_Utilities.String_To_Simple_List(Node_Kind'Image(Get_Kind(Node)), 
  29320.             Simple_List); 
  29321.         Insert(Rel_Attributes, Simple_List, "Kind", 0); 
  29322.         Set_A_Relationship(Node => New_Base, Rel_Name => New_Relation, Rel_Key
  29323.             => New_Key, Rel_Attributes => Rel_Attributes, Primary => False, 
  29324.             Shadow_File => Shadow_File(1 .. Shadow_Length)); 
  29325.  
  29326.         Write_Shadow_File(New_Base); 
  29327.  
  29328.     exception
  29329.         -- exceptions that are trapped (nothing propagated)
  29330.         -- exceptions that are propagated
  29331.         when Node_Definitions.Status_Error | Node_Definitions.Use_Error | 
  29332.             Node_Definitions.Intent_Violation | Node_Definitions.Name_Error | 
  29333.             Node_Definitions.Security_Violation => 
  29334.             raise; 
  29335.         -- exceptions that are mapped to other exceptions
  29336.         when Cais_Internals_Exceptions.No_Such_Shadow_File => 
  29337.             raise Node_Definitions.Name_Error; 
  29338.         -- predefined exceptions (propagated with trace)
  29339.         when Constraint_Error | Tasking_Error | Program_Error | Storage_Error | 
  29340.             Numeric_Error => 
  29341.             Trace.Report("PREDEFINED EXCEPTION in Node_Management.Link"); 
  29342.             raise; 
  29343.         -- unanticipated exceptions
  29344.         when others => 
  29345.             Set_Open(Node, False); 
  29346.             Trace.Report("UNANTICIPATED EXCEPTION in Node_Management.Link"); 
  29347.             raise Trace.Assertion_Violation; 
  29348.  
  29349.     end Link; 
  29350.  
  29351.  
  29352.     -- Additional Interface
  29353.     procedure Link(Node     : in out Node_Type; 
  29354.                    New_Name : Name_String) is 
  29355.  
  29356.         New_Base : Node_Type; 
  29357.     begin
  29358.         Open(New_Base, Base_Path(New_Name), (1 => Append_Relation