%$Id: cgiasir.sm1,v 1.16 2005/02/27 07:29:49 taka Exp $ %$OpenXM: OpenXM/src/kan96xx/Doc/cgiasir.sm1,v 1.6 2018/12/12 01:08:50 takayama Exp $ [(parse) (ox.sm1) pushfile] extension [(parse) (cgi.sm1) pushfile] extension % Default value of timer /cgiasir.tlimit (120) def % ------------------ set security flags of ox_asir. [(oxasirSetDefaultSecureFlags) [(It sets default secure flags for oxasir.sm1)] ] putUsages /oxasirSetDefaultSecureFlags { oxasir.ccc [ ] eq { ox_asirConnectMethod } { } ifelse % cf. oxasir.asir (ox_ptod) oxasirSetSecureFlag (ox_dtop) oxasirSetSecureFlag (sm1_ptozp_subst) oxasirSetSecureFlag (sm1_rat2plist) oxasirSetSecureFlag } def [(oxasirSetSecureMode) [(oxasirSetSecureMode) (It starts the restricted asir.) (cf. oxSecureFlag) ]] putUsages /oxasirSetSecureMode { oxasir.ccc [ ] eq { ox_asirConnectMethod } { } ifelse oxasir.ccc $ctrl("error_in_timer",1);$ oxsubmit oxasir.ccc $set_secure_mode(1);$ oxsubmit } def [(oxasirSetSecureFlag) [(name oxasirSetSecureFlag) (It sets the export flag for the function <>) (cf. oxSetSecureMode) ]] putUsages /oxasirSetSecureFlag { /arg1 set [/fff ] pushVariables [ /fff arg1 def oxasir.ccc [ ] eq { ox_asirConnectMethod } { } ifelse oxasir.ccc [$set_secure_flag("$ fff toString $",1);$] cat oxsubmit oxasir.ccc oxpopcmo ] pop popVariables } def /cgiAsir.test { oxasirSetDefaultSecureFlags (primadec) oxasirSetSecureFlag oxasirSetSecureMode } def %---------- server side ---------------------- % This is a default value. This is used when the environment variable % CGI_ASIR_ALLOW is not used. /cgiAsirAllow [ %% They are required by the system (ox103_reset) %%%%%%%%%%%%%%%%%%%%%%%%%% % (primadec) % (fctr) % (dp_gr_main) % (nd_gr_main) ] def /ox_cgiAsirConnectMethod { oxasir.ccc [ ] eq { ox_asirConnectMethod oxasirSetDefaultSecureFlags [(getenv) (CGI_ASIR_ALLOW)] extension isString { [(getenv) (CGI_ASIR_ALLOW)] extension /cgiAsirAllow.s set [(parse) cgiAsirAllow.s] extension pop /cgiAsirAllow.p set cgiAsirAllow.p isArray { cgiAsirAllow.p /cgiAsirAllow set } { } ifelse } { } ifelse cgiAsirAllow {oxasirSetSecureFlag} map oxasirSetSecureMode } { } ifelse } def /cgiAsir { { [(getenv) (CONTENT_LENGTH)] extension /cgi.content_length set cgi.content_length isString { } { cgiAsir.errorMessage message exit } ifelse cgi.content_length .. (integer) dc /cgi.content_length set cgi.content_length 1 lt { cgiAsir.errorMessage message exit } { } ifelse [(read) 0 cgi.content_length] extension /cgi.query_string set cgi.query_string isString { cgi.query_string length 0 eq { cgiAsir.errorMessage message exit } { } ifelse } { cgiAsir.errorMessage message exit } ifelse cgi.body.http0 message cgi.query_string cgiAsir.0 cgi.body cgiReplyInHttp0 /cgi.body.http set cgi.body.http message exit } loop [(flush)] extension } def /cgiAsir.errorMessage [ (Content-Type: text/html) nl nl () nl (Input
asir-command
without semicolon.

) nl (
 Example) nl
    $primadec([x^3-1],[x])$ nl
    $  $ nl
    $Commands accepted are $ nl
    [(getenv)  (CGI_ASIR_ALLOW)] extension tag 0 eq not {
     [(getenv) (CGI_ASIR_ALLOW)] extension nl nl
    } {  } ifelse
    $Execution CPU time limit is $ 
    cgiasir.tlimit toString  (  seconds.) nl nl
    (
) nl [(getenv) (CGI_ASIR_MSG)] extension tag 0 eq not { [(getenv) (CGI_ASIR_MSG)] extension nl nl } { } ifelse (
) nl () nl () nl (
) nl () nl ] cat def /cgiAsir.0 { cgiAsir.0a cgiAsir.0b } def /cgiAsir.0a { /arg1 set [/sss /kv /comm /i /acti0 /pError] pushVariables [ /sss arg1 def % Step 1. analyze the query string in URL encoding. [(cgiUrlEncodingToKeyValuePair) sss] extension /kv set kv (oxMessageBody) getNode /comm set % [nl nl] cat message sss message kv message % for debug. comm /cgi.body set % Step 2. Enclosed cgi.body by timer(limit, expr, "interrupted."); [(getenv) (CGI_ASIR_TLIMIT)] extension tag 0 eq { } { [(getenv) (CGI_ASIR_TLIMIT)] extension toString /cgiasir.tlimit set } ifelse [ $timer($ cgiasir.tlimit $,$ cgi.body $, "Exceeded the CPU time resource (<$ cgiasir.tlimit $ seconds) or the command is not allowed or the syntax error.");$ ] cat /cgi.body set % Step 3. Calling asir oxasir.ccc [ ] eq { ox_cgiAsirConnectMethod } { } ifelse oxasir.ccc cgi.body oxsubmit ] pop popVariables } def /cgiAsir.0b { % Step 4. Request the result oxasir.ccc oxpopstring /cgi_body set % set for cgiReplyInHttp0 /@@@stdout (NONE) def /@@@stderr (NONE) def /cgi.body cgi_body def } def /cgi.test2 { [ [(oxMessageBody) [$primadec([x^2-1],[x])$ ] cat ]] /ff set [(cgiKeyValuePairToUrlEncodingString) ff] extension /ff1 set ff1 message ff1 cgiAsir.0 cgi.body message } def % test2.txt : oxMessageBody=2-1%0A % env=CONTENT_LENGTH=20 cgi-asir.sh