
  PROCEDURE [INLINE] bai$get_record_header;

    manually_advance_to_next_block := FALSE;

    IF block_info^.block_position = bac$middle_of_block THEN
      IF rhl <= block_info^.residual_block_length THEN
        start_new_block := FALSE;
      ELSE
        start_new_block := TRUE;
      IFEND;
    ELSE
      start_new_block := TRUE;
    IFEND;

    get_data (file_identifier, operation, #LOC (rh), rhl,
          allow_direct_io_transfer, start_new_block,
          {convert_if_ebcdic =} FALSE, status);

    start_new_block := FALSE;

    IF NOT status.normal THEN
      manually_advance_to_next_block := TRUE;
      exit_situation := TRUE;
    ELSEIF gfi^.positioning_info.record_info.transfer_count < rhl THEN
      residual_data_length := 0;
      IF (tape_descriptor^.volume_position = amc$eov) OR
            (tape_descriptor^.volume_position = amc$after_tapemark) THEN
        no_header_read := TRUE;
        exit_situation := TRUE;
      ELSE
        manually_advance_to_next_block := TRUE;
        exit_situation := TRUE;
        amp$set_file_instance_abnormal (file_identifier,
              ame$improper_record_header, call_block.operation, ' ', status);
      IFEND
    ELSEIF (rh.unique_id = bac$record_header_unique_id) AND
          (rh.header_type <= UPPERVALUE (rh.header_type)) AND
          (rh.header_type >= LOWERVALUE (rh.header_type)) AND
          (rh.length <= UPPERVALUE (rh.length)) AND
          (rh.length >= LOWERVALUE (rh.length)) AND
          (rh.length <= block_info^.residual_block_length) THEN
      last_record_header_p := ^tape_descriptor^.
            get_tape_block_buffer^ [block_info^.current_block_byte_address +
            1 - rhl];
      residual_data_length := rh.length;
      IF rh.length = 0 THEN
        CASE rh.header_type OF
        = bac$full_record =
          zero_length_record := TRUE;
          exit_situation := TRUE;
        = bac$partition =
          exit_situation := TRUE;
        ELSE
        CASEND;
      IFEND;
    ELSE
      manually_advance_to_next_block := TRUE;
      exit_situation := TRUE;
      amp$set_file_instance_abnormal (file_identifier,
            ame$improper_record_header, call_block.operation, ' ', status);
    IFEND;

    gfi^.positioning_info.record_info.transfer_count := 0;

    IF manually_advance_to_next_block THEN
      residual_data_length := 0;
      block_info^.current_block_byte_address :=
            block_info^.current_block_byte_address +
            block_info^.residual_block_length;
      block_info^.residual_block_length :=
            block_info^.residual_block_length -
            block_info^.residual_block_length;
      gfi^.positioning_info.record_info.file_position := amc$mid_record;
    IFEND;

  PROCEND bai$get_record_header;
