[BACK]Return to httpd.sm1 CVS log [TXT][DIR] Up to [local] / OpenXM / src / kan96xx / Doc

Diff for /OpenXM/src/kan96xx/Doc/httpd.sm1 between version 1.5 and 1.13

version 1.5, 2001/09/20 05:57:40 version 1.13, 2002/11/03 12:43:03
Line 1 
Line 1 
 %% $OpenXM: OpenXM/src/kan96xx/Doc/httpd.sm1,v 1.4 2001/08/29 11:18:57 takayama Exp $  %% $OpenXM: OpenXM/src/kan96xx/Doc/httpd.sm1,v 1.12 2002/10/30 13:23:06 takayama Exp $
 %% common modules for httpd on sm1.  %% common modules for httpd on sm1.
 /Oxserver_history_variable (Oxserver_history_variable_) def  /Oxserver_history_variable (Oxserver_history_variable_) def
 /httpd.image.type  /httpd.image.type
   [(getenv) (OpenXM_PSTOIMG_TYPE)] extension    [(getenv) (OpenXM_PSTOIMG_TYPE)] extension
 def  def
   
   [(getenv) (OXWEB_DEBUG)] extension tag 0 eq {
      /httpd.debug 0 def
   } {
      /httpd.debug 1 def
   } ifelse
   [(getenv) (OXWEB_TAKE_LOG)] extension tag 0 eq {
      /httpd.take.log  0 def
   } {
      /httpd.take.log 1 def
   } ifelse
   
   
 /httpd_startserver {  /httpd_startserver {
    [(sm1.socket) (open) [httpd.port (localhost)]] extension     [(sm1.socket) (open) [httpd.port (localhost)]] extension
    /httpd.server.fdAndPort set     /httpd.server.fdAndPort set
Line 27  def
Line 38  def
   
 /sendln {  /sendln {
  /arg1 set   /arg1 set
  [/in-sendln /mmm] pushVariables   [/in-sendln /mmm /i] pushVariables
  [ arg1 /mmm set   [ arg1 /mmm set
   mmm tag 5 eq {    mmm tag 5 eq {
     [mmm 10 (string) dc] cat /mmm set      [mmm 10 (string) dc] cat /mmm set
Line 37  def
Line 48  def
   [(sm1.socket) (select) [httpd.server.fd 0 get 0]] extension {    [(sm1.socket) (select) [httpd.server.fd 0 get 0]] extension {
     (Warning (sendln): your peer closed the connection. Do not send the data.) message      (Warning (sendln): your peer closed the connection. Do not send the data.) message
   } {    } {
     [(sm1.socket) (write) [httpd.server.fd 0 get mmm]] extension message      [(sm1.socket) (write) [httpd.server.fd 0 get mmm]] extension /i set
        httpd.debug { i message } { } ifelse
   } ifelse    } ifelse
  ] pop   ] pop
  popVariables   popVariables
Line 74  def
Line 86  def
     httpd_startserver ;      httpd_startserver ;
     httpd_action ;      httpd_action ;
     httpd_stopserver ;      httpd_stopserver ;
     (5 sleep) system      httpd.take.log { (date) system  } { } ifelse
   %    (sleep 2) system
     httpd.serial 1 add /httpd.serial set      httpd.serial 1 add /httpd.serial set
   } loop    } loop
 } def  } def
Line 93  def
Line 106  def
    0 sendln     0 sendln
    (<html>) sendln     (<html>) sendln
    (Shutdown the engine. <br>) sendln     (Shutdown the engine. <br>) sendln
    (See you! <a href="http://www.openxm.org"> Web/sm1 </a>) sendln     (See you! <a href="http://www.openxm.org"> Web/asir, Web/sm1 </a>) sendln
    (</html>) sendln     (</html>) sendln
    0 sendln     0 sendln
    [(flush)] extension     [(flush)] extension
Line 127  def
Line 140  def
    %%(<img src="hoge.jpeg"> <img>) sendln %%test.  It does not work always?!     %%(<img src="hoge.jpeg"> <img>) sendln %%test.  It does not work always?!
    %%(<a href="hoge.jpeg"> Pretty format </a>) sendln %%test. It works.     %%(<a href="hoge.jpeg"> Pretty format </a>) sendln %%test. It works.
   
    (<FORM NAME="myFORM">) sendln    [(getenv) (OXWEB_POST)] extension tag 0 eq {
       (<FORM NAME="myFORM">) sendln  % use get
     }{
       (<FORM NAME="myFORM" METHOD="POST">) sendln
     } ifelse
    (<INPUT TYPE=submit VALUE="submit">) sendln     (<INPUT TYPE=submit VALUE="submit">) sendln
    [(<textarea name=) httpd.textarea.name     [(<textarea name=) httpd.textarea.name
     ( rows=10 cols="80" wrap="soft"></textarea>)] cat sendln      ( rows=10 cols="80" wrap="soft"></textarea>)] cat sendln
Line 284  def
Line 301  def
         ss i (,) put          ss i (,) put
       } {  } ifelse        } {  } ifelse
     } for      } for
     ss message      httpd.debug { ss message } {  } ifelse
     [ ss to_records pop] /arg1 set      [ ss to_records pop] /arg1 set
   ] pop    ] pop
   popVariables    popVariables
