/* modify the srefast configuration file */ parse arg ddir, tempfile, reqstrg,list0,verb ,uri,user, , basedir ,workdir,privset,enmadd,transaction,verbose, , servername,host_nickname,homedir if verb="" then do say " This SRE-Filter configurator is NOT meant to be run from the command line! " exit end /* Do */ /* chekc for needed_privs: superuser */ NO_REM=VALUE('SREF_NO_REMOTE_CONFIG',,'OS2ENVIRONMENT') if wordpos('SUPERUSER',upper(privset))=0 | no_rem=2 then do 'header add WWW-Authenticate: Basic Realm=' /* challenge */ foo=sref_response('unauth', "You do not have configuration rights ",tempfile,servername) return foo end port=extract('serverport') optslist=' ' list=translate(list0,' ','+') do until list="" parse var list a1 '&' list parse var a1 avar '=' aval ; avar=upper(avar) optslist=optslist||' '||avar aa='!'||avar opts.aa=aval end /* do */ /* which configuration header ? */ select when wordpos('ADDONE',optslist)>0 then call do_addone /* add to list */ when wordpos('REMOVEONE',optslist)>0 then call do_removeone when wordpos('REMOVETWO',optslist)>0 then call do_removetwo when wordpos('VIEWCONFIG0',optslist)>0 then call do_viewconfig0 when wordpos('VIEWCONFIG',optslist)>0 then call do_viewconfig when wordpos('REFRESH',optslist)>0 then call do_refresh otherwise string ' Bad option sent to SREFAST ' optslist end return 0 /*****************************/ /* remove an entry, step2 */ do_removetwo: foo=get_initfast('Removing an Entry') if foo=0 then return 0 igoo0=doit.0 igoo=0 do mm=1 to doit.0 aa='V_'||mm if wordpos(aa,optslist)>0 then iterate /* remove this one */ igoo=igoo+1 coo=cvcopy(doit.mm,sidx.igoo) end /* do */ sidx.0=igoo call lineout tempfile,'SREFAST: Removing Entries ' call lineout tempfile,'

Removing entries from the SREFAST configuration file

' foo=write_cfg(cfgfile) if foo=0 then call lineout tempfile,'
Error writing entries (after deletion) ' else call lineout tempfile, '

' igoo ' of ' igoo0 ' entries retained in SREFAST configuration file ' call lineout tempfile,'' call lineout tempfile 'FILE ERASE type text/html name ' tempfile return 0 /*****************************/ /* remove an entry */ do_removeone: foo=get_initfast('Remove Entry') if foo=0 then return 0 call lineout tempfile,'SREFAST: Remove Entry ' call lineout tempfile,'

Remove an entry from the SREFAST configuration file

' call lineout tempfile,'
' call lineout tempfile,'' call lineout tempfile,' Select entries to remove:
    ' do ii=1 to doit.0 call lineout tempfile,'
  1. ' if symbol('doit.'||ii||'.!NODO')="VAR" & doit.ii.!nodo=1 then call lineout tempfile,' NODO : ' call lineout tempfile,' ' call lineout tempfile,doit.ii.!sel if symbol('doit.'||ii||'.!NODO')="VAR" & doit.ii.!nodo=1 then call lineout tempfile,' NODO : ' if symbol('doit.'||ii||'.!SERVER')="VAR" then do if doit.ii.!server<>' ' then call lineout tempfile,' (for server : 'doit.ii.!server ') ' end end /* do */ call lineout tempfile,'
