axiom-developer
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Axiom-developer] 20071020.01.acr.patch


From: daly
Subject: [Axiom-developer] 20071020.01.acr.patch
Date: Sat, 20 Oct 2007 22:55:36 -0500

This patch changes the AJAX communication to use the new return values
for new hyperdoc.

==========================================================================
diff --git a/changelog b/changelog
index ea3d202..74bd7c2 100644
--- a/changelog
+++ b/changelog
@@ -1,3 +1,5 @@
+20071019 acr src/interp/http.lisp use new return values
+20071019 acr src/algebra/axserver.spad use new return values
 20071014 acr src/algebra/axserver.spad use getContentType(pathvar)
 20071013 acr license/license.ralfs license rewrite
 20071013 acr src/interp/http.lisp faster page service
diff --git a/src/algebra/axserver.spad.pamphlet 
b/src/algebra/axserver.spad.pamphlet
index 741840f..ead58da 100644
--- a/src/algebra/axserver.spad.pamphlet
+++ b/src/algebra/axserver.spad.pamphlet
@@ -11,22 +11,6 @@ to axiom.
 \eject
 \tableofcontents
 \eject
-\section{Running Axiom Server}
-
-Put the extracted files in a suitable directory, like the one you
-started Axiom from, and issue the commands:
-
-\begin{verbatim}
-)set message autoload off
-)set output mathml on
-axServer(8085,multiServ$AXSERV)
-\end{verbatim}
-
-Of course you need a mathml enabled build of axiom to do this.
-
-Once you've done this Axiom will be in a wait loop on a socket
-listening on port 8085. You can connect to this port by sending 
-the browser to the URL.
 \section{Axiom Server}
 <<package AXSERV AxiomServer>>=
 
@@ -58,48 +42,45 @@ AxiomServer: public == private where
        if not null?(SiListen(s)$Lisp)$SExpression then
          w := SiAccept(s)$Lisp
          serverfunc(w)
---         i := 0
+--        i := 0
 
    multiServ(s:SExpression):Void ==
          WriteLine("multiServ begin")$Lisp
          headers:String := ""
          char:String
          -- read in the http headers
