httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ben Laurie <...@algroup.co.uk>
Subject Typesafe generic hooks - done!
Date Mon, 01 Jan 2001 17:21:56 GMT
Here we go. Rather than show the implementation, which is the usual
nasty mess of macros, I'll show you how its used. Here are two modules,
a hook exporter, and a hook importer. If the hook exporter is not
present, then the hook importer's hook is not called. If it is, then it
is. The hook importer's hook _is_ typesafe. And, err, that's it. So,
without further ado, here's mod_generic_hook_export.h:

AP_DECLARE_HOOK(int,generic_hook_test,(const char *))

and mod_generic_export.c:

#include "httpd.h"
#include "http_config.h"
#include "ap_generic_hook.h"
#include "mod_generic_hook_export.h"
#include "http_protocol.h"

AP_IMPLEMENT_GENERIC_HOOK_RUN_ALL(int,generic_hook_test,(const char
*szStr),
				  (szStr),OK,DECLINED)

static int ExportLogTransaction(request_rec *r)
    {
    return ap_run_generic_hook_test(r->the_request);
    }

static void ExportRegisterHooks(void)
    {
   
ap_hook_log_transaction(ExportLogTransaction,NULL,NULL,AP_HOOK_MIDDLE);
    }

module generic_hook_export_module =
    {
    STANDARD20_MODULE_STUFF,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    ExportRegisterHooks
    };

and finally, mod_generic_hook_import.c:

#include "httpd.h"
#include "http_config.h"
#include "ap_generic_hook.h"
#include "http_log.h"
#include "mod_generic_hook_export.h"

static int ImportGenericHookTestHook(const char *szStr)
    {
    ap_log_error(APLOG_MARK,APLOG_ERR,OK,NULL,"Generic hook test said:
%s",
		 szStr);

    return OK;
    }

static void ImportRegisterHooks(void)
    {
   
AP_HOOK_GENERIC(generic_hook_test,ImportGenericHookTestHook,NULL,NULL,
		    AP_HOOK_MIDDLE);
    }

module generic_hook_import_module=
    {
    STANDARD20_MODULE_STUFF,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    ImportRegisterHooks
    };

Tested. Works. Shall I commit it?

BTW, I was wondering if I should start an "examples" module directory,
instead of them living in "experimental" as they currently do.

Cheers,

Ben.

--
http://www.apache-ssl.org/ben.html

"There is no limit to what a man can do or how far he can go if he
doesn't mind who gets the credit." - Robert Woodruff

Mime
View raw message