;;; -*- Mode: Lisp ; Base: 10 ; Syntax: ANSI-Common-Lisp -*-;;;; Trivial SEXP server.;; BIG FAT WARNING!!!!;; safe-read is subject to DoS attacks whereby attackers force the server;; to intern a lot of useless symbols until it runs out of memory.;; THIS NOT FOR USE IN THE WILD! Only on safe (virtual) private networks.;;;; If you want a robust server, you'll have to supply your own robust parser.;; And handle all kind of weird issues such as handling character encoding,;; not to speak about avoiding extra consing for performance.;; I recommend then trying UDF-A.(in-package:philip-jose)(defparameter*request-heads*(make-hash-table:test#'equal))(def*funregister-request-head(xfunc)(setf(gethashx*request-heads*)func))(def*macrodefun-request-handler(nameformals&bodybody)`(progn(defun,name,formals,@body)(register-request-head,(conc-keywordname)(function,name))))(def*funcall-request-handler(f&restargs)(let((fun(gethashf*request-heads*)))(iffun(applyfunargs)(error"Not a registered request type ~S"f))))(defunhandle-sexp-request(request)(if(consprequest)(apply#'call-request-handlerrequest)(error"Bad request ~S"request)))(defunsexp-request-handler()(handle-sexp-request(safe-read)))(defunhandle-sexp-request-from-stream(i&optional(oi))(let*((*standard-input*i)(*standard-output*o))(sexp-request-handler)))(defunhandle-sexp-request-from-socket(socket)(handle-sexp-request-from-streamsocket))(def*funreply(x)(safe-writex)(princ+crlf+)(finish-output))(def*funreply*(&restx)(replyx))