home *** CD-ROM | disk | FTP | other *** search
/ PC Online 1998 November / PCO_1198.ISO / filesbbs / os2 / gif_text.arj / GIF_TEXT.ZIP / install.cmd < prev    next >
Encoding:
Text File  |  1998-05-02  |  12.2 KB  |  436 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. ansion=checkansi()
  21. if ansion=1 then do
  22.   aesc='1B'x
  23.   cy_ye=aesc||'[37;46;m'
  24.   normal=aesc||'[0;m'
  25.   bold=aesc||'[1;m'
  26.   re_wh=aesc||'[31;47;m'
  27.   reverse=aesc||'[7;m'
  28. end
  29. else do
  30.   say " Warning: Could not detect ANSI....  Install will look ugly ! "
  31.   parse pull .
  32.   cy_ye="" ; normal="" ; bold="" ;re_wh="" ;
  33.   reverse=""
  34. end  /* Do */
  35.  
  36. cls
  37. say  " " ; say
  38.  
  39. call lineout, bold cy_ye
  40. call lineout, "This is the GIF_TEXT installation program (4/98).     "
  41. call lineout, "      (for the SRE-http web server) "
  42. call lineout, normal
  43. call lineout,"      If you are installing GIF_TEXT as a CGI-BIN script "
  44. call lineout,'      please see the "by hand" installation instructions in'
  45. call lineout,'      GIF_TEXT.DOC.'
  46. say "" 
  47. say " This program will ask for the names of a few directories,"
  48. say " and will copy a number of files to these directories."
  49. say "  "
  50.  
  51. if yesno(" Are you ready to continue ")=1 then
  52.  nop
  53. else do
  54.  say " See you later?.. "
  55.  exit
  56. end
  57.  
  58.  
  59. nowdir=directory()
  60.  
  61. godir=filespec('d',nowdir)||'\GOSERVE'
  62. webdir=filespec('d',godir)||'\WWW'
  63.  
  64.  
  65. gunky2:
  66. say " "
  67. call charout,  bold " Enter the GoServe working directory (that contains SREFILTR.80)" normal crlf
  68. call charout,"  ENTER= " godir  " ? "
  69. parse pull work_dir
  70. if work_dir="" then work_Dir=godir
  71. work_dir=strip(work_dir,'t','\')
  72. foo=ais_dir(work_dir)
  73. if foo=0 then do
  74.     say " Could not find directory: " work_dir
  75.     signal gunky2
  76. end
  77. foo=work_dir||'\SREFILTR.80'
  78. if stream(foo,'c','query exists')=' ' then do
  79.    say " Could not find SREFILTR.80.  Please reenter "
  80.    signal gunky2
  81. end  /* Do */
  82.  
  83.  
  84. addondir=work_dir||'\ADDON'
  85. gunky2a:
  86. say " "
  87. call charout,  bold " Enter the SRE-http " normal reverse " addon " normal bold " directory " normal crlf
  88. call charout,"  ENTER= " addondir  " ? "
  89. parse pull addon_dir
  90. if addon_dir="" then addon_Dir=addondir
  91. addon_dir=strip(addon_dir,'t','\')
  92. foo=ais_dir(addon_dir)
  93. if foo=0 then do
  94.     say " Could not find directory: " addon_dir
  95.     signal gunky2a
  96. end
  97.  
  98. gunky3:
  99. say " "
  100. call charout,  bold " Enter the  GoServe data directory (that contains your home page)" normal crlf
  101. call charout,"  ENTER= " webdir  " ? "
  102. parse pull web_dir
  103. if web_dir="" then web_Dir=webdir
  104. web_dir=strip(web_dir,'t','\')
  105. foo=ais_dir(web_dir)
  106. if foo=0 then do
  107.     say " Could not find directory: " web_dir
  108.     signal gunky3
  109. end
  110.  
  111.  
  112.  
  113. imgdir=web_dir'\IMGS'
  114. gunky3a:
  115. say " "
  116. call charout,  bold " Enter the IMGS data directory (that contains sample .GIF files)" normal crlf
  117. call charout,"  ENTER= " imgdir  " ? "
  118. parse pull img_dir
  119. if img_dir="" then img_Dir=imgdir
  120. img_dir=strip(img_dir,'t','\')
  121. foo=ais_dir(img_dir)
  122. if foo=0 then do
  123.     say " Could not find directory: " img_dir
  124.     signal gunky3a
  125. end
  126.  
  127. custdir=work_dir||'\ALPHABYT'
  128. gunky4:
  129. say " "
  130. call charout,  bold " Enter the ALPHABYT directory (for storing fonts)" normal crlf
  131. call charout,"  ENTER= " custdir  " ? "
  132. parse pull custom_dir
  133. if custom_dir="" then custom_Dir=custdir
  134. custom_dir=strip(custom_dir,'t','\')
  135. foo=ais_dir(custom_dir)
  136. if foo=0 then do
  137.     say " Creating " custom_dir
  138.     wow=dosmkdir(custom_dir)
  139.     if wow=0 then do
  140.       say " Could not create " custom_dir
  141.        signal gunky3
  142.     end
  143. end
  144. say " "
  145.  
  146. if yesno(" Are you ready to copy the files ")=0 then do
  147.    say " Okay, you can try again later "
  148.    exit
  149. end  /* Do */
  150.     
  151. say " "
  152.  
  153.  
  154. /* modify GIF_TEXT.CMD */
  155. ain=charin('GIF_TEXT.CMD',1,chars('GIF_TEXT.CMD'))
  156. foo=stream('GIF_TEXT.CMD','c','close')
  157. aa="gif_dir_root='\goserve\alphabyt'"
  158. parse var ain a1 (aa) a2
  159. boo=a1||'0d0a'x||"GIF_DIR_ROOT='"||custom_dir||"' "||'0d0a'x||a2
  160. foo=sysfiledelete('GIF_TEXT.$$$')
  161. foo=charout('GIF_TEXT.$$$',boo,1)
  162. if foo>0 then do
  163.     say " ERROR: could not write temporary file (GIF_TEXT.$$$)"
  164.     exit
  165. end
  166. foo=stream('GIF_TEXT.$$$','c','close')
  167.  
  168. say "Modifying MKGIFTXT and GIF_TEXT "
  169. /* modify MKGIFTEXT.CMD */
  170. ain=charin('MKGIFTXT.CMD',1,chars('MKGIFTXT.CMD'))
  171. foo=stream('MKGIFTXT.CMD','c','close')
  172. aa="STYLES_DIR='\goserve\alphabyt'" 
  173. parse var ain a1 (aa) a2
  174. boo=a1||'0d0a'x||"STYLES_DIR='"||custom_dir||"' "||'0d0a'x||a2
  175. foo=sysfiledelete('MKGIFTXT.$$$')
  176. foo=charout('MKGIFTXT.$$$',boo,1)
  177. if foo>0 then do
  178.     say " ERROR: could not write temporary file (MKGIFTXT.$$$)"
  179.     exit
  180. end
  181. foo=stream('MKGIFTXT.$$$','c','close')
  182.  
  183.  
  184.  
  185. say ' Copying  .CMD and other stuff to ' addon_dir
  186. foo=check_copy('GIF_TEXT.$$$',addon_dir'\GIF_TEXT.CMD',1)
  187. aa=sysfiledelete('GIF_TEXT.$$$')
  188.  
  189. foo=check_copy('MKGIFTXT.$$$',addon_dir'\MKGIFTXT.CMD',1)
  190. aa=sysfiledelete('MKGIFTXT.$$$')
  191. say "Copying RXGDUTIL.DLL to " work_dir
  192. foo=check_copy('RXGDUTIL.DLL',work_dir)
  193.  
  194. say "Copying the AlphaByte (font) .ZIP file to " custom_dir
  195. foo=check_copy('ALPHABYT.ZIP',custom_dir)
  196. if zipfoo=1 then do
  197.   say " Please CD to " custom_dir " and UNZIP ALPHABYT "
  198. end
  199. else do
  200.    say " Unzipping .GIF files to subdirectories under  " custom_dir
  201.    foo=uzunzip(' -o -q -d'||custom_dir||' '||custom_dir||'\ALPHABYT ')
  202. end  /* Do */
  203.  
  204.  
  205. say "Copying  MKGIFTXT.HTM and MKBUTTON.HTM sample documents to "web_dir
  206. foo=check_copy('MKGIFTXT.SRE',web_dir'\MKGIFTXT.HTM',1)
  207. foo=check_copy('MKBUTTON.SRE',web_dir'\MKBUTTON.HTM')
  208. foo=check_copy('GIF_TEXT.DOC',web_dir)
  209. foo=check_copy('ALLBUT1.GIF',img_dir)
  210.  
  211. foo=check_copy('SAMPGIF.ZIP',img_dir)
  212. if zipfoo=1  then do
  213.   say " Please CD to " img_dir " and UNZIP SAMPGIF "
  214. end
  215. else do
  216.    say " Unzipping .GIF files to subdirectories under  " img_dir
  217.    foo=uzunzip(' -o -q -d'||img_dir||' '||img_dir||'\SAMPGIF ')
  218. end  /* Do */
  219.  
  220.  
  221.  
  222. say " "
  223. say reverse " ------------------------------------------------- "normal
  224. say bold " The GIF_TEXT files and directories have been created. " normal
  225. say " "
  226. say " For some further hints, see the GIF_TEXT.DOC file. "
  227. say" "
  228.  
  229. exit
  230.  
  231. /* ------------------------------------------------------------------ */
  232.  /* function: Check if ANSI is activated                               */
  233.  /*                                                                    */
  234.  /* call:     CheckAnsi                                                */
  235.  /*                                                                    */
  236.  /* where:    -                                                        */
  237.  /*                                                                    */
  238.  /* returns:  1 - ANSI support detected                                */
  239.  /*           0 - no ANSI support available                            */
  240.  /*          -1 - error detecting ansi                                 */
  241.  /*                                                                    */
  242.  /* note:     Tested with the German and the US version of OS/2 3.0    */
  243.  /*                                                                    */
  244.  /*                                                                    */
  245.  CheckAnsi: PROCEDURE
  246.    thisRC = -1
  247.  
  248.    trace off
  249.                          /* install a local error handler              */
  250.    SIGNAL ON ERROR Name InitAnsiEnd
  251.  
  252.    "@ANSI 2>NUL | rxqueue 2>NUL"
  253.  
  254.    thisRC = 0
  255.  
  256.    do while queued() <> 0
  257.      queueLine = lineIN( "QUEUE:" )
  258.      if pos( " on.", queueLine ) <> 0 | ,                       /* USA */
  259.         pos( " (ON).", queueLine ) <> 0 then                    /* GER */
  260.        thisRC = 1
  261.    end /* do while queued() <> 0 */
  262.  
  263.  InitAnsiEnd:
  264.  signal off error
  265.  RETURN thisRC
  266.  
  267.  
  268. /* -------------------- */
  269. /* get a yes or no , return 1 if yes */
  270. yesno:procedure expose normal reverse bold
  271. parse arg fooa , allopt,altans
  272. if altans<>" " & words(altans)>1 then do
  273.    w1=strip(word(altans,1))
  274.    w2=strip(word(altans,2))
  275.    a1=left(w1,1) ; a2=left(w2,1)
  276.    a1a=substr(w1,2) ; a2a=substr(w2,2)
  277. end
  278. else do
  279.     a1='Y' ; a1a='es'
  280.     a2='N' ; a2a='o'
  281. end  /* Do */
  282. ayn='  '||bold||a1||normal||a1a||'\'||bold||a2||normal||a2a
  283. if allopt=1 then  ayn=ayn||'\'||bold||'A'||normal||'ll'
  284.  
  285. do forever
  286.  foo1=normal||reverse||fooa||normal||ayn
  287.  call charout,  foo1 normal ':'
  288.  pull anans
  289.  if abbrev(anans,a1)=1 then return 1
  290.  if abbrev(anans,a2)=1 then return 0
  291.  if allopt=1 & abbrev(anans,'A')=1 then return 2
  292. end
  293.  
  294.  
  295. /* ------------- */
  296. /* ----------------------------------------------------------------------- */
  297. /* REPLACESTRG: In string astring, find first occurence substring target and
  298. .   replace it with substring putme
  299. .      if no target, return unchanged astring
  300. .      if no putme, then remove target
  301. .      if type=backward, then find/change LAST occurence
  302. .      if type=all, find/change all occurences
  303. .      if exactmatch=yes, then do not capitalize during search (exact match only */
  304. /* ----------------------------------------------------------------------- */
  305.  
  306. replacestrg: procedure
  307.  
  308. exactmatch=0
  309. backward=0 ; doall=0
  310.  
  311. parse arg astring ,  target   , putme , type , exactmatch
  312.  
  313. type = translate(type)
  314. if type="BACKWARD" then backward="YES"
  315. if type="ALL" then doall="YES"
  316.  
  317. iat=1
  318. joelen=length(target)
  319. joelen2=length(putme)
  320.  
  321. doagain:                /* here if doall=yes */
  322.  if exactmatch="YES" then do
  323.     if   backward="YES" then
  324.         joe= lastpos(target,astring)
  325.     else
  326.         joe= pos(target,astring,iat)
  327.  end
  328.  else do
  329.    if   backward="YES" then
  330.         joe= lastpos(translate(target),translate(astring))
  331.     else
  332.         joe= pos(translate(target),translate(astring),iat)
  333.  end
  334.  if joe=0 then
  335.          return astring
  336.  
  337.  astring=delstr(astring,joe,joelen)
  338.  if putme<>' ' then
  339.     astring=insert(putme,astring,joe-1)
  340.  
  341.  if doall="YES" then do
  342.      iat=joe+joelen2
  343.      signal doagain
  344.  end
  345. /* else, all done */
  346.  return astring
  347.  
  348. /*******************************************/
  349. /* check for existence of file, then ask user to copy or not */
  350. /* note that for X.* type copies, it only checks once
  351.    (not for each file, but just for any one of them */
  352. /********************************************/
  353. check_copy: procedure expose copyall reverse bold normal
  354. parse arg file1, dest1 , asis
  355. amess=''
  356.  
  357. if asis="" then do
  358.   dest2=strip(dest1,'t','\')||'\'
  359.   filename=dest2||file1
  360. end
  361. else do
  362.   filename=dest1
  363. end /* do */
  364.  
  365. if copyall=1 then signal doit3
  366.  
  367. aa=sysfiletree(filename,isit,'F')
  368.  
  369. ok=1
  370. if aa<>0 then do
  371.    say " Warning: error when looking for pre-existing copy of: " filename
  372.    ok=yesno(" Do you want to copy this file (or files) anyways? ")
  373.    if ok=1 & amess<>""  then
  374.       ok=yesno(amess)
  375. end
  376.  
  377. if isit.0>0 then do
  378.   if pos('*',file1)=0 then do
  379.       say " "
  380.       say " A file exists with the name: " filename
  381.       ok=yesno(" Do you want to overwrite this file? ",1)
  382.       if ok=1 & amess<>""  then
  383.            ok=yesno(amess)
  384.   end
  385.   else do
  386.     say " "
  387.       say " There is at least one file that matches: " filename
  388.       say "  (this match may " bold " not " normal " be one of the files that will be copied!) "
  389.       ok=yesno(" Do you want to copy these files? ",1)
  390.       if ok=1 & amess<>""  then
  391.            ok=yesno(amess)
  392.   end  /* Do */
  393.  
  394. end
  395.  
  396. if ok=2 then do
  397.   say " "
  398.   say "SRE-http will overwrite all files (not just these) "
  399.   copyall=yesno(" Are you sure you want to do this?")
  400.   if copyall=0 then
  401.       ok=yesno(" Do you want to overwrite the current file (or files)? ")
  402. end
  403.  
  404. if ok=0  then return 0
  405.  
  406. doit3:          /* jump here if copyall is on, or noask=1 */
  407. '@COPY ' file1 dest1 ' > NUL '
  408.  
  409. return 1
  410.  
  411. /* return 1 if adir is an existing (possibly empty) directory , 0 if not */
  412. ais_dir:procedure 
  413. parse arg adir
  414.  
  415. adir=strip(adir)
  416. adir=strip(adir,'t','\')
  417. nowdir=directory()
  418. nowdrive=filespec('d',nowdir'\')
  419. nowpath=filespec('p',nowdir'\')
  420. adr=filespec('d',adir)
  421. if adr='' then do
  422.    if abbrev(adir,'\')=0 then 
  423.        adir=nowdrive||nowpath||adir
  424.    else
  425.        adir=nowdrive||adir
  426. end /* do */
  427.  
  428. foo=sysfiletree(adir,goo,'D')
  429. if  goo.0>0  then return 1
  430. return 0
  431.  
  432.  
  433.  
  434.  
  435.  
  436.