' call lineout tempfile foo=stream(tempfile,'c','close') 'FILE ERASE type text/html name ' tempfile return 0 /*****************************/ /* show working configuration file */ do_viewconfig: temp_dir=get_value("TEMPDATA_DIR") temp_dir=strip(TEMP_DIR,'t','\')||'\' isfast=get_value('SREFAST') if isfast<>1 then do ' STRING SREFAST is not currently in use; working configuration file is not in use ' return 0 end /* Do */ idxfile=temp_dir||'_FSTINDX.'||port if stream(idxfile,'c','query exists')='' then do 'STRING SREFAST working configuration file (' idxfile ') is not available. Try again in a minute. ' return 0 end foo=cvread(idxfile,sidx) if foo=0 then do 'STRING SREFAST configuration file (' idxfile ') was empty ' return 0 end oo= write_cfg(tempfile,1) oo=stream(tempfile,'c','close') 'FILE ERASE TYPE text/html name ' tempfile return 0 /*****************************/ /* show configuration file */ do_viewconfig0: foo=get_initfast('View Configuration') if foo=0 then return 0 drop sidx. ff=cvcopy(doit,sidx) oo= write_cfg(tempfile,1,1) oo=stream(tempfile,'c','close') 'FILE ERASE TYPE text/html name ' tempfile return 0 /*****************************/ /* add an entry */ do_addone: dolist='SEL NODO DIR DIR_NAMEONLY HOST SERVER TRIGGER USERS PWDS MIME NOCACHE NORECORD SSI ' cfgfile=basedir||'\INITFAST.'||port if stream(cfgfile,'c','query exists')=' ' then do doit.0=0 end /* Do */ else do foo=get_initfast('Add an Entry',1) if foo=0 then doit.0=0 end /* do */ ido=doit.0+1 if wordpos('ENTRYNUM',optslist)>0 then do ient=strip(packur(opts.!entrynum)) select when datatype(ient)<>'NUM' then ient=ido when ient<1 then ient=ido when ient>ido then ient=ido otherwise nop end end /* Do */ if ient'VAR' | doit.ient.!sel="" then do string ' Error: no SEL specified ' return 0 end /* check special cases*/ if wordpos('USERS',optslist)>0 then do if wordpos('PWDS',optslist)=0 then do string ' Error: ' words(users)' USERS specified with no PWDS ' return 0 end if words(doit.ient.!users)<>words(doit.ient.!pwds) then do string 'Error: ' words(doit.ient.!users) ' USERS, but ' words(doit.ient.!pwds) ' PWDS ' return 0 end end call lineout tempfile,'SREFAST: Adding Entry ' call lineout tempfile,'

Adding an entry to the SREFAST configuration file

' foo=cvcopy(doit,sidx) oo=write_cfg(cfgfile) if oo=0 then call lineout tempfile,'
Error writing SREFAST configuration file: 'cfgfile else call lineout tempfile,'

' doit.ient.!sel ' added to SREFAST index file as entry # ' ient call lineout tempfile,'' call lineout tempfile 'FILE ERASE type text/html name ' tempfile return 0 /******************/ /* save results to srefstcf.80 file */ write_cfg:procedure expose sidx. port tempfile enmadd parse arg aout,notascfg,isorig nossi=sidx.!nossi drop sidx.!nossi oo=cvtails(sidx,yeeks) do ii=1 to yeeks.0 parse var yeeks.ii ik '.' pook oog.ii=left(ik,8)||'.'||pook end /* do */ oog.0=yeeks.0 boop=arraysort(oog,,,1,5,'A','N',9,,'A') if boop<>1 then return 0 if notascfg<>1 then do idd=lastpos('.',aout) idd2=aout if idd>0 then idd2=delstr(aout,idd) aoutbak=dostempname(idd2||'.b??') foo=dosrename(aout,aoutbak) call lineout tempfile, '
Prior version saved as : ' aoutbak '' call lineout aout,'; Configuration for SREFAST: '||date('n')||' '||time('n') call lineout aout,'; Use SREFAST.HTM to modify this, or read SREFAST.DOC for details.' do mm=1 to oog.0 aw=space(strip(oog.mm),0) if aw='0.' then aw='0' if datatype(sidx.aw)='NUM' then call lineout aout, 'DOIT.'||aw||'='|| sidx.aw else call lineout aout,'DOIT.'||aw||'="'|| sidx.aw|| '"' end /* do */ call lineout tempfile, '
' oog.0 ' lines written to: ' aout '' end else do /* write as a report, not as an "interpretable" file */ if isorig<>1 then do call lineout aout,'SREFAST: Display Entries ' call lineout aout,' ' call lineout aout,'

SREFAST: Usage Stats and Working Configuration File

' /* some stats */ iscsh=value(enmadd||'SREF_FAST_CACHE',,'os2environment') ismain=value(enmadd||'SREF_FAST_MAIN',,'os2environment') isfast=value(enmadd||'SREF_FAST_FAST',,'os2environment') if iscsh=' ' then iscsh=0 if ismain=' ' then ismain=0 if isfast=' ' then isfast=0 itot=max(iscsh+ismain+isfast,1) biscsh=value(enmadd||'SREF_FAST_BYTES_CACHE',,'os2environment') bismain=value(enmadd||'SREF_FAST_BYTES_MAIN',,'os2environment') bisfast=value(enmadd||'SREF_FAST_BYTES_FAST',,'os2environment') if biscsh=' ' then biscsh=0 if bismain=' ' then bismain=0 if bisfast=' ' then bisfast=0 bitot=max(biscsh+bismain+bisfast,1) pctcsh=format(100*iscsh/itot,4,2) ; pctfast=format(100*isfast/itot,4,2) pctmain=format(100*ismain/itot,4,2) bpctcsh=format(100*biscsh/bitot,4,2) ; bpctfast=format(100*bisfast/bitot,4,2) bpctmain=format(100*bismain/bitot,4,2) select when bitot>1000 & bitot<2000000 then bitot=format(bitot/1000,4,0)||'K' when bitot>= 2000000 then bitot=format(bitot/1000000,7,1)||'M' otherwise nop end call lineout tempfile,'

