home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Spezial / SPEZIAL2_97.zip / SPEZIAL2_97.iso / ANWEND / ONLINE / SREFV12J / SREFMON.CMD < prev    next >
OS/2 REXX Batch file  |  1997-09-17  |  53KB  |  1,768 lines

  1. /*SRE_Filter monitor routine (run as a non-transient thread in same process
  2. as goserve */
  3.  
  4. doanyway_loops=300      /* reset after this many loops */
  5.  
  6. do_cleanup=1      /* set = 1 to occasionally cleanup orphaned cgi-bin temp files */
  7.  
  8.  
  9. _no_set_check=0  /* set =1 to suppress @SET checking (some machines require this */
  10.  
  11. /* the following are used by sref_pmprintf */
  12. pmprintf_line_length=150 /* max line length to "sref_pmprintf" */
  13. pmprintf_log_file='SREFILTR.LOG ' /* name of the sref_pmprintf log file (in goserve directory) */
  14.  
  15. signal on error name yipes ; signal on syntax name yipes ;
  16. signal on failure name yipes ; signal on halt name yipes ;
  17.  
  18.  
  19. /* ---------- DO NOT CHANGE BELOW HERE  ----------------*/
  20.  
  21. parse arg goserve_pid, thesem,servdir,SERVERPORT,envadd,max_semwait,moreargs
  22.  
  23. if servdir=" " then do
  24.    say " This SRE-Filter daemon is NOT meant to be invoked from an OS/2 prompt!"
  25.   exit
  26. end  /* Do */
  27.  
  28. parse var moreargs loadthreshold ',' backupserverlist ','  ,
  29.    delay_seconds ',' message_scramble ',' record_cache_lines ',' logon_limit ',' ssi_extensions ',' ,
  30.    ssi_cache_size ',' ssi_cache_duration ',' ssi_cache_stamp ',' save_state ',' no_no_record ',' hit_superuser_suppress ',' pmprintf_opt ',' ,
  31.    NO_REMOTE_CONFIG ',' custom_inits
  32.    
  33. loadthreshold=strip(loadthreshold) ; backupserverlist=strip(backupserverlist)
  34. delay_seconds=strip(delay_seconds) ; message_scramble=strip(message_scramble)
  35. record_cache_lines=strip(record_cache_lines)
  36. logon_limit=strip(logon_limit)
  37. pmprintf_opt=strip(pmprintf_opt)
  38. if pos(pmprintf_opt,'1 2 3')=0 then pmprintf_opt=1
  39. ssi_extensions=strip(ssi_extensions)
  40. ssi_cache_size=strip(ssi_cache_size)
  41. ssi_cache_duration=strip(ssi_cache_duration)
  42. ssi_cache_stamp=upper(strip(ssi_cache_stamp))
  43. save_state=strip(save_state)
  44. no_no_record=strip(no_no_record)
  45. IF WORDPOS(NO_REMOTE_CONFIG,'0 1 2')=0 THEN NO_REMOTE_CONFIG=0
  46. custom_inits=strip(custom_inits)
  47.  
  48.  
  49. /* pmprintf modiification? */
  50. foo=start_pmprintf(pmprintf_opt,pmprintf_line_length,pmprintf_log_file)
  51.  
  52. if datatype(logon_limit)<>'NUM' then logon_limit=0
  53. if datatype(delay_seconds)<>'NUM' then delay_Seconds=9
  54. if datatype(message_scramble)<>'NUM' then message_scramble=12415
  55.  
  56. if datatype(doanyway_loops)<>'NUM' then doanyway_loops=150
  57.  
  58.  
  59. if \RxFuncQuery("SockLoadFuncs") then nop
  60. else do
  61.        call RxFuncAdd "SockLoadFuncs","rxSock","SockLoadFuncs"
  62.        call SockLoadFuncs
  63. end
  64. foo=rxfuncquery('UZLoadFuncs')   /* load UNZIP dll */
  65. if foo=1 then do
  66.   call RxFuncAdd 'UZLoadFuncs', 'UNZIPAPI', 'UZLoadFuncs'
  67.   call UZLoadFuncs
  68. end
  69.  
  70. foo=rxfuncquery('UZLoadFuncs')   /* load UNZIP dll */
  71. if foo=1  then call pmprintf(' Warning: UNZIPAPI.DLL not found ')
  72.  
  73. if rxfuncquery('sref_fileread')<>0 then do
  74.   ik=rxfuncadd('sref_fileread','rexxlib','LIB_FILEREAD')
  75.   if ik<>0 then call pmprintf(' SRE-Filter Monitor: Warning: unable to register SREF_FILEREAD')
  76. end
  77.  
  78. if max_semwait="" then max_semwait=3000
  79. CALL  load_rxl(0)  /* load macrospace library */
  80.  
  81. IF result<0  then    do       /* fatal error if not found */
  82.   call pmprintf(' SRE-Filter monitor: ERROR: could not load macrospace library ')
  83.   EXIT
  84. end
  85.  
  86. doo=dostid()
  87. oo=dospid()||' '||dostid()
  88.  
  89. activecache.0=0
  90.  
  91. numeric digits 11
  92.  
  93. call pmprintf(" SRE-Filter Monitor: Initializing on port "|| serverport || ": " || filter_name)
  94. call pmprintf(" SRE-Filter monitor: Goserve pid ="|| goserve_pid' , monitor thread '||doo)
  95. call pmprintf(" SRE-Filter monitor: Using semaphore "|| thesem)
  96. parse upper version rexxtype .
  97. os2ver=sysos2ver()
  98. call pmprintf("SRE-Filter monitor: Using REXX version: " rexxtype ', under OS/2 ver 'os2ver)
  99.  
  100. /* cycle through list of custom_init routines */
  101. foo=call_custom_Inits(custom_Inits)
  102.  
  103. /* after this, use pmprintf_sref */
  104.  
  105. if record_cache_lines>0 then
  106.    call pmprintf_sref(" SRE-Filter monitor: Record cache file size= "||record_cache_lines)
  107.  
  108. init_file=servdir||"\INITFILT."||serverport
  109. filedate.initfilt=file_juldate(init_file)
  110. call get_initfilt(0)
  111. if result<0 then do
  112.           call pmprintf_sref(' SRE-Filter monitor: aborting due to initfilt error(s) ')
  113.           exit
  114. end
  115.  
  116.  
  117. call clear_temp(0)
  118.  
  119. if result<0  then do
  120.   call pmprintf_sref(" SRE-Filter fatal error : No INITFILT file ")
  121.   exit
  122. end
  123.  
  124. filedate.repstrgs=file_juldate(repstrgs_file)
  125. repsvars.0=0
  126.  
  127. call chk_repstrgs(0)
  128. foo= update_addons(0)
  129.  
  130. filedate.access=file_juldate(access_file)
  131. aa=start_access(0)
  132. filedate.alias=file_juldate(alias_file)
  133. aa=start_alias(0)
  134. filedate.user=file_juldate(user_file)
  135. aa=start_user(0)
  136. filedate.virtual=file_juldate(virtual_file)
  137. aa=start_virtual(0)
  138. aa=start_ssicache(0)
  139. aa=start_varstore(0)
  140.  
  141. aa=start_postf(0)
  142. aa=eventsem_create(thesem)
  143. if aa<0 then do
  144.  call pmprintf_sref(" SRE-Filter monitor: ERROR: could not create semaphore: "||thesem)
  145.  exit
  146. end
  147. foo=eventsem_post(thesem)       /* let the boys have it */
  148.  
  149. call pmprintf_sref(' SRE-Filter Monitor: Begin monitoring parameters files ..... ')
  150. nloops=0
  151. geelist="INITFILT REPSTRGS ALIAS ACCESS USER VIRTUAL "
  152. do forever
  153.   nloops=nloops+1
  154.    CALL load_rxl(1)
  155.    IF result<0 then do
  156.       call pmprintf_sref(' leaving after rxl error')
  157.       leave
  158.    end
  159.  
  160. /* get dates of current files  -- 0 if doesnt exist */
  161.    t1.initfilt=file_juldate(init_file)
  162.    t1.repstrgs=file_juldate(repstrgs_file)
  163.    t1.alias=file_juldate(alias_file)
  164.    t1.access=file_juldate(access_file)
  165.    t1.user=file_juldate(user_file)
  166.    t1.virtual=file_juldate(virtual_file)
  167.  
  168. /* any of them newer then last stored files */
  169.    redo=0
  170.    do mm=1 to words(geelist)
  171.        oo1=word(geelist,mm)
  172.        if t1.oo1 > filedate.oo1 then do
  173.            redo=1
  174.            filedate.oo1=t1.oo1
  175.         end
  176.    end
  177.  
  178.    if nloops>doanyway_loops then do         /* every 60 (or so) minutes, reset it anyways */
  179.         nloops=1                  /* just to be safe! */
  180.         redo=1
  181.    end
  182.    foo=value('SREF_REDO',,'os2environment')
  183.    if foo=1 then do 
  184.       redo=1
  185.       foo=value('SREF_FAST_REDO',1,'os2environment')  /* srefast shoud also redo */
  186.    end  /* Do */
  187.    foo=value('SREF_REDO',0,'os2environment')  /* reset to 0*/
  188.  
  189. /* one of three ways of being a redo? then reset */
  190.    if redo=1 then do            /* reset all stuff */
  191.  
  192.       call pmprintf_sref(" SRE-Filter resetting variables ")
  193.  
  194.       call get_initfilt(filedate.initfilt)
  195.       if result<0 then do
  196.           call pmprintf_sref(' SRE-Filter monitor: aborting due to initfilt error(s) ')
  197.           leave
  198.       end
  199.       call start_access(1)
  200.       call start_alias(1)
  201.       call start_user(1)
  202.  
  203.       call start_virtual(1)
  204.       call chk_repstrgs(0)
  205.  
  206.  
  207.       foo= update_addons(0)
  208.  
  209. /* store dates of just reset files (initfilt may have changed names */
  210.      filedate.access=file_juldate(access_file)
  211.      filedate.alias=file_juldate(alias_file)
  212.      filedate.user=file_juldate(user_file)
  213.      filedate.virtual=file_juldate(virtual_file)
  214.      filedate.repstrgs=file_juldate(repstrgs_file)
  215.      filedate.initfilt=file_juldate(init_file)
  216.      CALL pmprintf_sref(' SRE-Filter Monitor: Success resetting parameters ')
  217.     end
  218.  
  219. /* always check up on cached files (note that they may have
  220. changed if initfilt was updated */
  221.  
  222.     n=delay(delay_seconds)
  223.  
  224. /* get current env variables, perhaps write to pmprintf */
  225.    if display_env=1 & _no_set_check<>1 then do
  226.         a=rxqueue('s','session')
  227.        call pmprintf_sref(" Current SREF environment variables -----  ")
  228.         do queued(); pull .; end                   /* flush */
  229.         address cmd '@set | rxqueue'     /* execute the command */
  230.         do queued()
  231.            parse pull ares
  232.            iii=min(100,length(ares))
  233.            if abbrev(upper(ares),'SREF_')=1 then
  234.              call pmprintf_sref(left(ares,iii))
  235.         end
  236.        call pmprintf_sref(' --- end of sref environment variables ')
  237.        display_env=0
  238.    end
  239.  
  240.    ext1=extract('clients')
  241. /* note: small chance that this will delete a client's cgi-stuff that
  242. get's invoked just after the above extract('clients'). But, that just
  243. messes 1 client up, and it's so unlikely that it's not worth worrying about */
  244.    if redo=1 & ext1=0 & do_cleanup=1 then foo=clear_temp(1)
  245.  
  246. end  /* forever loop */
  247.  
  248.  
  249. exit
  250.  
  251. yipes:
  252. call pmprintf(" SRE-Filter monitor error at: " sigl', rc='rc )
  253. exit 'Error in SREFMON'
  254.  
  255. /* --------- END OF MAIN ---------------------------------------- */
  256.  
  257. /* ------------------------------------------------- */
  258. /* Routine to check, and load if neccessary,  SREFILTR.RXL into macrospace */
  259. /* ------------------------------------------------- */
  260.  
  261. load_rxl:
  262. nosref0=1
  263. signal on syntax name nosref
  264. signal on error name nosref
  265.  
  266. filter_name=sref_version()   /* if not here, then skip to nosref */
  267. nosref0=0
  268. nosref:         /* if skipped here, then load .rxl */
  269. signal off syntax ; signal off error
  270. signal on error name yipes ; signal on syntax name yipes ;
  271.  
  272.  
  273. if nosref0=1  then do
  274.    first_load=1
  275.  
  276.    parse upper version rexxtype .
  277.    if rexxtype="OBJREXX" then do
  278.         call pmprintf_sref(" SRE-Filter monitor: Loading SREFPRCO.RXL into macrospace ")
  279.         tt=servdir||'\SREFPRCO.RXL'
  280.    end
  281.    else do
  282.        call pmprintf(" SRE-Filter monitor: Loading SREFPRC1.RXL into macrospace ")
  283.        tt=servdir||'\SREFPRC1.RXL'
  284.    end
  285.    aa=macroload(tt)
  286.    if aa=0 then do
  287.       call pmprintf_sref(" SRE-Filter Monitor: ERROR: "|| tt ||" not available! "|| aa)
  288.       RETURN -1
  289.    end
  290.    filter_name=sref_version()
  291.    CALL pmprintf_sref(" SRE-Filter Monitor: Success on macrospace library load ")
  292. end
  293.  
  294. RETURN 1
  295.  
  296. /* ------------------------------------------------- */
  297. /* get date (fat and julian) of a file */
  298. /* ------------------------------------------------- */
  299.  
  300. file_juldate:procedure
  301.  
  302.  
  303. parse arg get_file , isquiet
  304. if GET_file=" " then return 0
  305.  
  306. eek=sysfiletree(translate(get_file,'\','/'),'gosh','FT')
  307. if gosh.0=0 then do  /* no file */
  308.    return 0
  309. end
  310. parse var gosh.1  atime .
  311. aa=sref_juldate('F',atime)
  312. return aa
  313.  
  314. /* ------------------------------------------------- */
  315. /* clear all $*.80 files out of tempdata_Dir */
  316. /* ------------------------------------------------- */
  317. clear_temp:
  318. parse arg cl1
  319.  
  320. if cl1<>1 then do               /* only do on startup */
  321.   lookstar=tempdata_dir||'\_DIRLIST.IDX'
  322.   foo=sysfiledelete(lookstar)
  323.  
  324.   lookstar=tempdata_dir||'\_*.DSH'         /* delete old directory cache files */
  325.   foo=sysfiletree(lookstar,stuff,'FO')
  326.   do mm=1 to stuff.0
  327.    foo=sysfiledelete(stuff.mm)
  328.   end /* do */
  329.   if stuff.0>0 then
  330.   call pmprintf_sref('SRE-Filter monitor: Deleted ' stuff.0 ' old directory cache files from: 'tempdata_dir)
  331.  
  332.   lookstar=tempdata_dir||'\_*.TMP'         /* delete old .TMP files */
  333.   foo=sysfiletree(lookstar,stuff,'FO')
  334.   do mm=1 to stuff.0
  335.     foo=sysfiledelete(stuff.mm)
  336.   end /* do */
  337.   if stuff.0>0 then
  338.     call pmprintf_sref('SRE-Filter monitor: Deleted ' stuff.0 ' _*.TMP files from: 'tempdata_dir)
  339.  
  340.   lookstar=strip(tempdata_dir||'\_T*.'||serverport)         /* delete old .TMP  files */
  341.   foo=sysfiletree(lookstar,stuff,'FO')
  342.   do mm=1 to stuff.0
  343.    foo=sysfiledelete(stuff.mm)
  344.   end /* do */
  345.   if stuff.0>0 then
  346.     call pmprintf_sref('SRE-Filter monitor: Deleted ' stuff.0 ' _T*.'serverport ' files from: 'tempdata_dir)
  347. end
  348.  
  349. /* do on startup, and on periodic cleanup */
  350. lookstar=tempdata_dir||'\~*.'||serverport         /* delete old cgi-bin temp files */
  351. foo=sysfiletree(lookstar,stuff,'FO')
  352. do mm=1 to stuff.0
  353.    foo=sysfiledelete(stuff.mm)
  354. end /* do */
  355. if stuff.0>0 then
  356.   call pmprintf_sref('SRE-Filter monitor: Deleted ' stuff.0 ' ~*.80 files from: 'tempdata_dir)
  357.  
  358. lookstar=tempdata_dir||'\$*.'||serverport         /* delete old cgi-bin temp files */
  359. foo=sysfiletree(lookstar,stuff,'FO')
  360. do mm=1 to stuff.0
  361.    foo=sysfiledelete(stuff.mm)
  362. end /* do */
  363. if stuff.0>0 then
  364.   call pmprintf_sref('SRE-Filter monitor: Deleted ' stuff.0 ' $*.80 files from: 'tempdata_dir)
  365.  
  366.  
  367. lookstar=strip(tempdata_dir||'\F*.cmd')         /* delete old .TMP  files */
  368. foo=sysfiletree(lookstar,stuff,'FO')
  369. do mm=1 to stuff.0
  370.    foo=sysfiledelete(stuff.mm)
  371. end /* do */
  372. if stuff.0>0 then
  373.   call pmprintf_sref('SRE-Filter monitor: Deleted ' stuff.0 ' F*.CMD  files from: 'tempdata_dir)
  374.  
  375.  
  376. return 0
  377.  
  378.  
  379.  
  380. /* ------------------------------------------------- */
  381. /* routine to load initfilt.nnn into macrospace
  382.    return 0= no change , 1= change,return<0=error */
  383. /* ------------------------------------------------- */
  384. get_initfilt:
  385.  
  386. get_file=init_file
  387. if get_file=" " then return 0
  388. oy=stream(get_file,'c','query exists')
  389. if oy=' ' then do
  390.    CALL pmprintf_sref("SRE-Filter monitor:FATAL ERROR. INITFILT file not found, "|| get_file)
  391.    exit 
  392. end
  393.  
  394. if _no_set_check<>1 then do
  395. /* get list of possible host variables */
  396. a=rxqueue('s','session')
  397. do queued(); pull .; end                   /* flush */
  398. nhs=0
  399. address cmd '@set | rxqueue'     /* execute the command */
  400. do queued()
  401.   parse pull ares0
  402.   if abbrev(upper(ares0),'SREF_')=1 then do
  403.       parse upper var ares0 ares '=' .
  404.       ibeam=lastpos('.',ares)
  405.       if ibeam>0 then do
  406.            cat3=substr(ares,ibeam+1)
  407.            if datatype(cat3)<>'NUM' then do
  408.               parse var ares . '_' . '_' ares1 '=' .
  409.               interpret ares1||'=" " '
  410. /*              call pmprintf_sref(' reset: ' ares1)*/
  411.            end          /* got a host entry */
  412.       end  /* got a . ed entry */
  413.    end     /* an sref entry */
  414. end     /* queued */
  415. end             /* _no_set_check */
  416.  
  417. call default_initfilt           /* default values */
  418.  
  419. ause=sref_fileread(get_file,'filelines',,'E')
  420. If (ause<=0) then  do               /*no such file,*/
  421.       CALL pmprintf_sref("SRE-Filter monitor: FATAL ERROR. INITFILT file unusable")
  422.       call pmprintf_sref('      File read: ' get_file)
  423.       call pmprintf_sref('      fileread response: 'ause)
  424.       call pmprintf_sref('      filelines.0:' filelines.0)
  425.       call pmprintf_sref('      filelines.1:' filelines.1)
  426.       argz=stream(get_file,'c','query size')
  427.       call pmprintf_sref('     Stream query size= ' argz)
  428.       exit
  429. end
  430.  
  431. /*Allow for gratuitous coding calamity by clumsy users */
  432.  
  433. mm=0 ; nerrs=0
  434.  
  435. iat1: nop
  436.  
  437. ok=0            /* assume an error */
  438. /* exit here when entire file read. Before exiting, cleanup and save results */
  439.  
  440. if mm>=filelines.0 then do
  441.    if nerrs>0 then do
  442.      signal off syntax ;   signal off error
  443.      signal on error name yipes ; signal on syntax name yipes ;
  444.      if  nerrs>0 then do
  445.         if verbose>0 then call pmprintf_sref(' SRE-Filter monitor:' nerrs ' errors in initfil.')
  446.          return  -nerrs               /* any error is fatal */
  447.       end  /* Do */
  448.    end
  449.    call initfilt_checkup
  450.  
  451.     call save_envstuff
  452.  
  453. /* check on status of counter files (create if necessary ) */
  454.    res1=sref_init_counter(counter_file, upload_log , record_all_file , record_option)
  455.    parse var res1 counter_file  upload_log  record_all_file  record_option
  456.    call value envadd||'COUNTER_FILE',counter_file,'os2environment'
  457.    call value envadd||'UPLOAD_LOG',upload_log,'os2environment'
  458.    call value envadd||'RECORD_OPTION',record_option,'os2environment'
  459.    call value envadd||'RECORD_ALL_FILE',record_all_file,'os2environment'
  460.  
  461.    call value envadd||'SERVERPORT',serverport,'os2environment'
  462.  
  463.    call pmprintf_sref(" SRE-Filter monitor: INITFILT file loaded, "||get_file)
  464.  
  465.    return 1
  466. end
  467.  
  468. mm=mm+1
  469. signal off syntax ;   signal off error
  470. signal on syntax name foobar1
  471. signal on error name foobar1
  472. filelines.mm=fix_me(filelines.mm)  /* convert from foo.host.n to foo.n.host */
  473.  
  474. goo=strip(filelines.mm)
  475. if goo="" | left(goo,1)=";" then  signal iat1
  476.  
  477. /* convert PUBLIC_FILES to PUBLC_URLS */
  478. if abbrev(upper(goo),'PUBLIC_FILES')=1 then
  479.    goo='PUBLIC_URLS'||delstr(goo,1,12)
  480.  
  481. /* convert PUBLIC_URL. to PUBLC_URLS. */
  482. if abbrev(upper(goo),'PUBLIC_URL.')=1 then
  483.    goo='PUBLIC_URLS'||delstr(goo,1,10)
  484.  
  485.  if abbrev(upper(goo),'SERVDIR')=1 then do
  486.      call pmprintf_sref(' Warning: INITFILT not allowed to change SERVDIR variable ')
  487.      nop /* don't let it be changed! */
  488.  end
  489.  else do
  490.     interpret goo
  491.  end
  492.  
  493. ok=1
  494.  
  495. foobar1:                /* here on error */
  496. if ok=0 then do
  497.    nerrs=nerrs+1
  498.    call pmprintf_sref(" !!! WARNING: SRE-Filter monitor: ERROR: in initfilt at ")
  499.    call pmprintf_sref("         "||goo)
  500. end
  501.  
  502.  
  503. signal iat1
  504.  
  505.  
  506. /* ---------------------------------------------- */
  507. /* Clean up parameters in initfilt */
  508. /* ---------------------------------------------- */
  509. initfilt_checkup:
  510.  
  511. checklog=STRIP(translate(checklog))
  512.   t1=wordpos(checklog,'NO YES ALWAYS INHOUSE')
  513.   if t1=0 then checklog='NO'
  514.  
  515. if auto_Name=0 then auto_name=" "
  516.    auto_name=translate(auto_name)
  517.  
  518.  
  519. /* include html for backward compataability */
  520. check_alias=is_true(check_alias,'Y YES 1 HTM HTML ')
  521.  
  522. accept_range=is_true(accept_range,'Y YES 1')
  523. no_include=is_true(no_include,'Y YES 1')
  524. no_interpret_code=is_true(no_interpret_code,'Y YES 1')
  525. no_processing=is_true(no_processing,'Y YES 1')
  526. use_stdout=is_true(use_stdout,'Y YES 1')
  527. do_send_piece=is_true(do_send_piece,'Y YES 1')
  528. add_user_name=is_true(add_user_name,'Y YES 1')
  529. add_resource_name=is_true(add_resource_name,'Y YES 1')
  530.  
  531. check_add_privs=is_true(check_add_privs,'Y YES 1')
  532.  
  533. if logon_fail_file=' '  then logon_fail_file=0
  534. if access_fail_file=' ' then access_fail_file=0
  535.  
  536. DEFAULT=STRIP(DEFAULT)
  537.    if default=' ' then default='INDEX.HTM'
  538.  
  539. /* check for existnce of varouse directories */
  540. mailbox_dir=translate(mailbox_dir,'\','/')
  541.    mailbox_dir=strip(mailbox_dir,'t','\')
  542. if dosisdir(mailbox_dir)=0 then do
  543.      call pmprintf_sref(' SRE-Filter monitor: Warning, could not find mailbox_dir: 'mailbox_dir)
  544.      mailbox_dir=""
  545. end  /* Do */
  546.  
  547. messbox_dir=translate(messbox_dir,'\','/')
  548.    messbox_dir=strip(messbox_dir,'t','\')
  549. if dosisdir(messbox_dir)=0 then do
  550.      call pmprintf_sref(' SRE-Filter monitor: Warning, could not find messbox_dir: 'messbox_dir)
  551.      messbox_dir=""
  552. end  /* Do */
  553.  
  554. config_dir=translate(config_dir,'\','/')
  555.    config_dir=strip(config_dir,'t','\')
  556. if dosisdir(config_dir)=0 then do
  557.      call pmprintf_sref(' SRE-Filter monitor: Warning, could not find config_dir: 'config_dir)
  558.      config_dir=datadir()
  559. end  /* Do */
  560.  
  561.  
  562. workdata_dir=translate(workdata_dir,'\','/')
  563.    workdata_dir=strip(workdata_dir,'t','\')
  564. if dosisdir(workdata_dir)=0 then do
  565.      call pmprintf_sref(' SRE-Filter monitor: Warning, could not find workdata_dir: 'workdata_dir)
  566.      workdata_dir=servdir
  567. end
  568.  
  569. tempdata_dir=translate(tempdata_dir,'\','/')
  570.    tempdata_dir=strip(tempdata_dir,'t','\')
  571. if dosisdir(tempdata_dir)=0 then do
  572.      call pmprintf_sref(' SRE-Filter monitor: Warning, could not find tempdata_dir: 'tempdata_dir)
  573.      tempdata_dir=datadir()
  574.  
  575. end
  576.  
  577. tempfile_dir=translate(tempfile_dir,'\','/')
  578.    tempfile_dir=strip(tempfile_dir,'t','\')
  579. if dosisdir(tempfile_dir)=0 then do
  580.      call pmprintf_sref(' SRE-Filter monitor: Warning, could not find tempfile_dir: 'tempfile_dir)
  581.      tempfile_dir=servdir
  582. end
  583.  
  584. cgi_bin_dir=translate(cgi_bin_dir,'\','/')
  585.    cgi_bin_dir=strip(cgi_bin_dir,'t','\')
  586.    if cgi_bin_dir="" then cgi_bin_dir=0
  587. if dosisdir(cgi_bin_dir)=0 then do
  588.      call pmprintf_sref(' SRE-Filter monitor: Warning, could not find cgi-bin-dir: 'cgi_bin_dir)
  589.      cgi_bin_dir=' '
  590. end  /* Do */
  591.  
  592.  
  593. addon_dir=translate(addon_dir,'\','/')
  594.    addon_dir=strip(addon_dir,'t','\')
  595.    if addon_dir="" then addon_dir=0
  596. if dosisdir(addon_dir)=0 then do
  597.      call pmprintf_sref(' SRE-Filter monitor: Warning, could not find addon-dir, 'addon_dir ', using : 'servdir)
  598.      addon_dir=servdir
  599. end  /* Do */
  600.  
  601.  
  602. /* chek other stuff */
  603.  
  604. HOME_DIR=STRIP(HOME_DIR)
  605. inhouse_privs=translate(inhouse_privs)
  606.    if inhouse_privs=0 then inhouse_privs=" "
  607. public_privs=translate(public_privs)
  608.    if public_privs=0 then public_privs=" "
  609.  
  610. virtual_file=strip(virtual_file)
  611.  
  612. ALLOW_ACCESS=TRANSLATE(STRIP(ALLOW_ACCESS))
  613. if allow_access="Y" | allow_access=1 then allow_access="YES"
  614.  
  615. do_Htaccess=is_true(do_htaccess,'Y YES 1')
  616.  
  617.  
  618. ssi_cache_on=is_true(ssi_cache_on,'Y YES 1 ')
  619.  
  620. ssi_shtml_only=is_true(ssi_shtml_only,'Y YES 1')
  621. DNS_CHECK=translate(dns_check)
  622. if upload_log="" then upload_log=0
  623. if datatype(upload_maxsize)<>'NUM' then
  624.     upload_maxsize=50
  625. if datatype(upload_minfree)<>'NUM' then
  626.     upload_minfree=20000
  627.  
  628. if datatype(ssi_cache_size)<>'NUM' then
  629.    ssi_cache_size=5000
  630.  
  631. if datatype(ssi_cache_duration)<>'NUM' then ssi_cache_duration=1
  632. if ssi_cache_duration=0 then ssi_cache_duration=1000000 /* infiinte*/
  633.  
  634. if wordpos(ssi_cache_stamp,'TIME DATE TIMEDATE DATETIME SIZE ALL')=0 then
  635.    ssi_cache_stamp='ALL'
  636.  
  637.  
  638. pre_filter=translate(pre_filter)
  639. post_filter=is_true(post_filter,'Y YES 1')
  640.  
  641. if smtp_gateway=" " then smtp_gateway=0
  642.  
  643. hit_owner_suppress=is_true(hit_owner_suppress,'Y YES 1')
  644. hit_superuser_suppress=is_true(hit_superuser_suppress,'Y YES 1')
  645.  
  646. write_logs=is_true(write_logs,'Y YES 1')
  647.  
  648. if upper(hit_cache_len)="FILE" then do
  649.    nop
  650. end  /* Do */
  651.  
  652. else do
  653.   if datatype(hit_cache_len)<>'NUM' then do 
  654.      hit_cache_len=0
  655.   end
  656.   else do
  657.     hit_cache_len=min(hit_cache_len,50)  /* 50 k max */
  658.   end  /* Do */
  659. end
  660.  
  661. if datatype(hit_cache_DURATION)<>'NUM' then do
  662.      hit_cache_DURATION=15
  663. END
  664. ELSE DO
  665.    HIT_cache_DURATION=MAX(1,HIT_cache_DURATION)
  666. end  /* Do */
  667.  
  668.  
  669. if the_realm=0 then do
  670.   if  symbol('inhouse_name')<>"VAR"  then
  671.         the_realm=inhouse_name
  672.   else
  673.        the_realm="OUR WEB SITE"           /* name we call "ourselves" */
  674. end
  675.  
  676.  
  677. RECORD_OPTION=TRANSLATE(RECORD_OPTION)
  678. if wordpos(record_option,'YES YES_ALL FILE ')=0 then
  679.      record_option="NO"              /* recording option on?*/
  680.  
  681. gots=0
  682.  
  683. hosts.0=0
  684. do m=1 to 100000
  685.    if symbol('hosts.m')<>"VAR" then leave
  686.    if hosts.m=0 then leave
  687.    hosts.0=m
  688. end /* do */
  689.  
  690.  
  691. ralphie=cvtails('DELIM_1',dlist)
  692.  
  693. delims=0
  694. do m=1 to ralphie
  695.  
  696.    a1=dlist.m
  697.    a2=translate(a1,' ','.')
  698.    if words(a2)=1 then do
  699.         if datatype(a1)='NUM' then do
  700.            tmp1=DELIM_1.a1
  701.            if tmp1='0' then iterate
  702.            delims=max(delims,a1)
  703.         end  /* Do */
  704.     end  /* Do */
  705.    if words(a2)=2 then do
  706.         if datatype(word(a2,1))='NUM' then do
  707.            ahost=word(a2,2)
  708.            tmp1=DELIM_1.a1
  709.            if tmp1='0' then iterate
  710.            if symbol('DELIMS.'||ahost)='VAR' then
  711.                 delims.ahost=max(delims.ahost,word(a2,1))
  712.            else
  713.                 delims.ahost=word(a2,1)
  714.         end  /* Do */
  715.     end  /* Do */
  716. end
  717.  
  718.  
  719.  
  720. crlf='0d0a'x
  721. FPO=MAKE_HEAD_FOOT()
  722.  
  723. /* creates HEADERS FOOTERS HEADERS. FOOTERS. HEADLIST. FOOTLIST. NHEADS NFOOTS */
  724.  
  725. auto_header=upper(auto_header)
  726.  
  727. /* check for "send in pieces "  --no fix_expire,  no 2nd delimiter
  728.    NOW DONE IN SSI routine
  729. if delims=1 &  fix_expire=0  & do_Send_piece=1 then
  730.    send_piece=1
  731. else
  732.   send_piece=0
  733. */
  734.  
  735. suppress_alias=0 ; suppress_virtual=0 ; suppress_access=0
  736. suppress_user=0 ; check_doq=0
  737. if (alias_file=" " | alias_file=0)  then
  738.         suppress_alias=1
  739. if virtual_file=" " | virtual_file=0 then
  740.         suppress_virtual=1
  741. if (user_file=" " | user_file=0 ) then
  742.         suppress_user=1
  743. if access_file=" "| access_file=0  then
  744.         suppress_access=1
  745. /*say suppress_alias suppress_user suppress_access suppress_virtual*/
  746.  
  747. if (suppress_alias+suppress_user+suppress_access+suppress_virtual)>0 then
  748.    check_doq=1
  749.  
  750. return 0
  751.  
  752.  
  753. /* ------------------------------------------------- */
  754. /* routine to set default initfilt.80  */
  755. /* ------------------------------------------------- */
  756. default_initfilt:
  757.  
  758. /* variables that can be changed by configure */
  759.  
  760. display_env=0
  761. checklog='NO'           /* Free entry */
  762. the_realm=0           /* name we call "ourselves" , 0 will be replaced generically*/
  763. home_name=" "              /* The colloquial (not necessrily ip) domain name */
  764. auto_header="NO"        /* no, always, head */
  765. AUTO_NAME=0         /* 0=none, or a list with *.HTM, !CREATE, file.nam */
  766. CHECK_alias="YES"   /* : YES=yes, NO=None, HTML=.HTM (or .HTML)  */
  767. not_found_url='<a href="/"> Visit the home_name home page? </a> '   /* Message that is sent with no such url  */
  768. pre_filter="NO"         /* no  yes first */
  769. post_filter="NO"
  770. noext_type="HTM"  /* NONE DIR HTM or HTML REDIR */
  771. record_option="NO"   /* YES, YES_ALL */
  772. allow_access="YES"  /* access control on file transfers (YES=none) */
  773. default='index.htm'     /* use if default home page selected */
  774. add_privs_prefix='!'
  775. hosts.1=0               /* list of alternatme hosts */
  776. inhouse_privs=" INHOUSE "    /* additional privs for inhouseips and owners */
  777. public_privs=" PUBLIC "    /* additional privs for veryone */
  778. inhouse.1=" (INHOUSE User) "   /* Used with REPLACE:INHOUSE1, etc. */
  779. suPEruser.1="(Super User)"
  780. headers.1=0  /* stuff to put at beginning / end of */
  781. footers.1=0  /* all htm documents. 0= nothing */
  782. OPTION_hit_line=":: still access # "
  783. webmaster=' (no contact available) '
  784. owners   = 'none'  /* Owners are automatically superusers (seperate with spaces) */
  785. inhouse_privs="INHOUSE"
  786. public_privs="PUBLIC"
  787. smtp_gateway=" "    /* smtp_gateway, used by post-filter "e-mail alert" facility */
  788.  
  789. /* Directories and files */
  790.  
  791. cgi_bin_dir="\goserv\cgi-bin"                   /* if 0, do not emulate cgi-bin */
  792. addon_dir="\goserv\addons"                   /* if 0, do not emulate cgi-bin */
  793.  
  794. messbox_dir="\GOSERV\MESSAGE"                        /* SRE-Filter data */
  795. maibox_dir="\GOSERV\MAIL"
  796. upload_dir="\GOSERV\UPLOAD"
  797. config_dir='\GOSERV\CONFIGS'
  798. tempfile_dir="\gohttp\temp"
  799. tempdata_dir="\goserv\temp"
  800. home_dir="\gohttp\home"
  801. workdata_dir="\GOSERV\DATA";
  802.  
  803. counter_file="\GOSERV\data\COUNTER.CNT"
  804. record_all_file="\GOSERV\DATA\RECRDALL.CNT"
  805. sendfile_file="\GOSERV\DATA\SENDFILE.CTL"
  806.  
  807. logon_fail_file=0
  808. access_fail_file=0
  809.  
  810. htaccess_file=0
  811. do_htaccess=0
  812.  
  813. access_file="\GOSERV\DATA\ALL_FILE.CTL"
  814. accept_range="NO"
  815. check_add_privs='NO'
  816. use_stdout="YES"
  817. add_user_name='YES'
  818. add_resource_name='NO'
  819. virtual_file="\GOSERV\data\VIRTUAL.IN"
  820. user_file="\GOSERV\data\USERS.IN"
  821. interpret_file="\GOSERV\data\INTERPET.IN"
  822.  
  823. repstrgs_file="\GOSERV\data\REPSTRGS.IN"
  824. alias_file="\GOSERV\data\ALIASES.IN"
  825. upload_log="\GOSERV\DATA\UPLOAD.LOG"
  826.  
  827. /* variables not changed by configure */
  828. max_pointdist=50     /* max distance acceptable for a "assign to point" in ncsa map */
  829. ssi_shtml_only='NO'    /* yes no, ssi on .sht or .shtml only */
  830. ssi_cache_on='YES'    /* use ssi-caching (no, yes) */
  831.  
  832. fix_expire=0    /* set to non zero to redo response headers */
  833. do_send_piece='NO' /* yes to allow "send in pieces",no to disallow */
  834. no_include="NO"   /* yes no , disallow all ssi */
  835. no_processing="NO"   /* if yes, then no server side processing allowed */
  836. no_interpret_code='NO'
  837. delim_1.1='<!--'     /* the left and right side "keyphrase" delimeters */
  838. delim_2.1='-->'      /* can be any string combo */
  839. upload_maxsize=50             /* max size that a uploaded file can be, in k */
  840. upload_minfree=20000        /* minimum free in K, in dowload_dir, AFTER file upload */
  841. postfilter_name="POSTFILT"
  842. prefilter_name="PREFILTR"
  843.  
  844. interpret_types=' PL=PERL5 '  /* used by CGI-BIN to invoke alternate interpeters */
  845.  
  846. dir_exclusion='HTACCESS. /PRIVATE *.CNT '
  847. DIR_OPTIONS='  notime auto_describe describe=describe.txt no_recurse_dir  '
  848. dir_access=' PRIVATE/* SYSTEM* '
  849. dir_access_privs='SUPERUSER '
  850.  
  851.  
  852. check_doq=0
  853. verbose=1
  854.  
  855. hit_cache_len=0        /* not on (otherwise, # of k) */
  856. hit_cache_duration=15     /* # of minutes */
  857. hit_cache=' '
  858. hit_owner_suppress='YES'
  859. write_logs='YES'
  860.  
  861.  
  862. return 0
  863.  
  864.  
  865. /* ----------------------------- */
  866. /* save some initfilt varibles to the environment */
  867. /* ----------------------------- */
  868. save_envstuff:
  869.  
  870. ALIST='CHECKLOG AUTO_HEADER DO_SEND_PIECE VERBOSE DNS_CHECK ALLOW_ACCESS '
  871. do mm=1 to words(alist)
  872.   call save_em(word(alist,mm))
  873. end
  874.  
  875.  
  876. call value enVadd||'SUPPRESS_ALIAS',suppress_alias,'os2environment'
  877. call value enVadd||'suppress_virtual',suppress_virtual,'os2environment'
  878. call value enVadd||'suppress_access',suppress_access,'os2environment'
  879. call value enVadd||'suppress_user',suppress_user,'os2environment'
  880. call value enVadd||'CHECK_DOQ',CHECK_DOQ,'os2environment'
  881. call value enVadd||'LOADTHRESHOLD',loadthreshold,'os2environment'
  882. call value enVadd||'BACKUPSERVERLIST',backupserverlist,'os2environment'
  883. call value enVadd||'SAVE_STATE',save_state,'os2environment'
  884. call value enVadd||'NO_NO_RECORD',no_no_record,'os2environment'
  885. call value enVadd||'MESSAGE_SCRAMBLE',MESSAGE_SCRAMBLE,'os2environment'
  886. CALL VALUE 'SREF_NO_REMOTE_CONFIG',NO_REMOTE_CONFIG,'OS2ENVIRONMENT'
  887. call value enVadd||'SSI_EXTENSIONS',ssi_extensions,'os2environment'
  888.  
  889.  
  890. ALIST='AUTO_NAME DEFAULT CHECK_ALIAS NOEXT_TYPE ADD_PRIVS_PREFIX INTERPRET_TYPES DIR_OPTIONS DIR_EXCLUSION DIR_ACCESS DIR_ACCESS_PRIVS'
  891. do mm=1 to words(alist)
  892.   call save_em(word(alist,mm))
  893. end
  894.  
  895. ALIST='PRE_FILTER PREFILTER_NAME POST_FILTER POSTFILTER_NAME  '
  896. do mm=1 to words(alist)
  897.   call save_em(word(alist,mm))
  898. end
  899.  
  900. call value envadd||'HEADERS',headers,'os2environment'
  901. call value envadd||'FOOTERS',footers,'os2environment'
  902.  
  903. do mm=1 to nheads
  904.    foo=strip(headlist.mm)
  905.    aval0=aheaders.foo
  906.    tty=strip(envadd||'HEADERS.'||foo)
  907.    call value tty,aval0,'os2environment'
  908. end /* do */
  909. do mm=1 to nfoots
  910.    foo=strip(footlist.mm)
  911.    aval0=afooters.foo
  912.    call value envadd||'FOOTERS.'||foo,aval0,'os2environment'
  913. end /* do */
  914.  
  915. alist='THE_REALM HOME_NAME NOT_FOUND_URL PUBLIC_PRIVS INHOUSE_PRIVS OPTION_HIT_LINE LOGON_FAIL_FILE ACCESS_FAIL_FILE'
  916. do mm=1 to words(alist)
  917.   call save_em(word(alist,mm))
  918. end
  919.  
  920. alist='WEBMASTER OWNERS SMTP_GATEWAY ACCEPT_RANGE USE_STDOUT ADD_USER_NAME ADD_RESOURCE_NAME '
  921. do mm=1 to words(alist)
  922.   call save_em(word(alist,mm))
  923. end
  924.  
  925.  
  926. call value envadd||'HOSTS.0',hosts.0,'os2environment'
  927.  
  928. ALIST='MAX_POINTDIST NO_INCLUDE NO_INTERPRET_CODE NO_PROCESSING FIX_EXPIRE SSI_SHTML_ONLY CHECK_ADD_PRIVS SSI_CACHE_ON '
  929. do mm=1 to words(alist)
  930.   call save_em(word(alist,mm))
  931. end
  932.  
  933. 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 '
  934. do mm=1 to words(alist)
  935.   call save_em(word(alist,mm))
  936. end
  937.  
  938. call value envadd||'cgi_bin_dir',cgi_bin_dir,'os2environment'
  939. call value envadd||'addon_dir',addon_dir,'os2environment'
  940.  
  941. tempfile_dir=upper(strip(tempfile_dir))
  942. call value envadd||'tempfile_dir',tempfile_dir,'os2environment'
  943.  
  944. tempdata_dir=upper(strip(tempdata_dir))
  945. call value envadd||'tempdata_dir',tempdata_dir,'os2environment'
  946.  
  947. upload_dir=upper(strip(upload_dir))
  948. call value envadd||'upload_dir',upload_dir,'os2environment'
  949.  
  950. messbox_dir=upper(strip(messbox_dir))
  951. call value envadd||'messbox_dir',messbox_dir,'os2environment'
  952.  
  953. config_dir=upper(strip(config_dir))
  954. call value envadd||'config_dir',config_dir,'os2environment'
  955.  
  956.  
  957. workdata_dir=upper(strip(workdata_dir))
  958. call value envadd||'workdata_dir',workdata_dir,'os2environment'
  959.  
  960.  
  961. mailbox_dir=upper(strip(mailbox_dir))
  962. call value envadd||'mailbox_dir',mailbox_dir,'os2environment'
  963.  
  964.  
  965. call value envadd||'SERVDIR',servdir,'os2environment'
  966.  
  967. call value envadd||'INITFILT_FILE',INIT_file,'os2environment'
  968. call value envadd||'USER_FILE',user_file,'os2environment'
  969. call value envadd||'ACCESS_FILE',access_file,'os2environment'
  970. call value envadd||'VIRTUAL_FILE',virtual_file,'os2environment'
  971. call value envadd||'ALIAS_FILE',alias_file,'os2environment'
  972. call value envadd||'REPSTRGS_FILE',repstrgs_file,'os2environment'
  973.  
  974. call value envadd||'INTERPRET_FILE',interpret_file,'os2environment'
  975. call value envadd||'SENDFILE_FILE',sendfile_file,'os2environment'
  976.  
  977. call value envadd||'HTACCESS_FILE',htaccess_file,'os2environment'
  978. call value envadd||'DO_HTACCESS',DO_htaccess,'os2environment'
  979.  
  980. /* determine # of public_urls (non host specific) -- used by srefquik.80 */
  981. /* and while we are at it, fix 'em up */
  982. aa='public_urls.'
  983. nin=0
  984. do mm=1 to 10000
  985.       moe=aa||mm
  986.       if upper(symbol(moe))<>"VAR" then leave
  987.       interpret 'tt='||moe
  988.       if tt="" | tt=0 then  leave
  989.       nin=nin+1
  990. end
  991. public_urls.0=nin
  992.  
  993. /*call save_em('public_urls.')*/
  994.  
  995. /* IP_address,  host_nickname,  default_directory */
  996. call pmprintf_sref('SRE-Filter monitor: looking up '||hosts.0||' HOST IP addresses')
  997. do m=1 to hosts.0
  998.    aah=upper(hosts.m)
  999.    aah=translate(aah,' ',',')
  1000.    parse upper var aah  sname  hn  adir
  1001.    SNAME=STRIP(SNAME)
  1002.  
  1003.    hn=upper(hn)
  1004.    adir=translate(strip(adir),'\','/'); adir=strip(adir,'t','\')||'\'
  1005.  
  1006. /* create ip number lookup table */
  1007.     isnumip=verify(SNAME,'1234567890.')
  1008.     if isnumip=0 then         /* is numeric ip */
  1009.            astat=sockgethostbyaddr(sname,'stuff.!')
  1010.     else
  1011.           astat=sockgethostbyname(sname,'stuff.!')
  1012.  
  1013. /* create HOST.n and HOSTS_IP.n :
  1014.    HOST.N will contain  ip_name , host_nickname, default dir
  1015.         where ip_name is the name supplied in the HOSTS. variable,
  1016.         OR, if a numeric ip address was supplied, the name associated
  1017.             with the numeric  ip address ( a socket call is made)
  1018.         BUT, if no name can be found for this IP address, the IP address
  1019.              is used
  1020.    HOSTS_IP  is a simple lookup table -- it's computed here to avoid
  1021.              lengthy socket calls.  The structure should be:
  1022.                 numeric_ip_address ip_name
  1023.              If a name is give, the address is looked up,
  1024.              if a numeric address is given, the name is looked up
  1025.              If no address can be found for a name, the entry is left
  1026.              blank.  Similarly, it a name can not be found for a
  1027.             numeric address, the entry is left blank.
  1028.             In other words: both have to exist, else a blank entry is used.
  1029. */
  1030.  
  1031. /* save basic name and ip */
  1032.     if astat=1  then do
  1033.            booz=stuff.!addr||' '||upper(stuff.!name)
  1034.            if isnumip=0 then
  1035.                name1=strip(upper(stuff.!name))
  1036.            else
  1037.                 name1=strip(upper(sname))
  1038.     end
  1039.     else do
  1040.            booz=' '
  1041.            name1=sname
  1042.    end
  1043.    call value envadd||'HOSTS_IP.'||m,booz,'os2environment'
  1044.    aah=name1||','||hn||','||adir
  1045.    call value envadd||'HOSTS.'||m,aah,'os2environment'
  1046. end /* do  HOSTS */
  1047.  
  1048. call save_em('inhouseips.')
  1049. do m=1 to plist.0            /* fix and save INHOUSEIPS */
  1050.   t1=plist.m
  1051.   anval=inhouseips.t1
  1052.   w1=word(anval,1)   /* look for host nickname */
  1053.   if right(w1,2)='//' then do
  1054.        geti=2
  1055.   end
  1056.   else do
  1057.      geti=1
  1058.   end
  1059.   call value envadd||'inhouseips.'||t1,anval,'os2environment'
  1060. end
  1061.  
  1062. call save_em('unallowedips.')
  1063. do m=1 to plist.0            /* fix and save unallowedIPS */
  1064.   t1=plist.m
  1065.   anval=unallowedips.t1
  1066.   w1=word(anval,1)   /* look for host nickname */
  1067.   if right(w1,2)='//' then do
  1068.        geti=2
  1069.   end
  1070.   else do
  1071.      geti=1
  1072.   end
  1073.   if verify(word(anval,geti),'1234567890.')<>0 then do  /* convert numeric ip */
  1074.       astat=sockgethostbyname(word(anval,geti),'stuff.!')
  1075.       if astat=1 then do
  1076.            if geti=1 then do
  1077.               parse var anval vv anval
  1078.               anval=stuff.!addr||' '||anval
  1079.             end
  1080.             else do
  1081.                parse var anval vv1 vv2  anval
  1082.                anval=vv1||' '||stuff.!addr||' '||anval
  1083.             end  /* Do */
  1084.       end  /* Do */
  1085.   end
  1086.   call value envadd||'unallowedips.'||t1,anval,'os2environment'
  1087. end
  1088.  
  1089. do m=1 to delims
  1090.   if symbol('DELIM_1.'||m)<>'VAR' then iterate
  1091.   call value envadd||'DELIM_1.'||m,delim_1.m,'os2environment'
  1092.   if symbol('DELIM_2.'||m)<>'VAR' then iterate
  1093.   call value envadd||'DELIM_2.'||m,delim_2.m,'os2environment'
  1094. end
  1095. call value envadd||'DELIMS',delims,'os2environment'
  1096.  
  1097. ralphie=cvtails('DELIMS',dlist)
  1098. do mm=1 to ralphie
  1099.    booboo=dlist.mm
  1100.    call value envadd||'DELIMS.'||booboo,delims.booboo,'os2environment'
  1101.    do m=1 to delims.booboo
  1102.     if symbol('DELIM_1.'||m||'.'||booboo)<>'VAR' then iterate
  1103.      call value envadd||'DELIM_1.'||m||'.'||booboo,delim_1.m.booboo,'os2environment'
  1104.     if symbol('DELIM_2.'||m||'.'||booboo)<>'VAR' then iterate
  1105.      call value envadd||'DELIM_2.'||m||'.'||booboo,delim_2.m.booboo,'os2environment'
  1106.    end
  1107. end /* do */
  1108.  
  1109.  
  1110. /* fix up public_urls */
  1111. num_public_Urls=cvtails(PUBLIC_URLS,foo1)
  1112. if num_public_urls>0 then do    /* clean em up */
  1113.    do mm=1 to num_public_urls
  1114.       tl1=foo1.mm
  1115.       vl=public_urls.tl1
  1116.       if pos('?',vl)>1 then do
  1117.           parse var vl vla '?' vlb
  1118.           vla=strip(translate(vla,'/','\'))
  1119.           if length(vla)>0 then 
  1120.               if  abbrev(vla,'/')=1 then vla=substr(vla,2)
  1121.           v1=vla||'?'||vlb
  1122.       end
  1123.       else do
  1124.           vl=strip(translate(vl,'/','\'))
  1125.           if length(vl)>0 then 
  1126.               if  abbrev(vl,'/')=1 then vl=substr(vl,2)
  1127.       end  /* Do */
  1128.       public_urls.tl1=vl
  1129.    end /* do */
  1130. end  /* Do */
  1131. call save_em('public_urls.')
  1132.  
  1133. call save_em('NUM_PUBLIC_URLS')
  1134. call pmprintf_sref(' #  of public urls = 'num_public_Urls)
  1135.  
  1136. CALL SAVE_EM('SUPERUSER')
  1137. CALL SAVE_EM('INHOUSE')
  1138.  
  1139. call pmprintf_sref(' SRE-Filter monitor: number of hosts= 'hosts.0 )
  1140. return 0
  1141.  
  1142.  
  1143. /* ----------------------------------------------------------------------- */
  1144. /* --  copy repstrgs file to environment */
  1145. /* ----------------------------------------------------------------------- */
  1146.  
  1147. chk_repstrgs:
  1148. parse arg resetit
  1149.  
  1150. if repstrgs_file=" " then
  1151.   return 0
  1152. oy=stream(repstrgs_file,'c','query exists')
  1153. if oy="" then do
  1154.    CALL pmprintf_sref("SRE-Filter monitor: Replacement strings file not found, "|| get_file)
  1155.    return -1
  1156. end
  1157.  
  1158. /* yep, reinitialize repstrgs file (set semaphore first */
  1159. ause=sref_fileread(repstrgs_file,'filelines',,'E')
  1160. If (ause<=0) then  do               /*no such file,*/
  1161.       CALL pmprintf_sref("SRE-Filter monitor: error " ause " when reading replacement strings file, "|| repstrgs_file)
  1162.       return -1
  1163. end
  1164.  
  1165. crlf='0d0a'x
  1166. j=0
  1167. /* zap current list of repstrings variables */
  1168. do rr=1 to repsvars.0
  1169.   call value repsvars.rr,' ','os2environment'
  1170. end
  1171. repsvars.0=0
  1172. do mm=1 to filelines.0
  1173.   goo=strip(filelines.mm)
  1174.   if goo="" | left(goo,1)=";" then  iterate
  1175.  
  1176.   parse var goo aname avalue
  1177.   aname=envadd||upper(aname)
  1178.   t1=value(aname,,'os2environment')
  1179.   if t1=' ' then do
  1180.       t1=avalue
  1181.       j=j+1
  1182.       repsvars.j=aname
  1183.       repsvars.0=j
  1184.   end
  1185.   else do
  1186.         t1=t1||crlf||avalue
  1187.   end
  1188.   call value aname,t1,'os2environment'
  1189. end
  1190. call pmprintf_sref(' SRE-Filter Monitor: loaded replacements strings: 'j)
  1191. return j
  1192.  
  1193.  
  1194. /* ----------------------------------------------------------------------- */
  1195. /* -- See if a "generic" YES answer. If so, return 1 */
  1196. /* ----------------------------------------------------------------------- */
  1197. is_true:procedure
  1198. parse upper arg ans,anslist
  1199. if wordpos(ans,anslist)>0 then
  1200.  return 1
  1201. else
  1202.  return 0
  1203.  
  1204.  
  1205.  
  1206. /*=========     Start various threads   ===================== */
  1207.  
  1208.  
  1209. /* ------------------------------------------------------------ */
  1210. /* start access processor thread */
  1211. start_access:
  1212. parse arg resetit
  1213.  
  1214. if access_file= ' ' | SUPPRESS_ACCESS=1 then
  1215.       return 0
  1216. oy=stream(access_file,'c','query exists')
  1217. if oy="" then do
  1218.    CALL pmprintf_sref("SRE-Filter monitor: access file not found, "|| access_file)
  1219.    access_file=' '
  1220.    return -1
  1221. end
  1222.  
  1223. arxx=servdir||'\acceschk.rxx'
  1224. usequeue='SREF_'||serverport||'_ACCESS'
  1225. usesem='\SEM32\SREF_'||serverport||'_ACCESS'
  1226.  
  1227. if resetit=1 then do            /* already opened --just send a *RESET* */
  1228.    a=rxqueue('s',usequeue)
  1229.    push '1, 1, 2, *RESET* ' access_file
  1230.    return 1
  1231. end
  1232.  
  1233. /* if here, first time */
  1234.  
  1235. a=rxqueue('d',usequeue)
  1236. a=rxqueue('c',usequeue)
  1237. if a<>usequeue then do
  1238.   bb=rxqueue('d','a')
  1239.   a=rxqueue('s',usequeue)
  1240.   do queued()
  1241.        pull
  1242.   end /* do */
  1243. end
  1244.  
  1245. a=eventsem_close(usesem)
  1246. A=EVENTSEM_CREATE(USESEM)
  1247. IF A<>0 then DO
  1248.     call pmprintf_sref(' SRE-Filter monitor: Error creating access semaphore: 'A' 'usesem)
  1249.     access_file=' '
  1250.     return -1
  1251. end
  1252. access_tid=rexxthread('f',arxx,access_file,usequeue,USESEM,max_semwait)
  1253. if access_tid=0 then do
  1254.    call pmprintf_sref(' SRE-Filter monitor: Could not open access thread 'arxx)
  1255.     access_file=' '
  1256.    return -1
  1257. end
  1258.  
  1259. return 1
  1260.  
  1261. /* ---------------- */
  1262. /* start alias processor thread */
  1263. start_alias:
  1264. parse arg resetit
  1265.  
  1266. if alias_file= ' ' | SUPPRESS_ALIAS=1 then
  1267.       return 0
  1268. oy=stream(alias_file,'c','query exists')
  1269.  
  1270. if oy="" then do
  1271.    CALL pmprintf_sref("SRE-Filter monitor: alias file not found, "|| alias_file)
  1272.    alias_file=' '
  1273.    return -1
  1274. end
  1275.  
  1276. arxx=servdir||'\aliaschk.rxx'
  1277. usequeue='SREF_'||serverport||'_ALIAS'
  1278. usesem='\SEM32\SREF_'||serverport||'_ALIAS'
  1279.  
  1280. if resetit=1 then do            /* already opened --just send a *RESET* */
  1281.    a=rxqueue('s',usequeue)
  1282.    push '1,1,2,*RESET* ' alias_file
  1283.    foo=eventsem_post(usesem)
  1284.    return 1
  1285. end
  1286.  
  1287. /* if here, first time */
  1288.  
  1289. a=rxqueue('d',usequeue)
  1290. a=rxqueue('c',usequeue)
  1291. if a<>usequeue then do
  1292.   bb=rxqueue('d','a')
  1293.   a=rxqueue('s',usequeue)
  1294.   do queued()
  1295.        pull
  1296.   end /* do */
  1297. end
  1298.  
  1299. a=eventsem_close(usesem)
  1300. A=EVENTSEM_CREATE(USESEM)
  1301. IF A<>0 then DO
  1302.     call pmprintf_sref(' SRE-Filter monitor: Error creating alias semaphore: 'A' 'usesem)
  1303.     return 0
  1304. end
  1305. alias_tid=rexxthread('f',arxx,alias_file,usequeue,USESEM,max_semwait)
  1306. if alias_tid=0 then do
  1307.    call pmprintf_sref(' SRE-Filter monitor: Could not open alias thread 'arxx)
  1308.    return 0
  1309. end
  1310.  
  1311. return 1
  1312.  
  1313.  
  1314.  
  1315. /* ---------------- */
  1316. /* start virtual dir processor thread */
  1317. start_virtual:
  1318. parse arg resetit
  1319.  
  1320. IF VIRTUAL_FILE="" | SUPPRESS_VIRTUAL=1 then RETURN 0
  1321.  
  1322. dlistx=upload_dir||' '||cgi_bin_dir||'  '||addon_dir||' '
  1323. dlistx=dlistx||translate(datadir(),'\','/')
  1324.  
  1325. arxx=servdir||'\virtchk.rxx'
  1326. usequeue='SREF_'||serverport||'_VIRTUAL'
  1327. usesem='\SEM32\SREF_'||serverport||'_VIRTUAL'
  1328.  
  1329. if resetit=1 then do            /* already opened --just send a *RESET* */
  1330.    call pmprintf_sref(' resetting virtual file 'virtual_file)
  1331.    a=rxqueue('s',usequeue)
  1332.    push '1,1,2, *RESET* ' virtual_file
  1333.    foo=eventsem_post(usesem)
  1334.    return 1
  1335. end
  1336.  
  1337. if virtual_file= ' ' then
  1338.       return 0
  1339. oy=stream(virtual_file,'c','query exists')
  1340. if oy="" then do
  1341.    CALL pmprintf_sref("SRE-Filter monitor: virtual file not found, "|| virtual_file)
  1342.    virtual_file=' '
  1343.    return 0
  1344. end
  1345.  
  1346. /* if here, first time */
  1347.  
  1348. a=rxqueue('d',usequeue)
  1349. a=rxqueue('c',usequeue)
  1350. if a<>usequeue then do
  1351.   bb=rxqueue('d','a')
  1352.   a=rxqueue('s',usequeue)
  1353.   do queued()
  1354.        pull
  1355.   end /* do */
  1356. end
  1357.  
  1358. a=eventsem_close(usesem)
  1359. A=EVENTSEM_CREATE(USESEM)
  1360. IF A<>0 then DO
  1361.     call pmprintf_sref(' SRE-Filter monitor:Error creating virtual semaphore: 'A' 'usesem)
  1362.     return 0
  1363. end
  1364. mm1=max_semwait
  1365. virtual_tid=rexxthread('f',arxx,virtual_file||' '||dlistx,usequeue,USESEM,mm1)
  1366. if virtual_tid=0 then do
  1367.    call pmprintf_sref(' SRE-Filter monitor:Could not open virtual thread 'arxx)
  1368.    return 0
  1369. end
  1370.  
  1371. return 1
  1372.  
  1373.  
  1374.  
  1375. /* ---------------- */
  1376. /* start variable storage thread */
  1377. start_varstore:
  1378. arxx=servdir||'\varstore.rxx'
  1379. usequeue='SREF_'||serverport||'_VARSTORE'
  1380. usesem='\SEM32\SREF_'||serverport||'_VARSTORE'
  1381. a=rxqueue('d',usequeue)
  1382. a=rxqueue('c',usequeue)
  1383. if a<>usequeue then do
  1384.   bb=rxqueue('d','a')
  1385.   a=rxqueue('s',usequeue)
  1386.   do queued()
  1387.        pull
  1388.   end /* do */
  1389. end
  1390.  
  1391. a=eventsem_close(usesem)
  1392. A=EVENTSEM_CREATE(USESEM)
  1393. IF A<>0 then DO
  1394.     call pmprintf_sref(' SRE-Filter monitor:Error creating variable storage semaphore:'usesem)
  1395.     return 0
  1396. end
  1397. mm1=max_semwait
  1398. v_tid=rexxthread('f',arxx,usequeue,USESEM,mm1)
  1399. if v_tid=0 then do
  1400.    call pmprintf_sref(' SRE-Filter monitor:Could not start variable storage thread 'arxx)
  1401.    return 0
  1402. end
  1403.  
  1404. return 1
  1405.  
  1406.  
  1407.  
  1408. /* ---------------- */
  1409. /* start virtual dir processor thread */
  1410. start_ssicache:
  1411. if ssi_cache_size="" then return 0
  1412.  
  1413. arxx=servdir||'\ssicache.rxx'
  1414. usequeue='SREF_'||serverport||'_SSICACHE'
  1415. usesem='\SEM32\SREF_'||serverport||'_SSICACHE'
  1416.  
  1417.  
  1418. a=rxqueue('d',usequeue)
  1419. a=rxqueue('c',usequeue)
  1420. if a<>usequeue then do
  1421.   bb=rxqueue('d','a')
  1422.   a=rxqueue('s',usequeue)
  1423.   do queued()
  1424.        pull
  1425.   end /* do */
  1426. end
  1427.  
  1428. a=eventsem_close(usesem)
  1429. A=EVENTSEM_CREATE(USESEM)
  1430. IF A<>0 then DO
  1431.     call pmprintf_sref(' SRE-Filter monitor:Error creating ssi-cache semaphore:'usesem)
  1432.     return 0
  1433. end
  1434. mm1=max_semwait
  1435. ssicache_tid=rexxthread('f',arxx,tempdata_dir,usequeue,USESEM,mm1,serverport,ssi_cache_size,ssi_cache_duration,ssi_cache_stamp)
  1436. if ssicache_tid=0 then do
  1437.    call pmprintf_sref(' SRE-Filter monitor:Could not open ssi-cache thread 'arxx)
  1438.    return 0
  1439. end
  1440.  
  1441. return 1
  1442.  
  1443.  
  1444.  
  1445.  
  1446. /* ---------------- */
  1447. /* start user check processor thread */
  1448. start_user:
  1449. parse arg resetit
  1450. if user_file= ' ' | SUPPRESS_USER=1 then
  1451.       return 0
  1452.  
  1453. oy=stream(user_File,'c','query exists')
  1454. if oy="" then do
  1455.    CALL pmprintf_sref("SRE-Filter monitor: userl file not found, "||user_file)
  1456.     user_file=' '
  1457.    return -1
  1458. end
  1459.  
  1460. arxx=servdir||'\userchk.rxx'
  1461. usequeue='SREF_'||serverport||'_USER'
  1462. usesem='\SEM32\SREF_'||serverport||'_USER'
  1463.  
  1464. if resetit=1 then do            /* already opened --just send a *RESET* */
  1465.    a=rxqueue('s',usequeue)
  1466.    push '1,1,2, *RESET* ' user_File
  1467.    foo=eventsem_post(usesem)
  1468.    return 1
  1469. end
  1470.  
  1471. /* if here, first time */
  1472. a=rxqueue('d',usequeue)
  1473. a=rxqueue('c',usequeue)
  1474. if a<>usequeue then do
  1475.   bb=rxqueue('d','a')
  1476.   a=rxqueue('s',usequeue)
  1477.   do queued()
  1478.        pull
  1479.   end /* do */
  1480. end
  1481.  
  1482. a=eventsem_close(usesem)
  1483. A=EVENTSEM_CREATE(USESEM)
  1484. IF A<>0 then DO
  1485.     call pmprintf_sref(' SRE-Filter monitor:Error creating user semaphore: 'A' 'usesem)
  1486.     return 0
  1487. end
  1488. user_tid=rexxthread('f',arxx,user_file,usequeue,USESEM,max_semwait,logon_limit)
  1489. if user_tid=0 then do
  1490.    call pmprintf_sref(' SRE-Filter monitor:Could not open user thread 'arxx)
  1491.    return 0
  1492. end
  1493.  
  1494.  
  1495. return 1
  1496.  
  1497.  
  1498. /* ---------------- */
  1499. /* start postfilter / recordall processor thread */
  1500. start_postf:
  1501. parse arg resetit
  1502.  
  1503. arxx=servdir||'\postfchk.rxx'
  1504. usequeue='SREF_'||serverport||'_postf'
  1505. usesem='\SEM32\SREF_'||serverport||'_postf'
  1506.  
  1507. a=rxqueue('d',usequeue)
  1508. a=rxqueue('c',usequeue)
  1509. if a<>usequeue then do
  1510.   bb=rxqueue('d','a')
  1511.   a=rxqueue('s',usequeue)
  1512.   do queued()
  1513.        pull
  1514.   end /* do */
  1515. end
  1516.  
  1517. a=eventsem_close(usesem)
  1518. A=EVENTSEM_CREATE(USESEM)
  1519. IF A<>0 then DO
  1520.     call pmprintf_sref('SRE-Filter monitor: Error creating postfilter semaphore: 'A' 'usesem)
  1521.     return 0
  1522. end
  1523.  
  1524. mm1=max_semwait*1.5
  1525. postf_tid=rexxthread('f',arxx,usequeue,USESEM,thesem,mm1,record_cache_lines' 'workdata_dir)
  1526. if postf_tid=0 then do
  1527.    call pmprintf_sref(' SRE-Filter monitor:Could not open postfilter thread 'arxx)
  1528.    return 0
  1529. end
  1530.  
  1531. return 1
  1532.  
  1533.  
  1534.  
  1535. /* ----  */
  1536. /* make headers and footers, host specific possibly */
  1537. make_head_foot:procedure expose aheaders. afooters. headlist. footlist. ,
  1538.         headers footers  nheads nfoots headers. footers.
  1539.  
  1540. foo=cvtails('headers.','b')
  1541. joe=arraysort('b')
  1542. crlf=' '
  1543. headers=' ' ; nheads=0 ; HDDONE=0
  1544. do mm=1 to b.0
  1545.     a1=b.mm
  1546.     a2=headers.a1
  1547.     if a2=" " then a2=0
  1548.     IF A2=0 then HDDONE=1
  1549.     if pos('.',a1)=0  then do
  1550.        if HDDONE=0 then  headers=headers||a2||crlf
  1551.     end  /* Do */
  1552.     else do             /* headers.hn */
  1553.        parse var a1 aval '.' ahost ; ahost=strip(ahost) ; aval=strip(aval)
  1554.        if strip(a2)=0 then do
  1555.              headstops.ahost=1
  1556.        end  /* Do */
  1557.        else do          /* not a stop */
  1558.          if aval=1 then  do
  1559.              nheads=nheads+1
  1560.               headlist.nheads=ahost
  1561.               aheaders.ahost=a2||crlf
  1562.              headstops.ahost=0
  1563.          end
  1564.          else do
  1565.            if headstops.ahost<>1 then
  1566.               aheaders.ahost=aheaders.ahost||a2||crlf
  1567.          end
  1568.        end              /* headstop */
  1569.     end                 /* .hn */
  1570. end
  1571. foo=cvtails('footers.','b')
  1572. joe=arraysort('b')
  1573. footers=' ' ; nfoots=0 ; FTDONE=0
  1574. do mm=1 to b.0
  1575.     a1=b.mm
  1576.     a2=footers.a1
  1577.     if a2=" " then a2=0
  1578.     IF A2=0 then FTDONE=1
  1579.     if pos('.',a1)=0  then do
  1580.        if FTDONE=0 then footers=footers||a2||crlf
  1581.     end  /* Do */
  1582.     else do             /* footers.hn */
  1583.        parse var a1 aval '.' ahost ; ahost=strip(ahost) ; aval=strip(aval)
  1584.        if strip(a2)=0 then do
  1585.              footstops.ahost=1
  1586.        end  /* Do */
  1587.        else do          /* not a stop */
  1588.          if aval=1 then  do
  1589.              nfoots=nfoots+1
  1590.               footlist.nfoots=ahost
  1591.               afooters.ahost=a2||crlf
  1592.              footstops.ahost=0
  1593.          end
  1594.          else do
  1595.            if footstops.ahost<>1 then
  1596.               afooters.ahost=afooters.ahost||a2||crlf
  1597.          end
  1598.        end              /* footstop */
  1599.     end                 /* .hn */
  1600. end
  1601.  
  1602. return 0
  1603.  
  1604.  
  1605. /*----------------------*/
  1606. save_em:
  1607. parse arg avar ;avar=strip(avar)
  1608.  
  1609. drop plist
  1610.  
  1611. avar0=strip(avar,'t','.')
  1612. avar=avar0||'.'
  1613. rr=cvtails(avar,'plist')
  1614. do r1=1 to rr
  1615.    atail=plist.r1
  1616.    interpret 't1='||avar||atail
  1617.    call value envadd||avar||atail,t1,'os2environment'
  1618. end
  1619.  
  1620. /* save the default (non hostname) version */
  1621.    if upper(symbol(avar0))="VAR" then do
  1622.       interpret 't1='||avar0
  1623.       call value envadd||avar0,t1,'os2environment'
  1624.    end
  1625.  
  1626. return 0
  1627.  
  1628.  
  1629. /* --- variable names of convert foo.bar.1 to foo.1.bar */
  1630. fix_me:procedure
  1631. parse arg a1
  1632.  
  1633. if a1=' '  then return a1
  1634. a1=strip(a1)
  1635. if abbrev(a1,';') then return a1
  1636.  
  1637. parse var a1  aname '=' avalue
  1638. if pos('.',aname)=0 then return a1
  1639.  
  1640. foo=translate(aname,' ','.')
  1641. if words(foo)<>3 then return a1
  1642.  
  1643. /* if here, array.x.y (3 elements) */
  1644. if datatype(word(foo,3))='NUM' & datatype(word(foo,2))<>'NUM' then do  /* rearrange */
  1645.    foo2=word(foo,1)||'.'||word(foo,3)||'.'||word(foo,2)||' = '||avalue
  1646.    return foo2
  1647. end  /* Do */
  1648. else do
  1649.    return a1
  1650. end  /* Do */
  1651.  
  1652.  
  1653.  
  1654.  
  1655. /***************/
  1656. /* update addon's to macrospace. */
  1657. update_addons:procedure expose keep_addons. verbose envadd
  1658. if symbol('KEEP_ADDONS.0')<>'VAR' then return  0 /* none specified*/
  1659. if datatype(keep_addons.0)<>'NUM'  then return 0
  1660.  
  1661. do iy=1 to keep_addons.0
  1662.    if symbol('KEEP_ADDONS.'||iy)<>'VAR' then iterate
  1663.    parse var keep_addons.iy asel afile . ; afile=strip(afile); asel=strip(asel)
  1664.    IF AFILE="" then DO          /* REMOVE ASEL */
  1665.       asel=strip(translate(asel,'/','\'),,'/')          
  1666.       tt=envadd||'ADDON_'||translate(asel,'__','/\')    
  1667.       FOO=MACROdROP(TT)
  1668.       ITERATE
  1669.    END
  1670.    if stream(afile,'c','query exists')="" then do
  1671.         if verbose>0 then call pmprintf_sref(" SREFMON warning: bad file in KEEP_ADDON entry: " asel ',' afile)
  1672.         iterate
  1673.    end  /* Do */
  1674.    asel=strip(translate(asel,'/','\'),,'/')
  1675.    tt=envadd||'ADDON_'||translate(asel,'__','/\')
  1676.    foo=macroadd(tt,afile,'B')
  1677.    if foo=0 then do
  1678.       if verbose>0 then call pmprintf_sref(" SREFMON warning: problem with KEEP_ADDON entry: " keep_addons.iy)
  1679.        iterate
  1680.    end  /* Do */
  1681.    if verbose>1 then call pmprintf_sref(' SREFMON: Okay ADDON entry: ' tt ' : ' afile)
  1682. end /* do */
  1683. return 0
  1684.  
  1685.  
  1686. /****************/
  1687. /* start the pmprintf thread 
  1688. itype: 1= use pmprintf, but check line lengths
  1689.        2= use pmprintf, and write to afile
  1690.        3= just write to afile
  1691. */
  1692.  
  1693. start_pmprintf:
  1694. parse arg itype, ilen, afile
  1695.  
  1696. if ilen<2 then ilen=80
  1697.  
  1698. /* check variables */
  1699. if itype=3 then ilen=0
  1700. if itype=1 then 
  1701.   afile=' '
  1702. else
  1703.   afile=servdir||'\'||strip(afile,,'\')
  1704.  
  1705. if itype>1 then do
  1706.   call lineout afile,' -- SRE-Filter log file: '||time('n')||' '||date('n')
  1707.   call lineout afile
  1708. end
  1709.  
  1710.  
  1711. /* start thread */
  1712. arxx=servdir||'\pmprintf.rxx'
  1713. usequeue='SREF_'||serverport||'_PMPRINTF'
  1714. usesem='\SEM32\SREF_'||serverport||'_PMPRINTF'
  1715. a=rxqueue('d',usequeue)
  1716. a=rxqueue('c',usequeue)
  1717. if a<>usequeue then do
  1718.   bb=rxqueue('d','a')
  1719.   a=rxqueue('s',usequeue)
  1720.   do queued()
  1721.        pull
  1722.   end /* do */
  1723. end
  1724.  
  1725. a=eventsem_close(usesem)
  1726. A=EVENTSEM_CREATE(USESEM)
  1727. IF A<>0 then DO
  1728.     call pmprintf(' SRE-Filter monitor:Error creating PMPRINTF semaphore:'usesem)
  1729.     return 0
  1730. end
  1731. mm1=max_semwait
  1732. v_tid=rexxthread('f',arxx,usequeue,USESEM,mm1,ilen,itype,afile)
  1733. if v_tid=0 then do
  1734.    call pmprintf(' SRE-Filter monitor:Could not start PMPRINTF thread 'arxx)
  1735.    return 0
  1736. end
  1737.  
  1738. return 1
  1739.  
  1740.  
  1741.  
  1742. /*********************/
  1743. /* call the procedures listed in custom_inits */
  1744. call_custom_inits:procedure
  1745. parse arg alist
  1746. signal off error ; signal off syntax ;
  1747. signal on error name yipes2 ; signal on syntax name yipes2 ;
  1748. if alist=0 then alist=""
  1749.  
  1750. do until alist=""
  1751.     parse var alist aproc ',' alist
  1752.     if aproc="" then leave
  1753.     parse var aproc aname anarg
  1754.     call pmprintf('SRE-Filter monitor: executing initialization procedure 'aproc)
  1755.     dog='okay='||aname||'("'anarg'")'
  1756.     interpret dog
  1757. end /* do */
  1758.  
  1759.  
  1760. signal on error name yipes ; signal on syntax name yipes ;
  1761.  
  1762. return 1
  1763.  
  1764. yipes2:
  1765. call pmprintf(' SRE-Filter Monitor: Error running external initialization procedure: 'aproc)
  1766. return 0
  1767.  
  1768.