i have wrote the c++ module in apache. The following is the code ::
mod_foo.hpp
#ifndef MOD_FOO_HPP
#define MOD_FOO_HPP
#ifdef __cplusplus
#define EXTERN_C_BLOCK_BEGIN extern "C" {
#define EXTERN_C_BLOCK_END }
#define EXTERN_C_FUNC extern "C"
#else
#define EXTERN_C_BLOCK_BEGIN
#define EXTERN_C_BLOCK_END
#define EXTERN_C_FUNC
#endif
#include <httpd.h>
#include <http_protocol.h>
#include <http_config.h>**
#endif /* MOD_FOO_HPP */
mod_foo.c
#include "mod_foo.hpp"
EXTERN_C_FUNC
int foo_handler( request_rec* inpRequest )
{
int nReturnVal = DECLINED;
if ( inpRequest->handler != NULL && strcmp( inpRequest->handler, "foo" ) == 0 )
{
ap_rputs( "Hello World from FOO", inpRequest );
nReturnVal = OK;
}
return nReturnVal;
}
EXTERN_C_FUNC
void foo_hooks( apr_pool_t* inpPool )
{
ap_hook_handler( foo_handler, NULL, NULL, APR_HOOK_MIDDLE );
}
EXTERN_C_BLOCK_BEGIN
module AP_MODULE_DECLARE_DATA foo_module =
{
STANDARD20_MODULE_STUFF,
NULL,
NULL,
NULL,
NULL,
NULL,
foo_hooks
};
EXTERN_C_BLOCK_END
The module is compiling successfully and it's also installing on the apache server but when i restart the apache server after installing it The following Error occurs:
apache2: Syntax error on line 234 of /etc/apache2/apache2.conf: Syntax error on line 1 of /etc/apache2/conf.d/foo.conf: API module structure 'foo_module' in file /usr/lib/apache2/modules/mod_foo.so is garbled - expected signature 41503232 but saw 41503234 - perhaps this is not an Apache module DSO, or was compiled for a different Apache version?
I added the LoadModule
thing in httpd.conf
to load the module but only c++ modules is giving this error. Any idea about how to resolve this problem?