perl.cvs.mod_parrot
[Top] [All Lists]

[svn:mod_parrot] r368 - in mod_parrot/trunk: . include lib lib/Apache sr

Subject: [svn:mod_parrot] r368 - in mod_parrot/trunk: . include lib lib/Apache src
From: jhorwitz@xxxxxxxxxxxx
Date: Mon, 21 Jul 2008 11:35:57 -0700 (PDT)
Newsgroups: perl.cvs.mod_parrot

Author: jhorwitz
Date: Mon Jul 21 11:35:56 2008
New Revision: 368

Modified:
   mod_parrot/trunk/call_list.txt
   mod_parrot/trunk/include/mod_parrot.h
   mod_parrot/trunk/include/modparrot_config.h
   mod_parrot/trunk/lib/Apache/Module.pir
   mod_parrot/trunk/lib/mod_parrot.pir
   mod_parrot/trunk/src/modparrot_config.c
   mod_parrot/trunk/src/nci.c

Log:
add infrastructure to update mod_parrot directory configs from HLL modules


Modified: mod_parrot/trunk/call_list.txt
==============================================================================
--- mod_parrot/trunk/call_list.txt      (original)
+++ mod_parrot/trunk/call_list.txt      Mon Jul 21 11:35:56 2008
@@ -19,3 +19,4 @@
 v       ptt
 v       Jtiiipt
 p       JtP
+P      Jtti

Modified: mod_parrot/trunk/include/mod_parrot.h
==============================================================================
--- mod_parrot/trunk/include/mod_parrot.h       (original)
+++ mod_parrot/trunk/include/mod_parrot.h       Mon Jul 21 11:35:56 2008
@@ -15,6 +15,9 @@
  * limitations under the License.
  */
 
+#ifndef _MODPARROT_H
+#define _MODPARROT_H
+
 #include "httpd.h"
 #include "http_config.h"
 
@@ -35,14 +38,17 @@
 #define MODPARROT_CTX_LOCK(x) (x->locked = 1)
 #define MODPARROT_CTX_UNLOCK(x) (x->locked = 0)
 
+/* we need to move things around to avoid this */
+#include "modparrot_config.h"
+
 /* per-interpreter context */
 struct modparrot_context
 {
-    Parrot_Interp interp;        /* this context's interpreter */
-    Parrot_Interp parent_interp; /* parent interpreter */
-    long count;                  /* number of interpreter invocations */
-    int locked;                  /* 0=available, 1=in use */
-    request_rec *r;              /* request_rec structure for this request */
+    Parrot_Interp interp;         /* this context's interpreter */
+    Parrot_Interp parent_interp;  /* parent interpreter */
+    long count;                   /* number of interpreter invocations */
+    int locked;                   /* 0=available, 1=in use */
+    request_rec *r;               /* request_rec structure for this request */
     apr_pool_t *pconf;
     apr_pool_t *plog;
     apr_pool_t *ptemp;
@@ -50,6 +56,8 @@
     server_rec *s;
     conn_rec *c;
     void *csd;
+    modparrot_dir_config *dircfg; /* used by HLL directives */
+    modparrot_srv_config *srvcfg; /* used by HLL directives */
 };
 typedef struct modparrot_context modparrot_context;
 
@@ -75,3 +83,5 @@
 void modparrot_load_file(Parrot_Interp, server_rec *, char *, char *);
 module *modparrot_add_module(Parrot_Interp, apr_pool_t *, const char *,
     Parrot_PMC);
+
+#endif /* _MODPARROT_H */

Modified: mod_parrot/trunk/include/modparrot_config.h
==============================================================================
--- mod_parrot/trunk/include/modparrot_config.h (original)
+++ mod_parrot/trunk/include/modparrot_config.h Mon Jul 21 11:35:56 2008
@@ -15,6 +15,9 @@
  * limitations under the License.
  */
 
+#ifndef _MODPARROT_CONFIG_H
+#define _MODPARROT_CONFIG_H
+
 #include "apr_tables.h"
 
 /* per-server options */
@@ -121,6 +124,7 @@
 const char *modparrot_cmd_options(cmd_parms *, void *, const char *);
 
 /* for HLL apache modules */
+const char *modparrot_set_config_ptrs(cmd_parms *, void *);
 const char *modparrot_module_cmd_take1(cmd_parms *, void *, const char *);
 const char *modparrot_module_cmd_take2(cmd_parms *, void *, const char *,
     const char*);
@@ -132,3 +136,5 @@
     const char *, const char*);
 const char *modparrot_module_cmd_take123(cmd_parms *, void *, const char *,
     const char *, const char*);
+
+#endif /* _MODPARROT_CONFIG_H */

Modified: mod_parrot/trunk/lib/Apache/Module.pir
==============================================================================
--- mod_parrot/trunk/lib/Apache/Module.pir      (original)
+++ mod_parrot/trunk/lib/Apache/Module.pir      Mon Jul 21 11:35:56 2008
@@ -36,6 +36,9 @@
     dlfunc func, nul, "mpnci_add_apache_module", "pJtP"
     set_root_global [ '_modparrot'; 'NCI' ], "add_apache_module", func
 
+    dlfunc func, nul, "mpnci_dircfg_handler", "PJtti"
+    set_root_global [ '_modparrot'; 'NCI' ], "dircfg_handler", func
+
     newclass module_class, [ 'Apache'; 'Module' ]
     addattribute module_class, 'module'
 .end
