From b0e50bbeb12e6247dd52dfd9e44c62f558c8a3a0 Mon Sep 17 00:00:00 2001 From: Stef Walter Date: Mon, 9 Aug 2004 16:57:46 +0000 Subject: - Seperated core Basic/Digest functionality into a base handler --- daemon/bd.h | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 daemon/bd.h (limited to 'daemon/bd.h') diff --git a/daemon/bd.h b/daemon/bd.h new file mode 100644 index 0000000..450c8e1 --- /dev/null +++ b/daemon/bd.h @@ -0,0 +1,71 @@ + +#ifndef BD_H +#define BD_H + +#include "hash.h" + +/* ---------------------------------------------------------------------------------- + * Callbacks + */ + +/* + * A callback for completing a given user's digest ha1. In this function + * you're required to fill in the digest ha1 hash for the user. ha1 will + * always be an array of MD5_LEN bytes. + * + * Return Values + * HA_OK: completed successfully + * HA_FAILED: error retrieving hash (should have logged error) + */ +typedef int (*bd_complete_digest)(const ha_request_t* req, + const char* user, unsigned char* ha1); + +/* + * A callback for validating a given user's password. + * + * Return Values + * HA_OK: good password + * HA_FALSE: invalid password + * HA_FAILED: error validating (should have logged error) + */ +typedef int (*bd_validate_basic)(const ha_request_t* req, + const char* user, const char* password); + +/* ---------------------------------------------------------------------------------- + * Base Context + */ +typedef struct bd_context +{ + hsh_t* cache; /* Some cached records or basic */ + + bd_complete_digest f_complete_digest; + bd_validate_basic f_validate_basic; +} +bd_context_t; + +#define BD_CALLBACKS(a, b) { NULL, (a), (b) } +#define BD_DEFAULTS { NULL, NULL, NULL } + +/* ---------------------------------------------------------------------------------- + * Base Handler Functions + */ + +/* + * The base/digest initialize function. Call this from your + * 'derived' handler initialize function. + */ +int bd_init(ha_context_t* context); + +/* + * The base/digest uninitialize function. Call this from your + * 'derived' handler uninitialize function. + */ +void bd_destroy(ha_context_t* context); + +/* + * The base/digest processer for requests. Call this from your + * 'derived' handler process function. + */ +int bd_process(const ha_request_t* req, ha_response_t* resp); + +#endif /* BD_H */ -- cgit v1.2.3