PROCEDURE convert_network_configuration (
  source_file, sf: file =  $system.network.configuration
  destination_file, df: file = $system.network.configuration.$next
  host_name, hn: string = $optional
  forward_search_range, fsr: integer = 4
  status)

  UTILITY convert_network_configuration
    command (define_channel_network, defcn) nap$define_channel_network
    command (define_host_network, defhn) nap$define_host_network
    command (define_network_connection, defnc) nap$define_network_connection
    command (define_network_access, defna) nap$define_network_access
    command (define_tcpip_host, defth) nap$define_tcpip_host
    command (quit, qui, end) nap$quit
    tablend

    "$FORMAT=OFF"
    VAR
      invalid_count : (utility) integer = 0
      invalid_list : (utility) array 1 .. 20  of string
      local_status : (utility)  status
      tcpip_host_defined : (utility) boolean = FALSE
      temp_file : (utility) file =  $unique($local)
    VAREND
    "$FORMAT=ON"

    WHEN exit DO
      delete_file temp_file status=local_status
      detach_file source_file status=local_status
    WHENEND

    attach_file file=source_file status=local_status
    IF NOT local_status.normal THEN
      EXIT procedure WITH local_status
    IFEND

    rewind_file file=source_file status=local_status
    IF NOT local_status.normal THEN
      EXIT procedure WITH local_status
    IFEND

    put_line ' Converting '//$string(source_file)//' to new format...' o=$response

    include_file source_file u=convert_network_configuration status=local_status
    IF NOT local_status.normal THEN
      EXIT procedure WITH local_status
    IFEND

    IF (NOT tcpip_host_defined) AND $specified(host_name) THEN
      put_line line=(' define_tcpip_host host_name='''//host_name//''' forward_search_range='//forward_search_range) ..
        o=temp_file.$eoi
    IFEND

    put_line ' Conversion complete.' o=$response

    IF invalid_count <> 0 THEN
      put_line ' Some network configuration commands could not be converted.'  o=$response
      put_line ' See the list at the end of the '//$string(destination_file)//' file' o=$response
      put_line ' for more details.'  o=$response

      put_line ' "' o=temp_file.$eoi
      put_line ' "   With the 1.5.1 NOS/VE release, ICA-I''s and ICA-II''s (running' o=temp_file.$eoi
      put_line ' "   in native mode) are not allowed.  If you wish to use  ICA-II''s in' o=temp_file.$eoi
      put_line ' "   OSI mode, they must be converted by hand. ' o=temp_file.$eoi
      put_line ' "' o=temp_file.$eoi
      put_line ' "   The following definitions must be converted by hand if they are to be used:' ..
            o=temp_file.$eoi

      FOR index = 1 TO invalid_count DO
        put_line ' "  '//invalid_list(index) o=temp_file.$eoi status=local_status
        IF NOT local_status.normal THEN
          EXIT procedure WITH local_status
        IFEND
      FOREND
    IFEND

    copf temp_file destination_file status=local_status
    IF NOT local_status.normal THEN
      EXIT procedure WITH local_status
    IFEND

    delete_file temp_file status=local_status
    detach_file source_file status=local_status

    include_command 'NAP$QUIT' ee=false

  UTILITYEND

PROCEND convert_network_configuration


PROCEDURE (HIDDEN) nap$define_channel_network (
  network, n: integer 1..0FFFFFFFF(16) = $required
  connected_system, cs: name = $required
  relays_restricted, rr: boolean = FALSE
  )

  put_line ' define_network_connection connected_system='//connected_system o=temp_file.$eoi

PROCEND nap$define_channel_network


PROCEDURE (HIDDEN) nap$define_host_network (
  network, n: integer 1..0FFFF(16) = $required
  )

  put_line ' define_host_network network=0'//$strrep(network, 16)//'(16)'    o=temp_file.$eoi

PROCEND nap$define_host_network


PROCEDURE (HIDDEN) nap$define_network_access (
  network, n: integer 1..0FFFF(16) = $required
  access, a: list of name = $required
  relays_restricted, rr: boolean = FALSE
  )

  invalid_count = invalid_count + 1
  invalid_list(invalid_count) = 'define_network_access network='//..
$strrep(network, 16)//'(16)  access='//access//' relays_restricted='//relays_restricted

PROCEND nap$define_network_access


PROCEDURE (HIDDEN) nap$define_network_connection (
  network, n: integer 1..0FFFF(16) = $optional
  connected_system, cs: name = $required
  system_identifier, si: integer 400101(16)..4FFFFF(16) = $optional
  )

  IF $specified(system_identifier) THEN
    put_line ' define_network_connection connected_system='//connected_system//' system_identifier='//..
$strrep(system_identifier, 16)//'(16)'  o=temp_file.$eoi
  ELSE
    put_line ' define_network_connection connected_system='//connected_system o=temp_file.$eoi
  IFEND

PROCEND nap$define_network_connection

PROCEDURE (HIDDEN) nap$define_tcpip_host (
  host_name, hn: string  = $required
  forward_search_range, fsr: integer = 4
  )

  put_line line=(' define_tcpip_host host_name='''//host_name//''' forward_search_range='//forward_search_range) ..
    o=temp_file.$eoi
  tcpip_host_defined = TRUE

PROCEND nap$define_tcpip_host

PROCEDURE (HIDDEN) nap$quit

  EXIT convert_network_configuration

PROCEND nap$quit

