diff options
author | Stef Walter <stef@memberwebs.com> | 2004-08-09 16:57:46 +0000 |
---|---|---|
committer | Stef Walter <stef@memberwebs.com> | 2004-08-09 16:57:46 +0000 |
commit | b0e50bbeb12e6247dd52dfd9e44c62f558c8a3a0 (patch) | |
tree | 20863017407586634b5fedf5ccf793d1cb5176a4 /daemon/bd.h | |
parent | 6be6d1dd25f2e7f2f1de6c0091e9aeae2ea1918c (diff) |
- Seperated core Basic/Digest functionality into a base handler
Diffstat (limited to 'daemon/bd.h')
-rw-r--r-- | daemon/bd.h | 71 |
1 files changed, 71 insertions, 0 deletions
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 */ |