Ben Laurie wrote:
Another approach still would require a fairly large change to the core
and many modules, but it strikes me as a better option...
struct http_data {
.
.
.
};
struct smtp_data {
.
.
.
};
struct request_rec {
.
. /* common stuff */
.
struct http_data *http;
struct smtp_data *smtp;
}
If there was going to be a large change to core, request_rec and friends
how about:
struct request_rec {
/* common stuff */
char *protocol_name; // different from r->protocol,
// but maybe doesn't have to be
struct ap_conf_vector_t *request_config;
};
The request_config vector would store all the protocol specific data.
Protocol_name would be so modules new what they were dealing with. To
retrieve protocol specific data define this in each protocol module:
smtpd_request_rec *get_smtpd_request(request_rec *r) {
return ap_get_module_config(r->request_config, &MODULE_NAME);
}
Then in handler modules:
type misc_smtp_handler(request_rec *r) {
smtpd_request_rec *smtp_data;
if (strncmp("http", r->protocol_name, 4)) {
// decline to handle, this module doesn't handle
// http requests.
}
//then get smtpd specific data
smtp_data = get_smtpd_request(r);
// do some handlin'
}
The advantage to this approach is a less bulky (but more all
encompassing) request_rec with support for an arbitrary amount of
protocols and protocol specific data.
-rian