?? RIGHT := 110 ??
?? NEWTITLE := 'NOS/VE Statistics Facility: Limit Commands and Functions' ??
MODULE sfm$limit_commands_functions;

{ PURPOSE:
{   This module contains SCL command processors to update and retrieve job limit
{   information.
{
{ DESIGN:
{   The command processors in this module simply convert the parameter values
{   specified on the command into their internal formats (when necessary) and call
{   the appropriate statistics facility program interface.(from
{   SFM$LIMIT_INTERFACES)

?? NEWTITLE := 'Global Declarations referenced by this module', EJECT ??
?? PUSH (LISTEXT := ON) ??
*copyc avc$system_defined_limit_names
*copyc cle$work_area_overflow
*copyc clt$work_area
*copyc sfc$unlimited
*copyc sfe$condition_codes
?? POP ??
*copyc clp$build_standard_title
*copyc clp$close_display
*copyc clp$convert_integer_to_rjstring
*copyc clp$convert_integer_to_string
*copyc clp$evaluate_parameters
*copyc clp$new_display_line
*copyc clp$open_display_reference
*copyc clp$put_display
*copyc clp$reset_for_next_display_page
*copyc clp$trimmed_string_size
*copyc osp$disestablish_cond_handler
*copyc osp$establish_block_exit_hndlr
*copyc osp$set_status_abnormal
*copyc sfp$change_job_warning_limit
*copyc sfp$get_all_job_limits
*copyc sfp$get_job_limit
*copyc sfp$get_job_limit_count
?? OLDTITLE ??
?? NEWTITLE := '[XDCL] sfp$_change_job_limit', EJECT ??

{ PURPOSE:
{   This is the command processor for CHANGE_JOB_LIMIT.

  PROCEDURE [XDCL] sfp$_change_job_limit
    (    parameter_list: clt$parameter_list;
     VAR status: ost$status);

{ PROCEDURE (osm$chajl) change_job_limit, chajl (
{   name, n: any of
{       key
{         cpu_time, magnetic_tape, permanent_file_space, sru, task, temporary_file_space
{       keyend
{       name
{     anyend = $required
{   warning_limit, resource_limit, rl, wl: any of
{       key
{         unlimited
{       keyend
{       integer
{     anyend = $required
{   status)

?? PUSH (LISTEXT := ON) ??

    VAR
      pdt: [STATIC, READ, cls$declaration_section] record
        header: clt$pdt_header,
        names: array [1 .. 7] of clt$pdt_parameter_name,
        parameters: array [1 .. 3] 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 .. 6] 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,
        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$integer_type_qualifier,
          recend,
        recend,
        type3: record
          header: clt$type_specification_header,
        recend,
      recend := [[1, [88, 10, 19, 15, 10, 26, 263], clc$command, 7, 3, 2, 0, 0, 0, 3, 'OSM$CHAJL'],
            [['N                              ', clc$abbreviation_entry, 1],
            ['NAME                           ', clc$nominal_entry, 1],
            ['RESOURCE_LIMIT                 ', clc$alias_entry, 2],
            ['RL                             ', clc$alias_entry, 2],
            ['STATUS                         ', clc$nominal_entry, 3],
            ['WARNING_LIMIT                  ', clc$nominal_entry, 2],
            ['WL                             ', clc$abbreviation_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, 254, clc$required_parameter, 0, 0],

{ PARAMETER 2

      [6, 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, 84, 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$union_type], [[clc$keyword_type, clc$name_type], FALSE, 2], 229,
            [[1, 0, clc$keyword_type], [6], [['CPU_TIME                       ', clc$nominal_entry,
            clc$normal_usage_entry, 1], ['MAGNETIC_TAPE                  ', clc$nominal_entry,
            clc$normal_usage_entry, 2], ['PERMANENT_FILE_SPACE           ', clc$nominal_entry,
            clc$normal_usage_entry, 3], ['SRU                            ', clc$nominal_entry,
            clc$normal_usage_entry, 4], ['TASK                           ', clc$nominal_entry,
            clc$normal_usage_entry, 5], ['TEMPORARY_FILE_SPACE           ', clc$nominal_entry,
            clc$normal_usage_entry, 6]]], 5, [[1, 0, clc$name_type], [1, osc$max_name_size]]],

{ PARAMETER 2

      [[1, 0, clc$union_type], [[clc$integer_type, clc$keyword_type], FALSE, 2], 44,
            [[1, 0, clc$keyword_type], [1], [['UNLIMITED                      ', clc$nominal_entry,
            clc$normal_usage_entry, 1]]], 20, [[1, 0, clc$integer_type],
            [clc$min_integer, clc$max_integer, 10]]],

{ PARAMETER 3

      [[1, 0, clc$status_type]]];

?? POP ??

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

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

    VAR
      limit_name: ost$name,
      warning_limit: sft$counter;

    status.normal := TRUE;

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

    IF pvt [p$name].value^.kind = clc$keyword THEN
      limit_name := pvt [p$name].value^.keyword_value;
    ELSE
      limit_name := pvt [p$name].value^.name_value;
    IFEND;

    IF pvt [p$warning_limit].value^.kind = clc$keyword THEN
      warning_limit := sfc$unlimited;
    ELSE
      warning_limit := pvt [p$warning_limit].value^.integer_value.value;
    IFEND;

    sfp$change_job_warning_limit (limit_name, warning_limit, status);

  PROCEND sfp$_change_job_limit;
?? OLDTITLE ??
?? NEWTITLE := '[XDCL] sfp$_display_job_limit', EJECT ??

{ PURPOSE:
{   This is the command processor for DISPLAY_JOB_LIMIT.

  PROCEDURE [XDCL] sfp$_display_job_limit
    (    parameter_list: clt$parameter_list;
     VAR status: ost$status);

{ PROCEDURE (osm$disjl) display_job_limit, display_job_limits, disjl (
{   output, o: file = $output
{   status)

?? PUSH (LISTEXT := ON) ??

    VAR
      pdt: [STATIC, READ, cls$declaration_section] record
        header: clt$pdt_header,
        names: array [1 .. 3] of clt$pdt_parameter_name,
        parameters: array [1 .. 2] of clt$pdt_parameter,
        type1: record
          header: clt$type_specification_header,
          default_value: string (7),
        recend,
        type2: record
          header: clt$type_specification_header,
        recend,
      recend := [[1, [88, 10, 19, 10, 52, 6, 82], clc$command, 3, 2, 0, 0, 0, 0, 2, 'OSM$DISJL'],
            [['O                              ', clc$abbreviation_entry, 1],
            ['OUTPUT                         ', clc$nominal_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, 3, clc$optional_default_parameter, 0, 7],

{ PARAMETER 2

      [3, 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], '$output'],

{ PARAMETER 2

      [[1, 0, clc$status_type]]];

?? POP ??

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

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

    CONST
      integer_field_width = 20;

*copy clv$display_variables

    VAR
      limits: sft$limits,
      display_control: clt$display_control,
      file_contents: amt$file_contents,
      output_line: string (osc$max_string_size),
      output_line_size: integer,
      accumulator_string: ost$string,
      job_warning_limit_string: ost$string,
      ring_attributes: amt$ring_attributes,
      job_maximum_limit_string: ost$string,
      limit_name_size: ost$name_size,
      available_space: 1 .. osc$max_string_size,
      name_column_size: amt$page_width,
      limit_name_column_size: ost$name_size,
      limit_count: jmt$job_resource_condition,
      index: jmt$job_resource_condition;

?? NEWTITLE := 'Dummy title because of error in clp$new_page_procedure' ??
*copyc clp$new_page_procedure

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

{ Dummy subtitle procedure

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

{ PURPOSE:
{   This is a block exit condition handler that is used to insure that the output
{   file is closed in case of an abnormal exit.

    PROCEDURE condition_handler
      (    condition: pmt$condition;
           condition_information: ^pmt$condition_information;
           save_area: ^ost$stack_frame_save_area;
       VAR handler_status: ost$status);

      VAR
        ignore_status: ost$status;

      clp$close_display (display_control, ignore_status);

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

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

{ Fill an array with the jobs limits.

    sfp$get_job_limit_count (limit_count, status);
    IF NOT status.normal THEN
      RETURN;
    IFEND;

    REPEAT
      PUSH limits: [1 .. limit_count];
      sfp$get_all_job_limits (limits, limit_count, status);
    UNTIL (status.normal) OR (status.condition <> sfe$limit_array_too_small);
    IF NOT status.normal THEN
      RETURN;
    IFEND;

    clv$titles_built := FALSE;
    clv$command_name := 'display_job_limits';
    ring_attributes.r1 := #RING (^ring_attributes);
    ring_attributes.r2 := #RING (^ring_attributes);
    ring_attributes.r3 := #RING (^ring_attributes);
    file_contents := amc$list;

    clp$open_display_reference (pvt [p$output].value^.file_value^, ^clp$new_page_procedure, file_contents,
          ring_attributes, display_control, status);
    IF NOT status.normal THEN
      RETURN;
    IFEND;

    osp$establish_block_exit_hndlr (^condition_handler);

{ Set page width.

    IF display_control.page_width < clc$narrow_page_width THEN
      clv$page_width := clc$narrow_page_width;
    ELSE
      clv$page_width := display_control.page_width;
    IFEND;

    clp$put_display (display_control, ' ', clc$trim, status);
    IF NOT status.normal THEN
      RETURN;
    IFEND;

{ The amount of space for the limit name column of the report should equal
{ the page width - (the amount of space needed for the three data columns) - (1 to remove autowrapping)

    name_column_size := clv$page_width - (3 * integer_field_width) - 1;

{ Reduce to the maximum space needed.

    IF name_column_size > osc$max_name_size THEN
      limit_name_column_size := osc$max_name_size;
    ELSE
      limit_name_column_size := name_column_size;
    IFEND;

{ The available space for printing limit name and the accumulator value should equal the
{ limit name column size calculated above + the amount of space needed for printing the maximum accumulator.

    available_space := limit_name_column_size + integer_field_width;

{ Write out the heading lines of the report.

    STRINGREP (output_line, output_line_size, 'Limit Name': limit_name_column_size, ' ':
          (integer_field_width - 11), 'Accumulator', ' ': (integer_field_width - 13), 'Warning Limit',
          ' ': (integer_field_width - 13), 'Maximum Limit');
    clp$put_display (display_control, output_line (1, output_line_size), clc$trim, status);
    IF NOT status.normal THEN
      RETURN;
    IFEND;
    STRINGREP (output_line, output_line_size, '----------': limit_name_column_size, ' ':
          (integer_field_width - 11), '-----------', ' ': (integer_field_width - 13), '-------------',
          ' ': (integer_field_width - 13), '-------------');
    clp$put_display (display_control, output_line (1, output_line_size), clc$trim, status);
    IF NOT status.normal THEN
      RETURN;
    IFEND;

  /process_limit_chain/
    FOR index := 1 TO limit_count DO
      clp$convert_integer_to_string (limits^ [index].accumulator, 10, FALSE, accumulator_string, status);

      job_warning_limit_string.value := ' ';
      IF limits^ [index].job_resource_limit = sfc$unlimited THEN

{ Right justify the literal 'UNLIMITED' in the appropriate column of the report.
{ (column width - length of the literal 'UNLIMITED') gives the number of leading spaces needed.
{ Adding 1 gives the starting substring position for the literal.

        job_warning_limit_string.value ((integer_field_width - 9) + 1, * ) := 'UNLIMITED';
      ELSE
        clp$convert_integer_to_rjstring (limits^ [index].job_resource_limit, 10, FALSE, ' ',
              job_warning_limit_string.value (1, integer_field_width), status);
      IFEND;
      job_warning_limit_string.size := integer_field_width;

      job_maximum_limit_string.value := ' ';
      IF limits^ [index].job_abort_limit = sfc$unlimited THEN

{ Right justify the literal 'UNLIMITED' in the appropriate column of the report.
{ (column width - length of the literal 'UNLIMITED') gives the number of leading spaces needed.
{ Adding 1 gives the starting substring position for the literal.

        job_maximum_limit_string.value ((integer_field_width - 9) + 1, * ) := 'UNLIMITED';
      ELSE
        clp$convert_integer_to_rjstring (limits^ [index].job_abort_limit, 10, FALSE, ' ',
              job_maximum_limit_string.value (1, integer_field_width), status);
      IFEND;
      job_maximum_limit_string.size := integer_field_width;

      limit_name_size := clp$trimmed_string_size (limits^ [index].name);

{ Check the limit name size + the accumulator size + 1 (for a space between fields) to see if they will
{ all fit on to one line.

      IF (limit_name_size + accumulator_string.size + 1) <= available_space THEN

{ Display will fit on one line.

        STRINGREP (output_line, output_line_size, limits^ [index].name (1, limit_name_size): limit_name_size,
              ' ': (available_space - (limit_name_size + accumulator_string.size)),
              accumulator_string.value (1, accumulator_string.size),
              job_warning_limit_string.value (1, job_warning_limit_string.size),
              job_maximum_limit_string.value (1, job_maximum_limit_string.size));
        clp$put_display (display_control, output_line (1, output_line_size), clc$trim, status);
        IF NOT status.normal THEN
          RETURN;
        IFEND;
      ELSE

{ Display must be split into two lines.
{ Limit name is displayed on line one.

        STRINGREP (output_line, output_line_size, limits^ [index].name: osc$max_name_size);
        clp$put_display (display_control, output_line (1, output_line_size), clc$trim, status);
        IF NOT status.normal THEN
          RETURN;
        IFEND;

{ Values are displayed on line two.

        STRINGREP (output_line, output_line_size, ' ': (available_space - accumulator_string.size),
              accumulator_string.value (1, accumulator_string.size),
              job_warning_limit_string.value (1, job_warning_limit_string.size),
              job_maximum_limit_string.value (1, job_maximum_limit_string.size));
        clp$put_display (display_control, output_line (1, output_line_size), clc$trim, status);
        IF NOT status.normal THEN
          RETURN;
        IFEND;
      IFEND;
    FOREND /process_limit_chain/;

    clp$put_display (display_control, ' ', clc$trim, status);
    IF NOT status.normal THEN
      RETURN;
    IFEND;

    clp$close_display (display_control, status);
    osp$disestablish_cond_handler;

  PROCEND sfp$_display_job_limit;
?? OLDTITLE ??
?? NEWTITLE := '[XDCL] sfp$$job_limit', EJECT ??

{ PURPOSE:
{   This is the function processor for $JOB_LIMIT

  PROCEDURE [XDCL] sfp$$job_limit
    (    parameter_list: clt$parameter_list;
     VAR work_area: ^clt$work_area;
     VAR result: ^clt$data_value;
     VAR status: ost$status);

{ FUNCTION $job_limit (
{   name: name = $required
{   option: key
{       active, accumulator
{       (warning_limit, resource_limit)
{       (maximum_limit, abort_limit)
{     keyend = $required
{   )

?? PUSH (LISTEXT := ON) ??

    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$name_type_qualifier,
        recend,
        type2: record
          header: clt$type_specification_header,
          qualifier: clt$keyword_type_qualifier,
          keyword_specs: array [1 .. 6] of clt$keyword_specification,
        recend,
      recend := [[1, [88, 10, 19, 11, 39, 36, 734], clc$function, 2, 2, 2, 0, 0, 0, 0, '$JOB_LIMIT'],
            [['NAME                           ', clc$nominal_entry, 1],
            ['OPTION                         ', clc$nominal_entry, 2]], [

{ PARAMETER 1

      [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, 5, clc$required_parameter, 0, 0],

{ PARAMETER 2

      [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, 229, clc$required_parameter, 0, 0]],

{ PARAMETER 1

      [[1, 0, clc$name_type], [1, osc$max_name_size]],

{ PARAMETER 2

      [[1, 0, clc$keyword_type], [6], [['ABORT_LIMIT                    ', clc$abbreviation_entry,
            clc$normal_usage_entry, 4], ['ACCUMULATOR                    ', clc$nominal_entry,
            clc$normal_usage_entry, 2], ['ACTIVE                         ', clc$nominal_entry,
            clc$normal_usage_entry, 1], ['MAXIMUM_LIMIT                  ', clc$nominal_entry,
            clc$normal_usage_entry, 4], ['RESOURCE_LIMIT                 ', clc$abbreviation_entry,
            clc$normal_usage_entry, 3], ['WARNING_LIMIT                  ', clc$nominal_entry,
            clc$normal_usage_entry, 3]]]];

?? POP ??

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

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

    VAR
      local_status: ost$status,
      limit: sft$limit;

    status.normal := TRUE;

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

    sfp$get_job_limit (pvt [p$name].value^.name_value, limit, local_status);

    NEXT result IN work_area;
    IF result = NIL THEN
      osp$set_status_abnormal ('CL', cle$work_area_overflow, '', status);
      RETURN;
    IFEND;

    IF (pvt [p$option].value^.keyword_value = 'ACTIVE') THEN
      result^.kind := clc$boolean;
      result^.boolean_value.kind := clc$true_false_boolean;
      IF local_status.normal THEN
        result^.boolean_value.value := TRUE;
      ELSEIF local_status.condition = sfe$limit_not_activated THEN
        result^.boolean_value.value := FALSE;
      ELSE
        status := local_status;
      IFEND;
    ELSEIF (NOT local_status.normal) THEN
      status := local_status;
    ELSE { Either the accumulator, warning limit or maximum limit were requested. }
      result^.kind := clc$integer;
      result^.integer_value.radix := 10;
      result^.integer_value.radix_specified := FALSE;
      IF (pvt [p$option].value^.keyword_value = 'ACCUMULATOR') THEN
        result^.integer_value.value := limit.accumulator;
      ELSEIF (pvt [p$option].value^.keyword_value = 'WARNING_LIMIT') THEN
        result^.integer_value.value := limit.job_resource_limit;
      ELSE { MAXIMUM_LIMIT}
        result^.integer_value.value := limit.job_abort_limit;
      IFEND;
    IFEND;

  PROCEND sfp$$job_limit;
?? OLDTITLE ??
?? NEWTITLE := '[XDCL] sfp$_set_job_limit', EJECT ??

{ PURPOSE:
{   This is the command processor for SET_JOB_LIMIT.
{
{ NOTES:
{   This command will be removed in a future release.

  PROCEDURE [XDCL] sfp$_set_job_limit
    (    parameter_list: clt$parameter_list;
     VAR status: ost$status);

{ PROCEDURE (osm$setjl) set_job_limit, set_job_limits, setjl (
{   time_increment, ti: integer 0..osc$max_integer = $optional
{   time: integer 0..osc$max_integer = $optional
{   task: integer 0..osc$max_integer = $optional
{   status)

?? PUSH (LISTEXT := ON) ??

    VAR
      pdt: [STATIC, READ, cls$declaration_section] record
        header: clt$pdt_header,
        names: array [1 .. 5] of clt$pdt_parameter_name,
        parameters: array [1 .. 4] of clt$pdt_parameter,
        type1: record
          header: clt$type_specification_header,
          qualifier: clt$integer_type_qualifier,
        recend,
        type2: record
          header: clt$type_specification_header,
          qualifier: clt$integer_type_qualifier,
        recend,
        type3: record
          header: clt$type_specification_header,
          qualifier: clt$integer_type_qualifier,
        recend,
        type4: record
          header: clt$type_specification_header,
        recend,
      recend := [[1, [88, 10, 19, 11, 10, 21, 629], clc$command, 5, 4, 0, 0, 0, 0, 4, 'OSM$SETJL'],
            [['STATUS                         ', clc$nominal_entry, 4],
            ['TASK                           ', clc$nominal_entry, 3],
            ['TI                             ', clc$abbreviation_entry, 1],
            ['TIME                           ', clc$nominal_entry, 2],
            ['TIME_INCREMENT                 ', clc$nominal_entry, 1]], [

{ PARAMETER 1

      [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, 20, clc$optional_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, 20, clc$optional_parameter, 0, 0],

{ PARAMETER 3

      [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, 20, clc$optional_parameter, 0, 0],

{ PARAMETER 4

      [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$integer_type], [0, osc$max_integer, 10]],

{ PARAMETER 2

      [[1, 0, clc$integer_type], [0, osc$max_integer, 10]],

{ PARAMETER 3

      [[1, 0, clc$integer_type], [0, osc$max_integer, 10]],

{ PARAMETER 4

      [[1, 0, clc$status_type]]];

?? POP ??

    CONST
      p$time_increment = 1,
      p$time = 2,
      p$task = 3,
      p$status = 4;

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

    VAR
      time_increment: integer,
      time: integer,
      task: integer,
      limit: sft$limit;

?? NEWTITLE := 'check_parameters', EJECT ??

    PROCEDURE check_parameters
      (    parameter_value_table: ^clt$parameter_value_table;
           which_parameter: clt$which_parameter;
       VAR status: ost$status);

      status.normal := TRUE;

{ Time and time increment must not be specified at the same time.

      IF (NOT which_parameter.specific) THEN
        IF (pvt [p$time_increment].specified) AND (pvt [p$time].specified) THEN
          osp$set_status_abnormal ('SF', sfe$conflicting_parameters, 'TIME_INCREMENT and TIME', status);
        IFEND;
      IFEND;

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

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

{ Increment the CPU time limit.

    IF pvt [p$time_increment].specified THEN
      time_increment := pvt [p$time_increment].value^.integer_value.value;

{ Get the current cp time limit then add the specified increment to it.

      sfp$get_job_limit (avc$cp_time_limit_name, limit, status);
      IF NOT status.normal THEN
        RETURN;
      IFEND;

{ Make sure the the value will not exceed unlimited.

      IF (sfc$unlimited - limit.job_resource_limit) < time_increment THEN
        time := sfc$unlimited;
      ELSE
        time := time_increment + limit.job_resource_limit;
      IFEND;
      sfp$change_job_warning_limit (avc$cp_time_limit_name, time, status);
      IF NOT status.normal THEN
        RETURN;
      IFEND;
    IFEND;

{ Set a new CPU time limit.

    IF pvt [p$time].specified THEN
      time := pvt [p$time].value^.integer_value.value;
      sfp$change_job_warning_limit (avc$cp_time_limit_name, time, status);
      IF NOT status.normal THEN
        RETURN;
      IFEND;
    IFEND;

{ Set a new task limit.

    IF pvt [p$task].specified THEN
      task := pvt [p$task].value^.integer_value.value;
      sfp$change_job_warning_limit (avc$task_limit_name, task, status);
    IFEND;

  PROCEND sfp$_set_job_limit;
?? OLDTITLE ??
MODEND sfm$limit_commands_functions;


