Hi All,
I am a newbie to Apache development. I am trying to develop a module
for apache 1.3.34 in C++. I really need to link with some C++ libs and
use C++ headers for this project.
1) How do i go about it ? Do i follow the standard Makefile approach
as outlined in the book "Writing Apache Modules with Perl and C" ?
2) The sample skeleton code (mixed C/C++) is given below. Would
someone be kind enough to go through and tell me if my approach is OK?
==========Example code =========================
#include "apache/httpd.h"
#include "http_config.h"
#include "http_core.h"
#include "http_log.h"
#include "http_protocol.h"
#undef strtoul
//will the next line work as intended?
extern "C" module MODULE_VAR_EXPORT clickout_module;
static void co_mod_init(server_rec *s, pool *p)
{
//some module initialization stuff
}
static int co_handler(request_rec *r)
{
const char* hostname;
r->content_type = "text/html";
ap_send_http_header(r);
hostname = ap_get_remote_host(r->connection, r->per_dir_config,
REMOTE_NAME);
ap_rputs ("Some text");
return OK;
}
static handler_rec co_handlers[] =
{
{"some-hander", some_handler},
{NULL}
};
void co_proc_init(server_rec* s, pool* p)
{
// some c++ initialization functions here.
}
extern "C" { // is this extern useful here?
module MODULE_VAR_EXPORT clickout_module =
{
STANDARD_MODULE_STUFF,
co_mod_init, /** module initializer */
NULL, /** per-directory config creator */
NULL, /** dir config merger */
NULL, /** server config creator */
NULL, /** server config merger */
NULL, /** command table */
co_handlers, /** [9] content handlers */
NULL, /** [2] URI-to-filename translation */
NULL, /** [5] check/validate user_id */
NULL, /** [6] check user_id is valid *here* */
NULL, /** [4] check access by host address */
NULL, /** [7] MIME type checker/setter */
NULL, /** [8] fixups */
NULL, /** [10] logger */
NULL, /** [3] header parser */
co_proc_init, /** process initialization */
NULL, /** process exit/cleanup */
NULL /** [1] post read_request handling */
};
}
==========End example code ======================
Thanks in advance.!!
--
Warm Regards,
Manish Chakravarty
----
Consultant Software Developer
PH: +919886702500
http://manishchaks.net
---