home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1993 #2 / Image.iso / lan / 21ripl.zip / IBMLS.ZIP / RPLSETD.CMD < prev    next >
OS/2 REXX Batch file  |  1993-05-28  |  54KB  |  1,576 lines

  1. /*****************************************************************************/
  2. /* RPLSETD.CMD - REXX program to convert an existing OS/2 Remote IPL client  */
  3. /*               to use the 32-bit VGA, XGA, and 8514 device drivers.        */
  4. /*                                                                           */
  5. /*    Copyright: (C) Copyright IBM Corp. 1993                                */
  6. /*                                                                           */
  7. /*    External rexx procedures used: RPLUCC20.CMD                            */
  8. /*                                   RPLUCFIT.CMD                            */
  9. /*                                   RPLSDMSG.CMD                            */
  10. /*                                                                           */
  11. /*    External EXE file used: RPLRXUTL.EXE                                   */
  12. /*                                                                           */
  13. /*    Note 1: Most variables are global to all subroutines.                  */
  14. /*                                                                           */
  15. /*    Note 2: All NLS message strings are centrally located in the           */
  16. /*            external rexx procedure RPLSDMSG.CMD.                          */
  17. /*                                                                           */
  18. /*    Note 3: This procedure must also be compatable with OS/2 1.30.2.       */
  19. /*            For this reason, none of the OS/2 2.0 unique rexx function     */
  20. /*            calls can be used.                                             */
  21. /*                                                                           */
  22. /*****************************************************************************/
  23.  
  24. driver = ''
  25. client = ''
  26. Logfile = ''
  27. Rspfile = ''
  28. os2csdlevel = ''
  29. Bustype = ''
  30. swaptarget = ''
  31. lantype = ''
  32. inputcurOS2 = ''
  33. inputnewOS2 = ''
  34. defcurrentOS2 = ''
  35. defnewOS2 = 'OS2.21'
  36. currentOS2 = ''
  37. newOS2 = 'OS2.21'
  38. CRLF = '0A0D'X
  39. nulsufix = '1>nul 2>nul'
  40. ERROR_INFO_type = 1
  41. SYNTAX_type = 2
  42. changeOS2 = 0
  43. basedevflag = 1
  44. clientlist.0 = 0
  45. msgdata = ''
  46. syntaxhelpflag = 0
  47.  
  48. /* initialize NLS error and informational message strings */
  49. Call Initialize_NLS_Messages
  50.  
  51. Parse Arg  parm.1 parm.2 parm.3 parm.4 parm.5 parm.6 parm.7 parm.8 .
  52. /* Check for help request (parm.1 = ? or '') */
  53. If parm.1 = '?' | parm.1 = '' Then Call Syntax_Help
  54.  
  55. Call Process_Input_Parameters
  56. If result <> 0 Then Call Error_Exit
  57.  
  58. /* if logfile specified, delete old log file (if it exists) & log header */
  59. If Logfile <> '' Then Do
  60.    Call Delete_File Logfile
  61.    msgdata = 'RPLSETD ' || message.3 || Date('U')  Time()
  62.    Call Lineout Logfile, msgdata
  63.    If result <> 0 Then Do
  64.       Say message.4 || Logfile
  65.       exit 4
  66.    end
  67.    Call Lineout Logfile, ' '
  68. end
  69.  
  70. /* if necessary, verify existance of response file */
  71. If Rspfile <> '' Then Do
  72.    If File_Exist(Rspfile) = 0 Then Do
  73.       /* response file not found */
  74.       Call Display_Log_Msg   Rspfile || message.10, ''
  75.    end
  76. end
  77.  
  78. Call Determine_RIPL_Directory
  79. If result <> 0 Then Call Error_Exit
  80.  
  81. /* get LAN Server version */
  82. Call Get_LAN_Server_Version
  83. if result <> 0 Then Exit
  84.  
  85. /* build list of directories in RPL\IBMCOM to process */
  86. lanlist.0 = 6
  87. lanlist.1 = 'TOKENRNG'
  88. lanlist.2 = 'ETHERNET'
  89. lanlist.3 = 'PCNETA'
  90. lanlist.4 = 'PCNET'
  91. lanlist.5 = 'ELNKII'
  92. lanlist.6 = 'ELNKMC'
  93.  
  94. datainput = 1
  95. Do while datainput = 1
  96.    If Rspfile <> '' Then Do
  97.       Call Read_Rspfile
  98.       If result > 2 Then Do
  99.          msgdata = errprefix || message.1 Rspfile || CRLF || message.2
  100.          Call Display_Log_Msg msgdata, ''
  101.          Call Error_Exit
  102.       end
  103.       else If result = 2 Then Leave  /* no more input */
  104.    end
  105.    else datainput = 0  /* only process command line inputs */
  106.  
  107.    /* was required parameter entered? */
  108.    If clientlist.0 = 0 Then Do
  109.       Call Display_Log_Msg errprefix || message.30, ''
  110.       Call Error_Exit
  111.    end
  112.  
  113.    /* was at least one other parameter entered? */
  114.    If clientlist.0 <> 0 Then Do
  115.       If driver = '' & Bustype = '' & swaptarget = '' & inputnewOS2 = '' Then Do
  116.          Call Display_Log_Msg errprefix || message.31, ''
  117.          Call Error_Exit
  118.       end
  119.    end
  120.  
  121.    /* if currentOS2 entered, make sure newOS2 was also */
  122.    If inputcurOS2 <> '' Then Do
  123.       If inputnewOS2 = '' Then Do
  124.          Call Display_Log_Msg errprefix || message.26
  125.          Call Error_Exit
  126.       end
  127.    end
  128.  
  129.    If Bustype <> '' Then Do
  130.       Call Validate_Bustype
  131.       If result <> 0 Then Call Error_Exit
  132.    end
  133.  
  134.    If swaptarget <> '' Then Do
  135.       Call Validate_swaptarget
  136.       If result <> 0 Then Call Error_Exit
  137.    end
  138.  
  139.    /* If OS/2 2.1 is in RIPL tree, check to see if 2.1 migration has been run. */
  140.    If version21 = 1 & File_Exist(rpldir'\RPLMIG21.$$$') = 0 Then Do
  141.       msgdata = errprefix || message.23
  142.       Call Display_Log_Msg msgdata, ''
  143.       Call Error_Exit
  144.    end
  145.  
  146.    do clnum = 1 to clientlist.0
  147.       /* update each client in list */
  148.       client = clientlist.clnum
  149.  
  150.       /* verify client does exist by checking for FIT file */
  151.       If client <> 'DEFALT20' Then Do
  152.          If File_Exist(rpldir'\FITS\'client'.FIT') = 0 Then Do
  153.             Call Display_Log_Msg errprefix || client || message.24, ''
  154.             return 2
  155.          end
  156.       end
  157.  
  158.       /* get client bootdrive id and target OS */
  159.       Call get_client_bootdrv_target_OS(client)
  160.  
  161.       rcode = 0
  162.       /* check for DEFALT21 */
  163.       If client = 'DEFALT21' Then Do
  164.          Call Display_Log_Msg errprefix || message.36, ''
  165.          rcode = 4
  166.       end
  167.       else Do
  168.          /* if current OS not specified, use OS of client */
  169.          If currentOS2 = '' Then currentOS2 = clientOS2
  170.          else Do
  171.             /* current OS is specified, does it match OS of client */
  172.             If currentOS2 <> clientOS2 Then Do
  173.                /* does not match, display error */
  174.                msgdata = errprefix || message.33
  175.                Call Display_Log_Msg msgdata, currentOS2, clientOS2, client
  176.                rcode = 4
  177.             end
  178.          end
  179.       end
  180.  
  181.       If rcode = 0 Then Do
  182.          If currentOS2 = 'OS2' Then Do
  183.             /* 1.3.2 client, can not upgrade 1.3.2 clients */
  184.             Call Display_Log_Msg  errprefix || client || message.35, ''
  185.             rcode = 4
  186.          end
  187.          else Do
  188.             /* if new OS specified, check for attempt to downgrade from 2.1 */
  189.             If changeOS2 = 1 Then Do
  190.                If clientOS2 = 'OS2.21' & newOS2 <> 'OS2.21' Then Do
  191.                   /* downgrade from 2.1 is not allowed */
  192.                   msgdata = errprefix || client || message.32
  193.                   Call Display_Log_Msg msgdata, ''
  194.                   rcode = 4
  195.                end
  196.             end
  197.          end
  198.  
  199.          If rcode = 0 Then Do
  200.             /* get version of OS/2 in target OS/2 RIPL directory */
  201.             Call Get_RIPL_OS2_Version
  202.             if result = 0 Then Do
  203.                If driver <> '' Then Do
  204.                   /* validate driver ids */
  205.                   Call Validate_Display_DriverID
  206.                   If result <> 0 Then rcode = result
  207.                   else Do
  208.                      /* determine if desired device driver is installed */
  209.                      If changeOS2 = 1 Then ddpath = rpldir'\'newOS2'\OS2\DLL\'
  210.                      else  ddpath = rpldir'\'currentOS2'\OS2\DLL\'
  211.                      filename = ddpath||driver||'.DLL'
  212.                      if File_Exist(filename) = 0 Then Do
  213.                         ddpath = substr(ddpath, 1, length(ddpath) - 1)
  214.                         msgdata = errprefix || message.5
  215.                         Call Display_Log_Msg msgdata, driver, ddpath
  216.                         rcode = 4
  217.                      end
  218.                   end
  219.                end
  220.                If rcode = 0 Then Do
  221.                   /* all inputs okay, update client files */
  222.                   If Rspfile <> '' Then Do
  223.                      /* display response file inputs */
  224.                      msgdata = '/C:'client ' /D:'driver  ' /O:'inputcurOS2  ' /N:'inputnewOS2,
  225.                                ' /B:'Bustype ' /S:'swaptarget
  226.                      Call Display_Log_Msg msgdata, ''
  227.                   end
  228.  
  229.                   Call Update_Client_Files
  230.                end
  231.             end
  232.          end
  233.       end
  234.    end
  235. end
  236.  
  237. If Logfile <> '' Then Call Lineout Logfile
  238. If Rspfile <> '' Then Call Lineout Rspfile
  239. exit
  240.  
  241. /* end of main routine */
  242.  
  243.  
  244. /*************** Start of subroutines ***************************/
  245.  
  246.  
  247. /* Subroutine Error_Exit */
  248. /* This subroutine cleans up on an error exit. */
  249. Error_Exit:
  250.    If Logfile <> '' Then Do
  251.       Call Lineout Logfile
  252.       Say message.7 || Logfile
  253.    end
  254.    If Rspfile <> '' Then Call Lineout Rspfile
  255.    exit 4
  256.  
  257.  
  258. /* Subroutine Get_LAN_Server_Version */
  259. /* This subroutine determines the version of LAN Server installed on  */
  260. /* the Remote IPL server. */
  261. Get_LAN_Server_Version:
  262.    /* Read the first 60 bytes of SYSLEVEL.SRV and check the current server level*/
  263.    filename = lanpath'\SYSLEVEL.SRV'
  264.    syslevel = ''
  265.    /* read syslevel file, try to get it with a single linein call */
  266.    syslevel = Linein(filename)
  267.    Call Lineout filename   /* close file */
  268.    If Length(syslevel) < 60 Then Do
  269.       /* single linein did not get enought of file, get syslevel */
  270.       /* character at a time */
  271.       syslevel = ''
  272.       Do i = 1 to 60
  273.          syslevel = syslevel || charin(filename)
  274.       end
  275.       Call Charout filename
  276.    end
  277.    verp = pos('IP', syslevel)
  278.    If verp <> 0 Then LS_version = substr(syslevel, verp+3, 4)
  279.    If LS_version = '' Then Do
  280.       msgdata = errprefix || message.8
  281.       Call Display_Log_Msg msgdata, ''
  282.       return 4
  283.    end
  284.    return 0
  285.  
  286.  
  287.  
  288. Get_RIPL_OS2_Version:
  289.    /* Read the first 60 bytes of RIPL SYSLEVEL.OS2 and get the current */
  290.    /* OS/2 CSD level and version id */
  291.    If changeOS2 = 1 Then spath = rpldir'\'newOS2
  292.    else  spath = rpldir'\'currentOS2
  293.    filename = spath'\OS2\INSTALL\SYSLEVEL.OS2'
  294.    syslevel = ''
  295.    If File_Exist(filename) = 1 Then Do
  296.       /* read syslevel file, try to get it with a single linein call */
  297.       syslevel = Linein(filename)
  298.       Call Lineout filename
  299.       If Length(syslevel) < 60 Then Do
  300.          /* single linein did not get enought of file, get syslevel */
  301.          /* character at a time */
  302.          Do i = 1 to 60
  303.             syslevel = syslevel || charin(filename)
  304.          end
  305.          Call Charout filename
  306.       end
  307.       verp = pos('XR', syslevel)
  308.    end
  309.    else verp = 0
  310.  
  311.    If verp <> 0 Then os2csdlevel = substr(syslevel, verp, 8)
  312.    else os2csdlevel = unknown
  313.    If os2csdlevel = unknown | substr(os2csdlevel, 4, 4) = '2000' Then Do
  314.       msgdata = errprefix || client || message.9
  315.       Call Display_Log_Msg msgdata, spath, os2csdlevel
  316.       return 4
  317.    end
  318.  
  319.    /* the following is to differentiate between 2.0+SP, 2.00.1, and 2.1 */
  320.    version21 = 0
  321.    If substr(os2csdlevel, 4, 4) = '6055' Then basedevflag = 1
  322.    else If substr(os2csdlevel, 4, 4) = '2010' & substr(syslevel, 41, 1) = '20'x,
  323.            Then basedevflag = 0
  324.         else Do
  325.            /* 2.1  or 2.0+SP2 (treat like 2.1) */
  326.            basedevflag = 1
  327.            version21 = 1
  328.         end
  329.    return 0
  330.  
  331.  
  332. /* subroutine to determine bootdrive id and target OS of client */
  333. get_client_bootdrv_target_OS:
  334.    parse arg clientname
  335.    If clientname = '' Then Do
  336.       /* no client passed, use first valid client in clientlist */
  337.       do clnum = 1 to clientlist.0
  338.          /* find first valid client in list */
  339.          clientname = clientlist.clnum
  340.          If clientname <> 'DEFALT20' Then Do
  341.             filename = rpldir'\FITS\'clientname'.FIT'
  342.             If File_Exist(filename) = 1 Then Leave
  343.          end
  344.       end
  345.    end
  346.  
  347.    clientOS2 = ''
  348.    filename = rpldir'\FITS\'clientname'.FIT'
  349.    If File_Exist(filename) = 1 Then Do
  350.       /* scan FIT looking for :\OS2 entry */
  351.       Do while lines(filename) <> 0
  352.          data = translate(Linein(filename))
  353.          dpos = pos(':\OS2 ', data)
  354.          If dpos <> 0 Then Do
  355.             /* get client bootdrive id */
  356.             clientbootdrv = substr(data, dpos-1, 1)
  357.  
  358.             /* extract target OS directory */
  359.             data = strip(substr(data, dpos+6))
  360.             dpos = pos('\', data)
  361.             If dpos <> 0 Then Do
  362.                clientOS2 = substr(data, 1, dpos-1);
  363.             end
  364.             else clientOS2 = data
  365.             Leave
  366.          end
  367.       end
  368.       Call Lineout filename  /* close file */
  369.    end
  370.    return
  371.  
  372.  
  373.  
  374.  
  375.  
  376. /* Subroutine Update_Client_Files */
  377. /* This subroutine calls the subroutines to update each client file. */
  378. Update_Client_Files:
  379.    result = 0
  380.    If driver <> '' Then Do
  381.       /* update the client copy of OS2INI.20 */
  382.       Call Update_Client_Ini
  383.       If result = 0 Then Do
  384.          msgdata = client || message.11
  385.          Call Display_Log_Msg msgdata, 'OS2INI.20'
  386.       end
  387.    end
  388.  
  389.    If result = 0 Then Do
  390.       If driver <> '' | Bustype <> '' | swaptarget <> '' Then Do
  391.          /* update the client CONFIG.20 file.  If the client is DEFALT20, */
  392.          /* then there is special processing to update each of the master */
  393.          /* CONFIG.20 files in the RPL\IBMCOM tree. */
  394.          if client = 'DEFALT20' Then Do
  395.             /* for DEFALT20 update each of the lantype CONFIG.20 and CONFIGRI.20 files */
  396.             Do lli = 1 to lanlist.0
  397.                lantype = lanlist.lli
  398.                configfilename = rpldir'\IBMCOM\'lantype'\CONFIG.20'
  399.                If File_Exist(configfilename) <> 0 Then Do
  400.                   /* a CONFIG.20 file is present, update it */
  401.                   /* Call Update_Client_Config_20 */
  402.                   Call RPLUCC20.CMD driver,client,Bustype,swaptarget,rpldir,lantype,version21,basedevflag
  403.                   If result = 0 Then Do
  404.                      msgdata = lantype || message.11
  405.                      Call Display_Log_Msg msgdata, 'CONFIG.20'
  406.                   end
  407.                   else Do
  408.                      If result = 2 Then Do
  409.                         /* could not update to 3.0 format */
  410.                         msgdata = errprefix || message.16
  411.                         Call Display_Log_Msg msgdata, rpldir, lantype
  412.                      end
  413.                      else Do
  414.                         msgdata = errprefix || client || lantype || message.12
  415.                         Call Display_Log_Msg msgdata, 'CONFIG.20'
  416.                      end
  417.                   end
  418.                end
  419.  
  420.                configfilename = rpldir'\IBMCOM\'lantype'\CONFIGRI.20'
  421.                If File_Exist(configfilename) <> 0 Then Do
  422.                   /* a CONFIGRI.20 file is present, update it */
  423.                   Call Update_Client_Configri_20
  424.                   If result = 0 Then Do
  425.                      msgdata = lantype || message.11
  426.                      Call Display_Log_Msg msgdata, 'CONFIGRI.20'
  427.                   end
  428.                   else Do
  429.                      msgdata = errprefix || client || lantype || message.12
  430.                      Call Display_Log_Msg msgdata, 'CONFIGRI.20'
  431.                   end
  432.                end
  433.             end
  434.          end
  435.          else Do
  436.             /* not the DEFALT20 client */
  437.             /* Update the RIPL Client Config.20 */
  438.             Call RPLUCC20.CMD driver,client,Bustype,swaptarget,rpldir,lantype,version21,basedevflag
  439.             If result = 0 Then Do
  440.                msgdata = client || message.11
  441.                Call Display_Log_Msg msgdata, 'CONFIG.20'
  442.             end
  443.             else Do
  444.                If result= 2 Then Do
  445.                   /* could not update to 3.0 format */
  446.                   msgdata = errprefix || message.16
  447.                   Call Display_Log_Msg msgdata, rpldir, lantype
  448.                end
  449.                else Do
  450.                   msgdata = errprefix || client || message.12
  451.                   Call Display_Log_Msg msgdata, 'CONFIG.20'
  452.                end
  453.             end
  454.  
  455.             Call Update_Client_Configri_20
  456.             If result = 0 Then Do
  457.                msgdata = client || message.11
  458.                Call Display_Log_Msg msgdata, 'CONFIGRI.20'
  459.             end
  460.             else Do
  461.                msgdata = errprefix || client || message.12
  462.                Call Display_Log_Msg msgdata, 'CONFIGRI.20'
  463.             end
  464.          end
  465.       end
  466.  
  467.       If driver <> '' | changeOS2 = 1 Then Do
  468.          /* Call RPLUCFIT to update the client.FIT file */
  469.          Call RPLUCFIT.CMD client, rpldir, driver, Bustype, currentOS2, ,
  470.                            newOS2, changeOS2, clientbootdrv, version21
  471.          If result = 0 Then Do
  472.             msgdata = client||message.13
  473.             Call Display_Log_Msg msgdata, ''
  474.          end
  475.          else If result = 2 Then Do
  476.             /* ignore return code 2 case, FIT did not need updating */
  477.             nop
  478.          end
  479.          else Do
  480.             /* error updating client fit */
  481.             msgdata = errprefix || client || message.14
  482.             Call Display_Log_Msg msgdata, ''
  483.          end
  484.       end
  485.  
  486.  
  487.       /* if OS/2 2.1 and if client copy of SYSTEM.INI and PROGMAN.INI is */
  488.       /* old format, copy new format INI and GRP files to client tree */
  489.       If version21 = 1 Then Do
  490.          srcpath = rpldir'\'newOS2'\OS2\MDOS\WINOS2\'
  491.          trgpath = lanpath'\RPLUSER\'client'\OS2\MDOS\WINOS2\'
  492.  
  493.          If File_Exist(trgpath'SYSTEM.INI') = 0 Then Do
  494.             /* assume *.INI, *.GRP, or directories do not exist, set up to */
  495.             /* copy masters from OS2.21 directory tree */
  496.             dpos = 0
  497.             backup = 0
  498.          end
  499.          else Do
  500.             /* file exists, check to see if SYSTEM.INI is old or new format */
  501.             srcfile = trgpath'SYSTEM.INI'
  502.             dpos = 0
  503.             Do while lines(srcfile) <> 0
  504.                data = translate(linein(srcfile))
  505.                dpos = pos('[XGA_DISPLAY]', data)
  506.                If dpos <> 0 Then Leave
  507.             end
  508.             Call Lineout srcfile
  509.             backup = 1
  510.          end
  511.          If dpos = 0 Then Do
  512.             /* old format, must replace all *.INI and *.GRP with 2.1 versions */
  513.             srcfile = srcpath'*.INI'
  514.             srcfile2 = trgpath'*.INI'
  515.             trgfile2 = substr(srcfile2, 1, length(srcfile2)-3) || 'IBK'
  516.             If backup = 1 Then Do
  517.                /* backup originals */
  518.                '@COPY 'srcfile2 trgfile2 nulsufix
  519.             end
  520.  
  521.             /* copy new INI files to RPLUSER\client tree */
  522.             '@XCOPY 'srcfile trgpath nulsufix
  523.  
  524.             srcfile = srcpath'*.GRP'
  525.             srcfile2 = trgpath'*.GRP'
  526.             trgfile2 = substr(srcfile2, 1, length(srcfile2)-3) || 'GBK'
  527.             If backup = 1 Then Do
  528.                /* backup original */
  529.                '@COPY 'srcfile2 trgfile2 nulsufix
  530.             end
  531.  
  532.             /* copy new GRP files to RPLUSER\client tree */
  533.             '@XCOPY 'srcfile trgpath nulsufix
  534.  
  535.             /* display information message */
  536.             Call Display_Log_Msg message.34, ''
  537.          end
  538.       end
  539.  
  540.       If driver <> '' | swaptarget <> '' Then Do
  541.          If version21 = 1 Then Do
  542.             /* update client SYSTEM.INI file to use correct display */
  543.             /* settings and PagingFile target */
  544.             Call Update_SYSTEM_INI
  545.             If result = 0 Then Do
  546.                msgdata = client || message.11
  547.                Call Display_Log_Msg msgdata, 'SYSTEM.INI'
  548.             end
  549.             else Do
  550.                msgdata = errprefix || client || message.12
  551.                Call Display_Log_Msg msgdata, 'SYSTEM.INI'
  552.             end
  553.  
  554.             If driver <> '' Then Do
  555.                /* update client PROGMAN.INI file to use correct display */
  556.                /* settings and bootdrive */
  557.                Call Update_PROGMAN_INI
  558.                If result = 0 Then Do
  559.                   msgdata = client || message.11
  560.                   Call Display_Log_Msg msgdata, 'PROGMAN.INI'
  561.                end
  562.                else Do
  563.                   msgdata = errprefix || client || message.12
  564.                   Call Display_Log_Msg msgdata, 'PROGMAN.INI'
  565.                end
  566.             end
  567.          end
  568.       end
  569.  
  570.       If client <> 'DEFALT20' Then Do
  571.          /* not DEFALT20, check for RPL.MMAP update */
  572.          If changeOS2 = 1 Then Do
  573.             /* update workstation record in RPL.MAP */
  574.             Call Update_Workstation_Record
  575.             If result = 0 Then Do
  576.                msgdata = client||message.27
  577.                Call Display_Log_Msg msgdata, ''
  578.             end
  579.             else Do
  580.                /* error updating workstation record */
  581.                msgdata = errprefix||client||message.28
  582.                Call Display_Log_Msg msgdata, ''
  583.             end
  584.  
  585.          end
  586.       end
  587.    end
  588.    else Do
  589.       /* INI update failed, skip CONFIG.20, FIT, RPL.MAP update & INI copy */
  590.       msgdata = errprefix || client || message.15 || client '.'
  591.       Call Display_Log_Msg msgdata, ''
  592.    end
  593.  
  594.    msgdata = '  '
  595.    Call Display_Log_Msg msgdata, ''
  596.    return 0
  597.  
  598.  
  599.  
  600. /* Subroutine Update_Client_Ini */
  601. /* This subroutine updates the OS2INI.20 file for a client workstation */
  602. /* to add the required profile data to support the specified device driver. */
  603. Update_Client_Ini:
  604.  
  605.    rc = 0
  606.  
  607.    /* build fully qualified path name for OS2INI.20 */
  608.    ininame = lanpath'\RPLUSER\'client'\OS2\OS2INI.20'
  609.  
  610.    /* OS2 may leave INI files read-only, play safe, remove read-only attributes */
  611.    '@ATTRIB -r 'ininame'OS2*.20 1>nul'
  612.  
  613.    /* Execute RPLRXUTL to update client copy of OS2.INI (OS2INI.20) */
  614.    '@RPLRXUTL.EXE /D:'driver ' /C:'ininame '1>nul'
  615.    return rc
  616.  
  617.  
  618.  
  619.  
  620. /* Subroutine Update_Client_Configri_20 */
  621. /* This subroutine creates a new CONFIGRI.20 for the client that has the */
  622. /* appropriate family 1/family 2 statements enabled/disabled (if /B */
  623. /* specified).  If also will add the DRIVER=x:\OS2\TESTCFG.SYS statement */
  624. /* if it is missing. */
  625. Update_Client_Configri_20:
  626.  
  627.    /* build fully qualified path names for client CONFIGRI.20 */
  628.    If client = 'DEFALT20' Then Do
  629.       /* DEFALT20 is special case, it must be called for each lantype */
  630.       configname = rpldir'\IBMCOM\'lantype'\CONFIGRI.20'
  631.       tmpconfigname = rpldir'\IBMCOM\'lantype'\CONFIGRI.20T'
  632.       bakconfigname = rpldir'\IBMCOM\'lantype'\CONFIGRI.20B'
  633.    end
  634.    else Do
  635.       configname = rpldir'\MACHINES\'client'\CONFIGRI.20'
  636.       tmpconfigname = rpldir'\MACHINES\'client'\CONFIGRI.20T'
  637.       bakconfigname = rpldir'\MACHINES\'client'\CONFIGRI.20B'
  638.    end
  639.    /* delete temp file names */
  640.    Call Delete_File tmpconfigname
  641.    Call Delete_File bakconfigname
  642.  
  643.    If File_Exist(configname) = 1 Then Do
  644.       tmpbustype = Bustype
  645.       If tmpbustype = 'EISA' Then tmpbustype = 'ISA'
  646.  
  647.       /* copy records looking for TESTCFG.SYS statement */
  648.       dpos = copy_records_until_str(configname, tmpconfigname, 'SET PATH=')
  649.       If dpos <> 0 Then Do
  650.          /* get bootdrive id from SET PATH statement */
  651.          dpos = pos(':\OS2;', ucdata)
  652.          if dpos <> 0 Then riclientbootdrv = substr(ucdata, dpos-1, 1)
  653.          Call Lineout tmpconfigname, data
  654.       end
  655.  
  656.       flag = 0
  657.       do until lines(configname) = 0
  658.          data = linein(configname)
  659.          ucdata = translate(data)
  660.  
  661.          If tmpbustype <> '' Then Do
  662.             /* check for family 1/family 2 BASEDEV statements */
  663.             dpos = pos('BASEDEV=', ucdata)
  664.             If dpos <> 0 Then Do
  665.                basedev = word(substr(ucdata, dpos+8), 1)
  666.                If basedev = 'PRINT01.SYS' | basedev = 'IBM1FLPY.ADD' |,
  667.                   basedev = 'IBM1S506.ADD' Then Do
  668.                   /* enable/disable family one */
  669.                   Call enable_disable_record  tmpbustype, 'ISA', 'REM '
  670.                end
  671.                else If basedev = 'PRINT02.SYS' | basedev = 'IBM2FLPY.ADD' |,
  672.                   basedev = 'IBM2SCSI.ADD' Then Do
  673.                   /* enable/disable family 2 */
  674.                   Call enable_disable_record  tmpbustype, 'MCA', 'REM '
  675.                end
  676.             end
  677.          end
  678.  
  679.          /* check for DEVICE statements */
  680.          dpos = pos('DEVICE=', ucdata)
  681.          If dpos <> 0 Then Do
  682.             If pos('\OS2\TESTCFG.SYS', ucdata, dpos+7) <> 0 Then Do
  683.                /* TESTCFG.SYS DEVICE statement already present */
  684.                If word(ucdata, 1) = 'REM' Then Do
  685.                   /* statement REMed out, un-REM it */
  686.                   newdata = substr(data, dpos)
  687.                   data = newdata
  688.                end
  689.                flag = 1
  690.             end
  691.          end
  692.          Call lineout tmpconfigname, data
  693.       end
  694.       If flag = 0 Then Do
  695.          /* add DEVICE statement to end of file */
  696.          Call lineout tmpconfigname, 'DEVICE='riclientbootdrv':\OS2\TESTCFG.SYS'
  697.       end
  698.  
  699.       Call Lineout tmpconfigname   /* close file */
  700.       Call Lineout configname      /* close file */
  701.  
  702.       /* rename original CONFIGRI.20 */
  703.       '@rename 'configname' CONFIGRI.20B'
  704.       if rc = 0 Then Do
  705.          /* rename CONFIGRI.20T to be CONFIGRI.20 */
  706.          '@rename 'tmpconfigname' CONFIGRI.20'
  707.          if rc = 0 Then Do
  708.             /* delete orginal CONFIGRI.20 */
  709.             Call Delete_File bakconfigname
  710.          end
  711.          else Do
  712.             /* rename error, try to restore original */
  713.             '@rename 'bakconfigname' CONFIGRI.20'
  714.          end
  715.       end
  716.       else return 4  /* rename error */
  717.    end
  718.    else return 4   /* file not found */
  719.    return 0
  720.  
  721.  
  722. /* subroutine to update client SYSTEM.INI file to change display type */
  723. /* and/or Pagingfile path */
  724. Update_SYSTEM_INI:
  725.    /* build path to client SYSTEM.INI file */
  726.    inipath = lanpath'\RPLUSER\'client'\OS2\MDOS\WINOS2\'
  727.    srcfile = inipath || 'SYSTEM.INI'
  728.    trgfile = inipath || 'SYSTEM.TMP'
  729.    Call Delete_File trgfile
  730.    Call Delete_File inipath || 'SYSTEM.BAK'
  731.  
  732.    If File_Exist(srcfile) = 1 Then Do
  733.       If driver <> '' Then Do
  734.          /* copy records looking for vga.drv statement */
  735.          dpos = copy_records_until_str( srcfile, trgfile, 'VGA.DRV')
  736.          If dpos <> 0 Then Do
  737.             /* vga.drv found */
  738.             /* process records until [keyboard] entry */
  739.             flag = 0
  740.             Do until lines(srcfile) = 0
  741.                /* bypass read on first pass, already have data */
  742.                If flag = 0 Then flag = 1
  743.                else Do
  744.                   data = linein(srcfile)
  745.                   ucdata = translate(data)
  746.                end
  747.  
  748.                /* check for loop exit */
  749.                dpos = pos('[KEYBOARD]', ucdata)
  750.                If dpos <> 0 Then Do
  751.                   Call Lineout trgfile, data
  752.                   Leave
  753.                end
  754.  
  755.                dpos = pos('VGA', ucdata)
  756.                if dpos <> 0 Then Do
  757.                   Call enable_disable_record  driver, 'IBMVGA32', ';'
  758.                end
  759.                else Do
  760.                   /* check for XGA entry */
  761.                   dpos = pos('XGA', ucdata)
  762.                   if dpos <> 0 Then Do
  763.                      dpos = pos(' NEXT ', ucdata)
  764.                      If dpos = 0 Then Do
  765.                         /* not comment entry */
  766.                         Call enable_disable_record  driver, 'IBMXGA32', ';'
  767.                      end
  768.                   end
  769.                   else Do
  770.                      /* check for 8514 entry */
  771.                      dpos = pos('8514', ucdata)
  772.                      if dpos <> 0 Then Do
  773.                         dpos = pos(' NEXT ', ucdata)
  774.                         if dpos = 0 Then Do
  775.                            /* not comment entry */
  776.                            Call enable_disable_record  driver, '8514_32', ';'
  777.                         end
  778.                      end
  779.                   end
  780.                end
  781.                Call Lineout trgfile, data
  782.             end
  783.          end
  784.       end
  785.  
  786.       /* if swaptarget specified, check PagingFile */
  787.       If swaptarget <> '' Then Do
  788.          /* process local pagingfile entry */
  789.          dpos = copy_records_until_str(srcfile, trgfile, 'PAGINGFILE=')
  790.          If dpos <> 0 Then Do
  791.             /* record found */
  792.             Call enable_disable_record  swaptarget, 'L', ';'
  793.          end
  794.          Call Lineout trgfile, data
  795.  
  796.          /* process server pagingfile entry */
  797.          dpos = copy_records_until_str(srcfile, trgfile, 'PAGINGFILE=')
  798.          If dpos <> 0 Then Do
  799.             /* record found */
  800.             Call enable_disable_record  swaptarget, 'S', ';'
  801.  
  802.             /* update RIPL boot drive id */
  803.             dpos = pos('=', data)
  804.             If dpos <> 0 Then Do
  805.                newdata = substr(data, 1, dpos) || clientbootdrv ||,
  806.                          strip(substr(data, dpos+1))
  807.             end
  808.          end
  809.          Call Lineout trgfile, data
  810.       end
  811.  
  812.       If driver <> '' Then Do
  813.          /* copy records to XGA_DISPLAY */
  814.          dpos = copy_records_until_str( srcfile, trgfile, '[XGA_DISPLAY]')
  815.          If dpos <> 0 Then Do
  816.             /* record found */
  817.             Call enable_disable_record  driver, 'IBMXGA32', ';'
  818.          end
  819.          Call Lineout trgfile, data
  820.  
  821.          dpos = copy_records_until_str(srcfile, trgfile, 'XGA_RES')
  822.          If dpos <> 0 Then Do
  823.             /* record found */
  824.             Call enable_disable_record  driver, 'IBMXGA32', ';'
  825.          end
  826.          Call Lineout trgfile, data
  827.       end
  828.  
  829.       /* copy any remaining records */
  830.       do while lines(srcfile) <> 0
  831.          data = linein(srcfile)
  832.          Call Lineout trgfile, data
  833.       end
  834.  
  835.       /* close files */
  836.       Call Lineout srcfile
  837.       Call Lineout trgfile
  838.  
  839.       /* rename files */
  840.       '@RENAME 'srcfile  'SYSTEM.BAK'
  841.       If rc = 0 Then Do
  842.          '@RENAME 'trgfile  'SYSTEM.INI'
  843.          If rc = 0 Then Do
  844.             Call Delete_File inipath || 'SYSTEM.BAK'
  845.          end
  846.          else Do
  847.             /* rename error, try to restore original */
  848.             '@RENAME 'inipath || 'SYSTEM.BAK SYSTEM.INI'
  849.             return 4
  850.          end
  851.       end
  852.       else return 4  /* rename error */
  853.    end
  854.    else return 4   /* file not found */
  855.    return 0
  856.  
  857.  
  858.  
  859. /* subroutine to update client PROGMAN.INI file to change display type */
  860. /* and bootdrive */
  861. Update_PROGMAN_INI:
  862.    /* build path to client PROGMAN.INI file */
  863.    inipath = lanpath'\RPLUSER\'client'\OS2\MDOS\WINOS2\'
  864.    srcfile = inipath || 'PROGMAN.INI'
  865.    trgfile = inipath || 'PROGMAN.TMP'
  866.    Call Delete_File trgfile
  867.    Call Delete_File inipath || 'PROGMAN.BAK'
  868.  
  869.    If File_Exist(srcfile) = 1 Then Do
  870.       /* copy records looking for vga.drv statement */
  871.       dpos = copy_records_until_str( srcfile, trgfile, 'VGA.DRV')
  872.       If dpos <> 0 Then Do
  873.          /* vga.drv found */
  874.          Call enable_disable_record  driver, 'IBMVGA32', ';'
  875.       end
  876.       Call Lineout trgfile, data
  877.  
  878.       /* copy records looking for xga.drv statement */
  879.       dpos = copy_records_until_str( srcfile, trgfile, 'XGA.DRV')
  880.       If dpos <> 0 Then Do
  881.          If driver = 'IBMXGA32' Then Do
  882.             /* xga.drv found, enable/disable for XGA */
  883.             Call enable_disable_record  driver, 'IBMXGA32', ';'
  884.          end
  885.          else If driver = '8514_32' Then Do
  886.             /* xga.drv found, enable/disable for 8514 */
  887.             Call enable_disable_record  driver, '8514_32', ';'
  888.          end
  889.       end
  890.       Call Lineout trgfile, data
  891.  
  892.       /* copy records looking for [Groups] */
  893.       dpos = copy_records_until_str( srcfile, trgfile, 'GROUPS')
  894.       Call Lineout trgfile, data
  895.  
  896.       /* update group records to use correct boot drive id */
  897.       do while lines(srcfile) <> 0
  898.          data = linein(srcfile)
  899.          ucdata = translate(data)
  900.            dpos = pos('GROUP', ucdata)
  901.            If dpos <> 0 Then Do
  902.               /* this may be a group record */
  903.               dpos = pos(':\OS2\', ucdata)
  904.               dpos2 = dpos
  905.               If dpos <> 0 Then Do
  906.                  /* partial path data found, assume valid record */
  907.                  dpos = pos('=', ucdata)
  908.                  If dpos <> 0 Then Do
  909.                     newdata = substr(data, 1, dpos) || clientbootdrv ||,
  910.                               substr(data, dpos2)
  911.                     data = newdata
  912.                  end
  913.               end
  914.            end
  915.          Call Lineout trgfile, data
  916.       end
  917.  
  918.       /* close files */
  919.       Call Lineout srcfile
  920.       Call Lineout trgfile
  921.  
  922.       /* rename files */
  923.       '@RENAME 'srcfile  'PROGMAN.BAK'
  924.       If rc = 0 Then Do
  925.          '@RENAME 'trgfile  'PROGMAN.INI'
  926.          If rc = 0 Then Do
  927.             Call Delete_File inipath || 'PROGMAN.BAK'
  928.          end
  929.          else Do
  930.             /* rename error, try to restore original */
  931.             '@RENAME 'inipath || 'PROGMAN.BAK PROGMAN.INI'
  932.             return 4
  933.          end
  934.       end
  935.       else return 4  /* rename error */
  936.    end
  937.    else return 4   /* file not found */
  938.    return 0
  939.  
  940.  
  941.  
  942. /* subroutine to copy records from one file to another until a specified */
  943. /* character string is encountered.  The postion of the character string */
  944. /* within the record is returned. */
  945. copy_records_until_str:
  946.    parse arg srcfile1, trgfile1, teststring
  947.    Do while lines(srcfile1) <> 0
  948.       data = linein(srcfile1)
  949.       ucdata = translate(data)
  950.       tspos = pos(teststring, ucdata)
  951.       If tspos <> 0 Then Do
  952.          If pos('NEXT ', ucdata) = 0 Then Leave
  953.          else tspos = 0
  954.       end
  955.       Call Lineout trgfile1, data
  956.    end
  957.    return tspos
  958.  
  959.  
  960. /* subroutine to enable/disable records based on specified criteria */
  961. enable_disable_record:
  962.    parse arg testvar, testvalue, disablestr
  963.  
  964.    lendisablestr = length(disablestr)
  965.    If testvar = testvalue Then Do
  966.       /* make sure record is enabled */
  967.       If substr(ucdata, 1, lendisablestr) = disablestr Then Do
  968.          newdata = strip(substr(data, lendisablestr+1))
  969.          data = newdata
  970.       end
  971.    end
  972.    else Do
  973.       /* make sure record is disabled */
  974.       If substr(ucdata, 1, lendisablestr) <> disablestr Then Do
  975.          data = disablestr || data
  976.       end
  977.    end
  978.    return
  979.  
  980.  
  981.  
  982. /* subroutine to delete a file */
  983. Delete_File:
  984.    arg delfilename
  985.    If stream(delfilename, C, 'query exists') <> '' Then Do
  986.       '@DEL 'delfilename
  987.    end
  988.    return 0
  989.  
  990.  
  991.  
  992. /* subroutine to display/log messages */
  993. /* This routine attempts to format the message line based on format */
  994. /* controls imbedded in each line. */
  995. Display_Log_Msg:
  996.    Parse Arg msgstring, parm.1, parm.2, parm.3, parm.4, parm.5, parm.6
  997.    if parm.1 <> '' Then Do
  998.       /* substitution data supplied */
  999.       startpoint = 1
  1000.       newmsg = ''
  1001.       sdpos = pos('%', msgstring, startpoint)
  1002.       Do while sdpos <> 0
  1003.          j = substr(msgstring, sdpos+1, 1)
  1004.          newmsg = newmsg || substr(msgstring, startpoint, sdpos-startpoint) || parm.j
  1005.          startpoint = sdpos+2
  1006.          sdpos = pos('%', msgstring, startpoint)
  1007.       end
  1008.       newmsg = newmsg || substr(msgstring, startpoint)
  1009.       msgstring = newmsg
  1010.    end
  1011.  
  1012.    If substr(msgstring, 1, length(errprefix)) = errprefix Then errprefixflag = 1
  1013.    else errprefixflag = 0
  1014.  
  1015.    /* display/log message 1 line at a time, max line length is 75 characters */
  1016.    dataflag = 1
  1017.    msgline = ''
  1018.    tablength = 0
  1019.    indentlength = 0
  1020.    indentvalue = 0
  1021.    Do while dataflag = 1
  1022.       /* look for special formatting commands at start of line */
  1023.       do formati = 1 to 2
  1024.          testword = word(msgstring, 1)
  1025.          If substr(testword, 1, 2) = '%T' Then Do
  1026.             /* special tab command at start of line */
  1027.             tablength = substr(testword, 3)
  1028.             indentvalue = 0
  1029.             /* remove tab command from line */
  1030.             tabp = pos('%T', msgstring)
  1031.             msgstring = strip(substr(msgstring, tabp+length(testword)+1), 'L')
  1032.          end
  1033.          else Do
  1034.             If substr(testword, 1, 2) = '%I' Then Do
  1035.                /* special indent command at start of line */
  1036.                indentlength = substr(testword, 3)
  1037.                /* remove indent command from line */
  1038.                tabp = pos('%I', msgstring)
  1039.                msgstring = strip(substr(msgstring, tabp+length(testword)+1), 'L')
  1040.             end
  1041.             else Leave
  1042.          end
  1043.       end
  1044.  
  1045.       startscanpos = 75 - tablength - indentvalue
  1046.       lenmsgstring = length(msgstring)
  1047.       If lenmsgstring <> 0 Then Do
  1048.          If lenmsgstring > startscanpos Then Do
  1049.             /* check for CRLF in string */
  1050.             crlfp = pos(CRLF, msgstring)
  1051.             If crlfp <> 0 Then Do
  1052.                If crlfp <= startscanpos Then Do
  1053.                   If crlfp <> 1 Then Do
  1054.                      /* force end of line at CRLF and discard CRLF */
  1055.                      msgline = msgline || substr(msgstring, 1, crlfp-1)
  1056.                      msgstring = strip(substr(msgstring, crlfp+2), 'L')
  1057.                   end
  1058.                end
  1059.                else crlfp = 0
  1060.             end
  1061.  
  1062.             If crlfp = 0 Then Do
  1063.                /* find last blank prior to startscanpos */
  1064.                endline = lastpos(' ', msgstring, startscanpos)
  1065.                If endline > 0  Then Do
  1066.                   msgline = msgline || substr(msgstring, 1, endline)
  1067.                   msgstring = substr(msgstring, endline+1)
  1068.                   If substr(msgstring, 1, 2) = CRLF Then Do
  1069.                      /* special case, this CRLF can be ignored */
  1070.                      msgstring = strip(substr(msgstring, 3), 'L')
  1071.                   end
  1072.                end
  1073.                else Do
  1074.                   /* no space, break word */
  1075.                   msgline = substr(msgstring, 1, startscanpos)
  1076.                   msgstring = substr(msgstring, startscanpos+1)
  1077.                end
  1078.             end
  1079.          end
  1080.          else Do
  1081.             /* line less than max length allowed */
  1082.             crlfp = pos(CRLF, msgstring)
  1083.             If crlfp <> 0 Then Do
  1084.                /* get message up to CRLF, discard CRLF */
  1085.                msgline = substr(msgstring, 1, crlfp-1)
  1086.                msgstring = substr(msgstring, crlfp+2)
  1087.             end
  1088.             else Do
  1089.                /* only thing left if message */
  1090.                msgline = msgline || msgstring
  1091.                msgstring = ''
  1092.             end
  1093.          end
  1094.  
  1095.          If tablength <> 0 Then Do
  1096.             /* insert required number of spaces at start of line */
  1097.             msgline = copies(' ',tablength) || msgline
  1098.          end
  1099.          If indentvalue <> 0 Then Do
  1100.             /* add in indentation value blanks */
  1101.             msgline = copies(' ', indentvalue) || msgline
  1102.          end
  1103.  
  1104.          If Logfile = '' Then Do
  1105.             /* display message locally */
  1106.             Say msgline
  1107.             If syntaxhelpflag = 1 Then Do
  1108.                nummsglines = nummsglines + 1
  1109.                If nummsglines >= maxmsglines Then Do
  1110.                   /* prompt user to press Enter to see next part of message */
  1111.                   Say message.22
  1112.                   Pull dummy .
  1113.                   /* clear screen */
  1114.                   'CLS'
  1115.                   Say '  '         /* dummy first line */
  1116.                   /* redisplay last line of last screen */
  1117.                   Say msgline
  1118.                   nummsglines = 2
  1119.                end
  1120.             end
  1121.             If indentlength <> 0 Then Do
  1122.                indentvalue = indentlength
  1123.                indentlength = 0
  1124.             end
  1125.          end
  1126.          else Do
  1127.             /* log message */
  1128.             Call lineout Logfile, msgline
  1129.             nummsglines = nummsglines+1
  1130.          end
  1131.  
  1132.          msgline = ''
  1133.          If length(msgstring) = 0 Then dataflag = 0
  1134.          else Do
  1135.             /* if errprefix present, insert blanks at start of next msg line */
  1136.             If errprefixflag = 1 then msgline = copies(' ', length(errprefix))
  1137.          end
  1138.       end
  1139.       else dataflag = 0
  1140.    end
  1141.    return 0
  1142.  
  1143.  
  1144.  
  1145. /* subroutine to test for existance of a file */
  1146. File_Exist:
  1147.    Arg testfilename
  1148.    If stream(testfilename, C, 'query exists') <> '' Then rc = 1
  1149.    else rc = 0
  1150.    return rc
  1151.  
  1152.  
  1153.  
  1154. Determine_RIPL_Directory:
  1155.    /* find out where IBMLAN is installed */
  1156.    os2path = value('PATH',,'OS2ENVIRONMENT')
  1157.  
  1158.    ibmlanp = pos(':\IBMLAN', translate(os2path))
  1159.    if ibmlanp = 0 Then Do
  1160.      msgdata = errprefix || message.17
  1161.      Call Display_Log_Msg msgdata, ''
  1162.      return 4
  1163.    end
  1164.  
  1165.    landrv = substr(os2path, ibmlanp-1, 1)
  1166.    lanpath = landrv':\IBMLAN'
  1167.  
  1168.    fname = lanpath'\IBMLAN.INI'
  1169.  
  1170.    /* read IBMLAN.INI looking for the RPLDIR entry */
  1171.    do until lines(fname) = 0
  1172.       data = linein(fname)
  1173.       rpldirp = pos('RPLDIR', translate(data))
  1174.       if rpldirp <> 0 then do
  1175.          rpldirp = pos('=', data)
  1176.          rpldir = strip(substr(data, rpldirp+1))
  1177.          Leave
  1178.       end
  1179.    end
  1180.    Call stream fname,C,'close'
  1181.  
  1182.    if rpldir = '' then do
  1183.       msgdata = errprefix || message.18
  1184.       Call Display_Log_Msg msgdata, ''
  1185.       return 4
  1186.    end
  1187.    return 0
  1188.  
  1189.  
  1190.  
  1191. /* subroutine to verify that the display driver id is valid */
  1192. Validate_Display_DriverID:
  1193.    /* initialize display driver ids */
  1194.    displaydrv.0 = 4
  1195.    displaydrv.1 = 'IBMVGA32'
  1196.    displaydrv.2 = 'IBMXGA32'
  1197.    displaydrv.3 = 'IBM8514'   /* 2.0+Service Pak or 2.00.1 */
  1198.    displaydrv.4 = '8514_32'   /* 2.1 only */
  1199.  
  1200.    /* validate driver parameter */
  1201.    flag = 0
  1202.    Do i=1 to displaydrv.0
  1203.       If driver=displaydrv.i Then Do
  1204.          flag = 1
  1205.          leave
  1206.       end
  1207.    end
  1208.    if flag = 0 Then Do
  1209.       Call Display_Log_Msg message.19, ''
  1210.       return 4
  1211.    end
  1212.  
  1213.    /* if IBM8514 and OS/2 2.1, convert to 32 bit name */
  1214.    If driver = 'IBM8514' & version21 = 1 Then driver = '8514_32'
  1215.  
  1216.    return 0
  1217.  
  1218.  
  1219.  
  1220. /* subroutine to validate the Bustype parameter */
  1221. Validate_Bustype:
  1222.    If Bustype <> 'MCA' Then Do
  1223.       If Bustype <> 'ISA' Then Do
  1224.          If Bustype <> 'EISA' Then Do
  1225.             Call Display_Log_Msg message.6, ''
  1226.             return 4
  1227.          end
  1228.       end
  1229.    end
  1230.    return 0
  1231.  
  1232.  
  1233. /* subroutine to validate the swaptarget parameter */
  1234. Validate_swaptarget:
  1235.    swaptarget = translate(swaptarget)
  1236.    If swaptarget <> 'L' Then Do
  1237.       If swaptarget <> 'S' Then Do
  1238.          Call Display_Log_Msg message.29, ''
  1239.          return 4
  1240.       end
  1241.    end
  1242.    return 0
  1243.  
  1244.  
  1245. /* subroutine to update client workstation record in RPL.MAP */
  1246. Update_Workstation_Record:
  1247.    rplmap = rpldir'\RPL.MAP'
  1248.    tmprplmap = rpldir'\RPLMAP.TMP'
  1249.    updateerr = 0
  1250.    Call Delete_File tmprplmap
  1251.    Do until lines(rplmap) = 0
  1252.       data = linein(rplmap)
  1253.       field2 = translate(word(data, 2))
  1254.       If field2 = client Then Do
  1255.          /* may be a client record, check field 4 for FIT */
  1256.          field4 = word(data,4)
  1257.          If translate(substr(field4, 1, 5)) = 'FITS\' Then Do
  1258.             /* this is an OS/2 client workstation record */
  1259.             field12 = word(data, 12)
  1260.             f12p = pos(field12, data)
  1261.             ucnewos2 = translate(newOS2)
  1262.             /* determine OS type for field 12 */
  1263.             Select
  1264.                when ucnewos2 = 'OS2.20' Then os2type = '20'
  1265.                when ucnewos2 = 'OS2.20A' Then os2type = '20A'
  1266.                when ucnewos2 = 'OS2.21' Then os2type = '21'
  1267.                otherwise Do
  1268.                   os2type = ''
  1269.                   updateerr = 1
  1270.                end
  1271.             end
  1272.             If os2type <> '' Then Do
  1273.                /* update field 12 for correct OS type */
  1274.                newdata = substr(data, 1, f12p+1) || os2type
  1275.                f12p = pos('_', data, f12p+2)
  1276.                if f12p <> 0 Then newdata = newdata || substr(data, f12p)
  1277.                else Do
  1278.                     /* error, use original record */
  1279.                     newdata = data
  1280.                     updateerr = 1
  1281.                end
  1282.                data = newdata
  1283.             end
  1284.          end
  1285.       end
  1286.       Call lineout tmprplmap, data
  1287.    end
  1288.    Call lineout rplmap
  1289.    Call lineout tmprplmap
  1290.    If updateerr = 0 Then Do
  1291.       /* no error, replace RPL.MAP with new RPL.MAP */
  1292.       '@copy 'rplmap  rpldir'\RPLMAP.BAK 1>nul 2>nul'
  1293.       Call Delete_File rplmap
  1294.       '@rename 'tmprplmap 'RPL.MAP 1>nul 2>nul'
  1295.    end
  1296.    else Do
  1297.       /* update error, delete tmp file, return error */
  1298.       Call Delete_File tmprplmap
  1299.       return 4
  1300.    end
  1301.    return 0
  1302.  
  1303.  
  1304.  
  1305.  
  1306.  
  1307. /* subroutine to read user provided response file and set keyword variables */
  1308. Read_Rspfile:
  1309.    /* reset selected variables to defaults for each new group */
  1310.    driver = ''
  1311.    inputcurOS2 = ''
  1312.    inputnewOS2 = ''
  1313.    currentOS2 = defcurrentOS2
  1314.    newOS2 = defnewOS2
  1315.    Bustype = ''
  1316.    swaptarget = ''
  1317.  
  1318.    /* read response file and get keyword values for next group */
  1319.    keydata = 0
  1320.    clientlist.0 = 0
  1321.    Do while lines(Rspfile) <> 0
  1322.       data = translate(linein(Rspfile))
  1323.       If data <> '' Then Do
  1324.          If substr(data, 1, 1) <> ';' Then Do
  1325.             /* not a comment */
  1326.             data = strip(data)  /* eliminate any leading blanks */
  1327.             If substr(data, 1, 10) = 'CLIENTLIST' | ,
  1328.                substr(data, 1, 6) = 'CLIENT' Then Do
  1329.                /* multiple CLIENT and/or CLIENTLIST entries are permitted */
  1330.                epos = pos('=', data)
  1331.                clientdata = strip(substr(data, epos+1))
  1332.                cpos = pos(',', clientdata)
  1333.                if cpos = 0 Then Do
  1334.                   /* only one client specified */
  1335.                   clnum = clientlist.0 + 1
  1336.                   clientlist.clnum = clientdata
  1337.                   clientlist.0 = clnum
  1338.                end
  1339.                else Do
  1340.                   /* list of clients provided */
  1341.                   startpoint = 1
  1342.                   clnum = clientlist.0 + 1
  1343.                   cpos = pos(',', clientdata, startpoint)
  1344.                   /* scan list and put each name in clientlist array */
  1345.                   Do while (cpos <> 0)
  1346.                      clientlist.clnum = strip(substr(clientdata, startpoint, cpos-startpoint))
  1347.                      clientlist.0 = clnum
  1348.                      startpoint = cpos+1
  1349.                      clnum = clnum + 1
  1350.                      cpos = pos(',', clientdata, startpoint)
  1351.                   end
  1352.                   if startpoint < length(clientdata) Then Do
  1353.                      /* last name in list */
  1354.                      clientlist.clnum = strip(substr(clientdata, startpoint))
  1355.                      clientlist.0 = clnum
  1356.                   end
  1357.                end
  1358.                keydata = 1
  1359.             end
  1360.             else If substr(data, 1, 13) = 'DISPLAYDRIVER' Then Do
  1361.                epos = pos('=', data)
  1362.                driver = strip(substr(data, epos+1))
  1363.                keydata = 1
  1364.             end
  1365.             else If substr(data, 1, 13) = 'CURRENTOS2DIR' Then Do
  1366.                /* optional, current OS/2 root directory parameter */
  1367.                epos = pos('=', data)
  1368.                currentOS2 = strip(substr(data, epos+1))
  1369.                inputcurOS2 = currentOS2
  1370.                changeOS2 = 1
  1371.                keydata = 1
  1372.             end
  1373.             else If substr(data, 1, 9) = 'NEWOS2DIR' Then Do
  1374.                /* optional, new OS/2 root directory parameter */
  1375.                epos = pos('=', data)
  1376.                newOS2 = strip(substr(data, epos+1))
  1377.                inputnewOS2 = newOS2
  1378.                changeOS2 = 1
  1379.                keydata = 1
  1380.             end
  1381.             else If substr(data, 1, 7) = 'BUSTYPE' Then Do
  1382.                /* Bustype parameter */
  1383.                epos = pos('=', data)
  1384.                Bustype = strip(substr(data, epos+1))
  1385.                keydata = 1
  1386.             end
  1387.             else If substr(data, 1, 10) = 'SWAPTARGET' Then Do
  1388.                /* swaptarget parameter */
  1389.                epos = pos('=', data)
  1390.                swaptarget = strip(substr(data, epos+1))
  1391.                keydata = 1
  1392.             end
  1393.             else If substr(data,1, 12) = '[GROUP]' Then Do
  1394.                /* start of new group, any keywords entered? */
  1395.                If keydata = 1 Then Leave
  1396.                else Do
  1397.                   /* no keywords, ignore entry */
  1398.                   nop
  1399.                end
  1400.             end
  1401.             else Do
  1402.                /* invalid entry */
  1403.                msgdata = errprefix || word(data, 1) || message.25
  1404.                Call Display_Log_Msg msgdata, ''
  1405.             end
  1406.          end
  1407.       end
  1408.    end
  1409.  
  1410.    If keydata = 1 Then Do
  1411.       /* at least one keyword entered */
  1412.       /* check for required keywords */
  1413.       If clientlist.0 = 0 Then Do
  1414.          /* invalid/incomplete response file */
  1415.          return 4
  1416.       end
  1417.       If clientlist.0 <> 0 Then Do
  1418.          If driver = '' & Bustype = '' & swaptarget = '' & changeOS2 = 0 Then Do
  1419.             /* invalid/incomplete response file */
  1420.             return 4
  1421.          end
  1422.       end
  1423.    end
  1424.  
  1425.    If Lines(Rspfile) = 0 & keydata = 0 Then return 2
  1426.    else return 0
  1427.  
  1428.  
  1429.  
  1430. /* subroutine to process command line parameters */
  1431. Process_Input_Parameters:
  1432.    Do i = 1 to 8
  1433.       If parm.i = '' Then Leave
  1434.       parmtype = translate(substr(parm.i,1,2))
  1435.       select
  1436.          when parmtype = '/H' Then Call Syntax_Help
  1437.  
  1438.          when parmtype = '/h' Then Call Syntax_Help
  1439.  
  1440.          when parmtype = '/D' Then Do
  1441.             if substr(parm.i, 3, 1) = ':' Then driver = substr(parm.i, 4)
  1442.             else driver = substr(parm.i, 3)
  1443.             driver = translate(driver)
  1444.          end
  1445.  
  1446.          when parmtype = '/C' Then Do
  1447.             if substr(parm.i, 3, 1) = ':' Then clientdata = substr(parm.i, 4)
  1448.             else clientdata = substr(parm.i, 3)
  1449.             clientdata = translate(clientdata)
  1450.             cpos = pos(',', clientdata)
  1451.             if cpos = 0 Then Do
  1452.                clientlist.0 = 1
  1453.                clientlist.1 = clientdata
  1454.             end
  1455.             else Do
  1456.                /* list of clients provided */
  1457.                startpoint = 1
  1458.                clnum = 1
  1459.                cpos = pos(',', clientdata, startpoint)
  1460.                /* scan list and put each name in clientlist array */
  1461.                Do while (cpos <> 0)
  1462.                   clientlist.clnum = substr(clientdata, startpoint, cpos-startpoint)
  1463.                   clientlist.0 = clnum
  1464.                   startpoint = cpos+1
  1465.                   clnum = clnum + 1
  1466.                   cpos = pos(',', clientdata, startpoint)
  1467.                end
  1468.                if startpoint < length(clientdata) Then Do
  1469.                   /* last name in list */
  1470.                   clientlist.clnum = substr(clientdata, startpoint)
  1471.                   clientlist.0 = clnum
  1472.                end
  1473.             end
  1474.          end
  1475.  
  1476.          when parmtype = '/O' Then Do
  1477.             if substr(parm.i, 3, 1) = ':' Then currentOS2 = substr(parm.i, 4)
  1478.             else currentOS2 = substr(parm.i, 3)
  1479.             inputcurOS2 = currentOS2
  1480.             changeOS2 = 1
  1481.          end
  1482.  
  1483.          when parmtype = '/N' Then Do
  1484.             if substr(parm.i, 3, 1) = ':' Then newOS2 = substr(parm.i, 4)
  1485.             else newOS2 = substr(parm.i, 3)
  1486.             inputnewOS2 = newOS2
  1487.             changeOS2 = 1
  1488.          end
  1489.  
  1490.          when parmtype = '/L' Then Do
  1491.             if substr(parm.i, 3, 1) = ':' Then Logfile = substr(parm.i, 4)
  1492.             else Logfile = substr(parm.i, 3)
  1493.          end
  1494.  
  1495.          when parmtype = '/R' Then Do
  1496.             if substr(parm.i, 3, 1) = ':' Then Rspfile = substr(parm.i, 4)
  1497.             else Rspfile = substr(parm.i, 3)
  1498.          end
  1499.  
  1500.          when parmtype = '/B' Then Do
  1501.             if substr(parm.i, 3, 1) = ':' Then Bustype = substr(parm.i, 4)
  1502.             else Bustype = substr(parm.i, 3)
  1503.             Bustype = translate(Bustype)
  1504.          end
  1505.  
  1506.          when parmtype = '/S' Then Do
  1507.             if substr(parm.i, 3, 1) = ':' Then swaptarget = substr(parm.i, 4)
  1508.             else swaptarget = substr(parm.i, 3)
  1509.             swaptarget = translate(swaptarget)
  1510.          end
  1511.  
  1512.          otherwise Do
  1513.            msgdata = errprefix || message.20
  1514.            Call Display_Log_Msg msgdata, parm.i
  1515.            return 4
  1516.          end
  1517.       end
  1518.    end
  1519.    return 0
  1520.  
  1521.  
  1522.  
  1523. Determine_Installed_OS2_Levels:
  1524.    syslevel = '\OS2\INSTALL\SYSLEVEL.OS2'
  1525.    If File_Exist(rpldir'\OS2'syslevel) = 1 Then os213 = 1
  1526.    else os213 = 0
  1527.  
  1528.    If File_Exist(rpldir'\OS2.20'syslevel) = 1 Then os220 = 1
  1529.    else os220 = 0
  1530.  
  1531.    If File_Exist(rpldir'\OS2.20a'syslevel) = 1 Then os220a = 1
  1532.    else os220a = 0
  1533.  
  1534.    If File_Exist(rpldir'\OS2.21'syslevel) = 1 Then os221 = 1
  1535.    else os221 = 0
  1536.    return
  1537.  
  1538.  
  1539. /* Subroutine Syntax_Help */
  1540. /* This subroutine displays the syntax help panel. */
  1541. Syntax_Help:
  1542.   If Logfile = '' Then Do
  1543.      'CLS'
  1544.      syntaxhelpflag = 1
  1545.      maxmsglines = 22
  1546.      nummsglines = 0
  1547.      Do i = 40 to 50
  1548.         Call Display_Log_Msg message.i, ''
  1549.      end
  1550.      exit
  1551.   end
  1552.   else Do
  1553.      Call Display_Log_Msg message.21, p1, p2, p3, p4, p5, p6, p7, p8
  1554.      Call Error_Exit
  1555.   end
  1556.  
  1557.  
  1558.  
  1559.  
  1560. Initialize_NLS_Messages:
  1561.    /* call RPLNLMSG to stack all NLS messages in queue in FIFO order */
  1562.    Call RPLSDMSG.CMD 1
  1563.  
  1564.    /* extract messages from queue and assign to appropriate message string */
  1565.    Pull errprefix
  1566.    Pull unknown
  1567.    do i = 1 to 50
  1568.       Parse Pull message.i
  1569.    end
  1570.  
  1571.    /* make sure nothing else is left in queue */
  1572.    do while queued()
  1573.       Pull dummy
  1574.    end
  1575. return
  1576.