?? RIGHT := 110 ??
?? NEWTITLE := 'NOS/VE Accounting and Validation: Validation Initialization' ??
MODULE avm$initialize;

{ PURPOSE:
{   This module contains the procedures to be called at deadstart to initialize families and initialize
{   accounting and validation.  This includes the validation file conversion routines.

*copyc avc$compile_test_code
?? NEWTITLE := 'Global Declarations referenced by this module', EJECT ??
?? PUSH (LISTEXT := ON) ??
*copyc avc$validation_default_values
*copyc avc$validation_field_names
*copyc avc$validation_file_name
*copyc avc$validation_record_names
*copyc ave$initialize_errors
*copyc avt$file_utility_information
*copyc fst$path
*copyc jmc$system_family
*copyc pfe$error_condition_codes
?? POP ??
*copyc amp$return
*copyc avp$change_account_member_rec
*copyc avp$change_account_record
*copyc avp$change_accum_limit_field
*copyc avp$change_capability_field
*copyc avp$change_capability_value
*copyc avp$change_file_utility_info
*copyc avp$change_file_value
*copyc avp$change_job_class_field
*copyc avp$change_job_class_value
*copyc avp$change_labeled_names_field
*copyc avp$change_labeled_names_value
*copyc avp$change_limit_field
*copyc avp$change_login_password_field
*copyc avp$change_login_password_value
*copyc avp$change_name_field
*copyc avp$change_name_value
*copyc avp$change_project_member_rec
*copyc avp$change_project_record
*copyc avp$change_ring_privilege_value
*copyc avp$change_user_record
*copyc avp$change_util_info_cmd_name
*copyc avp$change_val_field_name
*copyc avp$close_validation_file
*copyc avp$create_accum_limit_field
*copyc avp$create_capability_field
*copyc avp$create_labeled_names_field
*copyc avp$create_limit_field
*copyc avp$create_name_field
*copyc avp$create_user_record
*copyc avp$delete_validation_field
*copyc avp$end_subutility_session
*copyc avp$get_accum_limit_field_desc
*copyc avp$get_capabil_display_value
*copyc avp$get_capability_field_desc
*copyc avp$get_file_utility_info
*copyc avp$get_labeled_names_field_des
*copyc avp$get_limit_field_desc
*copyc avp$get_name_field_desc
*copyc avp$get_validation_field_names
*copyc avp$open_system_validation_file
*copyc avp$open_validation_file
*copyc avp$release_record_id
*copyc avp$verify_template_heap
*copyc avp$verify_user_exists
*copyc clp$trimmed_string_size
*copyc fsp$build_file_ref_from_elems
*copyc osp$append_status_parameter
*copyc osp$generate_output_message
*copyc osp$press_return_to_continue
*copyc osp$set_status_abnormal
*copyc pfp$define_master_catalog
*copyc pfp$purge
*copyc pmp$get_unique_name
*copyc pmp$get_user_identification
*copyc osv$deadstart_phase
*copyc stv$system_set_name
?? OLDTITLE ??
?? NEWTITLE := '[XDCL] avp$initialize', EJECT ??
*copyc avh$initialize

  PROCEDURE [XDCL] avp$initialize
    (VAR status: ost$status);

    VAR
      charge_id: pft$charge_id,
      file_information: avt$template_file_information,
      ignore_status: ost$status,
      new_path: ^array [1 .. * ] of pft$name,
      validation_file_path: fst$path;

    status.normal := TRUE;

{ Action is only neccessary if this is an installation deadstart.

    IF (osv$deadstart_phase = osc$installation_deadstart) THEN

{ Define the master catalog for the :$SYSTEM.$SYSTEM user.

      charge_id.account := osc$null_name;
      charge_id.project := osc$null_name;
      pfp$define_master_catalog (stv$system_set_name, jmc$system_family, jmc$system_user, charge_id, status);
      IF NOT status.normal THEN
        IF status.condition = pfe$duplicate_master_catalog THEN
          status.normal := TRUE;
        ELSE
          RETURN;
        IFEND;
      IFEND;

{ Create the validation file for the $SYSTEM family.

      PUSH new_path: [1 .. 3];
      new_path^ [1] := jmc$system_family;
      new_path^ [2] := jmc$system_user;
      new_path^ [3] := avc$validation_file_name;
      fsp$build_file_ref_from_elems (new_path, validation_file_path, status);
      IF NOT status.normal THEN
        RETURN;
      IFEND;

      avp$open_validation_file (validation_file_path, NIL, NIL, TRUE, file_information, status);
      IF NOT status.normal THEN
        RETURN;
      IFEND;

{ Add the $SYSTEM user to the validation file.

      avp$create_$system_user (jmc$system_family, file_information, status);

      avp$close_validation_file (file_information, ignore_status);
      amp$return (validation_file_path, ignore_status);
    IFEND;

  PROCEND avp$initialize;
?? OLDTITLE ??
?? NEWTITLE := '[XDCL] avp$initialize_family', EJECT ??

{ PURPOSE:
{   This procedure is called at set activation time to initialize a family.  It verifies the integrity of the
{   validation file for the family and converts it if necessary.

  PROCEDURE [XDCL] avp$initialize_family
    (    family_name: ost$family_name;
     VAR status: ost$status);

    VAR
      cycle_selector: pft$cycle_selector,
      file_information: avt$template_file_information,
      file_utility_information: ^avt$file_utility_information,
      ignore_status: ost$status,
      message_length: integer,
      message_status: ost$status,
      new_path: ^array [1 .. * ] of pft$name,
      system_user_exists: boolean,
      test_user_id: ost$user_identification,
      utility_information: ^avt$utility_information,
      validation_file_path: fst$path;

?? NEWTITLE := 'convert_validation_file', EJECT ??

{ PURPOSE:
{   This procedure converts a validation file to the latest version.

    PROCEDURE convert_validation_file
      (    family_name: ost$family_name;
           validation_file_version: ost$name;
       VAR file_information: avt$template_file_information;
       VAR status: ost$status);

      VAR
        description: ost$string,
        ignore_status: ost$status,
        prefix_length: ost$name_size;

      CONST
        prefix = '$OLD_';

?? NEWTITLE := 'add_accum_limit_field', EJECT ??

{ PURPOSE:
{   This procedure creates a new accumulating limit type validation field.

      PROCEDURE add_accum_limit_field
        (    field_name: ost$name;
             record_name: ost$name;
             job_warning_limit: avt$limit_value;
             job_maximum_limit: avt$limit_value;
             total_limit: avt$limit_value;
             limit_name: ost$name;
             job_limits_apply: boolean;
             limit_update_statistics: ^sft$limit_update_statistics;
             minimum_job_limit_value: avt$limit_value;
             maximum_job_limit_value: avt$limit_value;
             total_limit_applies: boolean;
             total_limit_stops_login: boolean;
             change_commands: avt$name_list;
             display_commands: avt$name_list;
             description: string ( * <= osc$max_string_size);
             display_authority: avt$validation_authority;
             change_authority: avt$validation_authority;
             manage_authority: avt$validation_authority;
             delete_authority: avt$validation_authority;
         VAR file_information: avt$template_file_information;
         VAR status: ost$status);

        VAR
          description_string: ost$string,
          get_change_authority: avt$validation_authority,
          get_delete_authority: avt$validation_authority,
          get_description: ost$string,
          get_display_authority: avt$validation_authority,
          get_job_limits_apply: boolean,
          get_job_maximum_limit: avt$limit_value,
          get_job_warning_limit: avt$limit_value,
          get_limit_name: ost$name,
          get_limit_update_statistics: ^sft$limit_update_statistics,
          get_manage_authority: avt$validation_authority,
          get_maximum_job_limit_value: avt$limit_value,
          get_minimum_job_limit_value: avt$limit_value,
          get_no_of_limit_update_stats: avt$name_list_size,
          get_total_accumulation: avt$limit_value,
          get_total_limit: avt$limit_value,
          get_total_limit_applies: boolean,
          get_total_limit_stops_login: boolean,
          new_field_name: ost$name;

        status.normal := TRUE;

        get_limit_update_statistics := NIL;
        description_string.value := description;
        description_string.size := #SIZE (description);

{ Determine if a field with this name already exists and is the correct type.

        avp$get_accum_limit_field_desc (field_name, record_name, {record_id=} osc$null_name,
              get_job_warning_limit, get_job_maximum_limit, get_total_limit, get_total_accumulation,
              get_limit_name, get_job_limits_apply, get_minimum_job_limit_value, get_maximum_job_limit_value,
              get_no_of_limit_update_stats, get_limit_update_statistics, get_total_limit_applies,
              get_total_limit_stops_login, get_description, get_change_authority, get_delete_authority,
              get_display_authority, get_manage_authority, file_information, status);
        IF status.normal THEN

{ If it does exist and it is the correct type then unconditionally change it to guarantee that the field is
{ set up correctly.

          avp$change_accum_limit_field (field_name, record_name, {job_warning_limit=} NIL,
                {job_maximum_limit=} NIL, {total_limit=} NIL, ^limit_name, {job_limits_apply=} NIL,
                {limit_update_statistics=} NIL, ^minimum_job_limit_value, ^maximum_job_limit_value,
                {total_limit_applies=} NIL, {total_limit_stops_login=} NIL, {change_command_names=} NIL,
                {display_command_names=} NIL, ^description_string, {display_authority=} NIL,
                {change_authority=} NIL, {manage_authority=} NIL, ^delete_authority, file_information,
                status);
          IF NOT status.normal THEN
            RETURN;
          IFEND;
        ELSE
          IF (status.condition <> ave$incorrect_kind) AND (status.condition <> ave$unknown_field) AND
                (status.condition <> ave$field_was_deleted) THEN
            RETURN;
          IFEND;

{ If it is not the correct type or has been deleted then the name of the field is changed so that the new
{ field can be created.

          IF (status.condition = ave$incorrect_kind) OR (status.condition = ave$field_was_deleted) THEN
            status.normal := TRUE;
            change_field_name (field_name, record_name, new_field_name, file_information, status);
            IF NOT status.normal THEN
              RETURN;
            IFEND;
          IFEND;

{ Make sure that no command table collisions can occur.

          prevalidate_command_table (record_name, change_commands, display_commands, file_information,
                status);
          IF NOT status.normal THEN
            RETURN;
          IFEND;

{ Create the new field.

          avp$create_accum_limit_field (field_name, record_name, job_warning_limit, job_maximum_limit,
                total_limit, limit_name, job_limits_apply, limit_update_statistics, minimum_job_limit_value,
                maximum_job_limit_value, total_limit_applies, total_limit_stops_login, change_commands,
                display_commands, description_string, display_authority, change_authority, manage_authority,
                delete_authority, file_information, status);
        IFEND;

      PROCEND add_accum_limit_field;
?? OLDTITLE ??
?? NEWTITLE := 'add_capability_field', EJECT ??

{ PURPOSE:
{   This procedure creates a new capability type validation field.

      PROCEDURE add_capability_field
        (    field_name: ost$name;
             record_name: ost$name;
             capability: boolean;
             description: string ( * <= osc$max_string_size);
             display_authority: avt$validation_authority;
             change_authority: avt$validation_authority;
             manage_authority: avt$validation_authority;
             delete_authority: avt$validation_authority;
         VAR file_information: avt$template_file_information;
         VAR status: ost$status);

        VAR
          description_string: ost$string,
          get_change_authority: avt$validation_authority,
          get_capability: boolean,
          get_delete_authority: avt$validation_authority,
          get_description: ost$string,
          get_display_authority: avt$validation_authority,
          get_manage_authority: avt$validation_authority,
          new_field_name: ost$name;

        status.normal := TRUE;
        description_string.value := description;
        description_string.size := #SIZE (description);

{ Determine if a field with this name already exists and is the correct type.

        avp$get_capability_field_desc (field_name, record_name, {record_id=} osc$null_name, get_capability,
              get_description, get_change_authority, get_delete_authority, get_display_authority,
              get_manage_authority, file_information, status);
        IF status.normal THEN

{ If it does exist and it is the correct type then unconditionally change it to guarantee that the field is
{ set up correctly.

          avp$change_capability_field (field_name, record_name, {capability=} NIL, ^description_string,
                {display_authority=} NIL, {change_authority=} NIL, {manage_authority=} NIL, ^delete_authority,
                file_information, status);
          IF NOT status.normal THEN
            RETURN;
          IFEND;
        ELSE
          IF (status.condition <> ave$incorrect_kind) AND (status.condition <> ave$unknown_field) AND
                (status.condition <> ave$field_was_deleted) THEN
            RETURN;
          IFEND;

{ If it is not the correct type or has been deleted then the name of the field is changed so that the new
{ field can be created.

          IF (status.condition = ave$incorrect_kind) OR (status.condition = ave$field_was_deleted) THEN
            status.normal := TRUE;
            change_field_name (field_name, record_name, new_field_name, file_information, status);
            IF NOT status.normal THEN
              RETURN;
            IFEND;
          IFEND;

{ Create the new field.

          avp$create_capability_field (field_name, record_name, capability, description_string,
                display_authority, change_authority, manage_authority, delete_authority, file_information,
                status);
        IFEND;

      PROCEND add_capability_field;
?? OLDTITLE ??
?? NEWTITLE := 'add_labeled_names_field', EJECT ??

{ PURPOSE:
{   This procedure creates a new labeled names type validation field.

      PROCEDURE add_labeled_names_field
        (    field_name: ost$name;
             record_name: ost$name;
             labeled_names: avt$labeled_names_list;
             valid_labels: avt$name_list;
             valid_names: avt$name_list;
             change_commands: avt$name_list;
             display_commands: avt$name_list;
             description: string ( * <= osc$max_string_size);
             display_authority: avt$validation_authority;
             change_authority: avt$validation_authority;
             manage_authority: avt$validation_authority;
             delete_authority: avt$validation_authority;
         VAR file_information: avt$template_file_information;
         VAR status: ost$status);

        VAR
          description_string: ost$string,
          get_change_authority: avt$validation_authority,
          get_delete_authority: avt$validation_authority,
          get_description: ost$string,
          get_display_authority: avt$validation_authority,
          get_labeled_names: ^avt$labeled_names_list,
          get_manage_authority: avt$validation_authority,
          get_number_of_valid_labels: avt$name_list_size,
          get_number_of_valid_names: avt$name_list_size,
          get_valid_labels: ^avt$name_list,
          get_valid_names: ^avt$name_list,
          new_field_name: ost$name,
          work_area: ^seq (*);

        status.normal := TRUE;
        description_string.value := description;
        description_string.size := #SIZE (description);

        get_labeled_names := NIL;
        get_valid_labels := NIL;
        get_valid_names := NIL;

{ Determine if a field with this name already exists and is the correct type.

        PUSH work_area: [[REP avc$max_template_record_size OF cell]];
        RESET work_area;
        avp$get_labeled_names_field_des (field_name, record_name, {record_id=} osc$null_name, work_area,
              get_labeled_names, get_number_of_valid_labels, get_valid_labels, get_number_of_valid_names,
              get_valid_names, get_description, get_change_authority, get_delete_authority,
              get_display_authority, get_manage_authority, file_information, status);
        IF status.normal THEN

{ If it does exist and it is the correct type then unconditionally change it to guarantee that the field is
{ set up correctly.

          avp$change_labeled_names_field (field_name, record_name, {add_labeled_names=} NIL,
                {delete_labeled_names=} NIL, {add_valid_labels=} NIL,  {delete_valid_labels=} NIL,
                {add_valid_names=} NIL,  {delete_valid_names=} NIL,
                {change_command_names=} NIL, {display_command_names=} NIL, ^description_string,
                {display_authority=} NIL, {change_authority=} NIL, {manage_authority=} NIL, ^delete_authority,
                file_information, status);
          IF NOT status.normal THEN
            RETURN;
          IFEND;
        ELSE
          IF (status.condition <> ave$incorrect_kind) AND (status.condition <> ave$unknown_field) AND
                (status.condition <> ave$field_was_deleted) THEN
            RETURN;
          IFEND;

{ If it is not the correct type or has been deleted then the name of the field is changed so that the new
{ field can be created.

          IF (status.condition = ave$incorrect_kind) OR (status.condition = ave$field_was_deleted) THEN
            status.normal := TRUE;
            change_field_name (field_name, record_name, new_field_name, file_information, status);
            IF NOT status.normal THEN
              RETURN;
            IFEND;
          IFEND;

{ Make sure that no command table collisions can occur.

          prevalidate_command_table (record_name, change_commands, display_commands, file_information,
                status);
          IF NOT status.normal THEN
            RETURN;
          IFEND;

{ Create the new field.

          avp$create_labeled_names_field (field_name, record_name, labeled_names, valid_labels,
                valid_names, change_commands, display_commands, description_string,
                display_authority, change_authority, manage_authority, delete_authority, file_information,
                status);
        IFEND;

      PROCEND add_labeled_names_field;
?? OLDTITLE ??
?? NEWTITLE := 'add_limit_field', EJECT ??

{ PURPOSE:
{   This procedure creates a new limit type validation field.

      PROCEDURE add_limit_field
        (    field_name: ost$name;
             record_name: ost$name;
             limit_value: avt$limit_value;
             minimum_limit_value: avt$limit_value;
             maximum_limit_value: avt$limit_value;
             change_commands: avt$name_list;
             display_commands: avt$name_list;
             description: string ( * <= osc$max_string_size);
             display_authority: avt$validation_authority;
             change_authority: avt$validation_authority;
             manage_authority: avt$validation_authority;
             delete_authority: avt$validation_authority;
         VAR file_information: avt$template_file_information;
         VAR status: ost$status);

        VAR
          description_string: ost$string,
          get_change_authority: avt$validation_authority,
          get_delete_authority: avt$validation_authority,
          get_description: ost$string,
          get_display_authority: avt$validation_authority,
          get_limit_value: avt$limit_value,
          get_minimum_limit_value: avt$limit_value,
          get_maximum_limit_value: avt$limit_value,
          get_manage_authority: avt$validation_authority,
          new_field_name: ost$name;

        status.normal := TRUE;
        description_string.value := description;
        description_string.size := #SIZE (description);

{ Determine if a field with this name already exists and is the correct type.

        avp$get_limit_field_desc (field_name, record_name, {record_id=} osc$null_name, get_limit_value,
              get_minimum_limit_value, get_maximum_limit_value, get_description, get_change_authority,
              get_delete_authority, get_display_authority, get_manage_authority, file_information, status);
        IF status.normal THEN

{ If it does exist and it is the correct type then unconditionally change it to guarantee that the field is
{ set up correctly.

          avp$change_limit_field (field_name, record_name, {limit_value =} NIL, ^minimum_limit_value,
                ^maximum_limit_value, {change_command_names=} NIL, {display_command_names=} NIL,
                ^description_string, {display_authority=} NIL, {change_authority=} NIL,
                {manage_authority=} NIL, ^delete_authority, file_information, status);
          IF NOT status.normal THEN
            RETURN;
          IFEND;
        ELSE
          IF (status.condition <> ave$incorrect_kind) AND (status.condition <> ave$unknown_field) AND
                (status.condition <> ave$field_was_deleted) THEN
            RETURN;
          IFEND;

{ If it is not the correct type or has been deleted then the name of the field is changed so that the new
{ field can be created.

          IF (status.condition = ave$incorrect_kind) OR (status.condition = ave$field_was_deleted) THEN
            status.normal := TRUE;
            change_field_name (field_name, record_name, new_field_name, file_information, status);
            IF NOT status.normal THEN
              RETURN;
            IFEND;
          IFEND;

{ Make sure that no command table collisions can occur.

          prevalidate_command_table (record_name, change_commands, display_commands, file_information,
                status);
          IF NOT status.normal THEN
            RETURN;
          IFEND;

{ Create the new field.

          avp$create_limit_field (field_name, record_name, limit_value, minimum_limit_value,
                maximum_limit_value, change_commands, display_commands, description_string, display_authority,
                change_authority, manage_authority, delete_authority, file_information, status);
        IFEND;

      PROCEND add_limit_field;
?? OLDTITLE ??
?? NEWTITLE := 'add_name_field', EJECT ??

{ PURPOSE:
{   This procedure creates a new name type validation field.

      PROCEDURE add_name_field
        (    field_name: ost$name;
             record_name: ost$name;
             names: avt$name_list;
             minimum_number_of_names: avt$name_list_size;
             maximum_number_of_names: avt$name_list_size;
             common_names: avt$name_list;
             change_commands: avt$name_list;
             display_commands: avt$name_list;
             description: string ( * <= osc$max_string_size);
             display_authority: avt$validation_authority;
             change_authority: avt$validation_authority;
             manage_authority: avt$validation_authority;
             delete_authority: avt$validation_authority;
         VAR file_information: avt$template_file_information;
         VAR status: ost$status);

        VAR
          description_string: ost$string,
          get_change_authority: avt$validation_authority,
          get_common_names: ^avt$name_list,
          get_delete_authority: avt$validation_authority,
          get_description: ost$string,
          get_display_authority: avt$validation_authority,
          get_manage_authority: avt$validation_authority,
          get_maximum_number_of_names: avt$name_list_size,
          get_minimum_number_of_names: avt$name_list_size,
          get_names: ^avt$name_list,
          get_number_of_common_names: avt$name_list_size,
          get_number_of_names: avt$name_list_size,
          new_field_name: ost$name;

        status.normal := TRUE;
        description_string.value := description;
        description_string.size := #SIZE (description);

        get_names := NIL;
        get_common_names := NIL;

{ Determine if a field with this name already exists and is the correct type.

        avp$get_name_field_desc (field_name, record_name, {record_id=} osc$null_name, get_number_of_names,
              get_names, get_minimum_number_of_names, get_maximum_number_of_names, get_number_of_common_names,
              get_common_names, get_description, get_change_authority, get_delete_authority,
              get_display_authority, get_manage_authority, file_information, status);
        IF status.normal THEN

{ If it does exist and it is the correct type then unconditionally change it to guarantee that the field is
{ set up correctly.

          avp$change_name_field (field_name, record_name, {add_names=} NIL, {delete_names=} NIL,
                ^minimum_number_of_names, ^maximum_number_of_names, ^common_names, {delete_common_names=} NIL,
                {change_command_names=} NIL, {display_command_names=} NIL, ^description_string,
                {display_authority=} NIL, {change_authority=} NIL, {manage_authority=} NIL, ^delete_authority,
                file_information, status);
          IF NOT status.normal THEN
            RETURN;
          IFEND;
        ELSE
          IF (status.condition <> ave$incorrect_kind) AND (status.condition <> ave$unknown_field) AND
                (status.condition <> ave$field_was_deleted) THEN
            RETURN;
          IFEND;

{ If it is not the correct type or has been deleted then the name of the field is changed so that the new
{ field can be created.

          IF (status.condition = ave$incorrect_kind) OR (status.condition = ave$field_was_deleted) THEN
            status.normal := TRUE;
            change_field_name (field_name, record_name, new_field_name, file_information, status);
            IF NOT status.normal THEN
              RETURN;
            IFEND;
          IFEND;

{ Make sure that no command table collisions can occur.

          prevalidate_command_table (record_name, change_commands, display_commands, file_information,
                status);
          IF NOT status.normal THEN
            RETURN;
          IFEND;

{ Create the new field.

          avp$create_name_field (field_name, record_name, names, minimum_number_of_names,
                maximum_number_of_names, common_names, change_commands, display_commands, description_string,
                display_authority, change_authority, manage_authority, delete_authority, file_information,
                status);
        IFEND;

      PROCEND add_name_field;
?? OLDTITLE ??
?? NEWTITLE := 'add_141_fields', EJECT ??

{ PURPOSE:
{   This procedure adds the 1.4.1 validation fields to this family's validation file.

      PROCEDURE add_141_fields
        (    family_name: ost$family_name;
             validation_file_version: ost$name;
         VAR file_information: avt$template_file_information;
         VAR status: ost$status);

        status.normal := TRUE;

{ Add the temporary file space limit field.

        add_accum_limit_field (avc$temporary_file_space_limit, avc$user_record_name, avc$maximum_tfs_default,
              avc$maximum_tfs_default, avc$maximum_tfs_default, avc$tfs_limit_name_default,
              avc$tfs_job_limits_apply_def, NIL, avc$minimum_tfs_default, avc$maximum_tfs_default,
              avc$tfs_total_limit_applies_def, avc$tfs_tot_lim_stops_login_def, avc$temp_file_space_chg_cmd,
              avc$temp_file_space_dis_cmd, avc$temp_file_space_limit_descr, avc$user_authority,
              avc$family_admin_authority, avc$family_admin_authority, avc$system_authority, file_information,
              status);
        IF NOT status.normal THEN
          RETURN;
        IFEND;

{ Add the configuration administration field.

        add_capability_field (avc$configuration_admin, avc$user_record_name, avc$configuration_admin_default,
              avc$configuration_admin_descr, avc$user_authority, avc$system_admin_authority,
              avc$system_admin_authority, avc$system_authority, file_information, status);
        IF NOT status.normal THEN
          RETURN;
        IFEND;

{ Add the removable media operation field.

        add_capability_field (avc$removable_media_operation, avc$user_record_name,
              avc$removable_media_oper_def, avc$removable_media_oper_descr, avc$user_authority,
              avc$system_admin_authority, avc$system_admin_authority, avc$system_authority, file_information,
              status);
        IF NOT status.normal THEN
          RETURN;
        IFEND;

{ Add the system operation field.

        add_capability_field (avc$system_operation, avc$user_record_name, avc$system_operation_default,
              avc$system_operation_descr, avc$user_authority, avc$system_admin_authority,
              avc$system_admin_authority, avc$system_authority, file_information, status);
        IF NOT status.normal THEN
          RETURN;
        IFEND;

{ Add the magnetic tape limits field.

        add_accum_limit_field (avc$magnetic_tape_limit, avc$user_record_name, avc$magnetic_tape_max_default,
              avc$magnetic_tape_max_default, avc$magnetic_tape_max_default, avc$mt_limit_name_default,
              avc$mt_job_limits_apply_def, NIL, avc$magnetic_tape_min_default, avc$magnetic_tape_max_default,
              avc$mt_total_limit_applies_def, avc$mt_tot_lim_stops_login_def, avc$magnetic_tape_limit_chg_cmd,
              avc$magnetic_tape_limit_dis_cmd, avc$magnetic_tape_limit_descr, avc$user_authority,
              avc$family_admin_authority, avc$family_admin_authority, avc$system_authority, file_information,
              status);
        IF NOT status.normal THEN
          RETURN;
        IFEND;

{ Add the terminal timeout limit field.

        add_limit_field (avc$terminal_timeout_limit, avc$user_record_name, avc$terminal_timeout_limit_def,
              avc$terminal_timeout_min_def, avc$terminal_timeout_max_def, avc$terminal_timeout_chg_cmd,
              avc$terminal_timeout_dis_cmd, avc$terminal_timeout_limit_desc, avc$user_authority,
              avc$family_admin_authority, avc$family_admin_authority, avc$system_authority, file_information,
              status);
        IF NOT status.normal THEN
          RETURN;
        IFEND;

{ Add the job destination usages field.

        add_name_field (avc$job_destination_usages, avc$user_record_name, avc$job_destination_usages_def,
              avc$jdu_min_number_of_names, avc$jdu_max_number_of_names, avc$job_dest_usages_names_def,
              avc$job_dest_usages_chg_cmd, avc$job_dest_usages_dis_cmd, avc$job_dest_usages_descr,
              avc$user_authority, avc$family_admin_authority, avc$family_admin_authority,
              avc$system_authority, file_information, status);
        IF NOT status.normal THEN
          RETURN;
        IFEND;

{ Add the output destination usages field.

        add_name_field (avc$output_destination_usages, avc$user_record_name, avc$output_dest_usages_def,
              avc$odu_min_number_of_names, avc$odu_max_number_of_names, avc$output_dest_usage_names_def,
              avc$output_dest_usages_chg_cmd, avc$output_dest_usages_dis_cmd, avc$output_dest_usages_descr,
              avc$user_authority, avc$family_admin_authority, avc$family_admin_authority,
              avc$system_authority, file_information, status);
        IF NOT status.normal THEN
          RETURN;
        IFEND;

      PROCEND add_141_fields;
?? OLDTITLE ??
?? NEWTITLE := 'add_142_fields', EJECT ??

{ PURPOSE:
{   This procedure adds the 1.4.2 validation fields to this family's validation file.

      PROCEDURE add_142_fields
        (    family_name: ost$family_name;
             validation_file_version: ost$name;
         VAR file_information: avt$template_file_information;
         VAR status: ost$status);

        VAR
          delete_authority: avt$validation_authority,
          terminal_timeout_min_def: integer;

        status.normal := TRUE;
        delete_authority := avc$system_authority;
        terminal_timeout_min_def := avc$terminal_timeout_min_def;

{ Ensure the delete authority is system for these fields added at 1.4.1.  It may be wrong because of a 1.4.1
{ bug.

        avp$change_accum_limit_field (avc$temporary_file_space_limit, avc$user_record_name, NIL, NIL, NIL,
              NIL, NIL, NIL, NIL, NIL, NIL, NIL, NIL, NIL, NIL, NIL, NIL, NIL, ^delete_authority,
              file_information, {ignored} status);
        avp$change_capability_field (avc$configuration_admin, avc$user_record_name, NIL, NIL, NIL, NIL, NIL,
              ^delete_authority, file_information, {ignored} status);
        avp$change_capability_field (avc$removable_media_operation, avc$user_record_name, NIL, NIL, NIL, NIL,
              NIL, ^delete_authority, file_information, {ignored} status);
        avp$change_accum_limit_field (avc$magnetic_tape_limit, avc$user_record_name, NIL, NIL, NIL, NIL, NIL,
              NIL, NIL, NIL, NIL, NIL, NIL, NIL, NIL, NIL, NIL, NIL, ^delete_authority, file_information,
              {ignored} status);
        avp$change_name_field (avc$job_destination_usages, avc$user_record_name, NIL, NIL, NIL, NIL, NIL, NIL,
              NIL, NIL, NIL, NIL, NIL, NIL, ^delete_authority, file_information, {ignored} status);
        avp$change_name_field (avc$output_destination_usages, avc$user_record_name, NIL, NIL, NIL, NIL, NIL,
              NIL, NIL, NIL, NIL, NIL, NIL, NIL, ^delete_authority, file_information, {ignored} status);
        status.normal := TRUE;

{ Change the terminal timeout limit field.  The terminal timeout limit field should already be defined but
{ this call will change the minimum value from 5 minutes to 1 minute.

        avp$change_limit_field (avc$terminal_timeout_limit, avc$user_record_name, NIL,
              ^terminal_timeout_min_def, NIL, NIL, NIL, NIL, NIL, NIL, NIL, ^delete_authority,
              file_information, {ignored} status);
        status.normal := TRUE;

{ Add the permit level field.

        add_name_field (avc$permit_level, avc$user_record_name, avc$permit_level_names_def,
              avc$pl_min_number_of_names, avc$pl_max_number_of_names, avc$permit_level_com_names_def,
              avc$permit_level_chg_cmd, avc$permit_level_dis_cmd, avc$permit_level_description,
              avc$user_authority, avc$family_admin_authority, avc$family_admin_authority,
              avc$system_authority, file_information, status);
        IF NOT status.normal THEN
          RETURN;
        IFEND;

      PROCEND add_142_fields;
?? OLDTITLE ??
?? NEWTITLE := 'add_151_fields', EJECT ??

{ PURPOSE:
{   This procedure adds the 1.5.1 validation fields to this family's validation file.

      PROCEDURE add_151_fields
        (    family_name: ost$family_name;
             validation_file_version: ost$name;
         VAR file_information: avt$template_file_information;
         VAR status: ost$status);

        VAR
          total_limit_stops_login: boolean;

        status.normal := TRUE;

{ Add the engineering operation field.

        add_capability_field (avc$engineering_operation, avc$user_record_name,
              avc$engineering_operation_def, avc$engineering_operation_descr, avc$user_authority,
              avc$system_admin_authority, avc$system_admin_authority, avc$system_authority, file_information,
              status);
        IF NOT status.normal THEN
          RETURN;
        IFEND;

{ Add the removable media administration field.

        add_capability_field (avc$removable_media_admin, avc$user_record_name,
              avc$removable_media_admin_def, avc$removable_media_admin_descr, avc$user_authority,
              avc$system_admin_authority, avc$system_admin_authority, avc$system_authority, file_information,
              status);
        IF NOT status.normal THEN
          RETURN;
        IFEND;

{ Add the removable media access field.

        add_labeled_names_field (avc$removable_media_access, avc$user_record_name,
              avc$removable_media_access_def, avc$rma_valid_groups_default, avc$rma_valid_access_modes_def,
              avc$rma_change_commands, avc$rma_display_commands,
              avc$removable_media_access_desc, avc$user_authority, avc$family_admin_authority,
              avc$family_admin_authority, avc$system_authority, file_information, status);
        IF NOT status.normal THEN
          RETURN;
        IFEND;

{ Change the permanent file space limit field.  The permanent file space limit field should already be defined
{ but this call will change the limit to default to not preventing login if the limit has been exceeded.

        total_limit_stops_login := FALSE;
        avp$change_accum_limit_field (avc$permanent_file_space_limit, avc$user_record_name, NIL, NIL, NIL,
              NIL, NIL, NIL, NIL, NIL, NIL, ^total_limit_stops_login, NIL, NIL, NIL, NIL, NIL, NIL, NIL,
              file_information, {ignored} status);
        status.normal := TRUE;

      PROCEND add_151_fields;
?? OLDTITLE ??
?? NEWTITLE := 'change_field_name', EJECT ??

{ PURPOSE:
{   This procedure changes the name of an existing site defined field to a resonable new name, or if unable to
{   do that to a unique name.

      PROCEDURE change_field_name
        (    field_name: ost$name;
             record_name: ost$name;
         VAR new_field_name: ost$name;
         VAR file_information: avt$template_file_information;
         VAR status: ost$status);

        status.normal := TRUE;

{ Build a new name from the old one and a prefix.

        new_field_name := field_name;
        new_field_name (prefix_length + 1, (osc$max_name_size - prefix_length)) :=
              new_field_name (1, (osc$max_name_size - prefix_length));
        new_field_name (1, prefix_length) := prefix;

{ Try to change the name to this new name.

        avp$change_val_field_name (field_name, record_name, new_field_name, NIL, NIL, file_information,
              status);
        IF NOT status.normal THEN
          IF status.condition = ave$field_already_exists THEN
            status.normal := TRUE;

{ If a field by that name already exists change the name to a unique name.

            pmp$get_unique_name (new_field_name, status);
            avp$change_val_field_name (field_name, record_name, new_field_name, NIL, NIL, file_information,
                  status);
          IFEND;
        IFEND;
      PROCEND change_field_name;
?? OLDTITLE ??
?? NEWTITLE := 'convert_user_fields_to_141', EJECT ??

{ PURPOSE:
{   This procedure reads each user record and converts any old validation information for the user into the
{   new validation information.

      PROCEDURE convert_user_fields_to_141
        (VAR file_information: avt$template_file_information;
         VAR status: ost$status);

        VAR
          command_table_size: integer,
          record_id: ost$name,
          user_name: ost$user_name;

        VAR
          capability: boolean;

        status.normal := TRUE;

{ Set up the validation file information so that the next record to be read sequentially from the file will be
{ the first user record.

        file_information.last_key_accessed (1, 31) := avc$high_value_name {account_name} ;
        file_information.last_key_accessed (32, 31) := avc$high_value_name {project_name} ;
        file_information.last_key_accessed (63, 31) := osc$null_name {user_name} ;

{ Read the first user record.

        user_name := osc$null_name;
        avp$change_user_record (user_name, record_id, command_table_size, file_information, status);

{ As long as there are user records, keep converting them.

        WHILE status.normal DO

{ Change the :$SYSTEM.$SYSTEM user.

          IF (family_name = jmc$system_family) AND (user_name = jmc$system_user) THEN

{ Add Remote operator capabilities.

            capability := TRUE;
            avp$change_capability_value (avc$configuration_admin, ^capability, record_id, file_information,
                  ignore_status);
            avp$change_capability_value (avc$removable_media_operation, ^capability, record_id,
                  file_information, ignore_status);
            avp$change_capability_value (avc$system_operation, ^capability, record_id, file_information,
                  ignore_status);

          IFEND;

{ Release the space used to hold the user record.

          avp$end_subutility_session (record_id, TRUE, file_information, status);
          IF status.normal THEN
            record_id := osc$null_name;
          ELSE
            RETURN;
          IFEND;

{ Read the next user record.

          user_name := osc$null_name;
          avp$change_user_record (user_name, record_id, command_table_size, file_information, status);
        WHILEND;
        IF status.condition = ave$end_of_template_file THEN
          status.normal := TRUE;
        IFEND;

      PROCEND convert_user_fields_to_141;
?? OLDTITLE ??
?? NEWTITLE := 'convert_user_fields_to_151', EJECT ??

{ PURPOSE:
{   This procedure reads each user record and converts any old validation information for the user into the
{   new validation information.

      PROCEDURE convert_user_fields_to_151
        (VAR file_information: avt$template_file_information;
         VAR status: ost$status);

        VAR
          add_labeled_names: ^avt$labeled_names_list,
          capability: boolean,
          command_table_size: integer,
          engineer: boolean,
          index: avt$field_count,
          name_field_count: avt$field_count,
          name_field_names: array [1 .. avc$maximum_field_count] of ost$name,
          record_id: ost$name,
          user_name: ost$user_name;

        status.normal := TRUE;

{ This call will cause the default job class list to be sorted.

        avp$change_job_class_field (avc$job_class, avc$user_record_name,
              NIL, NIL, NIL, NIL, NIL, NIL, NIL, NIL, NIL, NIL, NIL, NIL, NIL,
              file_information, {ignore} status);
        status.normal := TRUE;

{ This call will cause the default login password attributes list to be sorted.

        avp$change_login_password_field (avc$login_password, avc$user_record_name,
              NIL, NIL, NIL, NIL, NIL, NIL, NIL, NIL, NIL, NIL, NIL, NIL, NIL, NIL, NIL,
              file_information, {ignore} status);
        status.normal := TRUE;

{ This loop will cause all list of name type fields default values to be sorted.

        avp$get_validation_field_names (avc$user_record_name, $avt$field_kind_set [avc$name_kind],
                FALSE, name_field_names, name_field_count, file_information, {ignore} status);
        status.normal := TRUE;

        FOR index := 1 TO name_field_count DO
          avp$change_name_field (name_field_names [index], avc$user_record_name, NIL, NIL, NIL, NIL, NIL, NIL,
                NIL, NIL, NIL, NIL, NIL, NIL, NIL, file_information, {ignore} status);
          status.normal := TRUE;
        FOREND;

{ Set up the validation file information so that the next record to be read sequentially from the file will be
{ the first user record.

        file_information.last_key_accessed (1, 31) := avc$high_value_name {account_name} ;
        file_information.last_key_accessed (32, 31) := avc$high_value_name {project_name} ;
        file_information.last_key_accessed (63, 31) := osc$null_name {user_name} ;

{ Read the first user record.

        user_name := osc$null_name;
        avp$change_user_record (user_name, record_id, command_table_size, file_information, status);

{ As long as there are user records, keep converting them.

        WHILE status.normal DO

{ Change the :$SYSTEM.$SYSTEM user.

          IF (family_name = jmc$system_family) AND (user_name = jmc$system_user) THEN

{ Add removable media administation capability.

            capability := TRUE;
            avp$change_capability_value (avc$removable_media_admin, ^capability, record_id,
                  file_information, {ignore} status);
            status.normal := TRUE;

{ Add access to ALL removable media.

            PUSH add_labeled_names: [1 .. 1];
            add_labeled_names^ := avc$$sys_$sys_rma_default;
            avp$change_labeled_names_value (avc$removable_media_access, add_labeled_names,
                  {delete_labeled_names=} NIL, record_id, file_information, {ignore} status);
            status.normal := TRUE;

          IFEND;

{ Assign each user that currently has engineering administration the new engineering operation capability.

          engineer := FALSE;
          avp$get_capabil_display_value (avc$engineering_administration, record_id, engineer,
                {ignore} status);
          status.normal := TRUE;
          avp$change_capability_value (avc$engineering_operation, ^engineer, record_id,
                file_information, {ignore} status);
          status.normal := TRUE;

{ This call will cause the user's job class list to be sorted.

          avp$change_job_class_value (avc$job_class, NIL, NIL, NIL, NIL, record_id, file_information,
                {ignore} status);
          status.normal := TRUE;

{ This call will cause the user's login password attributes list to be sorted.

          avp$change_login_password_value (avc$login_password, NIL, NIL,  NIL, NIL, NIL, NIL, NIL, NIL, NIL,
                record_id, { update_batch_job_passwords = } FALSE, file_information, {ignore} status);
          status.normal := TRUE;

{ This loop will cause all of the user's list of name type field values to be sorted.

          FOR index := 1 TO name_field_count DO
            avp$change_name_value (name_field_names [index], NIL, NIL, record_id, file_information,
                  {ignore} status);
          FOREND;
          status.normal := TRUE;

{ Release the space used to hold the user record.

          avp$end_subutility_session (record_id, TRUE, file_information, status);
          IF status.normal THEN
            record_id := osc$null_name;
          ELSE
            RETURN;
          IFEND;

{ Read the next user record.

          user_name := osc$null_name;
          avp$change_user_record (user_name, record_id, command_table_size, file_information, status);
        WHILEND;
        IF status.condition = ave$end_of_template_file THEN
          status.normal := TRUE;
        IFEND;

      PROCEND convert_user_fields_to_151;
?? OLDTITLE ??
?? NEWTITLE := 'convert_account_fields_to_151', EJECT ??

{ PURPOSE:
{   This procedure reads each account record and converts any old validation information for the account into
{   the new validation information.

      PROCEDURE convert_account_fields_to_151
        (VAR file_information: avt$template_file_information;
         VAR status: ost$status);

        VAR
          command_table_size: integer,
          index: avt$field_count,
          name_field_count: avt$field_count,
          name_field_names: array [1 .. avc$maximum_field_count] of ost$name,
          record_id: ost$name,
          account_name: avt$account_name;

        status.normal := TRUE;

{ This loop will cause all list of name type fields default values to be sorted.

        avp$get_validation_field_names (avc$account_record_name, $avt$field_kind_set [avc$name_kind],
                FALSE, name_field_names, name_field_count, file_information, {ignore} status);
        status.normal := TRUE;

        IF name_field_count = 0 THEN
          RETURN;
        IFEND;

        FOR index := 1 TO name_field_count DO
          avp$change_name_field (name_field_names [index], avc$account_record_name, NIL, NIL, NIL, NIL, NIL,
                NIL, NIL, NIL, NIL, NIL, NIL, NIL, NIL, file_information, {ignore} status);
          status.normal := TRUE;
        FOREND;

{ Set up the validation file information so that the next record to be read sequentially from the file will be
{ the first account record.

        file_information.last_key_accessed (1, 31) := osc$null_name {account_name} ;
        file_information.last_key_accessed (32, 31) := osc$null_name {project_name} ;
        file_information.last_key_accessed (63, 31) := osc$null_name {user_name} ;

{ Read the first account record.

        account_name := osc$null_name;
        avp$change_account_record (account_name, record_id, command_table_size, file_information, status);

{ As long as there are account records, keep converting them.

        WHILE status.normal DO

{ This loop will cause all of the account's list of name type field values to be sorted.

          FOR index := 1 TO name_field_count DO
            avp$change_name_value (name_field_names [index], NIL, NIL, record_id, file_information,
                  {ignore} status);
          FOREND;
          status.normal := TRUE;

{ Release the space used to hold the account record.

          avp$end_subutility_session (record_id, TRUE, file_information, status);
          IF status.normal THEN
            record_id := osc$null_name;
          ELSE
            RETURN;
          IFEND;

{ Read the next account record.

          account_name := osc$null_name;
          avp$change_account_record (account_name, record_id, command_table_size, file_information, status);
        WHILEND;
        IF status.condition = ave$end_of_template_file THEN
          status.normal := TRUE;
        IFEND;

      PROCEND convert_account_fields_to_151;
?? OLDTITLE ??
?? NEWTITLE := 'convert_project_fields_to_151', EJECT ??

{ PURPOSE:
{   This procedure reads each project record and converts any old validation information for the project into
{   the new validation information.

      PROCEDURE convert_project_fields_to_151
        (VAR file_information: avt$template_file_information;
         VAR status: ost$status);

        VAR
          account_name: avt$account_name,
          command_table_size: integer,
          index: avt$field_count,
          name_field_count: avt$field_count,
          name_field_names: array [1 .. avc$maximum_field_count] of ost$name,
          project_name: avt$project_name,
          record_id: ost$name;

        status.normal := TRUE;

{ This loop will cause all list of name type fields default values to be sorted.

        avp$get_validation_field_names (avc$project_record_name, $avt$field_kind_set [avc$name_kind],
                FALSE, name_field_names, name_field_count, file_information, {ignore} status);
        status.normal := TRUE;

        IF name_field_count = 0 THEN
          RETURN;
        IFEND;

        FOR index := 1 TO name_field_count DO
          avp$change_name_field (name_field_names [index], avc$project_record_name, NIL, NIL, NIL, NIL, NIL,
                NIL, NIL, NIL, NIL, NIL, NIL, NIL, NIL, file_information, {ignore} status);
          status.normal := TRUE;
        FOREND;

{ Set up the validation file information so that the next record to be read sequentially from the file will be
{ the first project record.

        file_information.last_key_accessed (1, 31) := osc$null_name {account_name} ;
        file_information.last_key_accessed (32, 31) := osc$null_name {project_name} ;
        file_information.last_key_accessed (63, 31) := osc$null_name {user_name} ;

{ Read the first project record.

        account_name := osc$null_name;
        project_name := osc$null_name;
        avp$change_project_record (account_name, project_name, record_id, command_table_size,
              file_information, status);

{ As long as there are project records, keep converting them.

        WHILE status.normal DO

{ This loop will cause all of the project's list of name type field values to be sorted.

          FOR index := 1 TO name_field_count DO
            avp$change_name_value (name_field_names [index], NIL, NIL, record_id, file_information,
                  {ignore} status);
          FOREND;
          status.normal := TRUE;

{ Release the space used to hold the project record.

          avp$end_subutility_session (record_id, TRUE, file_information, status);
          IF status.normal THEN
            record_id := osc$null_name;
          ELSE
            RETURN;
          IFEND;

{ Read the next project record.

          account_name := osc$null_name;
          project_name := osc$null_name;
          avp$change_project_record (account_name, project_name, record_id, command_table_size,
                file_information, status);
        WHILEND;
        IF status.condition = ave$end_of_template_file THEN
          status.normal := TRUE;
        IFEND;

      PROCEND convert_project_fields_to_151;
?? OLDTITLE ??
?? NEWTITLE := 'convert_acct_mem_fields_to_151', EJECT ??

{ PURPOSE:
{   This procedure reads each account_member record and converts any old validation information for the
{   account_member into the new validation information.

      PROCEDURE convert_acct_mem_fields_to_151
        (VAR file_information: avt$template_file_information;
         VAR status: ost$status);

        VAR
          account_name: avt$account_name,
          command_table_size: integer,
          index: avt$field_count,
          name_field_count: avt$field_count,
          name_field_names: array [1 .. avc$maximum_field_count] of ost$name,
          project_name: avt$project_name,
          record_id: ost$name,
          user_name: ost$user_name;

        status.normal := TRUE;

{ This loop will cause all list of name type fields default values to be sorted.

        avp$get_validation_field_names (avc$account_member_record_name, $avt$field_kind_set [avc$name_kind],
                FALSE, name_field_names, name_field_count, file_information, {ignore} status);
        status.normal := TRUE;

        IF name_field_count = 0 THEN
          RETURN;
        IFEND;

        FOR index := 1 TO name_field_count DO
          avp$change_name_field (name_field_names [index], avc$account_member_record_name, NIL, NIL, NIL, NIL,
                NIL, NIL, NIL, NIL, NIL, NIL, NIL, NIL, NIL, file_information, {ignore} status);
          status.normal := TRUE;
        FOREND;

{ Set up the validation file information so that the next record to be read sequentially from the file will be
{ the first account_member record.

        file_information.last_key_accessed (1, 31) := osc$null_name {account_member_name} ;
        file_information.last_key_accessed (32, 31) := osc$null_name {project_name} ;
        file_information.last_key_accessed (63, 31) := osc$null_name {user_member_name} ;

{ Read the first account_member record.

        account_name := osc$null_name;
        user_name := osc$null_name;
        avp$change_account_member_rec (account_name, user_name, record_id, command_table_size,
              file_information, status);

{ As long as there are account_member records, keep converting them.

        WHILE status.normal DO

{ This loop will cause all of the account_member's list of name type field values to be sorted.

          FOR index := 1 TO name_field_count DO
            avp$change_name_value (name_field_names [index], NIL, NIL, record_id, file_information,
                  {ignore} status);
          FOREND;
          status.normal := TRUE;

{ Release the space used to hold the account_member record.

          avp$end_subutility_session (record_id, TRUE, file_information, status);
          IF status.normal THEN
            record_id := osc$null_name;
          ELSE
            RETURN;
          IFEND;

{ Read the next account_member record.

          account_name := osc$null_name;
          user_name := osc$null_name;
          avp$change_account_member_rec (account_name, user_name, record_id, command_table_size,
                file_information, status);
        WHILEND;
        IF status.condition = ave$end_of_template_file THEN
          status.normal := TRUE;
        IFEND;

      PROCEND convert_acct_mem_fields_to_151;
?? OLDTITLE ??
?? NEWTITLE := 'convert_proj_mem_fields_to_151', EJECT ??

{ PURPOSE:
{   This procedure reads each project_member record and converts any old validation information for the
{   project_member into the new validation information.

      PROCEDURE convert_proj_mem_fields_to_151
        (VAR file_information: avt$template_file_information;
         VAR status: ost$status);

        VAR
          account_name: avt$account_name,
          command_table_size: integer,
          index: avt$field_count,
          name_field_count: avt$field_count,
          name_field_names: array [1 .. avc$maximum_field_count] of ost$name,
          project_name: avt$project_name,
          record_id: ost$name,
          user_name: ost$user_name;

        status.normal := TRUE;

{ This loop will cause all list of name type fields default values to be sorted.

        avp$get_validation_field_names (avc$project_member_record_name, $avt$field_kind_set [avc$name_kind],
                FALSE, name_field_names, name_field_count, file_information, {ignore} status);
        status.normal := TRUE;

        IF name_field_count = 0 THEN
          RETURN;
        IFEND;

        FOR index := 1 TO name_field_count DO
          avp$change_name_field (name_field_names [index], avc$project_member_record_name, NIL, NIL, NIL, NIL,
                NIL, NIL, NIL, NIL, NIL, NIL, NIL, NIL, NIL, file_information, {ignore} status);
          status.normal := TRUE;
        FOREND;

{ Set up the validation file information so that the next record to be read sequentially from the file will be
{ the first project_member record.

        file_information.last_key_accessed (1, 31) := osc$null_name {account_member_name} ;
        file_information.last_key_accessed (32, 31) := osc$null_name {project_name} ;
        file_information.last_key_accessed (63, 31) := osc$null_name {user_member_name} ;

{ Read the first project_member record.

        account_name := osc$null_name;
        project_name := osc$null_name;
        user_name := osc$null_name;
        avp$change_project_member_rec (account_name, project_name, user_name, record_id,
              command_table_size, file_information, status);

{ As long as there are project_member records, keep converting them.

        WHILE status.normal DO

{ This loop will cause all of the project_member's list of name type field values to be sorted.

          FOR index := 1 TO name_field_count DO
            avp$change_name_value (name_field_names [index], NIL, NIL, record_id, file_information,
                  {ignore} status);
          FOREND;
          status.normal := TRUE;

{ Release the space used to hold the project_member record.

          avp$end_subutility_session (record_id, TRUE, file_information, status);
          IF status.normal THEN
            record_id := osc$null_name;
          ELSE
            RETURN;
          IFEND;

{ Read the next project_member record.

          account_name := osc$null_name;
          project_name := osc$null_name;
          user_name := osc$null_name;
          avp$change_project_member_rec (account_name, project_name, user_name, record_id,
                command_table_size, file_information, status);
        WHILEND;
        IF status.condition = ave$end_of_template_file THEN
          status.normal := TRUE;
        IFEND;

      PROCEND convert_proj_mem_fields_to_151;
?? OLDTITLE ??
?? NEWTITLE := 'delete_151_fields', EJECT ??

{ PURPOSE:
{   This procedure deletes the validation fields from this family's validation file,
{   which are removed from the 1.5.1 system.

      PROCEDURE delete_151_fields
        (VAR file_information: avt$template_file_information);

        VAR
          ignore_status: ost$status,
          total_limit_stops_login: boolean;

{ Delete the engineering administration field.

        avp$delete_validation_field (avc$engineering_administration, avc$user_record_name,
              file_information, ignore_status);

{ Delete the read unlabeled tapes field.

        avp$delete_validation_field (avc$read_unlabeled_tapes, avc$user_record_name,
              file_information, ignore_status);

{ Delete the write unlabeled tapes field.

        avp$delete_validation_field (avc$write_unlabeled_tapes, avc$user_record_name,
              file_information, ignore_status);

      PROCEND delete_151_fields;
?? OLDTITLE ??
?? NEWTITLE := 'prevalidate_command_table', EJECT ??

{ PURPOSE:
{   This procedure makes sure that the command table kept in the validation file does not conflict with
{   entries for new validation fields.  If a conflict is found the site defined field's name is changed to a
{   new name.  If the name it is being changed to already exists the field is changed to a unique name as a
{   fail safe mechanism.

      PROCEDURE prevalidate_command_table
        (    record_name: ost$name;
             change_commands: avt$name_list;
             display_commands: avt$name_list;
         VAR file_information: avt$template_file_information;
         VAR status: ost$status);

        VAR
          ignore_status: ost$status,
          index: integer,
          new_command_name: ost$name,
          new_field_name: ost$name;

        status.normal := TRUE;

{ Check each change command being added to verify that it is not already in the comand table.

        FOR index := 1 TO UPPERBOUND (change_commands) DO

{ Build the new command name.

          new_command_name (prefix_length + 1, (osc$max_name_size - prefix_length)) :=
                change_commands [index] (1, (osc$max_name_size - prefix_length));
          new_command_name (1, prefix_length) := prefix;

{ Change the name of the command that conflicts if any.

          avp$change_util_info_cmd_name (change_commands [index], new_command_name, record_name,
                file_information, status);
          IF NOT status.normal THEN

{ If the new command name already exists then use a unique name.

            IF status.condition = ave$cmd_already_in_cmd_table THEN
              pmp$get_unique_name (new_command_name, status);
              avp$change_util_info_cmd_name (change_commands [index], new_command_name, record_name,
                    file_information, status);
              IF NOT status.normal THEN
                RETURN;
              IFEND;
            ELSE
              RETURN;
            IFEND;
          IFEND;
        FOREND;

{ Check each display command being added to verify that it is not already in the comand table.

        FOR index := 1 TO UPPERBOUND (display_commands) DO

{ Build the new command name.

          new_command_name (prefix_length + 1, (osc$max_name_size - prefix_length)) :=
                display_commands [index] (1, (osc$max_name_size - prefix_length));
          new_command_name (1, prefix_length) := prefix;

{ Change the name of the command that conflicts if any.

          avp$change_util_info_cmd_name (display_commands [index], new_command_name, record_name,
                file_information, status);
          IF NOT status.normal THEN

{ If the new command name already exists then use a unique name.

            IF status.condition = ave$cmd_already_in_cmd_table THEN
              pmp$get_unique_name (new_command_name, status);
              avp$change_util_info_cmd_name (change_commands [index], new_command_name, record_name,
                    file_information, status);
              IF NOT status.normal THEN
                RETURN;
              IFEND;
            ELSE
              RETURN;
            IFEND;
          IFEND;
        FOREND;
      PROCEND prevalidate_command_table;
?? OLDTITLE, EJECT ??
      status.normal := TRUE;

      prefix_length := clp$trimmed_string_size (prefix);

{ Make 1.4.1 changes if needed.

      IF validation_file_version < avc$validation_file_version_141 THEN
        add_141_fields (family_name, validation_file_version, file_information, status);
        IF NOT status.normal THEN
          RETURN;
        IFEND;

        convert_user_fields_to_141 (file_information, status);
        IF NOT status.normal THEN
          RETURN;
        IFEND;
      IFEND;

{ Make 1.4.2 changes if needed.

      IF validation_file_version < avc$validation_file_version_142 THEN
        add_142_fields (family_name, validation_file_version, file_information, status);
        IF NOT status.normal THEN
          RETURN;
        IFEND;
      IFEND;

{ Make 1.5.1 changes if needed.

      IF validation_file_version < avc$validation_file_version_151 THEN
        add_151_fields (family_name, validation_file_version, file_information, status);
        IF NOT status.normal THEN
          RETURN;
        IFEND;
        convert_user_fields_to_151 (file_information, status);
        IF NOT status.normal THEN
          RETURN;
        IFEND;
        convert_account_fields_to_151 (file_information, status);
        IF NOT status.normal THEN
          RETURN;
        IFEND;
        convert_project_fields_to_151 (file_information, status);
        IF NOT status.normal THEN
          RETURN;
        IFEND;
        convert_acct_mem_fields_to_151 (file_information, status);
        IF NOT status.normal THEN
          RETURN;
        IFEND;
        convert_proj_mem_fields_to_151 (file_information, status);
        IF NOT status.normal THEN
          RETURN;
        IFEND;
        delete_151_fields (file_information);
      IFEND;

    PROCEND convert_validation_file;
?? OLDTITLE, EJECT ??
    status.normal := TRUE;


{ Open the validation file.

    avp$open_system_validation_file (family_name, file_information, status);
    IF NOT status.normal THEN
      osp$set_status_abnormal ('AV', ave$open_val_file_error, family_name, message_status);
      osp$generate_output_message (message_status, ignore_status);
    ELSE

    /initialize_family/
      BEGIN

{ Verify that the heap is intact.

        avp$verify_template_heap (family_name, file_information, status);
        IF NOT status.normal THEN
          osp$generate_output_message (status, ignore_status);
          EXIT /initialize_family/;
        IFEND;

{ Verify that the $SYSTEM user is defined.

        avp$verify_user_exists (jmc$system_user, system_user_exists, file_information, status);
        IF NOT status.normal THEN
          osp$set_status_abnormal ('AV', ave$access_user_rec_error, family_name, message_status);
          osp$generate_output_message (message_status, ignore_status);
          EXIT /initialize_family/;
        IFEND;

{ Get the validation file version number

        PUSH utility_information: [[REP 1 OF avt$file_utility_information]];
        RESET utility_information;
        avp$get_file_utility_info (utility_information, file_information, status);
        RESET utility_information;
        NEXT file_utility_information IN utility_information;
        IF file_utility_information = NIL THEN
          corrupted_sequence ('AVP$INITIALIZE_FAMILY', 'VERSION', 'FILE_UTILITY_INFORMATION', status);
          EXIT /initialize_family/;
        IFEND;

{ If the version is not equal to the current version then convert the validation file.

        IF file_utility_information^.version <> avc$validation_file_version THEN
          convert_validation_file (family_name, file_utility_information^.version, file_information, status);
          IF NOT status.normal THEN
            osp$set_status_abnormal ('AV', ave$cannot_convert_val_file, family_name, message_status);
            osp$generate_output_message (message_status, ignore_status);
            EXIT /initialize_family/;
          ELSE
            file_utility_information^.version := avc$validation_file_version;
            avp$change_file_utility_info (#SEQ (file_utility_information^), file_information, status);
            IF NOT status.normal THEN
              osp$set_status_abnormal ('AV', ave$cannot_update_val_version, family_name, message_status);
              osp$generate_output_message (message_status, ignore_status);
              EXIT /initialize_family/;
            IFEND;
          IFEND;
        IFEND;

{ If the $SYSTEM user is not defined, create one.

        IF NOT system_user_exists THEN
          avp$create_$system_user (family_name, file_information, status);
          IF NOT status.normal THEN
            osp$set_status_abnormal ('AV', ave$cannot_create_system_user, family_name, message_status);
            osp$generate_output_message (message_status, ignore_status);
          IFEND;
        IFEND;

      END /initialize_family/;

      avp$close_validation_file (file_information, ignore_status);

    IFEND;

{ If an error occured for the $SYSTEM family's validation file then recreate the validation file.

    IF NOT status.normal THEN
      IF family_name = jmc$system_family THEN
        status.normal := TRUE;
        osp$set_status_abnormal ('AV', ave$recreating_system_family, family_name, message_status);
        osp$generate_output_message (message_status, ignore_status);
        osp$press_return_to_continue (ignore_status);

        PUSH new_path: [1 .. 3];
        new_path^ [1] := jmc$system_family;
        new_path^ [2] := jmc$system_user;
        new_path^ [3] := avc$validation_file_name;
        cycle_selector.cycle_option := pfc$highest_cycle;
        pfp$purge (new_path^, cycle_selector, osc$null_name, ignore_status);

        PUSH new_path: [1 .. 4];
        new_path^ [1] := jmc$system_family;
        new_path^ [2] := jmc$system_user;
        new_path^ [3] := avc$validation_file_name;
        new_path^ [4] := '$NEXT';
        fsp$build_file_ref_from_elems (new_path, validation_file_path, status);
        IF NOT status.normal THEN
          RETURN;
        IFEND;
        avp$open_validation_file (validation_file_path, NIL, NIL, TRUE, file_information, status);
        IF NOT status.normal THEN
          RETURN;
        IFEND;
        avp$create_$system_user (jmc$system_family, file_information, status);
        IF NOT status.normal THEN
          RETURN;
        IFEND;
        avp$close_validation_file (file_information, ignore_status);
        amp$return (validation_file_path, ignore_status);
      IFEND;
    IFEND;

  PROCEND avp$initialize_family;
?? OLDTITLE ??
?? NEWTITLE := '[XDCL] avp$create_$system_user', EJECT ??

{ PURPOSE:
{   This procedure adds the $SYSTEM user name into the validation file for a family.

  PROCEDURE [XDCL] avp$create_$system_user
    (    family_name: ost$family_name;
     VAR file_information: avt$template_file_information;
     VAR status: ost$status);

    VAR
      add_job_classes: array [1 .. 1] of ost$name,
      add_labeled_names: array [1 .. 1] of avt$labeled_names,
      add_names: array [1 .. 1] of ost$name,
      batch_job_class_default: ost$name,
      capability_field_count: avt$field_count,
      capability_field_names: array [1 .. avc$maximum_field_count] of ost$name,
      capability: boolean,
      command_table_size: integer,
      delete_job_classes: array [1 .. 1] of ost$name,
      index: integer,
      interactive_job_class_default: ost$name,
      login_password: avt$login_password,
      minimum_ring: ost$ring,
      nominal_ring: ost$ring,
      record_id: ost$name,
      user_epilog: ^fst$file_reference,
      user_prolog: ^fst$file_reference;

    status.normal := TRUE;

{ Create the $SYSTEM user.

    avp$create_user_record (jmc$system_user, record_id, command_table_size, file_information, status);
    IF NOT status.normal THEN
      IF status.condition = ave$master_catalog_exists THEN
        status.normal := TRUE;
      ELSE
        RETURN;
      IFEND;
    IFEND;

{ Assign a unique password.

    login_password.encrypted := FALSE;
    pmp$get_unique_name (login_password.value, status);
    IF NOT status.normal THEN
      RETURN;
    IFEND;

    avp$change_login_password_value (avc$login_password, NIL, ^login_password, NIL, NIL, NIL, NIL, NIL, NIL,
          NIL, record_id, { update_batch_job_passwords = } FALSE, file_information, status);
    login_password.value := osc$null_name;
    IF NOT status.normal THEN
      RETURN;
    IFEND;

{ Assign special values if it is for family $SYSTEM.

    IF family_name = jmc$system_family THEN
      add_names := avc$$sys_$sys_mailve_admin_def;
      avp$change_name_value (avc$mailve_administration, ^add_names, {delete_names} NIL, record_id,
            file_information, status);
      IF NOT status.normal THEN
        RETURN;
      IFEND;

      minimum_ring := avc$$sys_$sys_minimum_ring_def;
      nominal_ring := avc$$sys_$sys_nominal_ring_def;
      avp$change_ring_privilege_value (avc$ring_privileges, ^minimum_ring, ^nominal_ring, record_id,
            file_information, status);
      IF NOT status.normal THEN
        RETURN;
      IFEND;

      add_labeled_names := avc$$sys_$sys_rma_default;
      avp$change_labeled_names_value (avc$removable_media_access, ^add_labeled_names,
            {delete_labeled_names=} NIL, record_id, file_information, status);
      IF NOT status.normal THEN
        RETURN;
      IFEND;

      add_job_classes [1] := avc$$sys_$sys_job_class_def;
      delete_job_classes [1] := 'ALL';
      batch_job_class_default := avc$$sys_$sys_job_class_bat_def;
      interactive_job_class_default := avc$$sys_$sys_job_class_int_def;
      capability := avc$$sys_$sys_capability_def;
      PUSH user_prolog: [clp$trimmed_string_size (avc$$sys_$sys_prolog_default)];
      user_prolog^ := avc$$sys_$sys_prolog_default;
      PUSH user_epilog: [clp$trimmed_string_size (avc$$sys_$sys_epilog_default)];
      user_epilog^ := avc$$sys_$sys_epilog_default;
    ELSE

{ Assign values for the $SYSTEM user on any other family than $SYSTEM.

      add_job_classes [1] := avc$$sys_user_job_class_def;
      delete_job_classes [1] := 'ALL';
      batch_job_class_default := avc$$sys_user_job_class_bat_def;
      interactive_job_class_default := avc$$sys_user_job_class_int_def;
      capability := avc$$sys_user_capability_def;
      PUSH user_prolog: [clp$trimmed_string_size (avc$$sys_user_prolog_default)];
      user_prolog^ := avc$$sys_user_prolog_default;
      PUSH user_epilog: [clp$trimmed_string_size (avc$$sys_user_epilog_default)];
      user_epilog^ := avc$$sys_user_epilog_default;
    IFEND;

{ Enter job class validations.

    avp$change_job_class_value (avc$job_class, ^add_job_classes, ^delete_job_classes,
          ^batch_job_class_default, ^interactive_job_class_default, record_id, file_information, status);
    IF NOT status.normal THEN
      RETURN;
    IFEND;

{ Enter user prolog validations.

    avp$change_file_value (avc$user_prolog, user_prolog, record_id, file_information, status);
    IF NOT status.normal THEN
      RETURN;
    IFEND;

{ Enter user epilog validations.

    avp$change_file_value (avc$user_epilog, user_epilog, record_id, file_information, status);
    IF NOT status.normal THEN
      RETURN;
    IFEND;

{ Retrieve the names of all capabilities.

    avp$get_validation_field_names (avc$user_record_name, $avt$field_kind_set [avc$capability_kind], FALSE,
          capability_field_names, capability_field_count, file_information, status);
    IF NOT status.normal THEN
      RETURN;
    IFEND;

{ Enter the validations for all capabilities.

    FOR index := 1 TO capability_field_count DO
      avp$change_capability_value (capability_field_names [index], ^capability, record_id, file_information,
            status);
      IF NOT status.normal THEN
        RETURN;
      IFEND;
    FOREND;

    avp$end_subutility_session (record_id, TRUE, file_information, status);
    IF NOT status.normal THEN
      RETURN;
    IFEND;

  PROCEND avp$create_$system_user;
?? OLDTITLE ??
?? NEWTITLE := 'corrupted_sequence', EJECT ??

{ PURPOSE:
{   This procedure builds an abnormal status variable used to report a problem when accessing a sequence
{   within the validation file.

  PROCEDURE corrupted_sequence
    (    procedure_name: string ( * );
         variable_name: string ( * );
         sequence_name: string ( * );
     VAR status: ost$status);

    osp$set_status_abnormal ('AV', ave$corrupted_sequence, procedure_name, status);
    osp$append_status_parameter (osc$status_parameter_delimiter, variable_name, status);
    osp$append_status_parameter (osc$status_parameter_delimiter, sequence_name, status);

  PROCEND corrupted_sequence;
?? OLDTITLE ??
MODEND avm$initialize;
