]> err.no Git - sope/blob - Recycler/mod_objc/mod_gsbundle.m
Add libxml2-dev to libsope-xml4.7-dev deps
[sope] / Recycler / mod_objc / mod_gsbundle.m
1 // $Id: mod_gsbundle.m,v 1.1 2004/06/08 11:15:59 helge Exp $
2
3 #include "httpd.h"
4 #include "http_config.h"
5 #include <dlfcn.h>
6
7 /*
8   Note:
9
10   an Apache bundle gets *unloaded* during the config process !!!
11 */
12
13 module MODULE_VAR_EXPORT gsbundle_module;
14
15 static void *helperLib = NULL;
16
17 static const char *(*GSBundleModuleLoadBundleCommand)
18 (module *module, cmd_parms *cmd, char *bundlePath) = NULL;
19
20 /* Called when the LoadBundle config directive is found */
21 static const char *loadBundle
22 (cmd_parms *cmd, void *dummy, char *bundlePath)
23 {
24   if (helperLib == NULL) {
25     const char *path;
26     const char *dirpath;
27     
28     dirpath = ap_pstrcat(cmd->pool,
29                          getenv("GNUSTEP_SYSTEM_ROOT"), "/Libraries/",
30                          getenv("GNUSTEP_HOST_CPU"),    "/",
31                          getenv("GNUSTEP_HOST_OS"),     "/",
32                          getenv("LIBRARY_COMBO"),       "/",
33                          NULL);
34     path = ap_pstrcat(cmd->pool, dirpath, "libApHelper_d.so", NULL);
35     
36     helperLib = dlopen(path, RTLD_NOW | RTLD_GLOBAL);
37     if (helperLib == NULL) {
38       return ap_pstrcat(cmd->pool,
39                         "couldn't load ObjC bundle helper lib:\n  '",
40                         path,
41                         "' ..." , NULL);
42     }
43     
44     GSBundleModuleLoadBundleCommand =
45       dlsym(helperLib, "GSBundleModuleLoadBundleCommand");
46   }
47   
48   if (GSBundleModuleLoadBundleCommand == NULL){
49     return ap_pstrcat(cmd->pool,
50                       "couldn't find load bundle command in helper lib ...",
51                       NULL);
52   }
53   
54   return GSBundleModuleLoadBundleCommand(&gsbundle_module, cmd, bundlePath);
55 }
56
57 /* Config file commands we recognize */
58 static const command_rec gsbundle_cmds[] =
59 {
60   {
61     "LoadBundle",
62     loadBundle,
63     "my userinfo",
64     RSRC_CONF,
65     RAW_ARGS,
66     "takes bundle-path as arg"
67   },
68   {NULL}
69 };
70
71 module MODULE_VAR_EXPORT gsbundle_module = {
72     STANDARD_MODULE_STUFF,
73     NULL,                  /* module initializer                  */
74     NULL,                  /* create per-dir    config structures */
75     NULL,                  /* merge  per-dir    config structures */
76     NULL,                  /* create per-server config structures */
77     NULL,                  /* merge  per-server config structures */
78     gsbundle_cmds,         /* table of config file commands       */
79     NULL,                  /* [#8] MIME-typed-dispatched handlers */
80     NULL,                  /* [#1] URI to filename translation    */
81     NULL,                  /* [#4] validate user id from request  */
82     NULL,                  /* [#5] check if the user is ok _here_ */
83     NULL,                  /* [#3] check access by host address   */
84     NULL,                  /* [#6] determine MIME type            */
85     NULL,                  /* [#7] pre-run fixups                 */
86     NULL,                  /* [#9] log a transaction              */
87     NULL,                  /* [#2] header parser                  */
88     NULL,                  /* child_init                          */
89     NULL,                  /* child_exit                          */
90     NULL                   /* [#0] post read-request              */
91 };