?? RIGHT := 110 ??
?? NEWTITLE := 'NOS/VE Job Management : Manage Queue File Utility' ??
MODULE jmm$manage_qfile_utility;
?? RIGHT := 110 ??

{ PURPOSE:
{   This module contains the command and subcommands for the NOS/VE Manage
{ Queue File Utility.  The utility is used to manage generic queue files in NOS/VE.
{
{ DESIGN:
{   This utility is a standalone utility outside of the operating system.  It is
{ available only to users with one of the following validation capabilities active:
{ system_displays, system_operation.
{
{   Commands in this utility are designed to process an entire list of arguments
{ and report errors as they occur.  (This is intended for future sub-commands).
{

?? NEWTITLE := 'Global Declarations Referenced By This Module', EJECT ??
?? PUSH (LISTEXT := ON) ??
*copyc clt$parameter_list
*copyc jmc$job_management_id
*copyc jmc$system_family
*copyc jme$queued_file_conditions
*copyc jmt$attribute_keys
*copyc jmt$attribute_keys_set
*copyc jmt$attribute_values
*copyc jmt$error_status_list
*copyc jmt$name_list
*copyc jmt$qfile_attribute_count
*copyc jmt$system_supplied_name_list
*copyc jmt$work_area
*copyc ofe$error_codes
*copyc osd$integer_limits
*copyc ost$caller_identifier
*copyc ost$status
?? POP ??
*copyc avp$system_displays
*copyc avp$system_operator
*copyc clp$begin_utility
*copyc clp$build_standard_title
*copyc clp$close_display
*copyc clp$convert_integer_to_string
*copyc clp$count_list_elements
*copyc clp$end_include
*copyc clp$end_utility
*copyc clp$evaluate_parameters
*copyc clp$include_file
*copyc clp$make_boolean_value
*copyc clp$make_date_time_value
*copyc clp$make_file_value
*copyc clp$make_keyword_value
*copyc clp$make_list_value
*copyc clp$make_name_value
*copyc clp$make_record_value
*copyc clp$make_string_value
*copyc clp$make_time_increment_value
*copyc clp$make_unspecified_value
*copyc clp$new_display_line
*copyc clp$open_display_reference
*copyc clp$put_display
*copyc clp$reset_for_next_display_page
*copyc jmp$copy_qfile
*copyc jmp$display_attributes
*copyc jmp$get_attribute_index
*copyc jmp$get_attribute_name
*copyc jmp$util_get_qfile_attributes
*copyc jmp$util_terminate_qfile
*copyc jmp$validate_name
*copyc mmp$create_scratch_segment
*copyc mmp$delete_scratch_segment
*copyc osp$append_status_parameter
*copyc osp$disestablish_cond_handler
*copyc osp$establish_block_exit_hndlr
*copyc osp$format_message
*copyc osp$generate_log_message
*copyc osp$set_status_abnormal
*copyc osv$lower_to_upper
?? OLDTITLE ??
?? NEWTITLE := 'Global Declarations Declared By This Module', EJECT ??

*copy clv$display_variables

  SECTION
    read_only: READ;

  CONST
    utility_prompt = 'MQF';

  VAR
    display_control: [STATIC] clt$display_control,
    error_file: [STATIC] fst$path := ':$LOCAL.$ERRORS',
    error_file_open: [STATIC] boolean := FALSE,
    output_file: [STATIC] fst$path := ':$LOCAL.OUTPUT';

  VAR
    data_mode_names: [STATIC, READ, read_only] array [jmt$data_mode] of string (13) := ['CODED',
          'RHF_STRUCTURE', 'TRANSPARENT'],
    qfile_state_names: [STATIC, READ, read_only] array [jmt$qfile_state] of string (10) := ['DEFERRED',
          'QUEUED', 'INITIATED', 'TERMINATED', 'COMPLETED'],
    utility_name: [STATIC, READ, read_only] clt$utility_name := 'manage_queue_files',
    manqf_work_area: amt$segment_pointer;

  CONST
    qfile_max_keys = 17;

?? OLDTITLE ??
?? NEWTITLE := 'Commands for the Manage_Queue_File Utility', EJECT ??

{ table name=manage_queue_file_comma type=command section_name=read_only ..
{   scope=local
{ command (change_list_options, change_list_option, chalo) ..
{   p=change_list_options cm=local
{ command (copy_queue_file, copqf) p=copy_queue_file cm=local
{ command (display_queue_file_attribute, display_queue_file_attributes, ..
{   disqfa)       p=display_queue_file_attribute cm=local
{ command (quit, end_manage_queue_file, end_manage_queue_files, endmqf, ..
{   qui) p=quit cm=local
{ command (terminate_queue_file, terminate_queue_files, terqf) ..
{   p=terminate_queue_file cm=local
{ tablend

?? PUSH (LISTEXT := ON) ??

  VAR
    manage_queue_file_comma: [STATIC, READ, read_only] ^clt$command_table := ^manage_queue_file_comma_entries,

    manage_queue_file_comma_entries: [STATIC, READ, read_only] array [1 .. 16] of clt$command_table_entry := [
          {} ['CHALO                          ', clc$abbreviation_entry, clc$normal_usage_entry, 1,
          clc$automatically_log, clc$linked_call, ^change_list_options],
          {} ['CHANGE_LIST_OPTION             ', clc$alias_entry, clc$normal_usage_entry, 1,
          clc$automatically_log, clc$linked_call, ^change_list_options],
          {} ['CHANGE_LIST_OPTIONS            ', clc$nominal_entry, clc$normal_usage_entry, 1,
          clc$automatically_log, clc$linked_call, ^change_list_options],
          {} ['COPQF                          ', clc$abbreviation_entry, clc$normal_usage_entry, 2,
          clc$automatically_log, clc$linked_call, ^copy_queue_file],
          {} ['COPY_QUEUE_FILE                ', clc$nominal_entry, clc$normal_usage_entry, 2,
          clc$automatically_log, clc$linked_call, ^copy_queue_file],
          {} ['DISPLAY_QUEUE_FILE_ATTRIBUTE   ', clc$nominal_entry, clc$normal_usage_entry, 3,
          clc$automatically_log, clc$linked_call, ^display_queue_file_attribute],
          {} ['DISPLAY_QUEUE_FILE_ATTRIBUTES  ', clc$alias_entry, clc$normal_usage_entry, 3,
          clc$automatically_log, clc$linked_call, ^display_queue_file_attribute],
          {} ['DISQFA                         ', clc$abbreviation_entry, clc$normal_usage_entry, 3,
          clc$automatically_log, clc$linked_call, ^display_queue_file_attribute],
          {} ['ENDMQF                         ', clc$alias_entry, clc$normal_usage_entry, 4,
          clc$automatically_log, clc$linked_call, ^quit],
          {} ['END_MANAGE_QUEUE_FILE          ', clc$alias_entry, clc$normal_usage_entry, 4,
          clc$automatically_log, clc$linked_call, ^quit],
          {} ['END_MANAGE_QUEUE_FILES         ', clc$alias_entry, clc$normal_usage_entry, 4,
          clc$automatically_log, clc$linked_call, ^quit],
          {} ['QUI                            ', clc$abbreviation_entry, clc$normal_usage_entry, 4,
          clc$automatically_log, clc$linked_call, ^quit],
          {} ['QUIT                           ', clc$nominal_entry, clc$normal_usage_entry, 4,
          clc$automatically_log, clc$linked_call, ^quit],
          {} ['TERMINATE_QUEUE_FILE           ', clc$nominal_entry, clc$normal_usage_entry, 5,
          clc$automatically_log, clc$linked_call, ^terminate_queue_file],
          {} ['TERMINATE_QUEUE_FILES          ', clc$alias_entry, clc$normal_usage_entry, 5,
          clc$automatically_log, clc$linked_call, ^terminate_queue_file],
          {} ['TERQF                          ', clc$abbreviation_entry, clc$normal_usage_entry, 5,
          clc$automatically_log, clc$linked_call, ^terminate_queue_file]];

?? POP ??

{ table name=manage_queue_file_funct type=function    ..
{   section_name=read_only scope=local
{ function $queue_file_attributes p=queue_file_attributes cm=local
{ tablend

?? PUSH (LISTEXT := ON) ??

  VAR
    manage_queue_file_funct: [STATIC, READ, read_only] ^clt$function_processor_table :=
          ^manage_queue_file_funct_entries,

    manage_queue_file_funct_entries: [STATIC, READ, read_only] array [1 .. 1] of
          clt$function_proc_table_entry := [
          {} ['$QUEUE_FILE_ATTRIBUTES         ', clc$nominal_entry, clc$normal_usage_entry, 1,
          clc$linked_call, ^queue_file_attributes]];

?? POP ??
?? OLDTITLE ??
?? NEWTITLE := '[XDCL, #GATE] jmp$_manage_queue_file_utility', EJECT ??

{ PURPOSE:
{   This is the entry point that begins the manage queue file utility.

  PROCEDURE [XDCL, #GATE] jmp$_manage_queue_file_utility
    (    parameter_list: clt$parameter_list;
     VAR status: ost$status);

{  PROCEDURE (jmm$manqf) manage_queue_file, manage_queue_files, manqf (
{    status)

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

  VAR
    pdt: [STATIC, READ, cls$declaration_section] record
      header: clt$pdt_header,
      names: array [1 .. 1] of clt$pdt_parameter_name,
      parameters: array [1 .. 1] of clt$pdt_parameter,
      type1: record
        header: clt$type_specification_header,
      recend,
    recend := [
    [1,
    [90, 2, 28, 16, 23, 24, 475],
    clc$command, 1, 1, 0, 0, 0, 0, 1, 'JMM$MANQF'], [
    ['STATUS                         ',clc$nominal_entry, 1]],
    [
{ PARAMETER 1
    [1, 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$status_type]]];

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

    CONST
      p$status = 1;

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

    VAR
      utility_attributes_p: ^clt$utility_attributes;

    status.normal := TRUE;
    IF (NOT avp$system_displays ()) AND (NOT avp$system_operator ()) THEN
      osp$set_status_abnormal (jmc$job_management_id, ofe$sou_not_active,
            'SYSTEM_DISPLAYS or SYSTEM_OPERATION', status);
      RETURN; {----->
    IFEND;
    clp$evaluate_parameters (parameter_list, #SEQ (pdt), NIL, ^pvt, status);
    IF NOT status.normal THEN
      RETURN; {----->
    IFEND;
    PUSH utility_attributes_p: [1 .. 5];
    utility_attributes_p^ [1].key := clc$utility_command_search_mode;
    utility_attributes_p^ [1].command_search_mode := clc$global_command_search;
    utility_attributes_p^ [2].key := clc$utility_command_table;
    utility_attributes_p^ [2].command_table := manage_queue_file_comma;
    utility_attributes_p^ [3].key := clc$utility_prompt;
    utility_attributes_p^ [3].prompt.value := utility_prompt;
    utility_attributes_p^ [3].prompt.size := STRLENGTH (utility_prompt);
    utility_attributes_p^ [4].key := clc$utility_termination_command;
    utility_attributes_p^ [4].termination_command := 'quit';
    utility_attributes_p^ [5].key := clc$utility_function_proc_table;
    utility_attributes_p^ [5].function_processor_table := manage_queue_file_funct;

    mmp$create_scratch_segment (amc$sequence_pointer, mmc$as_sequential, manqf_work_area, status);
    IF NOT status.normal THEN
      RETURN; {----->
    IFEND;

{ Begin the utility environment.  Establish the command list, and scan the
{ command file for commands.

    clp$begin_utility (utility_name, utility_attributes_p^, status);
    IF NOT status.normal THEN
      RETURN; {----->
    IFEND;

    clp$include_file (clc$current_command_input, utility_prompt, utility_name, status);
    IF NOT status.normal THEN
      RETURN; {----->
    IFEND;

    mmp$delete_scratch_segment (manqf_work_area, { ignore } status);
    status.normal := TRUE;

{ End the utility environment and exit the utility.

    clp$end_utility (utility_name, status);

  PROCEND jmp$_manage_queue_file_utility;
?? OLDTITLE ??
?? NEWTITLE := 'change_list_options', EJECT ??

{ This procedure is the command processor for the change_list_options subcommand.

  PROCEDURE change_list_options
    (    parameter_list: clt$parameter_list;
     VAR status: ost$status);

{  PROCEDURE (jmm$manqf_chalo) change_list_options, change_list_option, chalo (
{    errors, error, e: file = $optional
{    output, o: file = $optional
{    status)

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

  VAR
    pdt: [STATIC, READ, cls$declaration_section] record
      header: clt$pdt_header,
      names: array [1 .. 6] 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,
      recend,
      type3: record
        header: clt$type_specification_header,
      recend,
    recend := [
    [1,
    [90, 2, 28, 16, 23, 28, 607],
    clc$command, 6, 3, 0, 0, 0, 0, 3, 'JMM$MANQF_CHALO'], [
    ['E                              ',clc$abbreviation_entry, 1],
    ['ERROR                          ',clc$alias_entry, 1],
    ['ERRORS                         ',clc$nominal_entry, 1],
    ['O                              ',clc$abbreviation_entry, 2],
    ['OUTPUT                         ',clc$nominal_entry, 2],
    ['STATUS                         ',clc$nominal_entry, 3]],
    [
{ PARAMETER 1
    [3, 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_parameter, 0, 0],
{ PARAMETER 2
    [5, 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_parameter, 0, 0],
{ PARAMETER 3
    [6, 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$file_type]],
{ PARAMETER 3
    [[1, 0, clc$status_type]]];

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

    CONST
      p$errors = 1,
      p$output = 2,
      p$status = 3;

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

    status.normal := TRUE;

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

    IF pvt [p$errors].specified THEN
      error_file := pvt [p$errors].value^.file_value^;
    IFEND;

    IF pvt [p$output].specified THEN
      output_file := pvt [p$output].value^.file_value^;
    IFEND;

  PROCEND change_list_options;
?? OLDTITLE ??
?? NEWTITLE := 'close_error_file', EJECT ??

  PROCEDURE close_error_file
    (VAR status: ost$status);

    IF error_file_open THEN
      clp$close_display (display_control, status);
      IF status.normal THEN
        error_file_open := FALSE;
        #SPOIL (error_file_open);
      IFEND;
    IFEND;

  PROCEND close_error_file;
?? OLDTITLE ??
?? NEWTITLE := 'display_status_error', EJECT ??

  PROCEDURE display_status_error
    (    error_status: ost$status;
     VAR status: ost$status);

    VAR
      line_count: 1 .. osc$max_status_message_lines,
      status_message_p: ^ost$status_message,
      status_message_line_count_p: ^ost$status_message_line_count,
      status_message_line_p: ^ost$status_message_line,
      status_message_line_size_p: ^ost$status_message_line_size,
      status_message: ost$status_message;

    IF error_status.normal THEN
      RETURN; {----->
    IFEND;

    IF NOT error_file_open THEN
      open_error_file (error_file, status);
      IF NOT status.normal THEN
        RETURN; {----->
      IFEND;
    IFEND;

    osp$format_message (error_status, osc$full_message_level, display_control.page_width, status_message,
          status);
    IF NOT status.normal THEN
      RETURN; {----->
    IFEND;
    status_message_p := ^status_message;
    RESET status_message_p;
    NEXT status_message_line_count_p IN status_message_p;
    FOR line_count := 1 TO status_message_line_count_p^ DO
      NEXT status_message_line_size_p IN status_message_p;
      NEXT status_message_line_p: [status_message_line_size_p^] IN status_message_p;
      clp$put_display (display_control, status_message_line_p^, clc$trim, status);
      IF NOT status.normal THEN
        RETURN; {----->
      IFEND;
    FOREND;
  PROCEND display_status_error;
?? OLDTITLE ??
?? NEWTITLE := 'open_error_file', EJECT ??

  PROCEDURE open_error_file
    (    error_file: fst$file_reference;
     VAR status: ost$status);

    VAR
      default_ring_attributes: amt$ring_attributes;

    status.normal := TRUE;
    IF NOT error_file_open THEN

      default_ring_attributes.r1 := #RING (^default_ring_attributes);
      default_ring_attributes.r2 := #RING (^default_ring_attributes);
      default_ring_attributes.r3 := #RING (^default_ring_attributes);

      clp$open_display_reference (error_file, ^clp$new_page_procedure, fsc$list, default_ring_attributes,
            display_control, status);
      IF status.normal THEN
        error_file_open := TRUE;
        #SPOIL (error_file_open);
      IFEND;
    IFEND;

  PROCEND open_error_file;
?? OLDTITLE ??
?? NEWTITLE := 'put_subtitle', EJECT ??

  PROCEDURE [INLINE] put_subtitle
    (VAR display_control: clt$display_control;
     VAR status: ost$status);

{ These displays do not have subtitles.  This is merely a dummy routine to keep the module consistant
{ with those that do produce subtitles.

  PROCEND put_subtitle;
?? OLDTITLE ??
?? NEWTITLE := 'quit', EJECT ??

{ This procedure is the command processor for the quit subcommand.

  PROCEDURE quit
    (    parameter_list: clt$parameter_list;
     VAR status: ost$status);

{   PROCEDURE (jmm$manqf_qui) quit, end_manage_queue_file, ..
{ end_manage_queue_files, endmqf, qui (
{     status)

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

  VAR
    pdt: [STATIC, READ, cls$declaration_section] record
      header: clt$pdt_header,
      names: array [1 .. 1] of clt$pdt_parameter_name,
      parameters: array [1 .. 1] of clt$pdt_parameter,
      type1: record
        header: clt$type_specification_header,
      recend,
    recend := [
    [1,
    [90, 7, 13, 15, 48, 7, 429],
    clc$command, 1, 1, 0, 0, 0, 0, 1, 'JMM$MANQF_QUI'], [
    ['STATUS                         ',clc$nominal_entry, 1]],
    [
{ PARAMETER 1
    [1, 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$status_type]]];

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

    CONST
      p$status = 1;

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

    status.normal := TRUE;

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

    clp$end_include (utility_name, status);

{ Exit the utility.

  PROCEND quit;
?? OLDTITLE ??
?? NEWTITLE := 'copy_queue_file', EJECT ??

{ This procedure is the command processor for the copy_queue_file subcommand.

  PROCEDURE copy_queue_file
    (    parameter_list: clt$parameter_list;
     VAR status: ost$status);

{   PROCEDURE (jmm$manqf_copqf) copy_queue_file, copqf (
{     name, n: name = $required
{     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 .. 5] of clt$pdt_parameter_name,
      parameters: array [1 .. 3] of clt$pdt_parameter,
      type1: record
        header: clt$type_specification_header,
        qualifier: clt$name_type_qualifier,
      recend,
      type2: record
        header: clt$type_specification_header,
      recend,
      type3: record
        header: clt$type_specification_header,
      recend,
    recend := [
    [1,
    [95, 11, 28, 13, 0, 7, 948],
    clc$command, 5, 3, 2, 0, 0, 0, 3, 'JMM$MANQF_COPQF'], [
    ['N                              ',clc$abbreviation_entry, 1],
    ['NAME                           ',clc$nominal_entry, 1],
    ['O                              ',clc$abbreviation_entry, 2],
    ['OUTPUT                         ',clc$nominal_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, 5, clc$required_parameter, 0, 0],
{ PARAMETER 2
    [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 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$name_type], [1, osc$max_name_size]],
{ PARAMETER 2
    [[1, 0, clc$file_type]],
{ PARAMETER 3
    [[1, 0, clc$status_type]]];

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

    CONST
      p$name = 1,
      p$output = 2,
      p$status = 3;

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

    VAR
      caller_id: ost$caller_identifier,
      good_name: jmt$name,
      ignore_status: ost$status,
      local_status: ost$status,
      potential_name: jmt$name;

    status.normal := TRUE;
    IF NOT avp$system_operator () THEN
      osp$set_status_abnormal (jmc$job_management_id, ofe$sou_not_active, 'SYSTEM_OPERATION', status);
      RETURN; {----->
    IFEND;

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

{ Process NAME parameter.
{ Call jmp$validate_name to ensure that the caller supplied one of the forms of the
{ system-supplied name.  Interface jmp$copy_qfile requires a system-supplied name,
{ not just a name.

    potential_name.kind := jmc$system_supplied_name;
    potential_name.system_supplied_name := pvt [p$name].value^.name_value;
    jmp$validate_name (potential_name, good_name, status);
    IF NOT status.normal THEN
      RETURN; {----->
    IFEND;

    #CALLER_ID (caller_id);

    jmp$copy_qfile (good_name.system_supplied_name, pvt [p$output].value^.file_value^, caller_id.ring,
          local_status);
    IF NOT local_status.normal THEN
      display_status_error (local_status, ignore_status);
    IFEND;

    IF error_file_open THEN
      close_error_file (ignore_status);
    IFEND;
  PROCEND copy_queue_file;
?? OLDTITLE ??
?? NEWTITLE := 'display_queue_file_attribute', EJECT ??

{ This procedure is the command processor for the display_queue_file_attribute subcommand.

  PROCEDURE display_queue_file_attribute
    (    parameter_list: clt$parameter_list;
     VAR status: ost$status);

{ PROCEDURE (jmm$manqf_disqfa) display_queue_file_attribute, display_queue_file_attributes, disqfa (
{   system_file_name, system_file_names, sfn: any of
{       key
{         all
{       keyend
{       list of name
{     anyend = $required
{   display_option, display_options, do: any of
{       key
{         all
{       keyend
{       list of key
{         (application_name, an)
{         (application_status, as)
{         (control_family, cf)
{         (control_user, cu)
{         (data_mode, dm)
{         (deferred_by_application, dba)
{         (deferred_by_operator, dbo)
{         (deferred_by_user, dbu)
{         (destination, d)
{         (earliest_run_time, ert)
{         (latest_run_time, lrt)
{         (login_family, lf)
{         (login_user, lu)
{         (purge_delay, pd)
{         (remote_host_directive, rhd)
{         (state, s)
{         (system_file_name, sfn)
{       keyend
{     anyend = all
{   output, o: file = $output
{   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,
        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$list_type_qualifier_v2,
          element_type_spec: record
            header: clt$type_specification_header,
            qualifier: clt$name_type_qualifier,
          recend,
        recend,
      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$list_type_qualifier_v2,
          element_type_spec: record
            header: clt$type_specification_header,
            qualifier: clt$keyword_type_qualifier,
            keyword_specs: array [1 .. 34] of clt$keyword_specification,
          recend,
        recend,
        default_value: string (3),
      recend,
      type3: record
        header: clt$type_specification_header,
        default_value: string (7),
      recend,
      type4: record
        header: clt$type_specification_header,
      recend,
    recend := [
    [1,
    [102, 12, 20, 15, 42, 56, 459],
    clc$command, 9, 4, 1, 0, 0, 0, 4, 'JMM$MANQF_DISQFA'], [
    ['DISPLAY_OPTION                 ',clc$nominal_entry, 2],
    ['DISPLAY_OPTIONS                ',clc$alias_entry, 2],
    ['DO                             ',clc$abbreviation_entry, 2],
    ['O                              ',clc$abbreviation_entry, 3],
    ['OUTPUT                         ',clc$nominal_entry, 3],
    ['SFN                            ',clc$abbreviation_entry, 1],
    ['STATUS                         ',clc$nominal_entry, 4],
    ['SYSTEM_FILE_NAME               ',clc$nominal_entry, 1],
    ['SYSTEM_FILE_NAMES              ',clc$alias_entry, 1]],
    [
{ PARAMETER 1
    [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, 85, clc$required_parameter,
  0, 0],
{ PARAMETER 2
    [1, 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, 1345,
  clc$optional_default_parameter, 0, 3],
{ PARAMETER 3
    [5, 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, 7],
{ PARAMETER 4
    [7, 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$union_type], [[clc$keyword_type, clc$list_type],
    FALSE, 2],
    44, [[1, 0, clc$keyword_type], [1], [
      ['ALL                            ', clc$nominal_entry, clc$normal_usage_entry, 1]]
      ],
    21, [[1, 0, clc$list_type], [5, 1, clc$max_list_size, 0, FALSE, FALSE],
        [[1, 0, clc$name_type], [1, osc$max_name_size]]
      ]
    ],
{ PARAMETER 2
    [[1, 0, clc$union_type], [[clc$keyword_type, clc$list_type],
    FALSE, 2],
    44, [[1, 0, clc$keyword_type], [1], [
      ['ALL                            ', clc$nominal_entry, clc$normal_usage_entry, 1]]
      ],
    1281, [[1, 0, clc$list_type], [1265, 1, clc$max_list_size, 0, FALSE, FALSE],
        [[1, 0, clc$keyword_type], [34], [
        ['AN                             ', clc$abbreviation_entry, clc$normal_usage_entry, 1],
        ['APPLICATION_NAME               ', clc$nominal_entry, clc$normal_usage_entry, 1],
        ['APPLICATION_STATUS             ', clc$nominal_entry, clc$normal_usage_entry, 2],
        ['AS                             ', clc$abbreviation_entry, clc$normal_usage_entry, 2],
        ['CF                             ', clc$abbreviation_entry, clc$normal_usage_entry, 3],
        ['CONTROL_FAMILY                 ', clc$nominal_entry, clc$normal_usage_entry, 3],
        ['CONTROL_USER                   ', clc$nominal_entry, clc$normal_usage_entry, 4],
        ['CU                             ', clc$abbreviation_entry, clc$normal_usage_entry, 4],
        ['D                              ', clc$abbreviation_entry, clc$normal_usage_entry, 9],
        ['DATA_MODE                      ', clc$nominal_entry, clc$normal_usage_entry, 5],
        ['DBA                            ', clc$abbreviation_entry, clc$normal_usage_entry, 6],
        ['DBO                            ', clc$abbreviation_entry, clc$normal_usage_entry, 7],
        ['DBU                            ', clc$abbreviation_entry, clc$normal_usage_entry, 8],
        ['DEFERRED_BY_APPLICATION        ', clc$nominal_entry, clc$normal_usage_entry, 6],
        ['DEFERRED_BY_OPERATOR           ', clc$nominal_entry, clc$normal_usage_entry, 7],
        ['DEFERRED_BY_USER               ', clc$nominal_entry, clc$normal_usage_entry, 8],
        ['DESTINATION                    ', clc$nominal_entry, clc$normal_usage_entry, 9],
        ['DM                             ', clc$abbreviation_entry, clc$normal_usage_entry, 5],
        ['EARLIEST_RUN_TIME              ', clc$nominal_entry, clc$normal_usage_entry, 10],
        ['ERT                            ', clc$abbreviation_entry, clc$normal_usage_entry, 10],
        ['LATEST_RUN_TIME                ', clc$nominal_entry, clc$normal_usage_entry, 11],
        ['LF                             ', clc$abbreviation_entry, clc$normal_usage_entry, 12],
        ['LOGIN_FAMILY                   ', clc$nominal_entry, clc$normal_usage_entry, 12],
        ['LOGIN_USER                     ', clc$nominal_entry, clc$normal_usage_entry, 13],
        ['LRT                            ', clc$abbreviation_entry, clc$normal_usage_entry, 11],
        ['LU                             ', clc$abbreviation_entry, clc$normal_usage_entry, 13],
        ['PD                             ', clc$abbreviation_entry, clc$normal_usage_entry, 14],
        ['PURGE_DELAY                    ', clc$nominal_entry, clc$normal_usage_entry, 14],
        ['REMOTE_HOST_DIRECTIVE          ', clc$nominal_entry, clc$normal_usage_entry, 15],
        ['RHD                            ', clc$abbreviation_entry, clc$normal_usage_entry, 15],
        ['S                              ', clc$abbreviation_entry, clc$normal_usage_entry, 16],
        ['SFN                            ', clc$abbreviation_entry, clc$normal_usage_entry, 17],
        ['STATE                          ', clc$nominal_entry, clc$normal_usage_entry, 16],
        ['SYSTEM_FILE_NAME               ', clc$nominal_entry, clc$normal_usage_entry, 17]]
        ]
      ]
    ,
    'all'],
{ PARAMETER 3
    [[1, 0, clc$file_type],
    '$output'],
{ PARAMETER 4
    [[1, 0, clc$status_type]]];

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

    CONST
      p$system_file_name = 1,
      p$display_option = 2,
      p$output = 3,
      p$status = 4;

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

    TYPE
      qfile_name_list = array [1 .. * ] of record
        name: jmt$system_supplied_name,
        valid: boolean,
      recend;

    VAR
      attribute_options_p: ^jmt$qfile_attribute_options,
      attribute_results_keys_p: ^jmt$results_keys,
      attribute_results_p: ^jmt$qfile_attribute_results,
      attribute_results_seq_p: ^SEQ ( * ),
      candidate_name: jmt$name,
      display_all_files: boolean,
      display_option_list_p: ^clt$data_value,
      get_attribute: jmt$attribute_keys,
      get_key_count: 0 .. qfile_max_keys,
      get_key_number: 0 .. qfile_max_keys,
      get_keys: jmt$attribute_keys_set,
      inserted_system_file_name: boolean,
      key_index: 0 .. qfile_max_keys,
      name_count: 0 .. clc$max_list_size,
      name_index: 0 .. clc$max_list_size,
      name_list_p: ^clt$data_value,
      name_number: 0 .. clc$max_list_size,
      not_found_list_p: ^jmt$name_list,
      not_found_list_size: jmt$qfile_attribute_count,
      number_of_qfiles_found: jmt$qfile_attribute_count,
      qfile_found: boolean,
      qfile_index: jmt$qfile_attribute_count,
      qfile_name_list_p: ^qfile_name_list,
      qfiles_found_p: ^jmt$system_supplied_name_list,
      valid_name: jmt$name,
      valid_name_count: jmt$qfile_attribute_count,
      valid_name_index: jmt$qfile_attribute_count;

?? NEWTITLE := '[INLINE] add_to_attributes', EJECT ??

    PROCEDURE [INLINE] add_to_attributes
      (    get_attribute_key: jmt$attribute_keys);

      IF get_attribute_key IN get_keys THEN
        get_key_number := get_key_number + 1;
        attribute_results_keys_p^ [get_key_number] := get_attribute_key;
      IFEND;
    PROCEND add_to_attributes;
?? OLDTITLE, EJECT ??

    status.normal := TRUE;

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

{ Process SYSTEM_FILE_NAME parameter.

    display_all_files := FALSE;
    IF pvt [p$system_file_name].value^.kind = clc$keyword THEN { The only keyword is ALL.
      display_all_files := TRUE;
      PUSH attribute_options_p: [1 .. 1];
      attribute_options_p^ [1].key := jmc$null_attribute;
    ELSE
      name_list_p := pvt [p$system_file_name].value;
      name_count := clp$count_list_elements (pvt [p$system_file_name].value);
      PUSH attribute_options_p: [1 .. 1];
      attribute_options_p^ [1].key := jmc$system_supplied_name_list;
      candidate_name.kind := jmc$system_supplied_name;
      PUSH qfile_name_list_p: [1 .. name_count];
      valid_name_count := 0;
      FOR name_index := 1 TO name_count DO
        candidate_name.system_supplied_name := name_list_p^.element_value^.name_value;
        jmp$validate_name (candidate_name, valid_name, status);
        IF status.normal THEN
          valid_name_count := valid_name_count + 1;
          qfile_name_list_p^ [name_index].name := valid_name.system_supplied_name;
          qfile_name_list_p^ [name_index].valid := TRUE;
        ELSE
          qfile_name_list_p^ [name_index].name := candidate_name.system_supplied_name;
          qfile_name_list_p^ [name_index].valid := FALSE;
        IFEND;
        name_list_p := name_list_p^.link;
      FOREND;
      PUSH attribute_options_p^ [1].system_supplied_name_list: [1 .. valid_name_count];
      valid_name_index := 0;
      FOR name_index := 1 TO name_count DO
        IF qfile_name_list_p^ [name_index].valid THEN
          valid_name_index := valid_name_index + 1;
          attribute_options_p^ [1].system_supplied_name_list^ [valid_name_index] :=
                qfile_name_list_p^ [name_index].name;
        IFEND;
      FOREND;
    IFEND;

{ Process DISPLAY_OPTION parameter.

    get_keys := $jmt$attribute_keys_set [];
    get_key_count := 0;
    get_key_number := 0;
    IF pvt [p$display_option].value^.kind = clc$keyword THEN { The only keyword is ALL.
      get_keys := $jmt$attribute_keys_set [jmc$application_name, jmc$application_status, jmc$control_user,
            jmc$control_family, jmc$data_mode, jmc$deferred_by_application, jmc$deferred_by_operator,
            jmc$deferred_by_user, jmc$destination, jmc$earliest_run_time, jmc$latest_run_time, jmc$login_user,
            jmc$login_family, jmc$purge_delay, jmc$remote_host_directive, jmc$qfile_state,
            jmc$system_file_name];
      get_key_count := qfile_max_keys;
    ELSE
      display_option_list_p := pvt [p$display_option].value;
      WHILE display_option_list_p <> NIL DO
        jmp$get_attribute_index (display_option_list_p^.element_value^.keyword_value, get_attribute);
        IF NOT (get_attribute IN get_keys) THEN
          get_keys := get_keys + $jmt$attribute_keys_set [get_attribute];
          get_key_count := get_key_count + 1;
        IFEND;
        display_option_list_p := display_option_list_p^.link;
      WHILEND;
    IFEND;

    IF NOT display_all_files THEN
      inserted_system_file_name := NOT (jmc$system_file_name IN get_keys);
      get_keys := get_keys + $jmt$attribute_keys_set [jmc$system_file_name];
      IF inserted_system_file_name THEN
        get_key_count := get_key_count + 1;
      IFEND;
    IFEND;

    PUSH attribute_results_keys_p: [1 .. get_key_count];
    add_to_attributes (jmc$application_name);
    add_to_attributes (jmc$application_status);
    add_to_attributes (jmc$control_family);
    add_to_attributes (jmc$control_user);
    add_to_attributes (jmc$data_mode);
    add_to_attributes (jmc$deferred_by_application);
    add_to_attributes (jmc$deferred_by_operator);
    add_to_attributes (jmc$deferred_by_user);
    add_to_attributes (jmc$destination);
    add_to_attributes (jmc$earliest_run_time);
    add_to_attributes (jmc$latest_run_time);
    add_to_attributes (jmc$login_family);
    add_to_attributes (jmc$login_user);
    add_to_attributes (jmc$purge_delay);
    add_to_attributes (jmc$remote_host_directive);
    add_to_attributes (jmc$qfile_state);
    add_to_attributes (jmc$system_file_name);

    RESET manqf_work_area.sequence_pointer;
    jmp$util_get_qfile_attributes (attribute_options_p, attribute_results_keys_p,
          manqf_work_area.sequence_pointer, attribute_results_p, number_of_qfiles_found, status);

    IF NOT status.normal THEN
      IF status.condition = jme$no_qfiles_were_found THEN
        number_of_qfiles_found := 0;
        status.normal := TRUE;
      ELSE
        RETURN; {----->
      IFEND;
    IFEND;

{ Build a list of queue file names that were not found.

    not_found_list_size := 0;
    IF NOT display_all_files THEN
      PUSH not_found_list_p: [1 .. name_count];
      IF number_of_qfiles_found > 0 THEN
        PUSH qfiles_found_p: [1 .. number_of_qfiles_found];
        FOR qfile_index := 1 TO number_of_qfiles_found DO
          FOR key_index := 1 TO UPPERBOUND (attribute_results_p^ [qfile_index]^) DO
            IF attribute_results_p^ [qfile_index]^ [key_index].key = jmc$system_file_name THEN
              qfiles_found_p^ [qfile_index] := attribute_results_p^ [qfile_index]^ [key_index].
                    system_file_name;
              IF inserted_system_file_name THEN
                attribute_results_p^ [qfile_index]^ [key_index].key := jmc$null_attribute;
              IFEND;
            IFEND;
          FOREND;
        FOREND;
      IFEND;

      FOR name_number := 1 TO name_count DO
        IF qfile_name_list_p^ [name_number].valid THEN
          qfile_found := FALSE;
          qfile_index := 1;
          WHILE NOT qfile_found AND (qfile_index <= number_of_qfiles_found) DO
            qfile_found := (qfile_name_list_p^ [name_number].name = qfiles_found_p^ [qfile_index]);
            qfile_index := qfile_index + 1;
          WHILEND;
          IF NOT qfile_found THEN
            not_found_list_size := not_found_list_size + 1;
            not_found_list_p^ [not_found_list_size].system_supplied_name :=
                  qfile_name_list_p^ [name_number].name;
          IFEND;
        ELSE { not valid
          not_found_list_size := not_found_list_size + 1;
          not_found_list_p^ [not_found_list_size].system_supplied_name :=
                qfile_name_list_p^ [name_number].name;
        IFEND;
      FOREND;
    IFEND;

    IF not_found_list_size = 0 THEN
      not_found_list_p := NIL;
    IFEND;

    attribute_results_seq_p := #SEQ (attribute_results_p);

    jmp$display_attributes (pvt [p$output].value^.file_value^, attribute_results_seq_p,
          number_of_qfiles_found, { header_display_list_p } NIL, not_found_list_p, not_found_list_size,
          'display_queue_file_attribute', status);

  PROCEND display_queue_file_attribute;
?? OLDTITLE ??
?? NEWTITLE := 'queue_file_attributes', EJECT ??

{ This procedure is the function processor for the MANQF $QUEUE_FILE_ATTRIBUTES function.

  PROCEDURE queue_file_attributes
    (    parameter_list: clt$parameter_list;
     VAR work_area: ^clt$work_area;
     VAR result: ^clt$data_value;
     VAR status: ost$status);

{ FUNCTION (jmm$$manqf_quefa) $queue_file_attributes (
{   queue_files: any of
{       key
{         all
{       keyend
{       list of name
{     anyend = all
{   attributes: any of
{       key
{         all
{       keyend
{       list of key
{         (application_name, an)
{         (application_status, as)
{         (control_family, cf)
{         (control_user, cu)
{         (data_mode, dm)
{         (deferred_by_application, dba)
{         (deferred_by_operator, dbo)
{         (deferred_by_user, dbu)
{         (destination, d)
{         (earliest_run_time, ert)
{         (latest_run_time, lrt)
{         (login_family, lf)
{         (login_user, lu)
{         (purge_delay, pd)
{         (remote_host_directive, rhd)
{         (state, s)
{         (system_file_name, sfn)
{       keyend
{     anyend = all
{   )

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

  VAR
    pdt: [STATIC, READ, cls$declaration_section] record
      header: clt$pdt_header,
      names: array [1 .. 2] of clt$pdt_parameter_name,
      parameters: array [1 .. 2] of clt$pdt_parameter,
      type1: 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$list_type_qualifier_v2,
          element_type_spec: record
            header: clt$type_specification_header,
            qualifier: clt$name_type_qualifier,
          recend,
        recend,
        default_value: string (3),
      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$list_type_qualifier_v2,
          element_type_spec: record
            header: clt$type_specification_header,
            qualifier: clt$keyword_type_qualifier,
            keyword_specs: array [1 .. 34] of clt$keyword_specification,
          recend,
        recend,
        default_value: string (3),
      recend,
    recend := [
    [1,
    [102, 12, 20, 15, 50, 54, 929],
    clc$function, 2, 2, 0, 0, 0, 0, 0, 'JMM$$MANQF_QUEFA'], [
    ['ATTRIBUTES                     ',clc$nominal_entry, 2],
    ['QUEUE_FILES                    ',clc$nominal_entry, 1]],
    [
{ PARAMETER 1
    [2, clc$normal_usage_entry, clc$non_secure_parameter,
    $clt$parameter_spec_methods[clc$specify_positionally],
    clc$pass_by_value, clc$immediate_evaluation, clc$standard_parameter_checking, 85,
  clc$optional_default_parameter, 0, 3],
{ PARAMETER 2
    [1, clc$normal_usage_entry, clc$non_secure_parameter,
    $clt$parameter_spec_methods[clc$specify_positionally],
    clc$pass_by_value, clc$immediate_evaluation, clc$standard_parameter_checking, 1345,
  clc$optional_default_parameter, 0, 3]],
{ PARAMETER 1
    [[1, 0, clc$union_type], [[clc$keyword_type, clc$list_type],
    FALSE, 2],
    44, [[1, 0, clc$keyword_type], [1], [
      ['ALL                            ', clc$nominal_entry, clc$normal_usage_entry, 1]]
      ],
    21, [[1, 0, clc$list_type], [5, 1, clc$max_list_size, 0, FALSE, FALSE],
        [[1, 0, clc$name_type], [1, osc$max_name_size]]
      ]
    ,
    'all'],
{ PARAMETER 2
    [[1, 0, clc$union_type], [[clc$keyword_type, clc$list_type],
    FALSE, 2],
    44, [[1, 0, clc$keyword_type], [1], [
      ['ALL                            ', clc$nominal_entry, clc$normal_usage_entry, 1]]
      ],
    1281, [[1, 0, clc$list_type], [1265, 1, clc$max_list_size, 0, FALSE, FALSE],
        [[1, 0, clc$keyword_type], [34], [
        ['AN                             ', clc$abbreviation_entry, clc$normal_usage_entry, 1],
        ['APPLICATION_NAME               ', clc$nominal_entry, clc$normal_usage_entry, 1],
        ['APPLICATION_STATUS             ', clc$nominal_entry, clc$normal_usage_entry, 2],
        ['AS                             ', clc$abbreviation_entry, clc$normal_usage_entry, 2],
        ['CF                             ', clc$abbreviation_entry, clc$normal_usage_entry, 3],
        ['CONTROL_FAMILY                 ', clc$nominal_entry, clc$normal_usage_entry, 3],
        ['CONTROL_USER                   ', clc$nominal_entry, clc$normal_usage_entry, 4],
        ['CU                             ', clc$abbreviation_entry, clc$normal_usage_entry, 4],
        ['D                              ', clc$abbreviation_entry, clc$normal_usage_entry, 9],
        ['DATA_MODE                      ', clc$nominal_entry, clc$normal_usage_entry, 5],
        ['DBA                            ', clc$abbreviation_entry, clc$normal_usage_entry, 6],
        ['DBO                            ', clc$abbreviation_entry, clc$normal_usage_entry, 7],
        ['DBU                            ', clc$abbreviation_entry, clc$normal_usage_entry, 8],
        ['DEFERRED_BY_APPLICATION        ', clc$nominal_entry, clc$normal_usage_entry, 6],
        ['DEFERRED_BY_OPERATOR           ', clc$nominal_entry, clc$normal_usage_entry, 7],
        ['DEFERRED_BY_USER               ', clc$nominal_entry, clc$normal_usage_entry, 8],
        ['DESTINATION                    ', clc$nominal_entry, clc$normal_usage_entry, 9],
        ['DM                             ', clc$abbreviation_entry, clc$normal_usage_entry, 5],
        ['EARLIEST_RUN_TIME              ', clc$nominal_entry, clc$normal_usage_entry, 10],
        ['ERT                            ', clc$abbreviation_entry, clc$normal_usage_entry, 10],
        ['LATEST_RUN_TIME                ', clc$nominal_entry, clc$normal_usage_entry, 11],
        ['LF                             ', clc$abbreviation_entry, clc$normal_usage_entry, 12],
        ['LOGIN_FAMILY                   ', clc$nominal_entry, clc$normal_usage_entry, 12],
        ['LOGIN_USER                     ', clc$nominal_entry, clc$normal_usage_entry, 13],
        ['LRT                            ', clc$abbreviation_entry, clc$normal_usage_entry, 11],
        ['LU                             ', clc$abbreviation_entry, clc$normal_usage_entry, 13],
        ['PD                             ', clc$abbreviation_entry, clc$normal_usage_entry, 14],
        ['PURGE_DELAY                    ', clc$nominal_entry, clc$normal_usage_entry, 14],
        ['REMOTE_HOST_DIRECTIVE          ', clc$nominal_entry, clc$normal_usage_entry, 15],
        ['RHD                            ', clc$abbreviation_entry, clc$normal_usage_entry, 15],
        ['S                              ', clc$abbreviation_entry, clc$normal_usage_entry, 16],
        ['SFN                            ', clc$abbreviation_entry, clc$normal_usage_entry, 17],
        ['STATE                          ', clc$nominal_entry, clc$normal_usage_entry, 16],
        ['SYSTEM_FILE_NAME               ', clc$nominal_entry, clc$normal_usage_entry, 17]]
        ]
      ]
    ,
    'all']];

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

    CONST
      p$queue_files = 1,
      p$attributes = 2;

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

    TYPE
      qfile_name_list = array [1 .. * ] of record
        name: jmt$system_supplied_name,
        valid: boolean,
      recend;

    VAR
      attribute_options_p: ^jmt$qfile_attribute_options,
      attribute_results_keys_p: ^jmt$results_keys,
      attribute_results_p: ^jmt$qfile_attribute_results,
      attribute_work_area_p: ^jmt$work_area,
      candidate_name: jmt$name,
      display_all_files: boolean,
      display_option_list_p: ^clt$data_value,
      found: boolean,
      get_attribute: jmt$attribute_keys,
      get_key_count: 0 .. qfile_max_keys,
      get_key_number: 0 .. qfile_max_keys,
      get_keys: jmt$attribute_keys_set,
      inserted_system_file_name: boolean,
      key_array_index: 0 .. qfile_max_keys,
      key_index: 0 .. qfile_max_keys,
      key_names_p: ^array [1 .. * ] of ost$name,
      name_count: 0 .. clc$max_list_size,
      name_index: 0 .. clc$max_list_size,
      name_list_p: ^clt$data_value,
      number_of_qfiles_found: jmt$qfile_attribute_count,
      qfile_index: jmt$qfile_attribute_count,
      qfile_name_list_p: ^qfile_name_list,
      size_of_sequence: ost$non_negative_integers,
      valid_name: jmt$name,
      valid_name_count: jmt$qfile_attribute_count,
      valid_name_index: jmt$qfile_attribute_count,
      value_pp: ^^clt$data_value;

?? NEWTITLE := '[INLINE] add_to_attributes', EJECT ??

{ PURPOSE:
{   The purpose of this procedure is to add an attribute key to an array of keys.

    PROCEDURE [INLINE] add_to_attributes
      (    get_attribute_key: jmt$attribute_keys);

      IF get_attribute_key IN get_keys THEN
        get_key_number := get_key_number + 1;
        attribute_results_keys_p^ [get_key_number] := get_attribute_key;
      IFEND;
    PROCEND add_to_attributes;
?? OLDTITLE ??
?? NEWTITLE := 'build_attributes', EJECT ??

{ PURPOSE:
{   The purpose of this procedure is to build the attributes record for a
{ specified queue file.

    PROCEDURE build_attributes
      (    key_names_p: ^array [1 .. * ] of ost$name;
           attribute_result_p: ^array [1 .. * ] of jmt$qfile_attribute_result;
       VAR work_area_p: ^clt$work_area;
       VAR result_p: ^clt$data_value);

      CONST
        none_keyword = 'NONE';

      VAR
        date_time: clt$date_time,
        field_index: 0 .. qfile_max_keys,
        field_values_p: ^array [1 .. * ] of clt$field_value,
        key_index: 1 .. qfile_max_keys;

      clp$make_record_value (UPPERBOUND (key_names_p^), work_area_p, result_p);
      field_values_p := result_p^.field_values;
      field_index := 0;

      FOR key_index := 1 TO UPPERBOUND (attribute_result_p^) DO
        IF attribute_result_p^ [key_index].key = jmc$null_attribute THEN

{ Skip this entry.

        ELSE
          field_index := field_index + 1;
          field_values_p^ [field_index].name := key_names_p^ [field_index];
          CASE attribute_result_p^ [key_index].key OF
          = jmc$system_file_name =
            clp$make_name_value (attribute_result_p^ [key_index].system_file_name, work_area_p,
                  field_values_p^ [field_index].value);

          = jmc$application_name =
            clp$make_name_value (attribute_result_p^ [key_index].application_name, work_area_p,
                  field_values_p^ [field_index].value);

          = jmc$data_mode =
            IF attribute_result_p^ [key_index].data_mode = jmc$coded_data THEN
              clp$make_keyword_value ('CODED', work_area_p, field_values_p^ [field_index].value);
            ELSE
              clp$make_keyword_value ('TRANSPARENT', work_area_p, field_values_p^ [field_index].value);
            IFEND;

          = jmc$deferred_by_application =
            clp$make_boolean_value (attribute_result_p^ [key_index].deferred_by_application,
                  clc$yes_no_boolean, work_area_p, field_values_p^ [field_index].value);

          = jmc$destination =
            clp$make_name_value (attribute_result_p^ [key_index].
                  destination, work_area_p, field_values_p^ [field_index].value);

          = jmc$earliest_run_time =
            IF attribute_result_p^ [key_index].earliest_run_time.specified THEN
              date_time.value := attribute_result_p^ [key_index].earliest_run_time.date_time;
              date_time.date_specified := TRUE;
              date_time.time_specified := TRUE;
              clp$make_date_time_value (date_time, work_area_p, field_values_p^ [field_index].value);
            ELSE
              clp$make_keyword_value (none_keyword, work_area_p, field_values_p^ [field_index].value);
            IFEND;

          = jmc$latest_run_time =
            IF attribute_result_p^ [key_index].latest_run_time.specified THEN
              date_time.value := attribute_result_p^ [key_index].latest_run_time.date_time;
              date_time.date_specified := TRUE;
              date_time.time_specified := TRUE;
              clp$make_date_time_value (date_time, work_area_p, field_values_p^ [field_index].value);
            ELSE
              clp$make_keyword_value (none_keyword, work_area_p, field_values_p^ [field_index].value);
            IFEND;

          = jmc$purge_delay =
            IF attribute_result_p^ [key_index].purge_delay^.specified THEN
              clp$make_time_increment_value (^attribute_result_p^ [key_index].purge_delay^.time_increment,
                    work_area_p, field_values_p^ [field_index].value);
            ELSE
              clp$make_keyword_value (none_keyword, work_area_p, field_values_p^ [field_index].value);
            IFEND;

          = jmc$remote_host_directive =
            IF attribute_result_p^ [key_index].remote_host_directive^.size > 0 THEN
              clp$make_string_value (attribute_result_p^ [key_index].
                    remote_host_directive^.parameters (1, attribute_result_p^ [key_index].
                    remote_host_directive^.size), work_area_p, field_values_p^ [field_index].value);
            ELSE
              clp$make_string_value ('', work_area_p, field_values_p^ [field_index].value);
            IFEND;

          = jmc$qfile_state =
            IF attribute_result_p^ [key_index].qfile_state = jmc$deferred_qfile THEN
              clp$make_keyword_value ('DEFERRED', work_area_p, field_values_p^ [field_index].value);
            ELSEIF attribute_result_p^ [key_index].qfile_state = jmc$queued_qfile THEN
              clp$make_keyword_value ('QUEUED', work_area_p, field_values_p^ [field_index].value);
            ELSEIF attribute_result_p^ [key_index].qfile_state = jmc$initiated_qfile THEN
              clp$make_keyword_value ('INITIATED', work_area_p, field_values_p^ [field_index].value);
            ELSEIF attribute_result_p^ [key_index].qfile_state = jmc$terminated_qfile THEN
              clp$make_keyword_value ('TERMINATED', work_area_p, field_values_p^ [field_index].value);
            ELSE { attribute_result_p^ [key_index].qfile_state = jmc$completed_qfile
              clp$make_keyword_value ('COMPLETED', work_area_p, field_values_p^ [field_index].value);
            IFEND;
          ELSE
            ;

          CASEND;
        IFEND;
      FOREND;

    PROCEND build_attributes;
?? OLDTITLE ??
?? NEWTITLE := 'build_unspecified_attributes', EJECT ??

{ PURPOSE:
{   The purpose of this procedure is to build the attributes record for a
{ queue file that was not found or whose name was invalid.

    PROCEDURE build_unspecified_attributes
      (    key_names_p: ^array [1 .. * ] of ost$name;
           qfile_name: jmt$system_supplied_name;
       VAR work_area_p: ^clt$work_area;
       VAR result_p: ^clt$data_value);

      VAR
        field_index: 0 .. qfile_max_keys,
        field_values_p: ^array [1 .. * ] of clt$field_value;

      clp$make_record_value (UPPERBOUND (key_names_p^), work_area_p, result_p);
      field_values_p := result_p^.field_values;

      FOR field_index := 1 TO UPPERBOUND (key_names_p^) DO
        field_values_p^ [field_index].name := key_names_p^ [field_index];
        IF key_names_p^ [field_index] = 'SYSTEM_FILE_NAME' THEN
          clp$make_name_value (qfile_name, work_area_p, field_values_p^ [field_index].value);
        ELSE
          clp$make_unspecified_value (work_area_p, field_values_p^ [field_index].value);
        IFEND;
      FOREND;

    PROCEND build_unspecified_attributes;
?? OLDTITLE, EJECT ??

    status.normal := TRUE;
    clp$evaluate_parameters (parameter_list, #SEQ (pdt), NIL, ^pvt, status);
    IF NOT status.normal THEN
      RETURN; {----->
    IFEND;

    result := NIL;
    value_pp := ^result;
    attribute_results_p := NIL;

{ Process QUEUE_FILES parameter.

    display_all_files := FALSE;
    IF pvt [p$queue_files].value^.kind = clc$keyword THEN { The only keyword is ALL.
      display_all_files := TRUE;
      PUSH attribute_options_p: [1 .. 1];
      attribute_options_p^ [1].key := jmc$null_attribute;
    ELSE { A list of queue files was specified.
      name_list_p := pvt [p$queue_files].value;
      candidate_name.kind := jmc$system_supplied_name;
      PUSH attribute_options_p: [1 .. 1];
      attribute_options_p^ [1].key := jmc$system_supplied_name_list;

      name_count := clp$count_list_elements (pvt [p$queue_files].value);

{ Check if names given were valid system-supplied names. Build a list of the
{ names marked valid or invalid so later we can build an attributes record with unspecified values
{ for each invalid name.

      PUSH qfile_name_list_p: [1 .. name_count];
      valid_name_count := 0;
      FOR name_index := 1 TO name_count DO
        candidate_name.system_supplied_name := name_list_p^.element_value^.name_value;
        jmp$validate_name (candidate_name, valid_name, status);
        IF status.normal THEN
          valid_name_count := valid_name_count + 1;
          qfile_name_list_p^ [name_index].name := valid_name.system_supplied_name;
          qfile_name_list_p^ [name_index].valid := TRUE;
        ELSE
          status.normal := TRUE;
          qfile_name_list_p^ [name_index].name := candidate_name.system_supplied_name;
          qfile_name_list_p^ [name_index].valid := FALSE;
        IFEND;
        name_list_p := name_list_p^.link;
      FOREND;
      PUSH attribute_options_p^ [1].system_supplied_name_list: [1 .. valid_name_count];
      valid_name_index := 0;
      FOR name_index := 1 TO name_count DO
        IF qfile_name_list_p^ [name_index].valid THEN
          valid_name_index := valid_name_index + 1;
          attribute_options_p^ [1].system_supplied_name_list^ [valid_name_index] :=
                qfile_name_list_p^ [name_index].name;
        IFEND;
      FOREND;
    IFEND;

{ Process ATTRIBUTES parameter.

    get_keys := $jmt$attribute_keys_set [];
    get_key_count := 0;
    get_key_number := 0;
    IF pvt [p$attributes].value^.kind = clc$keyword THEN { The only keyword is ALL.
      get_keys := $jmt$attribute_keys_set [jmc$application_name, jmc$application_status, jmc$control_user,
            jmc$control_family, jmc$data_mode, jmc$deferred_by_application, jmc$deferred_by_operator,
            jmc$deferred_by_user, jmc$destination, jmc$earliest_run_time, jmc$latest_run_time, jmc$login_user,
            jmc$login_family, jmc$purge_delay, jmc$remote_host_directive, jmc$qfile_state,
            jmc$system_file_name];
      get_key_count := qfile_max_keys;
    ELSE
      display_option_list_p := pvt [p$attributes].value;
      WHILE display_option_list_p <> NIL DO
        jmp$get_attribute_index (display_option_list_p^.element_value^.keyword_value, get_attribute);
        IF NOT (get_attribute IN get_keys) THEN
          get_keys := get_keys + $jmt$attribute_keys_set [get_attribute];
          get_key_count := get_key_count + 1;
        IFEND;
        display_option_list_p := display_option_list_p^.link;
      WHILEND;
    IFEND;

    IF NOT display_all_files THEN
      inserted_system_file_name := NOT (jmc$system_file_name IN get_keys);
      get_keys := get_keys + $jmt$attribute_keys_set [jmc$system_file_name];
      IF inserted_system_file_name THEN
        get_key_count := get_key_count + 1;
      IFEND;
    IFEND;

    PUSH attribute_results_keys_p: [1 .. get_key_count];

{ Later code depends on jmc$system_file_name being the first key.
    add_to_attributes (jmc$system_file_name);
    add_to_attributes (jmc$application_name);
    add_to_attributes (jmc$application_status);
    add_to_attributes (jmc$control_family);
    add_to_attributes (jmc$control_user);
    add_to_attributes (jmc$data_mode);
    add_to_attributes (jmc$deferred_by_application);
    add_to_attributes (jmc$deferred_by_operator);
    add_to_attributes (jmc$deferred_by_user);
    add_to_attributes (jmc$destination);
    add_to_attributes (jmc$earliest_run_time);
    add_to_attributes (jmc$latest_run_time);
    add_to_attributes (jmc$login_family);
    add_to_attributes (jmc$login_user);
    add_to_attributes (jmc$purge_delay);
    add_to_attributes (jmc$remote_host_directive);
    add_to_attributes (jmc$qfile_state);

    RESET manqf_work_area.sequence_pointer;
    jmp$util_get_qfile_attributes (attribute_options_p, attribute_results_keys_p,
          manqf_work_area.sequence_pointer, attribute_results_p, number_of_qfiles_found, status);

    IF NOT status.normal THEN
      IF status.condition = jme$no_qfiles_were_found THEN
        status.normal := TRUE;
        clp$make_list_value (work_area, result);
      IFEND;
      IF display_all_files THEN
        RETURN; {----->
      IFEND;
    IFEND;

{ Build results.

    IF display_all_files THEN
      PUSH key_names_p: [1 .. get_key_count];
      FOR key_index := 1 TO get_key_count DO
        jmp$get_attribute_name (attribute_results_keys_p^ [key_index], key_names_p^ [key_index]);
      FOREND;

      FOR name_index := 1 TO number_of_qfiles_found DO
        clp$make_list_value (work_area, value_pp^);
        build_attributes (key_names_p, attribute_results_p^ [name_index], work_area,
              value_pp^^.element_value);
        value_pp := ^value_pp^^.link;
      FOREND;
    ELSE
      IF inserted_system_file_name THEN
        PUSH key_names_p: [1 .. (get_key_count - 1)];
        key_array_index := 0;

      /get_key_names/
        FOR key_index := 1 TO get_key_count DO
          IF attribute_results_keys_p^ [key_index] = jmc$system_file_name THEN
            CYCLE /get_key_names/; {----->
          ELSE
            key_array_index := key_array_index + 1;
            jmp$get_attribute_name (attribute_results_keys_p^ [key_index], key_names_p^ [key_array_index]);
          IFEND;
        FOREND /get_key_names/;
      ELSE
        PUSH key_names_p: [1 .. get_key_count];
        FOR key_index := 1 TO get_key_count DO
          jmp$get_attribute_name (attribute_results_keys_p^ [key_index], key_names_p^ [key_index]);
        FOREND;
      IFEND;

{ For each queue file specified, if it was valid and found, then build attributes record from results,
{ otherwise build attributes record with unspecified values.

      FOR name_index := 1 TO name_count DO
        clp$make_list_value (work_area, value_pp^);
        IF qfile_name_list_p^ [name_index].valid THEN
          qfile_index := 1;
          found := FALSE;
          IF attribute_results_p <> NIL THEN

          /find_attributes_for_sfn/
            WHILE (NOT found) AND (qfile_index <= number_of_qfiles_found) DO
              IF attribute_results_p^ [qfile_index]^ [1].key = jmc$system_file_name THEN
                IF qfile_name_list_p^ [name_index].name = attribute_results_p^ [qfile_index]^ [1].
                      system_file_name THEN
                  found := TRUE;
                  EXIT /find_attributes_for_sfn/; {----->
                IFEND;
              IFEND;
              qfile_index := qfile_index + 1;
            WHILEND /find_attributes_for_sfn/;
          IFEND;
          IF found THEN
            IF inserted_system_file_name THEN
              attribute_results_p^ [qfile_index]^ [1].key := jmc$null_attribute;
            IFEND;
            build_attributes (key_names_p, attribute_results_p^ [qfile_index], work_area,
                  value_pp^^.element_value);
          ELSE
            build_unspecified_attributes (key_names_p, qfile_name_list_p^ [name_index].name, work_area,
                  value_pp^^.element_value);
          IFEND;
        ELSE { not valid
          build_unspecified_attributes (key_names_p, qfile_name_list_p^ [name_index].name, work_area,
                value_pp^^.element_value);
        IFEND;
        value_pp := ^value_pp^^.link;
      FOREND;
    IFEND;

  PROCEND queue_file_attributes;
?? OLDTITLE ??
?? NEWTITLE := 'terminate_queue_file', EJECT ??

{ This procedure is the command processor for the terminate_queue_file subcommand.

  PROCEDURE terminate_queue_file
    (    parameter_list: clt$parameter_list;
     VAR status: ost$status);

{ PROCEDURE (jmm$manqf_terqf) terminate_queue_file, terminate_queue_files, ..
{ terqf (
{   name, names, n: list of name = $required
{   status)

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

  VAR
    pdt: [STATIC, READ, cls$declaration_section] record
      header: clt$pdt_header,
      names: array [1 .. 4] of clt$pdt_parameter_name,
      parameters: array [1 .. 2] of clt$pdt_parameter,
      type1: record
        header: clt$type_specification_header,
        qualifier: clt$list_type_qualifier_v2,
        element_type_spec: record
          header: clt$type_specification_header,
          qualifier: clt$name_type_qualifier,
        recend,
      recend,
      type2: record
        header: clt$type_specification_header,
      recend,
    recend := [
    [1,
    [90, 3, 30, 12, 57, 48, 329],
    clc$command, 4, 2, 1, 0, 0, 0, 2, 'JMM$MANQF_TERQF'], [
    ['N                              ',clc$abbreviation_entry, 1],
    ['NAME                           ',clc$nominal_entry, 1],
    ['NAMES                          ',clc$alias_entry, 1],
    ['STATUS                         ',clc$nominal_entry, 2]],
    [
{ 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, 21, clc$required_parameter, 0, 0],
{ PARAMETER 2
    [4, 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$list_type], [5, 1, clc$max_list_size, 0, FALSE, FALSE],
      [[1, 0, clc$name_type], [1, osc$max_name_size]]
    ],
{ PARAMETER 2
    [[1, 0, clc$status_type]]];

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

    CONST
      p$name = 1,
      p$status = 2;

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

    VAR
      good_name: jmt$name,
      ignore_status: ost$status,
      local_status: ost$status,
      name_list_p: ^clt$data_value,
      potential_name: jmt$name;

    status.normal := TRUE;
    IF NOT avp$system_operator () THEN
      osp$set_status_abnormal (jmc$job_management_id, ofe$sou_not_active, 'SYSTEM_OPERATION', status);
      RETURN; {----->
    IFEND;
    clp$evaluate_parameters (parameter_list, #SEQ (pdt), NIL, ^pvt, status);
    IF NOT status.normal THEN
      RETURN; {----->
    IFEND;

{ Process NAME parameter.
{ Call jmp$validate_name to ensure that the caller supplied one of the forms of the
{ system-supplied name.  Interface jmp$util_terminate_qfile requires a system-supplied name,
{ not just a name.

    name_list_p := pvt [p$name].value;
    potential_name.kind := jmc$system_supplied_name;
    WHILE name_list_p <> NIL DO
      potential_name.system_supplied_name := name_list_p^.element_value^.name_value;
      jmp$validate_name (potential_name, good_name, status);
      IF NOT status.normal THEN
        RETURN; {----->
      IFEND;

      jmp$util_terminate_qfile (good_name.system_supplied_name, { termination_options_p } NIL, local_status);
      IF NOT local_status.normal THEN
        display_status_error (local_status, ignore_status);
      IFEND;
      name_list_p := name_list_p^.link;
    WHILEND;

    IF error_file_open THEN
      close_error_file (ignore_status);
    IFEND;
  PROCEND terminate_queue_file;
?? OLDTITLE ??
*copy clp$new_page_procedure
?? OLDTITLE ??
MODEND jmm$manage_qfile_utility;