Some Usage Statistics

' call lineout tempfile,' # SREFAST transactions (bytes)=' itot ' (' bitot ')
' call lineout tempfile,' % transactions from GoServe cache: ' pctcsh ' (' bpctcsh ')
' call lineout tempfile,' % transactions from INITFAST entries: ' pctfast '(' bpctfast ')
' call lineout tempfile,' % transactions from main filter: ' pctmain '(' bpctmain ')

' call lineout aout,'

' sidx.0 ' entries in SREFAST configuration file

' call lineout aout,' This is the working configuration file; as produced from INITFAST' if nossi=1 then call lineout aout, ', it is currently being updated ' call lineout aout,'

Note that the FILE, ORIGFILE, STAMP, and TYPE fields are created by SREFAST.

' end else do call lineout aout,'SREFAST: Display Entries ' call lineout aout,'

' sidx.0 ' entries in SREFAST configuration file

' end /* Do */ call lineout aout,'
    ' ido=0 do mm=1 to oog.0 aw=space(strip(oog.mm),0) if aw='0.' then iterate parse upper var aw anum '.!' atype if anum<>ido then do if ido>0 then call lineout aout,' ' call lineout aout,'
  1. ' sidx.anum.!sel '' call lineout aout,' ' ido=anum end if atype="SEL" then iterate ali=sidx.aw call lineout aout,'
  2. ' atype ': ' ali ' ' end /* do */ call lineout aout,'
' call lineout aout end /* Do */ return 1 /* ----------- */ /* get environment value, possibly host specific */ /* ------------ */ get_value: procedure expose enmadd host_nickname parse arg vname vname=strip(vname) ; hname=strip(host_nickname) if hname<>' ' then do aval=value(enmadd||vname||'.'||hname,,'os2environment') if aval<>' ' Then do return aval end end aval=value(enmadd||vname,,'os2environment') return aval /**********/ /* read initfast into doit */ get_initfast:procedure expose port doit. basedir tempfile cfgfile parse arg amess,nowrite cfgfile=basedir||'\INITFAST.'||port aa=0 if stream(cfgfile,'c','query exists')<>"" then aa=sref_fileread(cfgfile,todos,,'E') if aa=0 then do if nowrite=1 then return 0 call lineout tempfile,'SREFAST: No Configuration File ' call lineout tempfile,'

SREFAST ' amess ' error: Missing configuation file

' call lineout tempfile,' The required configuration file,' cfgfile', is not available ' call lineout tempfile,'' call lineout tempfile 'FILE ERASE type text/html name ' tempfile return 0 end drop doit. signal on error name badline ; signal on syntax name badline ierr=1 do kk=1 to todos.0 /* look for errors */ aline=strip(todos.kk) if aline=' ' then iterate if abbrev(aline,';')=1 then iterate interpret aline end /* do */ ierr=0 badline: signal off error ; signal off syntax if ierr=1 then do if nowrite=1 then return 0 call lineout tempfile,'SREFAST: Bad Entry ' call lineout tempfile,'

SREFAST ' amess ' error: Bad entry

' call lineout tempfile,' There is a bad entry in the configuration file,'cfgfile,' near line 'kk) call lineout tempfile,'' call lineout tempfile 'FILE ERASE type text/html name ' tempfile return 0 end return 1 /**********/ do_refresh: cfgfile=basedir||'\INITFAST.'||port foo=value('SREF_FAST_REDO',1,'os2environment') /* srefast shoud also redo */ call lineout tempfile,'SREFAST: Index Refresh ' call lineout tempfile,'

SREFAST Index Refresh

' call lineout tempfile,' The SREFAST index will be refreshed in a minute or two' call lineout tempfile,'
The SREFAST index is generated from the 'cfgfile ' configuration file.' call lineout tempfile,'' call lineout tempfile 'FILE ERASE type text/html name ' tempfile return 0