home *** CD-ROM | disk | FTP | other *** search
- /* 08 Jan 1998:
-
- A front end to the GIF_TEXT addon -- this will take a request generated
- by MKGIFTXT.HTM, and return a link to GIF_TEXT.
-
- Note that this will work either as a cgi-bin script (for a generic, os/2
- cgi-bin-compatabile server,or as an addon for SRE-http (note that
- SRE-http is the new name as of 11/97 for SRE-Filter). It will
- detect how it's being called, and respond accordingly.
-
- Note that when used as cgi-bin, many servers have "request options"
- limit of 256 characters (that is, it will only recognize the first 256
- characters after the ?). Since MKGIFTXT uses an IMG= link to display results,
- which is always interpreted as a GET request, this limitation is likely to
- arise when you've selected a lot of options in mkgiftxt.htm. This is a problem,
- but there is no obvious work-around other then NOT specifying unneeded
- options (which means mkgiftxt.htm should be edited, with unnecessary
- options removed).
-
- There is 1 user changable parameter: the "style" directory. This is used
- to store and retrieve "styles", which allow one to use prior message
- specifications (with a new message).
-
- */
-
- /* ---------------- Begin User Changable Parameters ------------*/
-
- /* "Styles" directory. Should be a fully qualified directory (typically, you
- should use the GIF_DIR_ROOT directory you specified in GIF_TEXT.CMD
- Set to '' if you don't want to support these styles */
- STYLES_DIR='\os2httpd\alphabyt'
-
-
- /* ---------------- End User Changable Parameters ------------*/
-
-
- parse arg ddir, tempfile, reqstrg,list,verb ,uri,user, ,
- basedir ,workdir,privset,enmadd,transaction,verbose, ,
- servername,host_nickname,homedir
-
- signal on syntax name err1
- signal on error name err1
-
- styles_dir=strip(styles_dir,'t','\')
-
- /* check for CGI-BIN call */
- is_cgi=0
- if verb="" then do /* is it cgi-bin? */
- verb = value("REQUEST_METHOD",,'os2environment')
- if verb="" then do
- say " Sorry, this is a web server utility. "
- exit
- end /* do */
- is_cgi=1
- if verb="GET" then do
- list=value("QUERY_STRING",,'os2environment')
- end
- else do
- len=value('CONTENT_LENGTH',,'os2environment')
- list=charin(,,len)
- end
- end
- else do
- if verb='GET' then parse var uri . '?' list
- end
-
- /* look for "style" option, and use/save the appropriate "style" (if available) */
- l0=list
- lnew=''
- newtext=''; styfile='' ;is_style=0
- do until l0=''
- parse var l0 a1 '&' l0
- parse var a1 a1a '=' a1b ; a1a=translate(a1a)
- select
- when a1a="MESSAGE" | a1a="TEXT" then do
- newtext=a1b
- end
- when a1a='STYLE' then do
- if styles_dir='' | styles_dir=0 then iterate /* suppress styles */
- if a1b<>'' & a1b<>0 then do
- styfile=a1b
- if pos('.',a1b)=0 & a1b<>'' & a1b<>0 then styfile=styfile'.STY'
- styfile=strip(translate(styfile,'\','/'),'l','\')
- is_style=1
- end
- end /* do */
- when a1a='SAVE_STYLE' | a1a='STYLE_SAVE' then do /* otherwise, interpret as "use style" */
- if styles_dir='' | styles_dir=0 then iterate /* suppress styles */
- if a1b=1 then is_style=2
- end /* do */
- otherwise do
- if lnew='' then
- lnew=a1
- else
- lnew=lnew||'&'||a1
- end
- end
- end /* do */
-
- /* Read results from style file? */
- if is_style>0 then do
- if styfile='' | styfile=0 then styfile='DEFAULT.STY'
- oof=styles_dir'\'styfile
-
-
- if is_style=2 then do /* save list, minus text, in a style file */
- foo=stream(oof,'c','open write')
- if abbrev(translate(foo),'READY')=1 then do /* writeable ... */
- l2=charout(oof,lnew,1)
- foo=stream(oof,'c','close')
- end
- else do
- styfile='Unable to write to 'styfile
- end /* do */
- end /* do */
- else do /* read from style file */
- goo=stream(oof,'c','query exists')
- if goo<>'' then do
- foo=stream(oof,'c','open read')
- l2=charin(oof,1,chars(oof))
- foo=stream(oof,'c','close')
- list='TEXT='||newtext||'&'l2
- end
- else
- styfile='Unable to read from ' styfile
- end
- end /* do */
-
- list=list||'&MESSAGE.GIF'
- crlf='0d0a'x
-
- errm1=""
- uj=length(list)
- if is_cgi=0 then do
- img0='<IMG src="/GIF_TEXT.CMD?'||list||'">'
- end
- else do
- if uj > 245 then do /* long request; drop null = options */
- olist=""
- do until list=""
- parse var list av '&' list
- parse var av v1 '=' v2
- if v2<>'' then olist=olist||av||'&'
- end
- olist=strip(olist,'t','&')
- errm1="<p><B>Caution:</b> A long request was shortened by removing empty-valued options. In some cases this will effect the final results.<p>"
- list=olist
- end /* do */
- if length(list)>245 then do
- errm1="<p><B>Warning:</b> This server may not be able to handle this long ("||length(list)" characters) CGI-BIN IMG request </b><p> "
- end
- img0='<IMG src="/cgi-bin/GIF_TEXT.CMD?'||list||'">'
- end /* is cgi */
-
- iv=translate(img0)
- parse var iv . 'SLIDE=' goon '&' .
- if goon<>'' then
- extramess='<b>Note...</b> images created with <em>color slides</eM> may take require a few minutes to be generated '
- else
- extramess=""
-
- img=img0
- fimg2="" ; tmp=""
- do until img=""
- parse var img a1 '&' img
- if tmp="" then
- tmp=a1
- else
- tmp=tmp'&'a1
- if length(tmp)>80 then do
- if img<>"" then tmp=tmp'&'
- fimg2=fimg2'<br>'||fixit(tmp)
- tmp=""
- end
- end /* do */
- if tmp<>"" then fimg2=fimg2'<br>'||fixit(tmp)
- fimg=fimg2
-
- retmess=' Return to <a href="mkgiftxt.htm">GIF_TEXT input form </a> <p>'
-
- foo1='<HTML><head><TITLE>Generating A Graphical Message</title></head>'crlf
- foo1=foo1||'<body><h2>Generating a graphical message </h2> ' crlf||extramess||'<p>'
- foo1=foo1||' This image is generated from:<br><code>'||fimg||'<p>'crlf
- foo1=foo1||img0||'<p>'errm1'<hr>'||retmess
- if is_style=1 then do
- foo1=foo1||'<hr> Note. <b>using</b> specifications stored in style file: 'styfile
- end /* do */
- else do
- foo1=foo1||'<hr> Note. <b>storing</b> specifications in style file: 'styfile
- end /* do */
- foo1=foo1||'</body></html>'
-
- if is_cgi=1 then do
- Say "Content-type: text/html"
- Say
- call charout,foo1
- return
- end
-
- exp=value(enmadd||'FIX_EXPIRE',,'os2environment')
- foo=value('SREF_PREFIX',,'os2environment')
- if foo='' & exp>0 then
- a=sref_expire_response(0.1,length(foo1),'text/html')
-
- 'var type text/html name foo1 '
-
-
- return 0
-
- fixit:procedure
- parse arg adesc
-
- adesc=a_replacestrg(adesc,'&','&','ALL')
- adesc=a_replacestrg(adesc,'<','<','ALL')
- adesc=a_replacestrg(adesc,'>','>','ALL')
- adesc=a_replacestrg(adesc,'"','"','ALL')
- return adesc
-
-
- a_replacestrg:
-
- exactmatch=0
- backward=0 ; doall=0
-
- parse arg astring , target , putme , type , exactmatch
-
- type = translate(type)
- if type="BACKWARD" then backward="YES"
- if type="ALL" then doall="YES"
-
- iat=1
- joelen=length(target)
- joelen2=length(putme)
-
- doagain: /* here if doall=yes */
- if exactmatch="YES" then do
- if backward="YES" then
- joe= lastpos(target,astring)
- else
- joe= pos(target,astring,iat)
- end
- else do
- if backward="YES" then
- joe= lastpos(translate(target),translate(astring))
- else
- joe= pos(translate(target),translate(astring),iat)
- end
- if joe=0 then
- return astring
-
- astring=delstr(astring,joe,joelen)
- if putme<>' ' then
- astring=insert(putme,astring,joe-1)
-
- if doall="YES" then do
- iat=joe+joelen2
- signal doagain
- end
- /* else, all done */
- return astring
-
-
-
- err1:
- say " error in mkgiftxt at " sigl '( ' rc