home *** CD-ROM | disk | FTP | other *** search
/ IBM Presents OS/2 Software Hits 1995 / OS-2_SW_HITS_2ND_EDITION_1995.ISO / i17 / pmx20c2.exe / PMXC2.ZIP / BIN / resetPCF.CMD < prev    next >
OS/2 REXX Batch file  |  1994-10-21  |  8KB  |  228 lines

  1. /*   
  2.  * gimmePCF.cmd - This is a utility REXX exec that restores the miscPCF and/or
  3.  * 75dpiPCF font directories to misc and 75dpi respectively.  This is done via
  4.  * a rename, therefor the contents of miscPCF and 75dpiPCF should be maintained.
  5.  * If the Japanese and/or Korean .pcf fonts are found in the current misc font
  6.  * directory, they will be maintained in the restored misc font dir.  mkfontdir
  7.  * will be run in the restored misc and 75dpi directory.  
  8.  * This version checks that XFILES environment variable has been
  9.  * set up properly and both TCPBASE and TCPPMX have already been installed.
  10.  */
  11. 'ECHO OFF'
  12. XFILES = envvarcheck('XFILES')
  13. ETC = envvarcheck('ETC')
  14.  
  15. X11PATH=filespec("path",XFILES)
  16. if substr(X11PATH, length(X11PATH), 1) = '\' then
  17.     X11PATH = substr(X11PATH, 1, length(X11PATH) - 1)
  18. X11BASE=filespec("drive",XFILES)||X11PATH
  19. /*
  20.     Assume X11BASE and BASE are the same for now. Eventually we may want to
  21.     allow them to be different.  I.e. look down the PATH variable for
  22.     the BIN files, the LIBPATH for the DLLs, and so on.
  23.     Better yet, prompt the user for an optional change and then check to find
  24.     the files that we should update.
  25. */
  26. BASE = X11BASE
  27.  
  28. arg arglist
  29. progname = "resetPCF.cmd"
  30. do forever
  31.     parse var arglist nextarg arglist
  32.     select
  33.     when nextarg = '-Y' then 
  34.         leave
  35.     when (nextarg = '-?' | nextarg = "?") then do
  36.         'cls'
  37.         say " "
  38.         say progname "- This is a  REXX exec that restores the "
  39.         say X11BASE'\X11\miscPCF' " font directory to " X11BASE'X11\MISC'
  40.         say X11BASE'\X11\75dpiPCF' "font directory to  "X11BASE'\X11\75DPI'
  41.         say " "
  42.         say "This is done via a rename, therefore the contents of miscPCF "
  43.         say "and 75dpiPCF should be maintained. The current misc and 75dpi "
  44.         say "directories will be DELETED!"
  45.         say "If the Japanese and/or Korean .pcf (DBCS) fonts are found in "
  46.         say "the current misc font directory,  they will be maintained in "
  47.         say "the  restored  misc font dir.  mkfontdr  will be  run in the "
  48.         say "restored misc and 75dpi directories.  "
  49.         say " WARNING: Any modifications to fonts.ali or fonts added to "
  50.         say "    either misc or 75dpi will be lost!                     "
  51.         exit 1
  52.         end
  53.     when nextarg = "" then
  54.         leave
  55.     otherwise do
  56.         'cls'
  57.         say " "
  58.         say progname "- This is a  REXX exec that restores the "
  59.         say X11BASE'\X11\miscPCF' " font directory to " X11BASE'X11\MISC'
  60.         say X11BASE'\X11\75dpiPCF' "font directory to  "X11BASE'\X11\75DPI'
  61.         say " "
  62.         say "This is done via a rename, therefore the contents of miscPCF "
  63.         say "and 75dpiPCF should be maintained. The current misc and 75dpi "
  64.         say "directories will be DELETED!"
  65.         say "If the Japanese and/or Korean .pcf (DBCS) fonts are found in "
  66.         say "the current misc font directory,  they will be maintained in "
  67.         say "the  restored  misc font dir.  mkfontdr  will be  run in the "
  68.         say "restored misc and 75dpi directories.  "
  69.         say " WARNING: Any modifications to fonts.ali or fonts added to "
  70.         say "    either misc or 75dpi will be lost!                     "
  71.         exit 1
  72.         end
  73.     end /* select */
  74. end
  75.  
  76. /* Note that calls to direxist leaves the drive in the directory
  77.  * arg passed, if it exists.  A 'CD' is necessary after calling
  78.  * direxist, if a RENAME or RD will be performed.
  79.  */
  80. call dircheck X11BASE'\X11\MISC'
  81. if (direxist(X11BASE'\X11\MISCPCF')) then do
  82.    'CD' X11BASE
  83.    'RENAME' X11BASE'\X11\MISC' MISCDEL
  84.     if rc \= 0 then
  85.        call bailout("RENAME" X11BASE'\X11\MISC')
  86.    'RENAME' X11BASE'\X11\MISCPCF' MISC
  87.     if rc \= 0 then
  88.        call bailout("RENAME" X11BASE'\X11\MISCPCF')
  89.  
  90.     /* move the Asian DBCS fonts, if present */
  91.     moverc = 0
  92.     if fileexists(X11BASE'\x11\MISCDEL\jiskan16.pcf') then do
  93.         'MOVE' X11BASE'\x11\MISCDEL\jiskan16.pcf' X11PATH'\x11\misc'
  94.         moverc = moverc + rc
  95.         end
  96.     if fileexists(X11BASE'\x11\MISCDEL\jiskan24.pcf') then do
  97.         'MOVE' X11BASE'\x11\MISCDEL\jiskan24.pcf' X11PATH'\x11\misc'
  98.         moverc = moverc + rc
  99.         end
  100.     if fileexists(X11BASE'\x11\MISCDEL\k14.pcf')  then do
  101.         'MOVE' X11BASE'\x11\MISCDEL\k14.pcf' X11PATH'\x11\misc'
  102.         moverc = moverc + rc
  103.         end
  104.     if fileexists(X11BASE'\x11\MISCDEL\hanglg16.pcf') then do
  105.         'MOVE' X11BASE'\x11\MISCDEL\hanglg16.pcf' X11PATH'\x11\misc'
  106.         moverc = moverc + rc
  107.         end
  108.     if fileexists(X11BASE'\x11\MISCDEL\hanglm16.pcf') then do
  109.         'MOVE' X11BASE'\x11\MISCDEL\hanglm16.pcf' X11PATH'\x11\misc'
  110.         moverc = moverc + rc
  111.         end
  112.     if fileexists(X11BASE'\x11\MISCDEL\hanglm24.pcf') then do
  113.         'MOVE' X11BASE'\x11\MISCDEL\hanglm24.pcf' X11PATH'\x11\misc'
  114.         moverc = moverc + rc
  115.         end
  116.     if moverc \= 0 then
  117.        call bailout("MOVE" X11BASE'\X11\MISCDEL')
  118.    'ERASE /N' X11BASE'\X11\MISCDEL\*.*'
  119.    'RD' X11BASE'\X11\MISCDEL'
  120.     if rc \= 0 then
  121.        call bailout("RD" X11BASE'\X11\MISCDEL')
  122.    call buildfontsdir 'misc'
  123.    end
  124. else do
  125.    say " WARNING!! " X11BASE'\X11\MISCPCF' "not found.  No action taken."
  126.    end
  127.  
  128. call dircheck X11BASE'\X11\75DPI'
  129. if (direxist(X11BASE'\X11\75DPIPCF')) then do
  130.    'CD' X11BASE
  131.    'RENAME' X11BASE'\X11\75DPI' 75DPIDEL
  132.     if rc \= 0 then
  133.        call bailout("RENAME" X11BASE'\X11\75DPI')
  134.    'RENAME' X11BASE'\X11\75DPIPCF' 75DPI
  135.     if rc \= 0 then
  136.        call bailout("RENAME" X11BASE'\X11\75DPIPCF')
  137.    'ERASE /N' X11BASE'\X11\75DPIDEL\*.*'
  138.    'RD' X11BASE'\X11\75DPIDEL'
  139.     if rc \= 0 then
  140.        call bailout("RD" X11BASE'\X11\75DPIDEL')
  141.    call buildfontsdir '75dpi'
  142.    end
  143. else do
  144.    say " WARNING!! " X11BASE'\X11\75DPIPCF' "not found.  No action taken."
  145.    end
  146. return
  147. /* --------------end main program--------------------- */
  148.  
  149. envvarcheck: procedure
  150. arg envvar
  151. ENV = 'OS2ENVIRONMENT'
  152. retvar = VALUE(envvar,,ENV)
  153. if retvar = '' then
  154.     do
  155.     call beep 524,200
  156.     call beep 440,250
  157.     say ""
  158.     say "WARNING!"
  159.     say "You do NOT have the environment variable" envvar "defined!"
  160.     say "You already should have installed the OS/2 TCP/IP 2.0 base"
  161.     say "or its equivalent, and you already should have installed"
  162.     say "the X Window System option.  This update package only provides"
  163.     say "changes and additions to the already installed product."
  164.     say "Installation will not continue!"
  165.     say ""
  166.     exit 1
  167.     end
  168. return retvar
  169.  
  170. fileexists: procedure
  171. arg file
  172. progname = STREAM(file, 'C', 'QUERY EXISTS')
  173. return progname \= ''
  174.  
  175. direxist: procedure
  176. arg dir
  177. curdir = directory()
  178. newdir = directory(dir)
  179. call directory(curdir)
  180. return newdir \= ''
  181.  
  182. dircheck: procedure
  183. arg dir
  184. curdir = directory()
  185. newdir = directory(dir)
  186. call directory(curdir)
  187. if newdir \= '' then
  188.     do
  189.     return newdir
  190.     end
  191. else
  192.     do
  193.     call beep 524,200
  194.     call beep 440,250
  195.     say ""
  196.     say "Directory '"dir"' could not be found even though the XFILES"
  197.     say "environment variable is defined as '"XFILES"'!"
  198.     say "The directory was supposed to be created when the TCP/IP 2.0"
  199.     say "base and X Window System 2.0 option were installed."
  200.     say "Installation is terminated!"
  201.     exit 1
  202.     end
  203.  
  204. buildfontsdir: procedure expose X11BASE
  205. arg dir
  206. /* build the fonts.dir in the x11\dir directory. */
  207. /* save the user's current directory */
  208. currentdir = directory()
  209. /* make dir font directory the current one */
  210. call directory X11BASE'\X11\'dir
  211. say "Making a new fonts.dir file in "X11BASE"\X11\"dir "directory..."
  212. X11BASE'\bin\mkfontdr'
  213. /* restore the user's current directory */
  214. call directory(currentdir)
  215. return
  216.  
  217. bailout: procedure
  218. arg arglist
  219. parse var arglist operation dir
  220. /* This proc is called to report a failure of 'operation' */
  221. /* performed with 'dir' as its parameter. */
  222. /* Write the message, if not CID, pause.  Then exit */
  223. say operation "FAILURE on directory" dir
  224. say "Ensure no other process is using the directory."
  225. say "Install is ABORTING."
  226. pause
  227. exit 1
  228.