home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: Graphics / Graphics.zip / gif_text.zip / install.cmd < prev    next >
OS/2 REXX Batch file  |  1999-06-23  |  15KB  |  533 lines

  1. /* this is the gif_text addon for  SRE-http installation program */ 
  2.  
  3. /* Load up advanced REXX functions */
  4. call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
  5. call SysLoadFuncs
  6.  
  7. crlf='0d0a'x
  8. copyall=0
  9.  
  10. foo=rxfuncquery('UZLoadFuncs')   /* load UNZIP dll */
  11. if foo=1 then do
  12.   call RxFuncAdd 'UZLoadFuncs', 'UNZIPAPI', 'UZLoadFuncs'
  13.   call UZLoadFuncs
  14. end
  15. zipfoo=rxfuncquery('UZLoadFuncs')   /* load UNZIP dll */
  16. if zipfoo=1  then do
  17.   say " UNZIPAPI.DLL not found. You'll have to do some UnZIPing by hand."
  18. end
  19.  
  20. /*---   Load REXX libraries ----- */
  21. /* Load up advanced REXX functions */
  22. foo=rxfuncquery('sysloadfuncs')
  23. if foo=1 then do
  24.   call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
  25.   call SysLoadFuncs
  26. end
  27. foo=rxfuncquery('rexxlibregister')
  28. if foo=1 then do
  29.  call rxfuncadd 'rexxlibregister','rexxlib', 'rexxlibregister'
  30.  call rexxlibregister
  31. end
  32. foo=rxfuncquery('rexxlibregister')
  33. if foo=1 then do
  34.    say "Caution: could not find REXXLIB (is it in your LIBPATH?) "
  35.    say "(hit ENTER to continue)"
  36.    pull ff
  37. end /* do */
  38.  
  39.  
  40. ansion=checkansi()
  41. if ansion=1 then do
  42.   aesc='1B'x
  43.   cy_ye=aesc||'[37;46;m'
  44.   normal=aesc||'[0;m'
  45.   bold=aesc||'[1;m'
  46.   re_wh=aesc||'[31;47;m'
  47.   reverse=aesc||'[7;m'
  48. end
  49. else do
  50.   say " Warning: Could not detect ANSI....  Install will look ugly ! "
  51.   parse pull .
  52.   cy_ye="" ; normal="" ; bold="" ;re_wh="" ;
  53.   reverse=""
  54. end  /* Do */
  55.  
  56. cls
  57. say  " " ; say
  58.  
  59. call lineout, bold cy_ye
  60. call lineout, "This is the GIF_TEXT (ver 1.3b) installation program (6/99).     "
  61. call lineout, "      (for the SRE-http web server) "
  62. call lineout, normal
  63. call lineout,"      If you are installing GIF_TEXT as a CGI-BIN script, or as a  "
  64. call lineout,'      stand-alone program, please see the "by hand" installation'
  65. call lineout,'      instructions in GIF_TEXT.DOC.'
  66. say "" 
  67. say " This program will ask for the names of a few directories,"
  68. say " and will copy a number of files to these directories."
  69. say "  "
  70.  
  71. if yesno(" Are you ready to continue ")=1 then
  72.  nop
  73. else do
  74.  say " See you later?.. "
  75.  exit
  76. end
  77.  
  78.  
  79. nowdir=directory()
  80.  
  81. godir=filespec('d',nowdir)||'\GOSERVE'
  82. webdir=filespec('d',godir)||'\WWW'
  83.  
  84.  
  85. gunky2:
  86. say " "
  87. call charout,  bold " Enter the GoServe working directory (that contains SREFILTR.80)" normal crlf
  88. call charout,"  ENTER= " godir  " ? "
  89. parse pull work_dir
  90. if work_dir="" then work_Dir=godir
  91. work_dir=strip(work_dir,'t','\')
  92. foo=ais_dir(work_dir)
  93. if foo=0 then do
  94.     say " Could not find directory: " work_dir
  95.     signal gunky2
  96. end
  97. foo=work_dir||'\SREFILTR.80'
  98. if stream(foo,'c','query exists')=' ' then do
  99.    say " Could not find SREFILTR.80.  Please reenter "
  100.    signal gunky2
  101. end  /* Do */
  102.  
  103.  
  104. addondir=work_dir||'\ADDON'
  105. gunky2a:
  106. say " "
  107. call charout,  bold " Enter the SRE-http " normal reverse " addon " normal bold " directory " normal crlf
  108. call charout,"  ENTER= " addondir  " ? "
  109. parse pull addon_dir
  110. if addon_dir="" then addon_Dir=addondir
  111. addon_dir=strip(addon_dir,'t','\')
  112. foo=ais_dir(addon_dir)
  113. if foo=0 then do
  114.     say " Could not find directory: " addon_dir
  115.     signal gunky2a
  116. end
  117.  
  118. gunky3:
  119. say " "
  120. call charout,  bold " Enter a WWW accessible directory (for the GIF_Text HTML documents)" normal crlf
  121. call charout,"  ENTER= " webdir  " ? "
  122. parse pull web_dir
  123. if web_dir="" then web_Dir=webdir
  124. web_dir=strip(web_dir,'t','\')
  125. foo=ais_dir(web_dir)
  126. if foo=0 then do
  127.     say " Could not find directory: " web_dir
  128.     signal gunky3
  129. end
  130.  
  131.  
  132.  
  133. imgdir=web_dir'\IMGS'
  134. gunky3a:
  135. say " "
  136. call charout,  bold " Enter the /IMGS directory or your WWW server (for sample .GIF files)" normal crlf
  137. call charout,"  ENTER= " imgdir  " ? "
  138. parse pull img_dir
  139. if img_dir="" then img_Dir=imgdir
  140. img_dir=strip(img_dir,'t','\')
  141. foo=ais_dir(img_dir)
  142. if foo=0 then do
  143.     say " Could not find directory: " img_dir
  144.     signal gunky3a
  145. end
  146.  
  147. custdir=work_dir||'\ALPHABYT'
  148. gunky4:
  149. say " "
  150. call charout,  bold " Enter the ALPHABYT directory (for storing fonts)" normal crlf
  151. call charout,"  ENTER= " custdir  " ? "
  152. parse pull custom_dir
  153. if custom_dir="" then custom_Dir=custdir
  154. custom_dir=strip(custom_dir,'t','\')
  155. foo=ais_dir(custom_dir)
  156. if foo=0 then do
  157.     say " Creating " custom_dir
  158.     '@MKDIR 'custom_dir
  159.     if result <> 0 then do
  160.       say " Could not create " custom_dir
  161.        signal gunky4
  162.     end
  163. end
  164. say " "
  165.  
  166.  
  167. db=dosbootdrive()
  168. ttfdir=db||":\os2\mdos\winos2\system"
  169. gunky4a:
  170. say " "
  171. call charout,  bold " Enter the TTF directory (where TTF fonts are kept)" normal crlf
  172. call charout,"  ENTER= " ttfdir  " ? "
  173. parse pull ttf_dir
  174. if ttf_dir="" then ttf_Dir=ttfdir
  175. ttf_dir=strip(ttf_dir,'t','\')
  176. foo=ais_dir(ttf_dir)
  177. if foo=0 then do
  178.     say " Creating " ttf_dir
  179.     '@MKDIR 'ttf_dir
  180.     if result <> 0 then do
  181.        say " Could not create " ttf_dir
  182.        signal gunky4a
  183.     end
  184. end
  185. else do
  186.    foo=sysfiletree(ttf_dir'\*.ttf',gaa,'FOS')
  187.    in1=gaa.0
  188.    foo=sysfiletree(ttf_dir'\*.ttf',gaa,'FO')
  189.    in0=gaa.0
  190.  
  191.    say " ... a total of "in0" ("in1") TTF font files were found in (in & and under) "
  192.    say "     "ttf_dir
  193.    if in0=0 then do
  194.         if yesno(normal"   "reverse"Are you sure you want to use this TTF font directory?")=0 then signal gunky4a
  195.    end /* do */
  196. end /* do */
  197. say " "
  198.  
  199.  
  200.  
  201. if yesno(" Are you ready to copy the files ")=0 then do
  202.    say " Okay, you can try again later "
  203.    exit
  204. end  /* Do */
  205.     
  206. say " "
  207.  
  208.  
  209. say "Modifying MKGIFTXT and GIF_TEXT "
  210.  
  211. /* ---- modify GIF_TEXT.CMD */
  212. ain=charin('GIF_TEXT.CMD',1,chars('GIF_TEXT.CMD'))
  213. foo=stream('GIF_TEXT.CMD','c','close')
  214.  
  215. aa="GIF_DIR_ROOT='\goserve\alphabyt'"
  216. parse var ain a1 (aa) a2
  217. boo=a1||'0d0a'x||"GIF_DIR_ROOT='"||custom_dir||"' "||'0d0a'x||a2
  218.  
  219. aa="TTF_DIR_ROOT='\ttf'"
  220. parse var boo a1 (aa) a2
  221. boo=a1||'0d0a'x||"TTF_DIR_ROOT='"||ttf_dir||"' "||'0d0a'x||a2
  222.  
  223.  
  224. foo=sysfiledelete('GIF_TEXT.$$$')
  225. foo=charout('GIF_TEXT.$$$',boo,1)
  226. if foo>0 then do
  227.     say " ERROR: could not write temporary file (GIF_TEXT.$$$)"
  228.     exit
  229. end
  230. foo=stream('GIF_TEXT.$$$','c','close')
  231.  
  232.  
  233. /* --- modify MKGIFTEXT.CMD */
  234. ain=charin('MKGIFTXT.CMD',1,chars('MKGIFTXT.CMD'))
  235. foo=stream('MKGIFTXT.CMD','c','close')
  236.  
  237. aa="STYLES_DIR='\goserve\alphabyt'" 
  238. parse var ain a1 (aa) a2
  239. boo=a1||'0d0a'x||"STYLES_DIR='"||custom_dir||"' "||'0d0a'x||a2
  240.  
  241. aa="GIF_DIR_ROOT='\goserve\alphabyt'" 
  242. parse var boo a1 (aa) a2
  243. boo=a1||'0d0a'x||"GIF_DIR_ROOT='"||custom_dir||"' "||'0d0a'x||a2
  244.  
  245. aa="TTF_DIR_ROOT='\ttf'" 
  246. parse var boo a1 (aa) a2
  247. boo=a1||'0d0a'x||"TTF_DIR_ROOT='"||ttf_dir||"' "||'0d0a'x||a2
  248.  
  249. foo=sysfiledelete('MKGIFTXT.$$$')
  250. foo=charout('MKGIFTXT.$$$',boo,1)
  251. if foo>0 then do
  252.     say " ERROR: could not write temporary file (MKGIFTXT.$$$)"
  253.     exit
  254. end
  255. foo=stream('MKGIFTXT.$$$','c','close')
  256.  
  257. say ' Copying  .CMD and other stuff to ' addon_dir
  258.  
  259. foo=check_copy('GIF_TEXT.$$$',addon_dir'\GIF_TEXT.CMD',1)
  260. aa=sysfiledelete('GIF_TEXT.$$$')
  261.  
  262. foo=check_copy('MKGIFTXT.$$$',addon_dir'\MKGIFTXT.CMD',1)
  263. aa=sysfiledelete('MKGIFTXT.$$$')
  264. say "Copying RXGDUTIL.DLL to " work_dir
  265. foo=check_copy('RXGDUTIL.DLL',work_dir)
  266. say "Copying RXTTF.DLL to " work_dir
  267. foo=check_copy('RXTTF.DLL',work_dir)
  268.  
  269.  
  270. say "Copying the AlphaByte (font) .ZIP file to " custom_dir
  271. foo=check_copy('ALPHABYT.ZIP',custom_dir)
  272. if zipfoo=1 then do
  273.   say " Please CD to " custom_dir " and UNZIP ALPHABYT "
  274. end
  275. else do
  276.    if yesno(' Unzip ALPHABYT.ZIP? ')=1 then do
  277.      say " Unzipping .GIF files to subdirectories under  " custom_dir
  278.      foo=uzunzip(' -o -qq -d'||custom_dir||' '||custom_dir||'\ALPHABYT ')
  279.    end
  280. end  /* Do */
  281.  
  282.  
  283. say "Copying  MKGIFTXT.HTM and MKBUTTON.HTM sample documents to "web_dir
  284.  
  285. foo=check_copy('MKGIFTXT.SRE',web_dir'\MKGIFTXT.HTM',1) 
  286.  
  287. /*foo=check_copy('MKGIFTXH.$$$',web_dir'\MKGIFTXT.HTM',1)
  288. aa=sysfiledelete('MKGIFTXH.$$$') */
  289.  
  290. foo=check_copy('MKBUTTON.SRE',web_dir'\MKBUTTON.HTM')
  291.  
  292. foo=check_copy('GIF_TEXT.DOC',web_dir)
  293. foo=check_copy('MKGIFRM.HTM',web_dir)
  294. foo=check_copy('MKGIFTOC.HTM',web_dir)
  295. foo=check_copy('MKGIFTX2.HTM',web_dir)
  296. foo=check_copy('MKGIFTX3.HTM',web_dir)
  297.  
  298. foo=check_copy('ALLBUT1.GIF',img_dir)
  299.  
  300. foo=check_copy('SAMPGIF.ZIP',img_dir)
  301. if zipfoo=1  then do
  302.   say " Please CD to " img_dir " and UNZIP SAMPGIF "
  303. end
  304. else do
  305.    say " Unzipping .GIF files to subdirectories under  " img_dir
  306.    foo=uzunzip(' -o -q -d'||img_dir||' '||img_dir||'\SAMPGIF ')
  307. end  /* Do */
  308.  
  309.  
  310.  
  311. say " "
  312. say reverse " ------------------------------------------------- "normal
  313. say bold " The GIF_TEXT files and directories have been created. " normal
  314. say " "
  315. say " For some further hints, see the GIF_TEXT.DOC file. "
  316. say" "
  317. if stream('GIF_TEXT.DOC','c','query exists')<>'' then do
  318.      ii=yesno(normal"      "bold"Would you like to view GIF_TEXT.DOC ?"normal,,'N')
  319.      if ii=1 then '@START  "The GIF_text Manual" /C /F /WIN E GIF_TEXT.DOC'
  320. end
  321.  
  322.  
  323. exit
  324.  
  325. /* ------------------------------------------------------------------ */
  326.  /* function: Check if ANSI is activated                               */
  327.  /*                                                                    */
  328.  /* call:     CheckAnsi                                                */
  329.  /*                                                                    */
  330.  /* where:    -                                                        */
  331.  /*                                                                    */
  332.  /* returns:  1 - ANSI support detected                                */
  333.  /*           0 - no ANSI support available                            */
  334.  /*          -1 - error detecting ansi                                 */
  335.  /*                                                                    */
  336.  /* note:     Tested with the German and the US version of OS/2 3.0    */
  337.  /*                                                                    */
  338.  /*                                                                    */
  339.  CheckAnsi: PROCEDURE
  340.    thisRC = -1
  341.  
  342.    trace off
  343.                          /* install a local error handler              */
  344.    SIGNAL ON ERROR Name InitAnsiEnd
  345.  
  346.    "@ANSI 2>NUL | rxqueue 2>NUL"
  347.  
  348.    thisRC = 0
  349.  
  350.    do while queued() <> 0
  351.      queueLine = lineIN( "QUEUE:" )
  352.      if pos( " on.", queueLine ) <> 0 | ,                       /* USA */
  353.         pos( " (ON).", queueLine ) <> 0 then                    /* GER */
  354.        thisRC = 1
  355.    end /* do while queued() <> 0 */
  356.  
  357.  InitAnsiEnd:
  358.  signal off error
  359.  RETURN thisRC
  360.  
  361.  
  362. /* -------------------- */
  363. /* get a yes or no , return 1 if yes */
  364. yesno:procedure expose normal reverse bold
  365. parse arg fooa , allopt,altans
  366. if altans<>" " & words(altans)>1 then do
  367.    w1=strip(word(altans,1))
  368.    w2=strip(word(altans,2))
  369.    a1=left(w1,1) ; a2=left(w2,1)
  370.    a1a=substr(w1,2) ; a2a=substr(w2,2)
  371. end
  372. else do
  373.     a1='Y' ; a1a='es'
  374.     a2='N' ; a2a='o'
  375. end  /* Do */
  376. ayn='  '||bold||a1||normal||a1a||'\'||bold||a2||normal||a2a
  377. if allopt=1 then  ayn=ayn||'\'||bold||'A'||normal||'ll'
  378.  
  379. do forever
  380.  foo1=normal||reverse||fooa||normal||ayn
  381.  call charout,  foo1 normal ':'
  382.  pull anans
  383.  if abbrev(anans,a1)=1 then return 1
  384.  if abbrev(anans,a2)=1 then return 0
  385.  if allopt=1 & abbrev(anans,'A')=1 then return 2
  386. end
  387.  
  388.  
  389. /* ------------- */
  390. /* ----------------------------------------------------------------------- */
  391. /* REPLACESTRG: In string astring, find first occurence substring target and
  392. .   replace it with substring putme
  393. .      if no target, return unchanged astring
  394. .      if no putme, then remove target
  395. .      if type=backward, then find/change LAST occurence
  396. .      if type=all, find/change all occurences
  397. .      if exactmatch=yes, then do not capitalize during search (exact match only */
  398. /* ----------------------------------------------------------------------- */
  399.  
  400. replacestrg: procedure
  401.  
  402. exactmatch=0
  403. backward=0 ; doall=0
  404.  
  405. parse arg astring ,  target   , putme , type , exactmatch
  406.  
  407. type = translate(type)
  408. if type="BACKWARD" then backward="YES"
  409. if type="ALL" then doall="YES"
  410.  
  411. iat=1
  412. joelen=length(target)
  413. joelen2=length(putme)
  414.  
  415. doagain:                /* here if doall=yes */
  416.  if exactmatch="YES" then do
  417.     if   backward="YES" then
  418.         joe= lastpos(target,astring)
  419.     else
  420.         joe= pos(target,astring,iat)
  421.  end
  422.  else do
  423.    if   backward="YES" then
  424.         joe= lastpos(translate(target),translate(astring))
  425.     else
  426.         joe= pos(translate(target),translate(astring),iat)
  427.  end
  428.  if joe=0 then
  429.          return astring
  430.  
  431.  astring=delstr(astring,joe,joelen)
  432.  if putme<>' ' then
  433.     astring=insert(putme,astring,joe-1)
  434.  
  435.  if doall="YES" then do
  436.      iat=joe+joelen2
  437.      signal doagain
  438.  end
  439. /* else, all done */
  440.  return astring
  441.  
  442. /*******************************************/
  443. /* check for existence of file, then ask user to copy or not */
  444. /* note that for X.* type copies, it only checks once
  445.    (not for each file, but just for any one of them */
  446. /********************************************/
  447. check_copy: procedure expose copyall reverse bold normal
  448. parse arg file1, dest1 , asis
  449. amess=''
  450.  
  451. if asis="" then do
  452.   dest2=strip(dest1,'t','\')||'\'
  453.   filename=dest2||file1
  454. end
  455. else do
  456.   filename=dest1
  457. end /* do */
  458.  
  459. if copyall=1 then signal doit3
  460.  
  461. aa=sysfiletree(filename,isit,'F')
  462.  
  463. ok=1
  464. if aa<>0 then do
  465.    say " Warning: error when looking for pre-existing copy of: " filename
  466.    ok=yesno(" Do you want to copy this file (or files) anyways? ")
  467.    if ok=1 & amess<>""  then
  468.       ok=yesno(amess)
  469. end
  470.  
  471. if isit.0>0 then do
  472.   if pos('*',file1)=0 then do
  473.       say " "
  474.       say " A file exists with the name: " filename
  475.       ok=yesno(" Do you want to overwrite this file? ",1)
  476.        say ' '
  477.       if ok=1 & amess<>""  then
  478.            ok=yesno(amess)
  479.   end
  480.   else do
  481.     say " "
  482.       say " There is at least one file that matches: " filename
  483.       say "  (this match may " bold " not " normal " be one of the files that will be copied!) "
  484.       ok=yesno(" Do you want to copy these files? ",1)
  485.       say ' '
  486.       if ok=1 & amess<>""  then
  487.            ok=yesno(amess)
  488.   end  /* Do */
  489.  
  490. end
  491.  
  492. if ok=2 then do
  493.   say " "
  494.   say "A number of files will be overwritten (not just this one) "
  495.   copyall=yesno(" Are you sure you want to do this?")
  496.   if copyall=0 then
  497.       ok=yesno(" Do you want to overwrite the current file (or files)? ")
  498.       say ' '
  499. end
  500.  
  501. if ok=0  then return 0
  502.  
  503. doit3:          /* jump here if copyall is on, or noask=1 */
  504. '@COPY ' file1 dest1 ' > NUL '
  505.  
  506. return 1
  507.  
  508. /* return 1 if adir is an existing (possibly empty) directory , 0 if not */
  509. ais_dir:procedure 
  510. parse arg adir
  511.  
  512. adir=strip(adir)
  513. adir=strip(adir,'t','\')
  514. nowdir=directory()
  515. nowdrive=filespec('d',nowdir'\')
  516. nowpath=filespec('p',nowdir'\')
  517. adr=filespec('d',adir)
  518. if adr='' then do
  519.    if abbrev(adir,'\')=0 then 
  520.        adir=nowdrive||nowpath||adir
  521.    else
  522.        adir=nowdrive||adir
  523. end /* do */
  524.  
  525. foo=sysfiletree(adir,goo,'D')
  526. if  goo.0>0  then return 1
  527. return 0
  528.  
  529.  
  530.  
  531.  
  532.  
  533.