ma być sprawdzana konfiguracja serwera (kilka parametrów).
Jeśli jakiś parametr jest niewłaściwy wyświetli się strona błędu np. 500.
Przykładowy kod modułu zawiera zmienną "some_var_config_from_apache_or_htaacess".
W tym przykładzie powiedzmy że jest to konfiguracja "DirectoryIndex" która będzie się nam wyświetlać.
Jak pobrać tą zmienną aby zawierała konfigurację?
Kod
/* Source: http://people.apache.org/~humbedooh/mods/examples/mod_example_1.c */
#include "httpd.h"
#include "http_core.h"
#include "http_protocol.h"
#include "http_request.h"
static void register_hooks(apr_pool_t *pool);
static int example_handler(request_rec *r);
/* Define our module as an entity and assign a function for registering hooks */
module AP_MODULE_DECLARE_DATA example_module =
{
STANDARD20_MODULE_STUFF,
NULL, // Per-directory configuration handler
NULL, // Merge handler for per-directory configurations
NULL, // Per-server configuration handler
NULL, // Merge handler for per-server configurations
NULL, // Any directives we may have for httpd
register_hooks // Our hook registering function
};
static void register_hooks(apr_pool_t *pool)
{
ap_hook_handler(example_handler, NULL, NULL, APR_HOOK_LAST);
}
static int example_handler(request_rec *r)
{
if (!r->handler || strcmp(r->handler, "example-handler")) return (DECLINED);
// The first thing we will do is write a simple "Hello, world!" back to the client.
//ap_rputs("Hello, world!", r);
ap_rputs(some_var_config_from_apache_or_htaacess, r);
return OK;
}
#include "httpd.h"
#include "http_core.h"
#include "http_protocol.h"
#include "http_request.h"
static void register_hooks(apr_pool_t *pool);
static int example_handler(request_rec *r);
/* Define our module as an entity and assign a function for registering hooks */
module AP_MODULE_DECLARE_DATA example_module =
{
STANDARD20_MODULE_STUFF,
NULL, // Per-directory configuration handler
NULL, // Merge handler for per-directory configurations
NULL, // Per-server configuration handler
NULL, // Merge handler for per-server configurations
NULL, // Any directives we may have for httpd
register_hooks // Our hook registering function
};
static void register_hooks(apr_pool_t *pool)
{
ap_hook_handler(example_handler, NULL, NULL, APR_HOOK_LAST);
}
static int example_handler(request_rec *r)
{
if (!r->handler || strcmp(r->handler, "example-handler")) return (DECLINED);
// The first thing we will do is write a simple "Hello, world!" back to the client.
//ap_rputs("Hello, world!", r);
ap_rputs(some_var_config_from_apache_or_htaacess, r);
return OK;
}