PROCEDURE rap$nqs_update_network_files (
  port_number, pn: integer = 607
  status)

  VAR
    ls:status
    service_definition: file = $unique($local)
    service_entry: string = 'nqs '//port_number//'/tcp'
  VAREND

  EDIT_FILE $system.tcp_ip.inetd_configuration output=$null prolog=$null
    locate_text 'nqs' 1 all word=on upper_case=yes status=ls
    IF ls.normal THEN
      put_line ' A service definition already exist in the INETD configuration file for NQS.'
      EXIT PROCEDURE
    IFEND

COLLECT_TEXT service_definition sm='!'

 "INETD configuration file entry for the NQS server.

   define_service ..
     service=nqs ..
     application_name=OSA$NQS_SERVER ..
     debug_mode=OFF ..
     debug_mode_interactive=off ..
     initial_state=active ..
     port=!port_number! ..
     protocol=TCP ..
     service_task=$system.nqs.nqf$system_666 ..
     starting_procedure=nqp$nqs_server
**

    read_file f=service_definition insertion_location=last
    detach_file service_definition status=ls

  QUIT yes

  put_line ' An entry for the NQS server was added to the INETD configuration file.'

  EDIT_FILE $system.tcp_ip.services output=$null prolog=$null
    locate_text 'nqs' 1 all word=on upper_case=yes status=ls
    IF ls.normal THEN
      replace_line nt=service_entry lines=c
    ELSE
      insert_line service_entry insertion_location=last placement=after
    IFEND
  QUIT yes

  put_line ' The NQS service was defined as port '//port_number//'.'

PROCEND rap$nqs_update_network_files
