Configuring and Managing MPE/iX Internet Services (July 2001)
184 Chapter9
Apache for MPE/iX
Sample Module Code (mod_hw)
Sample Module Code (mod_hw)
This section contains source code for the sample DSO module discussed
in the previous sections, mod_hw.so. The module source code consists
of two files, mod_hw.c and hw.c. Mod_hw.c contains the module
structure and hw.c contains a function called by mod_hw.c.
mod_hw.c
Mod_hw.c is a simple Apache module. It calls pow() (in the math
library, /lib/libm) and helloworld() in hw.c. This example is
designed to illustrate the use of external function calls.
shell/iX> cat mod_hw.c
#include <stdlib.h>
#include <math.h>
#include "httpd.h"
#include "http_config.h"
#include "http_core.h"
#include "http_log.h"
#include "http_protocol.h"
/* here's the content handler */
static int hw_handler(request_rec *r) {
double root = 12;
double power = 2;
r->content_type = "text/html";
ap_send_http_header(r);
helloworld(r);
ap_rprintf(r, "\nresult of %.2lf**%.2lf is
%.2lf",root,power,pow(root,power));
return OK;
}
/* Make the name of the content handler known to Apache */
static handler_rec hw_handlers[] =
{
{"hw-handler", hw_handler},
{NULL}
};
/* Tell Apache what phases of the transaction we handle */
module MODULE_VAR_EXPORT hw_module =
{