httpd-modules-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kratzer, James \(Xetron\)" <James.Krat...@ngc.com>
Subject RE: Developing C++ modules with apache 1.3.34
Date Thu, 12 Oct 2006 13:40:19 GMT
Hi,

Here is what I'm doing with Apache 2.0.

I use autoconf and libtool to create my makefiles and to build my apache
modules.  I then put all of your C++ functions is a separate source file
having a cpp extension and I wrap the c++ functions with extern "C"
declarations.  I then call the c++ functions from the C module code.
Works great.

James Kratzer  

-----Original Message-----
From: Manish Chakravarty [mailto:manishchaks@gmail.com] 
Sent: Thursday, October 12, 2006 2:49 AM
To: modules-dev@httpd.apache.org
Subject: Developing C++ modules with apache 1.3.34

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
---

Mime
View raw message