home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 8 Other / 08-Other.zip / mmfix11.zip / MMFIX.CMD < prev    next >
OS/2 REXX Batch file  |  1997-09-15  |  8KB  |  337 lines

  1. /*********************************************************************/
  2. /*                                                                   */
  3. /*  MMFIX.CMD - version 1.1                                          */
  4. /*  Copyright (C) R L Walsh 1997 - All Rights Reserved               */
  5. /*                                                                   */
  6. /*  email the author at rlwalsh@packet.net                           */
  7. /*                                                                   */
  8. /*********************************************************************/
  9.  
  10. call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
  11. call SysLoadFuncs
  12. address cmd
  13.  
  14. /* show the intro message */
  15.  
  16. say ''
  17. say ' **********************************************************'
  18. say ' *  MMFIX.CMD - version 1.1                               *'
  19. say ' *  Copyright (C) R L Walsh 1997 - All Rights Reserved    *'
  20. say ' *                                                        *'
  21. say ' *  email the author at rlwalsh@packet.net                *'
  22. say ' **********************************************************'
  23. say ''
  24. say ' MMFIX lets you deregister selected WPS Multimedia classes'
  25. say ' without having to deregister all of them.  It will make a'
  26. say ' copy of MMPARTS.DLL and patch it.  You will have to edit'
  27. say ' config.sys, then run MMDEREG.CMD.  This version supports'
  28. say ' Warp v4 GA, or v4 with Fixpack 1 or Fixpack 3 applied'
  29. say ''
  30. say ' Do you want to continue?  If yes, press "Y" then "Enter"'
  31.  
  32. pull answer
  33. if left( strip(answer), 1) \= 'Y' then
  34.     do
  35.         say ' Aborting...'
  36.         exit
  37.     end
  38.  
  39. /* get source and target info */
  40.  
  41. basedir = GetBaseDir()
  42. srcfile = GetSrcFile(basedir)
  43. destdir = GetDestDir(basedir)
  44.  
  45. /* copy the dll */
  46.  
  47. '@copy /b' srcfile '> NUL'
  48.  
  49. if rc \= 0 then
  50.     do
  51.         say ' Error!  Unable to copy' srcfile 'to' destdir
  52.         say ' Aborting...'
  53.         exit
  54.     end
  55.  
  56. /* figure out which version we're patching */
  57.  
  58. patchfil = 'patchmm.fil'
  59. version = GetVersion(patchfil)
  60.  
  61. say ''
  62. if version = 23 then
  63.     say ' Patching Warp v4 with no fixpacks'
  64. else
  65. if version = 24 then
  66.     say ' Patching Warp v4 with Fixpack 1'
  67. else
  68. if version = 27 then
  69.     say ' Patching Warp v4 with Fixpack 3'
  70. else
  71. do
  72.     say ' Error!  This version of MMPARTS.DLL is not supported.'
  73.     say ' MMFIX only supports Warp v4 with no fixpacks or with'
  74.     say ' Fixpacks 1 or 3.  Read README.FIX for instructions on'
  75.     say ' how to patch your version manually.  Aborting...'
  76.     exit
  77. end
  78.  
  79. /* create a patch file for the appropriate version */
  80.  
  81. call BuildPatchFile patchfil, version
  82.  
  83. /* do it, then get the result */
  84.  
  85. '@patch' patchfil '/a | RXQUEUE'
  86. pull ok
  87. say ' ' || ok
  88. say ''
  89.  
  90. /* display result */
  91.  
  92. if ok = 'PATCHES APPLIED TO MMPARTS.DLL' then
  93.     do
  94.         say ' Now, edit config.sys and add "' || destdir || '"'
  95.         say ' to the LIBPATH *before* "' || basedir || '\DLL"'
  96.         say ' e.g.  LIBPATH=F:\MMOS2\TEMPDLL;.;F:\OS2\DLL;F:\MMOS2\DLL;'
  97.         say ''
  98.         say ' When you are done, run MMDEREG.CMD, then reboot'
  99.     end
  100. else
  101. if (left(ok,7) = 'SYS1595') & (IsFilePatched(patchfil, version)) then
  102.     do
  103.         say ' Error!  You did not need to run MMFIX because'
  104.         say ' ' || srcfile 'already has this patch!'
  105.         say ' You can run MMDEREG.CMD at any time.'
  106.     end
  107. else
  108.     do
  109.         say ' Error!  The patch failed for unknown reasons.'
  110.         say ' Aborting...'
  111.     end
  112.  
  113. say ''
  114.  
  115. /* main exit */
  116.  
  117. exit
  118.  
  119. /*********************************************************************/
  120.  
  121. GetBaseDir: procedure
  122.  
  123. base = value('MMBASE',,'OS2ENVIRONMENT')
  124.  
  125. if base = '' then
  126.     do
  127.         say ''
  128.         say ' Enter the path for your MMOS2 directory,'
  129.         say ' then press "Enter" (leave blank to quit)'
  130.         say ' e.g.  C:\MMOS2'
  131.         pull answer
  132.         base = strip(answer)
  133.         if base = '' then
  134.             do
  135.                 say ''
  136.                 say ' Nothing entered.  Aborting...'
  137.                 exit
  138.             end
  139.     end
  140.  
  141. base = strip(base, T, ';')
  142. base = strip(base, T, '\')
  143.  
  144. return base
  145.  
  146. /*********************************************************************/
  147.  
  148. GetSrcFile: procedure
  149.  
  150. ARG base
  151.  
  152. src = base || '\DLL\MMPARTS.DLL'
  153.  
  154. ok = stream( src, 'c', 'query exists')
  155. if ok = '' then
  156.     do
  157.         say ' Error!  Unable to locate' src
  158.         say ' Aborting...'
  159.         exit
  160.     end
  161.  
  162. return src
  163.  
  164. /*********************************************************************/
  165.  
  166. GetDestDir: procedure
  167.  
  168. ARG base
  169.  
  170. dest = base || '\TEMPDLL'
  171.  
  172. rc = SysMkDir(dest)
  173.  
  174. if (rc \= 0) & (rc \= 5) then
  175.     do
  176.         say ' Error!  Unable to create' dest
  177.         say ' Aborting...'
  178.         exit
  179.     end
  180.  
  181. if directory(dest) = '' then
  182.     do
  183.         say ' Error!  Unable to change the directory to' dest
  184.         say ' Aborting...'
  185.         exit
  186.     end
  187.  
  188. return dest
  189.  
  190. /*********************************************************************/
  191.  
  192. GetVersion: procedure
  193.  
  194. ARG filename
  195.  
  196. line. = ''
  197. line.1 = 'FILE MMPARTS.DLL'
  198. line.2 = 'VER 1743BD   402349424D3A392E3233234000'
  199.  
  200. call WritePatchFile
  201. '@patch' filename '/a | RXQUEUE'
  202. pull ok
  203.  
  204. if left(ok,7) = 'SYS1600' then
  205.     return 23
  206.  
  207. if left(ok,7) \= 'SYS1595' then
  208.     return 0
  209.  
  210. line.2 = 'VER 1752ED   402349424D3A392E3234234000'
  211.  
  212. call WritePatchFile
  213. '@patch' filename '/a | RXQUEUE'
  214. pull ok
  215.  
  216. if left(ok,7) = 'SYS1600' then
  217.     return 24
  218.  
  219. if left(ok,7) \= 'SYS1595' then
  220.     return 0
  221.  
  222. line.2 = 'VER 174D85   402349424D3A392E3237234000'
  223.  
  224. call WritePatchFile
  225. '@patch' filename '/a | RXQUEUE'
  226. pull ok
  227.  
  228. if left(ok,7) = 'SYS1600' then
  229.     return 27
  230. else
  231.     return 0
  232.  
  233. /*********************************************************************/
  234.  
  235. BuildPatchFile: procedure
  236.  
  237. ARG filename, ver
  238.  
  239. line. = ''
  240. line.1 = 'FILE MMPARTS.DLL'
  241.  
  242. if ver = 23 then
  243.     do
  244.         line.2 = 'VER 1743BD   402349424D3A392E3233234000'
  245.         line.3 = 'VER 17466E   0D534F4D496E69744D6F64756C6501'
  246.         line.4 = 'CHA 17466E   0D54'
  247.     end
  248. else
  249. if ver = 24 then
  250.     do
  251.         line.2 = 'VER 1752ED   402349424D3A392E3234234000'
  252.         line.3 = 'VER 17559E   0D534F4D496E69744D6F64756C6501'
  253.         line.4 = 'CHA 17559E   0D54'
  254.     end
  255. else
  256. if ver = 27 then
  257.     do
  258.         line.2 = 'VER 174D85   402349424D3A392E3237234000'
  259.         line.3 = 'VER 175036   0D534F4D496E69744D6F64756C6501'
  260.         line.4 = 'CHA 175036   0D54'
  261.     end
  262. else
  263.     do
  264.         say ' Error!  Invalid parameter passed to BuildPatchFile'
  265.         say ' Aborting...'
  266.         exit
  267.     end
  268.  
  269. call WritePatchFile
  270.  
  271. return
  272.  
  273. /*********************************************************************/
  274.  
  275. IsFilePatched: procedure
  276.  
  277. ARG filename, ver
  278.  
  279. line. = ''
  280. line.1 = 'FILE MMPARTS.DLL'
  281.  
  282. if ver = 23 then
  283.     line.2 = 'VER 17466E   0D54'
  284. else
  285. if ver = 24 then
  286.     line.2 = 'VER 17559E   0D54'
  287. else
  288. if ver = 27 then
  289.     line.2 = 'VER 175036   0D54'
  290. else
  291.     do
  292.         say ' Error!  Invalid parameter passed to IsFilePatched'
  293.         say ' Aborting...'
  294.         exit
  295.     end
  296.  
  297. call WritePatchFile
  298. '@patch' filename '/a | RXQUEUE'
  299. pull ok
  300.  
  301. if left(ok,7) = 'SYS1600' then
  302.     return 1
  303. else
  304.     return 0
  305.  
  306. /*********************************************************************/
  307.  
  308. WritePatchFile:
  309.  
  310. rc = SysFileDelete(filename)
  311.  
  312. rc = lineout(filename, line.1, 1)
  313.  
  314. if rc = 0 then
  315.     do
  316.         x = 2
  317.         do while line.x <> ''
  318.             rc = lineout(filename, line.x)
  319.             if rc \= 0 then leave
  320.             x = x + 1
  321.         end
  322.     end
  323.  
  324. rc2 = lineout(filename)
  325.  
  326. if rc \= 0 then
  327.     do
  328.         say ' Error!  Unable to write' filename
  329.         say ' Aborting...'
  330.         exit
  331.     end
  332.  
  333. return
  334.  
  335. /*********************************************************************/
  336.  
  337.