home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 35 Internet / 35-Internet.zip / srev13g.zip / srefmon.cmd < prev    next >
OS/2 REXX Batch file  |  1999-06-27  |  103KB  |  3,354 lines

  1. /* SRE-http monitor routine (run as a non-transient thread in same process
  2. as goserve */
  3.  
  4. /*BEGIN  --- */
  5.  
  6.  
  7. /* check that GoServe's settings are appropriate for http/1.1 compliance 
  8.   (1=check, 0=do not check). If 1, and not compliant, error occurs*/
  9. check_compliance=1
  10.  
  11. /* set to 1 to clear macrospace at startup */
  12. clear_macrospace=0
  13.  
  14. /* reset after this many loops */
  15. doanyway_loops=300      
  16.  
  17.  /* set = 1 to occasionally cleanup orphaned cgi-bin temp files */
  18. do_cleanup=1     
  19.  
  20.  
  21. /* the maximum size of common, referer and browser log 
  22.   files (in kbytes). When the size of a log file exceeds
  23.   this length, it will be renamed.
  24.   Set to 0 to supress this renaming.
  25. */
  26. logfile_maxsize=0
  27.  
  28. /* Size of MD5 cache (used by DOMD5.RXX daemon.
  29.    If 0, then do NOT use md5 daemon (compute each
  30.    md5 as needed.
  31.    A non-0 cache (hence use of the md5 daemon) can speed up 
  32.    throughput (especially if the number of commonly used files
  33.    is fairly small), and may avoid sys3175 errors on some
  34.    systems
  35.    A recommended non-zero size is 800.
  36.    Note: if content_md5=0 (in initfilt.80), 
  37.           you SHOULD set md5_cache=0
  38. */
  39. md5_cache=0
  40.  
  41. /* set=1 to suppress clientname lookup (returns ip number whenever
  42.          clientname is asked for (useful if no DNS is available) */
  43. no_dns=0
  44.  
  45. /* set=1 to suppress search-for & use of superceding realms */
  46. NO_SUPERCEDING_REALM=0
  47.  
  48. /* max line length to "sref_pmprintf" */
  49. pmprintf_line_length=150 
  50.  
  51. /* name of the sref_pmprintf log file (in goserve directory) */
  52. pmprintf_log_file='SREHTTP.LOG ' 
  53.  
  54.  
  55. /* Number of "variable storage daemons" to start. If you are use 
  56.    SRE-http queues, it can be useful to start multiple instances of the
  57.    variable storage daemon (say, one per queue). The default is 1 
  58.    (see SREFQUE.DOC for details) */
  59. storage_daemons=1
  60.  
  61. /* set to 0 to suppress dynamic loading of sre-http procedures 
  62.    If you set this to 0, then you must create the SREFPRC.RXL file
  63.    (using the makelib.cmd program) */
  64. use_dynamic_lib=1    
  65.  
  66.  
  67. /* Fully qualified directory: the location of the .SRF "macrospace" 
  68.   procedures. 
  69.   If blank, use the default (LIB subdirectory under your goserve directory). 
  70.   We  STRONGLY recommend using the '' (blank) default! */
  71. use_lib_dir=''
  72.  
  73.  
  74. /* Fully qualified directory: the location of the SRE-http configuration files
  75.   If blank, use the default (CFG subdirectory under your goserve directory). 
  76.   We STRONGLY recommend using the '' (blank) default! */
  77. CFGs_dir=''
  78.  
  79.  
  80. /*END --- */
  81.  
  82. /* ---------- DO NOT CHANGE BELOW HERE  ----------------*/
  83.  
  84. signal on error name yipes ; signal on syntax name yipes ;
  85. signal on failure name yipes ; signal on halt name yipes ;
  86.  
  87.  
  88. parse arg goserve_pid, thesem,servdir,SERVERPORT,envadd,max_semwait,moreargs,key_preface, ,
  89.                 x_limitclients,x_fasfile,x_limittimewait,x_gmtset,x_server
  90.  
  91. if servdir=" " then do
  92.    say " This SRE-http daemon is NOT meant to be invoked from an OS/2 prompt!"
  93.   exit
  94. end  /* Do */
  95.  
  96.  
  97. /* CHeck connection maintain on and gmt */
  98. if check_compliance=1 then do
  99.   a1=x_fastfile   /* extract('fastfile') */
  100.   a2=x_limittimewait /* extract('limittimewait') */
  101.   a3=x_gmtset        /* extract('gmtset') */
  102.   a4=x_server       /*  server('h') */
  103.   parse var a4 .'/' gver
  104.   if a1='ON' then do
  105.      call pmprintf(' Caution: The GoServe Cache is enabled.  ')
  106.      call pmprintf('      The GoServe 2.52 (or less) cache is NOT http/1.1 compliant.')
  107.      call pmprintf('      (that is: the goserve cache should be used with care!')
  108.   end /* do */
  109.   if a2 <= 0 then do
  110.      call pmprintf(' **** ERROR: Connection Maintain is NOT enabled')
  111.      call pmprintf('             Http 1.1 compliance requires persistent connections.')
  112.      call pmprintf('      (set the GoServe-Options-Limits-Connection_Maintain parameter)')
  113.      call gosexit 'Connection Maintain is NOT enabled'
  114.   end /* do */
  115.   if a3='OFF' then do
  116.      call pmprintf(' **** ERROR: GMT not available.')
  117.      call pmprintf('             Http 1.1 compliance requires GMT time information')
  118.      call pmprintf('       (you should check the TZ parameter in CONFIG.SYS)')
  119.      call gosexit 'GMT not available.'
  120.   end /* do */
  121.   if gver<2.52 then do
  122.      call pmprintf(' **** ERROR: Pre 2.52 version of GoServe.')
  123.      call pmprintf('             Http 1.1 compliance requires GoServe 2.52 or above')
  124.      call pmprintf('      (see http://www2.hursley.ibm.com/goserve for the latest GoServe).')
  125.      call gosexit 'Pre 2.52 version of GoServe.'
  126.   end
  127. end
  128.  
  129. parse var moreargs loadthreshold ',' backupserverlist ','  ,
  130.    delay_seconds ',' message_scramble ',' record_cache_lines ',' logon_limit ',' ssi_extensions ',' ,
  131.    ssi_cache_size ',' ssi_cache_duration ',' ssi_cache_stamp ',' no_no_record ',' hit_superuser_suppress ',' pmprintf_opt ',' ,
  132.    NO_REMOTE_CONFIG '!!' custom_inits '!!' cgi_post_long_get ',' get_decode_options ',' ,
  133.    never_publicurls ',' digest_auth ',' proxy_cache ',' suppress_gzip_te','pre_reply_procedure
  134.  
  135. loadthreshold=strip(loadthreshold) ; backupserverlist=strip(backupserverlist)
  136. delay_seconds=strip(delay_seconds) ; message_scramble=strip(message_scramble)
  137. record_cache_lines=strip(record_cache_lines)
  138. logon_limit=strip(logon_limit)
  139. pmprintf_opt=strip(pmprintf_opt)
  140. if wordpos(pmprintf_opt,'1 2 3')=0 then pmprintf_opt=1
  141. if wordpos(digest_auth,'Y YES 1')=0 then
  142.    digest_auth=0
  143. else
  144.    digest_auth=1
  145.  
  146. if wordpos(SUPPRESS_GZIP_TE,'Y YES 1')=0 then
  147.    suppress_gzip_te=0
  148. else
  149.    suppress_gzip_te=1
  150.  
  151. if pre_reply_procedure='' then pre_reply_procedure=0
  152.  
  153. a1=left(strip(proxy_cache),1)  /* n_wait or n (n=0,1,2,3, wait=seconts */
  154. if wordpos(a1,'1 2 3')=0 then proxy_cache=0  /* 0 otherwise */
  155.  
  156. ssi_extensions=strip(ssi_extensions)
  157. ssi_cache_size=strip(ssi_cache_size)
  158. ssi_cache_duration=strip(ssi_cache_duration)
  159. ssi_cache_stamp=upper(strip(ssi_cache_stamp))
  160. no_no_record=strip(no_no_record)
  161. IF WORDPOS(NO_REMOTE_CONFIG,'0 1 2')=0 THEN NO_REMOTE_CONFIG=0
  162. custom_inits=strip(custom_inits)
  163.  
  164. tmp=upper(strip(cgi_post_long_get))
  165. if datatype(tmp)<>'NUM' then tmp=0
  166. cgi_post_long_get=tmp
  167. if wordpos(tmp,'1 YES Y')>0 then cgi_post_long_get=240
  168. if wordpos(tmp,'0 NO N') then cgi_post_long_get=20000
  169.  
  170. tmp=upper(strip(get_decode_options))
  171. get_decode_options=0
  172. if wordpos(tmp,'1 YES Y')>0 then get_decode_options=1
  173.  
  174.  
  175. /* pmprintf modiification? */
  176. foo=start_pmprintf(pmprintf_opt,pmprintf_line_length,pmprintf_log_file)
  177.  
  178. if datatype(logon_limit)<>'NUM' then logon_limit=0
  179. if datatype(delay_seconds)<>'NUM' then delay_Seconds=9
  180. if datatype(message_scramble)<>'NUM' then message_scramble=12415
  181.  
  182. if datatype(doanyway_loops)<>'NUM' then doanyway_loops=150
  183.  
  184. foo=value('SREF_NODNS',no_dns,'os2environment')
  185.  
  186. if no_superceding_realm<>1 then no_superceding_realm=0
  187. foo=value("SREF_NO_SUPERCEDING_REALM",no_superceding_realm,'os2environment')
  188.  
  189. foo=value('SREF_ENABLE_ENCRYPTION',,'OS2ENVIRONMENT')
  190. if wordpos(foo,'0 1 2 3')=0 then do
  191.     foo=value('SREF_ENABLE_ENCRYPTION',0,'os2environment')
  192. end /* do */
  193.  
  194. foo=value('SREF_DEFAULT_ENCRYPTION',,'OS2ENVIRONMENT')
  195. if  foo='' | foo=0 then do
  196.    foo=value('SREF_DEFAULT_ENCRYPTION','SRE_A','OS2ENVIRONMENT')
  197. end
  198.  
  199. if datatype(md5_cache)<>'NUM' then md5_cache=0
  200.  
  201. if \RxFuncQuery("SockLoadFuncs") then nop
  202. else do
  203.        call RxFuncAdd "SockLoadFuncs","rxSock","SockLoadFuncs"
  204.        call SockLoadFuncs
  205. end
  206. foo=rxfuncquery('UZLoadFuncs')   /* load UNZIP dll */
  207. if foo=1 then do
  208.   call RxFuncAdd 'UZLoadFuncs', 'UNZIPAPI', 'UZLoadFuncs'
  209.   call UZLoadFuncs
  210. end
  211.  
  212. foo=rxfuncquery('UZLoadFuncs')   /* load UNZIP dll */
  213. if foo=1  then call pmprintf(' SRE-http Monitor: Warning: UNZIPAPI.DLL not found ')
  214.  
  215. if rxfuncquery('sref_fileread')<>0 then do
  216.   ik=rxfuncadd('sref_fileread','rexxlib','LIB_FILEREAD')
  217.   if ik<>0 then call pmprintf(' SRE-http Monitor: Warning: unable to register SREF_FILEREAD')
  218. end
  219.  
  220.  
  221. if rxfuncquery('sref_filewrite')<>0 then do
  222.   ik=rxfuncadd('sref_filewrite','rexxlib','LIB_FILEWRITE')
  223.   if ik<>0 then call pmprintf(' SRE-http Monitor: Warning: unable to register SREF_FILEWRITE')
  224. end
  225.  
  226.  
  227. if rxfuncquery('srx_md5')=1  then do
  228.   call RXFuncAdd 'SRXLoadFuncs', 'SRXFUNC', 'SRXLoadFuncs'
  229.   call SRXLoadFuncs
  230. end
  231. if rxfuncquery('srx_md5')=1  then 
  232.   call pmprintf("SRE-http Monitor: Unable to load SRX_MD5 from SRXFUNC.DLL")
  233.  
  234.  
  235. if max_semwait="" then max_semwait=3000
  236.  
  237. if clear_macrospace=1 then fo=macroclear()
  238.  
  239. CALL  load_rxl(0)  /* load macrospace library */
  240.  
  241.  
  242. /* set configuration files directory */
  243. if CFGs_dir='' then
  244.    CFGs_dir=servdir||'\CFGS'
  245. else
  246.    CFGs_dir=strip(cfgs_dir,'t','\')
  247. aa=value('SRE_CFGS_DIR',CFGs_dir,'os2environment')
  248.  
  249. cfglist_file=cfgs_dir||'\CFGLIST.CFG'
  250.  
  251.  
  252.  
  253. IF result<0  then    do       /* fatal error if not found */
  254.   call pmprintf(' SRE-http Monitor: ERROR: could not load macrospace library ')
  255.   call gosEXIT ' could not load macrospace library '
  256. end
  257.  
  258. IF PRE_REPLY_PROCEDURE<>0 then DO
  259.    FOO=STREAM(PRE_REPLY_PROCEDURE,'C','query exists')
  260.    if foo='' then do
  261.        call pmprintf("SRE-http Monitor: ERROR: no such PRE_REPLY_PROCEDURE: "pre_reply_procedure)
  262.        call gosEXIT ' missing pre_reply_procedure'
  263.    end /* do */
  264. /* load into macrospace */
  265.    foo=macroadd('SREF_PREREPLY_PROC',pre_reply_procedure,'B')
  266.    if foo=0 then do
  267.        call pmprintf("SRE-http Monitor: ERROR: error loading PRE_REPLY_PROCEDURE: "pre_reply_procedure)
  268.        call gosEXIT ' bad pre_reply_procedure'
  269.    end
  270.    foo=value('SREF_PRE_REPLY',1,'os2environment')
  271.    if verbose>1  then call pmprintf("SRE-http Monitor: PRE_REPLY_PROCEDURE enabled ")
  272. end /* do */
  273. else do
  274.    foo=value('SREF_PRE_REPLY',0,'os2environment')
  275. end /* do */
  276.  
  277.  
  278. doo=dostid()
  279. oo=dospid()||' '||dostid()
  280.  
  281. numeric digits 11
  282.  
  283. call pmprintf(" SRE-http Monitor: Initializing on port "|| serverport || ": " || filter_name' ('filter_number)
  284. call pmprintf(" SRE-http Monitor: Goserve pid ="|| goserve_pid' , Monitor thread '||doo)
  285. call pmprintf(" SRE-http Monitor: Using semaphore "|| thesem)
  286. parse upper version rexxtype .
  287. os2ver=sysos2ver()
  288. call pmprintf(" SRE-http Monitor: Using REXX version: " rexxtype ', under OS/2 ver 'os2ver)
  289.  
  290.  
  291. /* cycle through list of custom_init routines */
  292. foo=call_custom_Inits(custom_Inits)
  293.  
  294.  
  295. /* after this, use pmprintf_sref */
  296.  
  297. /* start variable storage daemon */
  298. if storage_daemons=0 | datatype(storage_daemons)<>'NUM' then storage_Daemoms=1
  299. do iss=1 to storage_daemons
  300.    if iss=1 then
  301.      goon=''
  302.    else
  303.      goon='_'||iss
  304.    aa=start_varstore(goon)
  305. end /* do */
  306. call syssleep 1         /* wait for daemons to settle down */
  307.  
  308. if record_cache_lines>0 then
  309.    foo=pmprintf_sr(" SRE-http Monitor: Record cache file size= "||record_cache_lines)
  310.  
  311.  
  312. /* set location of init_File (check cgs_dir first, then servdir */
  313. init_File=stream(cfgs_dir"\INITFILT."||serverport,'c','query exists')
  314. if init_file='' then  init_file=servdir||"\INITFILT."||serverport
  315. filedate.initfilt=file_juldate(init_file)
  316.  
  317. filedate.cfglist=file_juldate(cfglist_file)
  318.  
  319.  
  320. call get_initfilt(0)  /* and read cfglist.cfg */
  321.  
  322. if result<0 then do
  323.           call pmprintf(' SRE-http Monitor ERROR: aborting due to initfilt error(s) ')
  324.           call gosexit 'initfilt error(s) '
  325. end
  326.  
  327. call clear_temp(0)
  328.  
  329. if result<0  then do
  330.   call pmprintf(" SRE-http Monitor ERROR : No INITFILT file ")
  331.   call gosexit "no INITFILT file "
  332. end
  333.  
  334. DEFREALM_FILE=cfgs_dir||'\ATTRIBS.CFG'
  335. DEFREALM_FILE_temp=tempdata_dir||'\$DFREALM.'||serverport
  336.  
  337. filedate.DEFREALM=file_juldate(DEFREALM_FILE)
  338.  
  339. foo= update_addons(0)
  340.  
  341. mediatyp_file=servdir||"\MEDIATYP.RXX"
  342. filedate.mediatyp=file_juldate(mediatyp_file)
  343. mediatyp_tfile=tempdata_dir||'\MEDIATYP.TMP'
  344. call value 'SREF_MEDIATYP_TFILE',mediatyp_tfile,'os2environment'
  345. call chk_mediatyp(0)
  346.  
  347.  
  348. call value 'SREF_DEFREALM_FILE',DEFREALM_FILE,'os2environment'
  349. call value 'SREF_DEFREALM_FILE_TEMP',DEFREALM_FILE_temp,'os2environment'
  350. call make_DEFREALM_FILE_temp(0)
  351.  
  352. filedate.repstrgs=file_juldate(repstrgs_file)
  353. repsvars.0=0
  354. call chk_repstrgs(0)
  355.  
  356.  
  357. filedate.access=file_juldate(access_file)
  358. aa=start_access(0)
  359.  
  360. filedate.alias=file_juldate(alias_file)
  361. aa=start_alias(0)
  362.  
  363. filedate.puburl=file_juldate(puburl_file)
  364. aa=start_puburl(0)
  365.  
  366. filedate.user=file_juldate(user_file)
  367. aa=start_user(0)
  368.  
  369. filedate.virtual=file_juldate(virtual_file)
  370. aa=start_virtual(0)
  371.  
  372. call start_srealm(0)
  373.  
  374. aa=start_ssicache(0)
  375.  
  376. aa=start_sreproxy(0)
  377. if aa=-1 then do
  378.    call pmprintf(' SRE-http Monitor ERROR: aborting due to sreproxy error ')
  379.    call gosexit 'SREProxy error '
  380. end 
  381.  
  382. aa=start_postf(0)
  383.  
  384. if md5_cache>0 then do
  385.    arxx=servdir||'\SREdomd5.cmd'
  386.    foo=n_launch('MD5_DMN_SREF',arxx,md5_cache)
  387.   
  388.    if strip(word(foo,1))<0 then do
  389.        call pmprintf(" SRE-http Monitor: could not launch md5 daemon: "foo)
  390.        foo=value('SREF_MD5DMN',1,'os2environment')
  391.    end
  392.    else do
  393.        call pmprintf(" SRE-http Monitor: MD5 daemon in seperate process "foo)
  394.        md5pid=foo
  395.        foo=value('SREF_MD5DMN',1,'os2environment')
  396.    end
  397. end
  398. else do
  399.    foo=value('SREF_MD5DMN',0,'os2environment')
  400. end
  401.  
  402.  
  403. aa=eventsem_create(thesem)
  404. if aa<0 then do
  405.  call pmprintf(" SRE-http Monitor: ERROR: could not create semaphore: "||thesem)
  406.  call gosexit "could not create semaphore: "||thesem
  407. end
  408. foo=eventsem_post(thesem)       /* let the boys have it */
  409.  
  410. foo=value('SREF_WAIT_FLAG',0,'os2environment')
  411.  
  412. foo=pmprintf_sr(' SRE-http Monitor: Begin Monitoring parameters files ..... ')
  413. nloops=0
  414. geelist="INITFILT REPSTRGS MEDIATYP ALIAS ACCESS USER VIRTUAL PUBURL CFGLIST DEFREALM "
  415.  
  416. do forever
  417.   nloops=nloops+1
  418.    IF result<0 then do
  419.       call pmprintf(' SRE-http Monitor ERROR: leaving after rxl error')
  420.       leave
  421.    end
  422.  
  423. /* get dates of current files  -- 0 if doesnt exist */
  424.    t1.initfilt=file_juldate(init_file)
  425.    t1.cfglist=file_Juldate(cfglist_file)
  426.    t1.DEFREALM=file_Juldate(DEFREALM_FILE)
  427.  
  428.    t1.repstrgs=file_juldate(repstrgs_file)
  429.    t1.mediatyp=file_juldate(mediatyp_file)
  430.  
  431.    t1.alias=file_juldate(alias_file)
  432.    t1.puburl=file_juldate(puburl_file)
  433.  
  434.    t1.access=file_juldate(access_file)
  435.    t1.user=file_juldate(user_file)
  436.    t1.virtual=file_juldate(virtual_file)
  437.  
  438.    if md5_cache>0 then do            /* md5 cache still healthy? */
  439.         afoo=dosprocinfo('N',md5pid)
  440.         if afoo='' then do
  441.            foo=value('SREF_MD5DMN',-1,'os2environment')
  442.            call pmprintf(' SRE-http Monitor: MD5 digest wil not be computed -- daemon disappeared! ')
  443.            md5_cache=0
  444.         end
  445.    end
  446.  
  447.  
  448. /* any of them newer then last stored files */
  449.    redo=0
  450.    do mm=1 to words(geelist)
  451.        oo1=word(geelist,mm)
  452.        if t1.oo1 > filedate.oo1 then do
  453.            redo=1
  454.            filedate.oo1=t1.oo1
  455.         end
  456.    end
  457.  
  458.    if nloops>doanyway_loops then do         /* every 60 (or so) minutes, reset it anyways */
  459.         nloops=1                  /* just to be safe! */
  460.         redo=1
  461.    end
  462.    foo=value('SREF_REDO',,'os2environment')
  463.    if foo=1 then do 
  464.       redo=1
  465.    end  /* Do */
  466.    foo=value('SREF_REDO',0,'os2environment')  /* reset to 0*/
  467.  
  468. /* one of three ways of being a redo? then reset */
  469.    if redo=1 then do            /* reset all stuff */
  470.  
  471.       foo=pmprintf_sr(" SRE-http resetting variables ")
  472.  
  473.       call get_initfilt(filedate.initfilt)  /* and read hosts.cfg */
  474.       if result<0 then do
  475.           call pmprintf(' SRE-http Monitor ERROR: aborting due to initfilt error(s) ')
  476.           leave
  477.       end
  478.       call start_access(1)
  479.       call start_alias(1)
  480.       call start_puburl(1)
  481.  
  482.       call start_user(1)
  483.  
  484.       call start_srealm(1)
  485.  
  486.       call start_virtual(1)
  487.       call chk_repstrgs(0)
  488.       call chk_mediatyp(0)
  489.       call make_DEFREALM_FILE_temp(0)
  490.  
  491.       call start_sreproxy(1)
  492.  
  493.       foo= update_addons(0)
  494.  
  495. /* store dates of just reset files (initfilt may have changed names */
  496.      filedate.access=file_juldate(access_file)
  497.      filedate.alias=file_juldate(alias_file)
  498.      filedate.puburl=file_juldate(puburl_file)
  499.  
  500.      filedate.user=file_juldate(user_file)
  501.      filedate.virtual=file_juldate(virtual_file)
  502.      filedate.repstrgs=file_juldate(repstrgs_file)
  503.      filedate.mediatyp=file_juldate(mediatyp_file)
  504.      filedate.initfilt=file_juldate(init_file)
  505.      filedate.cfglist=file_juldate(cfglist_file)
  506.      filedate.DEFREALM=file_juldate(DEFREALM_FILE)
  507.  
  508.      CALL load_rxl(1)
  509.  
  510.      foo=pmprintf_sr(' SRE-http Monitor: Success resetting parameters ')
  511.     end
  512.  
  513. /* always check up on cached files (note that they may have
  514. changed if initfilt was updated */
  515.  
  516.     n=delay(delay_seconds)
  517.  
  518. /* get current env variables, perhaps write to pmprintf */
  519.    if display_env=1  then do
  520.        foo=pmprintf_sr(" Current SREF environment variables -----  ")
  521.        wow=dosenvlist(envs)
  522.        do kj=1 to envs.0
  523.            tv=strip(envs.kj)
  524.            if abbrev(tv,'SRE')=0 then iterate
  525.            ares=value(tv,,'os2environment')
  526.            iii=min(100,length(ares))
  527.            if abbrev(tv,'SREF_')=1 then 
  528.                 parse var tv . '_' . '_' atv
  529.            else
  530.                 parse var tv . "_" atv 
  531.            foo=pmprintf_sr(atv'='left(ares,iii))
  532.        end
  533.        foo=pmprintf_sr(' --- end of sref environment variables ')
  534.        display_env=0
  535.    end
  536.  
  537. /* CAN'T DO THIS UNDER NEW GOSERVE 
  538.    ext1=extract('clients') */
  539.  
  540. /* note: small chance that this will delete a client's cgi-stuff that
  541. get's invoked just after the above extract('clients'). But, that just
  542. messes 1 client up, and it's so unlikely that it's not worth worrying about */
  543.    if redo=1 & do_cleanup=1 then foo=clear_temp(1)
  544.  
  545. end  /* forever loop */
  546.  
  547.  
  548. exit            /* should never get here ! */
  549.  
  550. yipes:
  551. call pmprintf(" SRE-http Monitor ERROR at: " sigl', rc='rc )
  552. exit 'Error in SREFMON'
  553.  
  554. /* --------- END OF MAIN ---------------------------------------- */
  555.  
  556. /* ------------------------------------------------- */
  557. /* Routine to check, and load if neccessary,  SREFPRC.RXL into macrospace */
  558. /* ------------------------------------------------- */
  559.  
  560. load_rxl:
  561.  
  562. if use_dynamic_lib<>1 then do                /* load srefprc.rxl */
  563.   call load_rxl_old
  564.   return 1
  565. end
  566.  
  567. if use_lib_dir='' then
  568.    lib_dir=servdir||'\LIB'
  569. else
  570.    lib_dir=strip(use_lib_dir,'t','\')
  571.  
  572. aa=value('SRE_LIBDIR',lib_dir,'os2environment')
  573. tempsref=lib_dir||'\TEMPSREF.CMD'
  574.  
  575. parse arg eek1
  576. if dosisdir(lib_dir)=0 then do
  577.   call pmprintf(' SRE-http Monitor: FATAL ERROR: could not find Library Directory: 'lib_dir)
  578.   call gosexit 'could not find Library Directory: 'lib_dir
  579. end  /* Do */
  580.  
  581. nosref0=0
  582. first_load=0
  583. if macroquery('SREF_ERROR')="" then do  /* load rxl library? */
  584.    first_load=1
  585.    call pmprintf('SRE-http Monitor: Library directory= 'lib_dir)
  586.    parse upper version rexxtype .
  587.    if rexxtype="OBJREXX" then do
  588.         call pmprintf(" SRE-http Monitor: ERROR. SRE-http will not run under object rexx ")
  589.         call gosexit  "SRE-http will not run under object rexx "
  590.    end
  591.    else do
  592.        call pmprintf(" SRE-http Monitor: Loading SREFPRC.RXL into macrospace ")
  593.        rxlfile=lib_dir||'\SREFPRC.RXL'
  594.    end
  595. /* get procedure with procnames in it */
  596.    aa=macroload(rxlfile)
  597.    if aa=0 then do
  598.       call pmprintf(" SRE-http Monitor: ERROR: "|| rxlfile ||" not available! "|| aa)
  599.       call gosEXIT  rxlfile ||" not available! "|| aa
  600.    end
  601.    CALL pmprintf(" SRE-http Monitor: Success on macrospace dynamic library load ")
  602. end
  603. filter_name=sref_version()
  604. filter_number=sref_version(,1)
  605.  
  606.  
  607.  
  608. RETURN 1
  609.  
  610. /* old, non-dynamic version */
  611.  
  612. load_rxl_old:
  613. nosref0=0
  614. first_load=0
  615. if macroquery('SREF_VERSION')="" then do  /* load rxl library? */
  616.    first_load=1
  617.  
  618.    parse upper version rexxtype .
  619.    if rexxtype="OBJREXX" then do
  620.         call pmprintf(" SRE-http Monitor: ERROR. SRE-http will not run under object rexx ")
  621.         call gosexit  "SRE-http will not run under object rexx "
  622.    end
  623.    else do
  624.        call pmprintf(" SRE-http Monitor: Loading SREFPRCS.RXL into macrospace ")
  625.        tt=servdir||'\SREFPRCS.RXL'  
  626.    end
  627.    aa=macroload(tt)
  628.    if aa=0 then do
  629.       call pmprintf(" SRE-http Monitor: ERROR: "|| tt ||" not available! "|| aa)
  630.       RETURN -1
  631.    end
  632.    foo=pmprintf_sr(" SRE-http Monitor: Success on macrospace library load ")
  633. end
  634. filter_name=sref_version()
  635. filter_number=sref_version(,1)
  636. return 1
  637.  
  638.  
  639.  
  640. /* md5 daemon (process) launcher. */
  641. n_launch:procedure 
  642.  
  643. parse arg daemon_name,file_name,init_arg
  644.  
  645. /* relative file name? Then assume it's under the goserve addon
  646. directory */
  647.  
  648. fname=strip(upper(file_name))
  649. if pos(':',fname)=0 & abbrev(fname,'\')=0 then do  /*  a relative file */
  650.    addir=sref_value('ADDON_DIR',,'INI')
  651.    if addir<>"" then fname=strip(addir,'t','\')||'\'||fname
  652. end
  653. if fname=' ' then return '-1 Could not find file: 'file_name
  654. fname=stream(fname,'c','query exists')   /* does this file exist */
  655.  
  656. stat=make_em(daemon_name)            /* create queue and semaphore */
  657. if stat=0 then return '-2 Problem creating queue or semaphore '
  658.  
  659. /* launch the daemon as a thread. Provide opitonal argument 
  660. foo=rexxthread('F',fname,daemon_name,init_arg)
  661. if foo=0 then return '-3 Daemon could not be launched '
  662. */
  663.  
  664. /* launch as process */
  665. '@start "SRE-http MD5 daemon" /C 'fname' 'daemon_name' 'init_arg' '||dospid()
  666. if rc<>0 then call pmprintf('SRE-http Monitor warning: rc from start 'fname'='rc) 
  667.  
  668. wpid=sref_dmn_ask('MD5_DMN_SREF','*PID*',30)
  669.  
  670. return wpid                /* success */
  671.  
  672. /*****************************/
  673. /* make queue and semaphore */
  674. make_em:procedure
  675. parse arg aname
  676.  
  677. usesem='\SEM32\SRE_DMN_'||aname
  678. usequeue='SRE_DMN_'||aname
  679.  
  680. aqueue=rxqueue('C',usequeue)
  681. if aqueue<>usequeue then do    /* usequese exists, so kill unneeded new q */
  682.   foo=rxqueue('d',aqueue)      /* kill unneeded queue */
  683.   foo=rxqueue('s',usequeue)
  684.   ik=queued()
  685.   do ll=1 to ik               /* clear out pre existing queue */
  686.        pull boop
  687.    end
  688. end
  689.  
  690. wow=eventsem_query(usesem)
  691. if wow=-187 then do
  692.   foo=eventsem_create(usesem)
  693.   if foo<>0 then return 0
  694. end /* do */
  695. oo=eventsem_reset(usesem)
  696.  
  697. return 1
  698.  
  699. /* ------------------------------------------------- */
  700. /* get date (fat and julian) of a file */
  701. /* ------------------------------------------------- */
  702.  
  703. file_juldate:procedure
  704.  
  705.  
  706. parse arg get_file , isquiet
  707. if GET_file=" " then return 0
  708.  
  709. eek=sysfiletree(translate(get_file,'\','/'),'gosh','FT')
  710. if gosh.0=0 then do  /* no file */
  711.    return 0
  712. end
  713. parse var gosh.1  atime .
  714. aa=sref_juldate('F',atime)
  715. return aa
  716.  
  717. /* ------------------------------------------------- */
  718. /* clear all $*.80, and other temporary files out of tempdata_Dir */
  719. /* ------------------------------------------------- */
  720. clear_temp:
  721. parse arg cl1
  722.  
  723. if cl1<>1 then do               /* only do on startup */
  724.   lookstar=tempdata_dir||'\_DIRLIST.IDX'
  725.   foo=sysfiledelete(lookstar)
  726.  
  727.   lookstar=tempdata_dir||'\MEDIATYP.TMP'
  728.   foo=sysfiledelete(lookstar)
  729.  
  730.   lookstar=tempdata_dir||'\_*.DSH'         /* delete old directory cache files */
  731.   foo=sysfiletree(lookstar,stuff,'Fo')
  732.   do mm=1 to stuff.0
  733.     foo=sysfiledelete(stuff.mm)
  734.   end /* do */
  735.   if stuff.0>0 then
  736.   foo=pmprintf_sr('SRE-http Monitor: Deleted ' stuff.0 ' old directory cache files from: 'tempdata_dir)
  737.  
  738.   lookstar=tempdata_dir||'\_*.TMP'         /* delete old .TMP files */
  739.   foo=sysfiletree(lookstar,stuff,'FO')
  740.   do mm=1 to stuff.0
  741.     foo=sysfiledelete(stuff.mm)
  742.   end /* do */
  743.   if stuff.0>0 then
  744.     foo=pmprintf_sr('SRE-http Monitor: Deleted ' stuff.0 ' _*.TMP files from: 'tempdata_dir)
  745.  
  746.   lookstar=strip(tempdata_dir||'\_T*.'||serverport)         /* delete old .TMP  files */
  747.   foo=sysfiletree(lookstar,stuff,'FO')
  748.   do mm=1 to stuff.0
  749.    foo=sysfiledelete(stuff.mm)
  750.   end /* do */
  751.   if stuff.0>0 then
  752.     foo=pmprintf_sr('SRE-http Monitor: Deleted ' stuff.0 ' _T*.'serverport ' files from: 'tempdata_dir)
  753.  
  754.   lookstar=strip(tempdata_dir||'\_HT*.'||serverport)         /* delete old remote virtual files */
  755.   foo=sysfiletree(lookstar,stuff,'FO')
  756.   do mm=1 to stuff.0
  757.    foo=sysfiledelete(stuff.mm)
  758.   end /* do */
  759.   if stuff.0>0 then
  760.     foo=pmprintf_sr('SRE-http Monitor: Deleted ' stuff.0 ' _HT*.'serverport ' files from: 'tempdata_dir)
  761.  
  762.  
  763.   lookstar=strip(tempdata_dir||'\_ADDPRIV.'||serverport)         /* delete old additional privs  files */
  764.   foo=stream(lookstar,'c','query exists')
  765.   if foo<>'' then do
  766.      foo=sysfiledelete(foo)
  767.      foo=pmprintf_sr('SRE-http Monitor: Deleted additional privileges file ')
  768.   end /* do */
  769.  
  770. end             /* cleanup on startup only */
  771.  
  772.  
  773. /* do on startup, and on periodic cleanup */
  774. nowtime=date('b')+(time('s')/(24*60*60))
  775.  
  776. lookstar=tempdata_dir||'\~*.'||serverport         /* delete old cgi-bin temp files */
  777. foo=sysfiletree(lookstar,stuff,'Ft')
  778.  
  779. kkt=0           /* note: only delete if < .1 day (2.4 hours) old */
  780.  
  781. do mm=1 to stuff.0
  782.    parse var stuff.mm adate ff1 ff2 afile ; afile=strip(afile)
  783.    if cl1==1 then do            /* check time before deleting */
  784.         ttime=dateconv_3(adate,'o','b')
  785.         if nowtime-ttime<0.1 then iterate 
  786.    end
  787.    foo=sysfiledelete(afile)
  788.    kkt=kkt+1
  789. end /* do */
  790. if kkt>0 then
  791.   foo=pmprintf_sr('SRE-http Monitor: Deleted ' kkt ' ~*.80 files from: 'tempdata_dir)
  792.  
  793. lookstar=tempdata_dir||'\$*.'||serverport         /* delete old cgi-bin temp files */
  794. foo=sysfiletree(lookstar,stuff,'Ft')
  795. kkt=0
  796. do mm=1 to stuff.0
  797.    parse var stuff.mm adate ff1 ff2 afile ;afile=strip(afile)
  798.    if cl1==1 then do            /* check time before deleting */
  799.         ttime=dateconv_3(adate,'o','b')
  800.         if nowtime-ttime<0.1 then iterate 
  801.    end
  802.    foo=sysfiledelete(afile)
  803.    kkt=kkt+1
  804. end /* do */
  805. if kkt>0 then
  806.   foo=pmprintf_sr('SRE-http Monitor: Deleted ' kkt ' $*.80 files from: 'tempdata_dir)
  807.  
  808.  
  809. lookstar=strip(tempdata_dir||'\F*.cmd')         /* delete old .TMP  files */
  810. foo=sysfiletree(lookstar,stuff,'Ft')
  811. kkt=0
  812. do mm=1 to stuff.0
  813.    parse var stuff.mm adate ff1 ff2 afile ; afile=strip(afile)
  814.    if cl1=1 then do            /* check time before deleting */
  815.         ttime=dateconv_3(adate,'o','b')
  816.         if nowtime-ttime<0.1 then iterate 
  817.    end
  818.    foo=sysfiledelete(afile)
  819.    kkt=kkt+1
  820. end /* do */
  821. if kkt>0 then
  822.   foo=pmprintf_sr('SRE-http Monitor: Deleted ' kkt ' F*.CMD  files from: 'tempdata_dir)
  823.  
  824.  
  825. return 0
  826.  
  827.  
  828.  
  829. /* ------------------------------------------------- */
  830. /* routine to load initfilt.nnn into macrospace
  831.    return 0= no change , 1= change,return<0=error 
  832.   NOte: if line starts with $xxx, then see if xxx = the MACHINE_ID_SRE.
  833.   If not, skip it
  834. */
  835. /* ------------------------------------------------- */
  836. get_initfilt:
  837. PARSE ARG DACALL
  838.  
  839. get_file=init_file
  840. if get_file=" " then return 0
  841. oy=stream(get_file,'c','query exists')
  842. if oy=' ' then do
  843.    CALL pmprintf("SRE-http Monitor:FATAL ERROR. INITFILT file not found, "|| get_file)
  844.    call gosexit  "INITFILT file not found, "|| get_file
  845. end
  846.  
  847. /* get machine if, if set */
  848. machine_id=value('MACHINE_ID_SRE',,'os2environment')  /* should be a global env var */
  849. if verbose>2 then call pmprintf(" SRE-http Monitor: Machine ID = " machine_id)
  850.  
  851.  
  852. /* get list of possible host specific variables: and clear their values */
  853. a=rxqueue('s','session')
  854. wow=dosenvlist(envs)
  855. if wow=0 then do
  856.     call pmprintf(" SRE-http: Warning: Environment appears to be empty ")
  857. end /* do */
  858. else do
  859.    do mm=1 to envs.0
  860.       ares0=envs.mm
  861.       if abbrev(upper(ares0),'SREF_')=1 then do
  862.          parse upper var ares0 ares '=' .
  863.          ibeam=lastpos('.',ares)
  864.          if ibeam>0 then do
  865.            cat3=substr(ares,ibeam+1)
  866.            if datatype(cat3)<>'NUM' then do
  867.               parse var ares . '_' . '_' ares1 '=' .
  868.               interpret ares1||'=" " '
  869.               if verbose>3 then foo=pmprintf_sr('SRE-http Monitor: clearing: ' ares1)
  870.            end          /* got a host specific entry ; ie. fix_expire.host2= */
  871.          end  /* got a . ed entry */
  872.       end
  873.    end     /* an sref entry */
  874. end     /* envlist empty */
  875.  
  876. call default_initfilt           /* default values */
  877.  
  878. ause=sref_fileread(get_file,'filelines',,'E')
  879. If (ause<=0) then  do               /*no such file,*/
  880.       CALL pmprintf("SRE-http Monitor: FATAL ERROR. INITFILT file unusable")
  881.       call pmprintf('      File read: ' get_file)
  882.       call pmprintf('      fileread response: 'ause)
  883.       call pmprintf('      filelines.0:' filelines.0)
  884.       call pmprintf('      filelines.1:' filelines.1)
  885.       argz=stream(get_file,'c','query size')
  886.       call pmprintf('     Stream query size= ' argz)
  887.       call gosexit "INITFILT file unusable"
  888. end
  889.  
  890.  
  891. /* add  auxillary INITFILT.nnnn files? */
  892. foa=add_auxillary('INITFILT','INITFILT.80',serverport,1)
  893. If (foa=0) then  do               /*missing file,*/
  894.       CALL pmprintf("SRE-http Monitor: FATAL ERROR. Missing auxillary INITFILT file")
  895.       call gosexit "Missing AUXILLARY INITFILT file"
  896. end
  897.  
  898. /*Allow for gratuitous coding calamity by clumsy users */
  899.  
  900. mm=0 ; nerrs=0
  901.  
  902. iat1: nop
  903.  
  904. ok=0            /* assume an error */
  905. /* exit here when entire file read. Before exiting, cleanup and save results */
  906.  
  907. if mm>=filelines.0 then do    /* nothing more to interpret... SAVE and exit */
  908.    if nerrs>0 then do
  909.      signal off syntax ;   signal off error
  910.      signal on error name yipes ; signal on syntax name yipes ;
  911.      if  nerrs>0 then do
  912.         if verbose>0 then foo=pmprintf_sr(' SRE-http Monitor:' nerrs ' errors in initfil.')
  913.          return  -nerrs               /* any error is fatal */
  914.       end  /* Do */
  915.    end
  916.    call initfilt_checkup
  917.  
  918.    call save_envstuff
  919.  
  920. /* check on status of counter files (create if necessary ) */
  921.  
  922.    if counter_file<>'' then do
  923.        hitmeter_file=filespec('d',counter_file)||filespec('p',counter_file)
  924.        hitmeter_file=strip(hitmeter_file,'t','\')||'\HITMETER.CNT'
  925.    end /* do */
  926.    else do
  927.       hitmeter_file='HITMETER.CNT'
  928.    end 
  929.    res1=sref_init_counter(counter_file, upload_log , ,
  930.                          record_all_file , record_option,hitmeter_file)
  931.    parse var res1 counter_file  upload_log  record_all_file  record_option hitmeter_file
  932.    call value envadd||'COUNTER_FILE',counter_file,'os2environment'
  933.    call value envadd||'UPLOAD_LOG',upload_log,'os2environment'
  934.    call value envadd||'RECORD_OPTION',record_option,'os2environment'
  935.    call value envadd||'RECORD_ALL_FILE',record_all_file,'os2environment'
  936.    call value 'SREF_HITMETER_FILE',hitmeter_file,'os2environment'
  937.  
  938.    call value envadd||'SERVERPORT',serverport,'os2environment'
  939.    call value 'SREF_SERVERPORT',serverport,'os2environment'
  940.  
  941.    foo=pmprintf_sr(" SRE-http Monitor: INITFILT file loaded, "||get_file)
  942.  
  943.    return 1
  944. end
  945.  
  946.  
  947. /* --- IF here, there is more stuff to INTERPET */
  948. mm=mm+1
  949. signal off syntax ;   signal off error
  950. signal on syntax name foobar1
  951. signal on error name foobar1
  952. signal on failure name foobar1
  953. signal on halt name foobar1
  954. filelines.mm=fix_me(filelines.mm)  /* convert from foo.host.n to foo.n.host */
  955.  
  956. goo=strip(filelines.mm)
  957. if goo="" | left(goo,1)=";" then  signal iat1
  958.  
  959. if abbrev(goo,'$')=1 then do    /* is it machine_Id specific */ 
  960.    parse var goo anid goo ; goo=strip(goo)
  961.    anid=substr(upper(strip(anid)),2)
  962.    if anid<>machine_id then signal iat1  /* not for this "machine" -- so skip it */
  963. end /* do */
  964.  
  965.  
  966.  
  967. /* convert PUBLIC_FILES to PUBLC_URLS */
  968. if abbrev(upper(goo),'PUBLIC_FILES')=1 then
  969.    goo='PUBLIC_URLS'||delstr(goo,1,12)
  970.  
  971. /* convert PUBLIC_URL. to PUBLC_URLS. */
  972. if abbrev(upper(goo),'PUBLIC_URL.')=1 then
  973.    goo='PUBLIC_URLS'||delstr(goo,1,10)
  974.  
  975.  if abbrev(upper(goo),'SERVDIR')=1 then do
  976.      foo=pmprintf_sr(' Warning: INITFILT not allowed to change SERVDIR variable ')
  977.      nop /* don't let it be changed! */
  978.  end
  979.  else do                        /* THIS does the ACTUAL work */
  980.     interpret goo
  981.  end
  982.  
  983. ok=1
  984.  
  985. foobar1:                /* here on error */
  986. if ok=0 then do
  987.    nerrs=nerrs+1
  988.    call pmprintf(sigl" !!! WARNING: SRE-http Monitor: ERROR: in initfilt at ")
  989.    call pmprintf("         "||goo)
  990. end
  991.  
  992.  
  993. signal iat1
  994.  
  995. /* ============ END of main  ==================== */
  996.  
  997.  
  998.  
  999. /**********************************/
  1000. /* Add entries to repstrgs filelines. variable, from the defrealm_file_Temp.
  1001.   Note that this file only has the appropriate port entries
  1002.   in it */
  1003. add_defrealm_rep:procedure expose defrealm_file_temp filelines.
  1004.  
  1005. defrealm=defrealm_file_temp
  1006. parse upper arg atype
  1007. atype=strip(atype)
  1008. crlf='0d0a'x
  1009.  
  1010. if defrealm='' then return 0
  1011. aa=sref_open_read(defrealm,15,'READ')
  1012. if aa<=0 then return 0
  1013.  
  1014. ii=stream(defrealm,'c','query size')
  1015. if ii=0 | ii='' then return 0
  1016.  
  1017. stuff=charin(defrealm,1,ii)
  1018. foo=stream(defrealm,'c','close')
  1019.  
  1020. do forever
  1021.   if stuff="" then return 1
  1022.   parse var stuff aline (crlf) stuff
  1023.   if abbrev(aline,';')=1 then iterate
  1024.   parse var aline btype ':' aline
  1025.   if btype<>atype then iterate
  1026.   ii=filelines.0+1
  1027.   filelines.ii=aline
  1028.   filelines.0=ii
  1029. end
  1030.  
  1031.  
  1032.  
  1033. /* ---------------------------------------------- */
  1034. /* read auxillary INITFILT and repstrgs files */
  1035. add_auxillary:procedure expose filelines. cfglist_file cfgs_dir
  1036. parse upper arg atype,dfile,sport,numeric_tails
  1037.  
  1038.  
  1039. if cfglist_file='' then return  1       /* nothing to do */
  1040.  
  1041. /* look for files */
  1042. foo=translate(stream(cfglist_file,'c','open read'))
  1043. if abbrev(foo,'READY')<>1 then do
  1044.   call pmprintf('SRE-http Monitor: Unable to open 'cfglist_file ' ('foo)
  1045.   return 1            /* unable to open */
  1046. end
  1047. inj=stream(cfglist_file,'c','query size')
  1048. if inj=0 | inj='' then return   1        /* empty file */
  1049. astuff=charin(cfglist_file,1,inj)
  1050. foo=stream(cfglist_file,'c','close')
  1051.  
  1052. crlf='0d0a'x
  1053. astuff=astuff||crlf||' '        /* place an elephant in cairo */
  1054.  
  1055. /* determine which atype apply to this port, by readling CFGLIST.CFG */
  1056. mm=0
  1057.  
  1058. /* note: file is organized in blocks */
  1059. curport=80              /* defaults port and host */
  1060. curhost=''
  1061. curfile=''
  1062.  
  1063. do forever              /* for all blocks in file */
  1064.   if astuff='' then leave       /* all done  (note we always put an elephant in cairo */
  1065.   parse var astuff aline (crlf) astuff
  1066.   if abbrev(aline,';')=1 then iterate   /* ignore comments */
  1067.   if aline='' then do           /* block end */
  1068.      if curport<>sport | curfile='' then do     /* different port, or  file not specified */ 
  1069.         nop 
  1070.      end
  1071.      else do        /* otherwise, add this entry to filelist */
  1072.         mm=mm+1
  1073.         ufiles.mm.!host=curhost
  1074.         ufiles.mm.!file=curfile
  1075.      end
  1076.      curport=80 ; curhost='' ; curfile=''  /* clear block */
  1077.      iterate
  1078.   end
  1079.  
  1080. /* process an entry in this block */
  1081.   parse upper var aline ltype ':' lstuff ;ltype=strip(ltype) ; lstuff=strip(lstuff)
  1082.  
  1083.   select
  1084.     when ltype='PORT' then curport=lstuff
  1085.     when ltype='HOST' then curhost=lstuff
  1086.     when ltype=atype  then do
  1087.        curfile=strip(translate(lstuff,'\','/'),'l','\')
  1088.        if pos(':',curfile)=0 then curfile=cfgs_dir||'\'||curfile
  1089.     end
  1090.     when ltype='*'  then do
  1091.        curfile=strip(translate(lstuff,'\','/'),,'\')
  1092.        if pos(':',curfile)=0 then curfile=cfgs_dir||'\'||curfile
  1093.        curfile=stream(curfile'\'dfile,'c','query exists')
  1094.     end
  1095.  
  1096.     otherwise nop
  1097.   end
  1098.  
  1099. end
  1100.  
  1101. /* done reading cfglist; add entries from appropriate files */
  1102. if mm=0 then return 1     /* no auxillary files of this type */
  1103.  
  1104. ufiles.0=mm
  1105.  
  1106. do mm=1 to filelines.0              /* retain old fileline */
  1107.   ulisttmp.mm=filelines.mm
  1108. end
  1109. ulisttmp.0=filelines.0
  1110.  
  1111.  
  1112. do mm=1 to ufiles.0
  1113.   afile=ufiles.mm.!file
  1114.   ahost=ufiles.mm.!host
  1115.  
  1116.   a=sref_fileread(afile,'ulines',,'E')   /* read it to a stem variable */
  1117.  
  1118.   if a=0 | ulines.0=0 then do
  1119.       call pmprintf(' SRE-http Monitor: WARNING**: bad auxillary '||atype||': '||afile)
  1120.       iterate
  1121.   end
  1122.    
  1123.    call pmprintf('SRE-http Monitor: adding from 'AHOST ' specific 'atype' 'afile ',' ulines.0)
  1124.  
  1125.    do ii=1 to ulines.0
  1126.         aline=strip(ulines.ii)
  1127.         if ALINE=' ' then iterate
  1128.         aline=translate(aline,' ','0009'x)
  1129.         if  abbrev(strip(aline),';')=1 then iterate
  1130.         if atype='REPSTRGS' then
  1131.           parse var aline avar aval
  1132.         else
  1133.             parse var aline avar '=' aval
  1134.         ilp=lastpos('.',avar)
  1135.         if ilp>0 & numeric_tails=1 then do    /* numeric_tails=1 means "last tail must be a number */
  1136.             llstem=substr(avar,ilp+1)
  1137.             if datatype(llstem)<>'NUM' then do
  1138.                 call pmprintf('SRE-http Monitor:Warning: disallowed auxillary entry: 'aline)
  1139.                iterate
  1140.             end
  1141.         end
  1142.         if ahost<>'' then  avar=strip(avar)||'.'||strip(ahost)
  1143.         ii2=ulisttmp.0+1
  1144.         if atype='REPSTRGS' then
  1145.            ulisttmp.ii2=avar||' '||aval
  1146.         else
  1147.             ulisttmp.ii2=avar||'='||aval
  1148.         ulisttmp.0=ii2
  1149.    end
  1150. end
  1151.  
  1152. do mm=1 to ulisttmp.0
  1153.    filelines.mm=ulisttmp.mm
  1154. end
  1155. filelines.0=ulisttmp.0
  1156. drop ulisttmp.
  1157. return 1
  1158.  
  1159. /* initfilt repstrgs */
  1160.  
  1161.  
  1162. /* ---------------------------------------------- */
  1163. /* read ATTRIBs from cfglist_File */
  1164. add_attribs:procedure expose  cfglist_file cfgs_dir 
  1165. parse upper arg sport
  1166.  
  1167. if cfglist_file='' then return  ''       /* nothing to do */
  1168.  
  1169. /* look for files */
  1170. foo=translate(stream(cfglist_file,'c','open read'))
  1171. if abbrev(foo,'READY')<>1 then do
  1172.   call pmprintf('SRE-http Monitor: Unable to open: 'cfglist_file' ('foo)
  1173.   return ''            /* unable to open */
  1174. end
  1175. inj=stream(cfglist_file,'c','query size')
  1176. if inj=0 | inj='' then return   ''        /* empty file, nothing to add */
  1177. astuff=charin(cfglist_file,1,inj)
  1178. foo=stream(cfglist_file,'c','close')
  1179.  
  1180. crlf='0d0a'x
  1181. astuff=astuff||crlf||' '        /* place an elephant in cairo */
  1182. nustuff=''
  1183.  
  1184. /* determine if any entries (ATTRIBS:), for this port, by readling CFGLIST.CFG */
  1185. mm=0
  1186.  
  1187. /* note: file is organized in blocks */
  1188. aport=80              /* defaults port and host */
  1189. ahost='' ; afile=''
  1190.  
  1191. do forever              /* for all blocks in file */
  1192.   if astuff='' then leave       /* all done  (note we always put an elephant in cairo */
  1193.   parse var astuff aline (crlf) astuff
  1194.   if abbrev(aline,';')=1 then iterate   /* ignore comments */
  1195.   if aline='' then do           /* block end */
  1196.      if afile<>''  then do
  1197.         if aport=sport then
  1198.             nustuff=nustuff||crlf||'Host: 'ahost||crlf||'Include: 'afile||crlf
  1199.      end /* a defrealm entry */
  1200.      ahost=''
  1201.      afile=''
  1202.      aport=80
  1203.      iterate
  1204.    end
  1205.  
  1206. /* else, info to store? */
  1207.    parse upper var aline ltype ':' lstuff ;
  1208.    ltype=strip(ltype) ; lstuff=strip(lstuff)
  1209.  
  1210.    select
  1211.        when ltype='PORT' then aport=lstuff
  1212.        when ltype='HOST' then ahost=lstuff
  1213.        when abbrev(ltype,'ATTR')=1 then afile=lstuff
  1214.        otherwise nop
  1215.    end /* select */
  1216.  
  1217. end
  1218.  
  1219. return nustuff
  1220.  
  1221.  
  1222.  
  1223. /* ---------------------------------------------- */
  1224. /* Clean up parameters in initfilt */
  1225. /* ---------------------------------------------- */
  1226. initfilt_checkup:
  1227.  
  1228. checklog=STRIP(translate(checklog))
  1229. IF CHECKLOG='YES' then CHECKLOG='ALWAYS'
  1230.   t1=wordpos(checklog,'NO ALWAYS INHOUSE')
  1231.   if t1=0 then checklog='NO'
  1232.  
  1233. if auto_Name=0 then auto_name=" "
  1234.    auto_name=translate(auto_name)
  1235.  
  1236. /* include html for backward compataability */
  1237. check_alias=is_true(check_alias,'Y YES 1 HTM HTML ')
  1238.  
  1239. accept_range=is_true(accept_range,'Y YES 1')
  1240. no_include=is_true(no_include,'Y YES 1')
  1241. no_interpret_code=is_true(no_interpret_code,'Y YES 1')
  1242. no_processing=is_true(no_processing,'Y YES 1')
  1243. use_stdout=is_true(use_stdout,'Y YES 1')
  1244. add_user_name=is_true(add_user_name,'Y YES 1')
  1245. add_resource_name=is_true(add_resource_name,'Y YES 1')
  1246.  
  1247. check_add_privs=is_true(check_add_privs,'Y YES 1')
  1248.  
  1249. if logon_fail_file=' '  then logon_fail_file=0
  1250. if access_fail_file=' ' then access_fail_file=0
  1251.  
  1252. DEFAULT=STRIP(DEFAULT)
  1253.    if default=' ' then default='INDEX.HTM'
  1254.  
  1255.  
  1256.  
  1257. /* check for existnce of varouse directories */
  1258. mailbox_dir=translate(mailbox_dir,'\','/')
  1259.    mailbox_dir=strip(mailbox_dir,'t','\')
  1260. if dosisdir(mailbox_dir)=0 then do
  1261.      call pmprintf(' SRE-http Monitor: Warning, could not find mailbox_dir: 'mailbox_dir)
  1262.      mailbox_dir=""
  1263. end  /* Do */
  1264.  
  1265. messbox_dir=translate(messbox_dir,'\','/')
  1266.    messbox_dir=strip(messbox_dir,'t','\')
  1267. if dosisdir(messbox_dir)=0 then do
  1268.      call pmprintf(' SRE-http Monitor: Warning, could not find messbox_dir: 'messbox_dir)
  1269.      messbox_dir=""
  1270. end  /* Do */
  1271.  
  1272. config_dir=translate(config_dir,'\','/')
  1273.    config_dir=strip(config_dir,'t','\')
  1274. if dosisdir(config_dir)=0 then do
  1275.      call pmprintf(' SRE-http Monitor: Warning, could not find config_dir: 'config_dir)
  1276.      config_dir=datadir()
  1277. end  /* Do */
  1278.  
  1279.  
  1280.  
  1281. workdata_dir=translate(workdata_dir,'\','/')
  1282.    workdata_dir=strip(workdata_dir,'t','\')
  1283. if dosisdir(workdata_dir)=0 then do
  1284.      call pmprintf(' SRE-http Monitor: Warning, could not find workdata_dir: 'workdata_dir)
  1285.      workdata_dir=servdir
  1286. end
  1287.  
  1288. tempdata_dir=translate(tempdata_dir,'\','/')
  1289.    if length(tempdata_dir)>3 then tempdata_dir=strip(tempdata_dir,'t','\')
  1290. if dosisdir(tempdata_dir)=0 then do
  1291.      foo=tempdata_dir
  1292.      tempdata_dir=strip(translate(datadir(),'\','/'),'t','\')
  1293.      call pmprintf(' SRE-http Monitor: Warning, could not find tempdata_dir: 'foo', (using 'tempdata_dir)
  1294. end
  1295.  
  1296.  
  1297. userinfo_dir=translate(userinfo_dir,'\','/')
  1298.    userinfo_dir=strip(userinfo_dir,'t','\')
  1299. if dosisdir(userinfo_dir)=0 then do
  1300.      call pmprintf(' SRE-http Monitor: Warning, could not find userinfo_dir: 'userinfo_dir)
  1301.      userinfo_dir=tempdata_dir
  1302. end
  1303.  
  1304. tempfile_dir=translate(tempfile_dir,'\','/')
  1305.    tempfile_dir=strip(tempfile_dir,'t','\')
  1306. if dosisdir(tempfile_dir)=0 then do
  1307.      call pmprintf(' SRE-http Monitor: Warning, could not find tempfile_dir: 'tempfile_dir)
  1308.      tempfile_dir=servdir
  1309. end
  1310.  
  1311. cgi_bin_dir=translate(cgi_bin_dir,'\','/')
  1312.    cgi_bin_dir=strip(cgi_bin_dir,'t','\')
  1313.    if cgi_bin_dir="" then cgi_bin_dir=0
  1314. if dosisdir(cgi_bin_dir)=0 then do
  1315.      call pmprintf(' SRE-http Monitor: Warning, could not find cgi-bin-dir: 'cgi_bin_dir)
  1316.      cgi_bin_dir=' '
  1317. end  /* Do */
  1318.  
  1319.  
  1320. addon_dir=translate(addon_dir,'\','/')
  1321.    addon_dir=strip(addon_dir,'t','\')
  1322.    if addon_dir="" then addon_dir=0
  1323. if dosisdir(addon_dir)=0 then do
  1324.      call pmprintf(' SRE-http Monitor: Warning, could not find addon-dir, 'addon_dir ', using : 'servdir)
  1325.      addon_dir=servdir
  1326. end  /* Do */
  1327.  
  1328.  
  1329. /* chek other stuff */
  1330.  
  1331. HOME_DIR=STRIP(HOME_DIR)
  1332. inhouse_privs=translate(inhouse_privs)
  1333.    if inhouse_privs=0 then inhouse_privs=" "
  1334. public_privs=translate(public_privs)
  1335.    if public_privs=0 then public_privs=" "
  1336. user_privs=translate(user_privs)
  1337.    if user_privs=0 then user_privs=" "
  1338.  
  1339.  
  1340. virtual_file=strip(virtual_file)
  1341.  
  1342. ALLOW_ACCESS=TRANSLATE(STRIP(ALLOW_ACCESS))
  1343. if allow_access="Y" | allow_access=1 then allow_access="YES"
  1344.  
  1345. do_Htaccess=is_true(do_htaccess,'Y YES 1')
  1346.  
  1347.  
  1348. ssi_cache_on=is_true(ssi_cache_on,'Y YES 1 ')
  1349.  
  1350. ssi_shtml_only=is_true(ssi_shtml_only,'Y YES 1')
  1351. DNS_CHECK=translate(dns_check)
  1352. if upload_log="" then upload_log=0
  1353. if datatype(upload_maxsize)<>'NUM' then
  1354.     upload_maxsize=50
  1355. if datatype(upload_minfree)<>'NUM' then
  1356.     upload_minfree=20000
  1357.  
  1358. if datatype(ssi_cache_size)<>'NUM' then
  1359.    ssi_cache_size=5000
  1360.  
  1361. if datatype(ssi_cache_duration)<>'NUM' then ssi_cache_duration=1
  1362. if ssi_cache_duration=0 then ssi_cache_duration=1000000 /* infiinte*/
  1363.  
  1364. if wordpos(ssi_cache_stamp,'TIME DATE TIMEDATE DATETIME SIZE ALL')=0 then
  1365.    ssi_cache_stamp='ALL'
  1366.  
  1367.  
  1368. pre_filter=translate(pre_filter)
  1369. post_filter=is_true(post_filter,'Y YES 1')
  1370.  
  1371. if smtp_gateway=" " then smtp_gateway=0
  1372.  
  1373. hit_owner_suppress=is_true(hit_owner_suppress,'Y YES 1')
  1374. hit_superuser_suppress=is_true(hit_superuser_suppress,'Y YES 1')
  1375.  
  1376. write_logs=is_true(write_logs,'Y YES 1')
  1377.  
  1378. if upper(hit_cache_len)="FILE" then do
  1379.    nop
  1380. end  /* Do */
  1381.  
  1382. else do
  1383.   if datatype(hit_cache_len)<>'NUM' then do 
  1384.      hit_cache_len=0
  1385.   end
  1386.   else do
  1387.     hit_cache_len=min(hit_cache_len,50)  /* 50 k max */
  1388.   end  /* Do */
  1389. end
  1390.  
  1391. if datatype(hit_cache_DURATION)<>'NUM' then do
  1392.      hit_cache_DURATION=15
  1393. END
  1394. ELSE DO
  1395.    HIT_cache_DURATION=MAX(1,HIT_cache_DURATION)
  1396. end  /* Do */
  1397.  
  1398.  
  1399. if the_realm=0 then do
  1400.   if  symbol('inhouse_name')<>"VAR"  then
  1401.         the_realm=inhouse_name
  1402.   else
  1403.        the_realm="OUR WEB SITE"           /* name we call "ourselves" */
  1404. end
  1405.  
  1406.  
  1407. RECORD_OPTION=TRANSLATE(RECORD_OPTION)
  1408. if wordpos(record_option,'YES YES_ALL FILE ')=0 then
  1409.      record_option="NO"              /* recording option on?*/
  1410.  
  1411. gots=0
  1412.  
  1413. hosts.0=0
  1414. do m=1 to 100000
  1415.    if symbol('hosts.m')<>"VAR" then leave
  1416.    if hosts.m=0 then leave
  1417.    hosts.0=m
  1418. end /* do */
  1419.  
  1420.  
  1421. /* add entries from cfgs/cfglist.cfg */
  1422.  
  1423. hostfile=cfglist_file
  1424. inj=stream(hostfile,'c','query size')
  1425. hstuff=''
  1426. if inj<>'' & inj<>0 then do
  1427.   foo=translate(stream(hostfile,'c','open read'))
  1428.   if abbrev(foo,'READY')<>1 then do
  1429.      call pmprintf('SRE-http Monitor: Warning, unable to read 'hostfile)
  1430.   end /* do */
  1431.   else do
  1432.      hstuff=charin(hostfile,1,inj)
  1433.      foo=stream(hostfile,'c','close')
  1434.   end
  1435. end /* do */
  1436. if hstuff<>'' then do           /* process the hostfile */
  1437.   crlf='0d0a'x
  1438.   hstuff=hstuff||crlf||' '
  1439.   defdata=strip(translate(datadir(),'\','/'),'t','\')
  1440.   ahost='' ; adata='' ; anickname=''
  1441.   ahitcount='' ; acounter_rxx='' ; asendfile='' ; arecordall=''
  1442.   do forever  
  1443.      if hstuff="" then leave
  1444.      parse var hstuff aline (crlf) hstuff
  1445.      aline=translate(strip(aline))
  1446.      if abbrev(aline,';')=1 then iterate
  1447.      if aline='' then do                /* end of block */
  1448.         if ahost<>'' & anickname<>'' then do
  1449.           if adata='' then adata=defdata
  1450.           alin2=ahost','anickname','adata','ahitcount','acounter_rxx','asendfile','arecordall
  1451.           ih=hosts.0+1
  1452.           hosts.ih=alin2
  1453.           hosts.0=ih
  1454.         end
  1455.         ahost='' ; anickname='' ; adata=''
  1456.         iterate
  1457.      end
  1458. /* else, process an entry */
  1459.      parse var  aline avar ':' avalue ; avar=strip(translate(avar)); avalue=strip(translate(avalue))
  1460.      select
  1461.         when abbrev(avar,'IP')=1 then ahost=avalue
  1462.         when abbrev(avar,'NICK')=1 | avar="HOST" then anickname=avalue
  1463.         when abbrev(avar,'DATA')=1 then adata=avalue
  1464.         when abbrev(avar,'SEND')=1 then do
  1465.           if pos(':',avalue)>0 then
  1466.              asendfile=avalue
  1467.           else
  1468.              call pmprintf("SRE-http monitor: Ignoring: must use fully qualifed name ("avalue)
  1469.         end
  1470.         when abbrev(avar,'RECORD')=1 then do
  1471.           if pos(':',avalue)>0 then
  1472.              arecordall=avalue
  1473.          else
  1474.              call pmprintf("SRE-http monitor: Ignoring: must use fully qualifed name ("avalue)
  1475.  
  1476.         end
  1477.         when abbrev(avar,'HIT')=1 then  do
  1478.           if pos(':',avalue)>0 then
  1479.             ahitcount=avalue
  1480.          else
  1481.              call pmprintf("SRE-http monitor: Ignoring: must use fully qualifed name ("avalue)
  1482.  
  1483.         end
  1484.         when abbrev(avar,'COUNTER')=1 then do
  1485.           if pos(':',avalue)>0 then
  1486.             acounter_rxx=avalue
  1487.          else
  1488.              call pmprintf("SRE-http monitor: Ignoring: must use fully qualifed name ("avalue)
  1489.  
  1490.         end
  1491.         otherwise nop
  1492.      end
  1493.   end                   /* forever scan */
  1494. end                     /* hstuff exsits */
  1495.         
  1496.  
  1497. ralphie=cvtails('DELIM_1',dlist)
  1498.  
  1499. delims=0
  1500. do m=1 to ralphie
  1501.  
  1502.    a1=dlist.m
  1503.    a2=translate(a1,' ','.')
  1504.    if words(a2)=1 then do
  1505.         if datatype(a1)='NUM' then do
  1506.            tmp1=DELIM_1.a1
  1507.            if tmp1='0' then iterate
  1508.            delims=max(delims,a1)
  1509.         end  /* Do */
  1510.     end  /* Do */
  1511.    if words(a2)=2 then do
  1512.         if datatype(word(a2,1))='NUM' then do
  1513.            ahost=word(a2,2)
  1514.            tmp1=DELIM_1.a1
  1515.            if tmp1='0' then iterate
  1516.            if symbol('DELIMS.'||ahost)='VAR' then
  1517.                 delims.ahost=max(delims.ahost,word(a2,1))
  1518.            else
  1519.                 delims.ahost=word(a2,1)
  1520.         end  /* Do */
  1521.     end  /* Do */
  1522. end
  1523.  
  1524.  
  1525.  
  1526. crlf='0d0a'x
  1527. FPO=MAKE_HEAD_FOOT()
  1528.  
  1529. /* creates HEADERS FOOTERS HEADERS. FOOTERS. HEADLIST. FOOTLIST. NHEADS NFOOTS */
  1530.  
  1531. auto_header=upper(auto_header)
  1532.  
  1533. suppress_alias=0 ; suppress_virtual=0 ; suppress_access=0
  1534. suppress_user=0 ; check_doq=0
  1535. if (alias_file=" " | alias_file=0)  then
  1536.         suppress_alias=1
  1537. if virtual_file=" " | virtual_file=0 then
  1538.         suppress_virtual=1
  1539. if (user_file=" " | user_file=0 ) then
  1540.         suppress_user=1
  1541. if access_file=" "| access_file=0  then
  1542.         suppress_access=1
  1543.  
  1544. if (suppress_alias+suppress_user+suppress_access+suppress_virtual+never_publicurls)>0 then
  1545.    check_doq=1
  1546.  
  1547. return 0
  1548.  
  1549.  
  1550. /* ------------------------------------------------- */
  1551. /* routine to set default initfilt.80  */
  1552. /* ------------------------------------------------- */
  1553. default_initfilt:
  1554.  
  1555. /* variables that can be changed by configure */
  1556.  
  1557. display_env=0
  1558. checklog='NO'           /* Free entry */
  1559. the_realm=0           /* name we call "ourselves" , 0 will be replaced generically*/
  1560. home_name=" "              /* The colloquial (not necessrily ip) domain name */
  1561. auto_header="NO"        /* no, always, head */
  1562. AUTO_NAME=0         /* 0=none, or a list with *.HTM, !CREATE, file.nam */
  1563. CHECK_alias="YES"   /* : YES=yes, NO=None, HTML=.HTM (or .HTML)  */
  1564. not_found_url='<a href="/"> Visit the home_name home page? </a> '   /* Message that is sent with no such url  */
  1565. pre_filter="NO"         /* no  yes first */
  1566. post_filter="NO"
  1567. noext_type="HTM"  /* NONE DIR HTM or HTML REDIR */
  1568. record_option="NO"   /* YES, YES_ALL */
  1569. allow_access="YES"  /* access control on file transfers (YES=none) */
  1570. default='index.htm'     /* use if default home page selected */
  1571. add_privs_prefix='!'
  1572. inhouse_privs=" INHOUSE "    /* additional privs for inhouseips and owners */
  1573. public_privs=" PUBLIC "    /* additional privs for veryone */
  1574. user_privs=' USER '
  1575. inhouse.1=" (INHOUSE User) "   /* Used with REPLACE:INHOUSE1, etc. */
  1576. suPEruser.1="(Super User)"
  1577. replace_rules.0=0                /* no replace rules */
  1578. headers.1=0  /* stuff to put at beginning / end of */
  1579. footers.1=0  /* all htm documents. 0= nothing */
  1580. OPTION_hit_line=":: still access # "
  1581. webmaster=' (no contact available) '
  1582. owners   = 'none'  /* Owners are automatically superusers (seperate with spaces) */
  1583. inhouse_privs="INHOUSE"
  1584. smtp_gateway=" "    /* smtp_gateway, used by post-filter "e-mail alert" facility */
  1585.  
  1586. /* note: Directories and files  do NOT have defaults!*/
  1587.  
  1588. logon_fail_file=0
  1589. access_fail_file=0
  1590.  
  1591. htaccess_file=0
  1592. do_htaccess=0
  1593.  
  1594. accept_range="NO"
  1595. check_add_privs='NO'
  1596. use_stdout="YES"
  1597. add_user_name='YES'
  1598. add_resource_name='NO'
  1599.  
  1600. /* variables not changed by configure */
  1601. max_pointdist=50     /* max distance acceptable for a "assign to point" in ncsa map */
  1602. ssi_shtml_only='NO'    /* yes no, ssi on .sht or .shtml only */
  1603. ssi_cache_on='YES'    /* use ssi-caching (no, yes) */
  1604.  
  1605. fix_expire=0    /* set to non zero to redo response headers */
  1606. content_md5=0    /* add a content-md5 header */
  1607. no_include="NO"   /* yes no , disallow all ssi */
  1608. no_processing="NO"   /* if yes, then no server side processing allowed */
  1609. no_interpret_code='NO'
  1610. delim_1.1='<!--'     /* the left and right side "keyphrase" delimeters */
  1611. delim_2.1='-->'      /* can be any string combo */
  1612. upload_maxsize=50             /* max size that a uploaded file can be, in k */
  1613. upload_minfree=20000        /* minimum free in K, in dowload_dir, AFTER file upload */
  1614. postfilter_name="POSTFILT"
  1615. prefilter_name="PREFILTR"
  1616.  
  1617. interpret_types=' PL=PERL5 '  /* used by CGI-BIN to invoke alternate interpeters */
  1618.  
  1619. dir_exclusion='HTACCESS. /PRIVATE *.CNT '
  1620. DIR_OPTIONS='  notime auto_describe describe=describe.txt no_recurse_dir  '
  1621.  
  1622.  
  1623. dir_access=' PRIVATE/* SYSTEM* ' 
  1624. dir_access_privs='SUPERUSER '
  1625.  
  1626.  
  1627. check_doq=0
  1628. verbose=1
  1629.  
  1630. hit_cache_len=0        /* not on (otherwise, # of k) */
  1631. hit_cache_duration=15     /* # of minutes */
  1632. hit_cache=' '
  1633. hit_owner_suppress='YES'
  1634. write_logs='YES'
  1635.  
  1636.  
  1637. return 0
  1638.  
  1639.  
  1640. /* ----------------------------- */
  1641. /* save some initfilt varibles to the environment */
  1642. /* ----------------------------- */
  1643. save_envstuff:
  1644.  
  1645. ALIST='CHECKLOG AUTO_HEADER VERBOSE DNS_CHECK ALLOW_ACCESS '
  1646. do mm=1 to words(alist)
  1647.   call save_em(word(alist,mm))
  1648. end
  1649. foo=value('SREF_VERBOSE',verbose,'os2environment')
  1650.  
  1651.  
  1652. call value enVadd||'SUPPRESS_ALIAS',suppress_alias,'os2environment'
  1653. call value enVadd||'NEVER_PUBLICURLS',never_publicurls,'os2environment'
  1654.  
  1655. call value 'SREF_DIGEST_AUTH',digest_auth,'os2environment'
  1656. call value 'SREF_SUPPRESS_GZIP_TE',suppress_gzip_te,'os2environment'
  1657. call value 'SREF_PROXY_CACHE',proxy_cache,'os2environment'
  1658.  
  1659. call value enVadd||'suppress_virtual',suppress_virtual,'os2environment'
  1660. call value enVadd||'suppress_access',suppress_access,'os2environment'
  1661. call value enVadd||'suppress_user',suppress_user,'os2environment'
  1662. call value enVadd||'CHECK_DOQ',CHECK_DOQ,'os2environment'
  1663. call value enVadd||'LOADTHRESHOLD',loadthreshold,'os2environment'
  1664. foo=value('SREF_KEY_PREFACE',key_preface,'os2environment')
  1665. call value enVadd||'BACKUPSERVERLIST',backupserverlist,'os2environment'
  1666. call value enVadd||'CGI_POST_LONG_GET',cgi_post_long_get,'os2environment'
  1667. call value enVadd||'GET_DECODE_OPTIONS',get_decode_options,'os2environment'
  1668.  
  1669. call value enVadd||'NO_NO_RECORD',no_no_record,'os2environment'
  1670. call value enVadd||'MESSAGE_SCRAMBLE',MESSAGE_SCRAMBLE,'os2environment'
  1671. CALL VALUE 'SREF_NO_REMOTE_CONFIG',NO_REMOTE_CONFIG,'OS2ENVIRONMENT'
  1672. call value enVadd||'SSI_EXTENSIONS',ssi_extensions,'os2environment'
  1673.  
  1674.  
  1675. ALIST='AUTO_NAME DEFAULT CHECK_ALIAS NOEXT_TYPE ADD_PRIVS_PREFIX INTERPRET_TYPES DIR_OPTIONS DIR_EXCLUSION DIR_ACCESS DIR_ACCESS_PRIVS'
  1676. do mm=1 to words(alist)
  1677.   call save_em(word(alist,mm))
  1678. end
  1679.  
  1680. ALIST='PRE_FILTER PREFILTER_NAME POST_FILTER POSTFILTER_NAME  '
  1681. do mm=1 to words(alist)
  1682.   call save_em(word(alist,mm))
  1683. end
  1684.  
  1685. call value envadd||'HEADERS',headers,'os2environment'
  1686. call value envadd||'FOOTERS',footers,'os2environment'
  1687.  
  1688. do mm=1 to nheads
  1689.    foo=strip(headlist.mm)
  1690.    aval0=aheaders.foo
  1691.    tty=strip(envadd||'HEADERS.'||foo)
  1692.    call value tty,aval0,'os2environment'
  1693. end /* do */
  1694. do mm=1 to nfoots
  1695.    foo=strip(footlist.mm)
  1696.    aval0=afooters.foo
  1697.    call value envadd||'FOOTERS.'||foo,aval0,'os2environment'
  1698. end /* do */
  1699.  
  1700. alist='THE_REALM HOME_NAME NOT_FOUND_URL USER_PRIVS PUBLIC_PRIVS INHOUSE_PRIVS OPTION_HIT_LINE LOGON_FAIL_FILE ACCESS_FAIL_FILE'
  1701. do mm=1 to words(alist)
  1702.   call save_em(word(alist,mm))
  1703. end
  1704.  
  1705. alist='WEBMASTER OWNERS SMTP_GATEWAY ACCEPT_RANGE USE_STDOUT ADD_USER_NAME ADD_RESOURCE_NAME '
  1706. do mm=1 to words(alist)
  1707.   call save_em(word(alist,mm))
  1708. end
  1709.  
  1710.  
  1711. call value envadd||'HOSTS.0',hosts.0,'os2environment'
  1712.  
  1713. select
  1714.    when wordpos(upper(content_md5),'1 Y YES')>0 then content_md5=1
  1715.    when wordpos(content_md5,'2 MD5.EXE')>0 then content_md5=2
  1716.    otherwise  content_md5=0
  1717. end
  1718.  
  1719. ALIST='MAX_POINTDIST NO_INCLUDE NO_INTERPRET_CODE NO_PROCESSING CONTENT_MD5 FIX_EXPIRE SSI_SHTML_ONLY CHECK_ADD_PRIVS SSI_CACHE_ON '
  1720. do mm=1 to words(alist)
  1721.   call save_em(word(alist,mm))
  1722. end
  1723.  
  1724. ALIST='UPLOAD_MINFREE UPLOAD_MAXSIZE HOME_DIR HIT_CACHE_LEN HIT_CACHE_DURATION HIT_CACHE WRITE_LOGS HIT_OWNER_SUPPRESS SSI_CACHE_SIZE SSI_CACHE_DURATION SSI_CACHE_STAMP '
  1725. do mm=1 to words(alist)
  1726.   call save_em(word(alist,mm))
  1727. end
  1728.  
  1729. call value envadd||'cgi_bin_dir',cgi_bin_dir,'os2environment'
  1730. call value envadd||'addon_dir',addon_dir,'os2environment'
  1731.  
  1732. tempfile_dir=upper(strip(tempfile_dir))
  1733. call value envadd||'tempfile_dir',tempfile_dir,'os2environment'
  1734.  
  1735. tempdata_dir=upper(strip(tempdata_dir))
  1736. call value envadd||'tempdata_dir',tempdata_dir,'os2environment'
  1737. call value 'sref_temp_data_dir',tempdata_dir,'os2environment'
  1738.  
  1739. userinfo_dir=upper(strip(userinfo_dir))
  1740. call value envadd||'userinfo_dir',userinfo_dir,'os2environment'
  1741.  
  1742.  
  1743. upload_dir=upper(strip(upload_dir))
  1744. call value envadd||'upload_dir',upload_dir,'os2environment'
  1745.  
  1746. messbox_dir=upper(strip(messbox_dir))
  1747. call value envadd||'messbox_dir',messbox_dir,'os2environment'
  1748.  
  1749. config_dir=upper(strip(config_dir))
  1750. call value envadd||'config_dir',config_dir,'os2environment'
  1751.  
  1752. workdata_dir=upper(strip(workdata_dir))
  1753. call value envadd||'workdata_dir',workdata_dir,'os2environment'
  1754.  
  1755.  
  1756. mailbox_dir=upper(strip(mailbox_dir))
  1757. call value envadd||'mailbox_dir',mailbox_dir,'os2environment'
  1758.  
  1759.  
  1760. call value envadd||'SERVDIR',servdir,'os2environment'
  1761. call value 'SREF_PREFIX',envadd,'os2environment'
  1762.  
  1763. call value envadd||'INITFILT_FILE',INIT_file,'os2environment'
  1764. call value envadd||'USER_FILE',user_file,'os2environment'
  1765. call value envadd||'ACCESS_FILE',access_file,'os2environment'
  1766. call value envadd||'VIRTUAL_FILE',virtual_file,'os2environment'
  1767. call value envadd||'ALIAS_FILE',alias_file,'os2environment'
  1768. call value envadd||'PUBURL_FILE',puburl_file,'os2environment'
  1769.  
  1770. call value envadd||'REPSTRGS_FILE',repstrgs_file,'os2environment'
  1771.  
  1772. call value envadd||'INTERPRET_FILE',interpret_file,'os2environment'
  1773. call value envadd||'SENDFILE_FILE',sendfile_file,'os2environment'
  1774.  
  1775.  
  1776. IF DACALL=0 then do
  1777.    call lineout error_log,' ==== The SRE-http error log. '||time('n')' 'date('n')
  1778.    call lineout error_log
  1779. end
  1780. ELSE  do
  1781.    if verbose>1 then do 
  1782.       call lineout error_log,' ==== (parameter reset '||time('n')' 'date('n')
  1783.       call lineout error_log
  1784.    end /* do */
  1785. end
  1786.  
  1787. if stream(error_log,'c','query exists')="" then do
  1788.     foo=pmprintf_sr(' SRE-http Monitor: could not initialize error log: 'error_log)
  1789.     error_log=''
  1790. end /* do */
  1791. else do
  1792.    foo=pmprintf_sr(" SRE-http Monitor: using error log: " error_log)
  1793.    xaa=stream(error_log,'c','query size')
  1794.    if xaa>100000 then foo=pmprintf_sr(' SRE-http Monitor: WARNING, error log file is getting large ('xaa' bytes)')
  1795. end /* do */
  1796. call value envadd||'ERROR_LOG',error_log,'os2environment'
  1797.  
  1798. call value envadd||'HTACCESS_FILE',htaccess_file,'os2environment'
  1799. call value envadd||'DO_HTACCESS',DO_htaccess,'os2environment'
  1800.  
  1801. /* create a HOST listing, stored in sref_value environment */
  1802. /*  IP_address,  host_nickname,  default_directory */
  1803. foo=pmprintf_sr(' SRE-http Monitor: looking up '||hosts.0||' HOST IP addresses')
  1804. hostlist=''
  1805.  
  1806. do m=1 to hosts.0
  1807.    aah=upper(hosts.m)
  1808.  
  1809.    parse upper var aah  sname ','  hn ',' adir ','ahitcount','acounter_rxx','asendfile','arecordall
  1810.    SNAME=STRIP(SNAME); adir=strip(adir)
  1811.    hostlist=hostlist' 'sname
  1812.    hn=upper(hn)
  1813.    adir=translate(strip(adir),'\','/'); adir=strip(adir,'t','\')||'\'
  1814.    tmp.m=sname','hn','adir
  1815.    tmp.m.!name=sname
  1816.    foo=sref_value('$HOSTS.'||sname,tmp.m,'USER',,serverport)
  1817.  
  1818.    fpp=value(envadd||'COUNTER_FILE.'||hn,ahitcount,'OS2ENVIRONMENT')
  1819.    fpp=value(envadd||'COUNTER_RXX_DIR.'||hn,acounter_rxx,'OS2ENVIRONMENT')
  1820.    fpp=value(envadd||'SENDFILE_FILE.'||hn,asendfile,'OS2ENVIRONMENT')
  1821.    fpp=value(envadd||'RECORD_ALL_FILE.'||hn,arecordall,'OS2ENVIRONMENT')
  1822.  
  1823.  
  1824. end
  1825.  
  1826. /*  -- HOSTS. ENTRIES MUST BE COMPLETE -- WE NO LONGER FILL IN
  1827.    PROBABLE VALUES 
  1828. do aa=1 to words(hostlist)   
  1829.    sname=tmp.aa.!name
  1830.    isnumip=verify(sname,'1234567890.')  
  1831.    if isnumip=0 then iterate  
  1832.    astat=sockgethostbyname(sname,'stuff.!')
  1833.    if astat<>1 then iterate      
  1834.    sname=stuff.!addr
  1835.    if wordpos(sname,hostlist)>0 then iterate 
  1836.    foo=sref_value('$HOSTS.'||sname,tmp.aa,'USER',,serverport)
  1837.    hostlist=hostlist' 'sname
  1838. end
  1839. */
  1840. foo=sref_value('$HOSTS.0',hostlist' ','USER',,serverport)
  1841.  
  1842. /* end of hosts. section */
  1843.  
  1844. call save_em('inhouseips.')
  1845. do m=1 to plist.0            /* fix and save INHOUSEIPS */
  1846.   t1=plist.m
  1847.   anval=inhouseips.t1
  1848.   w1=word(anval,1)   /* look for host nickname */
  1849.   if right(w1,2)='//' then do
  1850.        geti=2
  1851.   end
  1852.   else do
  1853.      geti=1
  1854.   end
  1855.   call value envadd||'inhouseips.'||t1,anval,'os2environment'
  1856. end
  1857.  
  1858. call save_em('unallowedips.')
  1859. isu=0
  1860. do m=1 to plist.0            /* fix and save unallowedIPS */
  1861.   t1=plist.m
  1862.   anval=unallowedips.t1
  1863.   w1=word(anval,1)   /* look for host nickname */
  1864.   if right(w1,2)='//' then do
  1865.        geti=2
  1866.   end
  1867.   else do
  1868.      geti=1
  1869.   end
  1870.   if verify(word(anval,geti),'1234567890.')<>0 then do  /* convert numeric ip */
  1871.       astat=sockgethostbyname(word(anval,geti),'stuff.!')
  1872.       if astat=1 then do
  1873.            if geti=1 then do
  1874.               parse var anval vv anval
  1875.               anval=stuff.!addr||' '||anval
  1876.             end
  1877.             else do
  1878.                parse var anval vv1 vv2  anval
  1879.                anval=vv1||' '||stuff.!addr||' '||anval
  1880.             end  /* Do */
  1881.       end  /* Do */
  1882.   end
  1883.   call value envadd||'unallowedips.'||t1,anval,'os2environment'
  1884.   if anval<>'' & anval<>0 then isu=1
  1885. end
  1886. if isu>0 then 
  1887.   call value envadd||'UNALLOWEDIPS',1,'os2environment'
  1888. else
  1889.   call value envadd||'UNALLOWEDIPS',0,'os2environment'
  1890.  
  1891.  
  1892. do m=1 to delims
  1893.   if symbol('DELIM_1.'||m)<>'VAR' then iterate
  1894.   call value envadd||'DELIM_1.'||m,delim_1.m,'os2environment'
  1895.   if symbol('DELIM_2.'||m)<>'VAR' then iterate
  1896.   call value envadd||'DELIM_2.'||m,delim_2.m,'os2environment'
  1897. end
  1898. call value envadd||'DELIMS',delims,'os2environment'
  1899.  
  1900. ralphie=cvtails('DELIMS',dlist)
  1901. do mm=1 to ralphie
  1902.    booboo=dlist.mm
  1903.    call value envadd||'DELIMS.'||booboo,delims.booboo,'os2environment'
  1904.    do m=1 to delims.booboo
  1905.     if symbol('DELIM_1.'||m||'.'||booboo)<>'VAR' then iterate
  1906.      call value envadd||'DELIM_1.'||m||'.'||booboo,delim_1.m.booboo,'os2environment'
  1907.     if symbol('DELIM_2.'||m||'.'||booboo)<>'VAR' then iterate
  1908.      call value envadd||'DELIM_2.'||m||'.'||booboo,delim_2.m.booboo,'os2environment'
  1909.    end
  1910. end /* do */
  1911.  
  1912.  
  1913. CALL SAVE_EM('SUPERUSER')
  1914. CALL SAVE_EM('INHOUSE')
  1915. call save_em('REPLACE_RULES')
  1916.  
  1917. foo=pmprintf_sr(' SRE-http Monitor: number of hosts= 'hosts.0 )
  1918. return 0
  1919.  
  1920.  
  1921. /* ----------------------------------------------------------------------- */
  1922. /* -- create temporary sel-specific-options file  -- */
  1923. /* ----------------------------------------------------------------------- */
  1924. make_DEFREALM_FILE_temp:
  1925.  
  1926. /* 
  1927. 1) parse defrealm file into an array of entries. Each entry (numbered 1...n)
  1928.    can have several fields. One of these MUST be a REALM, and one of these
  1929.    must be a RULE
  1930. 2) Fill in a  stem (using REALM as tails) using values from the above array
  1931. 3) Fill in missing values in each "REALM tail"  -- this means using
  1932.    higher order realms to fill in values for subrealms.
  1933. Values that can be filled are:
  1934.    REQUIRES and PERMISSIONS. 
  1935. REQUIRES can NOT be subrealm specific -- the same REQUIRES
  1936. must be used in all subrealms (or a realm).
  1937. */
  1938.  
  1939. blocks.='01'x
  1940. wasline='' ; nthblock=1
  1941. blocks.nthblock.!useit=1
  1942. blocks.0=0
  1943.  
  1944. if stream(defrealm_file_temp,'c','query exists')<>'' then do
  1945.   foo=sysfiledelete(DEFREALM_FILE_temp)  /* delete temporary defrealm_file */
  1946.   if foo<>0 then do
  1947.     call pmprintf("SRE-http monitor: Warning ("foo") unable to delete "defrealm_file_temp)
  1948.     return 0   
  1949.   end
  1950. end
  1951.  
  1952. /* look for files */
  1953. foo=translate(stream(DEFREALM_FILE,'c','open read'))
  1954. if abbrev(foo,'READY')<>1 then do
  1955.   call pmprintf('SRE-http Monitor: ... unable to open 'DEFREALM_FILE ' ('foo)
  1956.   return 1            /* unable to open */
  1957. end
  1958. inj=stream(DEFREALM_FILE,'c','query size')
  1959. if inj=0 | inj='' then return   1        /* empty file */
  1960. astuff=charin(DEFREALM_FILE,1,inj)
  1961. foo=stream(DEFREALM_FILE,'c','close')
  1962. crlf='0d0a'x
  1963.  
  1964. /* add host/port specific files (from cfglist.cfg?) */
  1965. rr=add_attribs(serverport)
  1966. astuff=astuff||crlf||crlf||rr
  1967.  
  1968. astuff=astuff||crlf||' '        /* place an elephant in cairo */
  1969.  
  1970. /* look for entry blocks (each block is delimited by a blank line */
  1971. do forever
  1972.    if astuff='' then leave
  1973.    parse var astuff aline (crlf) astuff
  1974.    aline=strip(aline)
  1975.    if abbrev(aline,';')=1 then iterate   /* skip comment lines */
  1976.    if aline='' & wasline='' then iterate /* skip multiple blank lines */
  1977.  
  1978.    if aline=''  then do          /* first blank line signals end of entry*/
  1979.       foo=add_include_nthblock(nthblock)    /* "INCLUDE" (to astuff)? */
  1980.       if blocks.nthblock.!INCLUDE<>'01'x then do
  1981.            blocks.nthblock.!useit=0         /* don't use this block */
  1982.       end
  1983.       blocks.0=blocks.0+1  /* actual # of entries */
  1984.       nthblock=nthblock+1               /* initialize for next entry */
  1985.       blocks.nthblock.!useit=1
  1986.       wasline=''
  1987.       iterate
  1988.    end
  1989.    if pos(':',aline)>0 then
  1990.      parse var aline action ':' options
  1991.    else
  1992.       parse var aline action options 
  1993.    wasline=aline
  1994.    action=strip(translate(translate(action),' ',':='))
  1995.    options=strip(options)
  1996.    select
  1997.       when action='PORT' then do
  1998.         if options='' then options=80
  1999.         if options<>serverport then blocks.nthblock.!useit=0  /* this entry does not apply */
  2000.       end
  2001.       when action='REALM' then do
  2002.          if options='' then iterate
  2003.          parse var options drealm iscomplete 
  2004.          blocks.nthblock.!REALM=strip(translate(drealm))
  2005.          blocks.nthblock.!REALM.!C=strip(translate(iscomplete))
  2006.       end 
  2007.  
  2008.       when abbrev(action,'REPL')=1 then do 
  2009.           blocks.nthblock.!REPLACE=strip(translate(options))
  2010.       end 
  2011.       when abbrev(action,'WITH')=1 then do 
  2012.           blocks.nthblock.!RULES=options
  2013.       end 
  2014.  
  2015.       when abbrev(action,'USER')=1 then do 
  2016.           blocks.nthblock.!USER=strip(translate(options))
  2017.       end 
  2018.       when abbrev(action,'PWD')+abbrev(action,'PASS')>0 then do 
  2019.           blocks.nthblock.!RULES=strip(options)
  2020.       end 
  2021.       when abbrev(action,'PRIV')>0 then do 
  2022.           blocks.nthblock.!PRIVS=strip(options)
  2023.       end 
  2024.  
  2025.       when action='INCLUDE' then do
  2026.          if options='' then iterate
  2027.          blocks.nthblock.!INCLUDE=options
  2028.       end 
  2029.       when action='HOST' then do
  2030.           blocks.nthblock.!HOST=translate(options)
  2031.       end 
  2032.       when abbrev(action,'REQ')=1 then do 
  2033.           blocks.nthblock.!REQUIRES=translate(options)
  2034.       end 
  2035.       when abbrev(action,'PERM')=1 then do 
  2036.           blocks.nthblock.!permissions=translate(options)
  2037.       end 
  2038.       when abbrev(action,'RUL')=1 then do
  2039.         blocks.nthblock.!RULES=blocks.nthblock.!rules' 'options
  2040.       end
  2041.       when abbrev(action,'ADV')=1 then do
  2042.         blocks.nthblock.!ADVOPTS=options
  2043.       end /* do */
  2044.       when abbrev(action,'OPT')=1 then do
  2045.         blocks.nthblock.!OPTS=options' |#| 'blocks.nthblock.!opts 
  2046.       end /* do */
  2047.  
  2048.      when abbrev(action,'FAIL')=1 then do
  2049.         blocks.nthblock.!FAILURE=options
  2050.       end /* do */
  2051.      when abbrev(action,'LIMIT')=1 then do
  2052.         blocks.nthblock.!LIMITLIST=options
  2053.      end /* do */
  2054.  
  2055.       when wordpos(action,'REDIRECT  NEGOTIATE LITERAL ALIAS VIRTUAL MOVE TEMP MOVED TEMPMOVE PERMMOVE')>0 then do
  2056.          options2=translate(options,' ','=')
  2057.          parse var options2 a1  a2 
  2058.          if words(options2)=1 & translate(a1)<>'LITERAL' then a2=a1  /* action=alias, etc */
  2059.          a1=strip(translate(a1))
  2060.          select   
  2061.            when action='ALIAS' then do
  2062.                blocks.nthblock.!RTYPE='ALIAS'
  2063.                blocks.nthblock.!DEST=options
  2064.            end /* do */
  2065.            when abbrev(a1,"SEL")+abbrev(a1,'INTERN')+abbrev(a1,'ALIAS')>0 then do
  2066.              blocks.nthblock.!RTYPE='ALIAS'
  2067.              blocks.nthblock.!DEST=a2
  2068.            end 
  2069.            when action="LITERAL"  then do
  2070.              blocks.nthblock.!RTYPE='LITERAL'
  2071.              blocks.nthblock.!DEST=options
  2072.            end
  2073.            when  a1="LITERAL" then do
  2074.              blocks.nthblock.!RTYPE='LITERAL'
  2075.              blocks.nthblock.!DEST=a2
  2076.            end
  2077.            when action="NEGOTIATE" then do
  2078.              blocks.nthblock.!RTYPE='NEGOTIATE'
  2079.              blocks.nthblock.!DEST=options
  2080.            end
  2081.            when a1="NEGOTIATE" then do
  2082.              blocks.nthblock.!RTYPE='NEGOTIATE'
  2083.              blocks.nthblock.!DEST=a2
  2084.            end
  2085.  
  2086.            when action="VIRTUAL" then do
  2087.              blocks.nthblock.!RTYPE='VIRTUAL'
  2088.              blocks.nthblock.!DEST=options
  2089.            end
  2090.            when a1="DIR" then do
  2091.              blocks.nthblock.!RTYPE='VIRTUAL'
  2092.              blocks.nthblock.!DEST=a2
  2093.            end 
  2094.            when abbrev(action,"MOVE")=1 then do
  2095.              blocks.nthblock.!RTYPE='PERM'
  2096.              blocks.nthblock.!DEST=options
  2097.            end
  2098.            when abbrev(a1,"PERM")+abbrev(a1,'MOVE')>0 then do
  2099.              blocks.nthblock.!RTYPE='PERM'
  2100.              blocks.nthblock.!DEST=a2
  2101.            end 
  2102.            when abbrev(action,"TEMP")=1 then do
  2103.               blocks.nthblock.!RTYPE='TEMP'
  2104.               blocks.nthblock.!DEST=options
  2105.            end
  2106.            when abbrev(a1,"TEMP")=1  then do
  2107.               blocks.nthblock.!RTYPE='TEMP'
  2108.               blocks.nthblock.!DEST=a2
  2109.            end 
  2110.            otherwise  do
  2111.              call pmprintf(' SRE-http Monitor: unsupported REDIRECT action = 'action ','options)
  2112.            end
  2113.          end               /* which kind of redirect */
  2114.       end               /* action=redirect */
  2115.       otherwise  do
  2116.             call pmprintf(' SRE-http Monitor: unsupported ATTRIBS action = 'action ','options)
  2117.       end
  2118.   end                /* action */
  2119.    
  2120. end             /* do forever */
  2121.  
  2122.   
  2123. if verbose>0 then call pmprintf('SRE-http monitor: # of ATTRIBS.CFG entries: 'blocks.0)
  2124.  
  2125. if blocks.0=0 then return 1     /* nothing to write to */
  2126.  
  2127. /* clean up entries */
  2128. do nn=1 to blocks.0
  2129.    if blocks.nn.!useit=0 then iterate /* not for this port */
  2130.  
  2131.    if blocks.nn.!REPLACE<>'01'x then do
  2132.       blocks.nn.!realm='##REPLACE'
  2133.       iterate
  2134.    end
  2135.    if blocks.nn.!USER<>'01'x then do
  2136.       blocks.nn.!realm='##USER'
  2137.       iterate
  2138.    end
  2139.  
  2140.    if blocks.nn.!REALM='01'x then do
  2141.          call pmprintf(" SRE-http monitor: ERROR missing REALM: in ATTRIBS block #"nn)
  2142.          blocks.nn.!useit=0    /* don't use this one */
  2143.          iterate
  2144.    end /* do */
  2145.  
  2146.    if blocks.nn.!RULES='01'x then do
  2147.          call pmprintf(" SRE-http monitor: ERROR: missing RULE, PWD or WITH: in ATTRIBS block #"nn)
  2148.          blocks.nn.!useit=0    /* don't use this one */
  2149.          iterate
  2150.    end /* do */
  2151.  
  2152. /* create an idenfitying stem (using realm and host */
  2153.     trealm='!'||blocks.nn.!realm
  2154.     if blocks.nn.!host<>'01'x then do
  2155.             trealm=trealm||'.!!'||blocks.nn.!host
  2156.     end /* do */
  2157.  
  2158. /* is this a main realm -- if so, then check on REQUIRES: */
  2159.     if pos('.',blocks.nn.!realm)=0 then do
  2160.            if blocks.nn.!REQUIRES='01'x | blocks.nn.!requires='' then blocks.nn.!requires='*'
  2161.             blocks.nn.!ismain=1
  2162.      end
  2163.      blocks.nn.!stem=trealm
  2164. end
  2165.  
  2166. requires.='' ; permissions.=''
  2167.  
  2168.  
  2169. /* set REQUIRES. PERMISSIONS. stem arrays */
  2170. do nn=1 to blocks.0
  2171.    if blocks.nn.!useit=0 then iterate /* this entry not for this port, or missing info */
  2172.  
  2173. /* no realm for user and replace entries */
  2174.    if blocks.nn.!realm='##USER' | blocks.nn.!realm='##REPLACE' then iterate
  2175.  
  2176.    trealm=blocks.nn.!stem
  2177.    if blocks.nn.!ismain=1 then do        /* this is a main realm? then save requires */
  2178.        REQUIRES.trealm=blocks.nn.!requires
  2179.    end
  2180.  
  2181. /* save permissions (if they were set ) */
  2182.    if blocks.nn.!permissions<>'01'x then do
  2183.         permissions.trealm=blocks.nn.!permissions
  2184.    end /* do */
  2185.  
  2186. end
  2187.  
  2188.  
  2189. /* set the "requires" and "permissions" of subrealms */
  2190. do nn=1 to blocks.0
  2191.    if blocks.nn.!useit=0 then iterate
  2192.    if blocks.nn.!ismain=1 then iterate /* no super realms to check */
  2193.  
  2194. /* no requires or permissions for user and replace entries */
  2195.    if blocks.nn.!realm='##USER' | blocks.nn.!realm='##REPLACE' then iterate
  2196.  
  2197.    trealm=blocks.nn.!stem
  2198.    parse var trealm '!' arealm '.!!' ahost
  2199.    parse var arealm mrealm '.' .
  2200. /* fix up REQUIRES */
  2201.    mrealm2='!'||mrealm
  2202.    mrealm2=mrealm2||'.!!'||ahost
  2203.    if requires.mrealm2='' & mrealm<>'PUBLIC' then do
  2204.          call pmprintf(" SRE-http monitor: error: no main realm for subrealm: "arealm' ('mrealm2)
  2205.          blocks.nn.!useit=0
  2206.          iterate
  2207.     end
  2208.     blocks.nn.!requires=requires.mrealm2  /* subrealm MUST have main realm rules */
  2209.  
  2210. /* fill in with "superrealm's" PERMISSIONS, if need be */
  2211.    if permissions.trealm<>'' then iterate  /* explicit-- no need to fill in */
  2212.    do forever           /* look in higher "superealms" */
  2213.        iip=lastpos('.',arealm)
  2214.        if iip>0 then arealm=left(arealm,iip-1)
  2215.        urealm='!'||arealm
  2216.        if ahost<>'' then urealm=urealm||'.!!'||ahost
  2217.        if permissions.urealm<>'' then do
  2218.           blocks.nn.!permissions=permissions.urealm
  2219.          leave
  2220.        end
  2221.        if iip=0 then leave
  2222.    end
  2223.       
  2224. end
  2225.  
  2226. /* write results */
  2227. /*call pmprintf(' ---- writing to 'defrealm_file_temp) */
  2228. call lineout defrealm_file_temp,'; Do NOT edit this transient "realm definitions" file (created: 'date('n')' 'time('n')
  2229.  
  2230. do mm=1 to blocks.0
  2231.  if blocks.mm.!useit=0 then iterate /* skip this block */
  2232.  
  2233.  ahost=strip(translate(blocks.mm.!Host,' ','01'x))
  2234.  arealm=translate(blocks.mm.!realm)
  2235.  parse upper var arealm mainrealm '.' .
  2236.  rulist=strip(translate(blocks.mm.!rules,' ','01'x))
  2237.  adest=translate(blocks.mm.!dest,' ','01'x)
  2238.  do ii=1 to words(rulist)
  2239.     arule=strip(word(rulist,ii))
  2240.  
  2241.     call lineout defrealm_file_temp,' '
  2242.     if wordpos(blocks.mm.!REALM.!C,'1 C COMPLETE')>0 then
  2243.       call lineout defrealm_file_temp,';C_REALM:' arealm ', rule='arule
  2244.     else
  2245.       call lineout defrealm_file_temp,';REALM:' arealm ', rule='arule
  2246.  
  2247.  
  2248.    if arealm='##REPLACE' then do
  2249.        if ahost<>'' then
  2250.           aline='REPLACE: 'blocks.mm.!replace||'.'||ahost||' '||blocks.mm.!rules
  2251.        else
  2252.       call lineout defrealm_file_temp,aline    
  2253.       leave             
  2254.     end
  2255.  
  2256.    if arealm='##USER' then do
  2257.        if ahost<>'' then
  2258.           aline='USER: '||ahost||'// 'blocks.mm.!user
  2259.        else
  2260.           aline='USER: '||blocks.mm.!user
  2261.        aline=aline||' 'blocks.mm.!rules 
  2262.        if blocks.mm.!privs<>'01'x then
  2263.           aline=aline||' 'blocks.mm.!privs
  2264.       call lineout defrealm_file_temp,aline    
  2265.       leave
  2266.     end
  2267.  
  2268. /* is this a public url? */
  2269.     if mainrealm='PUBLIC' then do
  2270.        if ahost<>'' then
  2271.           aline='PUBURLS: '||ahost||'// 'arule
  2272.        else
  2273.           aline='PUBURLS: 'arule
  2274.        select
  2275.              when blocks.mm.!rtype='LITERAL' & pos('NO_POSTFILTER',blocks.mm.!permissions)>0 then 
  2276.                    aat=' LITERAL_NORECORD  '||blocks.mm.!dest
  2277.              when blocks.mm.!rtype='LITERAL'  then 
  2278.                    aat=' LITERAL '||blocks.mm.!dest
  2279.              when pos('NO_POSTFILTER',blocks.mm.!permissions)>0 then 
  2280.                    aat=' NORECORD '
  2281.              otherwise
  2282.                   aat=''
  2283.        end
  2284.        call lineout defrealm_file_temp,aline||aat  
  2285.        if blocks.mm.!rtype='LITERAL' then blocks.mm.!rtype='' /* suppres below */
  2286.        blocks.mm.!requires='*'          /* force open access */
  2287.     end /* do */
  2288.  
  2289. /* generate an access.in entry */
  2290.     if ahost<>'' then
  2291.        aline='ACCESS: '||ahost||'// 'arule
  2292.     else
  2293.        aline='ACCESS: 'arule
  2294.     aline=aline' '||translate(blocks.mm.!requires,' ','01'x)
  2295.     aline=aline','||translate(blocks.mm.!permissions,' ','01'x)
  2296.     aline=aline','||mainrealm
  2297.     aline=aline','||translate(blocks.mm.!failure,' ','01'x)
  2298.     aline=aline','||translate(blocks.mm.!advopts,' ','01'x)
  2299.     aline=aline','||translate(blocks.mm.!opts,' ','01'x)
  2300.     call lineout defrealm_file_temp,aline    
  2301.  
  2302. /* generate a virtual ? */
  2303.    if blocks.mm.!RTYPE='VIRTUAL' then do
  2304.       jj=pos('*',arule)
  2305.       if jj>0 then
  2306.          isit=left(arule,jj-1)
  2307.       else
  2308.          isit=arule
  2309.  
  2310.       bb=strip(strip(translate(isit,'/','\')),'t','/')||'/'
  2311.  
  2312.       if ahost<>'' then
  2313.          aline='VIRTUAL: '||ahost||'// 'bb
  2314.       else
  2315.          aline='VIRTUAL: 'bb
  2316.       bb2=blocks.mm.!dest
  2317.       if abbrev(translate(bb2),'HTTP://')=0 then do
  2318.           bb2=translate(bb2)
  2319.           bb2=strip(translate(bb2,'\','/'))
  2320.          if right(bb2,1)<>'*' then bb2=strip(bb2,'t','\')||'\'
  2321.       end
  2322.       aline=aline' 'bb2' '||translate(blocks.mm.!limitlist,' ','01'x)
  2323.       call lineout defrealm_file_temp,aline    
  2324.    end     
  2325.  
  2326.  
  2327.    if blocks.mm.!RTYPE='ALIAS' then do
  2328.       if ahost<>'' then
  2329.          aline='ALIAS: '||ahost||'// 'ARULE
  2330.       else
  2331.          aline='ALIAS: 'ARULE
  2332.       aline=aline' 'blocks.mm.!dest
  2333.       call lineout defrealm_file_temp,aline    
  2334.    end     
  2335.  
  2336.    if blocks.mm.!RTYPE='LITERAL' then do   /* note : not done with public realm */
  2337.       if ahost<>'' then
  2338.          aline='ALIAS: '||ahost||'// 'ARULE
  2339.       else
  2340.          aline='ALIAS: 'ARULE
  2341.       aline=aline' !TRANSFER='||strip(blocks.mm.!dest)
  2342.       call lineout defrealm_file_temp,aline    
  2343.    end
  2344.  
  2345.    if blocks.mm.!RTYPE='NEGOTIATE' then do   
  2346.       if ahost<>'' then
  2347.          aline='ALIAS: '||ahost||'// 'ARULE
  2348.       else
  2349.          aline='ALIAS: 'ARULE
  2350.       aline=aline' !NEGOTIATE '||translate(blocks.mm.!dest,' ','01'x)
  2351.       call lineout defrealm_file_temp,aline    
  2352.    end
  2353.  
  2354.  
  2355.    if blocks.mm.!RTYPE='PERM' then do
  2356.       jj=pos('*',blocks.mm.!dest)
  2357.       if jj>0 then
  2358.          isit=left(arule,jj-1)
  2359.       else
  2360.          isit=arule
  2361.  
  2362.       if ahost<>'' then
  2363.          aline='ALIAS: '||ahost||'// 'ARULE
  2364.       else
  2365.          aline='ALIAS: 'ARULE
  2366.       aline=aline' !MOVED='||STRIP(blocks.mm.!dest)
  2367.       call lineout defrealm_file_temp,aline    
  2368.    end     
  2369.  
  2370.  
  2371.    if blocks.mm.!RTYPE='TEMP' then do
  2372.       jj=pos('*',blocks.mm.!dest)
  2373.       if jj>0 then
  2374.          isit=left(arule,jj-1)
  2375.       else
  2376.          isit=arule
  2377.  
  2378.       if ahost<>'' then
  2379.          aline='ALIAS: '||ahost||'// 'ARULE
  2380.       else
  2381.          aline='ALIAS: 'ARULE
  2382.       aline=aline' !TEMP='||STRIP(blocks.mm.!dest)
  2383.       call lineout defrealm_file_temp,aline    
  2384.    end     
  2385.   end         /* this rule */
  2386.  
  2387.   if verbose<3  then iterate /* don't write background info */
  2388.  
  2389. end
  2390. call lineout defrealm_file_temp
  2391.  
  2392. return 1
  2393.  
  2394.  
  2395. /***************/
  2396. /* add an INCLUDE: file to astuff? If so,
  2397. possibly reset all HOST and PORT actions */
  2398.  
  2399. add_include_nthblock:procedure expose blocks. astuff crlf cfgs_dir
  2400. parse arg nthb
  2401.  
  2402. if blocks.nthb.!INCLUDE='01'x then return 0        /* no INCLUDE */
  2403.  
  2404. ill=stream(blocks.nthb.!INCLUDE,'c','query size')
  2405. if ill=0 | ill='' then do  /* try looking in cfgsdir */
  2406.   baa=cfgs_dir'\'blocks.nthb.!include
  2407.   ill=stream(baa,'c','query size')
  2408.   if ill<>0 & ill<>'' then blocks.nthb.!include=baa
  2409. end /* do */
  2410.  
  2411. if ill=0 | ill='' then do
  2412.     call pmprintf('SRE-http monitor: WARNING: bad ATTRIBS INCLUDE = 'blocks.nthb.!include)
  2413.     return 0
  2414. end /* do */
  2415. foo=stream(blocks.nthb.!include,'c','open read')
  2416. if abbrev(translate(foo),'READY')<>1 then do
  2417.     call pmprintf('SRE-http monitor: WARNING: 'foo' ATTRIBS INCLUDE = 'blocks.nthb.!include)
  2418.     return 0
  2419. end
  2420. aget=charin(blocks.nthb.!include,1,ill)  /* read in the INCLUDE file */
  2421. foo=stream(blocks.nthb.!include,'c','close')
  2422. aget=aget||crlf
  2423.  
  2424. /* now parse it, adding a PORT and HOST to each entry, and removing
  2425. any existing PORT and HOST actions */
  2426. if verbose>1 then call pmprintf('SRE-http monitor: including ATTRIBS file='blocks.nthb.!include) 
  2427. ngot=0
  2428. astuff=astuff||crlf||crlf
  2429. do forever
  2430.    if aget='' then return ngot
  2431.    parse var aget aline (crlf) aget
  2432.    aline=strip(aline);taline=translate(aline)
  2433.    if aline=';' then iterate  /* ignore comments */
  2434.  
  2435.    if abbrev(taline,'REALM')+abbrev(taline,'USER')+abbrev(taline,'REPL')>0 then do   /* all entries MUST have a REALM, USER or REPLACE */
  2436.       astuff=astuff||aline||crlf     /* WITH CURRENT HOST AND PORT */
  2437.       if blocks.nthb.!HOST<>'01'x then do
  2438.           astufF=astuff||'HOST: 'blocks.nthb.!host||crlf
  2439.       end
  2440.       if blocks.nthb.!PORT<>'01'x then do
  2441.           astufF=astuff||'PORT: 'blocks.nthb.!port||crlf
  2442.       end
  2443.       iterate
  2444.    end
  2445. /* suppress HOST and PORT -- always use this "blocks" host and port */
  2446.    if abbrev(taline,'HOST')+abbrev(taline,'PORT')>0 then iterate
  2447. /* else, add this line */
  2448.    astuff=astuff||aline||crlf
  2449. end
  2450.  
  2451.  
  2452. /* ----------------------------------------------------------------------- */
  2453. /* --  update mediatype temporary file */
  2454. /* ----------------------------------------------------------------------- */
  2455.  
  2456. chk_mediatyp:
  2457.  
  2458. if stream(mediatyp_file,'c','query exists')='' then do
  2459.    foo=' '
  2460.    aa=sysfiledelete(mediatyp_tfile)
  2461.    if aa<>0 then do
  2462.       call pmprintf(" SRE-http Monitor error: could not delete MEDIATYP.TMP ("aa)
  2463.       return 0
  2464.    end /* do */
  2465.    afoo=charout(mediatyp_tfile,foo,1)
  2466.    afoo=stream(mediatyp_tfile,'c','close')
  2467.    call pmprintf('SRE-http Monitor: no mediatyp.rxx file ')
  2468.    return 0
  2469. end /* do */
  2470.  
  2471. /* else, a mediatype file. Process, converting new style entries to 
  2472. old style entries*/
  2473.  
  2474. jin=stream(mediatyp_file,'c','query size')
  2475. iin=charin(mediatyp_file,1,jin)
  2476. oo=stream(mediatyp_file,'c','close')
  2477. /* remove comments (between /* and */ */
  2478. iin0=''
  2479. do forever
  2480.    parse var iin a1 '/*' ac '*/' iin
  2481.    iin0=iin0' 'a1
  2482.    if iin='' then leave
  2483. end
  2484. /* Look for type= entries, and convert 'em */
  2485. iin1=''; crlf='0d0a'x
  2486. do forever
  2487.   parse var iin0 a1 (crlf) iin0
  2488.   a1a=space(upper(a1),0)
  2489.   if abbrev(a1a,'TYPE=')=0 then do
  2490.       iin1=iin1||a1||'; '
  2491.   end
  2492.   else do               /* convert it */
  2493.       parse  var a1 . '=' amtype . '=' extlist
  2494.       extlist=translate(extlist,' ',','||'09'x)
  2495.       do forever
  2496.          parse upper var extlist aext extlist ; aext=strip(aext)
  2497.          iin1=iin1||"GARG='"||aext||"' ; KNOWN.GARG='"||amtype||"'; "
  2498.          if extlist='' then leave  /* done with this entry */
  2499.       end
  2500.   end
  2501.   if iin0='' then leave         /* done processing mediatyp file */
  2502. end
  2503. afoo=sysfiledelete(mediatyp_tfile)
  2504. afoo=charout(mediatyp_tfile,iin1,1)
  2505. afoo=stream(mediatyp_tfile,'c','close')
  2506. foo=pmprintf_sr(' SRE-http Monitor: updated MEDIATYP.RXX file ')
  2507.  
  2508. return 1
  2509.   
  2510.  
  2511. /* ----------------------------------------------------------------------- */
  2512. /* --  copy repstrgs file to environment */
  2513. /* ----------------------------------------------------------------------- */
  2514.  
  2515. chk_repstrgs:
  2516. parse arg resetit
  2517.  
  2518. if repstrgs_file=" " then
  2519.   return 0
  2520. oy=stream(repstrgs_file,'c','query exists')
  2521. if oy="" then do
  2522.    foo=pmprintf_sr("SRE-http Monitor: Replacement strings file not found, "|| get_file)
  2523.    return -1
  2524. end
  2525.  
  2526. /* yep, reinitialize repstrgs file (set semaphore first */
  2527. ause=sref_fileread(repstrgs_file,'filelines',,'E')
  2528.  
  2529. aa=add_auxillary('REPSTRGS','REPSTRGS.IN',serverport,0)
  2530.  
  2531. foo=add_defrealm_rep('REPLACE')
  2532.  
  2533. If (ause<=0) then  do               /*no such file,*/
  2534.       foo=pmprintf_sr("SRE-http Monitor: error " ause " when reading replacement strings file, "|| repstrgs_file)
  2535.       return -1
  2536. end
  2537.  
  2538. crlf='0d0a'x
  2539. j=0
  2540. /* zap current list of repstrings variables */
  2541. do rr=1 to repsvars.0
  2542.   call value repsvars.rr,' ','os2environment'
  2543. end
  2544. repsvars.0=0
  2545. do mm=1 to filelines.0
  2546.   goo=strip(filelines.mm)
  2547.   if goo="" | left(goo,1)=";" then  iterate
  2548.   parse var goo aname avalue
  2549.   aname=envadd||upper(aname)
  2550.   t1=value(aname,,'os2environment')
  2551.   if t1=' ' then do
  2552.       t1=avalue
  2553.       j=j+1
  2554.       repsvars.j=aname
  2555.       repsvars.0=j
  2556.   end
  2557.   else do
  2558.         t1=t1||crlf||avalue
  2559.   end
  2560.   call value aname,t1,'os2environment'
  2561. end
  2562. foo=pmprintf_sr(' SRE-http Monitor: loaded replacements strings: 'j)
  2563. return j
  2564.  
  2565.  
  2566. /* ----------------------------------------------------------------------- */
  2567. /* -- See if a "generic" YES answer. If so, return 1 */
  2568. /* ----------------------------------------------------------------------- */
  2569. is_true:procedure
  2570. parse upper arg ans,anslist
  2571. if wordpos(ans,anslist)>0 then
  2572.  return 1
  2573. else
  2574.  return 0
  2575.  
  2576.  
  2577.  
  2578. /*=========     Start various threads   ===================== */
  2579.  
  2580.  
  2581. /* ------------------------------------------------------------ */
  2582. /* start access processor thread */
  2583. start_access:
  2584. parse arg resetit
  2585.  
  2586. if access_file= ' ' | SUPPRESS_ACCESS=1 then
  2587.       return 0
  2588. oy=stream(access_file,'c','query exists')
  2589. if oy="" then do
  2590.    foo=pmprintf_sr("SRE-http Monitor: access file not found, "|| access_file)
  2591.    access_file=' '
  2592.    return -1
  2593. end
  2594.  
  2595. arxx=servdir||'\acceschk.rxx'
  2596. usequeue='SREF_'||serverport||'_ACCESS'
  2597. usesem='\SEM32\SREF_'||serverport||'_ACCESS'
  2598.  
  2599. if resetit=1 then do            /* already opened --just send a *RESET* */
  2600.    a=rxqueue('s',usequeue)
  2601.    push '1, 1, 2, *RESET* ' access_file
  2602.    return 1
  2603. end
  2604.  
  2605. /* if here, first time */
  2606.  
  2607. a=rxqueue('d',usequeue)
  2608. a=rxqueue('c',usequeue)
  2609. if a<>usequeue then do
  2610.   bb=rxqueue('d',a)
  2611.   a=rxqueue('s',usequeue)
  2612.   do queued()
  2613.        pull
  2614.   end /* do */
  2615. end
  2616.  
  2617. a=eventsem_close(usesem)
  2618. A=EVENTSEM_CREATE(USESEM)
  2619. IF A<>0 then DO
  2620.     foo=pmprintf_sr(' SRE-http Monitor: Error creating access semaphore: 'A' 'usesem)
  2621.     access_file=' '
  2622.     return -1
  2623. end
  2624. access_tid=rexxthread('f',arxx,access_file,usequeue,USESEM,max_semwait,serverport)
  2625. if access_tid=0 then do
  2626.    foo=pmprintf_sr(' SRE-http Monitor: Could not open access thread 'arxx)
  2627.     access_file=' '
  2628.    return -1
  2629. end
  2630.  
  2631. return 1
  2632.  
  2633. /* ---------------- */
  2634. /* start alias processor thread */
  2635. start_alias:
  2636. parse arg resetit
  2637.  
  2638. if alias_file= ' ' | SUPPRESS_ALIAS=1 then
  2639.       return 0
  2640. oy=stream(alias_file,'c','query exists')
  2641.  
  2642. if oy="" then do
  2643.    foo=pmprintf_sr("SRE-http Monitor: alias file not found, "|| alias_file)
  2644.    alias_file=' '
  2645.    return -1
  2646. end
  2647.  
  2648. arxx=servdir||'\aliaschk.rxx'
  2649. usequeue='SREF_'||serverport||'_ALIAS'
  2650. usesem='\SEM32\SREF_'||serverport||'_ALIAS'
  2651.  
  2652. if resetit=1 then do            /* already opened --just send a *RESET* */
  2653.    a=rxqueue('s',usequeue)
  2654.    push '1,1,2,*RESET* ' alias_file
  2655.    foo=eventsem_post(usesem)
  2656.    return 1
  2657. end
  2658.  
  2659. /* if here, first time */
  2660.  
  2661. a=rxqueue('d',usequeue)
  2662. a=rxqueue('c',usequeue)
  2663. if a<>usequeue then do
  2664.   bb=rxqueue('d',a)
  2665.   a=rxqueue('s',usequeue)
  2666.   do queued()
  2667.        pull
  2668.   end /* do */
  2669. end
  2670.  
  2671. a=eventsem_close(usesem)
  2672. A=EVENTSEM_CREATE(USESEM)
  2673. IF A<>0 then DO
  2674.     foo=pmprintf_sr(' SRE-http Monitor: Error creating alias semaphore: 'A' 'usesem)
  2675.     return 0
  2676. end
  2677. alias_tid=rexxthread('f',arxx,alias_file,usequeue,USESEM,max_semwait,serverport)
  2678. if alias_tid=0 then do
  2679.    foo=pmprintf_sr(' SRE-http Monitor: Could not open alias thread 'arxx)
  2680.    return 0
  2681. end
  2682.  
  2683. return 1
  2684.  
  2685.  
  2686. /* ---------------- */
  2687. /* start public-urls processor thread */
  2688. start_puburl:
  2689. parse arg resetit
  2690.  
  2691. if puburl_file= ' ' | never_publicurls=1 then do
  2692.     puburl_file=''
  2693.     call value envadd||'PUBURL_FILE',puburl_file,'os2environment'
  2694.    return 0
  2695. end /* do */
  2696.  
  2697. oy=stream(puburl_file,'c','query exists')
  2698. if oy="" then do
  2699.    foo=pmprintf_sr("SRE-http Monitor: Warning: public urls file not found, "|| puburl_file)
  2700.    puburl_file=' '
  2701.    call value envadd||'PUBURL_FILE',puburl_file,'os2environment'
  2702.    return -1
  2703. end
  2704.  
  2705. arxx=servdir||'\puburchk.rxx'
  2706. usequeue='SREF_'||serverport||'_PUBURL'
  2707. usesem='\SEM32\SREF_'||serverport||'_PUBURL'
  2708.  
  2709.  
  2710.  
  2711. if resetit=1 then do            /* already opened --just send a *RESET* */
  2712.    a=rxqueue('s',usequeue)
  2713.    push '1,1,2,*RESET* ' puburl_file
  2714.    foo=eventsem_post(usesem)
  2715.    return 1
  2716. end
  2717.  
  2718. /* if here, first time */
  2719.  
  2720. a=rxqueue('d',usequeue)
  2721. a=rxqueue('c',usequeue)
  2722. if a<>usequeue then do
  2723.   bb=rxqueue('d',a)
  2724.   a=rxqueue('s',usequeue)
  2725.   do queued()
  2726.        pull
  2727.   end /* do */
  2728. end
  2729.  
  2730.  
  2731. a=eventsem_close(usesem)
  2732. A=EVENTSEM_CREATE(USESEM)
  2733. IF A<>0 then DO
  2734.     foo=pmprintf_sr(' SRE-http Monitor: Error creating puburl semaphore: 'A' 'usesem)
  2735.     return 0
  2736. end
  2737. puburl_tid=rexxthread('f',arxx,puburl_file,usequeue,USESEM,max_semwait,serverport)
  2738. if puburl_tid=0 then do
  2739.    foo=pmprintf_sr(' SRE-http Monitor: Could not open puburl thread 'arxx)
  2740.    return 0
  2741. end
  2742.  
  2743. return 1
  2744.  
  2745.  
  2746.  
  2747. /* ---------------- */
  2748. /* start virtual dir processor thread */
  2749. start_virtual:
  2750. parse arg resetit
  2751.  
  2752. IF VIRTUAL_FILE="" | SUPPRESS_VIRTUAL=1 then RETURN 0
  2753.  
  2754. dlistx=upload_dir||' '||cgi_bin_dir||'  '||addon_dir||' '
  2755. dlistx=dlistx||translate(datadir(),'\','/')
  2756.  
  2757. arxx=servdir||'\virtchk.rxx'
  2758. usequeue='SREF_'||serverport||'_VIRTUAL'
  2759. usesem='\SEM32\SREF_'||serverport||'_VIRTUAL'
  2760.  
  2761. if resetit=1 then do            /* already opened --just send a *RESET* */
  2762.    a=rxqueue('s',usequeue)
  2763.    push '1,1,2, *RESET* ' virtual_file
  2764.    foo=eventsem_post(usesem)
  2765.    return 1
  2766. end
  2767.  
  2768. if virtual_file= ' ' then
  2769.       return 0
  2770. oy=stream(virtual_file,'c','query exists')
  2771. if oy="" then do
  2772.    foo=pmprintf_sr("SRE-http Monitor: virtual file not found, "|| virtual_file)
  2773.    virtual_file=' '
  2774.    return 0
  2775. end
  2776.  
  2777. /* if here, first time */
  2778.  
  2779. a=rxqueue('d',usequeue)
  2780. a=rxqueue('c',usequeue)
  2781. if a<>usequeue then do
  2782.   bb=rxqueue('d',a)
  2783.   a=rxqueue('s',usequeue)
  2784.   do queued()
  2785.        pull
  2786.   end /* do */
  2787. end
  2788.  
  2789. a=eventsem_close(usesem)
  2790. A=EVENTSEM_CREATE(USESEM)
  2791. IF A<>0 then DO
  2792.     foo=pmprintf_sr(' SRE-http Monitor:Error creating virtual semaphore: 'A' 'usesem)
  2793.     return 0
  2794. end
  2795. mm1=max_semwait
  2796. virtual_tid=rexxthread('f',arxx,virtual_file||' '||dlistx,usequeue,USESEM,mm1,serverport)
  2797. if virtual_tid=0 then do
  2798.    foo=pmprintf_sr(' SRE-http Monitor:Could not open virtual thread 'arxx)
  2799.    return 0
  2800. end
  2801.  
  2802. return 1
  2803.  
  2804.  
  2805.  
  2806. /* ---------------- */
  2807. /* start variable storage thread */
  2808. start_varstore:
  2809. parse arg addme
  2810.  
  2811. arxx=servdir||'\varstore.rxx'
  2812. usequeue='SREF_'||serverport||'_VARSTORE'||addme
  2813. usesem='\SEM32\SREF_'||serverport||'_VARSTORE'||addme
  2814. a=rxqueue('d',usequeue)
  2815. a=rxqueue('c',usequeue)
  2816. if a<>usequeue then do
  2817.   bb=rxqueue('d',a)
  2818.   a=rxqueue('s',usequeue)
  2819.   do queued()
  2820.        pull
  2821.   end /* do */
  2822. end
  2823.  
  2824. a=eventsem_close(usesem)
  2825. A=EVENTSEM_CREATE(USESEM)
  2826. IF A<>0 then DO
  2827.     call pmprintf(' SRE-http Monitor:Error creating variable storage semaphore:'usesem)
  2828.     return 0
  2829. end
  2830. mm1=max_semwait
  2831. v_tid=rexxthread('f',arxx,usequeue,USESEM,mm1,serverport,x_limitclients)
  2832. if v_tid=0 then do
  2833.    call pmprintf(' SRE-http Monitor:Could not start variable storage thread 'arxx)
  2834.    return 0
  2835. end
  2836.  
  2837. return 1
  2838.  
  2839.  
  2840.  
  2841.  
  2842. /* ---------------- */
  2843. /* start superceding realm  thread */
  2844. start_srealm:
  2845. parse arg resetit
  2846.  
  2847. if no_superceding_realm=1 then return 0
  2848.  
  2849. arxx=servdir||'\srealm.rxx'
  2850. usequeue='SREF_'||serverport||'_SREALM'
  2851. usesem='\SEM32\SREF_'||serverport||'_SREALM'
  2852.  
  2853. if resetit=1 then do            /* already opened --just send a *RESET* */
  2854.    a=rxqueue('s',usequeue)
  2855.    push '1,1,2, *RESET* ' virtual_file
  2856.    foo=eventsem_post(usesem)
  2857.    return 1
  2858. end
  2859.  
  2860.  
  2861. a=rxqueue('d',usequeue)
  2862. a=rxqueue('c',usequeue)
  2863. if a<>usequeue then do
  2864.   bb=rxqueue('d',a)
  2865.   a=rxqueue('s',usequeue)
  2866.   do queued()
  2867.        pull
  2868.   end /* do */
  2869. end
  2870.  
  2871. a=eventsem_close(usesem)
  2872. A=EVENTSEM_CREATE(USESEM)
  2873. IF A<>0 then DO
  2874.     foo=pmprintf_sr(' SRE-http Monitor:Error creating superceding realm semaphore:'usesem)
  2875.     return 0
  2876. end
  2877. mm1=max_semwait
  2878. ssicache_tid=rexxthread('f',arxx,defrealm_file_temp,usequeue,USESEM,mm1,serverport)
  2879. if ssicache_tid=0 then do
  2880.    foo=pmprintf_sr(' SRE-http Monitor:Could not open superceding realm thread 'arxx)
  2881.    return 0
  2882. end
  2883.  
  2884. return 1
  2885.  
  2886.  
  2887.  
  2888.  
  2889.  
  2890. /* ---------------- */
  2891. /* start virtual dir processor thread */
  2892. start_ssicache:
  2893. if ssi_cache_size="" then return 0
  2894.  
  2895. arxx=servdir||'\ssicache.rxx'
  2896. usequeue='SREF_'||serverport||'_SSICACHE'
  2897. usesem='\SEM32\SREF_'||serverport||'_SSICACHE'
  2898.  
  2899.  
  2900. a=rxqueue('d',usequeue)
  2901. a=rxqueue('c',usequeue)
  2902. if a<>usequeue then do
  2903.   bb=rxqueue('d',a)
  2904.   a=rxqueue('s',usequeue)
  2905.   do queued()
  2906.        pull
  2907.   end /* do */
  2908. end
  2909.  
  2910. a=eventsem_close(usesem)
  2911. A=EVENTSEM_CREATE(USESEM)
  2912. IF A<>0 then DO
  2913.     foo=pmprintf_sr(' SRE-http Monitor:Error creating ssi-cache semaphore:'usesem)
  2914.     return 0
  2915. end
  2916. mm1=max_semwait
  2917. ssicache_tid=rexxthread('f',arxx,tempdata_dir,usequeue,USESEM,mm1,serverport,ssi_cache_size,ssi_cache_duration,ssi_cache_stamp,serverport)
  2918. if ssicache_tid=0 then do
  2919.    foo=pmprintf_sr(' SRE-http Monitor:Could not open ssi-cache thread 'arxx)
  2920.    return 0
  2921. end
  2922.  
  2923. return 1
  2924.  
  2925.  
  2926.  
  2927. /* ---------------- */
  2928. /* start virtual dir processor thread */
  2929. start_sreproxy:
  2930. parse arg resetit
  2931.  
  2932. oo=value('SREF_PROXY',,'os2environment')
  2933. if oo='' | oo=0 then return 0
  2934.  
  2935. arxx=servdir||'\sreproxy.rxx'
  2936. afilter=servdir||'\SREFILTR.'||serverport
  2937. usequeue='SREF_SREPROXY'
  2938. usesem='\SEM32\SREF_SREPROXY'
  2939.  
  2940. if resetit=1 then do            /* already opened --just send a *RESET* */
  2941.    a=rxqueue('s',usequeue)
  2942.    push '1,1,2,RESET'
  2943.    foo=eventsem_post(usesem)
  2944.    return 1
  2945. end
  2946.  
  2947. a=rxqueue('d',usequeue)
  2948. a=rxqueue('c',usequeue)
  2949. if a<>usequeue then do
  2950.   bb=rxqueue('d',a)
  2951.   a=rxqueue('s',usequeue)
  2952.   do queued()
  2953.        pull
  2954.   end /* do */
  2955. end
  2956.  
  2957. a=eventsem_close(usesem)
  2958. A=EVENTSEM_CREATE(USESEM)
  2959. IF A<>0 then DO
  2960.     foo=pmprintf_sr(' SRE-http Monitor: Error creating sreproxy:'usesem)
  2961.     return -1
  2962. end
  2963. mm1=max_semwait
  2964. sreproxy_tid=rexxthread('f',arxx,tempdata_dir,usequeue,USESEM,mm1,serverport,afilter)
  2965. if sreproxy_tid=0 then do
  2966.    foo=pmprintf_sr(' SRE-http Monitor: Could not open sre-proxy thread 'arxx)
  2967.    return -1
  2968. end
  2969.  
  2970. return 1
  2971.  
  2972.  
  2973. /* ---------------- */
  2974. /* start user check processor thread */
  2975. start_user:
  2976. parse arg resetit
  2977. if user_file= ' ' | SUPPRESS_USER=1 then
  2978.       return 0
  2979.  
  2980. oy=stream(user_File,'c','query exists')
  2981. if oy="" then do
  2982.    foo=pmprintf_sr("SRE-http Monitor: userl file not found, "||user_file)
  2983.     user_file=' '
  2984.    return -1
  2985. end
  2986.  
  2987. arxx=servdir||'\userchk.rxx'
  2988. usequeue='SREF_'||serverport||'_USER'
  2989. usesem='\SEM32\SREF_'||serverport||'_USER'
  2990.  
  2991. if resetit=1 then do            /* already opened --just send a *RESET* */
  2992.    a=rxqueue('s',usequeue)
  2993.    push '1,1,2, *RESET* ' user_File
  2994.    foo=eventsem_post(usesem)
  2995.    return 1
  2996. end
  2997.  
  2998. /* if here, first time */
  2999. a=rxqueue('d',usequeue)
  3000. a=rxqueue('c',usequeue)
  3001. if a<>usequeue then do
  3002.   bb=rxqueue('d',a)
  3003.   a=rxqueue('s',usequeue)
  3004.   do queued()
  3005.        pull
  3006.   end /* do */
  3007. end
  3008.  
  3009. a=eventsem_close(usesem)
  3010. A=EVENTSEM_CREATE(USESEM)
  3011. IF A<>0 then DO
  3012.     foo=pmprintf_sr(' SRE-http Monitor:Error creating user semaphore: 'A' 'usesem)
  3013.     return 0
  3014. end
  3015. user_tid=rexxthread('f',arxx,user_file,usequeue,USESEM,max_semwait,logon_limit,serverport)
  3016. if user_tid=0 then do
  3017.    foo=pmprintf_sr(' SRE-http Monitor:Could not open user thread 'arxx)
  3018.    return 0
  3019. end
  3020.  
  3021.  
  3022. return 1
  3023.  
  3024.  
  3025. /* ---------------- */
  3026. /* start postfilter / recordall processor thread */
  3027. start_postf:
  3028. parse arg resetit
  3029.  
  3030. arxx=servdir||'\postfchk.rxx'
  3031. usequeue='SREF_'||serverport||'_POSTF'
  3032. usesem='\SEM32\SREF_'||serverport||'_POSTF'
  3033.  
  3034. a=rxqueue('d',usequeue)
  3035. a=rxqueue('c',usequeue)
  3036. if a<>usequeue then do
  3037.   bb=rxqueue('d',a)
  3038.   a=rxqueue('s',usequeue)
  3039.   do queued()
  3040.        pull
  3041.   end /* do */
  3042. end
  3043.  
  3044. a=eventsem_close(usesem)
  3045. A=EVENTSEM_CREATE(USESEM)
  3046. IF A<>0 then DO
  3047.     foo=pmprintf_sr('SRE-http Monitor: Error creating postfilter semaphore: 'A' 'usesem)
  3048.     return 0
  3049. end
  3050.  
  3051. mm1=max_semwait*1.5
  3052. postf_tid=rexxthread('f',arxx,usequeue,USESEM,thesem,mm1,record_cache_lines' 'workdata_dir,serverport,logfile_maxsize)
  3053. if postf_tid=0 then do
  3054.    foo=pmprintf_sr(' SRE-http Monitor:Could not open postfilter thread 'arxx)
  3055.    return 0
  3056. end
  3057.  
  3058. return 1
  3059.  
  3060.  
  3061.  
  3062. /* ----  */
  3063. /* make headers and footers, host specific possibly */
  3064. make_head_foot:procedure expose aheaders. afooters. headlist. footlist. ,
  3065.         headers footers  nheads nfoots headers. footers. serverport
  3066.  
  3067. foo=cvtails('headers.','b')
  3068. joe=arraysort('b')
  3069. crlf=' '
  3070. headers=' ' ; nheads=0 ; HDDONE=0
  3071. do mm=1 to b.0
  3072.     a1=b.mm
  3073.     a2=headers.a1
  3074.     if a2=" " then a2=0
  3075.     IF A2=0 then HDDONE=1
  3076.     if pos('.',a1)=0  then do
  3077.        if HDDONE=0 then  headers=headers||a2||crlf
  3078.     end  /* Do */
  3079.     else do             /* headers.hn */
  3080.        parse var a1 aval '.' ahost ; ahost=strip(ahost) ; aval=strip(aval)
  3081.        if strip(a2)=0 then do
  3082.              headstops.ahost=1
  3083.        end  /* Do */
  3084.        else do          /* not a stop */
  3085.          if aval=1 then  do
  3086.              nheads=nheads+1
  3087.               headlist.nheads=ahost
  3088.               aheaders.ahost=a2||crlf
  3089.              headstops.ahost=0
  3090.          end
  3091.          else do
  3092.            if headstops.ahost<>1 then
  3093.               aheaders.ahost=aheaders.ahost||a2||crlf
  3094.          end
  3095.        end              /* headstop */
  3096.     end                 /* .hn */
  3097. end
  3098. foo=cvtails('footers.','b')
  3099. joe=arraysort('b')
  3100. footers=' ' ; nfoots=0 ; FTDONE=0
  3101. do mm=1 to b.0
  3102.     a1=b.mm
  3103.     a2=footers.a1
  3104.     if a2=" " then a2=0
  3105.     IF A2=0 then FTDONE=1
  3106.     if pos('.',a1)=0  then do
  3107.        if FTDONE=0 then footers=footers||a2||crlf
  3108.     end  /* Do */
  3109.     else do             /* footers.hn */
  3110.        parse var a1 aval '.' ahost ; ahost=strip(ahost) ; aval=strip(aval)
  3111.        if strip(a2)=0 then do
  3112.              footstops.ahost=1
  3113.        end  /* Do */
  3114.        else do          /* not a stop */
  3115.          if aval=1 then  do
  3116.              nfoots=nfoots+1
  3117.               footlist.nfoots=ahost
  3118.               afooters.ahost=a2||crlf
  3119.              footstops.ahost=0
  3120.          end
  3121.          else do
  3122.            if footstops.ahost<>1 then
  3123.               afooters.ahost=afooters.ahost||a2||crlf
  3124.          end
  3125.        end              /* footstop */
  3126.     end                 /* .hn */
  3127. end
  3128.  
  3129. return 0
  3130.  
  3131.  
  3132. /*----------------------*/
  3133. save_em:
  3134. parse arg avar ;avar=strip(avar)
  3135.  
  3136. igot=0
  3137. drop plist
  3138.  
  3139. avar0=strip(avar,'t','.')
  3140. avar=avar0||'.'
  3141. rr=cvtails(avar,'plist')
  3142. do r1=1 to rr
  3143.    atail=plist.r1
  3144.    interpret 't1='||avar||atail
  3145.    call value envadd||avar||atail,t1,'os2environment'
  3146.    igot=igot+1
  3147. end
  3148.  
  3149. /* save the default (non hostname) version */
  3150.    if upper(symbol(avar0))="VAR" then do
  3151.       interpret 't1='||avar0
  3152.       call value envadd||avar0,t1,'os2environment'
  3153.       igot=igot+1
  3154.    end
  3155.  
  3156. return igot
  3157.  
  3158.  
  3159. /* --- variable names of convert foo.bar.1 to foo.1.bar */
  3160. fix_me:procedure
  3161. parse arg a1
  3162.  
  3163. if a1=' '  then return a1
  3164. a1=strip(a1)
  3165. if abbrev(a1,';') then return a1
  3166.  
  3167. parse var a1  aname '=' avalue
  3168. if pos('.',aname)=0 then return a1
  3169.  
  3170. foo=translate(aname,' ','.')
  3171. if words(foo)<>3 then return a1
  3172.  
  3173. /* if here, array.x.y (3 elements) */
  3174. if datatype(word(foo,3))='NUM' & datatype(word(foo,2))<>'NUM' then do  /* rearrange */
  3175.    foo2=word(foo,1)||'.'||word(foo,3)||'.'||word(foo,2)||' = '||avalue
  3176.    return foo2
  3177. end  /* Do */
  3178. else do
  3179.    return a1
  3180. end  /* Do */
  3181.  
  3182.  
  3183.  
  3184.  
  3185. /***************/
  3186. /* update addon's to macrospace. */
  3187. update_addons:procedure expose keep_addons. verbose envadd serverport
  3188. if symbol('KEEP_ADDONS.0')<>'VAR' then return  0 /* none specified*/
  3189. if datatype(keep_addons.0)<>'NUM'  then return 0
  3190.  
  3191. do iy=1 to keep_addons.0
  3192.    if symbol('KEEP_ADDONS.'||iy)<>'VAR' then iterate
  3193.    parse var keep_addons.iy asel afile . ; afile=strip(afile); asel=strip(asel)
  3194.    IF AFILE="" then DO          /* REMOVE ASEL */
  3195.       asel=strip(translate(asel,'/','\'),,'/')          
  3196.       tt=envadd||'ADDON_'||translate(asel,'__','/\')    
  3197.       FOO=MACROdROP(TT)
  3198.       ITERATE
  3199.    END
  3200.    if stream(afile,'c','query exists')="" then do
  3201.         if verbose>0 then foo=pmprintf_sr(" SRE-http Monitor WARNING: bad file in KEEP_ADDON entry: " asel ',' afile)
  3202.         iterate
  3203.    end  /* Do */
  3204.    asel=strip(translate(asel,'/','\'),,'/')
  3205.    tt=envadd||'ADDON_'||translate(asel,'__','/\')
  3206.    foo=macroadd(tt,afile,'B')
  3207.    if foo=0 then do
  3208.       if verbose>0 then foo=pmprintf_sr(" SRE-http Monitor WARNING: problem with KEEP_ADDON entry: " keep_addons.iy)
  3209.        iterate
  3210.    end  /* Do */
  3211.    if verbose>1 then foo=pmprintf_sr(' SRE-http Monitor: Okay ADDON entry: ' tt ' : ' afile)
  3212. end /* do */
  3213. return 0
  3214.  
  3215.  
  3216. /****************/
  3217. /* start the pmprintf thread 
  3218. itype: 1= use pmprintf, but check line lengths
  3219.        2= use pmprintf, and write to afile
  3220.        3= just write to afile
  3221. */
  3222.  
  3223. start_pmprintf:
  3224. parse arg itype, ilen, afile
  3225.  
  3226. if ilen<2 then ilen=80
  3227.  
  3228. /* check variables */
  3229. if itype=3 then ilen=0
  3230. if itype=1 then 
  3231.   afile=' '
  3232. else
  3233.   afile=servdir||'\'||strip(afile,,'\')
  3234.  
  3235. if itype>1 then do
  3236.   call lineout afile,' -- SRE-http log file: '||time('n')||' '||date('n')
  3237.   call lineout afile
  3238. end
  3239.  
  3240.  
  3241. /* start thread */
  3242. arxx=servdir||'\pmprintf.rxx'
  3243. usequeue='SREF_'||serverport||'_PMPRINTF'
  3244. usesem='\SEM32\SREF_'||serverport||'_PMPRINTF'
  3245. a=rxqueue('d',usequeue)
  3246. a=rxqueue('c',usequeue)
  3247. if a<>usequeue then do
  3248.   bb=rxqueue('d',a)
  3249.   a=rxqueue('s',usequeue)
  3250.   do queued()
  3251.        pull
  3252.   end /* do */
  3253. end
  3254.  
  3255. a=eventsem_close(usesem)
  3256. A=EVENTSEM_CREATE(USESEM)
  3257. IF A<>0 then DO
  3258.     call pmprintf(' SRE-http Monitor:Error creating PMPRINTF semaphore:'usesem)
  3259.     return 0
  3260. end
  3261. mm1=max_semwait
  3262. v_tid=rexxthread('f',arxx,usequeue,USESEM,mm1,ilen,itype,afile)
  3263. if v_tid=0 then do
  3264.    call pmprintf(' SRE-http Monitor:Could not start PMPRINTF thread 'arxx)
  3265.    return 0
  3266. end
  3267.  
  3268. return 1
  3269.  
  3270.  
  3271.  
  3272.  
  3273. /***************/
  3274. pmprintf_sr:procedure expose serverport
  3275. parse arg amess
  3276. foo=pmprintf_sref(amess,,serverport)
  3277. return 0
  3278.  
  3279.  
  3280. /*********************/
  3281. /* call the procedures listed in custom_inits */
  3282. call_custom_inits:procedure expose serverport
  3283. parse arg alist
  3284. signal off error ; signal off syntax ;
  3285. signal on error name yipes2 ; signal on syntax name yipes2 ;
  3286. if alist=0 then alist=""
  3287.  
  3288. if alist="" then do
  3289.     call pmprintf(' SRE-http Monitor: no custom initialization procedures specified')
  3290.    return 1
  3291. end /* do */
  3292.  
  3293. do until alist=""
  3294.     parse var alist aproc ',' alist
  3295.     if aproc="" then leave
  3296.     parse var aproc aname anarg
  3297.     call pmprintf('SRE-http Monitor: executing initialization procedure 'aproc)
  3298.     dog='okay='||aname||'("'anarg'")'
  3299.     interpret dog
  3300. end /* do */
  3301.  
  3302.  
  3303. signal on error name yipes ; signal on syntax name yipes ;
  3304.  
  3305. return 1
  3306.  
  3307. yipes2:
  3308. call pmprintf(' SRE-http Monitor: Error running external initialization procedure: 'aproc)
  3309. call pmprintf(dog)
  3310. return 0
  3311.  
  3312. /******************/
  3313. /* call rexxlib date conversion, but check y2k first */
  3314. dateconv_3:procedure 
  3315. parse upper arg aval,t1,t2
  3316. hh=''
  3317. select 
  3318.  when t1='O' | t1='U' | t1='E' then do
  3319.    if t1='O' then      parse var aval yy '/' mo '/' dd '/' hh '/' mm .
  3320.    if t1='U' then     parse var aval mo '/' dd '/' yy
  3321.    if t1='E' then     parse var aval dd '/' mo '/' yy
  3322.    if yy<78 then 
  3323.        yy=2000+yy 
  3324.    else
  3325.       yy=yy+1900
  3326.     yip=strip(yy)||strip(mo)||strip(dd)
  3327.     adatef=dateconv(yip,'S',t2)
  3328.  end
  3329.  otherwise do
  3330.     adatef=dateconv(aval,t1,t2)
  3331.  end
  3332. end
  3333.  
  3334. if hh<>'' then do
  3335.      adatef=adatef+(((hh*60)+mm)/1440)
  3336. end /* do */
  3337.  
  3338. return adatef
  3339.  
  3340.  
  3341. 
  3342. /******/
  3343. /* set an error flag, wake up srefilter, exit */
  3344. gosexit:
  3345. PARSE ARG AA
  3346. foo1=value('SREF_WAIT_FLAG',-2,'os2environment')
  3347. FOO2=VALUE('SREF_WAIT_FLAG_ERROR',AA,'OS2ENVIRONMENT')
  3348. foo3=eventsem_create(thesem)
  3349. foo2=eventsem_post(thesem)
  3350.  
  3351. exit  
  3352.  
  3353.  
  3354.