httpd-modules-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jieyun Fu <jieyu...@gmail.com>
Subject A simple module doesnt work.
Date Fri, 24 Jul 2009 20:05:35 GMT
Hi All,

I am trying to write a simple apache module, and this module works on Apache
2.0 but not on Apache 2.2. The problem happens in ap_get_module_config
(bolded in the code). Any clue about the possible cause?

Thanks in advance
[CODE]
#include <httpd.h>
#include <http_config.h>
#include <http_core.h>
#include <http_main.h>
#include <http_protocol.h>
#include <ap_compat.h>
#include <stdio.h>

typedef struct {
  const char* conf_path;
  bool model;
  bool limit;
} my_config;

extern "C" module AP_MODULE_DECLARE_DATA my_module;

static const char*
setpath(cmd_parms *parms, void *dummy, const char *arg) {
  my_config *cfg = (my_config *)
    ap_get_module_config(parms->server->module_config, &my_module);  *[B]//
Here, value of ap_get_module_config always null.[/B]*
  cfg->conf_path = arg;
  return NULL;
}

static void*
make_conf(apr_pool_t *p, server_rec *s)  {
  my_config *cfg =
    (my_config *)apr_palloc(p, sizeof(my_config));
  cfg->conf_path = NULL;
  cfg->model = TRUE;
  cfg->limit = TRUE;
  return (void *)cfg;
}

static const command_rec com_table[] = {
  {"directive name", (cmd_func)setpath,
   NULL, RSRC_CONF, TAKE1,
   "hello message"},
  {NULL}
};

extern "C" {
module my_module = {
    STANDARD20_MODULE_STUFF,
    NULL,                   /* create per-directory config structures */
    NULL,                   /* merge per-directory config structures  */
    make_conf, /* create per-server config structures    */
    NULL,                   /* merge per-server config structures     */
    com_table,     /* command handlers */
    NULL          /* register hooks */
 };
};
[/CODE]

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message