Update of /project/clhp/cvsroot/clhp In directory common-lisp.net:/tmp/cvs-serv7108
Modified Files: mod_clhp.c Log Message: Got the module working !!! it needs refining, but it works !!!! Now it's time to cook.
Date: Wed Nov 12 15:44:38 2003 Author: aventimiglia
Index: clhp/mod_clhp.c diff -u clhp/mod_clhp.c:1.2 clhp/mod_clhp.c:1.3 --- clhp/mod_clhp.c:1.2 Tue Nov 11 20:31:25 2003 +++ clhp/mod_clhp.c Wed Nov 12 15:44:38 2003 @@ -1,4 +1,4 @@ -/* $Id: mod_clhp.c,v 1.2 2003/11/12 01:31:25 aventimiglia Exp $ +/* $Id: mod_clhp.c,v 1.3 2003/11/12 20:44:38 aventimiglia Exp $
CLHP the Common Lisp Hypertext Preprocessor (C) 2003 Anthony J Ventimiglia @@ -33,6 +33,14 @@ #define HUGE_STRING_LEN 65000 #endif
+// AP_CALL_EXEC does not properly pass it's arguments +#define BROKEN_AP_CALL_EXEC 1 + +#define LISP_COMMAND "/usr/bin/lisp" +#define LISP_OPTIONS "-noinit -nositeinit -quiet -batch" +#define LISP_CORE "-core /usr/lib/cmucl/clhp.core" +#define LISP_EVAL "-eval '(clhp:parse (cdr (assoc :script_filename ext:*environment-list*)))(quit)'" + typedef struct _child { request_rec *req; } child_stuff; @@ -45,24 +53,25 @@ child->req->subprocess_env ); int child_pid;
- child->req->args = ap_pstrdup ( child->req->pool, - "-noinit -quiet -core /usr/lib/cmucl/clhp.core" ); - +#ifndef BROKEN_AP_CALL_EXEC + child->req->args = ap_psprintf ( child->req->pool, "%s %s %s", LISP_OPTIONS, + LISP_CORE, LISP_EVAL ); ap_cleanup_for_exec (); - child_pid = ap_call_exec ( child->req, pinfo, "/usr/bin/lisp", env, 1 ); - - return (0); -} - -static void send_to_lisp ( BUFF *out_buffer, const char *str ) -{ - ap_bwrite ( out_buffer, str, strlen ( str )); - ap_bflush ( out_buffer ); -} - -static void close_lisp ( BUFF *out_buff ) -{ - send_to_lisp ( out_buff, "(quit)" ); + child_pid = ap_call_exec ( child->req, pinfo, LISP_COMMAND, env, 1 ); +#else + char *command = ap_psprintf (child->req->pool, "%s %s %s %s", LISP_COMMAND, + LISP_OPTIONS, LISP_CORE, LISP_EVAL ); + ap_cleanup_for_exec (); + child_pid = ap_call_exec ( child->req, pinfo, command, env, 1 ); +#endif + +#ifdef WIN32 + return ( child_pid ); +#else + exit ( 0 ); + // Should not get here + return 0; +#endif }
static int Handler ( request_rec *req ) @@ -70,9 +79,6 @@ BUFF *lisp_out, *lisp_in; child_stuff child;
- req->content_type = "text/plain"; - ap_send_http_header ( req ); - ap_add_common_vars ( req ); ap_add_cgi_vars ( req ); child.req = req; @@ -81,25 +87,10 @@ kill_always, &lisp_out, &lisp_in, NULL )) return HTTP_INTERNAL_SERVER_ERROR;
- ap_hard_timeout ( "Hard Timeout", req ); - - // Debugging output - ap_rputs ( "-----------------\n", child.req ); - ap_rprintf ( child.req, "ARGS: %s\n-------------\n", child.req->args ); - - - send_to_lisp ( lisp_out, "(mapcar #'print ext:*command-line-strings*)"); - send_to_lisp ( lisp_out, "(progn (loop for f from 1 to 50 do (format t "-")) (terpri))" ); - send_to_lisp ( lisp_out, "(mapcar #'print ext:*environment-list*)" ); - - - close_lisp ( lisp_out ); + // ap_hard_timeout ( "Hard Timeout", req ); ap_bclose ( lisp_out ); - ap_send_fb ( lisp_in, req ); ap_bclose ( lisp_in ); - - ap_rputs ( "Done", req ); ap_child_terminate ( req );
return OK;