*copyc osd$default_pragmats
MODULE fmm$verify_attribute_limits;

{
{ PURPOSE:
{    This module contains a procedure that verifies that the values of file
{ attributes defined as integer subranges and whose source is undefined, are
{ within the currently defined limits.
{
{ DESIGN:
{    The file label is searched for those attributes defined as integer
{ subranges and whose sources are undefined.  If their values are not within the
{ defined limits of their TYPEs the values are changed to the current default.
{
{        FMP$VERIFY_ATTRIBUTE_LIMITS (STATIC_LABEL, STATUS)
{
{ STATIC_LABEL: (input) This parameter specifies the pointer to the label
{        of the file whose attributes are to verified.
{
{ STATUS: (output) This parameter returns the request status.
{
?? PUSH (LISTEXT := ON) ??
*copyc ame$attribute_validation_errors
*copyc fmt$file_attribute_keys
*copyc fmt$file_label
*copyc fmt$static_label_header
*copyc fmt$static_label_item
*copyc fmv$system_file_attributes
*copyc osp$set_status_abnormal
?? POP ??

?? TITLE := '[XDCL] fmp$verify_attribute_limits', EJECT ??

  PROCEDURE [XDCL] fmp$verify_attribute_limits (static_label: ^SEQ ( * );
    VAR status: ost$status);

    VAR
      attribute_key: fmt$file_attribute_keys,
      label_header: ^fmt$static_label_header,
      p_static_label: ^SEQ ( * ),
      static_label_item: ^fmt$static_label_item,
      str: ^string ( * );

    p_static_label := static_label; {make a local copy of sequence pointer}
    RESET p_static_label;
    NEXT label_header IN p_static_label;

    FOR attribute_key := fmc$ring_attributes TO label_header^.
          highest_attribute_present DO
      IF label_header^.attribute_present [attribute_key] THEN
        CASE attribute_key OF
        = fmc$average_record_length =
          NEXT static_label_item: [fmc$average_record_length] IN
                p_static_label;
          IF static_label_item = NIL THEN
            osp$set_status_abnormal (amc$access_method_id, ame$damaged_file_attributes,
              'average_record_length NIL in fmp$verify_attribute_limits', status);
            RETURN;
          IFEND;
          IF static_label_item^.source = amc$undefined_attribute THEN
            IF (static_label_item^.integer_value < LOWERVALUE
                  (amt$average_record_length)) OR (static_label_item^.
                  integer_value > UPPERVALUE (amt$average_record_length)) THEN
              static_label_item^.integer_value := fmv$system_file_attributes.
                    static_label.average_record_length;
            IFEND;
          IFEND;
        = fmc$key_length =
          NEXT static_label_item: [fmc$key_length] IN
                p_static_label;
          IF static_label_item = NIL THEN
            osp$set_status_abnormal (amc$access_method_id, ame$damaged_file_attributes,
              'key_length NIL in fmp$verify_attribute_limits', status);
            RETURN;
          IFEND;
          IF static_label_item^.source = amc$undefined_attribute THEN
            IF (static_label_item^.integer_value < LOWERVALUE (amt$key_length))
                  OR (static_label_item^.integer_value > UPPERVALUE
                  (amt$key_length)) THEN
              static_label_item^.integer_value := fmv$system_file_attributes.
                    static_label.key_length;
            IFEND;
          IFEND;
        = fmc$line_number =
          NEXT static_label_item: [fmc$line_number] IN
                p_static_label;
          IF static_label_item = NIL THEN
            osp$set_status_abnormal (amc$access_method_id, ame$damaged_file_attributes,
              'line_number NIL in fmp$verify_attribute_limits', status);
            RETURN;
          IFEND;
          IF static_label_item^.source = amc$undefined_attribute THEN
            IF (static_label_item^.line_number.length < LOWERVALUE
                  (amt$line_number_length)) OR (static_label_item^.
                  line_number.length > UPPERVALUE (amt$line_number_length)) THEN
              static_label_item^.line_number.length := fmv$system_file_attributes.
                    static_label.line_number.length;
            IFEND;
            IF (static_label_item^.line_number.location < LOWERVALUE
                  (amt$line_number_location)) OR (static_label_item^.
                  line_number.location > UPPERVALUE (amt$line_number_location)) THEN
              static_label_item^.line_number.location := fmv$system_file_attributes.
                    static_label.line_number.location;
            IFEND;
          IFEND;
        = fmc$record_limit =
          NEXT static_label_item: [fmc$record_limit] IN
                p_static_label;
          IF static_label_item = NIL THEN
            osp$set_status_abnormal (amc$access_method_id, ame$damaged_file_attributes,
              'record_limit NIL in fmp$verify_attribute_limits', status);
            RETURN;
          IFEND;
          IF static_label_item^.source = amc$undefined_attribute THEN
            IF (static_label_item^.integer_value < LOWERVALUE (amt$record_limit))
                  OR (static_label_item^.integer_value > UPPERVALUE
                  (amt$record_limit)) THEN
              static_label_item^.integer_value := fmv$system_file_attributes.
                    static_label.record_limit;
            IFEND;
          IFEND;
        = fmc$records_per_block =
          NEXT static_label_item: [fmc$records_per_block] IN
                p_static_label;
          IF static_label_item = NIL THEN
            osp$set_status_abnormal (amc$access_method_id, ame$damaged_file_attributes,
              'records_per_block NIL in fmp$verify_attribute_limits', status);
            RETURN;
          IFEND;
          IF static_label_item^.source = amc$undefined_attribute THEN
            IF (static_label_item^.integer_value < LOWERVALUE
                  (amt$records_per_block)) OR (static_label_item^.
                  integer_value > UPPERVALUE (amt$records_per_block)) THEN
              static_label_item^.integer_value := fmv$system_file_attributes.
                    static_label.records_per_block;
            IFEND;
          IFEND;
        = fmc$statement_identifier =
          NEXT static_label_item: [fmc$statement_identifier] IN
                p_static_label;
          IF static_label_item = NIL THEN
            osp$set_status_abnormal (amc$access_method_id, ame$damaged_file_attributes,
              'statement_identifier NIL in fmp$verify_attribute_limits', status);
            RETURN;
          IFEND;
          IF static_label_item^.source = amc$undefined_attribute THEN
            IF (static_label_item^.statement_identifier.length < LOWERVALUE
                  (amt$statement_id_length)) OR (static_label_item^.
                  statement_identifier.length > UPPERVALUE
                  (amt$statement_id_length)) THEN
              static_label_item^.statement_identifier.length :=
                    fmv$system_file_attributes.static_label.statement_identifier.length;
            IFEND;
            IF (static_label_item^.statement_identifier.location < LOWERVALUE
                  (amt$statement_id_location)) OR (static_label_item^.
                  statement_identifier.location > UPPERVALUE
                  (amt$statement_id_location)) THEN
              static_label_item^.statement_identifier.location :=
                    fmv$system_file_attributes.static_label.statement_identifier.location;
            IFEND;
          IFEND;
        = fmc$collate_table_name, fmc$compression_procedure_name,
          fmc$file_access_procedure, fmc$hashing_procedure_name =
          NEXT static_label_item: [attribute_key] IN
                p_static_label;
          IF static_label_item = NIL THEN
            osp$set_status_abnormal (amc$access_method_id, ame$damaged_file_attributes,
              'name NIL in fmp$verify_attribute_limits', status);
            RETURN;
          IFEND;
          NEXT str: [static_label_item^.entry_point_name_length] IN p_static_label;
          IF str = NIL THEN
            osp$set_status_abnormal (amc$access_method_id, ame$damaged_file_attributes,
              'str NIL in fmp$verify_attribute_limits for entry_point_name', status);
            RETURN;
          IFEND;
          IF static_label_item^.entry_point_path_length > 0 THEN
            NEXT str: [static_label_item^.entry_point_path_length] IN p_static_label;
            IF str = NIL THEN
              osp$set_status_abnormal (amc$access_method_id, ame$damaged_file_attributes,
                'str NIL in fmp$verify_attribute_limits for entry_point_path', status);
              RETURN;
            IFEND;
          IFEND;
        = fmc$file_contents, fmc$file_processor, fmc$file_structure =
          NEXT static_label_item: [attribute_key] IN
                p_static_label;
          IF static_label_item = NIL THEN
            osp$set_status_abnormal (amc$access_method_id, ame$damaged_file_attributes,
              'entry point reference NIL in fmp$verify_attribute_limits', status);
            RETURN;
          IFEND;
          NEXT str: [static_label_item^.name_length] IN p_static_label;
          IF str = NIL THEN
            osp$set_status_abnormal (amc$access_method_id, ame$damaged_file_attributes,
              'get_name str NIL in fmp$verify_attribute_limits', status);
            RETURN;
          IFEND;
        = fmc$log_residence =
          NEXT static_label_item: [fmc$log_residence] IN p_static_label;
          IF static_label_item = NIL THEN
            osp$set_status_abnormal (amc$access_method_id, ame$damaged_file_attributes,
              'log_residence NIL in fmp$verify_attribute_limits', status);
            RETURN;
          IFEND;
          NEXT str: [static_label_item^.path_length] IN p_static_label;
          IF str = NIL THEN
            osp$set_status_abnormal (amc$access_method_id, ame$damaged_file_attributes,
              'log_residence str NIL in fmp$verify_attribute_limits', status);
            RETURN;
          IFEND;
        = fmc$ring_attributes =
          ;
        = fmc$user_info =
          NEXT static_label_item: [fmc$user_info] IN p_static_label;
          IF static_label_item = NIL THEN
            osp$set_status_abnormal (amc$access_method_id, ame$damaged_file_attributes,
              'user_info NIL in fmp$verify_attribute_limits', status);
            RETURN;
          IFEND;
          IF static_label_item^.user_info_present THEN
            NEXT str: [32] IN p_static_label;
          IFEND;
        ELSE
          NEXT static_label_item: [attribute_key] IN p_static_label;
          IF static_label_item = NIL THEN
            osp$set_status_abnormal (amc$access_method_id, ame$damaged_file_attributes,
                  'item NIL in fmp$verify_attribute_limits', status);
            RETURN;
          IFEND;
        CASEND;
      IFEND;
    FOREND;
  PROCEND fmp$verify_attribute_limits;
MODEND fmm$verify_attribute_limits;

