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

Diff of /clhp/mod_clhp.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.2 by aventimiglia, Wed Nov 12 01:31:25 2003 UTC revision 1.3 by aventimiglia, Wed Nov 12 20:44:38 2003 UTC
# Line 33  Line 33 
33  #define HUGE_STRING_LEN 65000  #define HUGE_STRING_LEN 65000
34  #endif  #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 {  typedef struct _child {
45    request_rec *req;    request_rec *req;
46  } child_stuff;  } child_stuff;
# Line 45  static int run_lisp ( void *void_child_s Line 53  static int run_lisp ( void *void_child_s
53                                         child->req->subprocess_env );                                         child->req->subprocess_env );
54    int child_pid;    int child_pid;
55    
56    child->req->args = ap_pstrdup ( child->req->pool,  #ifndef BROKEN_AP_CALL_EXEC
57                                    "-noinit -quiet -core /usr/lib/cmucl/clhp.core" );    child->req->args = ap_psprintf ( child->req->pool, "%s %s %s", LISP_OPTIONS,
58                                       LISP_CORE, LISP_EVAL );
59    ap_cleanup_for_exec ();    ap_cleanup_for_exec ();
60    child_pid = ap_call_exec ( child->req, pinfo, "/usr/bin/lisp", env, 1 );    child_pid = ap_call_exec ( child->req, pinfo, LISP_COMMAND, env, 1 );
61    #else
62    return (0);    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  static void send_to_lisp ( BUFF *out_buffer, const char *str )    child_pid = ap_call_exec ( child->req, pinfo, command, env, 1 );
66  {  #endif
67    ap_bwrite ( out_buffer, str, strlen ( str ));  
68    ap_bflush ( out_buffer );  #ifdef WIN32
69  }    return ( child_pid );
70    #else
71  static void close_lisp ( BUFF *out_buff )    exit ( 0 );
72  {    // Should not get here
73    send_to_lisp ( out_buff, "(quit)" );    return 0;
74    #endif
75  }  }
76    
77  static int Handler ( request_rec *req )  static int Handler ( request_rec *req )
# Line 70  static int Handler ( request_rec *req ) Line 79  static int Handler ( request_rec *req )
79    BUFF *lisp_out, *lisp_in;    BUFF *lisp_out, *lisp_in;
80    child_stuff child;    child_stuff child;
81    
   req->content_type = "text/plain";  
   ap_send_http_header ( req );  
   
82    ap_add_common_vars ( req );    ap_add_common_vars ( req );
83    ap_add_cgi_vars ( req );    ap_add_cgi_vars ( req );
84    child.req = req;    child.req = req;
# Line 81  static int Handler ( request_rec *req ) Line 87  static int Handler ( request_rec *req )
87                             kill_always, &lisp_out, &lisp_in, NULL ))                             kill_always, &lisp_out, &lisp_in, NULL ))
88      return HTTP_INTERNAL_SERVER_ERROR;      return HTTP_INTERNAL_SERVER_ERROR;
89    
90    ap_hard_timeout ( "Hard Timeout", req );    // 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 );  
91    ap_bclose ( lisp_out );    ap_bclose ( lisp_out );
   
92    ap_send_fb ( lisp_in, req );    ap_send_fb ( lisp_in, req );
93    ap_bclose ( lisp_in );    ap_bclose ( lisp_in );
   
   ap_rputs ( "Done", req );  
94    ap_child_terminate ( req );    ap_child_terminate ( req );
95    
96    return OK;    return OK;

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

  ViewVC Help
Powered by ViewVC 1.1.5