home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 35 Internet / 35-Internet.zip / srev13g.zip / BROWSERS.CMD < prev    next >
OS/2 REXX Batch file  |  1998-01-03  |  6KB  |  178 lines

  1. /* Create a BROWSERS.IDX file from a .CFG file obtained from
  2. http://website-1.openmarket.com:80/browsertest/prob/bt-maker.cgi?DataFile
  3. or ... if called as an srehttp addon, will query/list
  4. capabilities of current browser (using sref_browser_info)
  5.  
  6.  
  7.  */
  8.  
  9. /*---   Load REXX libraries ----- */
  10. /* Load up advanced REXX functions */
  11. foo=rxfuncquery('sysloadfuncs')
  12. if foo=1 then do
  13.   call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
  14.   call SysLoadFuncs
  15. end
  16. foo=rxfuncquery('rexxlibregister')
  17. if foo=1 then do
  18.  call rxfuncadd 'rexxlibregister','rexxlib', 'rexxlibregister'
  19.  call rexxlibregister
  20. end
  21. if rxfuncquery('sref_fileread')<>0 then do
  22.   ik=rxfuncadd('sref_fileread','rexxlib','LIB_FILEREAD')
  23.   if ik<>0 then call pmprintf(' SRE-http Monitor: Warning: unable to register SREF_FILEREAD')
  24. end
  25.  
  26. parse arg  ddir, tempfile, reqstrg,list,verb ,uri,user, ,
  27.           basedir ,workdir,privset,enmadd,transaction,verbose, ,
  28.          servername,host_nickname,homedir,aparam,semqueue
  29.  
  30.  
  31. if verb<>'' then signal doaddon
  32.  
  33. /* if here, treat as a stand alone */
  34. say " This utility will create a BROWSERS.IDX file from information"
  35. say " obtained from http:\\website-1.openmarket.com/browsertest"
  36. say
  37. say " In particular, it reads a CFG style file (of browser capabilities)"
  38. say " generated by this /browsertest URL "
  39. say
  40. hoy1: nop
  41. say " Please enter name of the CFG file "
  42. parse pull cfgfile
  43. dd=stream(cfgfile,'c','query exists')
  44. if dd=""  then do
  45.      say " could not find: " cfgfile
  46.      signal hoy1
  47. end
  48. oo=sref_fileread(dd,lins,,'E')
  49. if lins.0=0 then do
  50.      say " error with cfg file "
  51.     signal hoy1
  52. end  /* Do */
  53.  
  54. /* look for # BROWSER.CFG */
  55. gotit=0
  56. do mm=1 to lins.0
  57.     a1=strip(lins.mm)
  58.     if abbrev(a1,'#')=0 then iterate
  59.     parse upper var a1 . '#' a2 . ; a2=strip(a2)
  60.     if a2='BROWSER.CFG' then do
  61.         gotit=1
  62.         leave
  63.     end   
  64. end
  65. if gotit=0 then do
  66.     say " This does not appear to be a BROWSER.CFG file."
  67.     call charout," Are you sure it is (Yes/NO): "
  68.     pull yesno
  69.     say
  70.     if abbrev(yesno,'Y')=0 then do
  71.           say " let's try again ... "
  72.           signal hoy1
  73.     end
  74. end
  75.  
  76. /* typical entry:
  77. Browser {Mozilla/2.0 (compatible; PCN-The PointCast Network 2.0/win32/ *} \
  78.         -browser {PointCast} \
  79.         -cache {WA} \
  80.         -cookies {YES} \
  81.         -date {97/08/01} \
  82.         -maxlinklen {8192} \
  83.         -redirectlimit {8192} \
  84.         -security {NONE} \
  85.         -tables {YES}
  86. */
  87.  
  88. varlist='USER_AGENT SIMPLEKEY'
  89. idid=0  ;mm=0
  90. BLIST.!AGENT_LIST=' '
  91. do until mm=lins.0
  92.     mm=mm+1
  93.     if lins.mm="" then iterate
  94.     alin=strip(lins.mm)
  95.     if abbrev(alin,'#')=1 then iterate
  96.  
  97. /* search for a BROWSER  entry; concatenate lines till next browser entry
  98.    or till end of file; then parse into fields */
  99.  
  100.     parse upper var alin avar . ; avar=strip(avar)
  101.     if avar<>'BROWSER' then iterate   /* some kind of orphan line */
  102.  
  103. /* got a BROWSER LINE -- start entry (concatenate all lines ending with a \ */
  104.     idid=idid+1         /* nth browser found */
  105.  
  106.     parse var alin  . '{' aval '}' .
  107.     anent=''
  108.     say " Entry for: " aval
  109.      blist.idid.!USER_AGENT=aval
  110.      blist.idid.!SIMPLEKEY=strip(upper(space(translate(aval,' ','*-~'),0)))
  111.      blist.!agent_list=blist.!agent_list' 'blist.idid.!SIMPLEKEY
  112.  
  113.     do forever
  114.         mm=mm+1
  115.         alin=strip(lins.mm)
  116.         anent=strip(anent' 'alin,'t','\')
  117.         if right(alin,1)='\' then iterate
  118.  
  119.  /* otherwise, this is last line of entry; so parse it */
  120.         do until anent=""
  121.            parse var anent avar '{' aval '}' anent 
  122.            avar=strip(avar); aval=strip(aval)
  123.            avar=upper(strip(avar,'l','-'))
  124.            tt='!'avar
  125.            blist.idid.tt=aval
  126.            if wordpos(avar,varlist)=0 then varlist=varlist' 'avar
  127.         end /* do */
  128.         leave           /* get next browser entry */
  129.    end /* do forever */
  130. end     /* do mm=lins.0 */
  131. blist.0=idid
  132. say " Found " idid " browsers "
  133. say " with variables: "varlist
  134.  
  135. say
  136. call charout, ' Enter output (BROWSERS.IDX) stem-file name: '
  137. pull outfile
  138. foo=cvwrite(outfile,blist)
  139. say " stem-file status: " foo
  140.  
  141. exit
  142.  
  143.  
  144. doaddon:               /* JUMP HERE WHEN CALLED AS AN ADDON */
  145.  
  146. foo=reqfield('USER-AGENT')
  147. call lineout tempfile,'<HTML><HEAD><TITLE>Browser Features</title></head><body>'
  148. call lineout tempfile,'<h1>Browser Features </h1>'
  149. call lineout tempfile,' Your browser'' user-agent is: <b>'foo '</b><p>'
  150. call lineout tempfile,' Our data indicate it has the following capabilities:<ul> '
  151.  
  152. /*
  153. user_agent = User-agent of browser                      
  154. browser = Vendor of the Browser                         
  155. cookies =Cookie capable? YES or NO.                     
  156. security = Type of security. NO, SHTTP, or SSL.         
  157. tables = Understands tables (YES NO)                    
  158. date = The date this table entry was entered or most rec
  159.         modified. YY/MM/DD                              
  160. redirectlimit = Maximum length of redirection string.   
  161.                Integer between 255 and 8000             
  162. maxlinklen = Maximum characters in url                  
  163.                Integer between 255 and 8000             */
  164.  
  165. call lineout tempfile,'<li> Vendor: <b>'||sref_browser_info('browser')||' </b>'
  166. call lineout tempfile,'<li> User-agent: <b>'||sref_browser_info('user_agent')||' </b>'
  167. call lineout tempfile,'<li> Cookies capable: <b>'||sref_browser_info('cookies')||' </b>'
  168. call lineout tempfile,'<li> Security: <b>'||sref_browser_info('security')||' </b>'
  169. call lineout tempfile,'<li> ReDirectLimit: <b>'||sref_browser_info('redirectlimit')||' </b>'
  170. call lineout tempfile,' <li> MaxCharInURL: <b>'||sref_browser_info('maxlinklen')||' </b>'
  171.  
  172. call lineout tempfile,'</ul></body></html>'
  173. call lineout tempfile
  174. 'FILE erase type text/html name 'tempfile
  175. return '200 '||extract('bytessent')
  176.  
  177.  
  178.