?? LEFT := 1, RIGHT := 110 ??
?? FMT (FORMAT := ON, INDENT := 2) ??
?? SET (LIST := ON, LISTCTS := OFF) ??
MODULE nfm$rhf_protocol_engine;
{********************************************************************************}
{                                                                                }
{     MODULE:                                                                    }
{       NFM$PROTOCOL_ENGINE                                                      }
{                                                                                }
{     PURPOSE:                                                                   }
{                                                                                }
{       This module provides the external interfaces                             }
{       necessary for transfering files between peer applications. These         }
{       interfaces correspond to the functions of the outermost layer            }
{       (application layer - 7) of the basic model for open systems              }
{       interconnection (OSI). OSI is a standard for the exchange of data        }
{       between remote hosts, independent of the physical differences of         }
{       the hosts.                                                               }
{                                                                                }
{     DESCRIPTION:                                                               }
{                                                                                }
{       This code performs common A-A network protocol functions for
{       CDC applications.her the client or servicer application depending        }
{       on the BTS intefaces being used. The following diagram illustrates       }
{       the high level processing flow for batch transfers.                      }
{                                                                                }
{                                                                                }
{                 CLIENT                           SERVER                        }
{                                             (remote host or DI)                }
{                                                                                }
{            +------+  +------+               +------+  +------+                 }
{            | MANRF|  | BTF  |               | BOOT |  | PTFS |<---:            }
{            +------+  +------+               +------+  +------+    :            }
{               :         :                      :         :        :            }
{               :         :                      :         :        :            }
{               v         v                      v         v        :            }
{            +----------------+     +---+     +----------------+    :            }
{            | Protocol engine|<--->|   |<--->| Protocol engine|----:            }
{            +---------+------+     | N |     +------+---------+                 }
{            | send_file      |<--->| A |<--->| Receive_file   |                 }
{            +----------------+     | M |     +----------------+                 }
{            | receive_file   |<--->|   |<--->| Send_file      |                 }
{            +----------------+     +---+     +---------+------+                 }
{                                     ^                                          }
{                                     :       +----------------+                 }
{                                     ------->|    BTFS/DI     |                 }
{                                             +----------------+                 }
{                                                                                }
{       The permanent file client application for NOS/VE can be either           }
{       the manage remote files directive (MANRF) or one of the NOS/VE           }
{       directives which could cause an implicit file transfer. The client       }
{       application uses batch transfer services to establish a connection       }
{       with the server application on the remote mainframe and cause the        }
{       file transfer to occur.                                                  }
?? EJECT ??
{       The permanent file server application for NOS/VE is comprised of a       }
{       system task (BOOT) that accepts the connection request from the          }
{       client, and a job that is submitted on behalf of the user (PTFS)         }
{       and becomes the the users server application.                            }
{                                                                                }
{       The system task server application accepts the connection request        }
{       and receives the first data unit. If no errors are found, a job          }
{       file is created from the directives contained in the first data          }
{       unit, and the job is submitted on behalf of the user. If an error        }
{       is found in the first data unit, or when submitting the new server       }
{       job, the system task server will finish the termination protocol         }
{       processing with the client.                                              }
{                                                                                }
{                                                                                }
{                                                                                }
{********************************************************************************}
?? EJECT ??
  {========================================================================================}
  { command | mnemonic |         command name and function                                 }
  {========================================================================================}
  {   00    |   RFT    | Request_File_Transfer. Sent by the initiating process and is      }
  {         |          | accompanied by all of the parameters necessary to define the      }
  {         |          | details of the transfer and to identify the file.                 }
  {----------------------------------------------------------------------------------------}
  {   01    |   RPOS   | Reply_Positive. Sent by the receiving process to accept the       }
  {         |          | proposed file transfer, and is accompanied by the parameters      }
  {         |          | defining the receivers veiw of the file transfer.                 }
  {----------------------------------------------------------------------------------------}
  {   02    |   RNEG   | Reply_Negative. sent by the receiving process to indicate that    }
  {         |          | the proposed transfer may not take place. Parameters are provided }
  {         |          | giving sugested values for those attributes which contributed to  }
  {         |          | the failure. Additionally, the parameters include a value for an  }
  {         |          | attribute which gives an encoded reason for the difficulty.       }
  {----------------------------------------------------------------------------------------}
  {   03    |   GO     | Enter_Transfer_Phase. Indicates that the initiating process,      }
  {         |          | after considering the reply, is entering the data transfer        }
  {         |          | state.                                                            }
  {----------------------------------------------------------------------------------------}
  {   04    |   STOP   | Enter_Idle_Phase. Sent by the initiating process to indicate      }
  {         |          | the termination of the transfer. It may be accompanied by         }
  {         |          | parameters giving the final status of the transfer, messages,     }
  {         |          | and other information.                                            }
  {----------------------------------------------------------------------------------------}
  {   05    |   STOPR  | Enter_Idle_Reply. Sent by the receiving process to indicate the   }
  {         |          | servicer's final status of the transfer.                          }
  {----------------------------------------------------------------------------------------}
  {   60    |   ETP    | Enter_Termination_Phase. Sent by the initiating process and is    }
  {         |          | accompanied by all of the parameters necessary to define the      }
  {         |          | details of the termination process.                               }
  {----------------------------------------------------------------------------------------}
  {   61    |   ETPR   | Enter_Termination_Reply. Sent by the receiving process in reply to}
  {         |          | the ETP command. It is accompanied by the parameters defining the }
  {         |          | server's view of the details of the termination process.          }
  {----------------------------------------------------------------------------------------}
  {   62    |   FINI   | Initiate_Disconnect. Sent by the initiating process to indicate   }
  {         |          | completion of the application connection.                         }
  {========================================================================================}
?? EJECT ??
  {=======================================================================================}
  { attribute |        parameter name and function                                        }
  {=======================================================================================}
  {    00     | protocol identification. The protocol identification parameter gives the  }
  {           | protocol name, version, and implementation level of the A to A protocol   }
  {           | being used.                                                               }
  { --------------------------------------------------------------------------------------}
  {    01     | maximum transfer file size. This parameter specifies the maximum size in  }
  {           | kilobytes (1024 bytes) of data that may be transferred during the data    }
  {           | phase of the transfer.                                                    }
  { --------------------------------------------------------------------------------------}
  {    02     | transfer identifier. The transfer identifier allows the initiating        }
  {           | process to tag the particular file transfer.                              }
  { --------------------------------------------------------------------------------------}
  {    03     | facilities. The facilities parameter defines a set of A to A protocol     }
  {           | processing options which may be used in the data transfer phase. Each     }
  {           | character of the text string indicates a particular option to be used.    }
  {           |     C = Collective text string processing.                                }
  {           |     G = parameters allowed on the GO command.                             }
  {           |     H = Temporary hold.                                                   }
  {           |     L = Later resumption of this transfer in new transfer possible.       }
  {           |     M = Restart checkmark acknowledgment must occur.                     }
  {           |     N = No blocking of levels 40 and 50 interactive commands.             }
  {           |     R = Restart requests permitted within this transfer.                  }
  {           |     S = Send data acknowledgment must occur.                             }
  { --------------------------------------------------------------------------------------}
  {    04     | state of transfer. The state of transfer parameter is used to convey      }
  {           | information about the current state of the file transfer and to provide   }
  {           | additional explanation when the transfer has failed or is being rejected. }
  { --------------------------------------------------------------------------------------}
  {    05     | user text directive. The user text directives provide the receiving       }
  {           | process with the user operation to be performed.                          }
  { --------------------------------------------------------------------------------------}
  {    06     | file size. The file size parameter specifies the amount of storage        }
  {           | (in kilobytes) to be reserved for the file.                               }
  { --------------------------------------------------------------------------------------}
  {    07     | operator message. The operator message parameter allows a text message    }
  {           | to be conveyed with a command for disposition to the operator display.    }
  { --------------------------------------------------------------------------------------}
  {    08     | user message. The user message parameter allows a text message to be      }
  {           | conveyed with a command for output to the user log of the receiving       }
  {           | process.                                                                  }
  { --------------------------------------------------------------------------------------}
  {    09     | account message. The account message parameter allows for a text message  }
  {           | to be conveyed with a command for output to the account file of the       }
  {           | receiving process.                                                        }
  { --------------------------------------------------------------------------------------}
  {    10     | error log message. The error log message parameter allows a text message  }
  {           | to be conveyed with a command for output to the error log file of the     }
  {           | receiving process.                                                        }
  { --------------------------------------------------------------------------------------}
  {    11     | special options. The special options parameter allows for parameters      }
  {           | specifically undefined by the A to A protocol but known to the receiving  }
  {           | to be exchanged.                                                          }
  { --------------------------------------------------------------------------------------}
  {    12     | maximum transfer block size. The maximum transfer block size parameter    }
  {           | specifies the maximum size (in bytes) of the data block which may be      }
  {           | transfered during the data phase of the protocol. It includes only user   }
  {           | data and no more then one logical record.                                 }
  { --------------------------------------------------------------------------------------}
  {    13     | Accounting limit. For the Bxxx protocol only, this parameter specifies    }
  {           | the I/O station operators validation limit for the number of records in   }
  {           | a file transferred from an input or an output device. The file transfer   }
  {           | is terminated when this number of records has been transmitted and an     }
  {           | end of data has not been detected.                                        }
  { --------------------------------------------------------------------------------------}
  {   14-15   | reserved for CDC.                                                         }
  { --------------------------------------------------------------------------------------}
  {    16     | file name. The file name parameter specifies the file to be used as the   }
  {           | source or destination of the file transfer, if one is to takes place.     }
  {           | For NOS/VE, the file name is explicitly specified by both peer            }
  {           | applications through procedure calls to batch transfer services.          }
  {           | Because of this the parameter is not communicated through the protocol.   }
  { --------------------------------------------------------------------------------------}
  {    17     | file disposition code.                                                    }
  { --------------------------------------------------------------------------------------}
  {    18     | acknowledgment window. The acknowledgment window parameter defines      }
  {           | the maximum number of restart checkmarks and associated data transmitted  }
  {           | by the sender before receiving acknowledment from the receiver.           }
  { --------------------------------------------------------------------------------------}
  {    19     | initial restart checkmark. The Initial restart checkmark parameter        }
  {           | specifies the checkmark number at which the re-transfer is to start.      }
  { --------------------------------------------------------------------------------------}
  {    20     | minimum time-out interval. The minimum time_out interval parameter is     }
  {           | used to specify the amount of time (in wall clock seconds) that an        }
  {           | application will wait for no activity from the peer application. When     }
  {           | this threshold is reached, the file transfer will be unilaterally aborted }
  {           | and the connection will be broken.                                        }
  { --------------------------------------------------------------------------------------}
  {    21     | mode of access. The mode of access parameter specifies the direction of   }
  {           | the transfer and the access mode of the file.                             }
  { --------------------------------------------------------------------------------------}
  {    22     | host type. The host type parameter defines the host mainframe for the     }
  {           | peer application.                                                         }
  {           |     CDI = CDCNET TDI/URI.                                                 }
  {           |     CGW = CYBER gateway.                                                  }
  {           |     DEC = DEC.                                                            }
  {           |     IBM = IBM.                                                            }
  {           |     NOS = CYBER 17x with NOS/V1.                                          }
  {           |     NS2 = CYBER 17x with NOS/V2 (64 character set).                       }
  {           |     NS3 = CYBER 17x with NOS/V2 (63 character set).                       }
  {           |     NBE = CYBER 17x with NOS/BE (64 character set).                       }
  {           |     NBE = CYBER 17x with NOS/BE (64 character set).                       }
  {           |     NVE = CYBER 8xx with NOS/VE.                                          }
  {           |     SC2 = CYBER 7600 with SCOPE 2.                                        }
  {           |     VAX = VAX.                                                            }
  {           |     200 = CYBER 20x.                                                      }
  {           |     120 = CYBER 120.                                                      }
  { --------------------------------------------------------------------------------------}
  {    23     | command argument. The function and meaning of this parameter is dependent }
  {           | on the data transfer phase command that it is contained in.               }
  { --------------------------------------------------------------------------------------}
  {    24     | source logical identifier. This parameter contains the logical mainframe  }
  {           | identifier to the source computer.                                        }
  { --------------------------------------------------------------------------------------}
  {    25     | transfer logical identifier. This parameter contains the logical          }
  {           | identifier which corresponds to the connection used for the file transfer.}
  { --------------------------------------------------------------------------------------}
  {    26     | job name. For permanent file transfers the job name parameter represents  }
  {           | the name of the peer application job. This parameter should be logged in  }
  {           | system file for accounting and job tracking purposes.                     }
  { --------------------------------------------------------------------------------------}
  {    27     | physical identifier. The physical identifier parameter is exchanged       }
  {           | between peer applications for accounting purposes.                        }
  { --------------------------------------------------------------------------------------}
  {    28     | destination host type. The destination host type parameter specifies the  }
  {           | mainframe host type of the receiving host. The initiating process can     }
  {           | use this parameter insure that the receiving process is of a spacific     }
  {           | known type. For a list of legal parameters see parameter 22.              }
  {           |                                                                           }
  { --------------------------------------------------------------------------------------}
  {    29     | echo. The echo parameter may be used on a RFT command by any application. }
  {           | The application receiving the RFT command may return the echo parameter   }
  {           | and data on the RPOS command. This will allow the initiating application  }
  {           | to verify the data returned. Since the application sending the echo       }
  {           | parameter can not expect that it will be returned, this parameter has     }
  {           | limited usefulness and is retained primarily for compatibility with       }
  {           | earlier versions of the protocol.                                         }
  { --------------------------------------------------------------------------------------}
  {    30     | command attributes continued. This parameter indicates that all the       }
  {           | attributes (parameters) for a given command could not be contained in     }
  {           | one message block, and that subsequent block with the same command will   }
  {           | be sent.                                                                  }
  { --------------------------------------------------------------------------------------}
  {    31     | data declaration. The data declaration parameter identifies the format    }
  {           | of the data on the network. The internal format of the data on various    }
  {           | host mainframes is dependent on that mainframes file management schemes.  }
  {           |     AR = Archival data with initiator application dependent structure.    }
  {           |     AS = Archival data with server application dependent structure.       }
  {           |     C6 = ASCII-64 character set data.                                     }
  {           |     C8 = 8 bit extended ASCII character set data.                         }
  {           |     UH = Undefined host dependent data structure.                         }
  {           |     US = Undefined logical data structure.                                }
  {           |     UU = Undefined and unstructured file.                                 }
  { --------------------------------------------------------------------------------------}
  {    32     | system routing text. The system routing text parameter provides           }
  {           | additional queue file routing text for enhanced queue file routing        }
  {           | capabilities between similar operating systems. This parameter overrides  }
  {           | implitit text values.                                                     }
  { --------------------------------------------------------------------------------------}
  {    33     | Implicit routing text. The Implicit Routing Text parameter provides the   }
  {           | text which accompanies an input file of disposition code 'IN'. This text  }
  {           | string must be returned with output files of any disposition code.        }
  { --------------------------------------------------------------------------------------}
  {   34-39   | reserved for CDC.                                                         }
  { --------------------------------------------------------------------------------------}
  {   40-50   | interactive transfer facility only.                                       }
  { --------------------------------------------------------------------------------------}
  {    51     | User file name. This parameter specifies the user assigned name of the    }
  {           | file disposed to the output device.                                       }
  { --------------------------------------------------------------------------------------}
  {    52     | Banner date and time. This parameter specifies the date and time that     }
  {           | the file transfer to the output devive is being initiated.                }
  { --------------------------------------------------------------------------------------}
  {    53     | Banner routing text. This parameter specifies the physical location       }
  {           | identifier for the place that the public I/O station operator is to       }
  {           | send the output file hard copy.                                           }
  { --------------------------------------------------------------------------------------}
  {    54     | User banner text. This parameter contains the user provided text string   }
  {           | that the receiver is to use when constructing the output file banner.     }
  { --------------------------------------------------------------------------------------}
  {    55     | Installation banner text. This parameter contains the installation        }
  {           | provided text string that the receiver is to use when constructing the    }
  {           | output file banner.                                                       }
  { --------------------------------------------------------------------------------------}
  {    56     | Reposition output parameters. This parameter contains the output file     }
  {           | repositioning command parameters to be used by the sender to define the   }
  {           | new file position.                                                        }
  { --------------------------------------------------------------------------------------}
  {    57     | Current file position. This parameter contains the current file position  }
  {           | byte and record ordinal.                                                  }
  { --------------------------------------------------------------------------------------}
  {    58     | Default output file destination. This parameter conatins the identity of  }
  {           | the default destination I/O station for output files disposed by the job  }
  {           | being transfered from an input batch device.                              }
  { ======================================================================================}
?? NEWTITLE := 'Global Declarations Referenced by this Module', EJECT ??
?? PUSH (LISTEXT := ON) ??
*copyc jmt$vertical_print_density
*copyc nae$application_interfaces
*copyc nfc$command_definitions
*copyc nfc$parameter_00_definitions
*copyc nfc$parameter_01_definitions
*copyc nfc$parameter_02_definitions
*copyc nfc$parameter_03_definitions
*copyc nfc$parameter_04_definitions
*copyc nfc$parameter_05_definitions
*copyc nfc$parameter_06_definitions
*copyc nfc$parameter_07_definitions
*copyc nfc$parameter_08_definitions
*copyc nfc$parameter_09_definitions
*copyc nfc$parameter_10_definitions
*copyc nfc$parameter_11_definitions
*copyc nfc$parameter_12_definitions
*copyc nfc$parameter_13_definitions
*copyc nfc$parameter_16_definitions
*copyc nfc$parameter_17_definitions
*copyc nfc$parameter_20_definitions
*copyc nfc$parameter_21_definitions
*copyc nfc$parameter_22_definitions
*copyc nfc$parameter_24_definitions
*copyc nfc$parameter_25_definitions
*copyc nfc$parameter_26_definitions
*copyc nfc$parameter_27_definitions
*copyc nfc$parameter_28_definitions
*copyc nfc$parameter_29_definitions
*copyc nfc$parameter_30_definitions
*copyc nfc$parameter_31_definitions
*copyc nfc$parameter_32_definitions
*copyc nfc$parameter_33_definitions
*copyc nfc$parameter_52_definitions
*copyc nfc$parameter_90_definitions
*copyc nfc$parameter_91_definitions
*copyc nfc$parameter_92_definitions
*copyc nfc$parameter_93_definitions
*copyc nfc$parameter_94_definitions
*copyc nfc$parameter_95_definitions
*copyc nfc$parameter_96_definitions
*copyc nfc$parameter_97_definitions
*copyc nfc$parameter_98_definitions
*copyc nfc$parameter_99_definitions
*copyc nfc$parameter_definitions
*copyc nfe$batch_transfer_services
*copyc nfs$protocol_engine_static
*copyc nft$application_values
*copyc nft$buffer_control_block
*copyc nft$command_pdu_size
*copyc nft$command_set
*copyc nft$command_values
*copyc nft$control_block
*copyc nft$crack_parameter_action
*copyc nft$directive_entry
*copyc nft$file_access_mode
*copyc nft$last_command_received
*copyc nft$last_command_sent
*copyc nft$lcn_application_names
*copyc nft$mode_of_access
*copyc nft$nam_application_names
*copyc nft$network_type
*copyc nft$number_pdu_param_range
*copyc nft$p00_values
*copyc nft$parameter_00_values
*copyc nft$parameter_01_values
*copyc nft$parameter_03_elements
*copyc nft$parameter_03_netvalues
*copyc nft$parameter_03_value_set
*copyc nft$parameter_04_values
*copyc nft$parameter_06_values
*copyc nft$parameter_11_options
*copyc nft$parameter_11_values
*copyc nft$parameter_12_range
*copyc nft$parameter_17_definition
*copyc nft$parameter_17_element
*copyc nft$parameter_17_values
*copyc nft$parameter_20_range
*copyc nft$parameter_21_options
*copyc nft$parameter_21_specifications
*copyc nft$parameter_21_values
*copyc nft$parameter_22_strings
*copyc nft$parameter_22_values
*copyc nft$parameter_24_definition
*copyc nft$parameter_25_definition
*copyc nft$parameter_25_length
*copyc nft$parameter_26_all_chars
*copyc nft$parameter_26_definition
*copyc nft$parameter_27_definition
*copyc nft$parameter_27_length
*copyc nft$parameter_31_definition
*copyc nft$parameter_59_values
*copyc nft$parameter_numbers
*copyc nft$parameter_qualifiers
*copyc nft$parameter_qualifier_values
*copyc nft$parameter_rules
*copyc nft$parameter_set
*copyc nft$parameter_values
*copyc nft$protocol_commands
*copyc nft$protocol_parameters
*copyc nft$ptf_protocol_states
*copyc nft$required_param_on_command
*copyc nft$task_queue
*copyc nft$transfer_declarations
*copyc nft$transfer_modes
*copyc nft$transfer_status
*copyc osd$default_pragmats
*copyc ost$status
*copyc osv$lower_to_upper
*copyc rfe$condition_codes
?? POP ??
?? OLDTITLE ??
?? NEWTITLE := 'Global Declarations Referenced by this Module', EJECT ??
*copyc amp$open
*copyc amp$return
*copyc clp$convert_string_to_integer
*copyc clp$convert_integer_to_rjstring
*copyc clp$convert_integer_to_string
*copyc clp$read_variable
*copyc fsp$close_file
*copyc fsp$open_file
*copyc mmp$create_scratch_segment
*copyc nap$accept_connection
*copyc nap$acquire_connection
*copyc nap$attach_server_application
*copyc nap$await_data_available
*copyc nap$begin_directory_search
*copyc nap$detach_server_application
*copyc nap$end_directory_search
*copyc nap$get_title_translation
*copyc nap$request_connection
*copyc nap$se_receive_data
*copyc nap$se_send_data
*copyc nap$se_synchronize
*copyc nap$store_attributes
*copyc nfp$set_abnormal_if_normal
*copyc nfp$send_file
*copyc nfp$receive_file
*copyc osp$i_await_activity_completion
*copyc osp$set_status_from_condition
*copyc osp$append_status_parameter
*copyc osp$format_message
*copyc osp$get_status_condition_string
*copyc osp$set_status_abnormal
*copyc osp$set_status_condition
*copyc pmp$disestablish_cond_handler
*copyc pmp$establish_condition_handler
*copyc pmp$exit
*copyc pmp$get_job_names
*copyc pmp$get_legible_date_time
*copyc pmp$get_microsecond_clock
*copyc pmp$generate_unique_name
*copyc pmp$log
*copyc rfp$accept_connect_request
*copyc rfp$acquire_connect_request
*copyc rfp$application_sign_off
*copyc rfp$application_sign_on
*copyc rfp$await_rhfam_event
*copyc rfp$await_server_response
*copyc rfp$find_available_service
*copyc rfp$get_attributes
*copyc rfp$receive_data
*copyc rfp$request_connection
*copyc rfp$send_data
*copyc rfp$store

?? OLDTITLE ??
?? NEWTITLE := 'nfp$specify_pdu_parameter', EJECT ??

  PROCEDURE nfp$specify_pdu_parameter
    (    parameter_number: nft$protocol_parameters;
         parameter_qualifier: nft$parameter_qualifiers;
         parameter_value: string ( * <= nfc$max_param_size);
     VAR buffer_list: nft$network_buffer_list;
     VAR status: ost$status);

{                                                                             }
{ Procedure  nfp$specify_pdu_parameter                                        }
{                                                                             }
{ Purpose    To encode a protocol parameter into a command buffer for         }
{            eventual transmittal to the remote application.                  }
{                                                                             }
{ Description                                                                 }
{            This routine stores away network parameters, in command buffer   }
{            format.  The command being sent is not important here, it is     }
{            specified when the buffer is sent ( by calling nfp$send_command).}
{            This routine actually maintains a linked list of command buffers }
{            and handles command continuation via protocol parameter 30.      }
{                                                                             }
{ Input parameters                                                            }
{            Parameter_number     : Parameter to be specified                 }
{            Parameter_qualifier  : Protocol parameter qualifier (S,M,I)      }
{            Parameter_value      : String representing protocol parameter    }
{                                                                             }
{ Output parameters                                                           }
{            Status               : Only errors pertaining to running out     }
{                                   of virtual memory space.                  }
{                                                                             }
{ Algorithm                                                                   }
{            If no buffers on list then                                       }
{              Allocate buffer                                                }
{            Else                                                             }
{              While buffers on list do                                       }
{                If buffer not complete Then                                  }
{                  Use buffer                                                 }
{                Else                                                         }
{                  If last buffer on list, allocate new                       }
{                Ifend                                                        }
{              Whilend                                                        }
{            Ifend                                                            }
{            If parameter does not fit in space left in buffer then           }
{              Put continuation in buffer                                     }
{              Specify buffer complete                                        }
{              Call self to put in parameter                                  }
{            Else                                                             }
{              Put parameter in buffer                                        }
{            Ifend                                                            }
{                                                                             }
?? EJECT ??
{}

    VAR
      current_buffer: ^nft$buffer_control_block,
      done: boolean,
      parameter_length: integer,
      parameter_plus_continue: integer,
      parameter_identifier: string (nfc$num_param_id_digits),
      parameter_count: string (nfc$num_param_size_digits),
      scratch_buffer_control_block: ^nft$buffer_control_block;

    VAR
      nfv$p30_value: [XREF] string (nfc$p30_required_space),
      nfv$param_id_values: [XREF] nft$parameter_values,
      nfv$param_qualifier_values: [XREF] nft$parameter_qualifier_values;

{}
    status.normal := TRUE;
    done := FALSE;
    current_buffer := buffer_list.head;
    WHILE NOT done DO
      IF current_buffer = NIL THEN { Allocate a buffer }
        ALLOCATE scratch_buffer_control_block;
        IF scratch_buffer_control_block = NIL THEN
          nfp$set_internal_error ('nfp$specify_pdu_parameter no vm', status);
          RETURN;
        IFEND;
        IF buffer_list.head = NIL THEN
          buffer_list.head := scratch_buffer_control_block;
          buffer_list.tail := scratch_buffer_control_block;
        ELSE
          buffer_list.tail^.next_buffer := scratch_buffer_control_block;
          buffer_list.tail := scratch_buffer_control_block;
        IFEND;
        current_buffer := scratch_buffer_control_block;
        current_buffer^.buffer_complete := FALSE;
        current_buffer^.number_parameters := 0;
        current_buffer^.space_left := nfc$command_buffer_size - nfc$begin_params_pos;
        current_buffer^.next_position := nfc$begin_params_pos;
        current_buffer^.next_buffer := NIL;
        done := TRUE;
      ELSE { Check for use of existing buffer }
        IF NOT current_buffer^.buffer_complete THEN {** We use this one **}
          done := TRUE;
        ELSE {** Continue search down list **}
          current_buffer := current_buffer^.next_buffer;
        IFEND;
      IFEND;
    WHILEND;
{}
{ At this point, current_buffer points to an available buffer }
{}
    parameter_length := STRLENGTH (parameter_value);
    parameter_plus_continue := parameter_length + nfc$param_header_size + STRLENGTH (nfv$p30_value);
    IF (current_buffer^.space_left <= parameter_plus_continue) OR
          (current_buffer^.number_parameters = nfc$max_parameter_count - 1) THEN
{}
{ Potentially not enough space for next parameter, continue here }
{}
      current_buffer^.buffer (current_buffer^.next_position, nfc$param_header_size) := nfc$p30_param_value;
      current_buffer^.next_position := current_buffer^.next_position + nfc$param_header_size;
      current_buffer^.number_parameters := current_buffer^.number_parameters + 1;
      current_buffer^.buffer_complete := TRUE;
{}
{ Now call myself to specify the parameter in question }
{}
      nfp$specify_pdu_parameter (parameter_number, parameter_qualifier, parameter_value, buffer_list, status);
      IF NOT status.normal THEN
        RETURN;
      IFEND;
    ELSE
{}
{ Enough space, stuff the parameter }
{}
      current_buffer^.buffer (current_buffer^.next_position, nfc$num_param_id_digits) :=
            nfv$param_id_values [parameter_number];
      current_buffer^.next_position := current_buffer^.next_position + nfc$num_param_id_digits;
      current_buffer^.buffer (current_buffer^.next_position,
            nfc$num_param_qual_digits) := nfv$param_qualifier_values [parameter_qualifier];
      current_buffer^.next_position := current_buffer^.next_position + nfc$num_param_qual_digits;
      clp$convert_integer_to_rjstring (STRLENGTH (parameter_value), nfc$parameter_length_radix, FALSE,
            nfc$parameter_fill_char, current_buffer^.buffer (current_buffer^.next_position,
            nfc$num_param_size_digits), status);
      IF NOT status.normal THEN
        RETURN;
      IFEND;
      current_buffer^.next_position := current_buffer^.next_position + nfc$num_param_size_digits;
      IF parameter_length > 0 THEN
        current_buffer^.buffer (current_buffer^.next_position, parameter_length) := parameter_value;
        current_buffer^.next_position := current_buffer^.next_position + parameter_length;
      IFEND;
      current_buffer^.space_left := current_buffer^.space_left - (nfc$param_header_size + parameter_length);
      current_buffer^.number_parameters := current_buffer^.number_parameters + 1;
    IFEND;
    {}
  PROCEND nfp$specify_pdu_parameter;
?? OLDTITLE ??
?? NEWTITLE := '[XDCL] nfp$send_command', EJECT ??

  PROCEDURE [XDCL] nfp$send_command
    (    command: nft$protocol_commands;
         select_parameters: nft$parameter_set;
         ignore_parameters: nft$parameter_set;
         modify_parameters: nft$parameter_set;
     VAR transfer_control: nft$control_block;
     VAR status: ost$status);

{
{ Procedure nfp$send_command
{
{ Purpose    Called to assemble zero or more parameters into a command
{            block and send it to the connected remote host.
{
{ Description
{            This routine is called specifying a set of parameters to be
{            placed in the command buffer(s).  A service routine will be
{            called for each parameter.  Note: parameters placed in the
{            command buffer ( via call to nfp$specify_pdu_parameter )
{            will ALSO be sent.  This provides a simple interface for
{            for modifying or ignoring parameters which are not critical
{            to a transfer ( in RFT -> RPOS negotiation ).
{
{ Input parameters
{            Command       : A-A protocol command
{            Select_Parameters    : Set of A-A protocol parameters to select
{            Ignore_Parameters    : Set of A-A protocol parameters to ignore
{            Modify_Parameters    : Set of A-A protocol parameters to modify
{
{ Output parameters
{            Status               : Return status
{
{ Input/Output parameters
{            Transfer_control     : Application control block
{
{ Algorithm
{            For all known parameters Do
{              If parameter to be specified Then
{                Case to parameter sent service routine
{              Ifend
{            Forend
{            Nfp$transmit_pdus_to_remote
{
?? EJECT ??

    VAR
      current_buffer: ^nft$buffer_control_block,
      current_buffer_address: ^nft$buffer_control_block,
      index: nft$protocol_parameters,
      qualifier: nft$parameter_qualifiers;
    {}
    status.normal := TRUE;
    /parameter_search_loop/
    FOR index := LOWERVALUE (index) TO UPPERVALUE (index) DO
      IF index IN select_parameters THEN
        qualifier := nfc$select;
      ELSEIF index  IN modify_parameters THEN
        qualifier := nfc$modify;
      ELSEIF index IN ignore_parameters THEN
        qualifier := nfc$ignore;
      ELSE
        CYCLE /parameter_search_loop/;
      IFEND;

{     Case to parameter service routine

        CASE index OF
        = nfc$protocol_id =
            nfp$send_protocol_parameter_00 (transfer_control.protocol_in_use, qualifier,
                transfer_control.network_buffer_list, status);
        = nfc$maximum_file_length =
            nfp$send_protocol_parameter_01 (transfer_control.maximum_file_size, qualifier,
                transfer_control.network_buffer_list, status);
        = nfc$transfer_id =
          ;
        = nfc$facilities =
            nfp$send_protocol_parameter_03 (qualifier, transfer_control.send_facilities,
                 transfer_control.network_buffer_list, status);
            IF status.normal THEN
              transfer_control.transfer_facilities := transfer_control.send_facilities;
            IFEND;
        = nfc$state_of_transfer =
            nfp$send_protocol_parameter_04 (transfer_control.state_of_transfer, qualifier,
                transfer_control.network_buffer_list, status);
        = nfc$user_text_directive =
            nfp$send_protocol_parameter_05 (transfer_control.send_directives, qualifier,
                transfer_control.network_buffer_list, status);
        = nfc$file_length =
            nfp$send_protocol_parameter_06 (transfer_control.file_size, qualifier,
                transfer_control.network_buffer_list, status);
        = nfc$operator_message =
            nfp$send_protocol_parameter_07 (transfer_control.send_operator_messages, qualifier,
                transfer_control.parameter_rules^ [nfc$operator_message]^ [transfer_control.protocol_in_use].
                maximum_parameter_length, transfer_control.network_buffer_list, status);
        = nfc$user_message =
            nfp$send_protocol_parameter_08 (transfer_control.protocol_in_use,
                transfer_control.send_user_messages, qualifier, transfer_control.
                parameter_rules^ [nfc$user_message]^ [transfer_control.protocol_in_use].
                maximum_parameter_length, transfer_control.network_buffer_list, status);
        = nfc$account_message =
            nfp$send_protocol_parameter_09 (transfer_control.protocol_in_use,
                transfer_control.send_account_messages, qualifier, transfer_control.
                parameter_rules^ [nfc$account_message]^ [transfer_control.protocol_in_use].
                maximum_parameter_length, transfer_control.network_buffer_list, status);
        = nfc$error_log_message =
            nfp$send_protocol_parameter_10 (transfer_control.protocol_in_use,
                transfer_control.send_errorlog_messages, qualifier, transfer_control.
                parameter_rules^ [nfc$error_log_message]^ [transfer_control.protocol_in_use].
                maximum_parameter_length, transfer_control.network_buffer_list, status);
        = nfc$special_options =
            nfp$send_protocol_parameter_11 (transfer_control.remote_host_type,
                transfer_control.send_special_options, qualifier, transfer_control.network_buffer_list,
                status);
        = nfc$max_block_size =
            nfp$send_protocol_parameter_12 (transfer_control.protocol_in_use,
                transfer_control.data_block_size,
                qualifier, transfer_control.network_buffer_list, status);
        = nfc$accounting_limit =
            nfp$send_protocol_parameter_13( transfer_control.accounting_limit,
                    qualifier, transfer_control.network_buffer_list, status);
        = nfc$file_name =
            nfp$send_protocol_parameter_16 (transfer_control.send_file_name.value
                (1, transfer_control.send_file_name.size),
                transfer_control.protocol_in_use,
                qualifier, transfer_control.parameter_rules^ [nfc$job_name]^
                [transfer_control.protocol_in_use].maximum_parameter_length,
                transfer_control.network_buffer_list,
                status);
        = nfc$file_disposition =
            nfp$send_protocol_parameter_17(transfer_control.disposition_code,
             qualifier, transfer_control.network_buffer_list, status);
        = nfc$acknowledgment_window =
            nfp$send_protocol_parameter_18(transfer_control.acknowledgment_window,
             qualifier, transfer_control.network_buffer_list, status);
        = nfc$initial_checkmark =
            nfp$send_protocol_parameter_19(transfer_control.initial_restart_checkmark,
             qualifier, transfer_control.network_buffer_list, status);
        = nfc$minimum_timeout_interval =
            nfp$send_protocol_parameter_20 (transfer_control.protocol_in_use, transfer_control.time_out,
                qualifier, transfer_control.parameter_rules^ [nfc$minimum_timeout_interval]^
                [transfer_control.protocol_in_use].maximum_parameter_length,
                transfer_control.network_buffer_list, status);
        = nfc$mode_of_access =
            nfp$send_protocol_parameter_21 (transfer_control.protocol_in_use, transfer_control.mode_of_access,
                transfer_control.mode_of_access_option, qualifier, transfer_control.
                parameter_rules^ [nfc$mode_of_access]^ [transfer_control.protocol_in_use].
                maximum_parameter_length, transfer_control.network_buffer_list, status);
        = nfc$host_type =
            nfp$send_protocol_parameter_22 (transfer_control.local_host_type, qualifier,
                transfer_control.network_buffer_list, status);
        = nfc$transfer_phase_attribute =
          ;
        = nfc$source_lid =
            nfp$send_protocol_parameter_24 (
                transfer_control.source_lid.value(1,transfer_control.source_lid.size), qualifier,
                transfer_control.parameter_rules^ [nfc$source_lid]^ [transfer_control.protocol_in_use].
                minimum_parameter_length, transfer_control.parameter_rules^ [nfc$source_lid]^
                [transfer_control.protocol_in_use].maximum_parameter_length,
                transfer_control.network_buffer_list, status);
        = nfc$transfer_lid =
            nfp$send_protocol_parameter_25 (transfer_control.protocol_in_use, transfer_control.
                transfer_lid (1, transfer_control.transfer_lid_length), qualifier,
                transfer_control.parameter_rules^ [nfc$transfer_lid]^ [transfer_control.protocol_in_use].
                maximum_parameter_length, transfer_control.network_buffer_list, status);
        = nfc$job_name =
            nfp$send_protocol_parameter_26 (transfer_control.protocol_in_use,
                transfer_control.application,
                transfer_control.send_job_name.value(1,transfer_control.
                send_job_name.size),
                qualifier, transfer_control.parameter_rules^ [nfc$job_name]^
                [transfer_control.protocol_in_use].maximum_parameter_length,
                transfer_control.network_buffer_list, status);
        = nfc$physical_id =
            nfp$send_protocol_parameter_27 (transfer_control.protocol_in_use, transfer_control.
                transfer_pid (1, transfer_control.transfer_pid_length), qualifier,
                transfer_control.parameter_rules^ [nfc$physical_id]^ [transfer_control.protocol_in_use].
                maximum_parameter_length, transfer_control.network_buffer_list, status);
        = nfc$destination_host_type =
            nfp$send_protocol_parameter_28 (transfer_control.expected_host_type, qualifier,
                transfer_control.network_buffer_list, status);
        = nfc$echo =
            nfp$send_protocol_parameter_29( transfer_control.send_echo_text, qualifier,
                transfer_control.network_buffer_list, status);
        = nfc$attribute_continued =
          ;
        = nfc$data_declaration =
            nfp$send_protocol_parameter_31 (transfer_control.data_declaration, qualifier,
                transfer_control.network_buffer_list, status);
        = nfc$system_routing_text =
            IF transfer_control.send_systems_routing_text.size < 1 THEN
              nfp$set_internal_error ('nfp$send_command no systems routing text', status);
            IFEND;
            nfp$send_protocol_parameter_32 (transfer_control.send_systems_routing_text.
                parameters(1, transfer_control.send_systems_routing_text.size), qualifier,
                transfer_control.network_buffer_list, status);
        = nfc$implicit_routing_text =
            IF transfer_control.send_implicit_routing_text.size < 1 THEN
              nfp$set_internal_error ('nfp$send_command no implicit routing text', status);
            IFEND;
            nfp$send_protocol_parameter_33 (transfer_control.send_implicit_routing_text.
                  text (1, transfer_control.send_implicit_routing_text.size), qualifier,
                  transfer_control.network_buffer_list, status);
        = nfc$user_file_name =
            nfp$send_protocol_parameter_51 (transfer_control.protocol_in_use, command,
                transfer_control.user_file_name.value (1, transfer_control.user_file_name.size), qualifier,
                transfer_control.network_buffer_list, status);
        = nfc$banner_date_and_time =
            nfp$send_protocol_parameter_52 ( qualifier,
                transfer_control.banner_date_and_time.value(1,
                transfer_control.banner_date_and_time.size),
                transfer_control.network_buffer_list, status);
        = nfc$banner_routing_text =
            nfp$send_protocol_parameter_53 (transfer_control.protocol_in_use, command,
                transfer_control.banner_routing_text.value (1, transfer_control.banner_routing_text.size),
                qualifier, transfer_control.network_buffer_list, status);
        = nfc$user_banner_text =
            nfp$send_protocol_parameter_54 (transfer_control.protocol_in_use, command,
                transfer_control.user_banner_message.value (1, transfer_control.user_banner_message.size),
                qualifier, transfer_control.network_buffer_list, status);
        = nfc$installation_banner_text =
            nfp$send_protocol_parameter_55 (transfer_control.protocol_in_use, command,
                transfer_control.installation_banner_message.value
                (1, transfer_control.installation_banner_message.size), qualifier,
                transfer_control.network_buffer_list, status);
        = nfc$reposition_output_params =
            nfp$send_protocol_parameter_56 (transfer_control.protocol_in_use, command,
                transfer_control.reposition_output_file.value (1,
                transfer_control.reposition_output_file.size), qualifier,
                transfer_control.network_buffer_list, status);
        = nfc$current_file_position =
            nfp$send_protocol_parameter_57 (transfer_control.protocol_in_use, command,
                transfer_control.current_file_position.value (1, transfer_control.current_file_position.size),
                qualifier, transfer_control.network_buffer_list, status);
        = nfc$output_file_destination =
            nfp$send_protocol_parameter_58 (transfer_control.protocol_in_use, command,
                transfer_control.default_output_file_destination.
                value (1, transfer_control.default_output_file_destination.size), qualifier,
                transfer_control.network_buffer_list, status);
        = nfc$vertical_print_density =
             nfp$send_protocol_parameter_59(
                    transfer_control.vertical_print_density, qualifier,
                    transfer_control.network_buffer_list, status);
        = nfc$vfu_load_procedure =
             IF transfer_control.vfu_load_procedure.size > 0 THEN
               nfp$send_protocol_parameter_60(
                    transfer_control.vfu_load_procedure.value(1,
                    transfer_control.vfu_load_procedure.size),
                    qualifier,
                    transfer_control.network_buffer_list, status);
             ELSE
               nfp$set_internal_error('vfu_load_procedure size = 0', status);
             IFEND;
          ;
        = nfc$reserved_for_site_90 =
          ;
        = nfc$reserved_for_site_91 =
          ;
        = nfc$reserved_for_site_92 =
          ;
        = nfc$reserved_for_site_93 =
          ;
        = nfc$reserved_for_site_94 =
          ;
        = nfc$reserved_for_site_95 =
          ;
        = nfc$reserved_for_site_96 =
          ;
        = nfc$reserved_for_site_97 =
          ;
        = nfc$reserved_for_site_98 =
          ;
        = nfc$reserved_for_site_99 =
          ;
        ELSE
          nfp$set_internal_error ('nfp$send_command', status);
        CASEND;
        IF NOT status.normal THEN

{         Release the protocol parameters on the network buffer list so that
{         they do not appear on the next SEND_COMMAND protocol parameter list

          current_buffer := transfer_control.network_buffer_list.head;
          WHILE current_buffer <> NIL DO
            current_buffer_address := current_buffer;
            current_buffer := current_buffer^ .next_buffer;
            FREE current_buffer_address;
          WHILEND;
          transfer_control.network_buffer_list.head := NIL;
          RETURN;
        IFEND;
    FOREND;
    {}
    {     PDU's for this command have been built and no errors have
    {     occured.  Send the PDU's on the network
    {}
    nfp$transmit_pdus_to_remote (command, transfer_control.application, transfer_control.protocol_trace,
          transfer_control.network_buffer_list, transfer_control.path, status);
    IF status.normal THEN
      transfer_control.last_command_sent := command;
    IFEND;
    {}
  PROCEND nfp$send_command;
?? OLDTITLE ??
?? NEWTITLE := 'nfp$transmit_pdus_to_remote', EJECT ??

{ PURPOSE:
{   This procedure will send the buffer(s) encoded by nfp$send_command to the
{   remote host by encoding the command and number of parameters into the
{   command buffer(s) and sends them on the network.
{
{ NOTE:
{   If no parameters where specified for the command (e.g. GO) the buffer
{   needs to be allocated here.

  PROCEDURE nfp$transmit_pdus_to_remote
    (    command: nft$protocol_commands;
         application: nft$application_values;
         protocol_trace: boolean;
     VAR buffer_list: nft$network_buffer_list;
     VAR path: nft$network_connection;
     VAR status: ost$status);

    VAR
      address: ^nft$buffer_control_block,
      current_buffer: ^nft$buffer_control_block,
      terminate_status: ost$status;

    VAR
      nfv$command_values: [XREF] nft$command_values;

    status.normal := TRUE;
    IF buffer_list.head = NIL THEN
      ALLOCATE buffer_list.head;
      IF buffer_list.head = NIL THEN
        nfp$set_internal_error ('nfp$transmit_pdus_to_remote no vm', status);
        RETURN;
      IFEND;
      current_buffer := buffer_list.head;
      current_buffer^.buffer_complete := FALSE;
      current_buffer^.number_parameters := 0;
      current_buffer^.space_left := nfc$command_buffer_size;
      current_buffer^.next_position := nfc$begin_params_pos;
      current_buffer^.next_buffer := NIL;
    IFEND;

    current_buffer := buffer_list.head;
    WHILE current_buffer <> NIL DO
      current_buffer^.buffer (nfc$pdu_command_pos, nfc$pdu_command_len) := nfv$command_values [command];
      clp$convert_integer_to_rjstring (current_buffer^.number_parameters, nfc$command_radix,
            nfc$command_include_radix, nfc$command_fill_char, current_buffer^.
            buffer (nfc$pdu_nparams_pos, nfc$pdu_nparams_len), status);
      IF NOT status.normal THEN

{       delete the rest of the parameters from the link list

        WHILE current_buffer <> NIL DO
          address := current_buffer;
          current_buffer := current_buffer^ .next_buffer;
          FREE address;
        WHILEND;
        buffer_list.head := NIL;
        RETURN;
      IFEND;
      nfp$write_network_block (application, path.network_file_id, path.network_type, current_buffer^.
            buffer (1, current_buffer^.next_position - 1), protocol_trace, status);
      IF NOT status.normal THEN { Network error }
        nfp$terminate_path (application, FALSE, path, terminate_status);

{       delete the rest of the parameters from the link list

        WHILE current_buffer <> NIL DO
          address := current_buffer;
          current_buffer := current_buffer^ .next_buffer;
          FREE address;
        WHILEND;
        buffer_list.head := NIL;
        RETURN;
      IFEND;
      address := current_buffer;
      current_buffer := current_buffer^.next_buffer;
      FREE address;
    WHILEND;
    buffer_list.head := NIL;

  PROCEND nfp$transmit_pdus_to_remote;
?? OLDTITLE ??
?? NEWTITLE := '[XDCL] nfp$crack_command', EJECT ??

  PROCEDURE [XDCL] nfp$crack_command
    (    command_string: string (nfc$pdu_command_len);
     VAR command: nft$protocol_commands;
     VAR status: ost$status);

{                                                                             }
{ Procedure nfp$crack_command                                                 }
{                                                                             }
{ Purpose   To convert a string to a protocol command ordinal.                }
{                                                                             }
{ Description                                                                 }
{           This routine attempts to match a protocol command to a known      }
{           value.  If the received value does not match a known value,       }
{           a protocol error is returned                                      }
{                                                                             }
{ Input parameters                                                            }
{           Command_string       : Input command                              }
{                                                                             }
{ Output parameters                                                           }
{           Command              : Command ordinal                            }
{           Status               : NORMAL or                                  }
{                                  Nfe$invalid_protocol_command               }
{ Algorithm                                                                   }
{           If input commmand string length invalid then error                }
{           For i = 1 To number of known comman                               }
{             If input command = command list[i] Then                         }
{               Set valid                                                     }
{               Exit for loop                                                 }
{           Forend                                                            }
{           If valid then                                                     }
{             Set command ordinal                                             }
{           Else                                                              }
{             Set error                                                       }
{           Ifend                                                             }
{                                                                             }
?? EJECT ??

    VAR
      command_length: 0 .. nfc$command_buffer_size,
      found_it: boolean,
      index: nft$protocol_commands;

    VAR
      nfv$command_values: [XREF] nft$command_values;

{}
    status.normal := TRUE;
    command_length := STRLENGTH (command_string);
    IF (command_length <> nfc$pdu_command_len) THEN
      osp$set_status_abnormal (nfc$status_id, nfe$invalid_protocol_command, command_string, status);
      RETURN;
    IFEND;
{}
    found_it := FALSE;

  /command_search_loop/
    FOR index := LOWERVALUE (index) TO UPPERVALUE (index) DO
      IF nfv$command_values [index] = command_string THEN
        found_it := TRUE;
        EXIT /command_search_loop/;
      IFEND;
    FOREND /command_search_loop/;
{}
    IF found_it THEN
      command := index;
    ELSE
      osp$set_status_abnormal (nfc$status_id, nfe$invalid_protocol_command, command_string, status);
    IFEND;
{}
  PROCEND nfp$crack_command;
?? OLDTITLE ??
?? NEWTITLE := '[XDCL] nfp$crack_number_of_parameters', EJECT ??

  PROCEDURE [XDCL] nfp$crack_number_of_parameters
    (    number_string: string (nfc$pdu_nparams_len);
     VAR number_parameters: nft$number_pdu_param_range;
     VAR status: ost$status);

    {
    {
    { Procedure nfp$crack_number_of_parameters
    {
    {
    {
    { Purpose   To return the number of parameters in a command.
    {
    {
    {
    { Description
    {
    {           This routine cracks the number of parameters present in a
    {           protocol command.
    {
    { Input parameters
    {
    {           Number_string        : String representing # of parameters
    {
    {
    {
    { Output parameters
    {
    {           Number_of_parameters : Return # of parameters
    {           Status               : Normal or
    {                                    Nfe$invalid_param_count
    {
    {
    { Algorithm
    {
    {           Convert string to integer
    {           If convert o.k., check # params in valid range
    {
?? EJECT ??

    VAR
      length_record: clt$integer;

    {}
    status.normal := TRUE;
    clp$convert_string_to_integer (number_string, length_record, status);
    IF status.normal THEN
      IF ((length_record.value > nfc$max_parameter_count) OR
            (length_record.value < nfc$min_parameter_count) OR (length_record.radix_specified)) THEN
        status.normal := FALSE;
      IFEND;
    IFEND;
    {}
    IF status.normal THEN
      number_parameters := length_record.value;
    ELSE
      osp$set_status_abnormal (nfc$status_id, nfe$invalid_param_count, number_string, status);
    IFEND;
    {}
  PROCEND nfp$crack_number_of_parameters;
?? OLDTITLE ??
?? NEWTITLE := '[XDCL] nfp$get_and_crack_command', EJECT ??

{ PURPOSE:
{   This procedure reads a command from the network, cracks the command and
{   the number of parameters associated with the command.  The command is
{   validated against the expected command(s) of the application.
{
{ NOTE:
{   PTFS boot will use this routine for RFT/job file processing.

  PROCEDURE [XDCL] nfp$get_and_crack_command
    (    legal_commands: nft$command_set;
         input_buffer: ^string (nfc$command_buffer_size);
     VAR control_block: nft$control_block;
     VAR input_length: nft$command_pdu_size;
     VAR number_of_parameters: nft$number_pdu_param_range;
     VAR received_command: nft$protocol_commands;
     VAR command_in_process: nft$protocol_commands;
     VAR status: ost$status);

    VAR
      terminate_status: ost$status,
      trace_status: ost$status;

    status.normal := TRUE;
    nfp$read_network_block (control_block.application, control_block.path.network_file_id, control_block.path.
          network_type, control_block.time_out, control_block.protocol_trace, input_buffer^, input_length,
          status);
    IF NOT status.normal THEN

{   network error

      nfp$terminate_path (control_block.application, FALSE, control_block.path, terminate_status);
      RETURN;
    ELSE

{   crack parameters

      IF input_length < nfc$pdu_header_size THEN
        nfp$set_internal_error ('nfp$get_and_crack_command invalid length', status);
        RETURN;
      IFEND;
      nfp$crack_command (input_buffer^ (nfc$pdu_command_pos, nfc$pdu_command_len), received_command, status);
      IF NOT status.normal THEN
        RETURN;
      ELSE
        IF command_in_process <> nfc$unknown_command THEN
          IF received_command <> command_in_process THEN
            osp$set_status_condition ( nfe$invalid_command_code,  status);
            RETURN;
          IFEND;
        ELSE
          command_in_process := received_command;
          control_block.last_command_received := received_command;
          IF NOT (received_command IN legal_commands) THEN
            osp$set_status_condition ( nfe$invalid_command_code,  status);
            RETURN;
          IFEND;
        IFEND;
      IFEND;

      nfp$crack_number_of_parameters (input_buffer^ (nfc$pdu_nparams_pos, nfc$pdu_nparams_len),
            number_of_parameters, status);
      IF NOT status.normal THEN
        RETURN;
      IFEND;
    IFEND;

  PROCEND nfp$get_and_crack_command;
?? OLDTITLE ??
?? NEWTITLE := '[XDCL] nfp$crack_parameter', EJECT ??

{ PURPOSE:
{   This procedure will analyze a protocol parameter for validity and qualities.
{   The parameter context is checked, if it is valid for this command.  If it is
{   valid, its length and qualifier characteristics are checked.
{
{ NOTE:
{   The parameter ABORT_XFER means that an invalid parameter length was identified,
{   and that this command is invalid and therefore, this transfer should be terminated.

  PROCEDURE [XDCL] nfp$crack_parameter
    (    command: nft$protocol_commands;
         protocol: nft$parameter_00_values;
         parameter: string ( * <= nfc$max_qualified_param_size);
         param_rules: nft$parameter_rules_array;
     VAR buffer_list: nft$network_buffer_list;
     VAR length: nft$parameter_size;
     VAR value: string ( * <= nfc$max_param_size);
     VAR identifier: nft$protocol_parameters;
     VAR qualifier: nft$parameter_qualifiers;
     VAR action: nft$crack_parameter_action;
     VAR ignored_params: nft$parameter_set;
     VAR abort_xfer: boolean;
     VAR status: ost$status);

    VAR
      found_id: boolean,
      found_qual: boolean,
      index: nft$protocol_parameters,
      length_record: clt$integer,
      qualifier_index: nft$parameter_qualifiers,
      scratch: nft$parameter_rules,
      trace_status: ost$status;

    VAR
      nfv$param_id_values: [XREF] nft$parameter_values;

    VAR
      nfv$param_qualifier_values: [XREF] nft$parameter_qualifier_values;

{ Crack parameter identifier (number)

    status.normal := TRUE;
    found_id := FALSE;
    abort_xfer := FALSE;
    action := nfc$do_not_process;

  /forloop/
    FOR index := LOWERVALUE (index) TO UPPERVALUE (index) DO
      IF parameter (1, nfc$num_param_id_digits) = nfv$param_id_values [index] THEN
        identifier := index;
        found_id := TRUE;
        EXIT /forloop/
      IFEND;
    FOREND /forloop/;
    IF found_id THEN
      scratch := param_rules [identifier]^;
    IFEND;

{ Crack parameter qualifier

    found_qual := FALSE;

  /for_qual_loop/
    FOR qualifier_index := LOWERVALUE (qualifier_index) TO UPPERVALUE (qualifier_index) DO
      IF parameter (nfc$param_qual_pos, nfc$num_param_qual_digits) =
            nfv$param_qualifier_values [qualifier_index] THEN
        found_qual := TRUE;
        EXIT /for_qual_loop/;
      IFEND;
    FOREND /for_qual_loop/;
    IF found_qual THEN
      qualifier := qualifier_index;
    IFEND;

{     Crack parameter length

    clp$convert_string_to_integer (parameter (nfc$param_size_pos, nfc$num_param_size_digits), length_record,
          status);
    IF (NOT status.normal) OR (length_record.value < nfc$min_param_size) OR
          (length_record.value > nfc$max_param_size) THEN
      osp$set_status_abnormal (nfc$status_id, nfe$parameter_length_error,
            parameter (1, nfc$param_header_size), status);
      abort_xfer := TRUE;
      RETURN;
    ELSE
      length := length_record.value;
      value := parameter (nfc$param_value_pos, length);
    IFEND;

{ Check if the parameter is processed by application

    IF found_id AND found_qual THEN
      IF (NOT scratch [protocol].valid_for_protocol) THEN
      { Not valid for application/protocol, ignore }
        IF ((command = nfc$rft) OR (command = nfc$stop) OR (command = nfc$rneg) OR
              ((command = nfc$rpos) AND (abort_xfer))) THEN
          ignored_params := ignored_params + $nft$parameter_set [identifier];
          nfp$specify_pdu_parameter (identifier, nfc$ignore, value (1, length), buffer_list, status);
        ELSE
          ; { Parameter is not processed, pretend it was not there }
        IFEND;
      ELSE { Processable }

{ CHECK PARAMETER LENGTH

        IF ((length < scratch [protocol].minimum_parameter_length) OR
              (length > scratch [protocol].maximum_parameter_length)) THEN
          osp$set_status_abnormal (nfc$status_id, nfe$parameter_length_error,
                parameter (1, nfc$param_header_size), status);
        ELSE
          action := nfc$process;
        IFEND;
      IFEND;
    IFEND;

  PROCEND nfp$crack_parameter;
?? OLDTITLE ??
?? NEWTITLE := '[XDCL] nfp$receive_command', EJECT ??

  PROCEDURE [XDCL] nfp$receive_command
    (    legal_commands: nft$command_set;
         required_params: nft$required_param_on_command;
     VAR control_block: nft$control_block;
     VAR received_params: nft$parameter_set;
     VAR ignored_params: nft$parameter_set;
     VAR modified_params: nft$parameter_set;
     VAR status: ost$status);

{                                                                             }
{ Procedure nfp$receive_command                                        }
{                                                                             }
{ Purpose   Receive a command (in one or more network blocks).                }
{                                                                             }
{ Description                                                                 }
{            This routine reads all network blocks in a command.  Processable }
{            parameters in each block are sent to service routines for        }
{            analysis.  Required parameters for command processing is also    }
{            done here                                                        }
{                                                                             }
{ Input parameters                                                            }
{            Legal_commands       : Set of A-A commands the application will  }
{                                   accept at this juncture.                  }
{            Required_parms       : Structure defining parameters required    }
{                                   on each protocol command for the          }
{                                   application.                              }
{                                                                             }
{ Output parameters                                                           }
{            Status               : Values returned by                        }
{                                     nfp$get_and_crack_command               }
{                                     nfp$crack_parameter                     }
{                                     Parameter service routines              }
{                                   -or- nfe$required_parameter_missing       }
{                                                                             }
{ Input/Output parameters                                                     }
{            Control_block        : Application control block                 }
{                                                                             }
{ Algorithm                                                                   }
{            While not done do                                                }
{              Nfp$get_and_crack_command                                      }
{              If not status.normal then return                               }
{              For i = 1 to # of parameters do                                }
{                Crack parameter                                              }
{                If parameter processable then                                }
{                  Case to parameter service routine                          }
{                Ifend                                                        }
{              Forend                                                         }
{              If no continuation, done = true                                }
{            Whilend                                                          }
{            If received parameters < required then                           }
{              Set error, return                                              }
{            Ifend                                                            }
{                                                                             }
?? EJECT ??

    VAR
      automatic_ignored_params: nft$parameter_set,
      automatic_modified_params: nft$parameter_set,
      command_in_process: nft$protocol_commands,
      input_buffer: ^string (nfc$command_buffer_size),
      input_length: nft$command_pdu_size,
      message_string: string(osc$max_string_size),
      message_string_length: 0..osc$max_string_size,
      missing_parameters: nft$parameter_set,
      more_command_blocks: boolean,
      number_of_parameters: nft$number_pdu_param_range,
      protocol_parameter: nft$protocol_parameters,
      received_command: nft$protocol_commands,
      received_pdu_params: nft$parameter_set;

    VAR
      nfv$param_id_values: [XREF] nft$parameter_values;

    VAR
      nfv$command_values: [XREF] nft$command_values;
{}
    status.normal := TRUE;
    command_in_process := nfc$unknown_command;
    received_params := $nft$parameter_set [];
    ignored_params := $nft$parameter_set [];
    modified_params := $nft$parameter_set [];
    control_block.last_auto_modify_ignore := $nft$parameter_set [];
    PUSH input_buffer;

  /main_loop/
    REPEAT
      {}
      { read network block }
      {}
      nfp$get_and_crack_command (legal_commands, input_buffer, control_block, input_length,
            number_of_parameters, received_command, command_in_process, status);
      IF NOT status.normal THEN
        RETURN;
      IFEND;
      nfp$crack_pdu (received_command, input_buffer^ (1, input_length), number_of_parameters,
            more_command_blocks, received_pdu_params, automatic_ignored_params, automatic_modified_params,
            control_block, status);
      IF NOT status.normal THEN
        RETURN;
      IFEND;
      received_params := received_params + received_pdu_params;
      ignored_params := ignored_params + automatic_ignored_params;
      modified_params := modified_params + automatic_modified_params;
      {}
    UNTIL NOT more_command_blocks;
    control_block.last_auto_modify_ignore := ignored_params + modified_params;
    {}
    {     Check have all REQUIRED parameters }
    {}
    IF NOT (required_params [received_command] <= received_params) THEN
      missing_parameters := required_params[received_command] - received_params;
      message_string_length := 1;
      /build_missing_param_string/
      FOR protocol_parameter := lowervalue(nft$protocol_parameters) to
             uppervalue(nft$protocol_parameters) DO
        IF protocol_parameter IN missing_parameters THEN
          message_string(message_string_length,nfc$num_param_id_digits) :=
             nfv$param_id_values[protocol_parameter];
          message_string_length := message_string_length +
             nfc$num_param_id_digits;
          message_string(message_string_length,1) := ' ';
          message_string_length := message_string_length + 1;
          IF message_string_length + (nfc$num_param_id_digits + 1) >=
             osc$max_string_size THEN
            EXIT /build_missing_param_string/;
          IFEND;
        IFEND;
      FOREND;
      IF message_string_length > 1 THEN
        message_string_length := message_string_length - 1;
        osp$set_status_abnormal (nfc$status_id, nfe$required_parameter_missing,
             message_string(1,message_string_length), status);
      IFEND;
      osp$append_status_parameter(osc$status_parameter_delimiter,
             nfv$command_values[received_command], status);
    IFEND;
    {}
  PROCEND nfp$receive_command;
?? OLDTITLE ??
?? NEWTITLE := '[XDCL] nfp$crack_pdu', EJECT ??

{ PURPOSE:
{   This procedure will crack and process all the parameters from a PDU,
{   which is input to this procedure.  Each parameter in the PDU is cracked.
{   As each parameter is cracked, it may be processed by a service application
{   or ignored.

  PROCEDURE [XDCL] nfp$crack_pdu
    (    received_command: nft$protocol_commands;
         input_buffer: string ( * <= nfc$command_buffer_size);
         number_of_parameters: nft$number_pdu_param_range;
     VAR more_command_blocks: boolean;
     VAR received_params: nft$parameter_set;
     VAR ignored_params: nft$parameter_set;
     VAR modified_params: nft$parameter_set;
     VAR control_block: nft$control_block;
     VAR status: ost$status);

    VAR
      abort_xfer: boolean,
      action: nft$crack_parameter_action,
      buffer_position: 0 .. nfc$command_buffer_size,
      parameter_identifier: nft$protocol_parameters,
      parameter_index: nft$number_pdu_param_range,
      parameter_length: nft$parameter_size,
      parameter_modified: boolean,
      parameter_processed: boolean,
      parameter_qualifier: nft$parameter_qualifiers,
      parameter_value: string (nfc$max_param_size),
      procedure_status: ost$status,
      protocol_negotiation: boolean,
      p11_value: nft$parameter_11_options;

    status.normal := TRUE;
    procedure_status.normal := TRUE;
    more_command_blocks := FALSE;
    received_params := $nft$parameter_set [];
    ignored_params := $nft$parameter_set [];
    modified_params := $nft$parameter_set [];
    buffer_position := nfc$begin_params_pos;
    protocol_negotiation := (control_block.negotiate_protocol) AND (received_command = nfc$rneg);
    FOR parameter_index := 1 TO number_of_parameters DO
      parameter_modified := FALSE;
      nfp$crack_parameter (received_command, control_block.protocol_in_use,
            input_buffer (buffer_position, * ), control_block.parameter_rules^,
            control_block.network_buffer_list, parameter_length, parameter_value, parameter_identifier,
            parameter_qualifier, action, ignored_params, abort_xfer, status);
      IF  NOT status.normal THEN
        nfp$format_message_to_job_log (status);
        nfp$set_abnormal_if_normal(status,procedure_status);
        IF abort_xfer THEN
          RETURN;
        IFEND;
      ELSE
        IF action = nfc$process THEN
          received_params := received_params + $nft$parameter_set [parameter_identifier];
          CASE parameter_identifier OF
          = nfc$protocol_id =
            nfp$receive_parameter_00 (received_command, parameter_value (1, parameter_length),
                  parameter_qualifier, control_block.protocol_in_use, control_block.protocol_in_use,
                  control_block.negotiate_protocol, status);
            protocol_negotiation := (control_block.negotiate_protocol) AND (received_command = nfc$rneg);
          = nfc$maximum_file_length =
            nfp$receive_parameter_01 (parameter_value (1, parameter_length), control_block.maximum_file_size,
                  status);
          = nfc$transfer_id =
            ;
          = nfc$facilities =
            nfp$receive_parameter_03 (received_command, parameter_value (1, parameter_length),
                  parameter_qualifier, control_block.transfer_facilities, control_block.required_facilities,
                  control_block.allowed_facilities, parameter_modified, control_block.transfer_facilities,
                  control_block.network_buffer_list, status);
          = nfc$state_of_transfer =
            nfp$receive_parameter_04 (received_command, parameter_value (1, parameter_length),
                  parameter_qualifier, control_block.state_of_transfer, control_block.state_of_transfer,
                  status);
          = nfc$user_text_directive =
            nfp$receive_parameter_05 (received_command, parameter_value (1, parameter_length),
                  parameter_qualifier, control_block.received_directives, status);
          = nfc$file_length =
            nfp$receive_parameter_06 (parameter_value (1, parameter_length), control_block.file_size, status);
          = nfc$operator_message =
            nfp$receive_parameter_07 (received_command, parameter_value (1, parameter_length),
                  parameter_qualifier, control_block.received_operator_messages, status);
          = nfc$user_message =
            nfp$receive_parameter_08 (received_command, parameter_value (1, parameter_length),
                  parameter_qualifier, control_block.received_user_messages, status);
          = nfc$account_message =
            nfp$receive_parameter_09 (received_command, parameter_value (1, parameter_length),
                  parameter_qualifier, control_block.received_account_messages, status);
          = nfc$error_log_message =
            nfp$receive_parameter_10 (received_command, parameter_value (1, parameter_length),
                  parameter_qualifier, control_block.received_errorlog_messages, status);
          = nfc$special_options =
            nfp$receive_parameter_11 (parameter_value (1, parameter_length), parameter_qualifier,
                  control_block.receive_special_options, status);
          = nfc$max_block_size =
            nfp$receive_parameter_12 (parameter_value (1, parameter_length), parameter_qualifier,
                  control_block.data_declaration, control_block.data_block_size, status);
          = nfc$accounting_limit =
            nfp$receive_parameter_13( parameter_value(1,parameter_length),
                  parameter_qualifier, received_command, control_block.accounting_limit, status);
          = nfc$file_name =
            nfp$receive_parameter_16 (parameter_value (1, parameter_length), control_block.receive_file_name,
                  status);
          = nfc$file_disposition =
            nfp$receive_parameter_17(parameter_value(1,parameter_length), received_command,
                  parameter_qualifier, control_block.disposition_code, status);
          = nfc$acknowledgment_window =
            nfp$receive_parameter_18(parameter_value(1,parameter_length), parameter_qualifier,
                  control_block.acknowledgment_window, status);
          = nfc$initial_checkmark =
            nfp$receive_parameter_19(parameter_value(1,parameter_length), parameter_qualifier,
                  control_block.initial_restart_checkmark, status);
          = nfc$minimum_timeout_interval =
            nfp$receive_parameter_20 (parameter_value (1, parameter_length), parameter_qualifier,
                  control_block.path, control_block.time_out, status);
          = nfc$mode_of_access =
            nfp$receive_parameter_21 (parameter_value (1, parameter_length), parameter_qualifier,
                  control_block.mode_of_access, control_block.mode_of_access_option, status);
          = nfc$host_type =
            nfp$receive_parameter_22 (parameter_value (1, parameter_length), parameter_qualifier,
                  control_block.remote_host_type, status);
          = nfc$transfer_phase_attribute =
            ;
          = nfc$source_lid =
            nfp$receive_parameter_24 (parameter_value (1, parameter_length), parameter_qualifier,
                  control_block.source_lid, status);
          = nfc$transfer_lid =
            nfp$receive_parameter_25 (received_command, parameter_value (1, parameter_length),
                  parameter_qualifier, control_block.remote_lid, control_block.remote_lid_length, status);
          = nfc$job_name =
            nfp$receive_parameter_26 (received_command, control_block.protocol_in_use,
                  parameter_value (1, parameter_length), parameter_qualifier, protocol_negotiation,
                  control_block.receive_job_name, status);
          = nfc$physical_id =
            nfp$receive_parameter_27 (received_command, parameter_value (1, parameter_length),
                  parameter_qualifier, control_block.remote_pid, control_block.remote_pid_length, status);
          = nfc$destination_host_type =
            nfp$receive_parameter_28 (parameter_value (1, parameter_length), parameter_qualifier,
                  control_block.requested_host_type, status);
          = nfc$echo =
            nfp$receive_parameter_29(parameter_value(1,parameter_length), control_block.received_echo_text);
          = nfc$attribute_continued =
            more_command_blocks := TRUE;
          = nfc$data_declaration =
            nfp$receive_parameter_31 (control_block.application, parameter_value (1, parameter_length),
                   parameter_qualifier, control_block.data_declaration, status);
          = nfc$system_routing_text =
            nfp$receive_parameter_32 (parameter_value (1, parameter_length), parameter_qualifier,
                  control_block.receive_systems_routing_text, status);
          = nfc$implicit_routing_text =
            nfp$receive_parameter_33 (parameter_value(1, parameter_length), parameter_qualifier,
                  control_block.receive_implicit_routing_text, status );
          = nfc$user_file_name =
            nfp$receive_parameter_51 (control_block.protocol_in_use, received_command,
                  parameter_value (1, parameter_length), parameter_qualifier,
                  control_block.network_buffer_list, control_block.user_file_name, status);
          = nfc$banner_date_and_time =
            nfp$receive_parameter_52 (control_block.protocol_in_use, received_command,
                  parameter_value (1, parameter_length), parameter_qualifier,
                  control_block.network_buffer_list, control_block.banner_date_and_time, status);
          = nfc$banner_routing_text =
            nfp$receive_parameter_53 (control_block.protocol_in_use, received_command,
                  parameter_value (1, parameter_length), parameter_qualifier,
                  control_block.network_buffer_list, control_block.banner_routing_text, status);
          = nfc$user_banner_text =
            nfp$receive_parameter_54 (control_block.protocol_in_use, received_command,
                  parameter_value (1, parameter_length), parameter_qualifier,
                  control_block.network_buffer_list, control_block.user_banner_message, status);
          = nfc$installation_banner_text =
            nfp$receive_parameter_55 (control_block.protocol_in_use, received_command,
                  parameter_value (1, parameter_length), parameter_qualifier,
                  control_block.network_buffer_list, control_block.installation_banner_message, status);
          = nfc$reposition_output_params =
            nfp$receive_parameter_56 (control_block.protocol_in_use, received_command,
                  parameter_value (1, parameter_length), parameter_qualifier,
                  control_block.reposition_output_file, status);
          = nfc$current_file_position =
            nfp$receive_parameter_57 (control_block.protocol_in_use, received_command,
                  parameter_value (1, parameter_length), parameter_qualifier,
                  control_block.current_file_position, status);
          = nfc$output_file_destination =
            nfp$receive_parameter_58 (control_block.protocol_in_use, received_command,
                  parameter_value (1, parameter_length), parameter_qualifier,
                  control_block.default_output_file_destination, status);
          = nfc$vertical_print_density =
            nfp$receive_parameter_59(parameter_value(1,parameter_length),
                  parameter_qualifier, control_block.vertical_print_density, status);
          = nfc$vfu_load_procedure =
            nfp$receive_parameter_60(parameter_value(1,parameter_length),
                  parameter_qualifier, control_block.vfu_load_procedure, status);
          = nfc$reserved_for_site_90 =
            ;
          = nfc$reserved_for_site_91 =
            ;
          = nfc$reserved_for_site_92 =
            ;
          = nfc$reserved_for_site_93 =
            ;
          = nfc$reserved_for_site_94 =
            ;
          = nfc$reserved_for_site_95 =
            ;
          = nfc$reserved_for_site_96 =
            ;
          = nfc$reserved_for_site_97 =
            ;
          = nfc$reserved_for_site_98 =
            ;
          = nfc$reserved_for_site_99 =
            ;
          ELSE
            nfp$set_internal_error ('nfp$crack_pdu, main loop', status);
            RETURN;
          CASEND;
          IF NOT status.normal THEN
            nfp$format_message_to_job_log (status);
            nfp$set_abnormal_if_normal (status,procedure_status);
          IFEND;
        IFEND;
      IFEND;
      buffer_position := buffer_position + parameter_length + nfc$param_header_size;
      IF parameter_modified THEN
        modified_params := modified_params + $nft$parameter_set [parameter_identifier];
      IFEND;
    FOREND;
    IF NOT procedure_status.normal THEN
      status := procedure_status;
    IFEND;

  PROCEND nfp$crack_pdu;
?? OLDTITLE ??
?? NEWTITLE := 'nfp$send_protocol_parameter_00', EJECT ??

  PROCEDURE nfp$send_protocol_parameter_00
    (    protocol: nft$parameter_00_values;
         qualifier: nft$parameter_qualifiers;
     VAR buffer_list: nft$network_buffer_list;
     VAR status: ost$status);

{                                                                             }
{ Procedure  nfp$send_protocol_parameter_00                                   }
{                                                                             }
{ Purpose    To send protocol parameter 00, the protocol identifier.          }
{                                                                             }
{ Description                                                                 }
{            This routine converts the protocol ID ordinal into a string      }
{            and puts it in the command buffer.                               }
{                                                                             }
{ Input parameters                                                            }
{            Protocol             : A-A protocol version                      }
{            Qualifier            : A-A protocol parameter qualifier          }
{            Buffer_list          : List of network buffers                   }
{                                                                             }
{ Output parameters                                                           }
{            Status               : Value returned by:                        }
{                                     nfp$specify_pdu_parameter               }
{                                                                             }
{ Algorithm                                                                   }
{            Convert protocol id ordinal to string                            }
{            nfp$specify_pdu_parameter(string)                                }
{                                                                             }
?? EJECT ??

    VAR
      nfv$p00_values: [XREF] nft$p00_values;

    {}
    status.normal := TRUE;
    nfp$specify_pdu_parameter (nfc$protocol_id, qualifier, nfv$p00_values [protocol].
          value (1, nfv$p00_values [protocol].length), buffer_list, status);
    {}
  PROCEND nfp$send_protocol_parameter_00;
?? OLDTITLE ??
?? NEWTITLE := 'nfp$send_protocol_parameter_01', EJECT ??

  PROCEDURE nfp$send_protocol_parameter_01
    (    file_size: nft$parameter_01_values;
         qualifier: nft$parameter_qualifiers;
     VAR buffer_list: nft$network_buffer_list;
     VAR status: ost$status);

    VAR
      parameter_value: string (nfc$p01_max_size);

    {
    { Procedure nfp$send_protocol_parameter_01
    {
    { Purpose   Send parameter 01, maximum file transfer size.
    {
    { Description
    {           Parameter 01 may be specified by the sender or the receiver
    {           to inform the remote application what is the maximum size
    {           it can send or receive.  Note:  NOS/VE does not send
    {           the parameter at present.
    {
    { Input parameters
    {           File_size            : Maximum file size in kilobytes
    {           Qualifier            : A-A protocol parameter qualifier
    {           Buffer_list          : List of current network buffers
    {
    { Output parameters
    {           Buffer_list          : List of current network buffers
    {           Status               : Can be any returned by:
    {                                  Clp$convert_integer_to_rjstring - or -
    {                                  nfp$specify_pdu_parameter
    {
    { Algorithm  Convert file size to a string value.
    {            Nfp$specify_pdu_parameter( string )
    {
?? EJECT ??
    {}
    status.normal := TRUE;
    clp$convert_integer_to_rjstring (file_size, nfc$p01_radix, nfc$p01_include_radix, nfc$p01_fill_char,
          parameter_value, status);
    IF status.normal THEN
      nfp$specify_pdu_parameter (nfc$maximum_file_length, qualifier, parameter_value, buffer_list, status);
    IFEND;
    {}
  PROCEND nfp$send_protocol_parameter_01;
?? OLDTITLE ??
?? NEWTITLE := 'nfp$send_protocol_parameter_03', EJECT ??

  PROCEDURE nfp$send_protocol_parameter_03
    (    qualifier: nft$parameter_qualifiers;
         send_p03: nft$parameter_03_value_set;
     VAR buffer_list: nft$network_buffer_list;
     VAR status: ost$status);

{                                                                             }
{ Procedure  nfp$send_protocol_parameter_03                                   }
{                                                                             }
{ Purpose    To send protocol parameter 03, facilities.                       }
{                                                                             }
{ Description                                                                 }
{            This routine takes a set of facilities which it specifies        }
{            for the remote host.  If the facilities set is empty, this       }
{            parameter is not specified.                                      }
{                                                                             }
{ Input parameters                                                            }
{            Qualifier            : A-A protocol parameter qualifer           }
{                                                                             }
{ Output parameters                                                           }
{            Send_p03             : Value specified                           }
{            Buffer_list          : List of current network buffers           }
{            Status               : Value returned by                         }
{                                     nfp$specify_pdu_parameter               }
{                                                                             }
{ Algorithm                                                                   }
{            Convert facility set to a string                                 }
{            Nfp$specify_pdu_parameter( facility_string )                     }
{                                                                             }
?? EJECT ??

    VAR
      nfv$p03_values: [XREF] nft$parameter_03_elements;

    VAR
      parameter_value: string (nfc$p03_max_size),
      parameter_length: nft$parameter_size,
      index: nft$facility_types;

    {}
    { Build the string }
    {}
    status.normal := TRUE;
    parameter_length := 0;
    FOR index := LOWERVALUE (nft$facility_types) TO UPPERVALUE (nft$facility_types) DO
      IF index IN send_p03 THEN
        parameter_length := parameter_length + 1;
        parameter_value (parameter_length, nfc$p03_element_size) := nfv$p03_values [index];
      IFEND;
    FOREND;
    {}
    { If the string has non-zero length, send it }
    {}
    IF parameter_length > 0 THEN
      nfp$specify_pdu_parameter (nfc$facilities, qualifier, parameter_value (1, parameter_length),
            buffer_list, status);
    IFEND;
    {}
  PROCEND nfp$send_protocol_parameter_03;
?? OLDTITLE ??
?? NEWTITLE := 'nfp$send_protocol_parameter_04', EJECT ??

  PROCEDURE nfp$send_protocol_parameter_04
    (    state: ost$status;
         qualifier: nft$parameter_qualifiers;
     VAR buffer_list: nft$network_buffer_list;
     VAR status: ost$status);

    {
    { Procedure  nfp$send_protocol_parameter_04
    {
    { Purpose    Send parameter 04, state of transfer.
    {
    { Description
    {            The internal state of transfer is translated into the
    {            string A-A value.  This value is then placed in the next
    {            outgoing PDU by calling nfp$specify_pdu_parameter.
    {
    { Input parameters
    {            State         : Status variable
    {            Qualifier     : A-A protocol parameter qualifier
    {            Buffer_list   : List of current network buffers
    {
    { Output parameters
    {            Status        : Return status =
    {                              Any returned by nfp$specify_pdu_parameter.
    { Algorithm
    {            Loop through known State Codes
    {              If code matches internal status  then
    {                exit loop
    {              Ifend
    {            Loopend
    {            If known, nfp$specify_pdu_parameter
    {
?? EJECT ??
    {}

    VAR
      found_it: boolean,
      index: 1 .. nfc$p04_max_transfer_states,
      nfv$p04_values: [XREF] nft$parameter_04_values,
      parameter_value: string (nfc$p04_max_param_len);

    {}
    status.normal := TRUE;
    IF state.normal THEN
      parameter_value := nfv$p04_values [1].code;
    ELSE
      found_it := FALSE;

    /forloop/
      FOR index := LOWERVALUE (index) TO UPPERVALUE (index) DO

        IF (state.normal = nfv$p04_values [index].normal) AND
              (state.condition = nfv$p04_values [index].condition) THEN
          found_it := TRUE;
          EXIT /forloop/;
        IFEND;
      FOREND /forloop/;
      IF found_it THEN
        parameter_value := nfv$p04_values [index].code;
      ELSE
        nfp$set_internal_error ('nfp$send_protocol_parameter_04', status);
        RETURN;
      IFEND;
    IFEND;
    {}
    nfp$specify_pdu_parameter (nfc$state_of_transfer, qualifier, parameter_value, buffer_list, status);
    {}
  PROCEND nfp$send_protocol_parameter_04;
?? OLDTITLE ??
?? NEWTITLE := 'nfp$send_protocol_parameter_05', EJECT ??

  PROCEDURE nfp$send_protocol_parameter_05
    (    directive_list: ^nft$directive_entry;
         qualifier: nft$parameter_qualifiers;
     VAR buffer_list: nft$network_buffer_list;
     VAR status: ost$status);

{                                                                             }
{ Procedure  nfp$send_protocol_parameter_05                                   }
{                                                                             }
{ Purpose    Send parameter 05, user text directives.                         }
{                                                                             }
{ Description                                                                 }
{            Initiator applications (i.e. ptfi,qtfi) must/may send text       }
{            to the remote servicer for processing.  A list of text is        }
{            passed to this module, and each list element is specified        }
{            as a separate parameter on the next out going pdu(s).            }
{                                                                             }
{ Input parameters                                                            }
{            Directive_list: Linked list of directives                        }
{            Qualifier     : A-A protocol parameter qualifier                 }
{            Buffer_list   : List of current network buffers                  }
{                                                                             }
{ Output parameters                                                           }
{            Status        : Return status =                                  }
{                                 Any returned by nfp$specify_pdu_parameter   }
{                                                                             }
{ Algorithm                                                                   }
{            While more directives do
{
{              Nfp$specify_pdu_parameter                                      }
{                If error, return                                             }
{            Whilend                                                          }
{                                                                             }
?? EJECT ??
{}

    VAR
      directive_pointer: ^nft$directive_entry;

{}
    status.normal := TRUE;
    directive_pointer := directive_list;
    WHILE directive_pointer <> NIL DO
      nfp$specify_pdu_parameter (nfc$user_text_directive, qualifier, directive_pointer^.line, buffer_list,
            status);
      IF NOT status.normal THEN
        RETURN;
      IFEND;
      directive_pointer := directive_pointer^.link;
    WHILEND;
{}
  PROCEND nfp$send_protocol_parameter_05;
?? OLDTITLE ??
?? NEWTITLE := '[XDCL] nfp$enqueue_directive_on_list', EJECT ??

  PROCEDURE [XDCL] nfp$enqueue_directive_on_list
    (    directive_value: string ( * <= nfc$max_param_size);
     VAR directive_list: nft$directive_entry_list_head;
     VAR status: ost$status);

{                                                                             }
{ Procedure  nfp$enqueue_directive_on_list                                    }
{                                                                             }
{ Purpose    To enqueue a string onto a directive list.                       }
{                                                                             }
{ Description                                                                 }
{            This routine allocates a directive entry for the input string,   }
{            then enqueues the directive entry on the specified list.         }
{                                                                             }
{ Input parameters                                                            }
{            Directive_value             : Input string                       }
{                                                                             }
{ Output parameters                                                           }
{            Directive_list              : List of directives + new one       }
{            Status                      : Return status                      }
{                                                                             }
{ Algorithm                                                                   }
{            Allocate directive entry                                         }
{            Copy input string into directive entry                           }
{            Enqueue directive entry                                          }
{                                                                             }
?? EJECT ??

    VAR
      check_entry: ^nft$directive_entry,
      current_entry: ^nft$directive_entry;

{}
    status.normal := TRUE;
    ALLOCATE current_entry: [#SIZE (directive_value)];
    IF current_entry = NIL THEN
      osp$set_status_abnormal (nfc$status_id, nfe$bts_internal_error,
            'nfp$enqueue_directive_on_list no space', status);
      RETURN;
    IFEND;
    current_entry^.line := directive_value;
    current_entry^.link := NIL;
    IF directive_list.head = NIL THEN
      directive_list.head := current_entry;
    ELSE
      check_entry := directive_list.head;
      WHILE check_entry^.link <> NIL DO
        check_entry := check_entry^.link;
      WHILEND;
      check_entry^.link := current_entry;
    IFEND;
    directive_list.tail := current_entry;
{}
  PROCEND nfp$enqueue_directive_on_list;
?? OLDTITLE ??
?? NEWTITLE := '[XDCL] nfp$enqueue_status_directive', EJECT ??

  PROCEDURE [XDCL] nfp$enqueue_status_directive
    (    send_status: ost$status;
     VAR directive_list: nft$directive_entry_list_head;
     VAR status: ost$status);

{                                                                             }
{ Procedure  nfp$enqueue_status_directive                                     }
{                                                                             }
{ Purpose    To convert a VE status message to a string and place that        }
{            string on a directive list.                                      }
{                                                                             }
{ Description                                                                 }
{            This routine converts the status into one or more messages       }
{            and places each message on the specified directive list.         }
{                                                                             }
{ Input parameters                                                            }
{            Send_status          : Input status                              }
{                                                                             }
{ Output parameters                                                           }
{            Directive_list       : List of directives + new ones             }
{            Status               : Return status                             }
{                                                                             }
{ Algorithm                                                                   }
{            osp$format_message                                               }
{            For index = 1 to number of lines                                 }
{              nfp$enqueue_directive_on_list line(index)                      }
{            Forend                                                           }
{                                                                             }
?? EJECT ??

    VAR
      index: 1 .. osc$max_status_message_lines,
      message: ost$status_message,
      msg_line_count: ^ost$status_message_line_count,
      msg_line_size: ^ost$status_message_line_size,
      msg_line_text: ^string ( * ),
      pointer: ^ost$status_message;

{}
    status.normal := TRUE;
    osp$format_message (send_status, osc$full_message_level, nfc$trace_commands_width, message, status);
    IF NOT status.normal THEN
      RETURN;
    IFEND;
    pointer := ^message;
    RESET pointer;
    NEXT msg_line_count IN pointer;
    FOR index := 1 TO msg_line_count^ DO
      NEXT msg_line_size IN pointer;
      NEXT msg_line_text: [msg_line_size^] IN pointer;
      nfp$enqueue_directive_on_list (msg_line_text^, directive_list, status);
      IF NOT status.normal THEN
        RETURN;
      IFEND;
    FOREND;
  PROCEND nfp$enqueue_status_directive;
?? OLDTITLE ??
?? NEWTITLE := '[XDCL] nfp$dequeue_directives_on_list', EJECT ??

  PROCEDURE [XDCL] nfp$dequeue_directives_on_list
    (VAR directive_head: ^nft$directive_entry;
     VAR status: ost$status);

{                                                                             }
{ Procedure  nfp$dequeue_directives_on_list                                   }
{                                                                             }
{ Purpose    To deallocate all directives on a directive list.                }
{            WARNING: directives must have been ALLOCATED onto list           }
{            using nfp$enqueue_directive_on_list or                           }
{            nfp$enqueue_status_directive.  Applications PUSHING directive    }
{            lists must NOT use this routine.                                 }
{                                                                             }
{ Description                                                                 }
{            Each directive on the list is dequeued and deallocated.  The     }
{            list header is returned NIL.  Any failure to deallocate space    }
{            will result in the local condition handler returning an error    }
{            to the caller (the application will not blow up!).               }
{                                                                             }
{ Input parameters                                                            }
{            None                                                             }
{                                                                             }
{ Output parameters                                                           }
{            Directive_head       : Head of directive list                    }
{            Status               : Returned status                           }
{                                                                             }
{ Algorithm                                                                   }
{            While directives on list DO                                      }
{              Dequeue directive                                              }
{              Deallocate directive                                           }
{            Whilend                                                          }
{            Directive header = NIL                                           }
{                                                                             }
?? EJECT ??

    PROCEDURE nfp$dequeue_directives_handler
      (    condition: pmt$condition;
           condition_desc: ^pmt$condition_information;
           save_area: ^ost$stack_frame_save_area;
       VAR trap_status: ost$status);

{}

      VAR
        local_status: ost$status;

{}
      osp$set_status_from_condition (nfc$status_id, condition, save_area, status, local_status);
      IF NOT local_status.normal THEN
        status := local_status;
      IFEND;
      trap_status.normal := TRUE;
      EXIT nfp$dequeue_directives_on_list;
{}
    PROCEND nfp$dequeue_directives_handler;

    VAR
      condition_descriptor: pmt$established_handler,
      current_entry: ^nft$directive_entry,
      free_ptr: ^nft$directive_entry,
      handler_conditions: pmt$condition,
      ignore_status: ost$status;

{}
    status.normal := TRUE;
    current_entry := directive_head;
    handler_conditions.selector := pmc$condition_combination;
    handler_conditions.combination := $pmt$condition_combination [mmc$segment_access_condition];
    pmp$establish_condition_handler (handler_conditions, ^nfp$dequeue_directives_handler,
          ^condition_descriptor, status);
    IF NOT status.normal THEN
      RETURN;
    IFEND;
    WHILE current_entry <> NIL DO
      free_ptr := current_entry;
      current_entry := current_entry^.link;
      FREE free_ptr;
    WHILEND;
    directive_head := NIL;
    pmp$disestablish_cond_handler (handler_conditions, ignore_status);
{}
  PROCEND nfp$dequeue_directives_on_list;
?? OLDTITLE ??
?? NEWTITLE := '[XDCL] nfp$deallocate_dirs_from_head', EJECT ??

  PROCEDURE [XDCL] nfp$deallocate_dirs_from_head
    (VAR directive_head: nft$directive_entry_list_head;
     VAR status: ost$status);

{                                                                             }
{ Procedure  nfp$deallocate_dirs_from_head                                    }
{                                                                             }
{ Purpose    To dequeue and deallocate directives from a list head of type    }
{            nft$directive_entry_list_head.                                   }
{                                                                             }
{ Description                                                                 }
{            This routine simply calls nfp$dequeue_directives_on_list and     }
{            sets the tail of the list to NIL.                                }
{                                                                             }
{ Input parameters                                                            }
{            None                                                             }
{                                                                             }
{ Output parameters                                                           }
{            Directive_head       : List head of directive list               }
{            Status               : Return status                             }
{                                                                             }
{ Algorithm                                                                   }
{            Call nfp$dequeue_directives_on_list to deallocate list           }
{            If o.k., set tail to NIL.                                        }
{                                                                             }
?? EJECT ??
    status.normal := TRUE;
    nfp$dequeue_directives_on_list (directive_head.head, status);
    IF status.normal THEN
      directive_head.tail := NIL;
    IFEND;
{}
  PROCEND nfp$deallocate_dirs_from_head;
?? OLDTITLE ??
?? NEWTITLE := 'nfp$send_protocol_parameter_06', EJECT ??

  PROCEDURE nfp$send_protocol_parameter_06
    (    file_size: nft$parameter_06_values;
         qualifier: nft$parameter_qualifiers;
     VAR buffer_list: nft$network_buffer_list;
     VAR status: ost$status);

{                                                                             }
{ Procedure nfp$send_protocol_parameter_06
{           }
{                                                                             }
{ Purpose   To send parameter 06, size of file to be transferred.             }
{                                                                             }
{ Description                                                                 }
{            The size of the file being transferred in converted into         }
{            kilobytes.  NOTE:  Since VE does not do file preallocation,      }
{            this parameter is only usefull when talking to non-VE            }
{            systems.                                                         }
{                                                                             }
{ Input parameters                                                            }
{            File_size     : Length of file in bytes                          }
{            Qualifier     : A-A protocol parameter qualifier                 }
{                                                                             }
{ Output parameters                                                           }
{            Buffer_list   : List of current network buffers                  }
{            Status        : Any returned by                                  }
{                                 Clp$convert_integer_to_rjstring             }
{                                 Nfp$specify_pdu_parameter                   }
{                                                                             }
{ Algorithm                                                                   }
{            Convert size to string                                           }
{            Nfp$specify_pdu_parameter(string)                                }
{                                                                             }
?? EJECT ??
{}

    VAR
      converted_file_size: nfc$p06_min_value..nfc$p06_max_value,
      parameter_value: string (nfc$p06_max_param_len);

{}
    status.normal := TRUE;

    converted_file_size := (file_size DIV nfc$p06_unit) + 1;
    IF converted_file_size > nfc$p06_max_value THEN
      converted_file_size := nfc$p06_max_value;
    IFEND;
    clp$convert_integer_to_rjstring (converted_file_size, nfc$p06_radix, nfc$p06_include_radix,
          nfc$p06_fill_char, parameter_value, status);
    IF status.normal THEN
      nfp$specify_pdu_parameter (nfc$file_length, qualifier, parameter_value, buffer_list, status);
    IFEND;
{}
  PROCEND nfp$send_protocol_parameter_06;
?? OLDTITLE ??
?? NEWTITLE := 'nfp$send_protocol_parameter_07', EJECT ??

  PROCEDURE nfp$send_protocol_parameter_07
    (    message_list: ^nft$directive_entry;
         qualifier: nft$parameter_qualifiers;
         maximum_message_length: nft$parameter_size;
     VAR buffer_list: nft$network_buffer_list;
     VAR status: ost$status);

{                                                                             }
{ Procedure nfp$send_protocol_parameter_07
{
{                                                                             }
{ Purpose   To send parameter 07, operator system message.                    }
{                                                                             }
{ Description                                                                 }
{            This routine takes a list of strings and sends them as protocol  }
{            parameters.  If necessary, the individual strings are            }
{            "chopped" into pieces to fit in the protocol.                    }
{                                                                             }
{ Input parameters                                                            }
{            message_list         : Linked list of message strings            }
{            qualifier            : A-A protocol parameter qualifier          }
{            maximum_message_length: Max size of protocol parameter           }
{                                                                             }
{ Output parameters                                                           }
{            buffer_list          : List of protocol command buffers          }
{            status               : Return status                             }
{                                                                             }
{ Algorithm                                                                   }
{            While directives left do                                         }
{              Chop directive if neccessary                                   }
{              Nfp$specify_chopped pieces                                     }
{            Whilend                                                          }
{                                                                             }
?? EJECT ??

    VAR
      current_entry: ^nft$directive_entry,
      message_length: integer,
      message_index: integer;

{}
    status.normal := TRUE;
    current_entry := message_list;
    WHILE current_entry <> NIL DO
      message_length := STRLENGTH (current_entry^.line);
      message_index := 1;

    /send_07_loop/
      WHILE message_index <= message_length DO
        IF (message_length - message_index + 1) > maximum_message_length THEN
          nfp$specify_pdu_parameter (nfc$operator_message, qualifier, current_entry^.
                line (message_index, maximum_message_length), buffer_list, status);
          IF NOT status.normal THEN
            RETURN;
          IFEND;
          message_index := message_index + maximum_message_length;
        ELSE
          nfp$specify_pdu_parameter (nfc$operator_message, qualifier, current_entry^.line (message_index, * ),
                buffer_list, status);
          IF NOT status.normal THEN
            RETURN;
          IFEND;
          EXIT /send_07_loop/;
        IFEND;
      WHILEND /send_07_loop/;
      current_entry := current_entry^.link;
    WHILEND;
{}
  PROCEND nfp$send_protocol_parameter_07;
?? OLDTITLE ??
?? NEWTITLE := 'nfp$send_protocol_parameter_08', EJECT ??

  PROCEDURE nfp$send_protocol_parameter_08
    (    protocol: nft$parameter_00_values;
         message_list: ^nft$directive_entry;
         qualifier: nft$parameter_qualifiers;
         maximum_message_length: nft$parameter_size;
     VAR buffer_list: nft$network_buffer_list;
     VAR status: ost$status);

{                                                                             }
{ Procedure nfp$send_protocol_parameter_08
{                                                                             }
{ Purpose   To send parameter 08, user message.                               }
{                                                                             }
{ Description                                                                 }
{            This routine takes a list of strings and sends them as protocol  }
{            parameters.  If necessary, the individual strings are            }
{            "chopped" into pieces to fit in the protocol.                    }
{                                                                             }
{ Input parameters                                                            }
{            message_list         : Linked list of message strings            }
{            qualifier            : A-A protocol parameter qualifier          }
{            maximum_message_length: Max size of protocol parameter           }
{                                                                             }
{ Output parameters                                                           }
{            buffer_list          : List of protocol command buffers          }
{            status               : Return status                             }
{                                                                             }
{ Algorithm                                                                   }
{            While directives left do                                         }
{              Chop directive if neccessary                                   }
{              Nfp$specify_chopped pieces                                     }
{            Whilend                                                          }
{                                                                             }
?? EJECT ??

    VAR
      current_entry: ^nft$directive_entry,
      message_length: integer,
      message_index: integer;

{}
    status.normal := TRUE;
    current_entry := message_list;
    WHILE current_entry <> NIL DO
      message_length := STRLENGTH (current_entry^.line);
      message_index := 1;

    /send_08_loop/
      WHILE message_index <= message_length DO
        IF (message_length - message_index + 1) > maximum_message_length THEN
          nfp$specify_pdu_parameter (nfc$user_message, qualifier, current_entry^.
                line (message_index, maximum_message_length), buffer_list, status);
          IF NOT status.normal THEN
            RETURN;
          IFEND;
          message_index := message_index + maximum_message_length;
        ELSE
          nfp$specify_pdu_parameter (nfc$user_message, qualifier, current_entry^.line (message_index, * ),
                buffer_list, status);
          IF NOT status.normal THEN
            RETURN;
          IFEND;
          EXIT /send_08_loop/;
        IFEND;
      WHILEND /send_08_loop/;
      current_entry := current_entry^.link;
    WHILEND;
{}
  PROCEND nfp$send_protocol_parameter_08;
?? OLDTITLE ??
?? NEWTITLE := 'nfp$send_protocol_parameter_09', EJECT ??

  PROCEDURE nfp$send_protocol_parameter_09
    (    protocol: nft$parameter_00_values;
         message_list: ^nft$directive_entry;
         qualifier: nft$parameter_qualifiers;
         maximum_message_length: nft$parameter_size;
     VAR buffer_list: nft$network_buffer_list;
     VAR status: ost$status);

    {
    { Procedure nfp$send_protocol_parameter_09
    {
    { Purpose   To send parameter 09, account message.
    {
    { Description
    {            This routine takes a list of strings and sends them as protocol  }
    {            parameters.  If necessary, the individual strings are            }
    {            "chopped" into pieces to fit in the protocol.                    }
    {                                                                             }
    { Input parameters
    {            message_list         : Linked list of message strings            }
    {            qualifier            : A-A protocol parameter qualifier          }
    {            maximum_message_length: Max size of protocol parameter           }
    {
    { Output parameters
    {            buffer_list          : List of protocol command buffers          }
    {            status               : Return status                             }
    {
    { Algorithm
    {            While directives left do
    {              Chop directive if neccessary
    {              Nfp$specify_chopped pieces
    {            Whilend
    {
?? EJECT ??

    VAR
      current_entry: ^nft$directive_entry,
      message_length: integer,
      message_index: integer;

{}
    status.normal := TRUE;
    current_entry := message_list;
    WHILE current_entry <> NIL DO
      message_length := STRLENGTH (current_entry^.line);
      message_index := 1;

    /send_09_loop/
      WHILE message_index <= message_length DO
        IF (message_length - message_index + 1) > maximum_message_length THEN
          nfp$specify_pdu_parameter (nfc$account_message, qualifier, current_entry^.
                line (message_index, maximum_message_length), buffer_list, status);
          IF NOT status.normal THEN
            RETURN;
          IFEND;
          message_index := message_index + maximum_message_length;
        ELSE
          nfp$specify_pdu_parameter (nfc$account_message, qualifier, current_entry^.line (message_index, * ),
                buffer_list, status);
          IF NOT status.normal THEN
            RETURN;
          IFEND;
          EXIT /send_09_loop/;
        IFEND;
      WHILEND /send_09_loop/;
      current_entry := current_entry^.link;
    WHILEND;
    {}
  PROCEND nfp$send_protocol_parameter_09;
?? OLDTITLE ??
?? NEWTITLE := 'nfp$send_protocol_parameter_10', EJECT ??

  PROCEDURE nfp$send_protocol_parameter_10
    (    protocol: nft$parameter_00_values;
         message_list: ^nft$directive_entry;
         qualifier: nft$parameter_qualifiers;
         maximum_message_length: nft$parameter_size;
     VAR buffer_list: nft$network_buffer_list;
     VAR status: ost$status);

    {
    { Procedure nfp$send_protocol_parameter_10
    {
    { Purpose   To send parameter 10, account message.
    {
    { Description
    {            This routine takes a list of strings and sends them as protocol  }
    {            parameters.  If necessary, the individual strings are            }
    {            "chopped" into pieces to fit in the protocol.                    }
    {                                                                             }
    { Input parameters
    {            message_list         : Linked list of message strings            }
    {            qualifier            : A-A protocol parameter qualifier          }
    {            maximum_message_length: Max size of protocol parameter           }
    {
    { Output parameters
    {            buffer_list          : List of protocol command buffers          }
    {            status               : Return status                             }
    {
    { Algorithm
    {            While directives left do
    {              Chop directive if neccessary
    {              Nfp$specify_chopped pieces
    {            Whilend
    {
?? EJECT ??

    VAR
      current_entry: ^nft$directive_entry,
      message_length: integer,
      message_index: integer;

{}
    status.normal := TRUE;
    current_entry := message_list;
    WHILE current_entry <> NIL DO
      message_length := STRLENGTH (current_entry^.line);
      message_index := 1;

    /send_10_loop/
      WHILE message_index <= message_length DO
        IF (message_length - message_index + 1) > maximum_message_length THEN
          nfp$specify_pdu_parameter (nfc$error_log_message, qualifier, current_entry^.
                line (message_index, maximum_message_length), buffer_list, status);
          IF NOT status.normal THEN
            RETURN;
          IFEND;
          message_index := message_index + maximum_message_length;
        ELSE
          nfp$specify_pdu_parameter (nfc$error_log_message, qualifier, current_entry^.
                line (message_index, * ), buffer_list, status);
          IF NOT status.normal THEN
            RETURN;
          IFEND;
          EXIT /send_10_loop/;
        IFEND;
      WHILEND /send_10_loop/;
      current_entry := current_entry^.link;
    WHILEND;
    {}
  PROCEND nfp$send_protocol_parameter_10;
?? OLDTITLE ??
?? NEWTITLE := 'nfp$send_protocol_parameter_11', EJECT ??

  PROCEDURE nfp$send_protocol_parameter_11
    (    remote_type: nft$parameter_22_values;
         special_options: nft$parameter_11_value;
         qualifier: nft$parameter_qualifiers;
     VAR buffer_list: nft$network_buffer_list;
     VAR status: ost$status);

    {
    { Procedure  nfp$send_protocol_parameter_11
    {
    { Purpose    To send protocol parameter 11, special options.
    {            The special options parameter is used in VE <-> VE
    {            transfers to pass NOS/VE status.
    {
    { Description
    {            The status variable is converted to a string and passed
    {            in a pdu.
    {
    { Input parameters
    {            Remote_type   : Remote host type (i.e. IBM)
    {            Special_options: The parameter string to send
    {            Qualifier     : A-A protocol parameter qualifier
    {
    { Output parameters
    {            Buffer_list   : List of current network buffers
    {            Status        : Any value returned by
    {                                 Clp$convert_integer_to_rjstring
    {                                 Nfp$specify_pdu_parameter
    {
    { Algorithm
    {            Nfp$specify_pdu_parameter
    {
?? EJECT ??
{}

{}
    status.normal := TRUE;
    nfp$specify_pdu_parameter (nfc$special_options, qualifier, special_options.
            value (1, special_options.size), buffer_list, status);
{}
  PROCEND nfp$send_protocol_parameter_11;
?? OLDTITLE ??
?? NEWTITLE := 'nfp$send_protocol_parameter_12', EJECT ??

  PROCEDURE nfp$send_protocol_parameter_12
    (    protocol_id: nft$parameter_00_values;
         block_size: nft$parameter_12_range;
         qualifier: nft$parameter_qualifiers;
     VAR buffer_list: nft$network_buffer_list;
     VAR status: ost$status);

    {
    { Procedure  nfp$send_protocol_parameter_12
    {
    { Purpose    To add protocol parameter 12, data block size, to the next
    {            send PDU.
    {
    { Description
    {            The block size is changed from nft$parameter_12_range to a
    {            string by Clp$convert_integer_to_rjstring.  The resulting
    {            string is then placed in the PDU by calling
    {            nfp$specify_pdu_parameter.
    {
    { Input parameters
    {               protocol_id:  A-A protocol version ordinal
    {               block_size:   Application requested block size
    {               qualifier:    A-A protocol parameter qualifier
    {
    { Output parameters
    {            buffer_list: List of current network buffers
    {            Status : normal or a result of:
    {                          clp$convert_integer_to_rjstring -or-
    {                          nfp$specify_pdu_parameter
    {
    { Algorithm
    {            Convert size to string
    {            Enter string in PDU
    {}
?? EJECT ??
    {}

    VAR
      parameter: ^string ( * );

    {}
    status.normal := TRUE;
    CASE protocol_id OF
    = nfc$p00_a102 =
      PUSH parameter: [nfc$p12_max_size_a102];
    = nfc$p00_a101 =
      PUSH parameter: [nfc$p12_max_size_a101];
    = nfc$p00_b101 =
      PUSH parameter: [nfc$p12_max_size_b101];
    ELSE
      nfp$set_internal_error ('nfp$send_protocol_parameter_12 Protid case', status);
      pmp$exit (status);
    CASEND;
    clp$convert_integer_to_rjstring (block_size, nfc$p12_radix, nfc$p12_include_radix, nfc$p12_fill_char,
          parameter^, status);
    IF status.normal THEN
      nfp$specify_pdu_parameter (nfc$max_block_size, qualifier, parameter^, buffer_list, status);
    IFEND;
    {}
  PROCEND nfp$send_protocol_parameter_12;
?? OLDTITLE ??
?? NEWTITLE := 'nfp$send_protocol_parameter_13', EJECT ??

  PROCEDURE nfp$send_protocol_parameter_13
    (    accounting_limit: nft$parameter_13_definition;
         qualifier: nft$parameter_qualifiers;
     VAR buffer_list: nft$network_buffer_list;
     VAR status: ost$status);
{
{ Procedure  nfp$send_protocol_parameter_13
{
{ Purpose    This routine sends parameter 13, accounting limit
{
{ Description
{            The accounting limit is converted from an integer
{            to a string and placed in a PDU.
{
{ Input parameters
{            accounting_limit:    value of accounting limit
{            qualifier:           protocol parameter qualifier
{
{ Output parameters
{            buffer_list:         list of network buffers
{            status:              return status
{
{ Algorithm
{            clp$convert_integer_to_string
{            If ok nfp$specify_pdu_parameter
{
VAR
      output_string: ost$string;
{}
  status.normal := TRUE;
  clp$convert_integer_to_string( accounting_limit,
      nfc$p13_radix, nfc$p13_include_radix, output_string,
      status);
  IF status.normal THEN
    nfp$specify_pdu_parameter( nfc$accounting_limit, qualifier,
      output_string.value(1,output_string.size), buffer_list,
      status);
  IFEND;
{}
  PROCEND nfp$send_protocol_parameter_13;
?? OLDTITLE ??
?? NEWTITLE := 'nfp$send_protocol_parameter_16', EJECT ??

  PROCEDURE nfp$send_protocol_parameter_16
    (    file_name: string ( * <= nfc$p16_max_param_length);
         protocol: nft$parameter_00_values;
         qualifier: nft$parameter_qualifiers;
         maximum_parameter_length: nft$parameter_size;
     VAR buffer_list: nft$network_buffer_list;
     VAR status: ost$status);

{
{ Procedure  nfp$send_protocol_parameter_16
{
{ Purpose    To send parameter 16, file name IO queue.
{            This parameter is used to exchange file-name/job-name
{            information between applications.
{
{ Description
{            The calling application must format P16 into a string
{            of correct length.
{
{ Input parameters
{            File_name     : Value to be sent
{            Qualifier     : A-A protocol parameter qualifier
{
{ Output parameters
{            Buffer_list   : List of A-A buffers to be sent
{            Status        : Return status
{
{ Algorithm
{            nfp$specify_pdu_parameter
{
?? EJECT ??
    CONST
{ This parameter specifies the system name for the queue file. It has the  }
{ format of $DDDD_DDDD_AAA_DDDD where D indicates a digit and A indicates  }
{ a alphabet. Set byte offset equal 11 will skip the digits that are in    }
{ front of the first alphabet and pick AAADDDD as the file name.           }
{}
      byte_offset = 11;

    VAR
      index: nft$parameter_size,
      input_parameter_length: nft$parameter_size,
      parameter_length: nft$parameter_size,
      scratch_index: nft$parameter_size,
      scratch_string: ^string ( * );

{}
    status.normal := TRUE;
    input_parameter_length := STRLENGTH (file_name);
    CASE protocol OF

    = nfc$p00_a101 =
      PUSH scratch_string: [maximum_parameter_length];
      parameter_length := 0;
      scratch_index := 1;

    /a101_for_loop/
      FOR index := 1+byte_offset TO input_parameter_length DO
        IF (($INTEGER (file_name (index)) >= $INTEGER (nfc$p16_1st_range1_a101)) AND
              ($INTEGER (file_name (index)) <= $INTEGER (nfc$p16_last_range1_a101))) OR
              (($INTEGER (file_name (index)) >= $INTEGER (nfc$p16_1st_range2_a101)) AND
              ($INTEGER (file_name (index)) <= $INTEGER (nfc$p16_last_range2_a101))) OR
              ($INTEGER (file_name (index)) = $INTEGER (nfc$p16_special1_a101)) OR
              ($INTEGER (file_name (index)) = $INTEGER (nfc$p16_special2_a101)) THEN
          scratch_string^ (scratch_index) := file_name (index);
          scratch_index := scratch_index + 1;
          parameter_length := parameter_length + 1;
          IF parameter_length = maximum_parameter_length THEN
            EXIT /a101_for_loop/;
          IFEND;
        IFEND;
      FOREND /a101_for_loop/;
      IF parameter_length < 0 THEN
        nfp$set_internal_error ('nfp$send_protocol_parameter_16 pl', status);
        RETURN;
      IFEND;

    = nfc$p00_a102, nfc$p00_b101 =

      IF maximum_parameter_length < input_parameter_length THEN
        parameter_length := maximum_parameter_length;
      ELSE
        parameter_length := input_parameter_length;
      IFEND;
      scratch_string := ^file_name;
    ELSE
      nfp$set_internal_error ('nfp$send_protocol_parameter_16 Protid case', status);
      pmp$exit (status);
    CASEND;

    nfp$specify_pdu_parameter (nfc$file_name, qualifier, scratch_string^ (1, parameter_length), buffer_list,
          status);


{}
  PROCEND nfp$send_protocol_parameter_16;
?? OLDTITLE ??
?? NEWTITLE := 'nfp$send_protocol_parameter_17', EJECT ??

  PROCEDURE nfp$send_protocol_parameter_17
    (    disposition: nft$parameter_17_definition;
         qualifier: nft$parameter_qualifiers;
     VAR buffer_list: nft$network_buffer_list;
     VAR status: ost$status);

    {
    { Procedure  nfp$send_protocol_parameter_17
    {
    { Purpose    To send protocol parameter 17, disposition code.
    {
    { Description
    {           The disposition code ordinal is changed to a string and
    {           sent as parameter 17.
    {
    { Input parameters
    {               Disposition:         Disposition code ordinal
    {               Qualifier:           A-A protocol parameter qualifier
    {
    { Output parameters
    {                   Buffer_list:  List of protocol command buffers.
    {                   Status:       As returned by nfp$specify_pdu_parameter.
    {
    { Algorithm  Call to nfp$specify_pdu_parameter.
    {
?? EJECT ??

    VAR
      nfv$parameter_17_values: [XREF] nft$parameter_17_values;

    {}
    status.normal := TRUE;
    nfp$specify_pdu_parameter (nfc$file_disposition, qualifier, nfv$parameter_17_values [disposition],
          buffer_list, status);
    {}
  PROCEND nfp$send_protocol_parameter_17;
?? OLDTITLE ??
?? NEWTITLE := 'nfp$send_protocol_parameter_18', EJECT ??
  PROCEDURE nfp$send_protocol_parameter_18
    (    acknowledgment_window: nft$parameter_18_definition;
         qualifier: nft$parameter_qualifiers;
     VAR buffer_list: nft$network_buffer_list;
     VAR status: ost$status);
{
{ Procedure  nfp$send_protocol_parameter_18
{
{ Purpose    To send protocol parameter 18, acknowledgment window
{
{ Description
{            This routine converts the p18 ordinal value to a string.
{
{ Input parameters
{            Acknowledgment_window:      Input value
{            Qualifier:                  A-A protocol parameter qualifier
{
{ Output parameters
{            Buffer_list:                List of active A-A buffers
{            Status:                     Return status
{
{ Algorithm
{            convert value to string
{            nfp$specify_pdu_parameter
{
VAR
      output_string: string(nfc$p18_maximum_parameter_size);
{}
  clp$convert_integer_to_rjstring( acknowledgment_window, nfc$p18_radix,
      nfc$p18_include_radix, nfc$p18_fill_character, output_string, status);
  IF status.normal THEN
   nfp$specify_pdu_parameter( nfc$acknowledgment_window, qualifier,
      output_string, buffer_list, status);
  IFEND;
{}
  PROCEND nfp$send_protocol_parameter_18;
?? OLDTITLE ??
?? NEWTITLE := 'nfp$send_protocol_parameter_19', EJECT ??
  PROCEDURE nfp$send_protocol_parameter_19
    (    initial_restart_checkmark: nft$parameter_19_definition;
         qualifier: nft$parameter_qualifiers;
     VAR buffer_list: nft$network_buffer_list;
     VAR status: ost$status);
{
{ Procedure  nfp$send_protocol_parameter_19
{
{ Purpose    To send protocol parameter 19, initial restart
{            checkmark.
{
{ Description
{            This routine converts the input subrange to a
{            string.  The string is then encoded into the
{            current (or next network buffer).
{
{ Input parameters
{            Initial_restart_checkmark:  Input value
{            Qualifier:                  A-A protocol parameter qualifier
{
{ Output parameters
{            Buffer_list:                List of current network buffers
{            Status:                     Return status
{
{ Algorithm
{            Convert value to string
{            nfp$specify_pdu_parameter
{
VAR
      output_string: string(nfc$p19_maximum_parameter_size);
{}
  clp$convert_integer_to_rjstring( initial_restart_checkmark, nfc$p19_radix,
      nfc$p19_include_radix, nfc$p19_fill_character, output_string, status);
  IF status.normal THEN
   nfp$specify_pdu_parameter( nfc$initial_checkmark, qualifier,
      output_string, buffer_list, status);
  IFEND;
{}
  PROCEND nfp$send_protocol_parameter_19;
?? OLDTITLE ??
?? NEWTITLE := 'nfp$send_protocol_parameter_20', EJECT ??

  PROCEDURE nfp$send_protocol_parameter_20
    (    protocol: nft$parameter_00_values;
         timeout_value: nft$parameter_20_range;
         qualifier: nft$parameter_qualifiers;
         parameter_length: nft$parameter_size;
     VAR buffer_list: nft$network_buffer_list;
     VAR status: ost$status);

    {
    { Procedure  nfp$send_protocol_parameter_20
    {
    { Purpose    To send protocol parameter 20, minimum time out value.
    {
    { Description
    {            This parameter specifies to the remote application what
    {            should
    {            be considered the minimum time out value for the transfer.
    {
    {
    { Input parameters
    {            Protocol      : A-A protocol version
    {            Timeout       : Time out value in seconds
    {            Qualifier     : A-A protocol parameter qualifier
    {            Parameter_length : Maximum length of parameter
    {
    { Output parameters
    {            Buffer_list   : List of current network buffers
    {            Status        : Any status returned by :
    {                                 Clp$convert_integer_to_rjstring
    {                                 Nfp$specify_pdu_parameter
    {
    { Algorithm
    {            Convert time to string
    {            Nfp$specify_pdu_parameter(string)
    {
?? EJECT ??
    {}

    VAR
      parameter: ^string ( * );

    {}
    status.normal := TRUE;
    PUSH parameter: [parameter_length];
    clp$convert_integer_to_rjstring (timeout_value, nfc$p20_radix, nfc$p20_include_radix, nfc$p20_fill_char,
          parameter^, status);
    IF status.normal THEN
      nfp$specify_pdu_parameter (nfc$minimum_timeout_interval, qualifier, parameter^, buffer_list, status);
    IFEND;
    {}
  PROCEND nfp$send_protocol_parameter_20;
?? OLDTITLE ??
?? NEWTITLE := 'nfp$send_protocol_parameter_21', EJECT ??

  PROCEDURE nfp$send_protocol_parameter_21
    (    protocol: nft$parameter_00_values;
         mode: nft$mode_of_access;
         option: nft$parameter_21_options;
         qualifier: nft$parameter_qualifiers;
         parameter_length: nft$parameter_size;
     VAR buffer_list: nft$network_buffer_list;
     VAR status: ost$status);

    {
    { Procedure  nfp$send_protocol_parameter_21
    {
    { Purpose    Send protocol parameter 21, mode of access.  This parameter
    {            is specified when the direction of the transfer in known.
    {
    { Description
    {            The state of transfer is ALWAYS given from the standpoint of
    {            the servicer.  For example, if the servicer is receiving the
    {            file, he returns TAKE.  If the initiator specifies the mode
    {            (as in QTF), and the mode is initiator sends file, he sends
    {            'TAKE'.  NOTE: NOS/VE does not process any mode option except
    {            0000, non-specific.
    {
    { Input parameters
    {            Protocol      : A-A Protocol version
    {            Mode          : Mode of access (GIVE,TAKE,NULL)
    {            Option        : Mode of access option
    {            Qualifier     : A-A Protocol parameter qualifier
    {            Parameter_length: Maximum length of this parameter
    {
    { Output parameters
    {            Buffer_list   : List of current network buffers
    {            Status        : Any value returned by
    {                                 nfp$specify_pdu_parameter
    {
    { Algorithm
    {            Convert parameter to string
    {            Nfp$specify_pdu_parameter(string)
    {
?? EJECT ??

    VAR
      parameter: ^string ( * );

    VAR
      nfv$p21_values: [XREF] nft$parameter_21_values;

    VAR
      nfv$p21_options: [XREF] nft$parameter_21_specifications;

    {}
    status.normal := TRUE;
    PUSH parameter: [parameter_length];
    parameter^ (nfc$p21_prefix_position, nfc$p21_prefix_length) := nfv$p21_values [mode];
    parameter^ (nfc$p21_opt_position, nfc$p21_opt_length) := nfv$p21_options [option];
    nfp$specify_pdu_parameter (nfc$mode_of_access, qualifier, parameter^, buffer_list, status);
    {}
  PROCEND nfp$send_protocol_parameter_21;
?? OLDTITLE ??
?? NEWTITLE := 'nfp$send_protocol_parameter_22', EJECT ??

  PROCEDURE nfp$send_protocol_parameter_22
    (    host_type: nft$parameter_22_values;
         qualifier: nft$parameter_qualifiers;
     VAR buffer_list: nft$network_buffer_list;
     VAR status: ost$status);

{                                                                             }
{ Procedure  nfp$send_protocol_parameter_22                                   }
{                                                                             }
{ Purpose    Send protocol parameter 22, host type.  This parameter is        }
{            sent to a remote host identifying its host type for special      }
{            processing consideration.                                        }
{                                                                             }
{ Description                                                                 }
{            The host type parameter allows like systems (i.e. NOS/VE <->     }
{            NOS/VE) to do some special things.  For example, we pass a       }
{            NOS/VE status parameter in P11 allowing the remote system        }
{            additional information on a transfer.                            }
{                                                                             }
{            Host_type     : Host type value                                  }
{            Qualifier     : A-A Protocol parameter qualifier                 }
{            Host_type     : Local host type                                  }
{                                                                             }
{ Output parameters                                                           }
{            Buffer_list   : List of current network buffers                  }
{            Status        : Any value returned by                            }
{                                 nfp$specify_pdu_parameter                   }
{ Algorithm                                                                   }
{            Nfp$specify_pdu_parameter(type)                                  }
{                                                                             }
?? EJECT ??
    {}

    VAR
      nfv$p22_values: [XREF] nft$parameter_22_strings;

    {}
    status.normal := TRUE;
    nfp$specify_pdu_parameter (nfc$host_type, qualifier, nfv$p22_values [host_type], buffer_list, status);
    {}
  PROCEND nfp$send_protocol_parameter_22;
?? OLDTITLE ??
?? NEWTITLE := 'nfp$send_protocol_parameter_24', EJECT ??

{ PURPOSE:
{   This procedure will send the protocol parameter 24, source lid.
{
{ NOTE:
{   This parameter may be truncated or extended to 3 characters for
{   the A101 protocol.

  PROCEDURE nfp$send_protocol_parameter_24
    (    source_lid: string ( * <= nfc$p24_max_param_size);
         qualifier: nft$parameter_qualifiers;
         minimum_parameter_length: nft$parameter_size;
         maximum_parameter_length: nft$parameter_size;
     VAR buffer_list: nft$network_buffer_list;
     VAR status: ost$status);

    VAR
      input_parameter_length: nft$parameter_size,
      parameter_length: nft$parameter_size,
      source_lid_value: string (nfc$p24_max_param_size);

    status.normal := TRUE;
    source_lid_value := source_lid;
    input_parameter_length := STRLENGTH(source_lid);
    IF input_parameter_length > maximum_parameter_length THEN
      parameter_length := maximum_parameter_length;
    ELSEIF input_parameter_length < minimum_parameter_length THEN
      parameter_length := minimum_parameter_length;
    ELSE
      parameter_length := input_parameter_length;
    IFEND;
    nfp$specify_pdu_parameter (nfc$source_lid, qualifier, source_lid_value (1, parameter_length),
          buffer_list, status);

  PROCEND nfp$send_protocol_parameter_24;
?? OLDTITLE ??
?? NEWTITLE := 'nfp$send_protocol_parameter_25', EJECT ??

  PROCEDURE nfp$send_protocol_parameter_25
    (    protocol: nft$parameter_00_values;
         transfer_lid: string ( * <= nfc$max_param_size);
         qualifier: nft$parameter_qualifiers;
         maximum_parameter_length: nft$parameter_size;
     VAR buffer_list: nft$network_buffer_list;
     VAR status: ost$status);

{                                                                             }
{ Procedure  nfp$send_protocol_parameter_25                                   }
{                                                                             }
{ Purpose    To send protocol parameter 25, transfer logical identifier.      }
{                                                                             }
{ Description                                                                 }
{            The transfer logical identifier (LID) is exchanged between       }
{            hosts during protocol negotiation.  It is used for network       }
{            control (LID's may be turned off) and tracking (LID's should     }
{            be logged) information.                                          }
{                                                                             }
{ Input parameters                                                            }
{            Protocol      : A-A Protocol version                             }
{            Transfer_lid  : Name of the transfer LID                         }
{            Qualifier     : A-A Protocol parameter qualifier                 }
{            Host_type     : Local host type                                  }
{            Maximum_Parameter_length: Maximum length for parameter           }
{                                                                             }
{ Output parameters                                                           }
{            Buffer_list   : List of current network buffers                  }
{            Status        : Any status returned by                           }
{                             nfp$specify_pdu_parameter                       }
{ Algorithm                                                                   }
{            Truncate LID to protocol maximum (if necessary)                  }
{            Nfp$specify_pdu_parameter                                        }
{                                                                             }
?? EJECT ??

    VAR
      input_parameter_length: nft$parameter_size,
      parameter_length: nft$parameter_size;

    {}
    status.normal := TRUE;
    input_parameter_length := STRLENGTH (transfer_lid);
    IF (input_parameter_length > maximum_parameter_length) THEN
      parameter_length := maximum_parameter_length;
    ELSE
      parameter_length := input_parameter_length;
    IFEND;
    nfp$specify_pdu_parameter (nfc$transfer_lid, qualifier, transfer_lid (1, parameter_length), buffer_list,
          status);
    {}
  PROCEND nfp$send_protocol_parameter_25;
?? OLDTITLE ??
?? NEWTITLE := 'nfp$send_protocol_parameter_26', EJECT ??

  PROCEDURE nfp$send_protocol_parameter_26
    (    protocol: nft$parameter_00_values;
         application: nft$application_values;
         job_name: string ( * <= nfc$max_param_size);
         qualifier: nft$parameter_qualifiers;
         maximum_parameter_length: nft$parameter_size;
     VAR buffer_list: nft$network_buffer_list;
     VAR status: ost$status);

{                                                                             }
{ Procedure  nfp$send_protocol_parameter_26                                   }
{                                                                             }
{ Purpose    To send protocol parameter 26, job name.                         }
{                                                                             }
{ Description                                                                 }
{            The job name parameter is exchanged between hosts for job        }
{            tracking.  NOTE: the protocol ID A101 forces NOS/VE to truncate  }
{            job names and fold characters.  Only allowed characters include  }
{                   A-Z, 0..9, $, #, and @.                                   }
{                                                                             }
{ Input parameters                                                            }
{            Protocol      : A-A Protocol version                             }
{            Job_name      : Name of the local job                            }
{            Qualifier     : A-A Protocol parameter qualifier                 }
{            Host_type     : Local host type                                  }
{            Maximum_parameter_length : Maximum size for parameter            }
{                                                                             }
{ Output parameters                                                           }
{            Buffer_list   : List of current network buffers                  }
{            Status        : Any status returned by                           }
{                             nfp$specify_pdu_parameter                       }
{ Algorithm                                                                   }
{            Case protocol ID of                                              }
{            =a101= Build a101 job name                                       }
{            =a102,b101= Build a102,b101 job name                             }
{            Nfp$specify_pdu_parameter                                        }
{                                                                             }
?? EJECT ??

    VAR
      byte_offset: 0 .. 11,
      index: nft$parameter_size,
      input_parameter_length: nft$parameter_size,
      parameter_length: nft$parameter_size,
      scratch_index: nft$parameter_size,
      scratch_string: ^string ( * );

{}
    status.normal := TRUE;
    input_parameter_length := STRLENGTH (job_name);
    CASE protocol OF

    = nfc$p00_a101 =
      PUSH scratch_string: [maximum_parameter_length];

{ For QTF, this parameter represents the user specified name of the job file. }
{ But for PTF, it represents the name of PTF/PTFS job which has the           }
{ format of $DDDD_DDDD_AAA_DDDD where D indicates a digit and A indicates     }
{ a alphabet. Set byte offset equal 11 will skip the digits that are in       }
{ front of the first alphabet and pick AAADDDD as the job name.               }
{}

      byte_offset := 0;
      IF ((application = nfc$application_ptf) OR
          (application = nfc$application_ptfs)) THEN
        byte_offset := 11;
      IFEND;
      parameter_length := 0;
      scratch_index := 1;

    /a101_for_loop/
      FOR index := 1+byte_offset TO input_parameter_length DO
        IF (($INTEGER (job_name (index)) >= $INTEGER (nfc$p26_1st_range1_a101)) AND
              ($INTEGER (job_name (index)) <= $INTEGER (nfc$p26_last_range1_a101))) OR
              (($INTEGER (job_name (index)) >= $INTEGER (nfc$p26_1st_range2_a101)) AND
              ($INTEGER (job_name (index)) <= $INTEGER (nfc$p26_last_range2_a101))) OR
              ($INTEGER (job_name (index)) = $INTEGER (nfc$p26_special1_a101)) OR
              ($INTEGER (job_name (index)) = $INTEGER (nfc$p26_special2_a101)) THEN
          scratch_string^ (scratch_index) := job_name (index);
          scratch_index := scratch_index + 1;
          parameter_length := parameter_length + 1;
          IF parameter_length = maximum_parameter_length THEN
            EXIT /a101_for_loop/;
          IFEND;
        IFEND;
      FOREND /a101_for_loop/;
      IF parameter_length < 0 THEN
        nfp$set_internal_error ('nfp$send_protocol_parameter_26 pl', status);
        RETURN;
      IFEND;

    = nfc$p00_a102, nfc$p00_b101 =

      IF maximum_parameter_length < input_parameter_length THEN
        parameter_length := maximum_parameter_length;
      ELSE
        parameter_length := input_parameter_length;
      IFEND;
      scratch_string := ^job_name;
    ELSE
      nfp$set_internal_error ('nfp$send_protocol_parameter_26 Protid case', status);
      pmp$exit (status);
    CASEND;

    nfp$specify_pdu_parameter (nfc$job_name, qualifier, scratch_string^ (1, parameter_length), buffer_list,
          status);

{}
  PROCEND nfp$send_protocol_parameter_26;
?? OLDTITLE ??
?? NEWTITLE := 'nfp$send_protocol_parameter_27', EJECT ??

  PROCEDURE nfp$send_protocol_parameter_27
    (    protocol: nft$parameter_00_values;
         physical_id: string ( * <= nfc$max_param_size);
         qualifier: nft$parameter_qualifiers;
         maximum_parameter_length: nft$parameter_size;
     VAR buffer_list: nft$network_buffer_list;
     VAR status: ost$status);

{                                                                             }
{ Procedure nfp$send_protocol_parameter_27
{           }
{                                                                             }
{ Purpose   Send parameter 27, physical id.                                   }
{                                                                             }
{ Description                                                                 }
{            The physical id parameter is exchanged between hosts for         }
{            network control and tracking purposes. Additionally, it is       }
{            used as the source LID is a store and forward environment if     }
{            no source lid is specified.                                      }
{                                                                             }
{ Input parameters                                                            }
{            Protocol      : A-A Protocol version                             }
{            Physical_id   : Input physical id                                }
{            Qualifier     : A-A Protocol parameter qualifier                 }
{            Maximum_parameter_length: Maximum # of characters in parameter   }
{                                                                             }
{ Output parameters                                                           }
{            Status        : Any status returned by                           }
{            Buffer_list   : List of current network buffers                  }
{                                 nfp$specify_pdu_parameter                   }
{ Algorithm                                                                   }
{            Format PID dependent on protocol varient                         }
{            Nfp$specify_pdu_parameter                                        }
{                                                                             }
?? EJECT ??

    VAR
      parameter_length: nft$parameter_size,
      input_parameter_length: integer;

    {}
    status.normal := TRUE;
    input_parameter_length := STRLENGTH (physical_id);
    IF input_parameter_length > maximum_parameter_length THEN
      parameter_length := maximum_parameter_length;
    ELSE
      parameter_length := input_parameter_length;
    IFEND;
    nfp$specify_pdu_parameter (nfc$physical_id, qualifier, physical_id (1, parameter_length), buffer_list,
          status);
    {}
  PROCEND nfp$send_protocol_parameter_27;
?? OLDTITLE ??
?? NEWTITLE := 'nfp$send_protocol_parameter_28', EJECT ??

  PROCEDURE nfp$send_protocol_parameter_28
    (    dest_host_type: nft$parameter_22_values;
         qualifier: nft$parameter_qualifiers;
     VAR buffer_list: nft$network_buffer_list;
     VAR status: ost$status);

{                                                                             }
{ Procedure  nfp$send_protocol_parameter_28                                   }
{                                                                             }
{ Purpose    To send protocol parameter 28, destination host type.            }
{                                                                             }
{ Description                                                                 }
{            This parameter is specified when a host assumes its partner      }
{            is a given host type.  If that assumption is wrong, the          }
{            parameter should be returned modified.                           }
{                                                                             }
{ Input parameters                                                            }
{            Dest_host     : Type of the destination host                     }
{            Qualifier     : A-A Protocol parameter qualifier                 }
{                                                                             }
{ Output parameters                                                           }
{            Buffer_list   : List of current network buffers                  }
{            Status        : Any status returned by                           }
{                                 nfp$specify_pdu_parameter                   }
{                                                                             }
{ Algorithm                                                                   }
{            Nfp$specify_pdu_parameter( host-type-string )                    }
{                                                                             }
?? EJECT ??

    VAR
      nfv$p22_values: [XREF] nft$parameter_22_strings;

{}
    status.normal := TRUE;
    nfp$specify_pdu_parameter (nfc$destination_host_type, qualifier, nfv$p22_values [dest_host_type],
          buffer_list, status);
{}
  PROCEND nfp$send_protocol_parameter_28;
?? OLDTITLE ??
?? NEWTITLE := 'nfp$send_protocol_parameter_29', EJECT ??

  PROCEDURE nfp$send_protocol_parameter_29
    (    echo_text_list: nft$parameter_29_list_head;
         qualifier: nft$parameter_qualifiers;
     VAR buffer_list: nft$network_buffer_list;
     VAR status: ost$status);
{
{ Procedure  nfp$send_protocol_parameter_29
{
{ Purpose    To send protocol parameter 29, echo text.
{
{ Description
{            This parameter may be sent to a remote host expecting the parameter
{            to be returned on the next protocol command (RFT -> RPOS).  For
{            VE -> VE applications, this parameter may be used to specify
{            VE specific information.
{
{ Input parameters
{            echo_text_list:      List of text of be sent
{            qualifier:           A-A protocol parameter qualifier
{
{ Output parameters
{            buffer_list:         List of current network buffers
{            status:              Return status
{
{ Algorithm
{            current_entry = first on list
{            While current_entry <> NIL Do
{              nfp$specify_pdu_parameter
{              If o.k., current_entry = next_entry
{              Else return
{            Whilend
{
?? EJECT ??
  VAR
      echo_text_ptr: ^nft$parameter_29_definition;

  status.normal := TRUE;
  echo_text_ptr := echo_text_list.first_text;
  WHILE (echo_text_ptr <> NIL) DO
    nfp$specify_pdu_parameter(nfc$echo, qualifier,
      echo_text_ptr^.value(1,echo_text_ptr^.size),
      buffer_list, status);
    IF status.normal THEN
      echo_text_ptr := echo_text_ptr^.link;
    ELSE
      RETURN;
    IFEND;
  WHILEND;

  PROCEND nfp$send_protocol_parameter_29;
?? OLDTITLE ??
?? NEWTITLE := 'nfp$send_protocol_parameter_31', EJECT ??

  PROCEDURE nfp$send_protocol_parameter_31
    (    data_declaration: nft$parameter_31_type;
         qualifier: nft$parameter_qualifiers;
     VAR buffer_list: nft$network_buffer_list;
     VAR status: ost$status);

{                                                                             }
{ Procedure nfp$send_protocol_parameter_31
{           }
{                                                                             }
{ Purpose    To send parameter 31, data declaration.                          }
{                                                                             }
{ Description                                                                 }
{            The data declaration parameter specifies what mode a file        }
{            transfer is to use.  For VE <-> VE transfers, mode UH should     }
{            be used.  For VE <-> non VE systems, types C6 , C8 , and UU      }
{            are valid.                                                       }
{                                                                             }
{ Input parameters                                                            }
{            Data_declar   : Data declaration to be used                      }
{            Qualifier     : A-A Protocol parameter qualifier                 }
{                                                                             }
{ Output parameters                                                           }
{            Buffer_list   : List of current network buffers                  }
{            Status        : Any status returned by                           }
{                                 nfp$specify_pdu_parameter                   }
{ Algorithm                                                                   }
{            Nfp$specify_pdu_parameter( data_type_string )                    }
{                                                                             }
?? EJECT ??

    VAR
      nfv$parameter_31_values: [XREF] nft$parameter_31_definition;

    {}
    status.normal := TRUE;
    nfp$specify_pdu_parameter (nfc$data_declaration, qualifier, nfv$parameter_31_values [data_declaration],
          buffer_list, status);
    {}
  PROCEND nfp$send_protocol_parameter_31;
?? OLDTITLE ??
?? NEWTITLE := 'nfp$send_protocol_parameter_32', EJECT ??

  PROCEDURE nfp$send_protocol_parameter_32
    (    systems_routing_text: string ( * <= nfc$max_param_size);
         qualifier: nft$parameter_qualifiers;
     VAR buffer_list: nft$network_buffer_list;
     VAR status: ost$status);

    {
    { Procedure  nfp$send_protocol_parameter_32
    {
    { Purpose    Send parameter 32, system routing text.
    {
    { Description   Systems routing text is defined
    {               separately for various applications.
    {
    { Input parameters
    {               systems_routing_text:       string of text to send
    {
    { Output parameters
    {               buffer_list:                list of protocol to send buffers
    {               status:                     return status
    {
    { Algorithm
    {               call nfp$specify_pdu_parameter
    {
?? EJECT ??

    nfp$specify_pdu_parameter (nfc$system_routing_text, qualifier, systems_routing_text, buffer_list, status);
    {}
  PROCEND nfp$send_protocol_parameter_32;
?? OLDTITLE ??
?? NEWTITLE := 'nfp$send_protocol_parameter_33', EJECT ??

  PROCEDURE nfp$send_protocol_parameter_33
    (    implicit_routing_text: string ( * <= nfc$max_param_size);
         qualifier: nft$parameter_qualifiers;
     VAR buffer_list: nft$network_buffer_list;
     VAR status: ost$status);

    {
    { Procedure  nfp$send_protocol_parameter_33
    {
    { Purpose    Send parameter 33, implicit routing text.
    {
    { Description  Implicit routing text is defined for
    {               separate applications.
    {
    { Input parameters
    {        implicit_routing_text:      routing text string
    {
    { Output parameters
    {        buffer_list:                list of protocol buffers to be sent
    {        status:                     return status
    {
    { Algorithm
    {        call nfp$specify_pdu_parameter
    {
?? EJECT ??

    nfp$specify_pdu_parameter (nfc$implicit_routing_text, qualifier, implicit_routing_text, buffer_list,
          status);
    {}
  PROCEND nfp$send_protocol_parameter_33;
?? OLDTITLE ??
?? NEWTITLE := 'nfp$send_protocol_parameter_51', EJECT ??

  PROCEDURE nfp$send_protocol_parameter_51
    (    protocol: nft$parameter_00_values;
         command: nft$protocol_commands;
         user_file_name: string ( * );
         qualifier: nft$parameter_qualifiers;
     VAR buffer_list: nft$network_buffer_list;
     VAR status: ost$status);

    {
    { Procedure  nfp$send_protocol_parameter_51
    {
    { Purpose    Send P51, user file name.
    {
    {
    {
    {
    {
    {
    { Description
    {
    {
    {
    {
    {
    {
    { Input parameters
    {
    {
    {
    {
    {
    { Output parameters
    {
    {
    {
    {
    {
    { Algorithm
    {
    {
    {
    {
    {
    {
    {
    {
    {
    {
?? EJECT ??
    status.normal := TRUE;
    IF STRLENGTH (user_file_name) > 0 THEN
      nfp$specify_pdu_parameter (nfc$user_file_name, qualifier, user_file_name, buffer_list, status);
    IFEND;
    {}
  PROCEND nfp$send_protocol_parameter_51;
?? OLDTITLE ??
?? NEWTITLE := 'nfp$send_protocol_parameter_52', EJECT ??
  {}

  PROCEDURE nfp$send_protocol_parameter_52
    (    qualifier: nft$parameter_qualifiers;
         banner_date_and_time: string(* <= nfc$p52_max_param_length);
     VAR buffer_list: nft$network_buffer_list;
     VAR status: ost$status);

    {
    { Procedure  nfp$send_protocol_parameter_52
    {
    { Purpose    Send parameter 52, banner date and time.
    {
    { Description
    {            This routine sends the banner date and
    {            time specified by the application.
    {
    { Input parameters
    {               qualifier:                  A-A protocol parameter qualifier
    {               banner_date_and_time:       String for banner
    {
    { Output parameters
    {               buffer_list:                List of network buffers
    {               status:                     Return status
    {
    { Algorithm
    {               nfp$specify_pdu_parameter
    {
?? EJECT ??

    status.normal := TRUE;
    nfp$specify_pdu_parameter (nfc$banner_date_and_time, qualifier,
             banner_date_and_time, buffer_list, status);
    {}
  PROCEND nfp$send_protocol_parameter_52;
?? OLDTITLE ??
?? NEWTITLE := 'nfp$send_protocol_parameter_53', EJECT ??

  PROCEDURE nfp$send_protocol_parameter_53
    (    protocol: nft$parameter_00_values;
         command: nft$protocol_commands;
         banner_routing_text: string ( * <= nfc$max_param_size);
         qualifier: nft$parameter_qualifiers;
     VAR buffer_list: nft$network_buffer_list;
     VAR status: ost$status);

    {
    { Procedure  nfp$send_protocol_parameter_53
    {
    { Purpose    Send parameter 53, banner routing text.
    {
    { Description
    {
    {
    {
    {
    {
    {
    { Input parameters
    {
    {
    {
    {
    {
    { Output parameters
    {
    {
    {
    {
    {
    { Algorithm
    {
    {
    {
    {
    {
    {
    {
    {
    {
    {
?? EJECT ??
    status.normal := TRUE;
    IF STRLENGTH (banner_routing_text) > 0 THEN
      nfp$specify_pdu_parameter (nfc$banner_routing_text, qualifier,
       banner_routing_text, buffer_list, status);
    IFEND;
    {}
  PROCEND nfp$send_protocol_parameter_53;
?? OLDTITLE ??
?? NEWTITLE := 'nfp$send_protocol_parameter_54', EJECT ??

  PROCEDURE nfp$send_protocol_parameter_54
    (    protocol: nft$parameter_00_values;
         command: nft$protocol_commands;
         user_banner_text: string ( * <= nfc$max_param_size);
         qualifier: nft$parameter_qualifiers;
     VAR buffer_list: nft$network_buffer_list;
     VAR status: ost$status);

    {
    { Procedure  nfp$send_protocol_parameter_54
    {
    { Purpose    Send parameter 54, user banner text.
    {
    { Description
    {
    {
    {
    {
    {
    {
    { Input parameters
    {
    {
    {
    {
    {
    { Output parameters
    {
    {
    {
    {
    {
    { Algorithm
    {
    {
    {
    {
    {
    {
    {
    {
    {
    {
?? EJECT ??
    status.normal := TRUE;
    IF STRLENGTH (user_banner_text) > 0 THEN
      nfp$specify_pdu_parameter (nfc$user_banner_text, qualifier, user_banner_text,
        buffer_list, status);
    IFEND;
    {}
  PROCEND nfp$send_protocol_parameter_54;
?? OLDTITLE ??
?? NEWTITLE := 'nfp$send_protocol_parameter_55', EJECT ??

  PROCEDURE nfp$send_protocol_parameter_55
    (    protocol: nft$parameter_00_values;
         command: nft$protocol_commands;
         installation_banner_text: string ( * <= nfc$max_param_size);
         qualifier: nft$parameter_qualifiers;
     VAR buffer_list: nft$network_buffer_list;
     VAR status: ost$status);

    {
    { Procedure  nfp$send_protocol_parameter_55
    {
    { Purpose    Send parameter 55, installation banner text.
    {
    { Description
    {
    {
    {
    {
    {
    {
    { Input parameters
    {
    {
    {
    {
    {
    { Output parameters
    {
    {
    {
    {
    {
    { Algorithm
    {               nfp$specify_pdu_parameter
    {
?? EJECT ??
    status.normal := TRUE;
    IF STRLENGTH(installation_banner_text) > 0 THEN
      nfp$specify_pdu_parameter (nfc$installation_banner_text, qualifier,
             installation_banner_text, buffer_list, status);
    IFEND;
  {}
  PROCEND nfp$send_protocol_parameter_55;
?? OLDTITLE ??
?? NEWTITLE := 'nfp$send_protocol_parameter_56', EJECT ??

  PROCEDURE nfp$send_protocol_parameter_56
    (    protocol: nft$parameter_00_values;
         command: nft$protocol_commands;
         repos_params: string ( * <= nfc$max_param_size);
         qualifier: nft$parameter_qualifiers;
     VAR buffer_list: nft$network_buffer_list;
     VAR status: ost$status);

    {
    { Procedure  nfp$send_protocol_parameter_56
    {
    { Purpose    To send parameter 56, reposition output parameters.
    {
    {
    {
    {
    {
    {
    { Description
    {
    {
    {
    {
    {
    {
    { Input parameters
    {
    {
    {
    {
    {
    { Output parameters
    {
    {
    {
    {
    {
    { Algorithm
    {
    {
    {
    {
    {
    {
    {
    {
    {
?? EJECT ??
    status.normal := TRUE;
  PROCEND nfp$send_protocol_parameter_56;
?? OLDTITLE ??
?? NEWTITLE := 'nfp$send_protocol_parameter_57', EJECT ??

  PROCEDURE nfp$send_protocol_parameter_57
    (    protocol: nft$parameter_00_values;
         command: nft$protocol_commands;
         current_fpos: string ( * <= nfc$max_param_size);
         qualifier: nft$parameter_qualifiers;
         buffer_list: nft$network_buffer_list;
     VAR status: ost$status);

    {
    { Procedure  nfp$send_protocol_parameter_57
    {
    { Purpose    Send parameter 57, current file position.
    {
    {
    {
    {
    {
    {
    { Description
    {
    {
    {
    {
    {
    {
    { Input parameters
    {
    {
    {
    {
    {
    { Output parameters
    {
    {
    {
    {
    {
    { Algorithm
    {
    {
    {
    {
    {
    {
    {
    {
    {
    {
?? EJECT ??
    status.normal := TRUE;
  PROCEND nfp$send_protocol_parameter_57;
?? OLDTITLE ??
?? NEWTITLE := 'nfp$send_protocol_parameter_58', EJECT ??

  PROCEDURE nfp$send_protocol_parameter_58
    (    protocol: nft$parameter_00_values;
         command: nft$protocol_commands;
         output_dest: string ( * <= nfc$max_param_size);
         qualifier: nft$parameter_qualifiers;
         buffer_list: nft$network_buffer_list;
     VAR status: ost$status);

    {
    { Procedure  nfp$send_protocol_parameter_58
    {
    { Purpose    To send parameter 58, output file destination.
    {
    {
    {
    {
    {
    {
    { Description
    {
    {
    {
    {
    {
    {
    { Input parameters
    {
    {
    {
    {
    {
    { Output parameters
    {
    {
    {
    {
    {
    { Algorithm
    {
    {
    {
    {
    {
    {
    {
    {
    {
    {
?? EJECT ??
    status.normal := TRUE;
  PROCEND nfp$send_protocol_parameter_58;
?? OLDTITLE ??
?? NEWTITLE := 'nfp$send_protocol_parameter_59' , eject ??
  PROCEDURE nfp$send_protocol_parameter_59
    (               vertical_print_density: jmt$vertical_print_density;
                    qualifier: nft$parameter_qualifiers;
                VAR buffer_list: nft$network_buffer_list;
                VAR status: ost$status);
{
{ Procedure  nfp$send_protocol_parameter_59
{
{ Purpose    To send protocol parameter 59, vertical print density
{
{
{
{
{
{ Description
{
{
{
{
{
{ Input parameters
{
{
{ Output parameters
{
{
{ Algorithm
{
{
{
{
{
{
VAR
      nfv$p59_values: [XREF] nft$parameter_59_values;
{}
  IF nfv$p59_values[vertical_print_density] = 'XX' THEN
    nfp$set_internal_error('Invalid p59 value to send', status);
  ELSE
    nfp$specify_pdu_parameter(nfc$vertical_print_density, qualifier,
      nfv$p59_values[vertical_print_density], buffer_list, status);
  IFEND;
{}
  PROCEND nfp$send_protocol_parameter_59;
?? OLDTITLE ??
?? NEWTITLE := 'nfp$send_protocol_parameter_60' , eject ??
  PROCEDURE nfp$send_protocol_parameter_60
    (               vfu_load_procedure: string(*<=nfc$p60_max_param_length);
                    qualifier: nft$parameter_qualifiers;
                VAR buffer_list: nft$network_buffer_list;
                VAR status: ost$status);
{
{ Procedure  nfp$send_protocol_parameter_60
{
{ Purpose    To send protocol parameter 60, vfu load procedure.
{
{ Description
{
{
{
{
{
{ Input parameters
{
{
{ Output parameters
{
{
{ Algorithm
{            nfp$specify_pdu_parameter for vfu_load_procedure
{
    nfp$specify_pdu_parameter(nfc$vfu_load_procedure, qualifier,
      vfu_load_procedure, buffer_list, status);
{}
  PROCEND nfp$send_protocol_parameter_60;
?? OLDTITLE ??
?? NEWTITLE := 'nfp$qualifier_error', EJECT ??

  PROCEDURE nfp$qualifier_error
    (    qualifier: nft$parameter_qualifiers;
         parameter: nft$protocol_parameters;
         command: nft$protocol_commands;
     VAR status: ost$status);

{                                                                             }
{ Procedure  nfp$qualifier_error                                              }
{                                                                             }
{ Purpose    To set a status variable to protocol parameter qualifier error.  }
{                                                                             }
{ Description                                                                 }
{            The status variable is set using call information.               }
{                                                                             }
{ Input parameters                                                            }
{            Qualifier     : Received (bad) qualifier.                        }
{            Parameter     : Protocol parameter of qualifier                  }
{            Command       : A-A protocol command of parameter                }
{                                                                             }
{ Output parameters                                                           }
{            Status        : Return status value                              }
{                                                                             }
{ Algorithm                                                                   }
{            Osp$set_status_abnormal                                          }
{            Osp$append_status_parameter                                      }
{            Osp$append_status_parameter                                      }
{                                                                             }
{}

    VAR
      nfv$command_values: [XREF] nft$command_values;

    VAR
      nfv$param_id_values: [XREF] nft$parameter_values;

    VAR
      nfv$param_qualifier_values: [XREF] nft$parameter_qualifier_values;

{}
    osp$set_status_abnormal (nfc$status_id, nfe$qualifier_error, nfv$param_qualifier_values [qualifier],
          status);
    osp$append_status_parameter (osc$status_parameter_delimiter, nfv$param_id_values [parameter], status);
    osp$append_status_parameter (osc$status_parameter_delimiter, nfv$command_values [command], status);
{}
  PROCEND nfp$qualifier_error;
?? OLDTITLE ??
?? NEWTITLE := 'nfp$set_internal_error', EJECT ??

  PROCEDURE nfp$set_internal_error
    (    message: string ( * );
     VAR status: ost$status);

{                                                                             }
{ Procedure  nfp$set_internal_error                                           }
{                                                                             }
{ Purpose    To set a status variable to internal error.                      }
{                                                                             }
{ Description                                                                 }
{            The status variable is set to internal error with a data         }
{            field containing a string value.  The string value should        }
{            normally be the name of the calling routine.                     }
{                                                                             }
{ Input parameters                                                            }
{            Message       : String error message                             }
{                                                                             }
{ Output parameters                                                           }
{            Status        : Return status = nfe$bts_internal_error           }
{                                                                             }
{ Algorithm                                                                   }
{            Osp$set_status_abnormal                                          }
{                                                                             }
{}
    osp$set_status_abnormal (nfc$status_id, nfe$bts_internal_error, message, status);
{}
  PROCEND nfp$set_internal_error;
?? OLDTITLE ??
?? NEWTITLE := '[XDCL] nfp$format_message_to_job_log', EJECT ??

  PROCEDURE [XDCL] nfp$format_message_to_job_log
    (    status: ost$status);

{                                                                             }
{ Procedure  nfp$format_message_to_job_log                                    }
{                                                                             }
{ Purpose    To translate a variable of type OST$STATUS and write the         }
{            value to the job log.                                            }
{                                                                             }
{ Description                                                                 }
{            If you think this routine looks a lot like an example in         }
{            CYBIL for NOS/VE System Interface, it is.                        }
{                                                                             }
{ Input parameters                                                            }
{            Status        : Input status value                               }
{                                                                             }
{ Output parameters                                                           }
{            NONE...                                                          }
{                                                                             }
{ Algorithm                                                                   }
{            Translate message to string                                      }
{            For i = 1 to # of message pieces Do                              }
{              Pmp$log( message piece)                                        }
{            Forend                                                           }
{                                                                             }
?? EJECT ??
{}

    VAR
      index: 1 .. osc$max_status_message_lines,
      message: ost$status_message,
      msg_line_count: ^ost$status_message_line_count,
      msg_line_size: ^ost$status_message_line_size,
      msg_line_text: ^string ( * ),
      pointer: ^ost$status_message,
      trace_status: ost$status;

{}
    osp$format_message (status, osc$full_message_level, nfc$trace_commands_width, message, trace_status);
    pointer := ^message;
    RESET pointer;
    NEXT msg_line_count IN pointer;
    FOR index := 1 TO msg_line_count^ DO
      NEXT msg_line_size IN pointer;
      NEXT msg_line_text: [msg_line_size^] IN pointer;
      pmp$log (msg_line_text^, trace_status);
    FOREND;
{}
  PROCEND nfp$format_message_to_job_log;
?? OLDTITLE ??
?? NEWTITLE := '[XDCL] nfp$receive_parameter_00', EJECT ??

  PROCEDURE [XDCL] nfp$receive_parameter_00
    (    command: nft$protocol_commands;
         received_value: string ( * <= nfc$max_param_size);
         qualifier: nft$parameter_qualifiers;
         current_value: nft$parameter_00_values;
     VAR new_value: nft$parameter_00_values;
     VAR negotiate_down: boolean;
     VAR status: ost$status);

    {
    { Procedure nfp$receive_parameter_00
    {
    { Purpose   Handle received parameter 00, protocol id.
    {
    { Description
    {           This routine is called to process received protocol
    {           identifiers.
    {           The protocol identifier should be received (in existing
    {           applications) on the commands (RFT,RPOS,RNEG).  These rules
    {           are enforced:
    {           1. If the received protocol ID is ignored, the lowest (A101)
    {              value is to be used.
    {           2. If the received value is selected or modified, this value
    {              cannot be greater than the applications current value.
    {              (i.e. the protocol ID can only be negotiated downward ).
    {
    { Input parameters
    {           Received_value       : Parameter value received (string)
    {           Qualifier            : A-A protocol parameter qualifier
    {           Current_value        : Value of current P00 (ordinal)
    {
    { Output parameters
    {           New_value            : Accepted new value
    {           Negotiate_down       : Boolean value informing the application
    {                                  to renegotiate the transfer with a new
    {                                  protocol ID.
    {           Status               : normal -or-
    {                                  nfe$invalid_protocol_negot
    {                                  nfe$invalid_protocol_value
    {
    { Algorithm
    {           If not legal protocol ID then
    {             Set error/return
    {           Ifend
    {           Case qualifier of
    {           =ignored= Prot_id = A101
    {           =select,modify=
    {                           If greater  than current value then
    {                             Error
    {                           Ifend
    {           Casend;
    {
?? EJECT ??

    VAR
      nfv$p00_values: [XREF] nft$p00_values;

    VAR
      index: nft$parameter_00_values,
      value_found: boolean,
      parameter_length: nft$parameter_size;

{}
    status.normal := TRUE;
    negotiate_down := FALSE;
    parameter_length := STRLENGTH (received_value);
    value_found := FALSE;

  /p00_search_loop/
    FOR index := LOWERVALUE (nft$parameter_00_values) TO UPPERVALUE (nft$parameter_00_values) DO
      IF ((parameter_length = nfv$p00_values [index].length) AND
            (received_value = nfv$p00_values [index].value)) THEN
        value_found := TRUE;
        EXIT /p00_search_loop/;
      IFEND;
    FOREND /p00_search_loop/;
{}
    IF NOT value_found THEN
      osp$set_status_abnormal (nfc$status_id, nfe$invalid_protocol_value, received_value, status);
      RETURN;
    IFEND;
{}
    CASE qualifier OF
    = nfc$ignore =
      new_value := nfc$p00_a101;
    = nfc$modify, nfc$select =
      IF index < current_value THEN {** Negoitiated downward, o.k. **}
        new_value := index;
        IF command = nfc$rneg THEN
          negotiate_down := TRUE;
        IFEND;
      ELSEIF index = current_value THEN {** protocol ID's match **}
        new_value := index;
      ELSE {** Illegal negotiation **}
        osp$set_status_abnormal (nfc$status_id, nfe$invalid_protocol_negot, received_value, status);
      IFEND;
    ELSE
      nfp$set_internal_error ('nfp$receive_parameter_00 qualifier case', status);
      pmp$exit (status);
    CASEND;

  PROCEND nfp$receive_parameter_00;
?? OLDTITLE ??
?? NEWTITLE := 'nfp$receive_parameter_01', EJECT ??

  PROCEDURE nfp$receive_parameter_01
    (    current_value: string ( * <= nfc$max_param_size);
     VAR new_value: nft$parameter_01_values;
     VAR status: ost$status);

    { Purpose   To process parameter 01, maximum transfer file size, as
    {           received from remote.

    VAR
      length_record: clt$integer;


    status.normal := TRUE;
    clp$convert_string_to_integer (current_value, length_record, status);
    IF (NOT status.normal) OR (length_record.radix_specified) THEN
      osp$set_status_abnormal (nfc$status_id, nfe$parameter_length_error, current_value, status);
    ELSE
      new_value := length_record.value;
    IFEND;

  PROCEND nfp$receive_parameter_01;
?? OLDTITLE ??
?? NEWTITLE := 'nfp$receive_parameter_03', EJECT ??

  PROCEDURE nfp$receive_parameter_03
    (    command: nft$protocol_commands;
         received_value: string ( * <= nfc$max_param_size);
         qualifier: nft$parameter_qualifiers;
         current_value: nft$parameter_03_value_set;
         required_facilities: nft$parameter_03_value_set;
         allowed_facilities: nft$parameter_03_value_set;
     VAR parameter_modified: boolean;
     VAR new_value: nft$parameter_03_value_set;
     VAR buffer_list: nft$network_buffer_list;
     VAR status: ost$status);

{ Procedure nfp$receive_parameter_03
{
{ Purpose    Process parameter 03, facilities, as received from remote
{            application.
{
{ Description
{            This routine cracks the received parameter value in a facilities
{            set.  This set is checked against the allowed facilities set
{            to ensure legality.
{
{ Input parameters
{            Command              : Received A-A protocol command
{            Received_value       : Received parameter string
{            Qualifier            : A-A protocol parameter qualifier
{            Current_value        : Current facility set
{            Network              : Type of network of connection
{            Required_facilities  : Application required facilities
{
{ Output parameters
{            Parameter_modified   : Flag indicating this process changed param
{            New_value            : Accepted protocol set
{            Buffer_list          : List of current network buffers
{            Status               : Return status
{                                     nfe$unknown_facility_option
{                                   from nfp$qualifier_error

    VAR
      facility_index: nft$facility_types,
      found_it: boolean,
      index: 0 .. nfc$p03_max_size,
      optional_facilities: nft$parameter_03_value_set,
      received_facilities: nft$parameter_03_value_set,
      trace_status: ost$status;

    VAR
      nfv$p03_values: [XREF] nft$parameter_03_elements;


    status.normal := TRUE;
    parameter_modified := FALSE;
    received_facilities := $nft$parameter_03_value_set [];

  /search_loop/
    FOR index := 1 TO STRLENGTH (received_value) DO
      found_it := FALSE;

    /facility_loop/
      FOR facility_index := LOWERVALUE (nft$facility_types) TO UPPERVALUE (nft$facility_types) DO
        IF received_value (index, 1) = nfv$p03_values [facility_index] THEN
          found_it := TRUE;
          EXIT /facility_loop/;
        IFEND;
      FOREND /facility_loop/;
      IF found_it THEN
        received_facilities := received_facilities + $nft$parameter_03_value_set [facility_index];
      ELSE
        osp$set_status_abnormal (nfc$status_id, nfe$unknown_facility_option, received_value (index, 1),
              status);
        RETURN;
      IFEND;
    FOREND /search_loop/;

    CASE qualifier OF
    = nfc$select, nfc$modify =
      new_value := received_facilities;
    = nfc$ignore =
      new_value := current_value - received_facilities;
    ELSE
      nfp$set_internal_error ('nfp$receive_parameter_03 qualifier case', status);
      RETURN;
    CASEND;

{ Check required facilities are present

    IF NOT (required_facilities <= new_value) THEN { No, cannot continue
      osp$set_status_abnormal (nfc$status_id, nfe$dislike_parameter, 'Unacceptable facilities option set',
            status);
      new_value := current_value;
    ELSE { Required facilities are there, check any optional facilities
      optional_facilities := new_value - required_facilities;
      IF NOT (optional_facilities <= allowed_facilities) THEN { Try to modify
        new_value := required_facilities;
        FOR facility_index := LOWERVALUE (nft$facility_types) TO UPPERVALUE (nft$facility_types) DO
          IF (facility_index IN optional_facilities) AND (facility_index IN allowed_facilities) THEN
            new_value := new_value + $nft$parameter_03_value_set [facility_index];
          IFEND;
        FOREND;
        nfp$send_protocol_parameter_03 (nfc$modify, new_value, buffer_list, status);
        IF NOT status.normal THEN { Major disaster, cannot modify
          pmp$exit (status);
        ELSE
          parameter_modified := TRUE;
        IFEND;
      IFEND;
    IFEND;

  PROCEND nfp$receive_parameter_03;
?? OLDTITLE ??
?? NEWTITLE := 'nfp$receive_parameter_04', EJECT ??

  PROCEDURE nfp$receive_parameter_04
    (    command: nft$protocol_commands;
         received_value: string ( * <= nfc$max_param_size);
         qualifier: nft$parameter_qualifiers;
         current_value: ost$status;
     VAR new_value: ost$status;
     VAR status: ost$status);

    {
    { Procedure  nfp$receive_parameter_04
    {
    { Purpose    Handle received parameter 04, state of transfer.
    {
    { Description
    {           This routine receives a parameter 04 string and cracks it into
    {           internal (status) format.  If the severity of the received
    {           status
    {           is less than the current status, the new status will not be
    {           set.
    {
    { Input parameters
    {           Command              : Received A-A protocol command
    {           Received_value       : P04 string
    {           Qualifier            : A-A protocol parameter qualifier
    {           Current_value        : Current P04 (status) value
    {
    { Output parameters
    {           New_value            : New P04 (status) value
    {           Status               : Completion status
    {
    { Algorithm
    {           Loop known 04 values for match
    {           If no match, error
    {           Else
    {             If new 04 value more severe than current, set to new value
    {           Ifend
    {
?? EJECT ??

    VAR
      found_it: boolean,
      index: 1 .. nfc$p04_max_transfer_states;

    VAR
      nfv$param_id_values: [XREF] nft$parameter_values;

    VAR
      nfv$p04_values: [XREF] nft$parameter_04_values;

    {}
    status.normal := TRUE;
    CASE qualifier OF
    = nfc$select, nfc$modify =
      found_it := FALSE;

    /p04_search_loop/
      FOR index := LOWERVALUE (index) TO UPPERVALUE (index) DO
        IF (received_value = nfv$p04_values [index].code) THEN
          found_it := TRUE;
          EXIT /p04_search_loop/;
        IFEND;
      FOREND /p04_search_loop/;
      {}
      IF NOT found_it THEN {** Remote sent illegal sot **}
        osp$set_status_abnormal (nfc$status_id, nfe$unknown_transfer_state,
              nfv$param_id_values [nfc$state_of_transfer], status);
        osp$append_status_parameter (osc$status_parameter_delimiter, received_value, status);
      ELSE {** Sot is valid, check it against my known status **}
        IF (nfv$p04_values [index].normal) AND (NOT current_value.normal) THEN
          ; { He is out of touch, ignore remote status }
        ELSE
          new_value.normal := nfv$p04_values [index].normal;
          new_value.condition := nfv$p04_values [index].condition;
        IFEND;
      IFEND;

    = nfc$ignore =
      nfp$qualifier_error (qualifier, nfc$state_of_transfer, command, status);
    ELSE
      nfp$set_internal_error ('nfp$receive_parameter_04 qualifier case', status);
      pmp$exit (status);
    CASEND;
    {}
  PROCEND nfp$receive_parameter_04;
?? OLDTITLE ??
?? NEWTITLE := 'nfp$receive_parameter_05', EJECT ??

  PROCEDURE nfp$receive_parameter_05
    (    command: nft$protocol_commands;
         received_value: string ( * <= nfc$max_param_size);
         qualifier: nft$parameter_qualifiers;
     VAR directive_list: nft$directive_entry_list_head;
     VAR status: ost$status);

    {
    { Procedure nfp$receive_parameter_05
    {
    { Purpose   To process protocol parameter 05, user text directive
    {
    { Description
    {           This routine takes the input 05 string and enqueues it to a
    {           list.  Processing of 05 parameters is dependent upon the
    {           application, therefore it must check for received 05's.
    {
    { Input parameters
    {           Command              : Received A-A protocol command             }
    {           Received_value       : P05 string
    {           Qualifier            : A-A protocol parameter qualifier
    {
    { Output parameters
    {           Directive_list       : List head for received 05 parameters
    {           Status               : Return status
    {
    { Algorithm
    {           Allocate space for directive
    {           Enqueue directive
    {
?? EJECT ??

    VAR
      current_entry: ^nft$directive_entry;

    {}
    status.normal := TRUE;
    CASE qualifier OF
    = nfc$select =
      ALLOCATE current_entry: [#SIZE (received_value)];
      IF current_entry = NIL THEN
        nfp$set_internal_error ('nfp$receive_parameter_05 no vm', status);
        RETURN;
        RETURN;
      IFEND;
      current_entry^.line := received_value;
      current_entry^.link := NIL;
      IF directive_list.head = NIL THEN
        directive_list.tail := current_entry;
        directive_list.head := current_entry;
      ELSE
        directive_list.tail^.link := current_entry;
        directive_list.tail := current_entry;
      IFEND;
    = nfc$modify =
      nfp$qualifier_error (qualifier, nfc$user_text_directive, command, status);
    = nfc$ignore =
      IF command <> nfc$rneg THEN {** Remote will not execute some directives }
        nfp$qualifier_error (qualifier, nfc$user_text_directive, command, status);
      IFEND;
    ELSE
      nfp$set_internal_error ('nfp$receive_parameter_05 qualifier case', status);
      pmp$exit (status);
    CASEND;
    {}
  PROCEND nfp$receive_parameter_05;
?? OLDTITLE ??
?? NEWTITLE := 'nfp$receive_parameter_06', EJECT ??

  PROCEDURE nfp$receive_parameter_06
    (    received_value: string ( * <= nfc$max_param_size);
     VAR file_size: nft$parameter_06_values;
     VAR status: ost$status);

    {
    { Procedure nfp$receive_parameter_06
    {
    { Purpose   To process parameter 06, file size.
    {
    {
    {
    { Description
    {           The length of the file is decoded and returned to the calling
    {           application.
    {
    { Input parameters
    {           Command              : Received A-A protocol command
    {           Received_value       : Parameter value string
    {
    { Output parameters
    {           File_size            : Returned file size
    {           Status               : Returned status
    {
    { Algorithm
    {           Convert string to integer
    {           If not success, set error
    {
?? EJECT ??

    VAR
      integer_record: clt$integer;

    {}
    status.normal := TRUE;
    clp$convert_string_to_integer (received_value, integer_record, status);
    IF NOT status.normal THEN
      osp$set_status_abnormal (nfc$status_id, nfe$invalid_p06_value, received_value, status);
    ELSE
      file_size := (integer_record.value * nfc$p06_unit);
    IFEND;
    {}
  PROCEND nfp$receive_parameter_06;
?? OLDTITLE ??
?? NEWTITLE := 'nfp$receive_parameter_07', EJECT ??

  PROCEDURE nfp$receive_parameter_07
    (    command: nft$protocol_commands;
         received_value: string ( * <= nfc$max_param_size);
         qualifier: nft$parameter_qualifiers;
     VAR directive_list: nft$directive_entry_list_head;
     VAR status: ost$status);

    {
    { Procedure  nfp$receive_parameter_07
    {
    { Purpose    Receive parameter 07, operator message, from remote host.
    {
    { Description The operator message is queued to a list for the calling
    {             application.
    {
    { Input parameters
    {           Command              : A-A protocol command
    {           Received_value       : Received parameter 07 value
    {           Qualifier            : A-A protocol parameter qualifier
    {
    { Output parameters
    {           Directive_list       : List on which to place received value
    {           Status               : Return status
    {
    { Algorithm
    {            Pmp$log
    {            Return
    {
    status.normal := TRUE;
    CASE qualifier OF

    = nfc$select =

      nfp$enqueue_directive_on_list (received_value, directive_list, status);

    = nfc$ignore, nfc$modify =
      ;

      nfp$qualifier_error (qualifier, nfc$user_message, command, status);

    ELSE
      nfp$set_internal_error ('nfp$receive_parameter_07 qualifier case', status);
      pmp$exit (status);
    CASEND;
    {}
  PROCEND nfp$receive_parameter_07;
?? OLDTITLE ??
?? NEWTITLE := 'nfp$receive_parameter_08', EJECT ??

  PROCEDURE nfp$receive_parameter_08
    (    command: nft$protocol_commands;
         received_value: string ( * <= nfc$max_param_size);
         qualifier: nft$parameter_qualifiers;
     VAR directive_list: nft$directive_entry_list_head;
     VAR status: ost$status);

    {
    { Procedure  nfp$receive_parameter_08
    {
    { Purpose    Receive parameter 08, user message, from remote host.
    {            Warning***Warning : In the future, when non-NOS/VE systems
    {            are verified, these messages should be sent to $output
    {
    { Description The user message is queued to a list for processing by the
    {             calling application.
    {
    { Input parameters
    {           Command              : A-A protocol command
    {           Received_value       : Received parameter 07 value
    {           Qualifier            : A-A protocol parameter qualifier
    {
    { Output parameters
    {
    { Algorithm
    {            Pmp$log
    {            Return
    {
?? EJECT ??
    status.normal := TRUE;
    CASE qualifier OF

    = nfc$select =

      nfp$enqueue_directive_on_list (received_value, directive_list, status);

    = nfc$ignore, nfc$modify =
      ;

      nfp$qualifier_error (qualifier, nfc$user_message, command, status);

    ELSE
      nfp$set_internal_error ('nfp$receive_parameter_08 qualifier case', status);
      pmp$exit (status);
    CASEND;
    {}
  PROCEND nfp$receive_parameter_08;
?? OLDTITLE ??
?? NEWTITLE := '[XDCL] nfp$dispose_user_msg_to_log', EJECT ??

  PROCEDURE [XDCL] nfp$dispose_user_msg_to_log
    (VAR directive_list: nft$directive_entry_list_head);

{                                                                             }
{ Procedure  nfp$dispose_user_msg_to_log                                      }
{                                                                             }
{ Purpose    To put all directives on list into the job log.                  }
{                                                                             }
{ Description                                                                 }
{            This routine puts each directive into the job log and deallocates}
{            its storage.  When this routine is complete, the list is NIL.    }
{                                                                             }
{ Input parameters                                                            }
{            None                                                             }
{                                                                             }
{ Output parameters                                                           }
{            Directive_list: List of directives to log and deallocate         }
{                                                                             }
{ Algorithm                                                                   }
{            While directive exists Do                                        }
{              Log directive                                                  }
{              Deallocate directive                                           }
{              Next directive                                                 }
{            Whilend                                                          }
{            Set list header = NIL                                            }
{                                                                             }
?? EJECT ??

    VAR
      current_entry: ^nft$directive_entry,
      log_status: ost$status,
      next_entry: ^nft$directive_entry;

{}
    IF directive_list.head <> NIL THEN
      current_entry := directive_list.head;
      pmp$log ('RHF - Message(s) from remote host', log_status);
      WHILE current_entry <> NIL DO
        pmp$log (current_entry^.line, log_status);
        next_entry := current_entry^.link;
        FREE current_entry;
        current_entry := next_entry;
      WHILEND;
      pmp$log ('RHF - End of remote host message(s)', log_status);
      directive_list.head := NIL;
      directive_list.tail := NIL;
    IFEND;
{}
  PROCEND nfp$dispose_user_msg_to_log;
?? OLDTITLE ??
?? NEWTITLE := 'nfp$receive_parameter_09', EJECT ??

  PROCEDURE nfp$receive_parameter_09
    (    command: nft$protocol_commands;
         received_value: string ( * <= nfc$max_param_size);
         qualifier: nft$parameter_qualifiers;
     VAR directive_list: nft$directive_entry_list_head;
     VAR status: ost$status);

    {
    { Procedure  nfp$receive_parameter_09
    {
    { Purpose    Receive parameter 09, accouting message, from remote host.
    {
    { Description The account message is not processed by nos/ve
    {
    { Input parameters
    {           Command              : A-A protocol command
    {           Received_value       : Received parameter 07 value
    {           Qualifier            : A-A protocol parameter qualifier
    {
    { Output parameters
    {
    { Algorithm
    {            Return
    {
?? EJECT ??
    status.normal := TRUE;
    CASE qualifier OF

    = nfc$select =

      nfp$enqueue_directive_on_list (received_value, directive_list, status);

    = nfc$ignore, nfc$modify =
      ;

      nfp$qualifier_error (qualifier, nfc$user_message, command, status);

    ELSE
      nfp$set_internal_error ('nfp$receive_parameter_09 qualifier case', status);
      pmp$exit (status);
    CASEND;
    {}
  PROCEND nfp$receive_parameter_09;
?? OLDTITLE ??
?? NEWTITLE := 'nfp$receive_parameter_10', EJECT ??

  PROCEDURE nfp$receive_parameter_10
    (    command: nft$protocol_commands;
         received_value: string ( * <= nfc$max_param_size);
         qualifier: nft$parameter_qualifiers;
     VAR directive_list: nft$directive_entry_list_head;
     VAR status: ost$status);

    {
    { Procedure  nfp$receive_parameter_10
    {
    { Purpose    Receive parameter 10, error log message, from remote host.
    {
    { Description
    {
    { Input parameters
    {           Command              : A-A protocol command
    {           Received_value       : Received parameter 07 value
    {           Qualifier            : A-A protocol parameter qualifier
    {
    { Output parameters
    {
    { Algorithm
    {            Return
    {
?? EJECT ??
    status.normal := TRUE;
    CASE qualifier OF

    = nfc$select =

      nfp$enqueue_directive_on_list (received_value, directive_list, status);

    = nfc$ignore, nfc$modify =
      ;

      nfp$qualifier_error (qualifier, nfc$user_message, command, status);

    ELSE
      nfp$set_internal_error ('nfp$receive_parameter_10 qualifier case', status);
      pmp$exit (status);
    CASEND;
    {}
  PROCEND nfp$receive_parameter_10;
?? OLDTITLE ??
?? NEWTITLE := 'nfp$receive_parameter_11', EJECT ??

  PROCEDURE nfp$receive_parameter_11
    (    received_value: string ( * <= nfc$max_param_size);
         qualifier: nft$parameter_qualifiers;
     VAR special_options: nft$parameter_11_value;
     VAR status: ost$status);

{                                                                             }
{ Procedure  nfp$receive_parameter_11
{                                                                             }
{ Purpose    Receive parameter 11, special options.  The special options      }
{            parameter is used in NOS/VE <-> NOS/VE transfers to pass NOS/VE  }
{            specific status information.  The special options are used in    }
{            a rather application dependent context.                          }
{                                                                             }
{ Description                                                                 }
{            Parameter 11 is application specific, and must be                }
{            cracked there.                                                   }
{                                                                             }
{ Input parameters                                                            }
{            Received_value       Received parameter string                   }
{            Qualifier            A-A protocol qualifier                      }
{                                                                             }
{ Output parameters                                                           }
{            Special_options      Returned value                              }
{            Status               Return status                               }
{                                                                             }

    status.normal := TRUE;
    special_options.qualifier := qualifier;
    special_options.size := STRLENGTH (received_value);
    IF special_options.size > 0 THEN
      special_options.value := received_value;
    IFEND;

  PROCEND nfp$receive_parameter_11;
?? OLDTITLE ??
?? NEWTITLE := 'nfp$receive_parameter_12', EJECT ??

  PROCEDURE nfp$receive_parameter_12
    (    received_value: string ( * <= nfc$max_param_size);
         qualifier: nft$parameter_qualifiers;
         data_type: nft$parameter_31_type;
     VAR block_size: nft$parameter_12_range;
     VAR status: ost$status);

{
{ Purpose    Receive parameter 12, maximum data block size and converts it to
{            an integer value.  If the parameter was ignored by the remote
{            host, defaults are applied..
{
{ Input parameters
{           Command              : A-A protocol command
{           Received_value       : P12 string
{           Qualifier            : A-A protocol parameter qualifier
{           Data_type            : Current data type  P31
{           Current_value        : Current value for P12
{
{ Output parameters
{           Block_size           : New block size
{           Status               : Returned status
{

    VAR
      integer_record: clt$integer;


    status.normal := TRUE;
    CASE qualifier OF
    = nfc$select, nfc$modify =
      clp$convert_string_to_integer (received_value, integer_record, status);
      IF status.normal THEN
        block_size := integer_record.value;
      ELSE
        osp$set_status_abnormal (nfc$status_id, nfe$invalid_p12_value, received_value, status);
      IFEND;

    = nfc$ignore =
      CASE data_type OF
      = nfc$p31_unspecified, nfc$p31_ascii_c6, nfc$p31_ascii_c8 =
        block_size := nfc$p12_nos_ascii_size;

      = nfc$p31_undef_unstructured_uu =
        block_size := nfc$p12_nos_binary_size;

      = nfc$p31_undefined_structured_us =
        block_size := nfc$p12_nos_binary_size;

      ELSE
        nfp$set_internal_error ('nfp$receive_parameter_12 host type case', status);
        RETURN;
      CASEND;
    ELSE
      nfp$set_internal_error ('nfp$receive_parameter_12 qualifier case', status);
      RETURN;
    CASEND;

  PROCEND nfp$receive_parameter_12;
?? OLDTITLE ??
?? NEWTITLE := 'nfp$receive_parameter_13', EJECT ??

  PROCEDURE nfp$receive_parameter_13
    (    received_value: string( * <= nfc$p13_max_param_size);
         qualifier: nft$parameter_qualifiers;
         command: nft$protocol_commands;
     VAR accounting_limit: nft$parameter_13_definition;
     VAR status: ost$status);

{
{ Procedure  nfp$receive_parameter_13
{
{ Purpose    To receive protocol parameter 13, accounting limit.
{
{ Description
{            The accounting limit is converted to an integer value.
{
{ Input parameters
{            received_value:      Received parameter value
{            qualifier:           Protocol parameter qualifier
{            command:             Protocol command
{
{ Output parameters
{            accounting_limit:    Returned accounting limit
{            status:              Return status
{
{ Algorithm
{            CASE qualifier OF
{            =select,modify= convert string to value
{            =ignore= If not on RPOS or RNEG, then error
{            CASEND
{
?? EJECT ??
{}
VAR
      integer_record: clt$integer;
{}
  status.normal := TRUE;
  CASE qualifier OF
  =nfc$select, nfc$modify =
    clp$convert_string_to_integer( received_value, integer_record, status);
    IF status.normal THEN
      accounting_limit := integer_record.value;
    IFEND;
  =nfc$ignore=
    IF NOT((command = nfc$rpos) OR (command = nfc$rneg)) THEN
      nfp$qualifier_error( qualifier, nfc$accounting_limit,
             command, status);
    IFEND;
  ELSE
    nfp$set_internal_error('nfp$receive_parameter_13 case error', status);
  CASEND;
{}
  PROCEND nfp$receive_parameter_13;
?? OLDTITLE ??
?? NEWTITLE := 'nfp$receive_parameter_16', EJECT ??

  PROCEDURE nfp$receive_parameter_16
    (    received_value: string ( * <= nfc$p16_max_param_length);
     VAR file_name: nft$parameter_16_definition;
     VAR status: ost$status);

{
{ Procedure  nfp$receive_parameter_16
{
{ Purpose    To receive parameter 16, file-name/IO queue.
{            This parameter is used to exchange file-name and/or
{            IO queue information between applications.
{            This information is application specific.
{
{ Description
{            This parameter is treated as a string.
{
{ Input parameters
{            Received_value:      String value of P16
{
{ Output parameters
{            File_name:    Returned string value
{
{ Algorithm
{            Output = Input
{
?? EJECT ??
    IF (STRLENGTH(received_value) <=
      STRLENGTH(file_name.value)) THEN
      file_name.size := STRLENGTH(received_value);
      file_name.value := received_value;
    ELSE
      nfp$set_internal_error('nfm$rhf_protocol_engine invalid P16 size',status);
    IFEND;
{}
  PROCEND nfp$receive_parameter_16;
?? OLDTITLE ??
?? NEWTITLE := 'nfp$receive_parameter_17', EJECT ??

  PROCEDURE nfp$receive_parameter_17
    (    received_value: string ( * <= nfc$max_param_size);
         command: nft$protocol_commands;
         qualifier: nft$parameter_qualifiers;
     VAR disposition: nft$parameter_17_definition;
     VAR status: ost$status);
{
{ Procedure  nfp$receive_parameter_17
{
{ Purpose    Handle received parameter 17, disposition code.
{
{ Description
{            This routine receives a string representing a disposition code.
{            The string is then cracked into an ordinal disposition code value.
{
{ Input parameters
{            Received_value:      Received parameter value
{            Command:             Received A-A protocol command
{            Qualifier:           Received protocol parameter qualifier
{
{ Output parameters
{            Disposition:         Returned ordinal value
{            Status:              Completion status
{
{ Algorithm
{            Loop known P17 values
{            If match then return value
{            Else return error
{            Ifend;
{
?? EJECT ??
  VAR
      disposition_index: nft$parameter_17_definition,
      matched_disposition_code: BOOLEAN;

  VAR
      nfv$parameter_17_values: [XREF] nft$parameter_17_values;
{}
  CASE qualifier OF
  =nfc$select,nfc$modify=
    matched_disposition_code := FALSE;
    /disposition_search_loop/
    FOR disposition_index := LOWERBOUND(nfv$parameter_17_values) TO
                             UPPERBOUND(nfv$parameter_17_values) DO
      IF (nfv$parameter_17_values[disposition_index] = received_value) THEN
        matched_disposition_code := TRUE;
        EXIT /disposition_search_loop/;
      IFEND;
    FOREND;
    IF matched_disposition_code THEN
      disposition := disposition_index;
    ELSE
      osp$set_status_abnormal( nfc$status_id, nfe$invalid_p17_value,
               received_value, status);
    IFEND;
  =nfc$ignore=
    nfp$qualifier_error(qualifier, nfc$file_disposition, command, status);
  ELSE
    nfp$set_internal_error('nfp$receive_parameter_17 qualifier case error', status);
  CASEND;
{}
  PROCEND nfp$receive_parameter_17;
?? OLDTITLE ??
?? NEWTITLE := 'nfp$receive_parameter_18', EJECT ??

  PROCEDURE nfp$receive_parameter_18
    (    received_value: string ( * <= nfc$p18_maximum_parameter_size);
         qualifier: nft$parameter_qualifiers;
     VAR acknowledgment_window: nft$parameter_18_definition;
     VAR status: ost$status);
{
{ Procedure  nfp$receive_parameter_18
{
{ Purpose    To receive and process parameter 18, acknowledgment window.
{
{ Description
{            This routine takes the received value and places it the
{            the subrange defined for parameter 18.
{
{ Input parameters
{            received_value:      Input value
{            qualifier:           A-A protocol parameter qualifier
{
{ Output parameters
{            acknowledgment_window:      Returned value
{            status:                     Return status
{
{ Algorithm
{            Convert input value to string
{            If value fits, return it
{
  VAR
      integer_record: clt$integer;
{}
  CASE qualifier OF
  =nfc$select, nfc$modify =
    clp$convert_string_to_integer( received_value, integer_record, status);
    IF status.normal THEN
      IF (integer_record.value <= UPPERVALUE(acknowledgment_window)) AND
         (integer_record.value >= LOWERVALUE(acknowledgment_window)) THEN
        acknowledgment_window := integer_record.value;
      ELSE
        osp$set_status_abnormal(nfc$status_id, nfe$invalid_p18_value,
          received_value, status);
      IFEND;
    ELSE
      osp$set_status_abnormal(nfc$status_id, nfe$invalid_p18_value,
        received_value, status);
    IFEND;
  =nfc$ignore=
      ;      { No action }
  ELSE
    nfp$set_internal_error('nfp$receive_parameter_18 case error', status);
  CASEND;
{}
  PROCEND nfp$receive_parameter_18;
?? OLDTITLE ??
?? NEWTITLE := 'nfp$receive_parameter_19', EJECT ??

  PROCEDURE nfp$receive_parameter_19
    (    received_value: string ( * <= nfc$p19_maximum_parameter_size);
         qualifier: nft$parameter_qualifiers;
     VAR initial_restart_checkmark: nft$parameter_19_definition;
     VAR status: ost$status);
{
{ Procedure  nfp$receive_parameter_19
{
{ Purpose    To receive and process parameter 19, initial checkmark restart
{
{ Description
{            The received value is converted to the subrange type and returned
{            to the application.
{
{ Input parameters
{            Received_value:      Input value
{            Qualifier:           A-A protocol parameter qualifier
{
{ Output parameters
{            Initial_restart_checkmark:  Returned value
{            Status:                     Return status
{
{ Algorithm
{            Convert input value to integer
{            If value fits in range, then return it
{
  VAR
      integer_record: clt$integer;
{}
  CASE qualifier OF
  =nfc$select, nfc$modify =
    clp$convert_string_to_integer( received_value, integer_record, status);
    IF status.normal THEN
      IF (integer_record.value <= UPPERVALUE(initial_restart_checkmark)) AND
         (integer_record.value >= LOWERVALUE(initial_restart_checkmark)) THEN
        initial_restart_checkmark := integer_record.value;
      ELSE
        osp$set_status_abnormal(nfc$status_id, nfe$invalid_p19_value,
          received_value, status);
      IFEND;
    ELSE
      osp$set_status_abnormal(nfc$status_id, nfe$invalid_p19_value,
        received_value, status);
    IFEND;
  =nfc$ignore=
      ;      { No action }
  ELSE
    nfp$set_internal_error('nfp$receive_parameter_19 case error', status);
  CASEND;
{}
  PROCEND nfp$receive_parameter_19;
?? OLDTITLE ??
?? NEWTITLE := '[XDCL] nfp$receive_parameter_20', EJECT ??

  PROCEDURE [XDCL] nfp$receive_parameter_20
    (    received_value: string ( * <= nfc$max_param_size);
         qualifier: nft$parameter_qualifiers;
         path: nft$network_connection;
     VAR timeout_value: nft$parameter_20_range;
     VAR status: ost$status);

    {
    { Procedure  nfp$receive_parameter_20
    {
    { Purpose    Handle received parameter 20, minimum time out value.
    {
    { Description
    {           The input parameter string is cracked into an integer
    {           representing
    {           representing the time out value in seconds.
    {
    { Input parameters
    {           Received_value       : Input P20 string value
    {           Qualifier            : A-A protocol parameter qualifier
    {           Path                 : Path info, for changing network file attributes
    {
    { Output parameters
    {           Timeout_value        : Returned time out value in seconds
    {           Status               : Return status
    {
    { Algorithm
    {           Convert P20 value to integer
    {           If error, set error return
    {
?? EJECT ??

    VAR
      integer_record: clt$integer,
      nam_attributes: ^nat$change_attributes,
      rhfam_attributes: ^rft$change_attributes;
    {}
    status.normal := TRUE;
    CASE qualifier OF
    = nfc$select, nfc$modify =
      clp$convert_string_to_integer (received_value, integer_record, status);
      IF status.normal AND (integer_record.value > 0) THEN
        timeout_value := integer_record.value;
        CASE path.network_type OF
        =nfc$network_nam=
             PUSH nam_attributes: [1..1];
             nam_attributes^[1].kind := nac$data_transfer_timeout;
             nam_attributes^[1].data_transfer_timeout := timeout_value *
                    nfc$milliseconds;
             nap$store_attributes( path.network_file_id, nam_attributes^,
                    status);
        =nfc$network_lcn=
             PUSH rhfam_attributes: [1..1];
             rhfam_attributes^[1].key := rfc$data_transfer_timeout;
             rhfam_attributes^[1].data_transfer_timeout := timeout_value *
                    nfc$milliseconds;
             rfp$store( path.network_file_id, rhfam_attributes^,
                    status);
        ELSE
          nfp$set_internal_error('nfp$receive_parameter_20 invalid network type',
             status);
        CASEND;
      ELSE
        osp$set_status_abnormal (nfc$status_id, nfe$invalid_p20_value, received_value, status);
      IFEND;
    = nfc$ignore =
      timeout_value := nfc$p20_network_default;
    ELSE
      nfp$set_internal_error ('nfp$receive_parameter_20 case statement', status);
    CASEND;
    {}
  PROCEND nfp$receive_parameter_20;
?? OLDTITLE ??
?? NEWTITLE := 'nfp$common_receive_21', EJECT ??

  PROCEDURE nfp$receive_parameter_21
    (    received_value: string ( * <= nfc$max_param_size);
         qualifier: nft$parameter_qualifiers;
     VAR mode: nft$mode_of_access;
     VAR option: nft$parameter_21_options;
     VAR status: ost$status);

    {
    { Procedure  nfp$receive_parameter_21
    {
    { Purpose    Receive parameter 21, mode of access.
    {
    { Description
    {           The received parameter 21 is cracked into the two components
    {           of the mode of access.  First, the mode part is cracked.
    {           Second, the option part is cracked.  NOS/VE RHF only uses
    {           the non-specific mode, others are processed as non-specific
    {           would be.
    {
    { Input parameters
    {           Received_value       : Received P21 value
    {           Qualifier            : A-A protocol parameter qualifier
    {
    { Output parameters
    {           Mode                 : Mode part of mode of access
    {           Option               : Option part of mode of access
    {           Status               : Return status
    {
    { Algorithm
    {
    {
    {
    {
    {
    {
    {
    {
    {
    {
?? EJECT ??

    VAR
      found_it: boolean;

    VAR
      nfv$p21_options: [XREF] nft$parameter_21_specifications;

    VAR
      nfv$p21_values: [XREF] nft$parameter_21_values;

    {}
    {     Search for mode }
    {}
    status.normal := TRUE;
    found_it := FALSE;

  /mode_loop/
    FOR mode := LOWERBOUND (nfv$p21_values) TO UPPERBOUND (nfv$p21_values) DO
      IF received_value (nfc$p21_prefix_position, nfc$p21_prefix_length) = nfv$p21_values [mode] THEN
        found_it := TRUE;
        EXIT /mode_loop/;
      IFEND;
    FOREND /mode_loop/;
    IF NOT found_it THEN
      osp$set_status_abnormal (nfc$status_id, nfe$invalid_p21_value, received_value, status);
      RETURN;
    IFEND;
    {}
    {     Search for mode option }
    {}
    found_it := FALSE;

  /option_loop/
    FOR option := LOWERBOUND (nfv$p21_options) TO UPPERBOUND (nfv$p21_options) DO
      IF received_value (nfc$p21_opt_position, nfc$p21_opt_length) = nfv$p21_options [option] THEN
        found_it := TRUE;
        EXIT /option_loop/;
      IFEND;
    FOREND /option_loop/;
    IF NOT found_it THEN
      osp$set_status_abnormal (nfc$status_id, nfe$invalid_p21_spec,
            received_value (nfc$p21_opt_position, nfc$p21_opt_length), status);
      RETURN;
    IFEND;
    {}
    IF (option = nfc$p21_make_only_too) THEN
      option := nfc$p21_make_only;
    IFEND;
    {}
  PROCEND nfp$receive_parameter_21;
?? OLDTITLE ??
?? NEWTITLE := '[XDCL] nfp$receive_parameter_22', EJECT ??

  PROCEDURE [XDCL] nfp$receive_parameter_22
    (    received_value: string ( * <= nfc$max_param_size);
         qualifier: nft$parameter_qualifiers;
     VAR host_type: nft$parameter_22_values;
     VAR status: ost$status);

    {
    { Procedure  nfp$receive_parameter_22
    {
    { Purpose    To receive and process parameter 22, remote host type.
    {
    { Description
    {           The input host type is converted to a host type ordinal.
    {
    { Input parameters
    {           Received_value       : Input P22 string
    {           Qualifier            : A-A protocol parameter qualifier
    {
    { Output parameters
    {           Host_type            : Returned NOS/VE host or UNKNOWN host type
    {           Status               : Return status
    {


    status.normal := TRUE;
    host_type := nfc$p22_unknown_host;
    CASE qualifier OF
    = nfc$select, nfc$modify =
      IF received_value = nfc$p22_value_cyber_nosve THEN
        host_type := nfc$p22_nos_ve;
      ELSEIF received_value = nfc$p22_value_cyber_nosve_qtf THEN
        host_type := nfc$p22_nos_ve_qtf;
      IFEND;
    = nfc$ignore =
      ;
    ELSE
      nfp$set_internal_error ('nfp$receive_parameter_22 qualifier case', status);
      pmp$exit (status);
    CASEND;

  PROCEND nfp$receive_parameter_22;
?? OLDTITLE ??
?? NEWTITLE := 'nfp$receive_parameter_24', EJECT ??

  PROCEDURE nfp$receive_parameter_24
    (    received_value: string ( * <= nfc$max_param_size);
         qualifier: nft$parameter_qualifiers;
     VAR source_lid: nft$parameter_24_definition;
     VAR status: ost$status);

    {
    { Procedure  nfp$receive_parameter_24
    {
    { Purpose    Receive and process parameter 24, source lid.
    {
    { Description
    {           This routine takes the parameter 24 string and
    {           places it in the proper type.
    {
    { Input parameters
    {        received_value:      Value of source LID
    {        qualifier:           A-A protocol parameter qualifier
    {
    { Output parameters
    {        source_lid:   Returned source LID value
    {        status:       Return status
    {
    { Algorithm
    {        IF qualifer is select or modify, set new value
    {        ELSE if qualifier is ignore, no action
    {        ELSE case error
    {
    status.normal := TRUE;
    CASE qualifier OF
    =nfc$select, nfc$modify =
      source_lid.size := STRLENGTH(received_value);
      source_lid.value := received_value;
    =nfc$ignore=
      ;      { No action }
    ELSE
      nfp$set_internal_error('nfp$receive_parameter_24 case error', status);
    CASEND;
    {}
  PROCEND nfp$receive_parameter_24;
?? OLDTITLE ??
?? NEWTITLE := 'nfp$receive_parameter_25', EJECT ??

  PROCEDURE nfp$receive_parameter_25
    (    command: nft$protocol_commands;
         received_value: string ( * <= nfc$max_param_size);
         qualifier: nft$parameter_qualifiers;
     VAR transfer_lid: nft$parameter_25_definition;
     VAR lid_length: nft$parameter_25_length;
     VAR status: ost$status);

    {
    { Procedure  nfp$receive_parameter_25
    {
    { Purpose    Receive and process parameter 25, transfer lid.
    {
    { Description
    {           The transfer lid is a name which is associated with a PID.
    {           This routine merely saves the transfer LID in the event the
    {           calling application is interested.
    {
    { Input parameters
    {           Received_value       : Received string
    {           Qualifier            : A-A protocol parameter qualifier
    {
    { Output parameters
    {           Buffer_list          : List of network send buffers
    {           Xfer_pid             : Returned LID name value
    {           Lid_length           : Length of returned LID
    {           Status               : Return status
    {
    { Algorithm
    {           Set LID value
    {           Set LID length
    {
?? EJECT ??
    status.normal := TRUE;
    CASE qualifier OF
    = nfc$select =
      transfer_lid := received_value;
      lid_length := STRLENGTH (received_value);
    = nfc$modify, nfc$ignore =
      nfp$qualifier_error (qualifier, nfc$transfer_lid, command, status);
    ELSE
      nfp$set_internal_error ('nfp$receive_parameter_25 case error', status);
    CASEND;
    {}
  PROCEND nfp$receive_parameter_25;
?? OLDTITLE ??
?? NEWTITLE := 'nfp$receive_parameter_26', EJECT ??

{ PURPOSE:
{   This procedure will process parameter 26, job name by validating the P26
{   value received was legal and returning the job name and job name length
{   to the caller.

  PROCEDURE nfp$receive_parameter_26
    (    command: nft$protocol_commands;
         protocol: nft$parameter_00_values;
         received_value: string ( * <= nfc$max_param_size);
         qualifier: nft$parameter_qualifiers;
         negotiation_in_progress: boolean;
     VAR job_name: nft$parameter_26_definition;
     VAR status: ost$status);

    VAR
      job_name_index: integer,
      job_name_length: integer,
      search_index: integer,
      space_filled: boolean;

    status.normal := TRUE;
    CASE qualifier OF
    = nfc$select =
      CASE protocol OF
      = nfc$p00_a101 =
        space_filled := FALSE;

      /name_loop/
        FOR job_name_index := 1 TO STRLENGTH (received_value) DO
          IF (($INTEGER (received_value (job_name_index)) > $INTEGER (nfc$p26_1st_char_a102)) AND
                ($INTEGER (received_value (job_name_index)) <= $INTEGER (nfc$p26_last_char_a102))) THEN
            {      Character is o.k. }
          ELSEIF received_value (job_name_index) = ' ' THEN
            space_filled := TRUE;
            EXIT /name_loop/;
          ELSE
            osp$set_status_abnormal (nfc$status_id, nfe$invalid_p26_value, received_value (job_name_index),
                  status);
            RETURN;
          IFEND;
        FOREND /name_loop/;

        IF space_filled THEN
          job_name_index := job_name_index - 1;
        IFEND;
        job_name_length := job_name_index;
        IF job_name_length > STRLENGTH (job_name.value) THEN { Truncate job name }
          job_name_length := STRLENGTH (job_name.value);
        IFEND;
        job_name.value (1, job_name_length) := received_value;
        job_name.size := job_name_length;
      = nfc$p00_a102, nfc$p00_b101 =

        FOR job_name_index := 1 TO STRLENGTH (received_value) DO
          IF NOT (($INTEGER (received_value (job_name_index,
                1)) >= $INTEGER (nfc$p26_1st_char_a102)) AND ($INTEGER (received_value (job_name_index,
                1)) <= $INTEGER (nfc$p26_last_char_a102))) THEN
            osp$set_status_abnormal (nfc$status_id, nfe$invalid_p26_value, received_value (job_name_index),
                  status);
            RETURN;
          IFEND;
        FOREND;
        job_name_length := STRLENGTH (received_value);
        IF job_name_length > STRLENGTH (job_name.value) THEN { Truncate job name }
          job_name_length := STRLENGTH (job_name.value);
        IFEND;
        job_name.size := job_name_length;
        job_name.value(1, job_name_length) := received_value;
      ELSE
        nfp$set_internal_error ('nfp$receive_parameter_26 protocol case', status);
        pmp$exit (status);
      CASEND;
    = nfc$modify =
      IF NOT (negotiation_in_progress) THEN
        nfp$qualifier_error (qualifier, nfc$job_name, command, status);
      ELSE
        { Do not process, should get again }
      IFEND;
    = nfc$ignore =
      IF NOT (negotiation_in_progress) THEN
        nfp$qualifier_error (qualifier, nfc$job_name, command, status);
      ELSE
        { Do not process, should get again }
      IFEND;
    ELSE
      nfp$set_internal_error ('nfp$receive_parameter_26 qualifier case', status);
    CASEND;

  PROCEND nfp$receive_parameter_26;
?? OLDTITLE ??
?? NEWTITLE := 'nfp$receive_parameter_27', EJECT ??

  PROCEDURE nfp$receive_parameter_27
    (    command: nft$protocol_commands;
         received_value: string ( * <= nfc$max_param_size);
         qualifier: nft$parameter_qualifiers;
     VAR transfer_pid: nft$parameter_27_definition;
     VAR transfer_pid_length: nft$parameter_27_length;
     VAR status: ost$status);

    {
    { Procedure  nfp$receive_parameter_27
    {
    { Purpose    Receive and process parameter 27, transfer PID.
    {
    { Description
    {           The PID for NOS/VE to NOS/VE transfers should be a family
    {           name.  With other hosts, it may be an abstration.
    {
    { Input parameters
    {           Received_value       : Received string
    {           Qualifier            : A-A protocol parameter qualifier
    {
    { Output parameters
    {           Xfer_pid             : Returned PID name value
    {           Pid_length           : Length of returned PID
    {           Status               : Return status
    {
    { Algorithm
    {           Set PID name
    {           Set PID length
    {
?? EJECT ??
    status.normal := TRUE;
    CASE qualifier OF
    = nfc$select =
      transfer_pid := received_value;
      transfer_pid_length := STRLENGTH (received_value);
    = nfc$modify =
{     Do not process }
    = nfc$ignore =
      nfp$qualifier_error (qualifier, nfc$job_name, command, status);
    ELSE
      nfp$set_internal_error ('nfp$receive_parameter_27 case statement', status);
    CASEND;
    {}
  PROCEND nfp$receive_parameter_27;
?? OLDTITLE ??
?? NEWTITLE := 'nfp$receive_parameter_28', EJECT ??

  PROCEDURE nfp$receive_parameter_28
    (    received_value: string ( * <= nfc$max_param_size);
         qualifier: nft$parameter_qualifiers;
     VAR host_type: nft$parameter_22_values;
     VAR status: ost$status);

{
{ Procedure  nfp$receive_parameter_28
{
{ Purpose    To receive parameter 28, destination host type.
{
{ Description
{            The destination host type is sent by an initiator when it
{            thinks (hopes) it knows the type of the remote host.
{            If it is incorrect, the value should be modified or the
{            transfer RNEG'ed.
{
{ Input parameters
{            Received_value       : Input string
{            Qualifier            : A-A protocol parameter qualifier
{
{ Output parameters
{            Host_type            : Returned NOS/VE host or UNKNOWN host type
{            Status               : Return status
{


    status.normal := TRUE;
    host_type := nfc$p22_unknown_host;
    CASE qualifier OF
    = nfc$select, nfc$modify =
      IF received_value = nfc$p22_value_cyber_nosve THEN
        host_type := nfc$p22_nos_ve;
      ELSEIF received_value = nfc$p22_value_cyber_nosve_qtf THEN
        host_type := nfc$p22_nos_ve_qtf;
      IFEND;
    = nfc$ignore =
    ELSE
      nfp$set_internal_error ('nfp$receive_parameter_28 qualifier case', status);
      pmp$exit (status);
    CASEND;

  PROCEND nfp$receive_parameter_28;
?? OLDTITLE ??
?? NEWTITLE := 'nfp$receive_parameter_29', EJECT ??

  PROCEDURE nfp$receive_parameter_29
    (    received_value: string(*<=nfc$p29_max_param_size);
     VAR echo_text_list: nft$parameter_29_list_head);
{
{ Procedure  nfp$receive_parameter_29
{
{ Purpose    To receive protocol parameter 29, echo text.
{
{ Description
{            The received echo text is placed on a linked list
{            for application specific processing.
{
{ Input parameters
{            received_value:      Input echo text value
{
{ Output parameters
{            echo_text_list:      List of echo text values received
{
{ Algorithm
{
{
{
{
{
{
?? EJECT ??
  VAR current_entry: ^nft$parameter_29_definition;

  ALLOCATE current_entry;
  current_entry^.size := STRLENGTH(received_value);
  current_entry^.value := received_value;
  current_entry^.link := NIL;
  IF echo_text_list.first_text = NIL THEN
    echo_text_list.first_text := current_entry;
    echo_text_list.last_text := current_entry;
  ELSE
    echo_text_list.last_text^.link := current_entry;
    echo_text_list.last_text := current_entry;
  IFEND;

  PROCEND nfp$receive_parameter_29;
?? OLDTITLE ??
?? NEWTITLE := '[XDCL] nfp$convert_p31_to_ordinal', EJECT ??

{ PURPOSE:
{   To convert a string, if possible, to a data declaration ordinal.
{   This routine essentially just loops through the list of
{   known data declarations attempting to match the input value.

  PROCEDURE [XDCL] nfp$convert_p31_to_ordinal
    (    received_value: string ( * <= nfc$max_param_size);
     VAR data_type: nft$parameter_31_type;
     VAR status: ost$status);

    VAR
      found_it: boolean,
      index: nft$parameter_31_type;

    VAR
      nfv$parameter_31_values: [XREF] nft$parameter_31_definition;

    status.normal := TRUE;
    found_it := FALSE;

  /search_loop/
    FOR index := LOWERBOUND (nfv$parameter_31_values) TO UPPERBOUND (nfv$parameter_31_values) DO
      IF received_value = nfv$parameter_31_values [index] THEN
        found_it := TRUE;
        EXIT /search_loop/;
      IFEND;
    FOREND /search_loop/;

    IF found_it THEN
      data_type := index;
    ELSE
      osp$set_status_abnormal (nfc$status_id, nfe$unknown_data_format, received_value, status);
    IFEND;

  PROCEND nfp$convert_p31_to_ordinal;
?? OLDTITLE ??
?? NEWTITLE := 'nfp$receive_parameter_31', EJECT ??

{ PURPOSE:
{   To receive protocol parameter 31, data declaration.
{   The received data declaration is converted into our P31 ordinal type.

  PROCEDURE nfp$receive_parameter_31
    (    application: nft$application_values;
         received_value: string ( * <= nfc$max_param_size);
         qualifier: nft$parameter_qualifiers;
     VAR data_type: nft$parameter_31_type;
     VAR status: ost$status);

    status.normal := TRUE;
    CASE qualifier OF
    = nfc$select, nfc$modify =
      nfp$convert_p31_to_ordinal (received_value, data_type, status);
      IF (status.normal) AND (data_type=nfc$p31_undefined_structured_us) AND
           (application <> nfc$application_ptf) AND (application <> nfc$application_ptfs) AND
           (application <> nfc$application_qtf) AND (application <> nfc$application_qtfs) THEN
        osp$set_status_abnormal(nfc$status_id,nfe$unknown_data_format,
            received_value,status);
      IFEND;
    = nfc$ignore =
    ELSE
      nfp$set_internal_error ('nfp$receive_parameter_31 qualifier case', status);
      pmp$exit (status);
    CASEND;

  PROCEND nfp$receive_parameter_31;
?? OLDTITLE ??
?? NEWTITLE := 'nfp$receive_parameter_32', EJECT ??

  PROCEDURE nfp$receive_parameter_32
    (    received_value: string ( * <= nfc$max_param_size);
         qualifier: nft$parameter_qualifiers;
     VAR systems_routing_text: jmt$system_routing_text;
     VAR status: ost$status);

{
{ Procedure  nfp$receive_parameter_32
{
{ Purpose    To receive parameter 32, systems routing text.
{
{ Description
{            This routine takes a received string value and
{            repackages it as systems routing text.  Note:
{            systems routing text is defined differently for various
{            applications.
{
{ Input parameters
{            received_value:      Implicit text value
{            qualifier:           A-A protocol parameter qualifier
{
{ Output parameters
{            systems_routing_text:       Systems routing text
{            status:                     Return status
{
{ Algorithm
{            systems_routing_text := received_value
{
?? EJECT ??
    status.normal := TRUE;
    CASE qualifier OF
    = nfc$select, nfc$modify =
      systems_routing_text.size := STRLENGTH (received_value);
      IF STRLENGTH (received_value) > 0 THEN
        systems_routing_text.parameters := received_value;
      IFEND;
    = nfc$ignore =
    ELSE
      nfp$set_internal_error ('nfp$receive_parameter_32 invalid case', status);
    CASEND;
{}
  PROCEND nfp$receive_parameter_32;
?? OLDTITLE ??
?? NEWTITLE := 'nfp$receive_parameter_33', EJECT ??

  PROCEDURE nfp$receive_parameter_33
    (    received_value: string ( * <= nfc$max_param_size);
         qualifier: nft$parameter_qualifiers;
     VAR implicit_routing_text: jmt$implicit_routing_text;
     VAR status: ost$status);

{
{ Procedure  nfp$receive_parameter_33
{
{ Purpose    Receive and process parameter 33, implicit routing text
{
{ Description
{            This routine takes a received string value and
{            repackages it as implicit routing text.  Note:
{            implicit routing text is defined differently for various
{            applications.
{
{ Input parameters
{            received_value:      Implicit text value
{            qualifier:           A-A protocol parameter qualifier
{
{ Output parameters
{            implicit_routing_text:      Systems routing text
{            status:                     Return status
{
{ Algorithm
{            implicit_routing_text := received_value
{
?? EJECT ??
    status.normal := TRUE;
    CASE qualifier OF
    = nfc$select, nfc$modify =
      implicit_routing_text.size := STRLENGTH (received_value);
      IF STRLENGTH (received_value) > 0 THEN
        implicit_routing_text.text := received_value;
      IFEND;
    = nfc$ignore =
      nfp$set_internal_error ('nfp$receive_parameter_33 invalid case', status);
    CASEND;
{}
  PROCEND nfp$receive_parameter_33;
?? OLDTITLE ??
?? NEWTITLE := 'nfp$receive_parameter_51', EJECT ??

  PROCEDURE nfp$receive_parameter_51
    (    protocol: nft$parameter_00_values;
         command: nft$protocol_commands;
         received_value: string ( * <= nfc$max_param_size);
         qualifier: nft$parameter_qualifiers;
     VAR buffer_list: nft$network_buffer_list;
     VAR user_file_name: ost$string;
     VAR status: ost$status);

{                                                                             }
{ Procedure  nfp$receive_parameter_51                                         }
{                                                                             }
{ Purpose    To receive and process parameter 51, user file name.  This       }
{            parameter is used only by BTF/BTFS at present.                   }
{                                                                             }
{ Description                                                                 }
{                                                                             }
{                                                                             }
{                                                                             }
{                                                                             }
{                                                                             }
{                                                                             }
{ Input parameters                                                            }
{                                                                             }
{                                                                             }
{                                                                             }
{                                                                             }
{                                                                             }
{ Output parameters                                                           }
{                                                                             }
{                                                                             }
{                                                                             }
{                                                                             }
{                                                                             }
{ Algorithm                                                                   }
{                                                                             }
{                                                                             }
{                                                                             }
{                                                                             }
{                                                                             }
{                                                                             }
{                                                                             }
{                                                                             }
{                                                                             }
{                                                                             }
    status.normal := TRUE;
    user_file_name.value := received_value;
    user_file_name.size := STRLENGTH (received_value);
{}
  PROCEND nfp$receive_parameter_51;
?? OLDTITLE ??
?? NEWTITLE := 'nfp$receive_parameter_52', EJECT ??

  PROCEDURE nfp$receive_parameter_52
    (    protocol: nft$parameter_00_values;
         command: nft$protocol_commands;
         received_value: string ( * <= nfc$max_param_size);
         qualifier: nft$parameter_qualifiers;
     VAR buffer_list: nft$network_buffer_list;
     VAR banner_dtime: ost$string;
     VAR status: ost$status);

{                                                                             }
{ Procedure  nfp$receive_parameter_52                                         }
{                                                                             }
{ Purpose    To receive and process parameter 52, banner date and time.       }
{            Note: this parameter is used only by BTF/BTFS at present.        }
{                                                                             }
{ Description                                                                 }
{            This parameter specifies the date and time that the file         }
{            transfer to the output device is being initiated.  The           }
{            receiver uses this parameter value when constructing the         }
{            output file banner.                                              }
{                                                                             }
{ Input parameters                                                            }
{                                                                             }
{                                                                             }
{                                                                             }
{                                                                             }
{                                                                             }
{ Output parameters                                                           }
{                                                                             }
{                                                                             }
{                                                                             }
{                                                                             }
{                                                                             }
{ Algorithm                                                                   }
{                                                                             }
{                                                                             }
{                                                                             }
{                                                                             }
{                                                                             }
{                                                                             }
{                                                                             }
{                                                                             }
{                                                                             }
{                                                                             }
    status.normal := TRUE;
    banner_dtime.value := received_value;
    banner_dtime.size := STRLENGTH (received_value);
{}
  PROCEND nfp$receive_parameter_52;
?? OLDTITLE ??
?? NEWTITLE := 'nfp$receive_parameter_53', EJECT ??

  PROCEDURE nfp$receive_parameter_53
    (    protocol: nft$parameter_00_values;
         command: nft$protocol_commands;
         received_value: string ( * <= nfc$max_param_size);
         qualifier: nft$parameter_qualifiers;
     VAR buffer_list: nft$network_buffer_list;
     VAR banner_routing_text: ost$string;
     VAR status: ost$status);

{                                                                             }
{ Procedure  nfp$receive_parameter_53                                         }
{                                                                             }
{ Purpose    To receive parameter 53, banner routing messages.                }
{                                                                             }
{ Description                                                                 }
{            This parameter specifies the physical location identifier        }
{            for the place that the public I/O station operator is to         }
{            send the output file hard copy.  This parameter is used by       }
{            the receiver when constructing the output file banner.           }
{                                                                             }
{ Input parameters                                                            }
{                                                                             }
{                                                                             }
{                                                                             }
{                                                                             }
{                                                                             }
{ Output parameters                                                           }
{                                                                             }
{                                                                             }
{                                                                             }
{                                                                             }
{                                                                             }
{ Algorithm                                                                   }
{                                                                             }
{                                                                             }
{                                                                             }
{                                                                             }
{                                                                             }
{                                                                             }
{                                                                             }
{                                                                             }
{                                                                             }
{                                                                             }
?? EJECT ??
    status.normal := TRUE;
    banner_routing_text.value := received_value;
    banner_routing_text.size := STRLENGTH (received_value);
{}
  PROCEND nfp$receive_parameter_53;
?? OLDTITLE ??
?? NEWTITLE := 'nfp$receive_parameter_54', EJECT ??

  PROCEDURE nfp$receive_parameter_54
    (    protocol: nft$parameter_00_values;
         command: nft$protocol_commands;
         received_value: string ( * <= nfc$max_param_size);
         qualifier: nft$parameter_qualifiers;
     VAR buffer_list: nft$network_buffer_list;
     VAR user_banner_text: ost$string;
     VAR status: ost$status);

{                                                                             }
{ Procedure  nfp$receive_parameter_54                                         }
{                                                                             }
{ Purpose    To receive and process parameter 54, user banner message.        }
{                                                                             }
{ Description                                                                 }
{            This parameter contains the user provided text string that       }
{            the receiver is to employ when constructing the output file      }
{            banner.                                                          }
{                                                                             }
{ Input parameters                                                            }
{                                                                             }
{                                                                             }
{                                                                             }
{                                                                             }
{                                                                             }
{ Output parameters                                                           }
{                                                                             }
{                                                                             }
{                                                                             }
{                                                                             }
{                                                                             }
{ Algorithm                                                                   }
{                                                                             }
{                                                                             }
{                                                                             }
{                                                                             }
{                                                                             }
{                                                                             }
{                                                                             }
{                                                                             }
{                                                                             }
{                                                                             }
?? EJECT ??
    status.normal := TRUE;
    user_banner_text.value := received_value;
    user_banner_text.size := STRLENGTH (received_value);
{}
  PROCEND nfp$receive_parameter_54;
?? OLDTITLE ??
?? NEWTITLE := 'nfp$receive_parameter_55', EJECT ??

  PROCEDURE nfp$receive_parameter_55
    (    protocol: nft$parameter_00_values;
         command: nft$protocol_commands;
         received_value: string ( * <= nfc$max_param_size);
         qualifier: nft$parameter_qualifiers;
     VAR buffer_list: nft$network_buffer_list;
     VAR installation_banner_message: ost$string;
     VAR status: ost$status);

{                                                                             }
{ Procedure  nfp$receive_parameter_55                                         }
{                                                                             }
{ Purpose    To receive and process parameter 55, installation banner message.}
{                                                                             }
{ Description                                                                 }
{            This parameter contains the installation provided text string    }
{            that the receiver is to employ when constructing the output      }
{            file banner.                                                     }
{                                                                             }
{ Input parameters                                                            }
{                                                                             }
{                                                                             }
{                                                                             }
{                                                                             }
{                                                                             }
{ Output parameters                                                           }
{                                                                             }
{                                                                             }
{                                                                             }
{                                                                             }
{                                                                             }
{ Algorithm                                                                   }
{                                                                             }
{                                                                             }
{                                                                             }
{                                                                             }
{                                                                             }
{                                                                             }
{                                                                             }
{                                                                             }
{                                                                             }
{                                                                             }
?? EJECT ??
    status.normal := TRUE;
    installation_banner_message.value := received_value;
    installation_banner_message.size := STRLENGTH (received_value);
{}
  PROCEND nfp$receive_parameter_55;
?? OLDTITLE ??
?? NEWTITLE := 'nfp$receive_parameter_56', EJECT ??

  PROCEDURE nfp$receive_parameter_56
    (    protocol: nft$parameter_00_values;
         command: nft$protocol_commands;
         received_value: string ( * <= nfc$max_param_size);
         qualifier: nft$parameter_qualifiers;
     VAR reposition: ost$string;
     VAR status: ost$status);

{                                                                             }
{ Procedure  nfp$receive_parameter_56                                         }
{                                                                             }
{ Purpose    To receive and process parameter 56, reposition output file.     }
{                                                                             }
{ Description                                                                 }
{            This parameter contains the I/O station operator entered         }
{            output file repositioning command parameters to be used by       }
{            the sender to define the new file position.                      }
{                                                                             }
{ Input parameters                                                            }
{                                                                             }
{                                                                             }
{                                                                             }
{                                                                             }
{                                                                             }
{ Output parameters                                                           }
{                                                                             }
{                                                                             }
{                                                                             }
{                                                                             }
{                                                                             }
{ Algorithm                                                                   }
{                                                                             }
{                                                                             }
{                                                                             }
{                                                                             }
{                                                                             }
{                                                                             }
{                                                                             }
{                                                                             }
{                                                                             }
{                                                                             }
?? EJECT ??
    status.normal := TRUE;
    reposition.value := received_value;
    reposition.size := STRLENGTH (received_value);
{}
  PROCEND nfp$receive_parameter_56;
?? OLDTITLE ??
?? NEWTITLE := 'nfp$receive_parameter_57', EJECT ??

  PROCEDURE nfp$receive_parameter_57
    (    protocol: nft$parameter_00_values;
         command: nft$protocol_commands;
         received_value: string ( * <= nfc$max_param_size);
         qualifier: nft$parameter_qualifiers;
     VAR current_pos: ost$string;
     VAR status: ost$status);

{                                                                             }
{ Procedure  nfp$receive_parameter_57                                         }
{                                                                             }
{ Purpose    To receive and process parameter 57, current file position.      }
{                                                                             }
{ Description                                                                 }
{            This parameter specifies the current file position byte and      }
{            record ordinal.  When this parameter is specified by the PR      }
{            command, this parameter contains the byte and record ordinal of  }
{            the last physical record transmitted to the output device.       }
{            When the data declaration parameter value is C8, the record      }
{            ordinal corresponds to the number of unit separator (US)         }
{            characters imbedded within the data sent or received.            }
{                                                                             }
{ Input parameters                                                            }
{                                                                             }
{                                                                             }
{                                                                             }
{                                                                             }
{                                                                             }
{ Output parameters                                                           }
{                                                                             }
{                                                                             }
{                                                                             }
{                                                                             }
{                                                                             }
{ Algorithm                                                                   }
{                                                                             }
{                                                                             }
{                                                                             }
{                                                                             }
{                                                                             }
{                                                                             }
{                                                                             }
{                                                                             }
{                                                                             }
{                                                                             }
?? EJECT ??
    status.normal := TRUE;
    current_pos.value := received_value;
    current_pos.size := STRLENGTH (received_value);
{}
  PROCEND nfp$receive_parameter_57;
?? OLDTITLE ??
?? NEWTITLE := 'nfp$receive_parameter_58', EJECT ??

  PROCEDURE nfp$receive_parameter_58
    (    protocol: nft$parameter_00_values;
         command: nft$protocol_commands;
         received_value: string ( * <= nfc$max_param_size);
         qualifier: nft$parameter_qualifiers;
     VAR default_output_destination: ost$string;
     VAR status: ost$status);

{                                                                             }
{ Procedure  nfp$receive_parameter_58                                         }
{                                                                             }
{ Purpose    To receive and process parameter 58, default output file         }
{            destination.                                                     }
{                                                                             }
{ Description                                                                 }
{            This parameter specifies the identity of the default destination }
{            I/O station for output files disposed by the job being           }
{            transferred from an input batch device.                          }
{                                                                             }
{ Input parameters                                                            }
{                                                                             }
{                                                                             }
{                                                                             }
{                                                                             }
{                                                                             }
{ Output parameters                                                           }
{                                                                             }
{                                                                             }
{                                                                             }
{                                                                             }
{                                                                             }
{ Algorithm                                                                   }
{                                                                             }
{                                                                             }
{                                                                             }
{                                                                             }
{                                                                             }
{                                                                             }
{                                                                             }
{                                                                             }
{                                                                             }
{                                                                             }
?? EJECT ??
    status.normal := TRUE;
    default_output_destination.value := received_value;
    default_output_destination.size := STRLENGTH (received_value);
{}
  PROCEND nfp$receive_parameter_58;
?? OLDTITLE ??
?? NEWTITLE := 'nfp$receive_parameter_59' , eject ??
  PROCEDURE nfp$receive_parameter_59
    (    received_value: string ( * <= nfc$max_param_size);
         qualifier: nft$parameter_qualifiers;
    VAR  vertical_print_density: jmt$vertical_print_density;
    VAR  status: ost$status);
{
{ Procedure  nfp$receive_parameter_59
{
{ Purpose    To receive protocol parameter 58, vertical print density.
{
{ Description
{            This routine converts a received vertical print density to
{            an ordinal.
{
{ Input parameters
{            Received_value:      Input vertical print density value
{            Qualifier:           A-A protocol parameter qualifier
{
{ Output parameters
{            Vertical_print_density:     Returned value
{            Status:                     Returned status
{ Algorithm
{            If parameter selected or modified, translate value
{
  VAR
      vertical_print_density_index: jmt$vertical_print_density,
      vpd_match: BOOLEAN;

  VAR
      nfv$p59_values: [XREF] nft$parameter_59_values;
{}
  CASE qualifier OF
  =nfc$select, nfc$modify=
   vpd_match := FALSE;
   /search_vpd_loop/
   FOR vertical_print_density_index := LOWERBOUND(nfv$p59_values) TO
                                       UPPERBOUND(nfv$p59_values) DO
     IF (received_value = nfv$p59_values[vertical_print_density_index]) THEN
       vpd_match := TRUE;
       EXIT /search_vpd_loop/;
     IFEND;
   FOREND;
   IF vpd_match THEN
     vertical_print_density := vertical_print_density_index;
   ELSE
     nfp$set_internal_error('Received bad P59 vpd', status);
   IFEND;
  =nfc$ignore=
   ;
  CASEND;
{}
  PROCEND nfp$receive_parameter_59;
?? OLDTITLE ??
?? NEWTITLE := 'nfp$receive_parameter_60' , eject ??
  PROCEDURE nfp$receive_parameter_60
    (    received_value: string ( * <= nfc$max_param_size);
         qualifier: nft$parameter_qualifiers;
    VAR  vfu_load_procedure: nft$parameter_60_element;
    VAR  status: ost$status);
{
{ Procedure  nfp$receive_parameter_60
{
{ Purpose    To receive protocol parameter 60, vfu load procedure.
{
{ Description
{            This routine returns a vfu load procedure name.
{
{ Input parameters
{            Received_value:      VFU load procedure string
{            Qualifier:           A-A protocol parameter qualifier
{
{ Output parameters
{            Vfu_load_procedure:  Returned value
{            Status:              Return status
{
{ Algorithm
{            If param selected or modified, then set return value.
{
?? EJECT ??
CASE qualifier OF
=nfc$select, nfc$modify=
  vfu_load_procedure.size := STRLENGTH(received_value);
  vfu_load_procedure.value := received_value;
=nfc$ignore=
  ;
CASEND;
{}
  PROCEND nfp$receive_parameter_60;
?? OLDTITLE ??
?? NEWTITLE := 'nfp$common_static_definitions', EJECT ??

  PROCEDURE nfp$common_static_definitions;


    VAR
      nfv$command_values: [STATIC, READ, XDCL, nfs$protocol_engine_static] nft$command_values :=
            [nfc$command_unknown, nfc$command_rft, nfc$command_rpos, nfc$command_rneg, nfc$command_go,
            nfc$command_stop, nfc$command_stopr, nfc$command_etp, nfc$command_etpr, nfc$command_fini];

    VAR
      nfv$param_qualifier_values: [STATIC, READ, XDCL, nfs$protocol_engine_static]
            nft$parameter_qualifier_values := [nfc$select_parameter, nfc$ignore_parameter,
            nfc$modify_parameter];

    VAR
      nfv$param_id_values: [STATIC, READ, XDCL, nfs$protocol_engine_static] nft$parameter_values :=
            [nfc$s_protocol_id, nfc$s_maximum_file_length, nfc$s_transfer_id, nfc$s_facilities,
            nfc$s_state_of_transfer, nfc$s_user_text_directive, nfc$s_file_length, nfc$s_operator_message,
            nfc$s_user_message, nfc$s_account_message, nfc$s_error_log_message, nfc$s_special_options,
            nfc$s_max_block_size, nfc$s_accounting_limit, nfc$s_file_name, nfc$s_file_disposition,
            nfc$s_acknowledgment_window, nfc$s_initial_checkmark, nfc$s_minimum_timeout_interval,
            nfc$s_mode_of_access, nfc$s_host_type, nfc$s_transfer_phase_attribute, nfc$s_source_lid,
            nfc$s_transfer_lid, nfc$s_job_name, nfc$s_physical_id, nfc$s_destination_host_type, nfc$s_echo,
            nfc$s_attribute_continued, nfc$s_data_declaration, nfc$s_system_routing_text,
            nfc$s_implicit_routing_text, nfc$s_user_file_name, nfc$s_banner_date_and_time,
            nfc$s_banner_routing_text, nfc$s_user_banner_text, nfc$s_installation_banner_text,
            nfc$s_reposition_output_params, nfc$s_current_file_position, nfc$s_output_file_destination,
            nfc$s_vertical_print_density, nfc$s_vfu_load_procedure,
            nfc$s_reserved_for_site_90, nfc$s_reserved_for_site_91, nfc$s_reserved_for_site_92,
            nfc$s_reserved_for_site_93, nfc$s_reserved_for_site_94, nfc$s_reserved_for_site_95,
            nfc$s_reserved_for_site_96, nfc$s_reserved_for_site_97, nfc$s_reserved_for_site_98,
            nfc$s_reserved_for_site_99];

    VAR
      nfv$param_id_numbers: [STATIC, READ, XDCL, nfs$protocol_engine_static] nft$parameter_numbers :=
            [nfc$i_protocol_id, nfc$i_maximum_file_length, nfc$i_transfer_id, nfc$i_facilities,
            nfc$i_state_of_transfer, nfc$i_user_text_directive, nfc$i_file_length, nfc$i_operator_message,
            nfc$i_user_message, nfc$i_account_message, nfc$i_error_log_message, nfc$i_special_options,
            nfc$i_max_block_size, nfc$i_accounting_limit, nfc$i_file_name, nfc$i_file_disposition,
            nfc$i_acknowledgment_window, nfc$i_initial_checkmark, nfc$i_minimum_timeout_interval,
            nfc$i_mode_of_access, nfc$i_host_type, nfc$i_transfer_phase_attribute, nfc$i_source_lid,
            nfc$i_transfer_lid, nfc$i_job_name, nfc$i_physical_id, nfc$i_destination_host_type, nfc$i_echo,
            nfc$i_attribute_continued, nfc$i_data_declaration, nfc$i_system_routing_text,
            nfc$i_implicit_routing_text, nfc$i_user_file_name, nfc$i_banner_date_and_time,
            nfc$i_banner_routing_text, nfc$i_user_banner_text, nfc$i_installation_banner_text,
            nfc$i_reposition_output_params, nfc$i_current_file_position, nfc$i_output_file_destination,
            nfc$i_vertical_print_density, nfc$i_vfu_load_procedure,
            nfc$i_reserved_for_site_90, nfc$i_reserved_for_site_91, nfc$i_reserved_for_site_92,
            nfc$i_reserved_for_site_93, nfc$i_reserved_for_site_94, nfc$i_reserved_for_site_95,
            nfc$i_reserved_for_site_96, nfc$i_reserved_for_site_97, nfc$i_reserved_for_site_98,
            nfc$i_reserved_for_site_99];

    VAR
      nfv$lcn_application_names: [STATIC, READ, XDCL] nft$lcn_application_names :=
            [nfc$lcn_appl_name_ptf, nfc$lcn_appl_name_ptfs, nfc$lcn_appl_name_qtf, nfc$lcn_appl_name_qtfs,
            nfc$lcn_appl_name_btf, nfc$lcn_appl_name_btfs];

    VAR
      nfv$nam_application_names: [STATIC, READ, XDCL] nft$nam_application_names :=
            [nfc$nam_appl_name_ptf, nfc$nam_appl_name_ptfs, nfc$nam_appl_name_qtf, nfc$nam_appl_name_qtfs,
            nfc$nam_appl_name_btf, nfc$nam_appl_name_btfs];

    VAR
      nfv$p00_values: [STATIC, READ, XDCL, nfs$protocol_engine_static] nft$p00_values :=
            [[nfc$p00_value_a101, nfc$p00_size_a101], [nfc$p00_value_a102, nfc$p00_size_a102],
            [nfc$p00_value_b101, nfc$p00_size_b101]];

    VAR
      nfv$p03_values: [STATIC, READ, XDCL, nfs$protocol_engine_static] nft$parameter_03_elements :=
            [nfc$p03_s_multiple_data_params, nfc$p03_s_collective_strings, nfc$p03_s_temporary_hold,
            nfc$p03_s_parameters_on_go, nfc$p03_s_later_resumption, nfc$p03_s_restart_permitted,
            nfc$p03_s_checkmark_ack_req, nfc$p03_s_send_data_ack_req, nfc$p03_s_data_compression];

    VAR
      nfv$p04_values: [READ, STATIC, XDCL, nfs$protocol_engine_static] nft$parameter_04_values :=
            [['000000', TRUE], ['000001', TRUE],

      ['011000', FALSE, nfe$unspecific_transfer, FALSE], ['011001', FALSE, nfe$transfer_rejected_message,
            FALSE], ['011002', FALSE, nfe$unacceptable_attributes, FALSE],
            ['011010', FALSE, nfe$unspecific_file_store, FALSE], ['011011', FALSE, nfe$file_not_found, FALSE],
            ['011012', FALSE, nfe$no_file_access, FALSE], ['011013', FALSE, nfe$wrong_file_type, FALSE],
            ['011014', FALSE, nfe$file_unavailable, FALSE], ['011015', FALSE, nfe$invalid_user, FALSE],
            ['011016', FALSE, nfe$invalid_password, FALSE], ['011017', FALSE, nfe$invalid_account, FALSE],
            ['011018', FALSE, nfe$invalid_account_pw, FALSE], ['011019', FALSE, nfe$no_money, FALSE],
            ['011020', FALSE, nfe$file_too_large, FALSE], ['011021', FALSE, nfe$wrong_device, FALSE],

      ['022000', TRUE], ['022001', FALSE, nfe$terminate_transfer_message, FALSE],
            ['022005', FALSE, nfe$accounting_limit_exceeded, FALSE],
            ['022006', FALSE, nfe$discard_input_file, FALSE],
            ['022007', FALSE, nfe$requeue_output_file, FALSE],
            ['022008', FALSE, nfe$requeue_at_current_priority, FALSE],
            ['022009', FALSE, nfe$requeue_not_eligible_file, FALSE],
            ['022010', FALSE, nfe$requeue_at_new_priority, FALSE],
            ['022011', FALSE, nfe$pm_message_time_out, FALSE],
            ['022012', FALSE, nfe$station_operator_terminate, FALSE],

      ['033000', FALSE, nfe$satisfactory_and_incomplete, FALSE],
            ['033001', FALSE, nfe$receiver_problem_retry, TRUE],
            ['033002', FALSE, nfe$receiver_problem_no_retry, FALSE],
            ['033003', FALSE, nfe$sender_problem_retry, TRUE],
            ['033004', FALSE, nfe$sender_problem_no_retry, FALSE],
            ['033005', FALSE, nfe$application_time_out, FALSE],
            ['033006', FALSE, nfe$protocol_anomaly, FALSE]];

    VAR
      nfv$parameter_17_values: [STATIC, READ, XDCL, nfs$protocol_engine_static] nft$parameter_17_values :=
            [ {nfc$p17_line_printer} 'LP',
              {nfc$p17_hollerith_card_punch} 'CP',
              {nfc$p17_binary_card_punch} 'PB',
              {nfc$p17_binary_checksummed_cp} 'P8',
              {nfc$p17_special_output} 'SP',
              {nfc$p17_input_return} 'IN',
              {nfc$input_no_return} 'IX',
              {nfc$generic_queue} 'GQ'];

    VAR
      nfv$p21_values: [STATIC, READ, XDCL, nfs$protocol_engine_static] nft$parameter_21_values :=
            [nfc$p21_prefix_value_give, nfc$p21_prefix_value_take, nfc$p21_prefix_value_null];

    VAR
      nfv$p21_options: [STATIC, READ, XDCL, nfs$protocol_engine_static] nft$parameter_21_specifications :=
            [nfc$p21_opt_non_specific, nfc$p21_opt_make_only, nfc$p21_opt_replace_only,
            nfc$p21_opt_replace_make, nfc$p21_opt_append_only, nfc$p21_opt_append_or_make,
            nfc$p21_opt_read_remove, nfc$p21_opt_read_only, nfc$p21_opt_destructive_read,
            nfc$p21_opt_make_only_too];
    VAR
      nfv$p22_values: [STATIC, READ, XDCL, nfs$protocol_engine_static] nft$parameter_22_strings :=
            [nfc$p22_value_unknown_host, nfc$p22_value_cyber_nosve, nfc$p22_value_cyber_nosve_qtf];

    VAR
      nfv$p30_value: [STATIC, READ, XDCL, nfs$protocol_engine_static] string (nfc$p30_required_space) :=
            nfc$p30_param_value;

    VAR
      nfv$parameter_31_values: [STATIC, READ, XDCL, nfs$protocol_engine_static] nft$parameter_31_definition :=
            [nfc$p31_unspecified_dd, nfc$p31_ascii_64, nfc$p31_ascii_extended, nfc$p31_host_dependent,
            nfc$p31_undefined_unstructured, nfc$p31_undefined_structured];

    VAR
      nfv$p59_values: [STATIC, READ, XDCL, nfs$protocol_engine_static] nft$parameter_59_values := ['XX', 'XX',
            '06', '07', '08', '09', '10', '11', '12' ];

  PROCEND nfp$common_static_definitions;
?? OLDTITLE ??
?? NEWTITLE := 'NAM/LCN interface routines' ??
?? NEWTITLE := '[XDCL] nfp$send_connect_request', EJECT ??

  PROCEDURE [XDCL] nfp$send_connect_request
    (    location: ost$name;
         server: nft$application_values;
         initiator: nft$application_values;
     VAR path: nft$network_connection;
     VAR status: ost$status);

    {
    { Procedure  nfp$send_connect_request
    {
    { Purpose    This module is responsible for attempting to initiating the
    {            connect process to a client (server) application.  This
    {            function
    {            is complicated by the fact two access methods are (possibly)
    {            available, LCN and NAM.
    {
    { Description
    {           This routine requests connection to a remote host via both
    {           LCN and NAM.  LCN is asked first  because LCN is much, much
    {           faster.  If LCN can't do the trick (possibly because it is not
    {           there)  we try NAM. The trick here is to pass back a retryable
    {           error if one is discovered from either LCN or NAM.  Also note
    {           some clean up should be done, only logging errors to the
    {           dayfile if the access method is there.  Therefore, we need an
    {           error for NAM/LCN the implies access method not there.
    {
    { Input parameters
    {           location             : The name of the remote service
    {           server               : Ordinal of the remote server
    {                                  application
    {           initiator            : Ordinal of the local initiator
    {                                  application
    {
    { Output parameters
    {           path                 : Structure containing connect info
    {           status               : Return status value
    {
    { Algorithm
    {           nfp$send_lcn_connect_request
    {           if success then
    {             set access method type = lcn
    {           else
    {             nfp$send_nam_connect_request
    {             if success then
    {               set access method type = nam
    {             else
    {               return appropriate status
    {             ifend
    {           ifend
    {
?? EJECT ??

    VAR
      lcn_status: ost$status,
      nam_status: ost$status;

{}
    status.normal := TRUE;
    path.path_connected := FALSE;
    nfp$send_lcn_connect_request (server, initiator, location, path, lcn_status);
    IF lcn_status.normal THEN
      path.network_type := nfc$network_lcn;
      path.path_connected := TRUE;
      status.normal := TRUE;
    ELSE { Log message if unexpected result }
      IF (lcn_status.condition <> rfe$system_task_not_active) AND
            (lcn_status.condition <> rfe$destination_host_undefined) THEN
        pmp$log (' RHF - Error in RHFAM connection process', status);
        nfp$format_message_to_job_log (lcn_status);
      IFEND;
{}
{     Try to send a sensible error to initiating application }
{}
      IF (lcn_status.condition = rfe$destination_host_undefined) THEN
        osp$set_status_abnormal (nfc$status_id, nfe$service_not_found, location, status);
      ELSEIF (lcn_status.condition = rfe$remote_host_busy) OR
             (lcn_status.condition = rfe$server_busy) THEN
        osp$set_status_abnormal (nfc$status_id, nfe$recoverable_connect, location, status);
      ELSE
        osp$set_status_abnormal (nfc$status_id, nfe$service_not_found, location, status);
      IFEND;
      nfp$send_nam_connect_request (path.network_file^, initiator, server, location, path.network_file_id,
            nam_status);
      IF nam_status.normal THEN
        path.network_type := nfc$network_nam;
        path.path_connected := TRUE;
        status.normal := TRUE;
      ELSE { ** cannot connect , log error if unexpected ** }
        IF (nam_status.condition <> nae$network_inactive) AND
              (nam_status.condition <> nfe$service_not_found) THEN
          pmp$log (' RHF - Error in NAM connection process', status);
          nfp$format_message_to_job_log (nam_status);
        IFEND;
{}
{     Try to send back sensible message to initiating application
{}
        IF (nam_status.condition = nae$connection_terminated) OR
              (nam_status.condition = nae$server_response_timeout) OR
              (nam_status.condition = nae$application_max_conn_limit) THEN
          osp$set_status_abnormal (nfc$status_id, nfe$recoverable_connect, location, status);
        ELSE
          IF status.condition <> nfe$recoverable_connect THEN
            osp$set_status_abnormal (nfc$status_id, nfe$service_not_found, location, status);
          IFEND;
        IFEND;
      IFEND;
    IFEND;
{}
  PROCEND nfp$send_connect_request;
?? OLDTITLE ??
?? NEWTITLE := 'nfp$read_network_block', EJECT ??

{ PURPOSE:
{   This procedure is used to synchronously read a pdu from the network.
{   This procedure is a 'bridge' to service procedures specific to NAM
{   and LCN. This procedure makes a network read request to the access
{   method which a path is connected to.
{
{ NOTE:
{   A lot of checking is done for odd NAM events.

  PROCEDURE nfp$read_network_block
    (    application: nft$application_values;
         path: amt$file_identifier;
         network: nft$network_type;
         timeout: nft$parameter_20_range;
         protocol_trace: boolean;
     VAR input_buffer: string ( * <= nfc$command_buffer_size);
     VAR input_length: nft$command_pdu_size;
     VAR status: ost$status);

    VAR
      activity_status: ost$activity_status,
      end_of_message: boolean,
      ignore_status: ost$status,
      lcn_data_area: rft$data_buffers,
      lcn_data_received: rft$bytes_transferred,
      nam_data_area: array [1 .. 1] of nat$data_fragment,
      network_event: nat$se_peer_operation,
      rhfam_event: rft$connection_events,
      rhfam_wait_time: rft$connection_timeout,
      synchronize_data: SEQ (REP 1 of cell);

    status.normal := TRUE;
    CASE network OF

    = nfc$network_nam =
      nap$await_data_available (path, { File id }
      timeout * nfc$milliseconds, { Time limit }
      0, { Expected time }
      status);
      IF NOT status.normal THEN
        IF status.condition = nae$no_data_available THEN
          osp$set_status_condition ( nfe$application_time_out,  status);
        IFEND;
        RETURN;
      IFEND;
      nam_data_area [1].address := ^input_buffer;
      nam_data_area [1].length := STRLENGTH (input_buffer);
      nap$se_receive_data (path, nam_data_area, osc$wait, network_event, activity_status, status);
      IF NOT status.normal THEN
        RETURN;
      ELSEIF (activity_status.complete) AND (NOT activity_status.status.normal) THEN
        status := activity_status.status;
        RETURN;
      ELSEIF (NOT activity_status.complete) THEN
        nfp$set_internal_error ('NFE$READ_NETWORK_BLOCK act_stat error', status);
        RETURN;
      IFEND;
      CASE network_event.kind OF
      = nac$se_send_data =

        IF (NOT network_event.end_of_message) OR (NOT network_event.qualified_data) THEN
          osp$set_status_condition ( nfe$protocol_anomaly,  status);
          RETURN;
        IFEND;
        input_length := network_event.data_length;

      = nac$se_synchronize =

        osp$set_status_condition ( nfe$protocol_anomaly,  status);
        RETURN;

      = nac$se_interrupt, nac$se_synchronize_confirm =

        osp$set_status_condition ( nfe$protocol_anomaly,  status);
        RETURN;

      ELSE
        osp$set_status_abnormal (nfc$status_id, nfe$illegal_event, 'NAP$SE_RECEIVE_DATA', status);
        RETURN;
      CASEND;

    = nfc$network_lcn =
      rhfam_event := rfc$input_available;
      rhfam_wait_time := nfc$p20_network_read_short_wait;
      rfp$await_rhfam_event (path, rhfam_event, rhfam_wait_time, status);
      IF NOT status.normal THEN
        IF status.condition = rfe$no_available_event THEN
          rhfam_wait_time := timeout * nfc$milliseconds -
                             nfc$p20_network_read_short_wait;
          IF rhfam_wait_time < 0 THEN
            nfp$set_internal_error('nfp$read_network_block minus timeout',
                    status);
             RETURN;
          ELSE
            rfp$await_rhfam_event (path, rhfam_event, rhfam_wait_time, status);
            IF NOT status.normal THEN
              IF status.condition = rfe$no_available_event THEN
                osp$set_status_condition ( nfe$application_time_out,  status);
              IFEND;
              RETURN;
            IFEND;
          IFEND;
        ELSE
          RETURN;
        IFEND;
      IFEND;
      PUSH lcn_data_area: [1 .. 1];
      lcn_data_area^ [1].address := ^input_buffer;
      lcn_data_area^ [1].length := STRLENGTH (input_buffer);
      rfp$receive_data (path, rfc$message_mode, lcn_data_area, osc$wait, activity_status, lcn_data_received,
            end_of_message, status);
      IF NOT status.normal THEN
        RETURN;
      ELSEIF (activity_status.complete) AND (NOT activity_status.status.normal) THEN
        status := activity_status.status;
        RETURN;
      ELSEIF (NOT activity_status.complete) THEN
        nfp$set_internal_error ('NFE$READ_NETWORK_BLOCK act_stat error', status);
        RETURN;
      ELSEIF (NOT end_of_message) THEN
        osp$set_status_condition ( nfe$protocol_anomaly,  status);
        RETURN;
      IFEND;
      input_length := lcn_data_received;
    ELSE
      nfp$set_internal_error ('nfp$read_network_block network case', status);
      pmp$exit (status);
    CASEND;

{     If trace commands

    IF protocol_trace AND status.normal THEN
      write_protocol_trace_to_log ('RECEIVE', application, input_buffer (1, input_length));
    IFEND;

  PROCEND nfp$read_network_block;
?? OLDTITLE ??
?? NEWTITLE := 'nfp$write_network_block', EJECT ??

{ PURPOSE:
{   This procedure is used to send a pdu to the network.  This routine
{   acts as a 'bridge' to service routines specific to NAM and LCN.
{
{ NOTE:
{   This procedure does NOT terminate the path if the write fails.

  PROCEDURE nfp$write_network_block
    (    application: nft$application_values;
         path: amt$file_identifier;
         network_type: nft$network_type;
         output_buffer: string ( * <= nfc$command_buffer_size);
         protocol_trace: boolean;
     VAR status: ost$status);

    VAR
      activity_status: ost$activity_status,
      buffer_length: integer,
      end_of_message: boolean,
      error_text: string (osc$max_string_size),
      error_text_length: 1 .. osc$max_string_size,
      lcn_data_area: rft$data_buffers,
      lcn_data_sent: rft$bytes_transferred,
      nam_data_area: array [1 .. 1] of nat$data_fragment,
      string_length: integer,
      terminate_status: ost$status;

    status.normal := TRUE;
    buffer_length := STRLENGTH (output_buffer);
    IF protocol_trace THEN
      write_protocol_trace_to_log ('SEND', application, output_buffer (1, buffer_length));
    IFEND;

    CASE network_type OF

    = nfc$network_nam =
      nam_data_area [1].length := buffer_length;
      nam_data_area [1].address := ^output_buffer;
      nap$se_send_data (path, { Path
      nam_data_area, { Data fragments
      TRUE, { End of message
      TRUE, { Qualified data
      osc$wait, { Wait
      activity_status, status);
    = nfc$network_lcn =
      PUSH lcn_data_area: [1 .. 1];
      lcn_data_area^ [1].length := buffer_length;
      lcn_data_area^ [1].address := ^output_buffer;
      rfp$send_data (path, { Path name
      rfc$message_mode, { Mode
      lcn_data_area, { Data fragments
      TRUE, { Always EOM
      osc$wait, { Wait
      activity_status, lcn_data_sent, status);
      IF (activity_status.complete AND
         (lcn_data_sent <> lcn_data_area^ [1].length)) THEN
        error_text (1, 57) := 'NFP$WRITE_NETWORK_BLOCK, lcn send length error, expected ';
        STRINGREP (error_text (57, * ), string_length, lcn_data_area^ [1].length);
        error_text_length := 57 + string_length;
        error_text (error_text_length, 6) := ' sent ';
        error_text_length := error_text_length + 6;
        STRINGREP (error_text (error_text_length, * ), string_length, lcn_data_sent);
        error_text_length := error_text_length + string_length;
        nfp$set_internal_error (error_text (1, error_text_length), status);
        RETURN;
      IFEND;
    ELSE
      nfp$set_internal_error ('nfp$write_network_block network case', status);
      pmp$exit (status);
    CASEND;
    IF (activity_status.complete) AND (NOT activity_status.status.normal) THEN
      status := activity_status.status;
    IFEND;

  PROCEND nfp$write_network_block;
?? OLDTITLE ??
?? NEWTITLE := 'write_protocol_trace_to_log', EJECT ??

{ PURPOSE:
{   This procedure will write the protocol trace to the User's job_log.
{
{ NOTE:
{   This procedure will blank out any user supplied remote host directives for PTF.

  PROCEDURE write_protocol_trace_to_log
    (    transmission_type: string ( * <= 7);
         application: nft$application_values;
         trace_buffer: string ( * <= nfc$command_buffer_size));

    VAR
      ignore_status: ost$status,
      integer_string: ost$string,
      number_parameters: clt$integer,
      parameter_info_position: ost$non_negative_integers,
      parameter_length: clt$integer,
      parameter_offset: ost$non_negative_integers,
      trace_buffer_length: integer,
      trace_buffer_param_position: ost$non_negative_integers,
      trace_string: string (nfc$trace_commands_width),
      trace_string_position: integer;

    trace_buffer_length := STRLENGTH (trace_buffer);
    pmp$log ('************************************************************', ignore_status);
    trace_string := '** ';
    trace_string_position := 4;
    trace_string (trace_string_position, *) := transmission_type;
    trace_string_position := trace_string_position + 8;

{ determine the protocol command

    IF (trace_buffer (nfc$pdu_command_pos, nfc$pdu_command_len) = nfc$command_rft) THEN
          trace_string (trace_string_position, *) := 'RFT';
    ELSEIF (trace_buffer (nfc$pdu_command_pos, nfc$pdu_command_len) = nfc$command_rpos) THEN
          trace_string (trace_string_position, *) := 'RPOS';
    ELSEIF (trace_buffer (nfc$pdu_command_pos, nfc$pdu_command_len) = nfc$command_rneg) THEN
          trace_string (trace_string_position, *) := 'RNEG';
    ELSEIF (trace_buffer (nfc$pdu_command_pos, nfc$pdu_command_len) = nfc$command_go) THEN
          trace_string (trace_string_position, *) := 'GO';
    ELSEIF (trace_buffer (nfc$pdu_command_pos, nfc$pdu_command_len) = nfc$command_stop) THEN
          trace_string (trace_string_position, *) := 'STOP';
    ELSEIF (trace_buffer (nfc$pdu_command_pos, nfc$pdu_command_len) = nfc$command_stopr) THEN
          trace_string (trace_string_position, *) := 'STOPR';
    ELSEIF (trace_buffer (nfc$pdu_command_pos, nfc$pdu_command_len) = nfc$command_etp) THEN
          trace_string (trace_string_position, *) := 'ETP';
    ELSEIF (trace_buffer (nfc$pdu_command_pos, nfc$pdu_command_len) = nfc$command_etpr) THEN
          trace_string (trace_string_position, *) := 'ETPR';
    ELSEIF (trace_buffer (nfc$pdu_command_pos, nfc$pdu_command_len) = nfc$command_fini) THEN
          trace_string (trace_string_position, *) := 'FINI';
    ELSE
          trace_string (trace_string_position, nfc$pdu_command_len) := trace_buffer (nfc$pdu_command_pos,
                nfc$pdu_command_len);
    IFEND;

    trace_string_position := trace_string_position + 5;
    trace_string (trace_string_position, *) := ' COMMAND with ';
    trace_string_position := trace_string_position + 14;
    trace_string (trace_string_position, nfc$pdu_nparams_len) := trace_buffer (nfc$pdu_nparams_pos,
          nfc$pdu_nparams_len);
    trace_string_position := trace_string_position + nfc$pdu_nparams_len;
    trace_string (trace_string_position, *) := ' PARAMETERs & length ';
    trace_string_position := trace_string_position + 21;

    clp$convert_integer_to_string (trace_buffer_length, 10, FALSE, integer_string, ignore_status);
    trace_string (trace_string_position, 7) := integer_string.value;
    pmp$log (trace_string, ignore_status);

    clp$convert_string_to_integer (trace_buffer (nfc$pdu_nparams_pos, nfc$pdu_nparams_len),
          number_parameters, ignore_status);
    IF number_parameters.value > 0 THEN
      pmp$log ('**-no-q-len--value------------------------------------------', ignore_status);
    IFEND;

    trace_buffer_param_position := nfc$pdu_header_size;
    WHILE trace_buffer_param_position  < trace_buffer_length DO

{   determine the protocol parameter

      trace_string := '** ';
      trace_string_position := 4;
      trace_string (trace_string_position, nfc$num_param_id_digits) := trace_buffer
            ((trace_buffer_param_position + nfc$param_id_pos), nfc$num_param_id_digits);
      trace_string_position := trace_string_position + nfc$num_param_id_digits + 1;

{   determine how the protocol parameter is selected, ignored, or modified

      trace_string (trace_string_position, nfc$num_param_qual_digits) := trace_buffer
            ((trace_buffer_param_position + nfc$param_qual_pos), nfc$num_param_qual_digits);
      trace_string_position := trace_string_position + nfc$num_param_qual_digits + 1;

{   determine the length of the protocol parameter

      trace_string (trace_string_position, nfc$num_param_size_digits) := trace_buffer
            ((trace_buffer_param_position + nfc$param_size_pos), nfc$num_param_size_digits);
      trace_string_position := trace_string_position + nfc$num_param_size_digits;
      trace_string (trace_string_position, 2) := ' :';
      trace_string_position := trace_string_position + 2;

{   determine the protocol parameter length

      clp$convert_string_to_integer (trace_buffer ((trace_buffer_param_position + nfc$param_size_pos),
            nfc$num_param_size_digits), parameter_length, ignore_status);

      IF (trace_buffer ((trace_buffer_param_position + nfc$param_id_pos), nfc$num_param_id_digits)
            = nfc$s_user_text_directive) AND ((application = nfc$application_ptf) OR (application =
            nfc$application_ptfs)) THEN
        trace_string (trace_string_position, *) := 'SECURED PARAMETER WILL NOT BE DISPLAYED';
        pmp$log (trace_string, ignore_status);
      ELSE
        parameter_offset := 0;
        parameter_info_position := trace_buffer_param_position + nfc$param_header_size + 1;
        WHILE parameter_offset < parameter_length.value DO
          IF (parameter_length.value - parameter_offset) < (nfc$trace_commands_width - trace_string_position
                 + 1) THEN
            trace_string (trace_string_position, *) := trace_buffer ((parameter_info_position +
                 parameter_offset), (parameter_length.value - parameter_offset));
            parameter_offset := parameter_length.value;
          ELSE
            trace_string (trace_string_position, *) := trace_buffer ((parameter_info_position +
                  parameter_offset), (nfc$trace_commands_width - trace_string_position + 1));
            parameter_offset := parameter_offset + nfc$trace_commands_width - trace_string_position + 1;
          IFEND;
          pmp$log (trace_string, ignore_status);
          trace_string_position := 1;
        WHILEND;
      IFEND;

      trace_buffer_param_position := trace_buffer_param_position + nfc$param_header_size +
           parameter_length.value;
    WHILEND;
    pmp$log ('************************************************************', ignore_status);
    pmp$log ('  ', ignore_status);
  PROCEND write_protocol_trace_to_log;

?? OLDTITLE ??
?? NEWTITLE := 'nfp$send_nam_connect_request', EJECT ??
{}

  PROCEDURE nfp$send_nam_connect_request
    (    network_file_name: fst$file_reference;
         initiator: nft$application_values;
         server: nft$application_values;
         remote_family: ost$name;
     VAR path: amt$file_identifier;
     VAR status: ost$status);

{                                                                             }
{ Procedure  nfp$send_nam_connect_request                                     }
{                                                                             }
{ Purpose This routine sends a connect request to a NAM node denoted          }
{            by a title.                                                      }
{                                                                             }
{ Description                                                                 }
{            This routine simply attempts to translate the remote title,      }
{            if successful it sends the                                       }
{            connect request.  If the connection is over NAM/VE and           }
{            to a system which does not support CDNA, the connection must     }
{            be gatewayed (not waylayed).  The mapping of a connect title     }
{            to whatever form of remote connect is done by CDCNET.  Here      }
{            is how it goes.  If user information is returned on the          }
{            title translation, we check the first byte (its VERSION) to see  }
{            if it implies gateway.  If so, the user data is mapped into      }
{            connection attributes.                                           }
{                                                                             }
{            User data version 1                Connect data version 1        }
{                                                                             }
{             --------------                     --------------               }
{     byte 1 | version = 1  |     |>     byte 1 | version = 2  |              }
{            |--------------|     | >            --------------               }
{     byte 2 | gateway type |  ------>   byte 2 |   key        |              }
{             --------------      | >    byte 3 |   field      |              }
{     byte 3 |    key       |     |>             --------------               }
{     byte 4 |    field     |                                                 }
{             --------------                                                  }
{                                                                             }
{                                                                             }
{ Input parameters                                                            }
{            Network_file_name           : Name of the network file           }
{            Initiator                   : Initiator application              }
{            Server                      : Server application                 }
{            Remote_family               : Unique part of remote title        }
{                                                                             }
{ Output parameters                                                           }
{            Path                        : File ID of successfull connect     }
{            Status                      : Output status -any from-           }
{                                               title translation             }
{                                               nap$request_connection        }
{                                                                             }
{ Algorithm                                                                   }
{            Nfp$translate_title                                              }
{            If success then                                                  }
{              Nap$request_connection                                         }
{            Ifend                                                            }
{                                                                             }
?? EJECT ??
{}


    TYPE
      gateway_connection_info = packed record
        version: 0 .. 255,
        key: string (2),
      recend;

{}
?? EJECT ??

    CONST
      nfc$nam_connect_non_cdna = 1,
      nfc$nam_connect_gateway = 2,
      nfc$connect_version_gateway = 1,
      nfc$minimum_size_gat_version_1 = 4,

      translation_wait_time = 0;

    VAR
      connection_attributes: ^nat$create_attributes,
      connection_protocol: nat$protocol,
      directory_data: ^nat$directory_data,
      directory_id: nat$directory_entry_identifier,
      gateway_connection_data: ^gateway_connection_info,
      get_title_status: ost$status,
      local_status: ost$status,
      network_address: nat$network_address,
      ready_index: integer,
      recurrent_search: boolean,
      search_id: nat$directory_search_identifier,
      title_pattern: ^nat$title_pattern,
      translation_attributes: ^nat$translation_attributes,
      user_info: ^string (nac$max_directory_data_length),
      wait_list: ^ost$i_wait_list;

    VAR
      nfv$nam_application_names: [XREF] nft$nam_application_names;

    BEGIN
      status.normal := TRUE;
      get_title_status.normal := TRUE;

      IF server <> nfc$application_ptfs THEN
        osp$set_status_abnormal (nfc$status_id, nfe$bts_internal_error,
              'Invalid application name given for NAM/VE connection_request.', status);
        RETURN;
      IFEND;

      PUSH title_pattern: [nfc$nam_title_prefix_length + osc$max_name_size];
      title_pattern^ (1, nfc$nam_title_prefix_length) := nfc$nam_ptfs_title_prefix;
      title_pattern^ (nfc$nam_title_prefix_length + 1, * ) := remote_family;

      recurrent_search := FALSE;
      nap$begin_directory_search (title_pattern^, nfc$nam_appl_name_ptf, recurrent_search, search_id, status);
      IF NOT status.normal THEN
        RETURN;
      IFEND;

      PUSH wait_list: [1 .. 2];
      wait_list^ [1].activity := nac$i_await_title_translation;
      wait_list^ [1].translation_request := search_id;
      wait_list^ [2].activity := osc$i_await_time;
      wait_list^ [2].milliseconds := 60 * nfc$milliseconds;

      osp$i_await_activity_completion (wait_list^, ready_index, status);
      IF NOT status.normal THEN
        nap$end_directory_search (search_id, local_status);
        RETURN;
      IFEND;

      IF wait_list^ [ready_index].activity = nac$i_await_title_translation THEN
        PUSH directory_data: [[REP nac$max_directory_data_length OF cell]];
        PUSH translation_attributes: [1 .. 1];
        translation_attributes^ [1].selector := nac$translation_data;
        translation_attributes^ [1].data := directory_data;

      /get_all_possible_titles/
        WHILE get_title_status.normal DO
          nap$get_title_translation (search_id, translation_wait_time, translation_attributes,
                network_address, get_title_status);
          IF get_title_status.normal THEN

{     Have a possible route, build call data }
            RESET directory_data;
            NEXT user_info IN directory_data;

            IF translation_attributes^ [1].data_length > 0 THEN
              IF $INTEGER (user_info^ (1, 1)) <> nfc$connect_version_gateway THEN
                osp$set_status_abnormal (nfc$status_id, nfe$incompatible_address_kind,
                      'user info version incorrect', status);
                nfp$format_message_to_job_log (status);
                RETURN;
              ELSE
                IF translation_attributes^ [1].data_length < nfc$minimum_size_gat_version_1 THEN
                  osp$set_status_abnormal (nfc$status_id, nfe$incompatible_address_kind,
                        'user info for version incorrect length', status);
                  nfp$format_message_to_job_log (status);
                  RETURN;
                ELSE
                  PUSH connection_attributes: [1 .. 1];
                  connection_attributes^ [1].kind := nac$connect_data;
                  PUSH connection_attributes^ [1].connect_data: [[REP 1 OF gateway_connection_info]];
                  RESET connection_attributes^ [1].connect_data;
                  NEXT gateway_connection_data IN connection_attributes^ [1].connect_data;
                  gateway_connection_data^.version := nfc$nam_connect_gateway;
                  gateway_connection_data^.key := user_info^ (3, 2);
                IFEND;
              IFEND;
            ELSE
              connection_attributes := NIL;
            IFEND;

            connection_protocol := nac$cdna_session;
            nap$request_connection (network_address, nfv$nam_application_names [initiator], network_file_name,
                  connection_protocol, connection_attributes, nfc$connection_timeout, status);
            IF status.normal THEN
              fsp$open_file (network_file_name, amc$record, NIL,
              { file attachment options }
              NIL, { default creation attributes }
              NIL, { mandated creation attributes }
              NIL, { attribute validation }
              NIL, { attribute override }
              path, status);
            IFEND;
            IF status.normal THEN
              EXIT /get_all_possible_titles/;
            IFEND;
          ELSE
            osp$set_status_abnormal (nfc$status_id, nfe$service_not_found, remote_family, status);
          IFEND;
        WHILEND /get_all_possible_titles/;
      ELSE {timer expired}
        osp$set_status_abnormal (nfc$status_id, nfe$service_not_found, remote_family, status);
      IFEND;

      nap$end_directory_search (search_id, local_status);

    END;

  PROCEND nfp$send_nam_connect_request;
?? OLDTITLE ??
?? NEWTITLE := '[XDCL] nfp$nam_request_connect', EJECT ??

  PROCEDURE [XDCL] nfp$nam_request_connect
    (    network_file_name: fst$file_reference;
         initiator: nft$application_values;
         server: nft$application_values;
         network_address: nat$network_address;
         application_version: 0..255;
         station_name: ost$name;
         device_name: ost$name;
     VAR path: amt$file_identifier;
     VAR status: ost$status);

    {
    { Procedure  nfp$send_nam_connect_request
    {
    { Purpose    This routine sends a connect request to a remote network
    {            address.  If the connect is accepted, the network file is
    {            opened for the requesting application.  NOTE:  This routine
    {            is XDCL'ed so that applications knowing the network address
    {            they want to connect to (i.e. BTF) can call here directly
    {            for connect purposes.
    {
    { Description
    {           This routine only works if the remote title has been correctly
    {           translated.  It simply calls nap$request_connection and
    {           fsp$open_file.
    {
    { Input parameters
    {           Network_file_name    : File name of path
    {           Initiator            : Initiator application value
    {           Server               : Server application value
    {           Network_address      : NAM network address
    {           Application_version  : Version of the application connect
    {           Station_name         : Name of the requested station
    {           Device_name          : Name of the requested device
    {
    { Output parameters
    {           Path                 : Returned file ID
    {           Status               : Return status
    {
    { Algorithm
    {           When connecting to BTFS, create connection data
    {           nap$request_connection
    {           If o.k., open network file
    {
?? EJECT ??
    TYPE
      btfs_connection_info = packed record
        application_version: 0 .. 255,
        station_name: ost$name,
        device_name: ost$name,
      recend;

    VAR
      connection_attributes: ^nat$create_attributes,
      connection_information: ^btfs_connection_info,
      connection_protocol: nat$protocol;

    VAR
      nfv$nam_application_names: [XREF] nft$nam_application_names;

    {}
    status.normal := TRUE;
    CASE initiator OF

    = nfc$application_btf =
      PUSH connection_attributes: [1..1];
      connection_attributes^[1].kind := nac$connect_data;
      PUSH connection_attributes^[1].connect_data: [[REP 1 of btfs_connection_info]];
      RESET connection_attributes^[1].connect_data;
      NEXT connection_information IN connection_attributes^[1].connect_data;
      connection_information^.application_version := application_version;
      connection_information^.station_name := station_name;
      connection_information^.device_name := device_name;

    ELSE
      nfp$set_internal_error ('nfp$nam_request_connect application case', status);
      pmp$exit (status);
    CASEND;

    connection_protocol := nac$cdna_session;
    nap$request_connection (network_address, nfv$nam_application_names [initiator], network_file_name,
          connection_protocol, connection_attributes, nfc$connection_timeout, status);
    IF status.normal THEN
      fsp$open_file (network_file_name, amc$record, NIL,
      { file attachment options }
      NIL, { default creation attributes }
      NIL, { mandated creation attributes }
      NIL, { attribute validation }
      NIL, { attribute override }
      path, status);
    IFEND;
    {}
  PROCEND nfp$nam_request_connect;
?? OLDTITLE ??
?? NEWTITLE := '[XDCL] nfp$terminate_path', EJECT ??

  PROCEDURE [XDCL] nfp$terminate_path
    (    application: nft$application_values;
         sign_off: boolean;
     VAR path: nft$network_connection;
     VAR status: ost$status);

    {
    { Procedure  nfp$terminate_path
    {
    { Purpose    This procedure is used to terminate the connection with the
    {            remote host.
    {
    { Description
    {            The routine method of terminating the connection is to
    {            close and return the network file.  If the connection was
    {            to LCN, the application is signed off.
    {
    { Input parameters
    {           Application    : The application type ( used for LCN sign off )
    {
    { Output parameters
    {            Status        : The close/return completion status.
    {            Path          : The network file data structure.
    {
    { Algorithm
    {            Close network file
    {            Return network file
    {            If LCN,
    {              Sign off application
    {              If error Then log to job log
    {
?? EJECT ??

    VAR
      ignore_status: ost$status;

    VAR
      nfv$lcn_application_names: [XREF] nft$lcn_application_names;

    {}
    status.normal := TRUE;
    fsp$close_file (path.network_file_id, status);
    amp$return (path.network_file^, status);

    CASE path.network_type OF

    = nfc$network_nam =
      ;
    = nfc$network_lcn =
      IF sign_off THEN
        rfp$application_sign_off (nfv$lcn_application_names [application], ignore_status);
      IFEND;
    ELSE
      nfp$set_internal_error ('nfp$terminate_path network case', status);
      RETURN;
    CASEND;
    path.path_connected := FALSE;
    {}
  PROCEND nfp$terminate_path;
?? OLDTITLE ??
?? NEWTITLE := 'nfp$send_lcn_connect_request', EJECT ??

  PROCEDURE nfp$send_lcn_connect_request
    (    server: nft$application_values;
         initiator: nft$application_values;
         remote_family: ost$name;
     VAR path: nft$network_connection;
     VAR status: ost$status);

{                                                                             }
{ Procedure  nfp$send_lcn_connect_request                                     }
{                                                                             }
{ Purpose    Attempt to establish a connection to a remote host via RHFAM.    }
{                                                                             }
{ Description                                                                 }
{            This routine checks with RHFAM for all possible paths.           }
{            If one or more are possible, each is tried until one succeeds    }
{            or all have failed.  Note: Because this routine attempts         }
{            connects in the order presented by RHFAM, RHFAM should return    }
{            the least used (currently) path such that connection leveling    }
{            occurs.  If RHFAM does not do this, this routine should be       }
{            changed to pick the path attempt order randomly.                 }
{                                                                             }
{ Input parameters                                                            }
{            Server        : Name of Remote server application                }
{            Initiator     : Name of Local client application                 }
{            Remote_family : Name of the remote host                          }
{                                                                             }
{ Output parameters                                                           }
{            Path          : Record containing path data                      }
{            Status        : Return status any from                           }
{                             rfp$find_available_service                      }
{                             rfp$sign_on                                     }
{                             rfp$request_connection                          }
{                             rfp$await_server_respose                        }
{                             fsp$open_file                                   }
{                                                                             }
{ Algorithm                                                                   }
{            Find possible service paths (rfp$find_available_service)         }
{            If any Then                                                      }
{              For index := 1 to number of service paths do                   }
{                Request connection path(index)                               }
{                if success exit                                              }
{              forend                                                         }
{              If not success, return                                         }
{            Wait for server response                                         }
{            If not success, return                                           }
{            Open connection file                                             }
{                                                                             }
?? EJECT ??
{}

    VAR
      application_connects: rft$application_connections,
      destination_host: rft$host_identifier,
      host_identifiers: rft$destination_hosts,
      ignore_status: ost$status,
      index: integer,
      number_of_hosts: rft$number_of_hosts,
      rhfam_connection_attributes: array [1..1] of rft$get_attribute,
      server_response: rft$server_response,
      wait_time: rft$connection_timeout;

    VAR
      nfv$lcn_application_names: [XREF] nft$lcn_application_names;


{}
    status.normal := TRUE;
    destination_host.host_identifier_kind := rfc$logical_identifier;
    destination_host.logical_identifier := remote_family;
    rfp$find_available_service (nfv$lcn_application_names [server], destination_host, host_identifiers,
          number_of_hosts, status);
    IF (NOT status.normal) THEN
      RETURN;
    IFEND;
{}
{     Application sign on
{}
    application_connects := 1; {** PTF Client only needs 1 **}
    rfp$application_sign_on (nfv$lcn_application_names [initiator], rfc$client,
    { Application kind
    application_connects, { How many connects at a time
    status);
    IF (NOT status.normal) AND (status.condition <> rfe$already_signed_on) THEN
      RETURN;
    IFEND;
{}
{     Request connection }
{}

  /connect_loop/
    FOR index := 1 TO number_of_hosts DO
      rfp$request_connection (nfv$lcn_application_names [initiator], nfv$lcn_application_names [server],
            host_identifiers [index], { Target host }
            path.network_file^, { File name }
            NIL, { File attributes }
            status); { Return status }
      IF status.normal THEN
        EXIT /connect_loop/;
      ELSE
        amp$return (path.network_file^, ignore_status);
      IFEND;
    FOREND /connect_loop/;
    IF status.normal THEN

{ Get the CONNECTION_TIMEOUT value specified on the DEFINE_LOCAL_HOST command.

      rhfam_connection_attributes [1].key := rfc$connection_timeout;
      rfp$get_attributes (path.network_file^, rhfam_connection_attributes, status);
      IF status.normal THEN
        wait_time := rhfam_connection_attributes[1].connection_timeout;
      ELSE
        wait_time := nfc$connection_timeout;
      IFEND;

{}
{     Wait for connection completion
{}
      rfp$await_server_response (path.network_file^, wait_time, server_response, status);
      IF status.normal THEN
        fsp$open_file (path.network_file^, amc$record, NIL,
        { file attachment options
        NIL, { default creation attributes
        NIL, { mandated creation attributes
        NIL, { attribute validation
        NIL, { attribute override
        path.network_file_id, { returned file id
        status);
        IF NOT status.normal THEN
          amp$return (path.network_file^, ignore_status);
        IFEND;
      ELSE
        amp$return (path.network_file^, ignore_status);
      IFEND;
    IFEND;
{}
{     If this baby didn't connect up, sign off and try NAM
{}
    IF NOT status.normal THEN
      rfp$application_sign_off (nfv$lcn_application_names [initiator], ignore_status);
    IFEND;
{}
  PROCEND nfp$send_lcn_connect_request;
?? OLDTITLE ??
?? NEWTITLE := '[XDCL] nfp$get_server_asynch_event', EJECT ??

  PROCEDURE [XDCL] nfp$get_server_asynch_event
    (    application: nft$application_values;
     VAR path: nft$network_connection;
     VAR lcn_boot: boolean;
     VAR nam_boot: boolean;
     VAR task_queue: nft$task_queue;
     VAR status: ost$status);

{
{ Procedure  nfp$get_server_asynch_event
{
{ Purpose    This routine returns a network event.  The events it may
{            return include NAM connection available, LCN connection
{            available, and all access methods turned off.  This routine
{            also senses tasks which terminate, though these
{            events are never returned to the caller.  Rather, if a task
{            terminates, this routine continues to search for connect
{            requests.
{
{
{ Description
{            This routine senses access methods availability.  If one is
{            turned off, we will poll looking for it to return.
{            This procedure should not return error unless something
{            really hideous happens.  Received connections are returned to
{            the calling procedure for processing.
{
{ Input parameters
{            Application          : Application type ordinal
{
{ Output parameters
{            Lcn_boot             : Flag if server for LCN
{            Nam_boot             : Flag if server for NAM
{            Number_of_tasks      : Number current tasks
{            Task_queue           : List of current tasks
{            Status               : Return status
{                                                                             }
{ Input/output parameters                                                     }
{            Control_block        : Application control block                 }
{
{ Algorithm
{            Build wait list
{            Wait for event
{            Case event of
{            =task complete= Clean up task list
{            =LCN commect= Get LCN connection
{            =NAM commect= Get NAM connection
{            Casend
{
?? EJECT ??
{}

    CONST
      nfc$am_polling_time = 60000; { One minute }

    TYPE
      known_events = (lcn_connect, nam_connect, task_termination, poll_access_method);

{}

    VAR
      client_name: rft$application_name,
      connection_received: boolean,
      current_task: ^nft$task_list,
      current_time: integer,
      ignore_status: ost$status,
      index: integer,
      max_lcn_ptfs_connections: rft$application_connections,
      max_nam_ptfs_connections: nat$number_of_connections,
      number_of_events: integer,
      ready_index: integer,
      source_host_name: rft$host_identifier,
      task_index: integer,
      wait_action_list: ^array [ * ] of known_events,
      wait_list: ^ost$i_wait_list;

    VAR
      last_nam_am_check: [STATIC] integer := 0;

    VAR
      last_lcn_am_check: [STATIC] integer := 0;

    VAR
      nfv$lcn_application_names: [XREF] nft$lcn_application_names;

    VAR
      nfv$nam_application_names: [XREF] nft$nam_application_names;

{}
    status.normal := TRUE;
    connection_received := FALSE;
{}
{     First check last time we checked for access method availability.
{     This is done so if one AM is down, and connections are coming in
{     regularily on the other, the off one is checked.  If this were not
{     done and say RHFAM was down, and a connection came in every
{     nfc$am_poll_time-1, the timed wait would never go to AM check.
{
    pmp$get_microsecond_clock (current_time, status);
    IF NOT status.normal THEN
      RETURN;
    IFEND;

    IF (NOT nam_boot) AND ((current_time - last_nam_am_check) > nfc$am_polling_time) THEN
      last_nam_am_check := current_time;
      max_nam_ptfs_connections := 0; {** Use all that are available **}
      nap$attach_server_application (nfv$nam_application_names [application], max_nam_ptfs_connections,
            status);
      IF status.normal OR ((NOT status.normal) AND (status.condition = nae$appl_already_attached)) THEN
        nam_boot := TRUE;
      IFEND;
    IFEND;

    IF (NOT lcn_boot) AND ((current_time - last_lcn_am_check) > nfc$am_polling_time) THEN
      last_lcn_am_check := current_time;
      max_lcn_ptfs_connections := 0; {** Use all that are available **}
      rfp$application_sign_on (nfv$lcn_application_names [application], rfc$server, max_lcn_ptfs_connections,
            status);
      IF status.normal OR ((NOT status.normal) AND (status.condition = rfe$already_signed_on)) THEN
        lcn_boot := TRUE;
      IFEND;
    IFEND;
{
{     MAIN loop, wait for incoming NAM or RHFAM connections, service task
{     termination, and poll for unavailable access methods.
{
    WHILE NOT connection_received DO
      number_of_events := 0;
      IF lcn_boot THEN
        number_of_events := number_of_events + 1;
      IFEND;
{}
      IF nam_boot THEN
        number_of_events := number_of_events + 1;
      IFEND;
{}
      IF ((NOT nam_boot) OR (NOT lcn_boot)) THEN
        number_of_events := number_of_events + 1;
      IFEND;
{}
      number_of_events := number_of_events + task_queue.number_of_tasks;
{}
      IF number_of_events < 1 THEN
        nfp$set_internal_error ('nfp$server_get_network_connect, no events', status);
        RETURN;
      IFEND;
      ALLOCATE wait_list: [1 .. number_of_events];
      ALLOCATE wait_action_list: [1 .. number_of_events];
      index := 1;
      IF lcn_boot THEN

        wait_list^ [index].activity := rfc$i_await_incoming_connect;
        wait_list^ [index].application_name := nfv$lcn_application_names [application];
        wait_action_list^ [index] := lcn_connect;
        index := index + 1;

      IFEND;
      IF nam_boot THEN
        wait_list^ [index].activity := nac$i_await_connection;
        wait_list^ [index].server := nfv$nam_application_names [application];
        wait_action_list^ [index] := nam_connect;
        index := index + 1;
      IFEND;
{}
      IF ((NOT nam_boot) OR (NOT lcn_boot)) THEN
        wait_list^ [index].activity := osc$i_await_time;
        wait_list^ [index].milliseconds := nfc$am_polling_time;
        wait_action_list^ [index] := poll_access_method;
        index := index + 1;
      IFEND;

{}
      current_task := task_queue.head;
      FOR task_index := index TO (task_queue.number_of_tasks + index - 1) DO
        wait_list^ [task_index].activity := pmc$i_await_task_termination;
        wait_list^ [task_index].task_id := current_task^.task_id;
        wait_action_list^ [task_index] := task_termination;
        current_task := current_task^.forward_pointer;
      FOREND;
{}
      osp$i_await_activity_completion (wait_list^, ready_index, status);
      IF NOT status.normal THEN
        nfp$format_message_to_job_log (status);
        IF (ready_index < 1) OR (ready_index > number_of_events) THEN
{            Ready index not valid, take down both networks }
          rfp$application_sign_off (nfv$lcn_application_names [application], ignore_status);
          lcn_boot := FALSE;
          nap$detach_server_application (nfv$nam_application_names [application], ignore_status);
          nam_boot := FALSE;
        ELSE { Ready index valid }
          CASE wait_action_list^ [ready_index] OF
          = lcn_connect =
            rfp$application_sign_off (nfv$lcn_application_names [application], ignore_status);
            lcn_boot := FALSE;
          = nam_connect =
            nap$detach_server_application (nfv$nam_application_names [application], ignore_status);
            nam_boot := FALSE;
          ELSE { Wait on non-network event }
            RETURN;
          CASEND;
        IFEND;
      IFEND;
{}
      CASE wait_action_list^ [ready_index] OF
      = lcn_connect =
        rfp$acquire_connect_request (nfv$lcn_application_names [application], path.network_file^, NIL,
              nfc$connection_timeout, client_name, source_host_name, status);
        IF NOT status.normal THEN
          IF NOT (status.condition = rfe$connection_not_available) THEN
            lcn_boot := FALSE;
            rfp$application_sign_off (nfv$lcn_application_names [application], ignore_status);
            nfp$format_message_to_job_log (status);
          IFEND;
        ELSE
          rfp$accept_connect_request (path.network_file^, status);
          IF NOT status.normal THEN
            amp$return (path.network_file^, ignore_status);
          ELSE
            path.path_connected := TRUE;
            path.network_type := nfc$network_lcn;
            connection_received := TRUE;
          IFEND;
        IFEND;
      = nam_connect =
        nap$acquire_connection (nfv$nam_application_names [application], path.network_file^, NIL,
              nfc$connection_timeout, status);
        IF (NOT status.normal) THEN
          IF NOT ((status.condition = nae$no_connection_available) OR
                (status.condition = nae$max_connections_acquired)) THEN
            nam_boot := FALSE;
            nap$detach_server_application (nfv$nam_application_names [application], ignore_status);
          IFEND;
        ELSE
          nap$accept_connection (path.network_file^, status);
          IF NOT status.normal THEN
            amp$return (path.network_file^, ignore_status);
            IF status.condition <> nae$connection_terminated THEN
              nap$detach_server_application (nfv$nam_application_names [application], ignore_status);
              nam_boot := FALSE;
            IFEND;
          ELSE
            path.path_connected := TRUE;
            path.network_type := nfc$network_nam;
            connection_received := TRUE;
          IFEND;
        IFEND;

      = task_termination =
        nfp$dequeue_task (wait_list^ [ready_index].task_id, task_queue, status);
        IF NOT status.normal THEN
          RETURN;
        IFEND;
      = poll_access_method =
        IF NOT nam_boot THEN
          nap$attach_server_application (nfv$nam_application_names [application], max_nam_ptfs_connections,
                status);
          IF status.normal OR ((NOT status.normal) AND (status.condition = nae$appl_already_attached)) THEN
            nam_boot := TRUE;
          IFEND;
        IFEND;
        IF NOT lcn_boot THEN
          max_lcn_ptfs_connections := 0; {** Use all that are available **}
          rfp$application_sign_on (nfv$lcn_application_names [application], rfc$server,
                max_lcn_ptfs_connections, status);
          IF status.normal OR ((NOT status.normal) AND (status.condition = rfe$already_signed_on)) THEN
            lcn_boot := TRUE;
          IFEND;
        IFEND;
      ELSE
        nfp$set_internal_error ('nfp$server_get_network_connect wait case', status);
        RETURN;
      CASEND;
      FREE wait_list;
      FREE wait_action_list;
    WHILEND;
{}
  PROCEND nfp$get_server_asynch_event;
?? OLDTITLE ??
?? NEWTITLE := '[XDCL] nfp$enqueue_task', EJECT ??

  PROCEDURE [XDCL] nfp$enqueue_task
    (    task_id: pmt$task_id;
         path: nft$network_connection;
     VAR task_queue: nft$task_queue);

{
{ Procedure nfp$enqueue_task
{
{ Purpose    This procedure places a task ID (with some network info) on a
{            list.
{
{ Description
{            The new task is lined at the end of the task list.
{
{ Input parameters
{            task_id              : ID of task to link
{            path                 : Network information
{
{ Output parameters
{            task_queue           : List head of task queue
{
{ Algorithm
{            Allocate new element
{            If no tasks on list then
{              put at head of list
{            else
{              place at tail of list
{            ifend
{
?? EJECT ??

    VAR
      new_element: ^nft$task_list,
      old_element: ^nft$task_list,
      status: ost$status;

{}
    ALLOCATE new_element;
    IF new_element = NIL THEN
      nfp$set_internal_error ('nfp$enqueue_task no vm', status);
      pmp$exit (status);
    IFEND;
    task_queue.number_of_tasks := task_queue.number_of_tasks + 1;
    new_element^.task_id := task_id;
    new_element^.path := path;
    new_element^.forward_pointer := NIL;
    IF task_queue.head = NIL THEN
      task_queue.head := new_element;
      task_queue.tail := new_element;
      new_element^.backward_pointer := NIL;
    ELSE
      old_element := task_queue.tail;
      task_queue.tail^.forward_pointer := new_element;
      task_queue.tail := new_element;
      new_element^.backward_pointer := old_element;
    IFEND;
{}
  PROCEND nfp$enqueue_task;
?? OLDTITLE ??
?? NEWTITLE := 'nfp$dequeue_task', EJECT ??

  PROCEDURE nfp$dequeue_task
    (    task_id: pmt$task_id;
     VAR task_queue: nft$task_queue;
     VAR status: ost$status);

{
{ Procedure nfp$dequeue_task
{
{ Purpose    This procedure removes a task from
{            the task list.
{
{ Description
{            The task list is searched to find the element in question.
{            If its is not found, this is a major disaster.
{
{ Input parameters
{            task_id       : Identifier of the task in question
{
{ Output parameters
{            task_queue    : List of tasks
{
{ Algorithm
{            If task list is empty, error
{            for i = 1 to # of tasks
{              if task[i] is task in question then
{                dequeue task
{                update # of tasks
{              ifend
{            forend
{            if task was not found, error
{
?? EJECT ??

    VAR
      backward_link: ^nft$task_list,
      current_element: ^nft$task_list,
      done: boolean,
      forward_link: ^nft$task_list;

{}
    status.normal := TRUE;
    IF task_queue.head = NIL THEN
      osp$set_status_abnormal (nfc$status_id, nfe$bts_internal_error, 'NFP$DEQUEUE_TASK, no task(s) on list',
            status);
      RETURN;
    ELSE
      current_element := task_queue.head;
      done := FALSE;

    /task_search_loop/
      WHILE NOT done DO
        IF current_element^.task_id = task_id THEN
          done := TRUE;
          IF current_element^.forward_pointer = NIL THEN
            IF current_element^.backward_pointer = NIL THEN { Single element }
              task_queue.head := NIL;
              task_queue.tail := NIL;
              EXIT /task_search_loop/;
            ELSE { Last element }
              backward_link := current_element^.backward_pointer;
              backward_link^.forward_pointer := NIL;
              task_queue.tail := backward_link;
              EXIT /task_search_loop/;
            IFEND;
          ELSE
            IF current_element^.backward_pointer = NIL THEN { First on list }
              forward_link := current_element^.forward_pointer;
              forward_link^.backward_pointer := NIL;
              task_queue.head := forward_link;
            ELSE { Middle of list }
              forward_link := current_element^.forward_pointer;
              backward_link := current_element^.backward_pointer;
              forward_link^.backward_pointer := backward_link;
              backward_link^.forward_pointer := forward_link;
            IFEND;
          IFEND;
        ELSE
          current_element := current_element^.forward_pointer;
          IF current_element = NIL THEN
            osp$set_status_abnormal (nfc$status_id, nfe$bts_internal_error,
                  'NFP$DEQUEUE_TASK, task not found on list', status);
            RETURN;
          IFEND;
        IFEND;
      WHILEND /task_search_loop/;
      task_queue.number_of_tasks := task_queue.number_of_tasks - 1;
      FREE current_element;
    IFEND;
{}
  PROCEND nfp$dequeue_task;
?? OLDTITLE ??
?? NEWTITLE := '[XDCL] nfp$initialize_control_block', EJECT ??

{ PURPOSE:
{   This procedure will initialize the control block structure for a given application.

  PROCEDURE [XDCL] nfp$initialize_control_block
    (    application: nft$application_values;
         data_declaration: nft$parameter_31_type;
         requested_facilities: nft$parameter_03_value_set;
         required_facilities: nft$parameter_03_value_set;
         allowed_facilities: nft$parameter_03_value_set;
         initial_protocol: nft$parameter_00_values;
         mode_of_access: nft$mode_of_access;
         parameter_rules: ^nft$parameter_rules_array;
     VAR control_block: nft$control_block);

*copy nfv$protocol_trace_info

    VAR
      locate_string: ost$string,
      protocol_trace: boolean,
      status: ost$status,
      string_variable: ^ ost$string,
      trace_variable: clt$variable_reference;

?? NEWTITLE := 'scan_trace_variable', EJECT ??
  FUNCTION scan_trace_variable
    (      locate_string: ost$string;
           search_string: ost$string): boolean;

    VAR
      found_correct_string: boolean,
      index: integer,
      ptr_translated_locate_string: ^ string(*),
      ptr_translated_search_string: ^ string(*);

    found_correct_string := FALSE;

    IF (search_string.size > 0) AND (locate_string.size > 0) AND
       (search_string.size >= locate_string.size) THEN

      ALLOCATE ptr_translated_locate_string: [locate_string.size];
      ALLOCATE ptr_translated_search_string: [search_string.size];

      IF (ptr_translated_locate_string <> NIL) AND (ptr_translated_search_string <> NIL) THEN

        #translate(osv$lower_to_upper, locate_string.value (1, locate_string.size),
           ptr_translated_locate_string^);
        #translate(osv$lower_to_upper, search_string.value (1, search_string.size),
           ptr_translated_search_string^);
        index := 1;

        REPEAT
          IF ptr_translated_search_string^ (index, locate_string.size) = ptr_translated_locate_string^ THEN
            IF (index+locate_string.size) <= search_string.size THEN
              IF ($INTEGER(ptr_translated_search_string^ ((index+locate_string.size), 1)) < $INTEGER('A'))
              OR ($INTEGER(ptr_translated_search_string^ ((index+locate_string.size), 1)) > $INTEGER('Z'))
              THEN
                found_correct_string := TRUE;
              IFEND;
            ELSEIF (index+locate_string.size-1) = search_string.size THEN
              found_correct_string := TRUE;
            IFEND;
          IFEND;
          index := index + 1;
        UNTIL found_correct_string OR (index > (search_string.size-locate_string.size+1));
      IFEND;

      IF ptr_translated_locate_string <> NIL THEN
        FREE ptr_translated_locate_string;
      IFEND;

      IF ptr_translated_search_string <> NIL THEN
        FREE ptr_translated_search_string;
      IFEND;
    IFEND;

    scan_trace_variable := found_correct_string;
  FUNCEND scan_trace_variable;
?? OLDTITLE, EJECT ??
    control_block.application := application;
    CASE application OF
    = nfc$application_ptf =
      control_block.application_server := nfc$application_ptfs;
    = nfc$application_qtf =
      control_block.application_server := nfc$application_qtfs;
    = nfc$application_btf =
      control_block.application_server := nfc$application_btfs;
    ELSE
      { Is server
    CASEND;
    pmp$get_job_names (control_block.user_job_name, control_block.system_job_name, status);
    IF NOT status.normal THEN
      pmp$exit (status);
    ELSE
      IF STRLENGTH(control_block.system_job_name) <=
         STRLENGTH(control_block.send_job_name.value) THEN
        control_block.send_job_name.size := STRLENGTH(control_block.system_job_name);
        control_block.send_job_name.value := control_block.system_job_name;
      IFEND;
    IFEND;

    clp$read_variable ('NFV$RHF_PROTOCOL_TRACE', trace_variable, status);
    IF status.normal AND (trace_variable.value.kind = clc$string_value) THEN
      string_variable := #LOC(trace_variable.value.string_value^);
      locate_string.value := 'ALL';
      locate_string.size := 3;
      protocol_trace := scan_trace_variable(locate_string, string_variable^);
      IF NOT protocol_trace THEN
        protocol_trace := scan_trace_variable(nfv$protocol_trace_info [application] .application_name,
          string_variable^);
        IF NOT protocol_trace THEN
          protocol_trace := scan_trace_variable(nfv$protocol_trace_info [application] .
            appl_client_or_server_name, string_variable^);
        IFEND;
      IFEND;
      control_block.protocol_trace := protocol_trace;
    ELSE
      control_block.protocol_trace := FALSE;
      status.normal := TRUE;
    IFEND;

    control_block.last_command_sent := nfc$unknown_command;
    control_block.last_command_received := nfc$unknown_command;
    control_block.last_auto_modify_ignore := $nft$parameter_set [];
    control_block.data_xfer_complete := FALSE;
    control_block.file_name := '';
    control_block.protocol_in_use := initial_protocol;
    control_block.maximum_file_size := nfc$p06_unlimited_value;
    control_block.file_size := nfc$p06_unlimited_value;
    control_block.send_facilities := requested_facilities;
    control_block.received_facilities := $nft$parameter_03_value_set [];
    control_block.required_facilities := required_facilities;
    control_block.allowed_facilities := allowed_facilities;
    control_block.transfer_facilities := requested_facilities;
    control_block.send_directives := NIL;
    control_block.received_directives.head := NIL;
    control_block.received_directives.tail := NIL;
    control_block.send_operator_messages := NIL;
    control_block.received_operator_messages.head := NIL;
    control_block.received_operator_messages.tail := NIL;
    control_block.send_user_messages := NIL;
    control_block.received_user_messages.head := NIL;
    control_block.received_user_messages.tail := NIL;
    control_block.send_account_messages := NIL;
    control_block.received_account_messages.head := NIL;
    control_block.received_account_messages.tail := NIL;
    control_block.send_errorlog_messages := NIL;
    control_block.received_errorlog_messages.head := NIL;
    control_block.received_errorlog_messages.tail := NIL;
    control_block.data_block_size := nfc$p12_max_value;
    control_block.accounting_limit := nfc$p13_default_value;
    control_block.acknowledgment_window := nfc$p18_default_value;
    control_block.initial_restart_checkmark := nfc$p19_default_value;
    control_block.time_out := nfc$p20_network_default;
    control_block.mode_of_access := mode_of_access;
    control_block.mode_of_access_option := nfc$p21_non_specific;
    control_block.local_host_type := nfc$p22_nos_ve;
    control_block.remote_host_type := nfc$p22_unknown_host;
    control_block.requested_host_type := nfc$p22_unknown_host;
    control_block.expected_host_type := nfc$p22_unknown_host;
    control_block.source_lid.size := nfc$p24_min_param_size;
    control_block.source_lid.value := '*';
    control_block.transfer_lid := '*';
    control_block.transfer_lid_length := nfc$p25_min_param_size;
    control_block.transfer_pid := '*';
    control_block.transfer_pid_length := nfc$p27_min_param_size;
    control_block.send_echo_text.first_text := NIL;
    control_block.send_echo_text.last_text := NIL;
    control_block.received_echo_text.first_text := NIL;
    control_block.received_echo_text.last_text := NIL;
    control_block.data_declaration := data_declaration;
    control_block.receive_job_name.size := 0;
    control_block.receive_file_name.size := 0;
    control_block.negotiate_protocol := FALSE;
    control_block.parameter_rules := parameter_rules;
    control_block.network_buffer_list.head := NIL;
    control_block.network_buffer_list.tail := NIL;
    control_block.path.network_file := NIL;
    control_block.path.path_connected := FALSE;
    control_block.path.application_sequence_number := 0;
    control_block.retry_count := 0;
    control_block.retry_limit := 0;
    control_block.retry_milliseconds := 0;
    control_block.state_of_transfer.normal := TRUE;
    control_block.remote_status.normal := TRUE;
    control_block.local_status.normal := TRUE;

    CASE application OF
    = nfc$application_ptf, nfc$application_ptfs =
      control_block.remote_ring.specified := FALSE;
      control_block.recovery_text := FALSE;
      control_block.transfer_file_size := 0;
      control_block.transfer_directives_length := 0;
      control_block.ptf_scl_directive.size := 0;
    = nfc$application_qtf, nfc$application_qtfs =
    = nfc$application_btf, nfc$application_btfs =
      control_block.user_file_name.size := 0;
      control_block.user_file_name.value := '';
      control_block.banner_date_and_time.size := 0;
      control_block.banner_date_and_time.value := '';
      control_block.banner_routing_text.size := 0;
      control_block.banner_routing_text.value := '';
      control_block.user_banner_message.size := 0;
      control_block.user_banner_message.value := '';
      control_block.installation_banner_message.size := 0;
      control_block.installation_banner_message.value := '';
      control_block.reposition_output_file.size := 0;
      control_block.reposition_output_file.value := '';
      control_block.current_file_position.size := 0;
      control_block.current_file_position.value := '';
      control_block.default_output_file_destination.size := 0;
      control_block.default_output_file_destination.value := '';
    ELSE
      nfp$set_internal_error ('nfp$initialize_control_block application case', status);
      pmp$exit (status);
    CASEND;

  PROCEND nfp$initialize_control_block;
?? OLDTITLE ??
MODEND nfm$rhf_protocol_engine;
