home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 35 Internet / 35-Internet.zip / srev13g.zip / TESTVALU.CMD < prev    next >
OS/2 REXX Batch file  |  1999-03-02  |  4KB  |  114 lines

  1. /* test sref_value */
  2.  
  3. /* note: with this utility, you can temporarily change system variables.
  4.    Thus, superuser privileges are required (by default).
  5.    You can relax this by changingt the reqpriv parameter */
  6.  
  7.  
  8. REQPRIV='SUPERUSER'                     /* set to '' to allow free access */
  9.  
  10. parse arg  ddir, tempfile, reqstrg,list,verb ,uri,user, ,
  11.           basedir ,workdir,privset,enmadd,transaction,verbose, ,
  12.          servername,host_nickname,homedir
  13.  
  14. if verb="" then do
  15.     say "Sorry, this SRE-http can not be run from the command line."
  16. end /* do */
  17.  
  18. PARSE ARG R1, R2,servername,stale,amessage
  19.  
  20. if reqpriv<>'' then do
  21.     if wordpos(reqpriv,translate(privset))=0 then do
  22.          aa=sref_ask_auth('TEST_VALUE',,servername)
  23.          return aa
  24.     end /* do */
  25. end /* do */
  26.  
  27. if upper(verb)='GET' then  parse var uri . '?' list
  28.  
  29. newval="" ; anenv="OS2" 
  30. varname="" 
  31. miscval=""
  32.  
  33. readonly=0;treadonly=0
  34.  
  35. do until list=""
  36.    parse var list a1 '&' list
  37.    parse var a1 avar '=' aval
  38.    avar=upper(avar) ; aval=packur(translate(aval,' ','+'))
  39.    select 
  40.       when avar='ENV' then anenv=aval
  41.       when avar="VARNAME" then varname=aval
  42.       when avar="NEWVAL" then newval=aval
  43.       when avar="MISC"  then miscval=aval
  44.       when avar='READONLY' then 
  45.          if wordpos(strip(aval),'Y YES 1')>0 then readonly=1
  46.    otherwise
  47.    end  /* select */
  48. end /* do */
  49. miscval=strip(miscval)
  50. if readonly=1 then newval=""  /* suppress writing */
  51.  
  52. parse var uri app '?' .
  53. app='<a href="'app'?env='anenv'&readonly=1&MISC='miscval'&Varname='
  54.  
  55.  
  56. /* responses to * contain a space delimited list of variable,pairs.
  57.   Each variable,pair has the "sre_name" first, then a comma, then real name.
  58.   For os/2, request, and user envirnoments, the sre_name and the real_name are the
  59.   same. For the INI environment, the real_name will have a SREF_80, SRE_, SREF_, or
  60.   some such similar "this is an sre variable" prefix appended. (the "real name"
  61.   is the named used by os/2 when storing the value in the environment */
  62.   
  63. gee=sref_value(varname,newval,anenv,miscval)
  64. mx=0
  65. if pos('*',varname)>0 & gee<>' 'then do          /* sort the "list of all variables */
  66.   gob.0=words(gee) ;mx=-1
  67.   do imm=1 to gob.0
  68.      gob=word(gee,imm) 
  69.      parse var gob  g1 ',' g2
  70.      g1=strip(g1)
  71.      if g2='' then g2=g1
  72.      mx=max(mx,length(g1))
  73.      gob.imm=left(g1,60,' ')||g2
  74.   end /* do */
  75.   yee=arraysort('gob',1,,,59)
  76.   gee='<pre>';gee2=' ' ; mgee=0
  77.   do jjj=1 to gob.0
  78.      agobsre=strip(left(gob.jjj,59))
  79.      agobori=strip(substr(gob.jjj,60))
  80.      agob=app||agobori','agobsre||'">'agobsre'</a>'
  81.      aruba=mx+1-length(agobsre)
  82.      agob=agob||copies(' ',aruba)
  83.      gee2=gee2' 'agob
  84.      mgee=mgee+mx+1
  85.      if mgee>65 then do
  86.            gee=gee||gee2||'0d0a'x ; gee2=' ' ; mgee=0
  87.      end /* do */
  88.   end /* do */
  89.   if gee2<>'' then    gee=gee||gee2||'<br></pre>'
  90. end
  91. else do                         /* not a list of all vars */
  92.   gee=sref_replacestrg(gee,'<','<','ALL')  /* html encode dangerous  characters */
  93.   gee=sref_replacestrg(gee,'>','>','ALL')  
  94.   gee=sref_replacestrg(gee,'"','"','ALL')  
  95.   gee=sref_replacestrg(gee,' ','  ','ALL')  
  96. end
  97.  
  98.  
  99. crlf='0d0a'x
  100. call lineout tempfile,'<html><head><title>Test SREF_VALUE results </title></head><body>'
  101. call lineout tempfile,'<h3>Results of SREF_VALUE </h3>'
  102. call lineout tempfile,' <b>Environment: </b> 'anenv
  103. parse upper var varname  varnamex hn
  104. parse var  varname v1 ',' v2
  105. if v2<>'' then v1=v2 
  106. call lineout tempfile,'<br><b>Variable:</b> 'v1 '<p>'
  107. call lineout tempfile," <b>Value returned=</b>" gee
  108. call lineout tempfile,'</body></html> '
  109. call lineout tempfile
  110. foo=sref_gos('FILE type text/html name 'tempfile)
  111. return ' '
  112.  
  113.  
  114.