home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / rplrxset.zip / rplrxset.cmd
OS/2 REXX Batch file  |  1996-02-20  |  18KB  |  554 lines

  1. /**2/REXX*********************************************************************/
  2. /* Function Name: RPLRXSET                                                   */
  3. /*****************************************************************************/
  4. /* Function Description:                                                     */
  5. /*                                                                           */
  6. /* This routine will set information for a specific RIPL client using        */
  7. /* the RxNetSetRIPLMachineInfo API call.                                     */
  8. /*****************************************************************************/
  9. /* Example:                                                                  */
  10. /*                                                                           */
  11. /* RPLRXSET /L:2A /M:A_MACH /A:123456789ABC /R:R_21_OTK /B:Z /C:D            */
  12. /*****************************************************************************/
  13. /* Algorithm:                                                                */
  14. /*                                                                           */
  15. /* begin rplrxset                                                            */
  16. /* |>if there are no input parameters then display the syntax                */
  17. /* |>load and verify input parameters                                        */
  18. /* |>call RxNetSetRIPLMachineInfo API                                        */
  19. /* |>exit with resulting return code                                         */
  20. /* end rplrxset                                                              */
  21. /*****************************************************************************/
  22. /* trace ?i */
  23. if arg() = 0 then
  24. do
  25.   say 'Set RIPL Machine Information--Command Syntax:'
  26.   say 'RPLRXSET /L: /M: /A: /R: {(/B: & /C:) | /I:} [/S: /D:]'
  27.   say '/L: Level of structure to update(1,2A,2S)'
  28.   say '    1 ->change description field for level 1 structure'
  29.   say '    2A->change All fields for level 2 structure'
  30.   say '    2S->change a Single field for level 2 structure'
  31.   say '/M: OS/2 Machine ID(<= 15) or DOS Machine ID(<= 8)'
  32.   say '/A: hex network adapter Address(12)'
  33.   say '/R: server Record ID(<= 40)'
  34.   say '/B: OS/2 remote IPL Boot drive ID(C-Z)'
  35.   say '/C: OS/2 Configuration flags(<= 3)'
  36.   say '    L->Local swapper file  |E->Ega display'
  37.   say '    S->Server swapper file |U->sUper vga display'
  38.   say '    I->Isa bus             |V->Vga display'
  39.   say '    M->Microchannel bus    |X->Xga display'
  40.   say '    3->s3 super vga display|D->Default flags->LMV'
  41.   say '    8->8514 display        |'
  42.   say '/I: DOS Image ID(<= 8)'
  43.   say '/S: remote IPL Server name(<= 15)'
  44.   say '/D: Description-cannot include blanks(<= 40)'
  45.   exit 0
  46. end
  47. Call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
  48. Call SysLoadFuncs
  49. call RxFuncAdd 'RxRegRIPLFuncs', 'RXRPLEXT', 'RXREGRIPLFUNCS'
  50. call RxRegRIPLFuncs
  51. /*****************************************************************************/
  52. /* initialize variables                                                      */
  53. /*****************************************************************************/
  54. rc               = 0
  55. level            = ''
  56. mach_id          = ''
  57. adap_add         = ''
  58. os2_srid         = ''
  59. dos_srid         = ''
  60. boot_drv         = ''
  61. cfg_flgs         = ''
  62. cfg_flgs_raw     = ''
  63. cfg_flgs_raw_len = 0
  64. dos_image        = ''
  65. ripl_svr         = ''
  66. description      = ''
  67. OS2              = 0
  68. /*****************************************************************************/
  69. /* load and verify parameters                                                */
  70. /*****************************************************************************/
  71. arg p.0 p.1 p.2 p.3 p.4 p.5 p.6 p.7 p.8
  72. if p.8 <> '' then
  73. do
  74.   rc = 8
  75.   call error
  76. end
  77. do i = 0 to 7
  78.   if p.i <> '' then
  79.   do
  80.     sep_pos = pos(':', p.i)
  81.     if sep_pos = 0 then
  82.     do
  83.       rc = 19
  84.       call error
  85.     end
  86.     parm_sec     = sep_pos - 1
  87.     parm         = substr(p.i, 1, parm_sec)
  88.     parm_val_sec = length(p.i) - sep_pos
  89.     parm_val     = substr(p.i, sep_pos+1, parm_val_sec)
  90.     if      parm = '/L' then
  91.     do
  92.       if (parm_val <> '1') & (parm_val <> '2A') & (parm_val <> '2S') then
  93.       do
  94.         rc = 20
  95.         call error
  96.       end
  97.       level = parm_val
  98.       if pos('1', level) <> 0 then
  99.         true_level = 1
  100.       else
  101.         true_level = 2
  102.     end
  103.     else if parm = '/M' then
  104.     do
  105.       if length(parm_val) > 15 then
  106.       do
  107.         rc = 12
  108.         call error
  109.       end
  110.       mach_id = parm_val
  111.     end
  112.     else if parm = '/A' then
  113.     do
  114.       if length(parm_val) <> 12 then
  115.       do
  116.         rc = 13
  117.         call error
  118.       end
  119.       adap_add = parm_val
  120.     end
  121.     else if parm = '/R' then
  122.     do
  123.       if length(parm_val) > 40 then
  124.       do
  125.         rc = 14
  126.         call error
  127.       end
  128.       if pos('R_D', parm_val) = 0 then
  129.       do
  130.         OS2 = 1
  131.         os2_srid = parm_val
  132.       end
  133.       else
  134.         dos_srid = parm_val
  135.     end
  136.     else if parm = '/B' then
  137.     do
  138.       if (length(parm_val) > 1) | (parm_val < 'C') | (parm_val > 'Z') then
  139.       do
  140.         rc = 9
  141.         call error
  142.       end
  143.       boot_drv = parm_val
  144.     end
  145.     else if parm = '/C' then
  146.     do
  147.       cfg_flgs_raw_len = length(parm_val)
  148.       if cfg_flgs_raw_len > 3 then
  149.       do
  150.         rc = 6
  151.         call error
  152.       end
  153.       cfg_flgs_raw = parm_val
  154.     end
  155.     else if parm = '/I' then
  156.     do
  157.       if length(parm_val) > 8 then
  158.       do
  159.         rc = 15
  160.         call error
  161.       end
  162.       dos_image = parm_val
  163.     end
  164.     else if parm = '/S' then
  165.     do
  166.       if length(parm_val) > 15 then
  167.       do
  168.         rc = 16
  169.         call error
  170.       end
  171.       ripl_svr = '\\' || parm_val
  172.     end
  173.     else if parm = '/D' then
  174.     do
  175.       if length(parm_val) > 40 then
  176.       do
  177.         rc = 4
  178.         call error
  179.       end
  180.       description = parm_val
  181.     end
  182.     else
  183.     do
  184.       rc = 17
  185.       call error
  186.     end
  187.   end
  188. end
  189. /*****************************************************************************/
  190. /* level 2--specify all parameters                                           */
  191. /*****************************************************************************/
  192. if level = '2A' then
  193. do
  194. /*****************************************************************************/
  195. /* level 2--OS/2 RIPL client                                                 */
  196. /*****************************************************************************/
  197.   if OS2 = 1 then
  198.   do
  199.     if (mach_id = '') | (adap_add = '') | (os2_srid = '') | (boot_drv = '') | ,
  200.        (cfg_flgs_raw = '') then
  201.     do
  202.       rc = 5
  203.       call error
  204.     end
  205.     if (dos_image <> '') | (dos_srid <> '') then
  206.     do
  207.       rc = 21
  208.       call error
  209.     end
  210.     cfg_flgs = 'OS2_SWAPPER_LOCAL'
  211.     slot1    = 0
  212.     slot2    = 0
  213.     slot3    = 0
  214. /*****************************************************************************/
  215. /* are the default OS/2 configuration flags specified with the default flag  */
  216. /*****************************************************************************/
  217.     slot = pos('D', cfg_flgs_raw)
  218.     if slot <> 0 then
  219.     do
  220.       call slot_proc
  221.     end
  222.     else
  223.     do
  224.       swapper  = 0
  225.       bus      = 0
  226.       display  = 0
  227. /*****************************************************************************/
  228. /* is a local swapper file specified                                         */
  229. /*****************************************************************************/
  230.       slot = pos('L', cfg_flgs_raw)
  231.       if slot <> 0 then
  232.       do
  233.         swapper = 1
  234.         call slot_proc
  235.       end
  236. /*****************************************************************************/
  237. /* is a remote swapper file specified                                        */
  238. /*****************************************************************************/
  239.       slot = pos('S', cfg_flgs_raw)
  240.       if slot <> 0 then
  241.       do
  242.         if swapper = 1 then
  243.         do
  244.           rc = 1
  245.           call error
  246.         end
  247.         cfg_flgs = 'OS2_SWAPPER_SERVER'
  248.         call slot_proc
  249.       end
  250. /*****************************************************************************/
  251. /* is an ISA bus specified                                                   */
  252. /*****************************************************************************/
  253.       slot = pos('I', cfg_flgs_raw)
  254.       if slot <> 0 then
  255.       do
  256.         bus = 1
  257.         cfg_flgs = cfg_flgs || '|' || 'OS2_BUS_ISA'
  258.         call slot_proc
  259.       end
  260. /*****************************************************************************/
  261. /* is a microchannel bus specified                                           */
  262. /*****************************************************************************/
  263.       slot = pos('M', cfg_flgs_raw)
  264.       if slot <> 0 then
  265.       do
  266.         if bus = 1 then
  267.         do
  268.           rc = 2
  269.           call error
  270.         end
  271.         call slot_proc
  272.       end
  273. /*****************************************************************************/
  274. /* is a VGA display type specified                                           */
  275. /*****************************************************************************/
  276.       slot = pos('V', cfg_flgs_raw)
  277.       if slot <> 0 then
  278.       do
  279.         display = 1
  280.         call slot_proc
  281.       end
  282. /*****************************************************************************/
  283. /* is an S3 super VGA display specified                                      */
  284. /*****************************************************************************/
  285.       slot = pos('3', cfg_flgs_raw)
  286.       if slot <> 0 then
  287.       do
  288.         display = 1
  289.         cfg_flgs = cfg_flgs || '|' || 'OS2_DISPLAY_S3SVGA'
  290.         call slot_proc
  291.       end
  292. /*****************************************************************************/
  293. /* is an 8514 display specified                                              */
  294. /*****************************************************************************/
  295.       slot = pos('8', cfg_flgs_raw)
  296.       if slot <> 0 then
  297.       do
  298.         if display = 1 then
  299.         do
  300.           rc = 3
  301.           call error
  302.         end
  303.         display = 1
  304.         cfg_flgs = cfg_flgs || '|' || 'OS2_DISPLAY_IBM8514'
  305.         call slot_proc
  306.       end
  307. /*****************************************************************************/
  308. /* is an EGA display specified                                               */
  309. /*****************************************************************************/
  310.       slot = pos('E', cfg_flgs_raw)
  311.       if slot <> 0 then
  312.       do
  313.         if display = 1 then
  314.         do
  315.           rc = 3
  316.           call error
  317.         end
  318.         display = 1
  319.         cfg_flgs = cfg_flgs || '|' || 'OS2_DISPLAY_IBMEGA'
  320.         call slot_proc
  321.       end
  322. /*****************************************************************************/
  323. /* is a super VGA display specified                                          */
  324. /*****************************************************************************/
  325.       slot = pos('U', cfg_flgs_raw)
  326.       if slot <> 0 then
  327.       do
  328.         if display = 1 then
  329.         do
  330.           rc = 3
  331.           call error
  332.         end
  333.         display = 1
  334.         cfg_flgs = cfg_flgs || '|' || 'OS2_DISPLAY_SVGA'
  335.         call slot_proc
  336.       end
  337. /*****************************************************************************/
  338. /* is an XGA display specified                                               */
  339. /*****************************************************************************/
  340.       slot = pos('X', cfg_flgs_raw)
  341.       if slot <> 0 then
  342.       do
  343.         if display = 1 then
  344.         do
  345.           rc = 3
  346.           call error
  347.         end
  348.         display = 1
  349.         cfg_flgs = cfg_flgs || '|' || 'OS2_DISPLAY_IBMXGA32'
  350.         call slot_proc
  351.       end
  352.     end
  353. /*****************************************************************************/
  354. /* are there any invalid OS/2 configuration flags specified                  */
  355. /*****************************************************************************/
  356.     if ((cfg_flgs_raw_len = 3) & ((slot1 = 0) | (slot2 = 0) | (slot3 = 0))) | ,
  357.        ((cfg_flgs_raw_len = 2) & ((slot1 = 0) | (slot2 = 0))) | ,
  358.        ((cfg_flgs_raw_len = 1) & (slot1 = 0)) then
  359.     do
  360.       rc = 7
  361.       call error
  362.     end
  363.   end
  364. /*****************************************************************************/
  365. /* level 2--DOS RIPL client                                                  */
  366. /*****************************************************************************/
  367.   else
  368.   do
  369.     if p.7 <> '' then
  370.     do
  371.       rc = 8
  372.       call error
  373.     end
  374.     if (mach_id = '') | (adap_add = '') | (dos_srid = '') | ,
  375.        (dos_image = '') then
  376.     do
  377.       rc = 5
  378.       call error
  379.     end
  380.     if (os2_srid <> '') | (boot_drv <> '') | (cfg_flgs_raw <> '') then
  381.     do
  382.       rc = 21
  383.       call error
  384.     end
  385.     if length(mach_id) > 8 then
  386.     do
  387.       rc = 18
  388.       call error
  389.     end
  390.   end
  391.   call RxNetSetRIPLMachineInfo ripl_svr, true_level, 0, mach_id, description, ,
  392.                                adap_add, boot_drv, dos_image, dos_srid, ,
  393.                                os2_srid, cfg_flgs
  394. end
  395. /*****************************************************************************/
  396. /* level 2--specify a single parameter                                       */
  397. /*****************************************************************************/
  398. else if level = '2S' then
  399. do
  400.   if (p.4 <> '') | ((p.3 <> '') & (ripl_svr = '')) then
  401.   do
  402.     rc = 8
  403.     call error
  404.   end
  405.   if mach_id = '' then
  406.   do
  407.     rc = 5
  408.     call error
  409.   end
  410.   if      description <> '' then
  411.   do
  412.     var_parameter = description
  413.     parm_num = 2
  414.   end
  415.   else if adap_add    <> '' then
  416.   do
  417.     var_parameter = adap_add
  418.     parm_num = 3
  419.   end
  420.   else if boot_drv    <> '' then
  421.   do
  422.     var_parameter = boot_drv
  423.     parm_num = 5
  424.   end
  425.   else if dos_image   <> '' then
  426.   do
  427.     var_parameter = dos_image
  428.     parm_num = 7
  429.   end
  430.   else if dos_srid    <> '' then
  431.   do
  432.     var_parameter = dos_srid
  433.     parm_num = 9
  434.   end
  435.   else if os2_srid    <> '' then
  436.   do
  437.     var_parameter = os2_srid
  438.     parm_num = 10
  439.   end
  440.   else
  441.   do
  442.     rc = 5
  443.     call error
  444.   end
  445.   call RxNetSetRIPLMachineInfo ripl_svr, true_level, parm_num, mach_id, ,
  446.                                var_parameter
  447. end
  448. /*****************************************************************************/
  449. /* verify level 1 parameters                                                 */
  450. /*****************************************************************************/
  451. else if level = '1' then
  452. do
  453.   if (p.4 <> '') | ((p.3 <> '') & (ripl_svr = '')) then
  454.   do
  455.     rc = 8
  456.     call error
  457.   end
  458.   if (mach_id = '') | (description = '') then
  459.   do
  460.     rc = 5
  461.     call error
  462.   end
  463.   call RxNetSetRIPLMachineInfo ripl_svr, true_level, 0, mach_id, description
  464. end
  465. else
  466. do
  467.   rc = 5
  468.   call error
  469. end
  470. if RESULT <> 0 then
  471. do
  472.   if RESULT < 2100 then
  473.     msg = SysGetMessage(RESULT)
  474.   else
  475.     msg = SysGetMessage(RESULT, 'NET.MSG')
  476.   say msg
  477.   exit RESULT
  478. end
  479. say 'the specified RIPL client was updated successfully'
  480. exit 0
  481. /*****************************************************************************/
  482. /* this routine displays the appropriate error message then exits            */
  483. /*****************************************************************************/
  484. error:
  485. if      rc = 1 then
  486.   say 'a machine cannot have a local swapper file and a remote swapper file'
  487. else if rc = 2 then
  488.   say 'a machine cannot have a microchannel bus and an ISA bus'
  489. else if rc = 3 then
  490.   say 'a machine can have only one type of display'
  491. else if rc = 4 then
  492. do
  493.   say 'the value specified for the description parameter is more than 40'
  494.   say 'characters in length'
  495. end
  496. else if rc = 5 then
  497.   say 'at least one of the necessary parameters was not specified'
  498. else if rc = 6 then
  499. do
  500.   say 'the OS/2 configuration flags value is greater than 3 characters'
  501.   say 'in length'
  502. end
  503. else if rc = 7 then
  504. do
  505.   say 'an incorrect flag was used as part of the OS/2 configuration flags'
  506.   say 'value or a flag was repeated in the OS/2 configuration flags value'
  507. end
  508. else if rc = 8 then
  509.   say 'an incorrect number of parameters was specified'
  510. else if rc = 9 then
  511. do
  512.   say 'the OS/2 boot drive value should be 1 alphabetic character in the range'
  513.   say 'from C to Z inclusive'
  514. end
  515. else if rc = 12 then
  516.   say 'the machine ID specified is more than 15 characters in length'
  517. else if rc = 13 then
  518.   say 'the adapter address specified is not exactly 12 characters in length'
  519. else if rc = 14 then
  520.   say 'the server record ID specified is more than 40 characters in length'
  521. else if rc = 15 then
  522. do
  523.   say 'the DOS image ID value specified is more than 8 characters in'
  524.   say 'length'
  525. end
  526. else if rc = 16 then
  527. do
  528.   say 'the remote IPL server name specified is more than 15 characters in'
  529.   say 'length'
  530. end
  531. else if rc = 17 then
  532.   say 'an invalid parameter was specified'
  533. else if rc = 18 then
  534.   say 'the DOS machine ID specified is more than 8 characters in length'
  535. else if rc = 19 then
  536.   say 'a parameter was specified with an invalid format'
  537. else if rc = 20 then
  538.   say 'an incorrect value was specified for the level(/L:) parameter'
  539. else if rc = 21 then
  540.   say 'DOS and OS/2 parameters were specified resulting in a conflict'
  541. exit rc
  542. /*****************************************************************************/
  543. /* this routine ensures that every OS/2 configuration flag specified is      */
  544. /* accounted for                                                             */
  545. /*****************************************************************************/
  546. slot_proc:
  547. if      slot = 1 then
  548.   slot1 = 1
  549. else if slot = 2 then
  550.   slot2 = 1
  551. else if slot = 3 then
  552.   slot3 = 1
  553. return
  554.