/* */
parse arg cookie

cookie = strip(cookie)
valid = 'SNDIFENTRIES'

/* This is an installation command file and should NOT be run by the user,
 * skip if the installation parm has not been specified
 */
if cookie = valid then
do
  call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
  call SysLoadFuncs
  windir = SysIni( ,"PM_INSTALL","WINOS2_LOCATION")
  if windir <> "" then
  do
    if datatype(right(windir,1),'a') = 0  then windir = left(windir,length(windir)-1)
    tmpfile = CreateTempFile(windir)
    update = 0
    winfile = windir'\win.ini'
    do while lines(winfile)
      line = linein(winfile)
      if strip(line) = '[Netscape]' then
      do
        /* Found keyword, next line = "ini=d:\path\netscape.ini" */
        line = strip(linein(winfile))
        if stream(substr(line,5), 'c', 'query size') < 400 then
          do
          /* File seems to have been installed by the PIP, bag it, and
           * skip this line, too
           */
          '@del' substr(line,5)
          line = linein(winfile)
          update = 1                            /* Need to update the ini */
          end
      end
      call lineout tmpfile, line
    end
    call stream tmpfile, 'c', 'close'
    call stream winfile, 'c', 'close'
    if update = 1 then
      do
      bbucket = '>NUL:'
      '@copy' winfile windir'\win.ppo' bbucket  /* Back up the existing win.ini */
      '@copy' tmpfile winfile bbucket           /* Copy the temp file to win.ii */
      '@del' tmpfile bbucket
      end
  end
end

exit 0

CreateTempFile:  procedure
  arg wfile
  i = 0
  tmp = wfile'\wtf'ntoascii(i,5)
  do while stream(tmp,'c','query exists') <> ''
    i = i + 1
    tmp = wfile'\wtf'ntoascii(i,5)
  end
  return tmp



/* Convert the decimal value i to an l character string with leading (ASCII) '0's */
ntoascii: arg i, l
  x = right(  d2c(i+48), l, '0' )
  return x
