home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 35 Internet / 35-Internet.zip / srev13h.zip / BYBROWSR.RX0 < prev    next >
Text File  |  1998-01-04  |  8KB  |  212 lines

  1. /* ByBrowsr: Using Browser Specific Documents.
  2.  
  3. Usage: include the following in a requested document (say, FOOBAR.HTM):
  4.           <!-- interpret file ByBrowsr.rxx -->
  5.       and create a set of files ending with the appropriate extensions
  6.       (say, FOOBAR.NETSCAPE2, FOOBAR.WEBEX11, FOOBAR.MSIE3, etc.).
  7.  
  8. Customization Note: The "user-changable" parameters are:
  9.  
  10.    BROWSER.!    -- Primary Rules: 
  11.    BROWSER_2.! --  Backup rules:                                 
  12.    DEFAULT      -- Defaul
  13.  
  14. Documentation: See ByBrowsr.Doc for details.
  15.  
  16. ******************************************/
  17. /************* BEGIN USER CHANGABLE PARAMETERS **************/
  18.  
  19.  
  20. /* DEFAULT -- the extension to use if there is no successful match */
  21. DEFAULT='DEF'
  22.  
  23. /* BROWSERS.! -- Primary Rules: A list of User Agents and associated extensions.
  24.  Syntax: BROWSER.!an_ext='u_agent'
  25.      alternate syntax: BROWSER.!an_ext.n='u_agent'
  26.  where:
  27.        an_ext is the extension to use 
  28.        an_ext.n is an alternate version of an_ext (n is an integer)
  29.        u_agent is compared against user-agent request headers
  30.  
  31.  Examples: BROWSER.!NETSCAPE3='Mozilla/3.*'
  32.            BROWSER.!NETSCAPE2.1='Mozilla/2.02E*'
  33.  
  34.  Notes:
  35.   +  Be sure to include the .! before the an_extension                
  36.   +  Be sure to surround the u_agent with ' quotes
  37.   +  Spaces in the user_agent are ignored, case is ignored, * are wildcards
  38.   +  If you are using a FAT system, your an_ext "tails" should have no more 
  39.      then 3 characters.
  40.   +  To have multiple u_agents map to the same an_ext, add a .n after the
  41.      the an_ext; with n an integer.
  42. */
  43.  
  44.   
  45. BROWSER.!WEBTV='Mozilla/1.*WebTV/1.*compatible*MSIE2.*' 
  46. BROWSER.!ACCENT='MultilingualMosaic/1.*Win32Accent*' 
  47. BROWSER.!ALIS='Tango/c1.2c1.0Win32Alis/6*' 
  48. BROWSER.!AOL1='Mozilla/2.0*Compatible*AOL-IWENG3.1*' 
  49. BROWSER.!AOL25A='IWENG/*' 
  50. BROWSER.!AOL25B='aolbrowser/1.*' 
  51. BROWSER.!ATT='NCD/1.0f(Windows' I' 16bit)*' 
  52. BROWSER.!BOOKLINK='InternetWorks/*' 
  53. BROWSER.!EINETMACWEB='MacWeb/1.00*libwww/2*' 
  54. BROWSER.!EINETWINWEB='EINetWin*' 
  55. BROWSER.!GNN='GNNworks/v1.2.0*' 
  56. BROWSER.!WEBEX12='IBMWebExplorerDLL/v1.2*' 
  57. BROWSER.!WEBEX11='IBMWebExplorerDLL/v1.1*' 
  58. BROWSER.!WEBEX10='IBMWebExplorerDLL/v1.0*' 
  59. BROWSER.!LOTUS45='*Lotus-Notes/4.5*' 
  60. BROWSER.!LOTUS4='*Lotus-Notes/4.[01]*' 
  61. BROWSER.!LYNX='Lynx/*' 
  62. BROWSER.!LYNX24='Lynx/2-4-[12]libwww/2.14*' 
  63. BROWSER.!MCI='internetMCI/1.0(Windows)*' 
  64. BROWSER.!MSIE3='Mozilla/2.0*(compatible*MSIE3.*' 
  65. BROWSER.!MSIE2='Mozilla/*compatible*MSIE2.*' 
  66. BROWSER.!MSIE1='Mozilla/1.22*compatible*MSIE1.*' 
  67. BROWSER.!MSIE4='MicrosoftInternetExplorer/4.*' 
  68. BROWSER.!MOSAIC27='NCSA_Mosaic/2.7*' 
  69. BROWSER.!MOSAIC26='NCSA_Mosaic/2.6(X11*' 
  70. BROWSER.!MOSAIC2='NCSAMosaic/2.*' 
  71. BROWSER.!NETCOM3='NetCruiser/V3.*' 
  72. BROWSER.!NETCOM2='NetCruiser/V2.*' 
  73. BROWSER.!NETCOM1='NetCruiser/V1.*' 
  74. BROWSER.!NETMANAGE='NetManageChameleonWebSurfer/*' 
  75. BROWSER.!NETSCAPE4='Mozilla/4.*' 
  76. BROWSER.!NETSCAPE3='Mozilla/3.*' 
  77. BROWSER.!NETSCAPE2='Mozilla/2.*' 
  78. BROWSER.!NETSCAPE1='Mozilla/1.*' 
  79. BROWSER.!OMNIWEB='OmniWeb/2.0*OWF/1.0*' 
  80. BROWSER.!PRODIGY2='PRODIGY-WB/2.*' 
  81. BROWSER.!PRODIGY1='PRODIGY-WB/1.*' 
  82. BROWSER.!QUARTERDECK='QuarterdeckMosaicVersion*' 
  83. BROWSER.!MOSAICSEC='SecureNCSAMosaicfortheXWindowSystem/0.[34]*' 
  84. BROWSER.!SPRY='SPRY_Mosaic/v8.*SPRY_package/v4.00*' 
  85. BROWSER.!AIR='AIR_Mosaic(16bit)/v1.00.198.07*' 
  86. BROWSER.!SPRY4='AIR_Mosaic(16bit)/v4.*' 
  87. BROWSER.!SPRY3='AIR_Mosaic(16bit)/v3.*' 
  88. BROWSER.!SPYGLASS1='SpyglassMosaic/1.02_Win32*' 
  89. BROWSER.!SPYGLASSWIN2='Enhanced_Mosaic/2.1*Win32Spyglass/*' 
  90. BROWSER.!SPYGLASSSOL2='Enhanced_Mosaic/2.1*SolarisSpyglass/*' 
  91. BROWSER.!SPYGLASSDEC2='Enhanced_Mosaic/2.1*DEC_AlphaSpyglass/*' 
  92. BROWSER.!SPYGLASS2='Enhanced_Mosaic/2.*' 
  93. BROWSER.!WOLLONGONG='Emissary1.0b*' 
  94.  
  95. BROWSER.!FOO.1='Foo*'
  96. BROWSER.!FOO.2='Bar*'
  97.  
  98.  
  99.  
  100. /*  BROWSER_2.! -- Secondary rules. BROWSER_2.! variables are used when there is 
  101.                    no successful BROWSER.! "pimary rule".
  102.   Syntax: same as BROWSER.!
  103.   Notes:
  104.     +  We advice using  generic (short, with early use of *) u_agents.
  105.     +  You can use u_agents specified in BROWSER.! rules.
  106. */
  107.  
  108. BROWSER_2.!NETSCAPE2.0='Mozilla/2.*'  
  109. BROWSER_2.!NETSCAPE2.1='Mozilla/3.*'
  110. BROWSER_2.!NETSCAPE2.2='Mozilla/4.*'
  111. BROWSER_2.!NET='Mozilla*'   
  112. BROWSER_2.!MSIE3.1='Mozilla/2.*MSIE*3*'
  113. BROWSER_2.!MSIE3.2='Mozilla/2.*MSIE*4*'
  114. BROWSER_2.!MOSAIC='*MOSAIC'
  115.  
  116.  
  117. /************* END USER CHANGABLE PARAMETERS **************/
  118. /************* END USER CHANGABLE PARAMETERS **************/
  119.  
  120. /* 1) Extract user-agent*/
  121. myagent=upper(space(reqfield('user-agent'),0))
  122.  
  123. /* 1a)Determine a base file name*/
  124. parse arg targfile 
  125. if targfile<>'' then USEDFILE=sref_do_virtual(ddir,TARGFILE,enmadd,0,,homedir,host_nickname)
  126.  
  127. a1=lastpos('.',usedfile)            
  128. if a1>0 then
  129.   basefile=delstr(usedfile,a1+1)
  130. else
  131.   basefile=usedfile||'.'
  132.  
  133.  
  134. /* Get list of BROWSER. variables */
  135. foo=cvtails('BROWSER.',btails)
  136.  
  137. /* compare each browser. entry */
  138. gotit='' ; oldresu=''
  139. do t1=1 to btails.0
  140.   avv=upper(btails.t1)
  141.   aresu=sref_wild_match(myagent,space(browser.avv,0),oldresu)
  142.   if aresu=0 then iterate  /* 0 means no, or inferior, match */
  143.   parse var avv '!' gotit '.' .
  144.   if aresu=-1 then leave    /* -1 means exact match */
  145.   oldresu=aresu            /* gotta beat oldresu */
  146. end
  147. if gotit<>'' then do    /* got a match-- see if a file exists */
  148.    a2=basefile||gotit   /* this is the file to find */
  149.    if stream(a2,'c','query exists')<>'' then do  /* it does exist */
  150.        if verbose>3 then call pmprintf("ByBrowsr using " a2)
  151.    end
  152.    else do
  153.       gotit=''
  154.       if verbose>2  then call pmprintf('ByBrowser caution. no such file: 'a2)
  155.    end /* do */
  156. end
  157.  
  158. /* compare each browser_2. entry (perhaps look at more then one)? */
  159. if gotit='' then do
  160.    foo=cvtails('BROWSER_2.',btails)
  161.    do forever
  162.  
  163.      oldresu=''
  164.      do t1=1 to btails.0
  165.        avv=upper(btails.t1)
  166.        if avv='' then iterate /*was removed */
  167.        aresu=sref_wild_match(myagent,space(browser_2.avv,0),oldresu)
  168.        if aresu=0  then do
  169.           if oldresu='' then btails.t1=''  /* save time later? */
  170.           iterate  
  171.        end
  172.        parse var avv '!' gotit '.' .
  173.        uset1=t1
  174.        if aresu=-1 then leave    
  175.        oldresu=aresu           
  176.      end                /* check all tails */
  177.  
  178.      if gotit='' then leave     /*no match, give up */
  179.      
  180.      if gotit<>'' then do    /* got a match-- see if a file exists */
  181.         a2=basefile||gotit              
  182.         if stream(a2,'c','query exists')<>'' then do  
  183.            if verbose>3 then call pmprintf("ByBrowsr using 2ndary file:" a2)
  184.            leave
  185.         end
  186.         else do 
  187.            gotit=''
  188.            btails.uset1=''     /* skip this entry on next round */
  189.            if verbose>1  then call pmprintf('ByBrowser caution. no such 2ndary file: 'a2)
  190.         end /* do */
  191.      end                /* got a match */
  192.   end           /* forever */
  193. end             /* gotit<>'' */
  194.  
  195. /* no match, use default (don't bother checking */ 
  196. if gotit='' then  gotit=default
  197.  
  198.  
  199. /* now return */
  200. if targfile<>' ' then do   /* use "virtual" Mode */
  201.    a1=lastpos(targfile,'.')
  202.    if a1=0 then
  203.        goo=targfile||'.'||gotit
  204.    else
  205.       goo=delstr(targfile,a1+1)||gotit
  206.    return '<!-- #include virtual='||goo||'" -->'
  207. end /* do */
  208.  
  209. goo=filespec('n',basefile||gotit)               /* file mode (invoking file, hence same dir) */
  210. return '<!-- #include file='||goo||'" -->'
  211.  
  212.