xmaxima on CMUCL



Here is a version of server.lisp, which works on cmucl. To use it with
xmaxima, change in bin/xmaxima the line

set ws_openMath(localMaximaServer) "[file join $ws_openMath(maximaPath)
src/saved_maxima] -load [file join $ws_openMath(maximaPath) src/server.lisp] -eval \"(setup PORT)\" &"

to

set ws_openMath(localMaximaServer) "lisp -core [file join $ws_openMath(maximaPath) src/maxima.core] -load [file join $ws_openMath(maximaPath) src/server-new.lisp] -eval \"(setup PORT)\" &"

--------------------------------------------------

;; very simple server started on port

(and (find-package "MAXIMA") (push :maxima *features*))

#+maxima
(in-package "MAXIMA")

;;; from CLOCC: <http://clocc.sourceforge.net>;
(defun open-socket (host port &optional bin)
  "Open a socket connection to HOST at PORT."
  (declare (type (or integer string) host) (fixnum port) (type boolean bin))
  (let ((host (etypecase host
                (string host)
                (integer (hostent-name (resolve-host-ipaddr host))))))
    #+allegro (socket:make-socket :remote-host host :remote-port port
                                  :format (if bin :binary :text))
    #+clisp (lisp:socket-connect port host :element-type
                                 (if bin '(unsigned-byte 8) 'character))

    #+cmu (sys:make-fd-stream (ext:connect-to-inet-socket host port)
                              :input t :output t :element-type
                              (if bin '(unsigned-byte 8) 'character))
    #+gcl (si:make-socket-stream host port bin) ; FIXME
    #+lispworks (comm:open-tcp-stream host port :direction :io :element-type
                                      (if bin 'unsigned-byte 'base-char))
    #-(or allegro clisp cmu gcl lispworks)
    (error 'not-implemented :proc (list 'open-socket host port bin))))

(defun user::setup ( port &optional (host "localhost"))
  (let* ((sock (open-socket host port)))
    (setq me sock)
    (setq *socket-connection* me)
    (setq *standard-input* me)
    (setq *standard-output* me)
    (setq *error-output* me)
    (setq *terminal-io* me)
    (format t "pid=~a~%"
            #+cmu (unix:unix-getpid)
            #+gcl (si::getpid)
            #-(or cmu gcl) (error 'not-emplemented 'getpid))
    (setq *debug-io* me)
    ))

#+maxima
(progn
(setq $in_netmath t)
(setq $show_openplot nil))