
?? RIGHT := 110 ??
?? NEWTITLE := 'NOS/VE Permanent Files: Test Routines', ??
MODULE pfm$permanent_file_tests;

{
{ PURPOSE:
{   This module contains the processors for permanent file tests.
{

?? NEWTITLE := 'Global Declarations', EJECT ??
?? PUSH (LISTEXT := ON) ??
*copyc fsc$local
*copyc cle$all_must_be_used_alone
*copyc cle$ecc_file_reference
*copyc cle$ecc_parsing
*copyc cle$incompatible_params_given
*copyc cle$none_must_be_used_alone
*copyc cle$redundancy_in_selections
*copyc ost$status
?? POP ??
*copyc amp$get_segment_pointer
*copyc amp$set_segment_eoi
*copyc clp$evaluate_parameters
*copyc fsp$change_cycle_damage
*copyc fsp$close_file
*copyc fsp$open_file
*copyc pfp$get_object_information
*copyc osp$set_status_abnormal

  PROCEDURE [XDCL] pfp$get_object_info_cmd
    (    parameter_list: clt$parameter_list;
     VAR status: ost$status);


{ PROCEDURE get_object_information, getoi (
{   file, f, catalog, c: file = $required
{   information_request, ir: (BY_NAME) list of key
{       all
{     keyend = all
{   output, o: file = $required
{   status)

?? PUSH (LISTEXT := ON) ??
?? FMT (FORMAT := OFF) ??

  VAR
    pdt: [STATIC, READ, cls$declaration_section] record
      header: clt$pdt_header,
      names: array [1 .. 9] of clt$pdt_parameter_name,
      parameters: array [1 .. 4] of clt$pdt_parameter,
      type1: record
        header: clt$type_specification_header,
      recend,
      type2: record
        header: clt$type_specification_header,
        qualifier: clt$list_type_qualifier,
        element_type_spec: record
          header: clt$type_specification_header,
          qualifier: clt$keyword_type_qualifier,
          keyword_specs: array [1 .. 1] of clt$keyword_specification,
        recend,
        default_value: string (3),
      recend,
      type3: record
        header: clt$type_specification_header,
      recend,
      type4: record
        header: clt$type_specification_header,
      recend,
    recend := [
    [1,
    [89, 2, 8, 11, 16, 8, 215],
    clc$command, 9, 4, 2, 0, 0, 0, 4, ''], [
    ['C                              ',clc$abbreviation_entry, 1],
    ['CATALOG                        ',clc$alias_entry, 1],
    ['F                              ',clc$alias_entry, 1],
    ['FILE                           ',clc$nominal_entry, 1],
    ['INFORMATION_REQUEST            ',clc$nominal_entry, 2],
    ['IR                             ',clc$abbreviation_entry, 2],
    ['O                              ',clc$abbreviation_entry, 3],
    ['OUTPUT                         ',clc$nominal_entry, 3],
    ['STATUS                         ',clc$nominal_entry, 4]],
    [
{ PARAMETER 1
    [4, clc$normal_usage_entry, clc$non_secure_parameter,
    $clt$parameter_spec_methods[clc$specify_by_name, clc$specify_positionally],
    clc$pass_by_value, clc$immediate_evaluation, clc$standard_parameter_checking, 3, clc$required_parameter, 0
  , 0],
{ PARAMETER 2
    [5, clc$normal_usage_entry, clc$non_secure_parameter,
    $clt$parameter_spec_methods[clc$specify_by_name],
    clc$pass_by_value, clc$immediate_evaluation, clc$standard_parameter_checking, 60,
  clc$optional_default_parameter, 0, 3],
{ PARAMETER 3
    [8, clc$normal_usage_entry, clc$non_secure_parameter,
    $clt$parameter_spec_methods[clc$specify_by_name, clc$specify_positionally],
    clc$pass_by_value, clc$immediate_evaluation, clc$standard_parameter_checking, 3, clc$required_parameter, 0
  , 0],
{ PARAMETER 4
    [9, clc$normal_usage_entry, clc$non_secure_parameter,
    $clt$parameter_spec_methods[clc$specify_by_name],
    clc$pass_by_reference, clc$immediate_evaluation, clc$standard_parameter_checking, 3,
  clc$optional_parameter, 0, 0]],
{ PARAMETER 1
    [[1, 0, clc$file_type]],
{ PARAMETER 2
    [[1, 0, clc$list_type], [44, 1, clc$max_list_size, FALSE],
      [[1, 0, clc$keyword_type], [1], [
      ['ALL                            ', clc$nominal_entry, clc$normal_usage_entry, 1]]
      ]
    ,
    'all'],
{ PARAMETER 3
    [[1, 0, clc$file_type]],
{ PARAMETER 4
    [[1, 0, clc$status_type]]];

?? FMT (FORMAT := ON) ??
?? POP ??

    CONST
      p$file = 1,
      p$information_request = 2,
      p$output = 3,
      p$status = 4;

    VAR
      pvt: array [1 .. 4] of clt$parameter_value;


    VAR
      info_request: fst$goi_information_request,
      access_mode_selections: fst$file_access_options,
      local_status: ost$status,
      out_fid: amt$file_identifier,
      p_attachment_options: ^fst$attachment_options,
      segment_pointer: amt$segment_pointer;


    clp$evaluate_parameters (parameter_list, #SEQ (pdt), NIL, ^pvt, status);
    IF NOT status.normal THEN
      RETURN;
    IFEND;

    PUSH p_attachment_options: [1 .. 1];
    p_attachment_options^[1].selector := fsc$access_and_share_modes;
    p_attachment_options^[1].access_modes.selector := fsc$specific_access_modes;
    p_attachment_options^[1].access_modes.value := -$fst$file_access_options [];
    p_attachment_options^[1].share_modes.selector := fsc$specific_share_modes;
    p_attachment_options^[1].share_modes.value := $fst$file_access_options [];


    fsp$open_file (pvt [p$output].value^.file_value^, amc$segment, NIL, NIL, NIL, NIL,
          NIL, out_fid, status);
    IF NOT status.normal THEN
      RETURN;
    IFEND;

  /segment_open/
    BEGIN
      amp$get_segment_pointer (out_fid, amc$sequence_pointer, segment_pointer, status);
      IF NOT status.normal THEN
        EXIT /segment_open/;
      IFEND;

      RESET segment_pointer.sequence_pointer;

      info_request.catalog_depth.depth_specification := fsc$specific_depth;
      info_request.catalog_depth.depth := 1;
      info_request.object_information_requests := $fst$goi_object_info_requests[fsc$goi_catalog_identity,
            fsc$goi_catalog_object_list, fsc$goi_file_identity, fsc$goi_file_object_list];

      pfp$get_object_information (pvt [p$file].value^.file_value^, info_request, {p_validation_criteria} NIL,
            segment_pointer.sequence_pointer, status);
      IF NOT status.normal THEN
        EXIT /segment_open/;
      IFEND;

      amp$set_segment_eoi (out_fid, segment_pointer, status);
    END /segment_open/;

    fsp$close_file (out_fid, local_status);

  PROCEND pfp$get_object_info_cmd;

?? TITLE := 'pfp$set_cycle_damaged_cmd', EJECT ??

  PROCEDURE [XDCL] pfp$set_cycle_damaged_cmd
    (    parameter_list: clt$parameter_list;
     VAR status: ost$status);




{ PROCEDURE (osm$setcd) set_cycle_damaged, setcd (
{   file, f: file = $required
{   password, pw: (BY_NAME, SECURE) any of
{       key
{         none
{       keyend
{       name
{     anyend = none
{   status)

?? PUSH (LISTEXT := ON) ??
?? FMT (FORMAT := OFF) ??

  VAR
    pdt: [STATIC, READ, cls$declaration_section] record
      header: clt$pdt_header,
      names: array [1 .. 5] of clt$pdt_parameter_name,
      parameters: array [1 .. 3] of clt$pdt_parameter,
      type1: record
        header: clt$type_specification_header,
      recend,
      type2: record
        header: clt$type_specification_header,
        qualifier: clt$union_type_qualifier,
        type_size_1: clt$type_specification_size,
        element_type_spec_1: record
          header: clt$type_specification_header,
          qualifier: clt$keyword_type_qualifier,
          keyword_specs: array [1 .. 1] of clt$keyword_specification,
        recend,
        type_size_2: clt$type_specification_size,
        element_type_spec_2: record
          header: clt$type_specification_header,
          qualifier: clt$name_type_qualifier,
        recend,
        default_value: string (4),
      recend,
      type3: record
        header: clt$type_specification_header,
      recend,
    recend := [
    [1,
    [88, 11, 9, 15, 22, 38, 126],
    clc$command, 5, 3, 1, 0, 0, 0, 3, 'OSM$SETCD'], [
    ['F                              ',clc$abbreviation_entry, 1],
    ['FILE                           ',clc$nominal_entry, 1],
    ['PASSWORD                       ',clc$nominal_entry, 2],
    ['PW                             ',clc$abbreviation_entry, 2],
    ['STATUS                         ',clc$nominal_entry, 3]],
    [
{ PARAMETER 1
    [2, clc$normal_usage_entry, clc$non_secure_parameter,
    $clt$parameter_spec_methods[clc$specify_by_name, clc$specify_positionally],
    clc$pass_by_value, clc$immediate_evaluation, clc$standard_parameter_checking, 3, clc$required_parameter, 0
  , 0],
{ PARAMETER 2
    [3, clc$normal_usage_entry, clc$secure_parameter,
    $clt$parameter_spec_methods[clc$specify_by_name],
    clc$pass_by_value, clc$immediate_evaluation, clc$standard_parameter_checking, 69,
  clc$optional_default_parameter, 0, 4],
{ PARAMETER 3
    [5, clc$normal_usage_entry, clc$non_secure_parameter,
    $clt$parameter_spec_methods[clc$specify_by_name],
    clc$pass_by_reference, clc$immediate_evaluation, clc$standard_parameter_checking, 3,
  clc$optional_parameter, 0, 0]],
{ PARAMETER 1
    [[1, 0, clc$file_type]],
{ PARAMETER 2
    [[1, 0, clc$union_type], [[clc$keyword_type, clc$name_type],
    FALSE, 2],
    44, [[1, 0, clc$keyword_type], [1], [
      ['NONE                           ', clc$nominal_entry, clc$normal_usage_entry, 1]]
      ],
    5, [[1, 0, clc$name_type], [1, osc$max_name_size]]
    ,
    'none'],
{ PARAMETER 3
    [[1, 0, clc$status_type]]];

?? FMT (FORMAT := ON) ??
?? POP ??

    CONST
      p$file = 1,
      p$password = 2,
      p$status = 3;

    VAR
      pvt: array [1 .. 3] of clt$parameter_value;


    VAR
      password: pft$password;


    clp$evaluate_parameters (parameter_list, #SEQ (pdt), NIL, ^pvt, status);
    IF NOT status.normal THEN
      RETURN;
    IFEND;

    IF pvt [p$password].value^.kind = clc$name THEN
      password := pvt [p$password].value^.name_value;
    ELSE { keyword = NONE }
      password := osc$null_name;
    IFEND;

    fsp$change_cycle_damage (pvt [p$file].value^.file_value^, password,
          $fst$cycle_damage_symptoms [fsc$media_image_inconsistent], status);
  PROCEND pfp$set_cycle_damaged_cmd;

?? TITLE := 'pfp$open_file_cmd', EJECT ??

  PROCEDURE [XDCL] pfp$open_file_cmd
    (    parameter_list: clt$parameter_list;
     VAR status: ost$status);


{ PROCEDURE (osm$opef) open_file, opef (
{   file, f: file = $required
{   access_modes, access_mode, am: (BY_NAME) list of key
{       all
{       (append, a)
{       (execute, e)
{       (modify, m)
{       (read, r)
{       (shorten, s)
{       (write, w)
{     keyend = (read, execute)
{   share_modes, share_mode, sm: (BY_NAME) list of key
{       all, none
{       (append, a)
{       (execute, e)
{       (modify, m)
{       (read, r)
{       (shorten, s)
{       (write, w)
{     keyend = $optional
{   allowed_damage_conditions, adc: (BY_NAME) list of key
{       none
{       (media_image_inconsistent, mii)
{       (parent_catalog_restored, pcr)
{       (respf_modification_mismatch, rmm)
{     keyend = $optional
{   enable_media_damage_detection, emdd: boolean = false
{   status)

?? PUSH (LISTEXT := ON) ??
?? FMT (FORMAT := OFF) ??

  VAR
    pdt: [STATIC, READ, cls$declaration_section] record
      header: clt$pdt_header,
      names: array [1 .. 13] of clt$pdt_parameter_name,
      parameters: array [1 .. 6] of clt$pdt_parameter,
      type1: record
        header: clt$type_specification_header,
      recend,
      type2: record
        header: clt$type_specification_header,
        qualifier: clt$list_type_qualifier,
        element_type_spec: record
          header: clt$type_specification_header,
          qualifier: clt$keyword_type_qualifier,
          keyword_specs: array [1 .. 13] of clt$keyword_specification,
        recend,
        default_value: string (15),
      recend,
      type3: record
        header: clt$type_specification_header,
        qualifier: clt$list_type_qualifier,
        element_type_spec: record
          header: clt$type_specification_header,
          qualifier: clt$keyword_type_qualifier,
          keyword_specs: array [1 .. 14] of clt$keyword_specification,
        recend,
      recend,
      type4: record
        header: clt$type_specification_header,
        qualifier: clt$list_type_qualifier,
        element_type_spec: record
          header: clt$type_specification_header,
          qualifier: clt$keyword_type_qualifier,
          keyword_specs: array [1 .. 7] of clt$keyword_specification,
        recend,
      recend,
      type5: record
        header: clt$type_specification_header,
        default_value: string (5),
      recend,
      type6: record
        header: clt$type_specification_header,
      recend,
    recend := [
    [1,
    [88, 12, 16, 8, 51, 9, 567],
    clc$command, 13, 6, 1, 0, 0, 0, 6, 'OSM$OPEF'], [
    ['ACCESS_MODE                    ',clc$alias_entry, 2],
    ['ACCESS_MODES                   ',clc$nominal_entry, 2],
    ['ADC                            ',clc$abbreviation_entry, 4],
    ['ALLOWED_DAMAGE_CONDITIONS      ',clc$nominal_entry, 4],
    ['AM                             ',clc$abbreviation_entry, 2],
    ['EMDD                           ',clc$abbreviation_entry, 5],
    ['ENABLE_MEDIA_DAMAGE_DETECTION  ',clc$nominal_entry, 5],
    ['F                              ',clc$abbreviation_entry, 1],
    ['FILE                           ',clc$nominal_entry, 1],
    ['SHARE_MODE                     ',clc$alias_entry, 3],
    ['SHARE_MODES                    ',clc$nominal_entry, 3],
    ['SM                             ',clc$abbreviation_entry, 3],
    ['STATUS                         ',clc$nominal_entry, 6]],
    [
{ PARAMETER 1
    [9, clc$normal_usage_entry, clc$non_secure_parameter,
    $clt$parameter_spec_methods[clc$specify_by_name, clc$specify_positionally],
    clc$pass_by_value, clc$immediate_evaluation, clc$standard_parameter_checking, 3, clc$required_parameter, 0
  , 0],
{ PARAMETER 2
    [2, clc$normal_usage_entry, clc$non_secure_parameter,
    $clt$parameter_spec_methods[clc$specify_by_name],
    clc$pass_by_value, clc$immediate_evaluation, clc$standard_parameter_checking, 504,
  clc$optional_default_parameter, 0, 15],
{ PARAMETER 3
    [11, clc$normal_usage_entry, clc$non_secure_parameter,
    $clt$parameter_spec_methods[clc$specify_by_name],
    clc$pass_by_value, clc$immediate_evaluation, clc$standard_parameter_checking, 541,
  clc$optional_parameter, 0, 0],
{ PARAMETER 4
    [4, clc$normal_usage_entry, clc$non_secure_parameter,
    $clt$parameter_spec_methods[clc$specify_by_name],
    clc$pass_by_value, clc$immediate_evaluation, clc$standard_parameter_checking, 282,
  clc$optional_parameter, 0, 0],
{ PARAMETER 5
    [7, clc$normal_usage_entry, clc$non_secure_parameter,
    $clt$parameter_spec_methods[clc$specify_by_name, clc$specify_positionally],
    clc$pass_by_value, clc$immediate_evaluation, clc$standard_parameter_checking, 3,
  clc$optional_default_parameter, 0, 5],
{ PARAMETER 6
    [13, clc$normal_usage_entry, clc$non_secure_parameter,
    $clt$parameter_spec_methods[clc$specify_by_name],
    clc$pass_by_reference, clc$immediate_evaluation, clc$standard_parameter_checking, 3,
  clc$optional_parameter, 0, 0]],
{ PARAMETER 1
    [[1, 0, clc$file_type]],
{ PARAMETER 2
    [[1, 0, clc$list_type], [488, 1, clc$max_list_size, FALSE],
      [[1, 0, clc$keyword_type], [13], [
      ['A                              ', clc$abbreviation_entry, clc$normal_usage_entry, 2],
      ['ALL                            ', clc$nominal_entry, clc$normal_usage_entry, 1],
      ['APPEND                         ', clc$nominal_entry, clc$normal_usage_entry, 2],
      ['E                              ', clc$abbreviation_entry, clc$normal_usage_entry, 3],
      ['EXECUTE                        ', clc$nominal_entry, clc$normal_usage_entry, 3],
      ['M                              ', clc$abbreviation_entry, clc$normal_usage_entry, 4],
      ['MODIFY                         ', clc$nominal_entry, clc$normal_usage_entry, 4],
      ['R                              ', clc$abbreviation_entry, clc$normal_usage_entry, 5],
      ['READ                           ', clc$nominal_entry, clc$normal_usage_entry, 5],
      ['S                              ', clc$abbreviation_entry, clc$normal_usage_entry, 6],
      ['SHORTEN                        ', clc$nominal_entry, clc$normal_usage_entry, 6],
      ['W                              ', clc$abbreviation_entry, clc$normal_usage_entry, 7],
      ['WRITE                          ', clc$nominal_entry, clc$normal_usage_entry, 7]]
      ]
    ,
    '(read, execute)'],
{ PARAMETER 3
    [[1, 0, clc$list_type], [525, 1, clc$max_list_size, FALSE],
      [[1, 0, clc$keyword_type], [14], [
      ['A                              ', clc$abbreviation_entry, clc$normal_usage_entry, 3],
      ['ALL                            ', clc$nominal_entry, clc$normal_usage_entry, 1],
      ['APPEND                         ', clc$nominal_entry, clc$normal_usage_entry, 3],
      ['E                              ', clc$abbreviation_entry, clc$normal_usage_entry, 4],
      ['EXECUTE                        ', clc$nominal_entry, clc$normal_usage_entry, 4],
      ['M                              ', clc$abbreviation_entry, clc$normal_usage_entry, 5],
      ['MODIFY                         ', clc$nominal_entry, clc$normal_usage_entry, 5],
      ['NONE                           ', clc$nominal_entry, clc$normal_usage_entry, 2],
      ['R                              ', clc$abbreviation_entry, clc$normal_usage_entry, 6],
      ['READ                           ', clc$nominal_entry, clc$normal_usage_entry, 6],
      ['S                              ', clc$abbreviation_entry, clc$normal_usage_entry, 7],
      ['SHORTEN                        ', clc$nominal_entry, clc$normal_usage_entry, 7],
      ['W                              ', clc$abbreviation_entry, clc$normal_usage_entry, 8],
      ['WRITE                          ', clc$nominal_entry, clc$normal_usage_entry, 8]]
      ]
    ],
{ PARAMETER 4
    [[1, 0, clc$list_type], [266, 1, clc$max_list_size, FALSE],
      [[1, 0, clc$keyword_type], [7], [
      ['MEDIA_IMAGE_INCONSISTENT       ', clc$nominal_entry, clc$normal_usage_entry, 2],
      ['MII                            ', clc$abbreviation_entry, clc$normal_usage_entry, 2],
      ['NONE                           ', clc$nominal_entry, clc$normal_usage_entry, 1],
      ['PARENT_CATALOG_RESTORED        ', clc$nominal_entry, clc$normal_usage_entry, 3],
      ['PCR                            ', clc$abbreviation_entry, clc$normal_usage_entry, 3],
      ['RESPF_MODIFICATION_MISMATCH    ', clc$nominal_entry, clc$normal_usage_entry, 4],
      ['RMM                            ', clc$abbreviation_entry, clc$normal_usage_entry, 4]]
      ]
    ],
{ PARAMETER 5
    [[1, 0, clc$boolean_type],
    'false'],
{ PARAMETER 6
    [[1, 0, clc$status_type]]];

?? FMT (FORMAT := ON) ??
?? POP ??

    CONST
      p$file = 1,
      p$access_modes = 2,
      p$share_modes = 3,
      p$allowed_damage_conditions = 4,
      p$enable_media_damage_detection = 5,
      p$status = 6;

    VAR
      pvt: array [1 .. 6] of clt$parameter_value;

    VAR
      allowed_cycle_damage_conditions: fst$cycle_damage_symptoms,
      fid: amt$file_identifier,
      access_mode_selections: fst$file_access_options,
      usage_selections: fst$file_access_options,
      share_selections: fst$file_access_options,
      p_attachment_options: ^fst$attachment_options;


    clp$evaluate_parameters (parameter_list, #SEQ (pdt), NIL, ^pvt, status);
    IF NOT status.normal THEN
      RETURN;
    IFEND;

    PUSH p_attachment_options: [1 .. 3];
    p_attachment_options^[1].selector := fsc$access_and_share_modes;
    p_attachment_options^[2].selector := fsc$exception_detection;
    p_attachment_options^[3].selector := fsc$allowed_exceptions;

    IF pvt [p$enable_media_damage_detection].specified AND
          pvt [p$enable_media_damage_detection].value^.boolean_value.value THEN
      p_attachment_options^ [2].exception_detection := $fst$cycle_damage_symptoms
            [fsc$media_image_inconsistent];
    ELSE
      p_attachment_options^ [2].exception_detection := $fst$cycle_damage_symptoms [];
    IFEND;

    handle_allowed_damage_condition (pvt [p$allowed_damage_conditions].value,
          allowed_cycle_damage_conditions, status);
    IF NOT status.normal THEN
      RETURN;
    IFEND;
    p_attachment_options^ [3].allowed_exceptions.damage_symptoms := allowed_cycle_damage_conditions;
    p_attachment_options^ [3].allowed_exceptions.access_conditions := $fst$file_access_conditions [];

    access_mode_selections := $fst$file_access_options [fsc$append, fsc$shorten, fsc$modify];

    handle_access_mode_or_share (pvt [p$access_modes].value, select_usage, usage_selections, status);
    IF NOT status.normal THEN
      RETURN;
    IFEND;


    IF pvt [p$share_modes].specified THEN
      handle_access_mode_or_share (pvt [p$share_modes].value, select_share, share_selections, status);
      IF NOT status.normal THEN
        RETURN;
      IFEND;
    ELSEIF (usage_selections * access_mode_selections) <> $fst$file_access_options [] THEN
      share_selections := $fst$file_access_options [];
    ELSE
      share_selections := $fst$file_access_options [fsc$read, fsc$execute];
    IFEND;
    p_attachment_options^[1].access_modes.selector := fsc$specific_access_modes;
    p_attachment_options^[1].access_modes.value := usage_selections;

    p_attachment_options^[1].share_modes.selector := fsc$specific_share_modes;
    p_attachment_options^[1].share_modes.value := share_selections;


    fsp$open_file (pvt [p$file].value^.file_value^, amc$record, p_attachment_options, NIL, NIL, NIL,
          NIL, fid, status);

  PROCEND pfp$open_file_cmd;

?? TITLE := 'handle_access_mode_or_share', EJECT ??

{
{ PURPOSE:
{   This procedure processes the 'ACCESS_MODE' and 'SHARE_MODE' parameters for
{   all commands that contain  one or both of them.  One of the command
{   parameters is processed on each call to this procedure.  For any given
{   call, the caller will use only one of the output parameters; however, both
{   are always built since this procedure doesn't know which one the caller
{   wants.
{
{ NOTE:
{   The procedure assumes that pft$usage_selections and pft$share_selections
{   are "really" the same type.
{

  PROCEDURE handle_access_mode_or_share
    (    usage_share_value: ^clt$data_value;
         selections_kind: (select_usage, select_share);
     VAR usage_share_selections: fst$file_access_options;
     VAR status: ost$status);

    VAR
      access_mode_value: clt$keyword,
      local_usage_share_value: ^clt$data_value;


    usage_share_selections := $fst$file_access_options [];

    local_usage_share_value := usage_share_value;
    WHILE local_usage_share_value <> NIL DO
      access_mode_value := local_usage_share_value^.element_value^.keyword_value;
      IF access_mode_value = 'ALL' THEN
        usage_share_selections := -$fst$file_access_options [];
      ELSEIF access_mode_value = 'APPEND' THEN
        usage_share_selections := usage_share_selections + $fst$file_access_options [fsc$append];
      ELSEIF access_mode_value = 'EXECUTE' THEN
        usage_share_selections := usage_share_selections + $fst$file_access_options [fsc$execute];
      ELSEIF access_mode_value = 'MODIFY' THEN
        usage_share_selections := usage_share_selections + $fst$file_access_options [fsc$modify];
      ELSEIF access_mode_value = 'NONE' THEN
        IF usage_share_value^.link <> NIL THEN
          osp$set_status_abnormal ('CL', cle$none_must_be_used_alone, access_mode_value, status);
        IFEND;
        RETURN;
      ELSEIF access_mode_value = 'READ' THEN
        usage_share_selections := usage_share_selections + $fst$file_access_options [fsc$read];
      ELSEIF access_mode_value = 'SHORTEN' THEN
        usage_share_selections := usage_share_selections + $fst$file_access_options [fsc$shorten];
      ELSEIF access_mode_value = 'WRITE' THEN
        usage_share_selections := usage_share_selections + $fst$file_access_options
              [fsc$append, fsc$modify, fsc$shorten];
      IFEND;
      local_usage_share_value := local_usage_share_value^.link;
    WHILEND;

  PROCEND handle_access_mode_or_share;

?? TITLE := 'handle_allowed_damage_condition', EJECT ??

{
{ PURPOSE:
{   This procedure processes the 'ACCESS_MODE' and 'SHARE_MODE' parameters for
{   all commands that contain  one or both of them.  One of the command
{   parameters is processed on each call to this procedure.  For any given
{   call, the caller will use only one of the output parameters; however, both
{   are always built since this procedure doesn't know which one the caller
{   wants.
{
{ NOTE:
{   The procedure assumes that pft$usage_selections and pft$share_selections
{   are "really" the same type.
{

  PROCEDURE handle_allowed_damage_condition
    (    allowed_damage_value: ^clt$data_value;
     VAR allowed_damage_conditions: fst$cycle_damage_symptoms;
     VAR status: ost$status);

    VAR
      damage_condition_value: clt$keyword,
      local_allowed_damage_value: ^clt$data_value;


    allowed_damage_conditions := $fst$cycle_damage_symptoms [];

    local_allowed_damage_value := allowed_damage_value;
    WHILE local_allowed_damage_value <> NIL DO
      damage_condition_value := local_allowed_damage_value^.element_value^.keyword_value;
      IF damage_condition_value (1) = 'M' THEN {Media_image_inconsistent}
        allowed_damage_conditions := allowed_damage_conditions +
              $fst$cycle_damage_symptoms [fsc$media_image_inconsistent];
      ELSEIF damage_condition_value (1) = 'P' THEN {parent_catalog_restored}
        allowed_damage_conditions := allowed_damage_conditions +
              $fst$cycle_damage_symptoms [fsc$parent_catalog_restored];
      ELSEIF damage_condition_value (1) = 'R' THEN {respf_modification_mismatch}
        allowed_damage_conditions := allowed_damage_conditions +
              $fst$cycle_damage_symptoms [fsc$respf_modification_mismatch];
      ELSEIF damage_condition_value = 'NONE' THEN
        IF local_allowed_damage_value^.link <> NIL THEN
          osp$set_status_abnormal ('CL', cle$none_must_be_used_alone, damage_condition_value, status);
        IFEND;
        RETURN;
      IFEND;
      local_allowed_damage_value := local_allowed_damage_value^.link;
    WHILEND;

  PROCEND handle_allowed_damage_condition;
MODEND pfm$permanent_file_tests;