Line 318  def
Line 335  def
   arg1    arg1
 } def  } def
   
 %% remove GET /?msg=  %% remove GET /?msg= or msg=
 /removeGET {  /removeGET {
   /arg1 set    /arg1 set
   [/in-removeGET /s /s2 /i /j /i0    [/in-removeGET /s /s2 /i /j /i0
    /tname     /tname  /nnn /sta
   ] pushVariables    ] pushVariables
   [    [
      /s arg1 def       /s arg1 def
      /httpd.textarea.valid 1 def       /httpd.textarea.valid 0 def
      s 1 copy /s2 set       s 1 copy /s2 set
      s (array) dc /s set       s (array) dc /s set
   
        /sta 0 def
   
        %% In case of POST, remove the HTTP header. cf. trouble for NS 6.0
        s length 4 gt {
          [s 0 get s 1 get s 2 get s 3 get] (POST) (array) dc eq {
             0 1 s length 4 sub {
                /i0 set
                /sta i0 def
                [ s i0 get  s i0 1 add get ] [ 10 10 ] eq
                [ s i0 get  s i0 1 add get s i0 2 add get s i0 3 add get]
                [ 13 10 13 10] eq or
                { exit } { } ifelse
             } for
           }{ } ifelse
        } { } ifelse
        (sta=) messagen sta message
        /nnn httpd.textarea.name.aaa length 6 sub def
   
      /tname  [  ] def       /tname  [  ] def
      0 1 s length 1 sub {       sta 1 s length 1 sub {
        /i0 set         /i0 set
        s i0 get 61 eq {  %% 61 is =         s i0 get 61 eq {  %% 61 is =
          i0 1 add /i0 set           i0 1 add /i0 set
          tname message  
          httpd.textarea.name.aaa message           [
             << tname length 1 sub  >> -1
             << tname length nnn sub >> dup 0 ge { } { pop 0 } ifelse
             {
                /i set
                tname i get
             } for
            ] reverse /tname set
            (GET /?) (array) dc tname join /tname set
   
            httpd.debug { httpd.textarea.name.aaa message } {  } ifelse
          tname httpd.textarea.name.aaa eq {           tname httpd.textarea.name.aaa eq {
            /httpd.textarea.valid 1 def             /httpd.textarea.valid 1 def
          } {           } {
            /httpd.textarea.valid 0 def             /httpd.textarea.valid 0 def
              tname message
              httpd.textarea.name.aaa { (string) dc } map cat message
            (Warning: got an invalid name for the text field.) message             (Warning: got an invalid name for the text field.) message
          } ifelse           } ifelse
          exit           exit
Line 352  def
Line 399  def
      i0 1 s length 1 sub {       i0 1 s length 1 sub {
        /i set         /i set
        s2 j << s i get (string) dc >> put         s2 j << s i get (string) dc >> put
          j s2 length 1 sub lt { s2 j 1 add ( ) put } { } ifelse
          %% might cause a BUG. It should be improved.
        j 1 add /j set         j 1 add /j set
      } for       } for
      /arg1 s2 def       /arg1 s2 def
Line 498  def
Line 547  def
    ] pop     ] pop
    popVariables     popVariables
    arg1     arg1
   } def
   
   % This function will be written in C in a future.
   % [(httpd) (parseHTTP) string] extension
   % [(GET) key-value-pair-1 key-value-pair-2 ...]
   % [(POST) key-value-pair-1 key-value-pair-2 ...]
   % [(GET-file) file-1 file2 ...]
   % ex. (GET / HTT..) (GET /?rpc=1-2)
   /httpd.parse {
    /arg1 set
    [/in-httpd.parse /s /s2 /sta /i0
     /ans /getKeyword /j /tname /tvalue
    ] pushVariables
    [
        /s arg1 def
        s 1 copy /s2 set
        s (array) dc /s set
   
        /sta 0 def
        /getKeyword 0 def
   
        s length 7 lt {
           /ans [(GET-file)] def
           /httpd.exit goto
        }{ } ifelse
   
        /ans [(GET)] def
        [s 0 get s 1 get s 2 get s 3 get s 4 get s 5 get] (GET /?) (array) dc eq {
           /sta 6 def
           /getKeyword 1 def
        }{
           [s 0 get s 1 get s 2 get s 3 get s 4 get] (GET /) (array) dc eq {
               /sta 5 def
           }{
             [s 0 get s 1 get s 2 get s 3 get] (GET ) (array) dc eq {
                /ans [(GET-file)] def
                /httpd.exit goto
             }  { /ans [ ] def /httpd.exit.goto } ifelse
           } ifelse
        }ifelse
   
        %% In case of POST, remove the HTTP header. cf. trouble for NS 6.0
        [s 0 get s 1 get s 2 get s 3 get] (POST) (array) dc eq {
             /ans [(POST) ] def
             /getKeyword  1 def
             0 1 s length 4 sub {
                /i0 set
                /sta i0 def
                [ s i0 get  s i0 1 add get ] [ 10 10 ] eq
                [ s i0 get  s i0 1 add get s i0 2 add get s i0 3 add get]
                [ 13 10 13 10] eq or
                { exit } { } ifelse
             } for
        }{ } ifelse
        (sta=) messagen sta message
   
        %% get file name
        getKeyword not {
          /tname  [  ] def
          sta 1 << s length 1 sub >> {
            /i0 set
            s i0 get 32 le {  %% 32 is  " "
              exit
            } { } ifelse
            tname s i0 get append /tname set
          } for
          httpd.debug { (Filename is ) messagen tname {(string) dc } map message} {  } ifelse
          /ans [(GET-file) tname { (string) dc } map cat ] def
          /httpd.exit goto
        } { } ifelse
   
        /tname  [  ] def
        sta 1 << s length 1 sub >> {
          /i0 set
          s i0 get 61 eq {  %% 61 is =
            httpd.debug { tname message tname {(string) dc } map cat message} {  } ifelse
            i0 1 add /i0 set
            exit
          } { } ifelse
          tname s i0 get append /tname set
        } for
   
        /j 0 def
        i0 1 s length 1 sub {
          /i set
          s2 j << s i get (string) dc >> put
          j s2 length 1 sub lt { s2 j 1 add ( ) put } { } ifelse
          %% might cause a BUG. It should be improved.
          j 1 add /j set
        } for
        ans [tname {(string) dc} map  cat
              s2 webstringToAscii ] append
        /ans set
   
        /httpd.exit
        /arg1 ans def
    ] pop
    popVariables
    arg1
 } def  } def
   

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.13

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>