?? NEWTITLE := 'NOS/VE Basic Access Method : Attribute Merging Procedures' ??
MODULE bam$merge_attributes;
?? RIGHT := 110 ??

{ PURPOSE:
{   This module contains the routines used to merge file attributes.

?? NEWTITLE := 'Global Declarations Referenced by this Module', EJECT ??
?? PUSH (LISTEXT := ON) ??
*copyc amc$condition_code_limits
*copyc amt$file_access_selections
*copyc osd$virtual_address
*copyc amt$access_level
*copyc amt$attribute_source
*copyc amt$average_record_length
*copyc amt$block_type
*copyc amt$collate_table
*copyc amt$collation_value
*copyc amt$data_padding
*copyc amt$error_exit_procedure
*copyc amt$error_limit
*copyc amt$estimated_record_count
*copyc amt$file_access_selections
*copyc amt$file_attribute_keys
*copyc amt$file_attributes
*copyc amt$file_byte_address
*copyc amt$file_identifier
*copyc amt$file_length
*copyc amt$file_limit
*copyc amt$file_organization
*copyc amt$file_position
*copyc amt$forced_write
*copyc amt$global_file_position
*copyc amt$index_padding
*copyc amt$internal_code
*copyc amt$key_length
*copyc amt$key_position
*copyc amt$key_type
*copyc amt$label_exit_procedure
*copyc amt$label_options
*copyc amt$label_type
*copyc amt$local_file_name
*copyc amc$mau_length
*copyc amt$max_block_length
*copyc amt$max_record_length
*copyc amt$message_control
*copyc amt$min_block_length
*copyc amt$min_record_length
*copyc amt$padding_character
*copyc amt$record_limit
*copyc amt$record_type
*copyc amt$records_per_block
*copyc amt$return_option
*copyc amt$user_info
*copyc amt$vertical_print_density
*copyc ost$status
*copyc ame$attribute_validation_errors
*copyc amt$file_attributes
*copyc bat$descriptive_file_attributes
*copyc bat$dynamic_label_attributes
*copyc bat$static_label_attributes
*copyc fsc$local
*copyc fst$open_position
*copyc osd$virtual_address
*copyc ost$status
?? POP ??
*copyc fsp$dtm_structure_from_contents
*copyc fsp$path_element
*copyc fsp$set_evaluated_file_abnormal
*copyc osp$append_status_integer

*copyc fmv$system_file_attributes
*copyc fsv$evaluated_file_reference
*copyc osv$lower_to_upper
?? OLDTITLE ??
?? NEWTITLE := 'Global Declarations Declared by this Module', EJECT ??

  CONST
    parameter_name = 'FILE_ATTRIBUTES';

?? OLDTITLE ??
?? NEWTITLE := '[xdcl] BAP$MERGE_DYNAMIC_ATTR_SOURCE', EJECT ??

  PROCEDURE [XDCL] bap$merge_dynamic_attr_source
    (    evaluated_file_reference: fst$evaluated_file_reference;
         attributes: ^amt$file_attributes;
         source: amc$file_command .. amc$file_request;
     VAR dynamic_label {input, output} : bat$dynamic_label_attributes;
     VAR status: ost$status);

    VAR
      attribute_p: ^amt$file_item,
      translated_name: ost$name,
      i: integer;

    status.normal := TRUE;
    FOR i := 1 TO UPPERBOUND (attributes^) DO
      attribute_p := ^attributes^ [i];
      CASE attribute_p^.key OF
      = amc$access_mode =
        IF (dynamic_label.access_mode_source = amc$undefined_attribute) OR
              (source <= dynamic_label.access_mode_source) THEN
          dynamic_label.access_mode := attribute_p^.access_mode;
          dynamic_label.access_mode_source := source;
        IFEND;
      = amc$error_exit_name =
        IF (dynamic_label.error_exit_name_source = amc$undefined_attribute) OR
              (source <= dynamic_label.error_exit_name_source) THEN
          #TRANSLATE (osv$lower_to_upper, attribute_p^.error_exit_name, translated_name);
          dynamic_label.error_exit_name := translated_name;
          IF dynamic_label.error_exit_name = osc$null_name THEN
            dynamic_label.error_exit_name_source := amc$undefined_attribute;
          ELSE
            dynamic_label.error_exit_name_source := source;
          IFEND;
        IFEND;
      = amc$error_options =
        IF (dynamic_label.error_options_source = amc$undefined_attribute) OR
              (source <= dynamic_label.error_options_source) THEN
          dynamic_label.error_options := attribute_p^.error_options;
          dynamic_label.error_options_source := source;
        IFEND;
      = amc$label_exit_name =
        IF (dynamic_label.label_exit_name_source = amc$undefined_attribute) OR
              (source <= dynamic_label.label_exit_name_source) THEN
          #TRANSLATE (osv$lower_to_upper, attribute_p^.label_exit_name, translated_name);
          dynamic_label.label_exit_name := translated_name;
          IF dynamic_label.label_exit_name = osc$null_name THEN
            dynamic_label.label_exit_name_source := amc$undefined_attribute;
          ELSE
            dynamic_label.label_exit_name_source := source;
          IFEND;
        IFEND;
      = amc$label_options =
        IF (dynamic_label.label_options_source = amc$undefined_attribute) OR
              (source <= dynamic_label.label_options_source) THEN
          dynamic_label.label_options := attribute_p^.label_options;
          dynamic_label.label_options_source := source;
        IFEND;
      = amc$open_position =
        IF (dynamic_label.open_position_source = amc$undefined_attribute) OR
              (source <= dynamic_label.open_position_source) THEN
          dynamic_label.open_position := attribute_p^.open_position;
          dynamic_label.open_position_source := source;
        IFEND;
      = amc$return_option =
        IF (dynamic_label.return_option_source = amc$undefined_attribute) OR
              (source <= dynamic_label.return_option_source) THEN
          dynamic_label.return_option := attribute_p^.return_option;
          dynamic_label.return_option_source := source;
        IFEND;

        { aam }

      = amc$error_limit =
        IF (dynamic_label.error_limit_source = amc$undefined_attribute) OR
              (source <= dynamic_label.error_limit_source) THEN
          dynamic_label.error_limit := attribute_p^.error_limit;
          dynamic_label.error_limit_source := source;
        IFEND;
      = amc$message_control =
        IF (dynamic_label.message_control_source = amc$undefined_attribute) OR
              (source <= dynamic_label.message_control_source) THEN
          dynamic_label.message_control := attribute_p^.message_control;
          dynamic_label.message_control_source := source;
        IFEND;
      ELSE
        IF status.normal THEN
          fsp$set_evaluated_file_abnormal (evaluated_file_reference, ame$improper_file_attrib_key,
                amc$get_file_attributes_req, parameter_name, status);
          osp$append_status_integer (osc$status_parameter_delimiter, i, 10, FALSE, status);
        ELSE
          osp$append_status_integer (',', i, 10, FALSE, status);
        IFEND;
      CASEND;
    FOREND;

  PROCEND bap$merge_dynamic_attr_source;
?? OLDTITLE ??
?? NEWTITLE := '[xdcl, #gate] BAP$MERGE_STATIC_ATTRIBUTES', EJECT ??

  PROCEDURE [XDCL, #GATE] bap$merge_static_attributes
    (    evaluated_file_reference: fst$evaluated_file_reference;
         attributes: ^amt$file_attributes;
     VAR static_label {input, output} : bat$static_label_attributes;
     VAR status: ost$status);

    VAR
      attribute_p: ^amt$file_item,
      translated_name: ost$name,
      i: integer;

    status.normal := TRUE;
    IF attributes = NIL THEN
      RETURN; {----->
    IFEND;

    FOR i := 1 TO UPPERBOUND (attributes^) DO
      attribute_p := ^attributes^ [i];
      CASE attribute_p^.key OF
      = amc$block_type =
        IF (static_label.block_type_source = amc$undefined_attribute) OR
              (amc$file_request <= static_label.block_type_source) THEN
          static_label.block_type := attribute_p^.block_type;
          static_label.block_type_source := amc$file_request;
        IFEND;
      = amc$character_conversion =
        IF (static_label.character_conversion_source = amc$undefined_attribute) OR
              (amc$file_request <= static_label.character_conversion_source) THEN
          static_label.character_conversion := attribute_p^.character_conversion;
          static_label.character_conversion_source := amc$file_request;
        IFEND;
      = amc$clear_space =
        IF (static_label.clear_space_source = amc$undefined_attribute) OR
              (amc$file_request <= static_label.clear_space_source) THEN
          static_label.clear_space := attribute_p^.clear_space;
          static_label.clear_space_source := amc$file_request;
        IFEND;
      = amc$file_access_procedure =
        IF (static_label.file_access_procedure_source = amc$undefined_attribute) OR
              (amc$file_request <= static_label.file_access_procedure_source) THEN
          #TRANSLATE (osv$lower_to_upper, attribute_p^.file_access_procedure, translated_name);
          static_label.file_access_procedure := translated_name;
          static_label.file_access_procedure_source := amc$file_request;
        IFEND;
      = amc$file_contents =
        IF ((amc$file_request <= static_label.file_contents_source) OR
              (static_label.file_contents_source = amc$undefined_attribute)) AND
              ((amc$file_request <= static_label.file_structure_source) OR
              (static_label.file_structure_source = amc$undefined_attribute)) THEN
          #TRANSLATE (osv$lower_to_upper, attribute_p^.file_contents, translated_name);
          static_label.file_contents := translated_name;
          static_label.file_contents_source := amc$file_request;
        IFEND;
      = amc$file_limit =
        IF (static_label.file_limit_source = amc$undefined_attribute) OR
              (amc$file_request <= static_label.file_limit_source) THEN
          static_label.file_limit := attribute_p^.file_limit;
          static_label.file_limit_source := amc$file_request;
        IFEND;
      = amc$file_organization =
        IF (static_label.file_organization_source = amc$undefined_attribute) OR
              (amc$file_request <= static_label.file_organization_source) THEN
          static_label.file_organization := attribute_p^.file_organization;
          static_label.file_organization_source := amc$file_request;
        IFEND;
      = amc$file_processor =
        IF (static_label.file_processor_source = amc$undefined_attribute) OR
              (amc$file_request <= static_label.file_processor_source) THEN
          #TRANSLATE (osv$lower_to_upper, attribute_p^.file_processor, translated_name);
          static_label.file_processor := translated_name;
          static_label.file_processor_source := amc$file_request;
        IFEND;
      = amc$file_structure =
        IF ((amc$file_request <= static_label.file_contents_source) OR
              (static_label.file_contents_source = amc$undefined_attribute)) AND
              ((amc$file_request <= static_label.file_structure_source) OR
              (static_label.file_structure_source = amc$undefined_attribute)) THEN
          #TRANSLATE (osv$lower_to_upper, attribute_p^.file_structure, translated_name);
          static_label.file_structure := translated_name;
          static_label.file_structure_source := amc$file_request;
        IFEND;
      = amc$forced_write =
        IF (static_label.forced_write_source = amc$undefined_attribute) OR
              (amc$file_request <= static_label.forced_write_source) THEN
          static_label.forced_write := attribute_p^.forced_write;
          static_label.forced_write_source := amc$file_request;
        IFEND;
      = amc$internal_code =
        IF (static_label.internal_code_source = amc$undefined_attribute) OR
              (amc$file_request <= static_label.internal_code_source) THEN
          static_label.internal_code := attribute_p^.internal_code;
          static_label.internal_code_source := amc$file_request;
        IFEND;
      = amc$label_type =
        IF (static_label.label_type_source = amc$undefined_attribute) OR
              (amc$file_request <= static_label.label_type_source) THEN
          static_label.label_type := attribute_p^.label_type;
          static_label.label_type_source := amc$file_request;
        IFEND;
      = amc$line_number =
        IF (static_label.line_number_source = amc$undefined_attribute) OR
              (amc$file_request <= static_label.line_number_source) THEN
          static_label.line_number := attribute_p^.line_number;
          static_label.line_number_source := amc$file_request;
        IFEND;
      = amc$max_block_length =
        IF (static_label.max_block_length_source = amc$undefined_attribute) OR
              (amc$file_request <= static_label.max_block_length_source) THEN
          static_label.max_block_length := attribute_p^.max_block_length;
          static_label.max_block_length_source := amc$file_request;
        IFEND;
      = amc$max_record_length =
        IF (static_label.max_record_length_source = amc$undefined_attribute) OR
              (amc$file_request <= static_label.max_record_length_source) THEN
          static_label.max_record_length := attribute_p^.max_record_length;
          static_label.max_record_length_source := amc$file_request;
        IFEND;
      = amc$min_block_length =
        IF (static_label.min_block_length_source = amc$undefined_attribute) OR
              (amc$file_request <= static_label.min_block_length_source) THEN
          static_label.min_block_length := attribute_p^.min_block_length;
          static_label.min_block_length_source := amc$file_request;
        IFEND;
      = amc$min_record_length =
        IF (static_label.min_record_length_source = amc$undefined_attribute) OR
              (amc$file_request <= static_label.min_record_length_source) THEN
          static_label.min_record_length := attribute_p^.min_record_length;
          static_label.min_record_length_source := amc$file_request;
        IFEND;
      = amc$padding_character =
        IF (static_label.padding_character_source = amc$undefined_attribute) OR
              (amc$file_request <= static_label.padding_character_source) THEN
          static_label.padding_character := attribute_p^.padding_character;
          static_label.padding_character_source := amc$file_request;
        IFEND;
      = amc$page_format =
        IF (static_label.page_format_source = amc$undefined_attribute) OR
              (amc$file_request <= static_label.page_format_source) THEN
          static_label.page_format := attribute_p^.page_format;
          static_label.page_format_source := amc$file_request;
        IFEND;
      = amc$page_length =
        IF (static_label.page_length_source = amc$undefined_attribute) OR
              (amc$file_request <= static_label.page_length_source) THEN
          static_label.page_length := attribute_p^.page_length;
          static_label.page_length_source := amc$file_request;
        IFEND;
      = amc$page_width =
        IF (static_label.page_width_source = amc$undefined_attribute) OR
              (amc$file_request <= static_label.page_width_source) THEN
          static_label.page_width := attribute_p^.page_width;
          static_label.page_width_source := amc$file_request;
        IFEND;
      = amc$preset_value =
        IF (static_label.preset_value_source = amc$undefined_attribute) OR
              (amc$file_request <= static_label.preset_value_source) THEN
          static_label.preset_value := attribute_p^.preset_value;
          static_label.preset_value_source := amc$file_request;
        IFEND;
      = amc$record_type =
        IF (static_label.record_type_source = amc$undefined_attribute) OR
              (amc$file_request <= static_label.record_type_source) THEN
          static_label.record_type := attribute_p^.record_type;
          static_label.record_type_source := amc$file_request;
        IFEND;
      = amc$ring_attributes =
        IF (static_label.ring_attributes_source = amc$undefined_attribute) OR
              (amc$file_request <= static_label.ring_attributes_source) THEN
          static_label.ring_attributes := attribute_p^.ring_attributes;
          static_label.ring_attributes_source := amc$file_request;
        IFEND;
      = amc$statement_identifier =
        IF (static_label.statement_identifier_source = amc$undefined_attribute) OR
              (amc$file_request <= static_label.statement_identifier_source) THEN
          static_label.statement_identifier := attribute_p^.statement_identifier;
          static_label.statement_identifier_source := amc$file_request;
        IFEND;
      = amc$user_info =
        IF (static_label.user_info_source = amc$undefined_attribute) OR
              (amc$file_request <= static_label.user_info_source) THEN
          static_label.user_info := attribute_p^.user_info;
          static_label.user_info_source := amc$file_request;
        IFEND;
      = amc$vertical_print_density =
        IF (static_label.vertical_print_density_source = amc$undefined_attribute) OR
              (amc$file_request <= static_label.vertical_print_density_source) THEN
          static_label.vertical_print_density := attribute_p^.vertical_print_density;
          static_label.vertical_print_density_source := amc$file_request;
        IFEND;

        { aam }

      = amc$average_record_length =
        IF (static_label.average_record_length_source = amc$undefined_attribute) OR
              (amc$file_request <= static_label.average_record_length_source) THEN
          static_label.average_record_length := attribute_p^.average_record_length;
          static_label.average_record_length_source := amc$file_request;
        IFEND;
      = amc$collate_table_name =
        IF (static_label.collate_table_name_source = amc$undefined_attribute) OR
              (amc$file_request <= static_label.collate_table_name_source) THEN
          #TRANSLATE (osv$lower_to_upper, attribute_p^.collate_table_name, translated_name);
          static_label.collate_table_name := translated_name;
          IF static_label.collate_table_name = osc$null_name THEN
            static_label.collate_table_name_source := amc$undefined_attribute;
          ELSE
            static_label.collate_table_name_source := amc$file_request;
          IFEND;
        IFEND;
      = amc$compression_procedure_name =
        IF (static_label.compression_proc_name_source = amc$undefined_attribute) OR
              (amc$file_request <= static_label.compression_proc_name_source) THEN
          IF attribute_p^.compression_procedure_name <> NIL THEN
            #TRANSLATE (osv$lower_to_upper, attribute_p^.compression_procedure_name^.name, translated_name);
            static_label.compression_procedure_name.name := translated_name;
            static_label.compression_procedure_name.object_library :=
                  attribute_p^.compression_procedure_name^.object_library;
            IF static_label.compression_procedure_name.name = osc$null_name THEN
              static_label.compression_proc_name_source := amc$undefined_attribute;
            ELSE
              static_label.compression_proc_name_source := amc$file_request;
            IFEND;
          IFEND;
        IFEND;
      = amc$data_padding =
        IF (static_label.data_padding_source = amc$undefined_attribute) OR
              (amc$file_request <= static_label.data_padding_source) THEN
          static_label.data_padding := attribute_p^.data_padding;
          static_label.data_padding_source := amc$file_request;
        IFEND;
      = amc$dynamic_home_block_space =
        IF (static_label.dynamic_home_block_space_source = amc$undefined_attribute) OR
              (amc$file_request <= static_label.dynamic_home_block_space_source) THEN
          static_label.dynamic_home_block_space := attribute_p^.dynamic_home_block_space;
          static_label.dynamic_home_block_space_source := amc$file_request;
        IFEND;
      = amc$embedded_key =
        IF (static_label.embedded_key_source = amc$undefined_attribute) OR
              (amc$file_request <= static_label.embedded_key_source) THEN
          static_label.embedded_key := attribute_p^.embedded_key;
          static_label.embedded_key_source := amc$file_request;
        IFEND;
      = amc$estimated_record_count =
        IF (static_label.estimated_record_count_source = amc$undefined_attribute) OR
              (amc$file_request <= static_label.estimated_record_count_source) THEN
          static_label.estimated_record_count := attribute_p^.estimated_record_count;
          static_label.estimated_record_count_source := amc$file_request;
        IFEND;
      = amc$hashing_procedure_name =
        IF (static_label.hashing_procedure_name_source = amc$undefined_attribute) OR
              (amc$file_request <= static_label.hashing_procedure_name_source) THEN
          IF attribute_p^.hashing_procedure_name <> NIL THEN
            #TRANSLATE (osv$lower_to_upper, attribute_p^.hashing_procedure_name^.name, translated_name);
            static_label.hashing_procedure_name.name := translated_name;
            static_label.hashing_procedure_name.object_library :=
                  attribute_p^.hashing_procedure_name^.object_library;
            IF static_label.hashing_procedure_name.name = osc$null_name THEN
              static_label.hashing_procedure_name_source := amc$undefined_attribute;
            ELSE
              static_label.hashing_procedure_name_source := amc$file_request;
            IFEND;
          IFEND;
        IFEND;
      = amc$index_levels =
        IF (static_label.index_levels_source = amc$undefined_attribute) OR
              (amc$file_request <= static_label.index_levels_source) THEN
          static_label.index_levels := attribute_p^.index_levels;
          static_label.index_levels_source := amc$file_request;
        IFEND;
      = amc$index_padding =
        IF (static_label.index_padding_source = amc$undefined_attribute) OR
              (amc$file_request <= static_label.index_padding_source) THEN
          static_label.index_padding := attribute_p^.index_padding;
          static_label.index_padding_source := amc$file_request;
        IFEND;
      = amc$initial_home_block_count =
        IF (static_label.initial_home_block_count_source = amc$undefined_attribute) OR
              (amc$file_request <= static_label.initial_home_block_count_source) THEN
          static_label.initial_home_block_count := attribute_p^.initial_home_block_count;
          static_label.initial_home_block_count_source := amc$file_request;
        IFEND;
      = amc$key_length =
        IF (static_label.key_length_source = amc$undefined_attribute) OR
              (amc$file_request <= static_label.key_length_source) THEN
          static_label.key_length := attribute_p^.key_length;
          static_label.key_length_source := amc$file_request;
        IFEND;
      = amc$key_position =
        IF (static_label.key_position_source = amc$undefined_attribute) OR
              (amc$file_request <= static_label.key_position_source) THEN
          static_label.key_position := attribute_p^.key_position;
          static_label.key_position_source := amc$file_request;
        IFEND;
      = amc$key_type =
        IF (static_label.key_type_source = amc$undefined_attribute) OR
              (amc$file_request <= static_label.key_type_source) THEN
          static_label.key_type := attribute_p^.key_type;
          static_label.key_type_source := amc$file_request;
        IFEND;
      = amc$loading_factor =
        IF (static_label.loading_factor_source = amc$undefined_attribute) OR
              (amc$file_request <= static_label.loading_factor_source) THEN
          static_label.loading_factor := attribute_p^.loading_factor;
          static_label.loading_factor_source := amc$file_request;
        IFEND;
      = amc$lock_expiration_time =
        IF (static_label.lock_expiration_time_source = amc$undefined_attribute) OR
              (amc$file_request <= static_label.lock_expiration_time_source) THEN
          static_label.lock_expiration_time := attribute_p^.lock_expiration_time;
          static_label.lock_expiration_time_source := amc$file_request;
        IFEND;
      = amc$logging_options =
        IF (static_label.logging_options_source = amc$undefined_attribute) OR
              (amc$file_request <= static_label.logging_options_source) THEN
          static_label.logging_options := attribute_p^.logging_options;
          static_label.logging_options_source := amc$file_request;
        IFEND;
      = amc$log_residence =
        IF (static_label.log_residence_source = amc$undefined_attribute) OR
              (amc$file_request <= static_label.log_residence_source) THEN
          IF attribute_p^.log_residence <> NIL THEN
            static_label.log_residence := attribute_p^.log_residence^;
            IF static_label.log_residence = osc$null_name THEN
              static_label.log_residence_source := amc$undefined_attribute;
            ELSE
              static_label.log_residence_source := amc$file_request;
            IFEND;
          IFEND;
        IFEND;
      = amc$record_limit =
        IF (static_label.record_limit_source = amc$undefined_attribute) OR
              (amc$file_request <= static_label.record_limit_source) THEN
          static_label.record_limit := attribute_p^.record_limit;
          static_label.record_limit_source := amc$file_request;
        IFEND;
      = amc$records_per_block =
        IF (static_label.records_per_block_source = amc$undefined_attribute) OR
              (amc$file_request <= static_label.records_per_block_source) THEN
          static_label.records_per_block := attribute_p^.records_per_block;
          static_label.records_per_block_source := amc$file_request;
        IFEND;
      ELSE
      CASEND;
    FOREND;

    IF static_label.page_length_source = amc$access_method_default THEN
      IF static_label.vertical_print_density_source <> amc$access_method_default THEN
        static_label.page_length := static_label.vertical_print_density * 10;
      IFEND;
    IFEND;

    {The following code insures that file_contents and file_structure have}
    { sources with equivalent precedence.}
    IF (static_label.file_contents_source <> static_label.file_structure_source) THEN
      IF ((static_label.file_structure_source < static_label.file_contents_source) AND
            (static_label.file_structure_source <> amc$undefined_attribute)) OR
            (static_label.file_contents_source = amc$undefined_attribute) THEN
        static_label.file_contents := 'UNKNOWN';
        static_label.file_contents_source := static_label.file_structure_source;
      ELSE
        fsp$dtm_structure_from_contents (static_label.file_contents, static_label.file_structure);
        static_label.file_structure_source := static_label.file_contents_source;
      IFEND;
    IFEND;

  PROCEND bap$merge_static_attributes;
?? OLDTITLE ??
MODEND bam$merge_attributes;
