/[clhp]/clhp/mod_clhp.c
ViewVC logotype

Contents of /clhp/mod_clhp.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.4 - (show annotations)
Wed Nov 12 21:57:40 2003 UTC (10 years, 5 months ago) by aventimiglia
Branch: MAIN
CVS Tags: rel-0-2-0alpha
Changes since 1.3: +2 -2 lines
File MIME type: text/plain
changed name of clhp handler to clhp-handler for Apache coinfig
1 /* $Id: mod_clhp.c,v 1.4 2003/11/12 21:57:40 aventimiglia Exp $
2
3 CLHP the Common Lisp Hypertext Preprocessor
4 (C) 2003 Anthony J Ventimiglia
5
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
10
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public
17 License along with this library; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
20 email: aventimiglia@common-lisp.net
21 HomePage: http://common-lisp.net/project/clhp/
22
23 Apache module for clhp
24 */
25
26 #include "httpd.h"
27 #include "http_config.h"
28 #include "http_protocol.h"
29 #include "util_script.h"
30 #include <string.h>
31
32 #ifndef HUGE_STRING_LEN
33 #define HUGE_STRING_LEN 65000
34 #endif
35
36 // AP_CALL_EXEC does not properly pass it's arguments
37 #define BROKEN_AP_CALL_EXEC 1
38
39 #define LISP_COMMAND "/usr/bin/lisp"
40 #define LISP_OPTIONS "-noinit -nositeinit -quiet -batch"
41 #define LISP_CORE "-core /usr/lib/cmucl/clhp.core"
42 #define LISP_EVAL "-eval '(clhp:parse (cdr (assoc :script_filename ext:*environment-list*)))(quit)'"
43
44 typedef struct _child {
45 request_rec *req;
46 } child_stuff;
47
48 /* Child init, right now this just runs a quick Lisp command */
49 static int run_lisp ( void *void_child_stuff, child_info *pinfo )
50 {
51 child_stuff *child = (child_stuff *) void_child_stuff;
52 char **env = ap_create_environment ( child->req->pool,
53 child->req->subprocess_env );
54 int child_pid;
55
56 #ifndef BROKEN_AP_CALL_EXEC
57 child->req->args = ap_psprintf ( child->req->pool, "%s %s %s", LISP_OPTIONS,
58 LISP_CORE, LISP_EVAL );
59 ap_cleanup_for_exec ();
60 child_pid = ap_call_exec ( child->req, pinfo, LISP_COMMAND, env, 1 );
61 #else
62 char *command = ap_psprintf (child->req->pool, "%s %s %s %s", LISP_COMMAND,
63 LISP_OPTIONS, LISP_CORE, LISP_EVAL );
64 ap_cleanup_for_exec ();
65 child_pid = ap_call_exec ( child->req, pinfo, command, env, 1 );
66 #endif
67
68 #ifdef WIN32
69 return ( child_pid );
70 #else
71 exit ( 0 );
72 // Should not get here
73 return 0;
74 #endif
75 }
76
77 static int Handler ( request_rec *req )
78 {
79 BUFF *lisp_out, *lisp_in;
80 child_stuff child;
81
82 ap_add_common_vars ( req );
83 ap_add_cgi_vars ( req );
84 child.req = req;
85
86 if ( ! ap_bspawn_child ( req->pool, run_lisp, (void *) &child,
87 kill_always, &lisp_out, &lisp_in, NULL ))
88 return HTTP_INTERNAL_SERVER_ERROR;
89
90 // ap_hard_timeout ( "Hard Timeout", req );
91 ap_bclose ( lisp_out );
92 ap_send_fb ( lisp_in, req );
93 ap_bclose ( lisp_in );
94 ap_child_terminate ( req );
95
96 return OK;
97 }
98
99
100 // Associate the handler with Handler String
101 static handler_rec Handlers[] =
102 {
103 { "clhp-handler", Handler },
104 { NULL }
105 };
106
107 module clhp_module = {
108 STANDARD_MODULE_STUFF,
109 NULL, /* Initializer */
110 NULL, /* dir_config creator */
111 NULL, /* dir merger */
112 NULL, /* server config */
113 NULL, /* merge server configs */
114 NULL, /* command-table */
115 Handlers, /* handlers */
116 NULL, /* Filename translation */
117 NULL, /* check user ID */
118 NULL, /* Check auth */
119 NULL, /* Check Access */
120 NULL, /* type checker */
121 NULL, /* Fixups */
122 NULL, /* logger */
123 NULL, /* Header Parser */
124 NULL, /* child init */
125 NULL, /* child exit */
126 NULL, /* post read request */
127 };
128

  ViewVC Help
Powered by ViewVC 1.1.5