-         while (_
-          char := STRING(READ_-CHAR_-NO_-HANG(s,NIL$Lisp,'EOF)$Lisp)$Lisp)_
-           ^= "EOF" repeat
+         while (char := 
STRING(READ_-CHAR_-NO_-HANG(s,NIL$Lisp,'EOF)$Lisp)$Lisp) ^= "EOF" repeat
              headers := concat [headers,char]
-        WriteLine(headers)$Lisp
+         sayTeX$Lisp headers
          StringMatch("([^ ]*)", headers)$Lisp
          u:UniversalSegment(Integer)
-         u := segment(MatchBeginning(1)$Lisp+1,_
-                      MatchEnd(1)$Lisp)$UniversalSegment(Integer)
+         u := 
segment(MatchBeginning(1)$Lisp+1,MatchEnd(1)$Lisp)$UniversalSegment(Integer)
          reqtype:String := headers.u
-         WriteLine$Lisp  concat ["request type: ",reqtype]
+         sayTeX$Lisp  concat ["request type: ",reqtype]
          if  reqtype = "GET" then
              StringMatch("GET ([^ ]*)",headers)$Lisp
              u:UniversalSegment(Integer)
-             u := segment(MatchBeginning(1)$Lisp+1,_
-                          MatchEnd(1)$Lisp)$UniversalSegment(Integer)
+             u := 
segment(MatchBeginning(1)$Lisp+1,MatchEnd(1)$Lisp)$UniversalSegment(Integer)
              getFile(s,headers.u)
          if reqtype = "POST" then
              StringMatch("command=(.*)$",headers)$Lisp
              u:UniversalSegment(Integer)
-             u := segment(MatchBeginning(1)$Lisp+1,_
-                          MatchEnd(1)$Lisp)$UniversalSegment(Integer)
+             u := 
segment(MatchBeginning(1)$Lisp+1,MatchEnd(1)$Lisp)$UniversalSegment(Integer)
              getCommand(s,headers.u)
          WriteLine("multiServ end")$Lisp
-        WriteLine("")$Lisp
+         WriteLine("")$Lisp
 
    getFile(s:SExpression,pathvar:String):Void ==
        WriteLine("")$Lisp
-       WriteLine("getFile begin")$Lisp
+       WriteLine("getFile")$Lisp
        if not null? PATHNAME_-NAME(PATHNAME(pathvar)$Lisp)$Lisp then
+       -- display contents of file
+       --first determine Content-Type from file extension
            contentType:String := getContentType(pathvar)
-          q := Open(pathvar)$Lisp
-          if null? q then
-            q := MAKE_-STRING_-INPUT_-STREAM("File doesn't exist")$Lisp
-            WriteLine("File does not exist.")$Lisp
+           q:=Open(pathvar)$Lisp
+           if null? q then
+             q := MAKE_-STRING_-INPUT_-STREAM("File doesn't exist")$Lisp
+             WriteLine("File does not exist.")$Lisp
        else
            q:=MAKE_-STRING_-INPUT_-STREAM("Problem with file path")$Lisp
        file:String := ""
@@ -109,13 +90,11 @@ AxiomServer: public == private where
        filestream:String := GET_-OUTPUT_-STREAM_-STRING(r)$Lisp
        CLOSE(r)$Lisp
        CLOSE(q)$Lisp
-       filelength:String := string(#filestream)
        WriteLine("end reading file")$Lisp
-       file := concat ["Content-Length: ",filelength,_
-                STRING(NewLine$Lisp)$Lisp,STRING(NewLine$Lisp)$Lisp,file]
+       filelength:String := string(#filestream)
+       file := concat ["Content-Length: 
",filelength,STRING(NewLine$Lisp)$Lisp,STRING(NewLine$Lisp)$Lisp,file]
        file := concat ["Connection: close",STRING(NewLine$Lisp)$Lisp,file]
-       file := concat ["Content-Type: ",contentType,_
-                STRING(NewLine$Lisp)$Lisp,file]
+       file := concat ["Content-Type: 
",contentType,STRING(NewLine$Lisp)$Lisp,file]
        file := concat ["HTTP/1.1 200 OK",STRING(NewLine$Lisp)$Lisp,file]
        file := concat [file,filestream]
        f:=MAKE_-STRING_-INPUT_-STREAM(file)$Lisp
@@ -135,45 +114,32 @@ AxiomServer: public == private where
        SETQ(_$algebraOutputStream$Lisp,tmpalgebra$Lisp)$Lisp
 --      parseAndInterpret$Lisp command
 --      parseAndEvalStr$Lisp command
--- The previous two commands don't exit nicely when a syntactically 
--- incorrect command is given to them.  They somehow need to be wrapped 
--- in CATCH statements but I haven't figured out how to do this.  
--- parseAndEvalToStringEqNum  uses the following CATCH statements to call 
--- parseAndEvalStr but when I try these they don't work.  I get a
--- "NIL is not a valid identifier to use in AXIOM" message. Using 
--- parseAndEvalToStringEqNum works and doesn't crash on a syntax error.
---        v := CATCH('SPAD__READER, _
---             CATCH('top__level, parseAndEvalStr$Lisp command)$Lisp)$Lisp
+-- The previous two commands don't exit nicely when a syntactically incorrect 
command is
+-- given to them.  They somehow need to be wrapped in CATCH statements but I 
haven't
+-- figured out how to do this.  parseAndEvalToStringEqNum  uses the following 
CATCH
+-- statements to call parseAndEvalStr but when I try these they don't work.  I 
get a
+-- "NIL is not a valid identifier to use in AXIOM" message. Using 
parseAndEvalToStringEqNum
+-- works and doesn't crash on a syntax error.
+--        v := CATCH('SPAD__READER, CATCH('top__level, parseAndEvalStr$Lisp 
command)$Lisp)$Lisp
 --        v = 'restart => ['"error"]
        ans := string parseAndEvalToStringEqNum$Lisp command
-       SETQ(resultmathml$Lisp,_
-         GET_-OUTPUT_-STREAM_-STRING(_$texOutputStream$Lisp)$Lisp)$Lisp
-       SETQ(resultalgebra$Lisp,_
-         GET_-OUTPUT_-STREAM_-STRING(_$algebraOutputStream$Lisp)$Lisp)$Lisp
+       
SETQ(resultmathml$Lisp,GET_-OUTPUT_-STREAM_-STRING(_$texOutputStream$Lisp)$Lisp)$Lisp
+       
SETQ(resultalgebra$Lisp,GET_-OUTPUT_-STREAM_-STRING(_$algebraOutputStream$Lisp)$Lisp)$Lisp
        SETQ(_$texOutputStream$Lisp,savemathml$Lisp)$Lisp
        SETQ(_$algebraOutputStream$Lisp,savealgebra$Lisp)$Lisp
        CLOSE(tmpmathml$Lisp)$Lisp
        CLOSE(tmpalgebra$Lisp)$Lisp
-       -- Since strings returned from axiom are going to be 
-       -- displayed in html I
-       -- should really check for the characters &,<,> and 
-       -- replace them with
-       -- &amp;,&lt;,&gt;.  At present I only check for ampersands in
-       -- formatMessages.  MathML should already be valid xml.
+       -- Since strings returned from axiom are going to be displayed in html I
+       -- should really check for the characters &,<,> and replace them with
+       -- &amp;,&lt;,&gt;.  At present I only check for ampersands in 
formatMessages.
        mathml:String := string(resultmathml$Lisp)
        algebra:String := string(resultalgebra$Lisp)
        algebra := formatMessages(algebra)
-       -- At this point mathml contains the mathml for the 
-       -- output but does not
-       -- include step number or type information.  
-       -- We should also save the command.
+       -- At this point mathml contains the mathml for the output but does not
+       -- include step number or type information.  We should also save the 
command.
        -- I get the type and step number from the $internalHistoryTable
-       axans:String := concat _
-         ["<div><div class=_"command_">(",lastStep(),") -> ",_
-           command,"</div><div class=_"algebra_">",_
-           algebra,"</div><div class=_"mathml_">",_
-           mathml,"</div><div class=_"type_">Type: ",_
-           lastType(),"</div></div>"]
+--       axans:String := concat ["<div><div class=_"command_">(",lastStep(),") 
-> ",command,"</div><div class=_"algebra_">",algebra,"</div><div 
class=_"mathml_">",mathml,"</div><div class=_"type_">Type: 
",lastType(),"</div></div>"]
+       axans:String := concat ["<div class=_"stepnum_">", lastStep(), 
"</div><div class=_"command_">", command, "</div><div 
class=_"algebra_">",algebra,"</div><div class=_"mathml_">",mathml,"</div><div 
class=_"type_">",lastType(),"</div>"]       
        WriteLine$Lisp concat ["mathml answer: ",mathml]
        WriteLine$Lisp concat ["algebra answer: ",algebra]
        q:=MAKE_-STRING_-INPUT_-STREAM(axans)$Lisp
@@ -183,15 +149,12 @@ AxiomServer: public == private where
 
 
    lastType():String ==
---  The last history entry is the first item in the 
--- $internalHistoryTable list so
+--  The last history entry is the first item in the $internalHistoryTable list 
so
 --  car(_$internalHistoryTable$Lisp) selects it.  Here's an example:
---  (3 (x+y)**3 (% (value (Polynomial (Integer)) WRAPPED 1 y 
---    (3 0 . 1) (2 1 x (1 0 . 3)) (1 1 x (2 0 . 3)) (0 1 x (3 0 . 1)))))
---  This corresponds to the input "(x+y)**3" being issued 
--- as the third command after
+--  (3 (x+y)**3 (% (value (Polynomial (Integer)) WRAPPED 1 y (3 0 . 1) (2 1 x 
(1 0 . 3)) (1 1 x (2 0 . 3)) (0 1 x (3 0 . 1)))))
+--  This corresponds to the input "(x+y)**3" being issued as the third command 
after
 --  starting axiom.  The following line selects the type information.
-       string cadr(cadar(cddar(_$internalHistoryTable$Lisp)$Lisp)$Lisp)$Lisp
+       string 
car(cdr(car(cdr(car(cdr(cdr(car(_$internalHistoryTable$Lisp)$Lisp)$Lisp)$Lisp)$Lisp)$Lisp)$Lisp)$Lisp)$Lisp
 
 
    lastStep():String ==
@@ -230,11 +193,10 @@ AxiomServer: public == private where
        -- need to test for successful match?
        StringMatch(".*\.(.*)$", pathvar)$Lisp
        u:UniversalSegment(Integer)
-       u := segment(MatchBeginning(1)$Lisp+1,_
-                    MatchEnd(1)$Lisp)$UniversalSegment(Integer)
+       u := 
segment(MatchBeginning(1)$Lisp+1,MatchEnd(1)$Lisp)$UniversalSegment(Integer)
        extension:String := pathvar.u
        WriteLine$Lisp concat ["file extension: ",extension]
-       -- test for extensions: html, htm, xml, xhtml, js, css, png, jpg, jpeg
+       -- test for extensions: html, htm, xml, xhtml, js, css
        if extension = "html" then
            contentType:String := "text/html"
        else if extension = "htm" then
@@ -257,8 +219,6 @@ AxiomServer: public == private where
        WriteLine("getContentType end")$Lisp
        contentType
 
-
-
 @
         
 \section{License}
@@ -278,9 +238,9 @@ AxiomServer: public == private where
 --      the documentation and/or other materials provided with the
 --      distribution.
 --
---    - The name of Arthur C. Ralfs may not be used to endorse or promote 
---      products derived from this software without specific prior written 
---      permission.
+--    - Neither the name of Arthur C. Ralfs nor the
+--      names of its contributors may be used to endorse or promote products
+--      derived from this software without specific prior written permission.
 --
 --THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
 --IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
@@ -294,7 +254,6 @@ AxiomServer: public == private where
 --NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 --SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
-
 @
 
 <<*>>=
diff --git a/src/interp/http.lisp b/src/interp/http.lisp
index 6feb283..0b264bf 100644
--- a/src/interp/http.lisp
+++ b/src/interp/http.lisp
@@ -4,23 +4,45 @@
   (si::open path :direction :input :if-exists nil :if-does-not-exist nil)
   )
 
+(defvar |StandardOutput| *standard-output*)
 
 (defvar  |NewLine| '#\NewLine)
 
 ;; some regexp stuff
 
-(defun |StringMatch| (s1 s2) (si::string-match s1 s2))
-(defun |ListMatches| (&rest args) (si::list-matches args))
-(defun |MatchBeginning| (i) (si::match-beginning i))
-(defun |MatchEnd| (i) (si::match-end i))
+(defun |StringMatch| (s1 s2)
+ (si::string-match s1 s2)
+ )
+
+(defun |ListMatches| (&rest args)
+ (si::list-matches args)
+ )
+
+(defun |MatchBeginning| (i)
+ (si::match-beginning i)
+ )
+
+(defun |MatchEnd| (i)
+ (si::match-end i)
+ )
 
 ;; the socket stuff
 
 (defun |SiSock| (p spadfn)
-  (si::socket p :server
-   (function (lambda (w) (SPADCALL w spadfn) )) :daemon nil))
-
-(defun |SiListen| (s) (si::listen s))
+;;  (format t "SiSocket-1")
+ (si::socket p :server
+             (function
+              (lambda (w) (SPADCALL w spadfn) )
+              )
+             :daemon nil)
+ )
+
+(defun |SiListen| (s)
+;;  (format t "SiListen-1")
+ (si::listen s)
+ )
 (defun |SiAccept| (s) (si::accept s))
 (defun |SiCopyStream| (q s) (si::copy-stream q s))
 
+
+




reply via email to

[Prev in Thread] Current Thread [Next in Thread]