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

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