@@ -44,8 +47,6 @@
 
 =over 4
 
-=cut
-
 =item C<add(STRING name, ARRAY cmds)>
 
 =over 4
@@ -134,6 +135,37 @@
     add_module(name, cmds)
 .end
 
+=back
+
+=over 4 
+
+=item C<modparrot_dircfg_handler(STRING hll, STRING id)>
+
+=over 4
+
+Get or set the mod_parrot response handler.
+
+=cut
+
+.sub modparrot_dircfg_handler
+    .param pmc hll :optional
+    .param pmc id :optional
+    .param int update :opt_flag
+    .local pmc func, res
+
+    func = get_root_global ['_modparrot'; 'NCI' ], "dircfg_handler"
+
+    if update goto do_update
+    hll = new 'String'
+    id = new 'String'
+  do_update:
+    res = func(hll, id, update)
+   
+    .return(res)
+.end 
+    
+=back
+
 =head1 AUTHOR
 
 Jeff Horwitz

Modified: mod_parrot/trunk/lib/mod_parrot.pir
==============================================================================
--- mod_parrot/trunk/lib/mod_parrot.pir (original)
+++ mod_parrot/trunk/lib/mod_parrot.pir Mon Jul 21 11:35:56 2008
@@ -78,6 +78,9 @@
     dlfunc func, nul, "mpnci_csd", "pJ"
     set_root_global [ '_modparrot'; 'NCI' ], "csd", func
 
+    dlfunc func, nul, "mpnci_dirconfig", "pJ"
+    set_root_global [ '_modparrot'; 'NCI' ], "modparrot_dirconfig", func
+
     # load required libraries
     load_bytecode 'Protoobject.pbc'
     load_bytecode 'ModParrot/Interpreter.pbc'

Modified: mod_parrot/trunk/src/modparrot_config.c
==============================================================================
--- mod_parrot/trunk/src/modparrot_config.c     (original)
+++ mod_parrot/trunk/src/modparrot_config.c     Mon Jul 21 11:35:56 2008
@@ -582,15 +582,26 @@
     return(args);
 }
 
+static void set_mp_config_vectors(modparrot_context *ctxp, cmd_parms *cmd)
+{
+    modparrot_dir_config *cfg = (modparrot_dir_config *)ap_set_config_vectors(
+        cmd->server, cmd->context, cmd->path, &parrot_module, cmd->pool);
+    ctxp->dircfg = cfg;
+    ctxp->srvcfg = (modparrot_srv_config *)ap_get_module_config(
+        cmd->server->module_config, &parrot_module);
+}
+
 const char *modparrot_module_cmd_take1(cmd_parms *cmd, void *mconfig,
                                        const char *arg)
 {
     modparrot_context *ctxp;
+    Parrot_PMC dircfg;
     Parrot_PMC args;
     modparrot_module_cmd_data *data = cmd->cmd->cmd_data;
     int ret;
 
     ctxp = modparrot_startup(cmd->pool, cmd->server);
+    set_mp_config_vectors(ctxp, cmd);
     args = make_cmd_args_array(ctxp->interp, cmd->pool, 1, arg);
     ret = Parrot_call_sub_ret_int(ctxp->interp, data->func, "IP", args);
     return NULL;

Modified: mod_parrot/trunk/src/nci.c
==============================================================================
--- mod_parrot/trunk/src/nci.c  (original)
+++ mod_parrot/trunk/src/nci.c  Mon Jul 21 11:35:56 2008
@@ -29,6 +29,7 @@
 #include "parrot/extend.h"
 
 #include "mod_parrot.h"
+#include "modparrot_config.h"
 
 #include "../build/src/nci/request_rec.c"
 
@@ -188,3 +189,31 @@
     modp = modparrot_add_module(interp, ctxp->pconf, name, cmd_array);
     return(modp);
 }
+
+Parrot_PMC mpnci_dircfg_handler(Parrot_Interp interp, char *hll, char *id,
+    int update)
+{
+    modparrot_context *ctxp;
+    Parrot_PMC handler;
+    int typenum;
+
+    ctxp = get_interp_ctx(interp);
+    if (!ctxp) return NULL;
+
+    if (update) {
+        ctxp->dircfg->handler->hll = apr_pstrdup(ctxp->pconf, hll);
+        ctxp->dircfg->handler->id = apr_pstrdup(ctxp->pconf, id);
+    }
+
+    typenum = Parrot_PMC_typenum(interp, "SArray");
+    handler = (Parrot_PMC)Parrot_PMC_new(interp, typenum);
+    /* XXX how do we unregister this after it's used? */
+    Parrot_register_pmc(interp, handler);
+    Parrot_PMC_set_intval(interp, handler, 2);
+    Parrot_PMC_set_cstring_intkey(interp, handler, 0,
+        ctxp->dircfg->handler->hll);
+    Parrot_PMC_set_cstring_intkey(interp, handler, 1,
+        ctxp->dircfg->handler->id);
+
+    return(handler);
+}

<Prev in Thread] Current Thread [Next in Thread>
  • [svn:mod_parrot] r368 - in mod_parrot/trunk: . include lib lib/Apache src, jhorwitz <=