home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 35 Internet / 35-Internet.zip / srev13g.zip / ALIASCFG.CMD < prev    next >
OS/2 REXX Batch file  |  1999-06-20  |  22KB  |  638 lines

  1. /*  */
  2. aliascfg:
  3. CHECKIT=0   /* Change this to 0 if you want to enable REMOTE configuration */
  4.  
  5. /* background color */
  6. USECOLOR='2dd52f'
  7.  
  8.  
  9. /* ---------------- DO NOT MODIFY BELOW THIS LINE  ------------------ */
  10.  
  11. parse arg  ddir, tempfile, sel,list,verb ,uri,user, ,
  12.           basedir ,workdir,privset,enmadd,transaction,verbose, ,
  13.          servername,host_nickname,homedir,aparam,semqueue,prog_file,reqnum
  14.  
  15. /* parse arg ddir,tempfile,sel,list,verb,uri,user,basedir,workdir,privset, ,
  16.   enmadd,transaction,verbose */
  17.  
  18. if verb="" then do
  19.    say " This SRE-http add-on is NOT meant to be run from the command line."
  20.    say " It can be invoked by using CONFIGUR.HTM "
  21.    exit
  22. end  /* Do */
  23.  
  24.  
  25. list=translate(list, ' ', '+'||'090a0d'x)  /* Whitespace, etc. */
  26.  
  27. who2=extract('CLIENTADDR')
  28. saddr2=extract('SERVERADDR')
  29. crlf='0d0a'x
  30.  
  31. NO_REM=VALUE('SREF_NO_REMOTE_CONFIG',,'OS2ENVIRONMENT')
  32.  
  33. select
  34.    when checkit=1 | no_rem>0 then do
  35.  
  36. /* only if user = serveraddress !!! */
  37.      if who2<>saddr2 | no_rem=2 then do
  38.  
  39.         call lineout tempfile, '<!doctype html public "-//IETF//DTD HTML 3.0//EN">'
  40.         call lineout tempfile, "<html><head><title>SRE-http  remote configurator disabled </title>"
  41.         call lineout tempfile, '</head><body  bgcolor="#'||usecolor||'">'
  42.  
  43.         call lineout tempfile,' <strong> Action not allowed remotely.</strong> <pre>'
  44.         call lineout tempfile,' </body> </html> '
  45.         call lineout tempfile
  46.         foo=sref_gos('FILE ERASE TYPE text/html NAME' tempfile)
  47.         return 'ALIASCFG: action not allowed remotely. '
  48.      end
  49.    end
  50.    otherwise do
  51.       if wordpos('SUPERUSER',privset)=0 then do
  52.         'RESPONSE HTTP/1.1 401 Unauthorized '     /* Set HTTP response line */
  53.         att=sref_gmt()
  54.         'HEADER Noauto ADD Date: 'att
  55.         'header add WWW-Authenticate: Basic Realm=<CONFIGURE>'  /* challenge */
  56.  
  57.         call lineout tempfile, '<!doctype html public "-//IETF//DTD HTML 3.0//EN">'
  58.         call lineout tempfile, "<html><head><title>Not authorized </title>"
  59.         call lineout tempfile, '</head><body  bgcolor="#'||usecolor||'">'
  60.  
  61.  
  62.         call lineout tempfile,' <strong> You do not have configuration rights.</strong> <pre>'
  63.         if who2=saddr2 then 
  64.                 call lineout tempfile,'<br> <Em> You may want to edit USERCFG.CMD </em> '
  65.         call lineout tempfile,' </body> </html> '
  66.         call lineout tempfile
  67.          iia=dosdir(tempfile,'s')
  68.         'FILE ERASE TYPE text/html NAME' tempfile
  69.         return '401 'iia' ALIASCFG: not permitted to configure. '
  70.       end
  71.    end
  72. end
  73.  
  74. list=strip(list)
  75. select 
  76.    when upper(list)='TODO=SHOW' | upper(list)='TODO=SHOW_HEADER' then
  77.         signal doshow
  78.  
  79.    when upper(list)='TODO=CURRENT' then
  80.         signal showcurrent
  81.  
  82.    when upper(list)='TODO=PUBURLS' then
  83.         signal showcurrent_puburls
  84.  
  85.    when upper(list)='TODO=SET' then
  86.         signal doset
  87.    otherwise
  88.         signal dochange
  89. end  /* select */
  90.  
  91. /* jump here to show values */
  92. doshow:
  93.  
  94. aliasfile=value(enmadd||'ALIAS_FILE',,'os2environment')
  95.    call lineout tempfile, '<!doctype html public "-//IETF//DTD HTML 3.0//EN">'
  96.    call lineout tempfile, "<html><head><title>SRE-http redirection aliases </title>"
  97.    call lineout tempfile, '</head><body  bgcolor="#'||usecolor||'">'
  98.  
  99.  
  100. aa=go_fileread(aliasfile)  /* expose lins */
  101.  
  102. /*aa=fileread(aliasfile,'lins',,'E') */
  103.  
  104. call lineout tempfile, "<h1> SRE-http: <A NAME="top"> Redirection aliases </A>   </h1> <p>"
  105. if upper(list)="TODO=SHOW"  then
  106.    call lineout tempfile, "<h2> List of "header" comments </h2> <pre> <blockquote>"
  107. else
  108.    call lineout tempfile, "<h2> Description of redirection aliaases </h2> <pre> <blockquote>"
  109.  
  110.  
  111. /* show "header comments" */
  112. iat=0
  113. do until iat >= lins.0
  114.    iat=iat+1
  115.    if  abbrev(strip(lins.iat),';')  then do
  116.         foo=strip(lins.iat) ;foo=strip(foo,'l',';')
  117.          call lineout tempfile, foo 
  118.    end  /* Do */
  119.    else do
  120.         leave
  121.    end
  122. end /* do -- iat is the first non header comment line  */
  123. call lineout tempfile, '</blockquote></pre> '
  124.  
  125. /* view descriptive header only? */
  126. if upper(list)='TODO=SHOW_HEADER' then do
  127.    call lineout tempfile,' <hr> </body></html>'
  128.    call lineout tempfile
  129.    foo=sref_gos('file erase  type text/html name  ' tempfile)
  130.    return ' done '
  131. end  /* Do */
  132.  
  133. /* read in aliases, etc */
  134. nusers=0
  135. call lineout tempfile, '<hr><h2> List of redirection aliases </h2> '
  136. call lineout tempfile,' Notes: <ul> '
  137. call lineout tempfile,' <li> Aliases are stored in: ' aliasfile
  138. call lineout tempfile,' <li> <em>Comments are in italics </em> '
  139. call lineout tempfile,' <li> The <strong>*</strong> character is used as a wildcard (for an arbitrarily long string)'
  140. call lineout tempfile, ' <li> Entries with no <strong>host nickname</strong> apply to all requests</ul> <br>'
  141. call lineout tempfile,' <table border=1> <th> Host Nickname </th>'
  142. call lineout tempfile,' <th> Candidate SEL (convert from)</th>'
  143. call lineout tempfile,'  <th> Target of redirection (convert to) </th> <tr>'
  144.  
  145. do mm=iat to lins.0
  146.   if lins.mm=' ' then iterate
  147.   if  abbrev(strip(lins.mm),';') then do  
  148.        call lineout tempfile,'<td colspan=3>  <code>     </code> <em>' strip(strip(lins.mm),'l',';') '</em></td> <tr> '
  149.   end
  150.   else do
  151.       if pos('// ',lins.mm)>0 then do
  152.            parse var lins.mm hostname '//' candurl targurl
  153.       end
  154.       else do
  155.            hostname=' .. '
  156.            parse var lins.mm candurl targurl
  157.       end  /* Do */
  158.       movers=' '
  159.       if abbrev(upper(targurl),'!MOVED')+abbrev(upper(targurl),'!TEMP')>0 then do
  160.            parse var targurl movers targurl
  161.       end /* do */
  162.  
  163.       if length(targurl) > 55 then do
  164.           iiat2=0 ; moocow='' ; ijoe=length(targurl) 
  165.           do while iiat2 <= length(targurl)
  166.               iiat=iiat2+1
  167.               eek=substr(targurl,iiat,45)
  168.               moocow=moocow||eek||'<br>'
  169.               iiat2=iiat2+45
  170.           end
  171.           targurl=moocow
  172.       end
  173.       call lineout tempfile,'<td>     <STRONG> 'hostname '</STRONG> </td>'
  174.       call lineout tempfile,'<td>   <STRONG> ' candurl '</STRONG> </td>'
  175.       call lineout tempfile,'<td>    <STRONG> 'movers ' 'targurl '</STRONG> </td> <tr>'
  176.  
  177.   end /* do */
  178.  
  179. end
  180. call lineout tempfile,' </table>'
  181.  
  182. call lineout tempfile,' <hr> Thanks for checking </body></html>'
  183. call lineout tempfile
  184.  
  185. foo=sref_gos('file erase  type text/html name  ' tempfile)
  186. return ' done '
  187.  
  188.  
  189. /* jump here if "show current" chosen */
  190. showcurrent:
  191. foo=wait_queue('ALIAS')
  192. call lineout tempfile, '<!doctype html public "-//IETF//DTD HTML 3.0//EN">'
  193. call lineout tempfile, "<html><head><title>SRE-http: list of aliases </title>"
  194. call lineout tempfile, '</head><body  bgcolor="#'||usecolor||'">'
  195.  
  196. call lineout tempfile, '<h2>List of SRE-http ALIASes </h2>'
  197. call lineout tempfile,' This complete list of ALIASes includes entries in default and host specific copies '
  198. call lineout tempfile,' of ALIASES.IN and ATTRIBS.CFG <hr width="30%">'
  199. call lineout tempfile,'<table border=1>'
  200. call lineout tempfile,'<tr><th> Host <th> Selector <th> Replacement '
  201. do forever
  202.   if foo='' then leave
  203.   parse var foo ah '//' a1 a2 (crlf) foo
  204.   call lineout tempfile,'<tr><td> 'ah '<td> 'a1 '<td> 'a2 
  205. end
  206. call lineout tempfile,'</table></body></html>'
  207. call lineout tempfile
  208. foo=sref_gos('file erase  type text/html name  ' tempfile)
  209. return ' done '
  210.  
  211.   
  212.  
  213. /* jump here if "show current puburls" chosen */
  214. showcurrent_puburls:
  215. foo=wait_queue('PUBURL')
  216. call lineout tempfile, '<!doctype html public "-//IETF//DTD HTML 3.0//EN">'
  217. call lineout tempfile, "<html><head><title>SRE-http: list of Public URLS</title>"
  218. call lineout tempfile, '</head><body  bgcolor="#'||usecolor||'">'
  219.  
  220. call lineout tempfile, '<h2>List of SRE-http Public URLS</h2>'
  221. call lineout tempfile,' This complete list of Public URLS includes entries in default and host specific copies '
  222. call lineout tempfile,' of PUBURLS.IN and ATTRIBS.CFG <hr width="30%">'
  223. call lineout tempfile,'<table border=1>'
  224. call lineout tempfile,'<tr><th> Host <th> Selector <th> Options '
  225. do forever
  226.   if foo='' then leave
  227.   parse var foo aline (crlf) foo
  228.   parse var aline ah '//' a1 a2
  229.   call lineout tempfile,'<tr><td> 'ah '<td> 'a1 '<td> 'a2 
  230. end
  231. call lineout tempfile,'</table></body></html>'
  232. call lineout tempfile
  233. foo=sref_gos('file erase  type text/html name  ' tempfile)
  234. return ' done '
  235.  
  236.   
  237.  
  238.  
  239.  
  240. /* --- jump here to modify values -- */
  241. /* jump here if "set values" chosen */
  242. doset:
  243. aliasfile=value(enmadd||'ALIAS_FILE',,'os2environment')
  244.  
  245. aa=go_fileread(aliasfile)
  246. /*aa=fileread(aliasfile,'lins',,'E')*/
  247.  
  248. call lineout tempfile, '<!doctype html public "-//IETF//DTD HTML 3.0//EN">'
  249. call lineout tempfile, "<html><head><title>SRE-http: modify redirection aliases </title>"
  250. call lineout tempfile, '</head><body  bgcolor="#'||usecolor||'">'
  251.  
  252. call lineout tempfile,'<!--  a button bar. --> 'crlf ,
  253.            '<a href="/configur.htm">Configurator</a>||' crlf ,
  254.            '<a href="/config2?todo=SET">Parameters</a>||' crlf ,
  255.            '<a href="/usercfg?todo=SET">Usernames</a>||'  crlf ,
  256.            '<a href="/realmcfg?todo=SET">Define-Realms</a>||'||crlf ,
  257.            '<a href="/accescfg?todo=SET">Access-Controls||'  crlf ,
  258.            '<a href="/aliascfg?todo=SET">Aliases</a>||'  crlf ,
  259.            '<a href="/virtcfg?todo=SET">VirtualDir</a><p>'  
  260.  
  261.  
  262. /* ignore header stuff */
  263. iat=0
  264. do until iat >= lins.0
  265.    iat=iat+1
  266.    if  abbrev(strip(lins.iat),';') | lins.iat=' ' then iterate
  267.    leave
  268. end /* do -- iat is the first non header comment line  */
  269.  
  270. call lineout tempfile, "<h1> SRE-http: modify redirection Aliases  </h1> <p>"
  271.  
  272. call lineout tempfile,' <blockquote> You can modify, remove, or add redirection aliases.'
  273. call lineout tempfile,' <br><em> Questions? <A HREF="#notes">The notes might help.</A> </em> </blockquote> '
  274. call lineout tempfile,' <h2> Modify or remove current Aliases </h2>'
  275. call lineout tempfile,'<FORM ACTION="/aliascfg" METHOD="POST">'
  276. call lineout tempfile,' <table border=1> <th> Host Nickname <br> (see below  for a <br>listing of <A HREF="#hosts">current hosts</A>) </th>'
  277. call lineout tempfile,' <th> Candidate SEL   (set to blank to  <br> delete the entry)</th>'
  278. call lineout tempfile,'  <th> Target SEL   </th> <tr>'
  279.  
  280. nhidden=0 ; mm=0
  281. do mm0=iat to lins.0
  282.     alin=translate(lins.mm0,' ','1a000d0a'x)
  283.     mm=mm+1
  284.     if  abbrev(strip(alin),';')=1 | alin=' ' then do
  285.         nhidden=nhidden+1
  286.         hiddens.nhidden='<INPUT TYPE="HIDDEN" name="COMMENT.'||mm||'"  value="'||alin||'" >'
  287.         iterate
  288.     end
  289.  
  290. /* non comment */
  291.     if pos('// ',alin)>0 then
  292.              parse var alin hostname '//' candurl targurl
  293.         else do
  294.              hostname='  '
  295.              parse var alin candurl targurl
  296.      end  /* Do */
  297.      call lineout tempfile,'<td> <EM>Host nickname:</EM> <br> <INPUT TYPE="text" NAME="hostname.'||mm||'"'
  298.      call lineout tempfile,'value="'hostname'" SIZE=8 MAXLENGTH=15> </td> '
  299.  
  300. /*    call lineout tempfile,'<td> <EM>Candidate SEL:</EM> <br> <INPUT TYPE="text" NAME="candurl.'||mm||'"'
  301.      call lineout tempfile,'value="'candurl'" SIZE=28 MAXLENGTH=295> </td> '*/
  302.  
  303.      candurl2=candurl ; iat=25
  304.      do until iat>length(candurl2)
  305.           candurl2=insert('0d0a'x,candurl2,iat)
  306.           iat=iat+30
  307.      end /* do */
  308.  
  309.      call lineout tempfile,'<td> <EM>Candidate SEL:</EM> <br> <TEXTAREA NAME="candurl.'||mm||'"'
  310.      call lineout tempfile,' rows=2 cols=32>'candurl2' </textarea> </td>'
  311.  
  312.  
  313. /*     call lineout tempfile,'<td> <EM>Target SEL:</EM> <br> <INPUT TYPE="text" NAME="targurl.'||mm||'"'
  314.      call lineout tempfile,'value="'targurl'" SIZE=28 MAXLENGTH=295> </td> '*/
  315.      targurl2=targurl ; iat=25
  316.      do until iat>length(targurl2)
  317.           targurl2=insert('0d0a'x,targurl2,iat)
  318.           iat=iat+35
  319.      end /* do */
  320.      call lineout tempfile,'<td> <EM>Target SEL:</EM> <br> <TEXTAREA NAME="targurl.'||mm||'"'
  321.      call lineout tempfile,' rows=2 cols=35>'targurl2'</textarea> </td>'
  322.  
  323.  
  324.      if mm0<lins.0 then do
  325.            call lineout tempfile,'<tr>' ; call lineout tempfile,' '
  326.      end
  327. end
  328. call lineout tempfile,' '
  329.  
  330. /* --- allow user to enter a few new names */
  331. call lineout tempfile,' </table>  <p> <h2> Add new redirection aliases </h2> <table border=1>'
  332. mm0=mm
  333. do mm=mm0+1 to mm0+3
  334.      call lineout tempfile,'<td> <EM>Host nickname:</EM> <br> <INPUT TYPE="text" NAME="hostname.'||mm||'"'
  335.      call lineout tempfile,'value=" " SIZE=8 MAXLENGTH=15> </td> '
  336.      call lineout tempfile,'<td> <EM>Candidate SEL:</EM> <br>'
  337.      call lineout tempfile,'<textarea name="candurl.'||mm||'" rows=2 cols=30>'
  338.      call lineout tempfile,' </textarea> </td> '
  339.      call lineout tempfile,'<td> <EM>Target SEL:</EM> <br>'
  340.      call lineout tempfile,' <TEXTAREA NAME="targurl.'||mm||'" rows=2 cols=30>'
  341.      call lineout tempfile,' </textarea> </td> '
  342.      if mm<mm0+3 then call lineout tempfile,' <tr> '
  343. end
  344.  
  345. call lineout tempfile,'</table> <p>'
  346.  
  347.  
  348. /* ----- add comments information */
  349.  
  350. do jj=1 to nhidden
  351.    call lineout tempfile,hiddens.jj
  352. end /* do */
  353. call lineout tempfile,' <input type="hidden" name="entries" value="'||mm||'">'
  354. call lineout tempfile,' <input type="submit"> <input type="reset"> </form> '
  355.  
  356.  
  357. call lineout tempfile,' <hr> <h3><A NAME="notes"> Notes</A> </h3> '
  358. call lineout tempfile,' <ul> <li> Aliases are stored in: 'aliasfile
  359. call lineout tempfile,' <li> New lines and spaces, that are included in '
  360. call lineout tempfile,' <em>candidate sel </em> and <em>target sel </em> fields, '
  361. call lineout tempfile,' will be removed.'
  362. call lineout tempfile,' <li> If a <em>request selector</em> matches a <em>candidate SEL</em>, '
  363. call lineout tempfile,' <br> the associated <em>target SEL </em> is for the (internal or external) redirection'
  364. call lineout tempfile,' <li> To add more then 3 new aliases, just rerun this several times <br> or edit ' aliasfile
  365. call lineout tempfile,' <li> Do you want to view a  more complete description of '
  366. call lineout tempfile,' <a href="/samples/in_files.doc"> aliases </a>?'
  367. call lineout tempfile,' <li>View the <a href="/aliascfg?TODO=CURRENT"> current set of aliases </a>?'
  368.  
  369. call lineout tempfile,' <li> <em>Comments are NOT displayed </em>  <li> Case is ignored '
  370. call lineout tempfile,' <li> Use a <strong>* </strong> in the <em>candidate SEL</em> as a wildcard character '
  371. call lineout tempfile,' <li> When a * appears in the <em>candidate SEL</em>.. '
  372. call lineout tempfile,' <br> you can use a <strong>* </strong> in the <em>target SEL</em> as a placeholder for the wildcard match '
  373. call lineout tempfile,' <li> A <em>Target SEL</em> being used for external redirection should start with <strong>http:// </strong>'
  374. call lineout tempfile, ' <li> Entries with no <strong>host nickname</strong> will apply to all requests'
  375. call lineout tempfile, ' <li> To identify a negotiable resource, enter <B>!NEGOTIATE</b> in the ',
  376.                        ' <em>Target sel </em> field<br>'
  377. call lineout tempfile,' <em> Or, </em> enter <B>!NEGOTIATE variant_list</b>, and use a wildcarded <em>candidate sel</em></ul> <br>'
  378.  
  379.  
  380.  
  381. call lineout tempfile,' <h3> A list of the <A NAME="hosts">current hosts</A> </h3>  <blockquote> '
  382. ii=value(enmadd||'HOSTS.0',,'os2environment')
  383. if ii=0 then do
  384.    call lineout tempfile,'<strong>There are no hosts defined</strong>'
  385. end 
  386. else do
  387.   hlist=sref_value('$HOSTS.0',,'USE')
  388.   call lineout tempfile,' <table> <th> IP address </th> <th> Host Nickname </th> <th> Data Directory </th> <tr> '
  389.   do ll=1 to words(hlist)
  390.       hh=strip(translate(word(hlist,ll)))
  391.       wow=sref_value('$HOSTS.'||hh,,'use')
  392.       parse var wow ip ',' hn ',' hdir
  393.      call lineout tempfile,' <td> ' ip  '</td> <td> ' hn ' </td> <td> ' hdir '</td> <tr> '
  394.   end /* do */
  395.   call lineout tempfile,' </table> </blockquote>'
  396. end
  397.  
  398.  
  399. call lineout tempfile,' <p> <A HREF="#top">Return to the top of this form.</A>'
  400.  
  401. call lineout tempfile,'</body></html>'
  402. call lineout tempfile
  403.  
  404. foo=sref_gos('file erase  type text/html name  ' tempfile)
  405. return foo
  406.  
  407.  
  408.  
  409. /* ********************** jump here to recrod changes */
  410. dochange:
  411.  
  412. parse upper var list foo 'ENTRIES=' nentries '&' .
  413. do ii1=1 to nentries
  414.    fillme.ii1.0=0
  415. end /* do */
  416.  
  417. do until list=""
  418.    parse var list aa '&' list
  419.    parse  var aa avar '.' aind '=' aval
  420.    avar=upper(avar)
  421.    aval=packur(aval)
  422.    if abbrev(upper(avar),'ENTRIES=')=1 then iterate
  423.    wow=fillme.aind.0+1
  424.    fillme.aind.0=wow
  425.    fillme.aind.wow.var=avar ; fillme.aind.wow.val=aval
  426.    select
  427.       when avar="COMMENT" then do
  428.           fillme.aind.type='COMMENT'
  429.           parse  var aa foo '=' aval
  430.           fillme.aind.wow.val=packur(aval)
  431.       end
  432.       when avar="CANDURL" then fillme.aind.type='URL'
  433.       otherwise nop
  434.    end
  435. end /* do */
  436.  
  437. aliasfile=value(enmadd||'alias_FILE',,'os2environment')
  438. aa=go_fileread(aliasfile)
  439. /*aa=fileread(aliasfile,'lins',,'E')*/
  440.  
  441. /* pull "header comments" */
  442. iat=0
  443. do until iat >= lins.0
  444.    iat=iat+1
  445.    if  abbrev(strip(lins.iat),';')=1  then do
  446.        newlines.iat=lins.iat
  447.    end  /* Do */
  448.    else do
  449.         leave
  450.    end
  451. end /* do -- iat is the first non header comment line  */
  452. iat=iat-1
  453.  
  454. do uu=1 to nentries
  455.    select
  456.       when fillme.uu.type='COMMENT' then do
  457.           iat=iat+1
  458.           newlines.iat=fillme.uu.1.val
  459.       end
  460.       when fillme.uu.type='URL' then do
  461.           candurl=' ' ; targurl=' ' ; hostname=' ' 
  462.           do uu2=1 to fillme.uu.0
  463.              chk1=fillme.uu.uu2.var
  464.              vvv=strip(fillme.uu.uu2.val)
  465.              prefx=''
  466.  
  467.              if abbrev(vvv,'!')>0 then do
  468.                  parse var vvv vvva vvvb ; vvva=strip(upper(vvva))
  469.                  if wordpos(vvva,'!TEMP !NEGOTIATE !MOVED')>0 then do
  470.                      prefx=vvva' ' ; vvv=vvvb
  471.                  end
  472.  
  473.              end /* do */
  474.              vvv2=prefx' 'space(translate(vvv,' ','0d0a'x),0)
  475.              select
  476.                 when chk1='CANDURL' then candurl=vvv2
  477.                 when chk1='TARGURL' then targurl=vvv2
  478.                 when chk1='HOSTNAME' then hostname=vvv
  479.                 otherwise nop
  480.              end
  481.              
  482.           end
  483.           if candurl<>' ' then do
  484.               iat=iat+1
  485.               newlines.iat=''
  486.               if hostname<>' ' then
  487.                   newlines.iat=hostname||'// '
  488.               newlines.iat=newlines.iat||candurl' ' targurl
  489.           end
  490.       end
  491.       otherwise do
  492.             nop
  493.       end  /* Do */
  494.  
  495.   end                   /* select over type */
  496. end                     /* do over entries */
  497.  
  498. /* save to aliasfile.. but rename access_file first */
  499. foo=lastpos('.',aliasfile)
  500. if FOO=0 then
  501.    acf1=aliasfile||'.'
  502. else
  503.    acf1=left(aliasfile,foo)
  504. do hi=1 to 999
  505.    try1=acf1||hi
  506.    if stream(acf1||hi,'c','query exists')='' then leave
  507. end /* do */
  508. foo=dosrename(aliasfile,try1)
  509.  
  510.  
  511. newlines.0=iat
  512. foo=sref_filewrite(aliasfile,newlines,'R')
  513.  
  514.  
  515. call lineout tempfile, '<!doctype html public "-//IETF//DTD HTML 3.0//EN">'
  516. call lineout tempfile, "<html><head><titLE> SRE-http: Changed the aliases</title>"
  517. call lineout tempfile, '</head><body  bgcolor="#'||usecolor||'">'
  518.  
  519. call lineout tempfile,' <h2>The aliases have been changed </h2>'
  520. call lineout tempfile,' The list of aliases has been saved to: ' aliasfile
  521. call lineout tempfile,' <p> The old version of 'aliasfile' has been moved to ' try1
  522. call lineout tempfile,'<p> <a href="/config2.htm">Return to Intermediate Mode Configurator</a>'
  523.  
  524. call lineout tempfile,' </body> </html> '
  525. call lineout tempfile
  526.  
  527. foo=value('SREF_REDO',1,'os2environment')
  528.  
  529. foo=sref_gos('FILE ERASE TYPE text/html NAME' tempfile)
  530. return 'done change '
  531.  
  532.  
  533.  
  534.  
  535. /* read in aliasfile, concatenate  extension lines */
  536. go_fileread:procedure expose lins.
  537. parse arg aliasfile
  538. aa=sref_fileread(aliasfile,'lins0',,'E')
  539. FOO=DO_EXTENDS(0)
  540.  
  541.  
  542. /* OLDER "END WITH , " METHOD RETAINED FOR COMPATABILITIES */
  543. ill=0
  544. exton=0
  545. do il=1 to lins0.0
  546.   t1=strip(lins0.il)
  547.   if exton=1 then do
  548.        t1=t1storage||t1
  549.   end
  550.   exton=0 
  551.  
  552.   if abbrev(t1,';')=0 then do
  553.      if right(t1,2)=' ,' & il < lins0.0 then do
  554.         exton=1
  555.         t1=left(t1,length(t1)-2)
  556.         t1storage=strip(t1)
  557.         iterate
  558.      end
  559.   end
  560.  
  561.   ill=ill+1
  562.   lins.ill=t1
  563. end /* do */
  564.  
  565. lins.0=ill
  566. return ill
  567.  
  568.  
  569. /************/
  570. /* Redo ulist, by treating lines starting with , as continuation lines */
  571. do_extends:procedure expose lins0.
  572.  
  573. if lins0.0=0 then return
  574. isnew=1
  575. tmps.1=lins0.1
  576. do mm=2 to lins0.0
  577.    ali=strip(lins0.mm)
  578.    if abbrev(ali,',')=0 then do
  579.         isnew=isnew+1
  580.         tmps.isnew=lins0.mm
  581.     end
  582.     else do
  583.         tmps.isnew=tmps.isnew||substr(ali,2)
  584.     end
  585. end
  586. do mm=1 to isnew
  587.     lins0.mm=tmps.mm
  588. end
  589. lins0.0=isnew
  590. return 0
  591.  
  592.  
  593. /* ------------------------------------------------------ */
  594. /* query and wait on helper thread */
  595. /* ------------------------------------------------------*/
  596. wait_queue:procedure expose enmadd transaction semqueue host_nickname
  597. parse arg athread
  598. again1t:
  599.  
  600. parse var semqueue mysem myqueue
  601.  
  602. basesem='\SEM32\'||enmadd
  603.  
  604. goober=enmadd||athread
  605.  a=rxqueue('s',goober)
  606.  queue  transaction ' ' host_nickname ',' myqueue ',' mysem ', *LIST* '
  607.  
  608.   a=eventsem_reset(mysem)
  609.   dothread=basesem||athread
  610.  
  611.   a=eventsem_post(dothread)
  612. again2t:
  613.   a=eventsem_wait(mysem,90000)  /* max wait of 90 seconds */
  614.  
  615.   if a<>0 then do
  616.         ss=sref_error(mytid','athread' A Fatal Semaphore failure: 'a,1)
  617.         'response HTTP/1.1 503 Service Unavailable'
  618.         String 'Web server is temporarily busy '
  619.         exit ' '
  620.   end
  621.   a=rxqueue('s',myqueue)
  622.  
  623.   parse pull aline
  624.  
  625.   PARSE VAR ALINE idnum ',' aline
  626.   idnum=strip(translate(idnum,' ','000d0a'x));TRANSACTION=STRIP(TRANSACTION)
  627.   if idnum<>transaction then  do /*wierd error: got someone else's message! */
  628.         ss=sref_error(mytid','athread' A  Semaphore failure: 'a,1)
  629.         'response HTTP/1.1 503 Service Unavailable'
  630.         String 'Web server is temporarily busy '
  631.         exit ' '
  632.   end
  633.  
  634.   return aline
  635.  
  636.  
  637.  
  638.