?? RIGHT := 110 ??
?? NEWTITLE := 'NOS/VE File Management : Tape Label Attributes Retrieval' ??
MODULE fmm$get_tape_label_cmd_attrib;

{ PURPOSE:
{   This module contains the procedure that gets the tape label attributes
{   defined by the CHATLA command.

?? NEWTITLE := 'Global Declarations Referenced by This Module', EJECT ??
?? PUSH (LISTEXT := ON) ??
*copyc ame$device_class_validation
*copyc ame$tape_program_actions
*copyc fme$file_management_errors
*copyc fst$attachment_options
*copyc fst$evaluated_file_reference
*copyc fst$tla_returned_attributes
*copyc ost$status
?? POP ??
*copyc bap$set_evaluated_file_abnormal
*copyc fmp$adjust_file_set_pos_values
*copyc fmp$locate_cycle_description
*copyc fmp$unlock_path_table
*copyc osp$set_status_abnormal

?? TITLE := 'fmp$get_tape_label_cmd_attrib', EJECT ??

  PROCEDURE [XDCL, #GATE] fmp$get_tape_label_cmd_attrib
    (    evaluated_file_reference: fst$evaluated_file_reference;
         rma_or_ring_privileged: boolean;
     VAR attributes {input, output} : fst$attachment_options;
     VAR returned_attributes: fst$tla_returned_attributes;
     VAR status: ost$status);

    VAR
      attachment_option: fst$file_attachment_choices,
      cmd_info: fst$tape_attachment_information,
      cycle_description: ^fmt$cycle_description,
      local_evaluated_file_reference: fst$evaluated_file_reference,
      path_table_locked: boolean,
      tape_descriptor_p: ^bat$tape_descriptor;

    status.normal := TRUE;
    local_evaluated_file_reference := evaluated_file_reference;
    fmp$locate_cycle_description (local_evaluated_file_reference, cycle_description, status);

    path_table_locked := status.normal;
    IF NOT status.normal THEN
      IF status.condition = fme$no_cycle_description THEN
        cycle_description := NIL;
        status.normal := TRUE;
      ELSE
        RETURN;
      IFEND;
    IFEND;

  /get_tape_label_cmd_attrib/
    BEGIN
      IF (cycle_description = NIL) OR NOT cycle_description^.attached_file THEN
        bap$set_evaluated_file_abnormal (evaluated_file_reference, ame$file_attachment_required,
              'FSP$GET_TAPE_LABEL_ATTRIBUTES', '', status);
        EXIT /get_tape_label_cmd_attrib/;
      IFEND;

      IF cycle_description^.device_class <> rmc$magnetic_tape_device THEN
        bap$set_evaluated_file_abnormal (evaluated_file_reference, ame$improper_device_class,
              'FSP$GET_TAPE_LABEL_ATTRIBUTES', 'MASS_STORAGE/NULL/TERMINAL', status);
        EXIT /get_tape_label_cmd_attrib/;
      IFEND;

      returned_attributes := $fst$tla_returned_attributes [];

      IF cycle_description^.global_file_information^.device_dependent_info.tape_descriptor <> NIL THEN
        RESET cycle_description^.global_file_information^.device_dependent_info.tape_descriptor;
        NEXT tape_descriptor_p IN cycle_description^.global_file_information^.device_dependent_info.
              tape_descriptor;
        IF tape_descriptor_p = NIL THEN
          osp$set_status_abnormal ('FM', fme$system_error,
                ' NIL tape_descriptor IN fmp$get_tape_label_cmd_attrib', status);
          EXIT /get_tape_label_cmd_attrib/;
        IFEND;

        IF cycle_description^.global_file_information^.open_count = 0 THEN
          cmd_info := tape_descriptor_p^.tape_label_attr_command_info;
        ELSE
          cmd_info := tape_descriptor_p^.tape_attachment_information;
        IFEND;
        fmp$adjust_file_set_pos_values (cmd_info);

        FOR attachment_option := 1 TO UPPERBOUND (attributes) DO
          IF attributes [attachment_option].selector = fsc$tape_attachment THEN
            CASE attributes [attachment_option].tape_attachment.selector OF
            = fsc$tape_block_type =
              IF cmd_info.block_type_source = fsc$tape_label_attr_command THEN
                attributes [attachment_option].tape_attachment.tape_block_type := cmd_info.block_type;
                returned_attributes := returned_attributes + $fst$tla_returned_attributes
                      [attributes [attachment_option].tape_attachment.selector];
              IFEND;

            = fsc$tape_character_conversion =
              IF cmd_info.character_conversion_source = fsc$tape_label_attr_command THEN
                attributes [attachment_option].tape_attachment.tape_character_conversion :=
                      cmd_info.character_conversion;
                returned_attributes := returned_attributes + $fst$tla_returned_attributes
                      [attributes [attachment_option].tape_attachment.selector];
              IFEND;

            = fsc$tape_character_set =
              IF cmd_info.character_set_source = fsc$tape_label_attr_command THEN
                attributes [attachment_option].tape_attachment.tape_character_set := cmd_info.character_set;
                returned_attributes := returned_attributes + $fst$tla_returned_attributes
                      [attributes [attachment_option].tape_attachment.selector];
              IFEND;

            = fsc$tape_creation_date =
              IF cmd_info.creation_date_source = fsc$tape_label_attr_command THEN
                attributes [attachment_option].tape_attachment.tape_creation_date := cmd_info.creation_date;
                returned_attributes := returned_attributes + $fst$tla_returned_attributes
                      [attributes [attachment_option].tape_attachment.selector];
              IFEND;

            = fsc$tape_expiration_date =
              IF cmd_info.expiration_date_source = fsc$tape_label_attr_command THEN
                attributes [attachment_option].tape_attachment.tape_expiration_date :=
                      cmd_info.expiration_date;
                returned_attributes := returned_attributes + $fst$tla_returned_attributes
                      [attributes [attachment_option].tape_attachment.selector];
              IFEND;

            = fsc$tape_file_accessibility =
{             IF rma_or_ring_privileged THEN
                IF cmd_info.file_accessibility_source = fsc$tape_label_attr_command THEN
                  attributes [attachment_option].tape_attachment.tape_file_accessibility :=
                        cmd_info.file_accessibility;
                  returned_attributes := returned_attributes + $fst$tla_returned_attributes
                        [attributes [attachment_option].tape_attachment.selector];
                IFEND;
{             ELSE
{               bap$set_evaluated_file_abnormal (evaluated_file_reference, ame$security_conflict, '',
{                     'FILE_ACCESSIBILITY', status);
{               EXIT /get_tape_label_cmd_attrib/;
{             IFEND;

            = fsc$tape_file_identifier =
              IF cmd_info.file_identifier_source = fsc$tape_label_attr_command THEN
                attributes [attachment_option].tape_attachment.tape_file_identifier :=
                      cmd_info.file_identifier;
                returned_attributes := returned_attributes + $fst$tla_returned_attributes
                      [attributes [attachment_option].tape_attachment.selector];
              IFEND;

            = fsc$tape_file_sequence_number =
              IF cmd_info.file_sequence_number_source = fsc$tape_label_attr_command THEN
                attributes [attachment_option].tape_attachment.tape_file_sequence_number :=
                      cmd_info.file_sequence_number;
                returned_attributes := returned_attributes + $fst$tla_returned_attributes
                      [attributes [attachment_option].tape_attachment.selector];
              IFEND;

            = fsc$tape_file_set_identifier =
              IF cmd_info.file_set_identifier_source = fsc$tape_label_attr_command THEN
                attributes [attachment_option].tape_attachment.tape_file_set_identifier :=
                      cmd_info.file_set_identifier;
                returned_attributes := returned_attributes + $fst$tla_returned_attributes
                      [attributes [attachment_option].tape_attachment.selector];
              IFEND;

            = fsc$tape_file_set_position =
              IF cmd_info.file_set_position_source = fsc$tape_label_attr_command THEN
                attributes [attachment_option].tape_attachment.tape_file_set_position :=
                      cmd_info.file_set_position;
                returned_attributes := returned_attributes + $fst$tla_returned_attributes
                      [attributes [attachment_option].tape_attachment.selector];
              IFEND;

            = fsc$tape_generation_number =
              IF cmd_info.generation_number_source = fsc$tape_label_attr_command THEN
                attributes [attachment_option].tape_attachment.tape_generation_number :=
                      cmd_info.generation_number;
                returned_attributes := returned_attributes + $fst$tla_returned_attributes
                      [attributes [attachment_option].tape_attachment.selector];
              IFEND;

            = fsc$tape_generation_version_num =
              IF cmd_info.generation_version_num_source = fsc$tape_label_attr_command THEN
                attributes [attachment_option].tape_attachment.tape_generation_version_num :=
                      cmd_info.generation_version_number;
                returned_attributes := returned_attributes + $fst$tla_returned_attributes
                      [attributes [attachment_option].tape_attachment.selector];
              IFEND;

            = fsc$tape_max_block_length =
              IF cmd_info.max_block_length_source = fsc$tape_label_attr_command THEN
                attributes [attachment_option].tape_attachment.tape_max_block_length :=
                      cmd_info.max_block_length;
                returned_attributes := returned_attributes + $fst$tla_returned_attributes
                      [attributes [attachment_option].tape_attachment.selector];
              IFEND;

            = fsc$tape_max_record_length =
              IF cmd_info.max_record_length_source = fsc$tape_label_attr_command THEN
                attributes [attachment_option].tape_attachment.tape_max_record_length :=
                      cmd_info.max_record_length;
                returned_attributes := returned_attributes + $fst$tla_returned_attributes
                      [attributes [attachment_option].tape_attachment.selector];
              IFEND;

            = fsc$tape_owner_identification =
              IF rma_or_ring_privileged THEN
                IF cmd_info.owner_identifier_source = fsc$tape_label_attr_command THEN
                  attributes [attachment_option].tape_attachment.tape_owner_identification :=
                        cmd_info.owner_identifier;
                  returned_attributes := returned_attributes + $fst$tla_returned_attributes
                        [attributes [attachment_option].tape_attachment.selector];
                IFEND;
              ELSE
                bap$set_evaluated_file_abnormal (evaluated_file_reference, ame$security_conflict, '',
                      'OWNER_IDENTIFICATION', status);
                EXIT /get_tape_label_cmd_attrib/;
              IFEND;

            = fsc$tape_padding_character =
              IF cmd_info.padding_character_source = fsc$tape_label_attr_command THEN
                attributes [attachment_option].tape_attachment.tape_padding_character :=
                      cmd_info.padding_character;
                returned_attributes := returned_attributes + $fst$tla_returned_attributes
                      [attributes [attachment_option].tape_attachment.selector];
              IFEND;

            = fsc$tape_record_type =
              IF cmd_info.record_type_source = fsc$tape_label_attr_command THEN
                attributes [attachment_option].tape_attachment.tape_record_type := cmd_info.record_type;
                returned_attributes := returned_attributes + $fst$tla_returned_attributes
                      [attributes [attachment_option].tape_attachment.selector];
              IFEND;

            = fsc$tape_removable_media_group =
              IF rma_or_ring_privileged THEN
                IF cmd_info.removable_media_group_source = fsc$tape_label_attr_command THEN
                  attributes [attachment_option].tape_attachment.tape_removable_media_group :=
                        cmd_info.removable_media_group;
                  returned_attributes := returned_attributes + $fst$tla_returned_attributes
                        [attributes [attachment_option].tape_attachment.selector];
                IFEND;
              ELSE
                bap$set_evaluated_file_abnormal (evaluated_file_reference, ame$security_conflict, '',
                      'REMOVABLE_MEDIA_GROUP', status);
                EXIT /get_tape_label_cmd_attrib/;
              IFEND;

            = fsc$tape_rewrite_labels =
              IF cmd_info.rewrite_labels_source = fsc$tape_label_attr_command THEN
                attributes [attachment_option].tape_attachment.tape_rewrite_labels := cmd_info.rewrite_labels;
                returned_attributes := returned_attributes + $fst$tla_returned_attributes
                      [attributes [attachment_option].tape_attachment.selector];
              IFEND;

            = fsc$tape_volume_accessibility =
              IF rma_or_ring_privileged THEN
                IF cmd_info.volume_accessibility_source = fsc$tape_label_attr_command THEN
                  attributes [attachment_option].tape_attachment.tape_volume_accessibility :=
                        cmd_info.volume_accessibility;
                  returned_attributes := returned_attributes + $fst$tla_returned_attributes
                        [attributes [attachment_option].tape_attachment.selector];
                IFEND;
              ELSE
                bap$set_evaluated_file_abnormal (evaluated_file_reference, ame$security_conflict, '',
                      'VOLUME_ACCESSIBILITY', status);
                EXIT /get_tape_label_cmd_attrib/;
              IFEND;

            ELSE { unimplemented attribute }
              ;
            CASEND;

          IFEND;
        FOREND;
      IFEND; { tape_descriptor <> NIL }

    END /get_tape_label_cmd_attrib/;

    IF path_table_locked THEN
      fmp$unlock_path_table;
    IFEND;

  PROCEND fmp$get_tape_label_cmd_attrib;
MODEND fmm$get_tape_label_cmd_attrib;
