From 670eba73c474230e31d688e9568fcd540b4e3b39 Mon Sep 17 00:00:00 2001 From: Stef Walter Date: Mon, 9 Aug 2004 18:35:56 +0000 Subject: - added request parameter to ha_message... - combined ha_request and ha_response --- daemon/httpauthd.h | 137 ++++++++++++++++++++++++++--------------------------- 1 file changed, 67 insertions(+), 70 deletions(-) (limited to 'daemon/httpauthd.h') diff --git a/daemon/httpauthd.h b/daemon/httpauthd.h index 84a30cd..39bf94e 100644 --- a/daemon/httpauthd.h +++ b/daemon/httpauthd.h @@ -2,6 +2,8 @@ #ifndef __HTTPAUTHD_H__ #define __HTTPAUTHD_H__ +#include + /* ----------------------------------------------------------------------- * Memory Buffers */ @@ -11,10 +13,10 @@ struct ha_buffer_internal; /* A buffer which owns memory */ typedef struct ha_buffer { - struct ha_buffer_internal* _ft; - struct ha_buffer_internal* _dt; - char* _pp; - char* _rp; + struct ha_buffer_internal* _ft; + struct ha_buffer_internal* _dt; + char* _pp; + char* _rp; } ha_buffer_t; @@ -28,16 +30,16 @@ void ha_buffree(ha_buffer_t* buf); void ha_bufreset(ha_buffer_t* buf); #define ha_buflen(buf) \ - ((buf)->_rp - (buf)->_pp) + ((buf)->_rp - (buf)->_pp) #define ha_bufchar(buf) \ - ((!ha_buferr(buf) && ha_buflen(buf) > 0) ? *((buf)->_pp) : '\0' ) + ((!ha_buferr(buf) && ha_buflen(buf) > 0) ? *((buf)->_pp) : '\0' ) #define ha_bufdata(buf) \ - ((buf)->_pp) + ((buf)->_pp) #define ha_buferr(buf) \ - ((buf)->_dt == NULL) + ((buf)->_dt == NULL) /* Buffer input functions ------------------------------------------------ */ @@ -51,10 +53,10 @@ char* ha_bufparseline(ha_buffer_t* buf, int trim); char* ha_bufparseword(ha_buffer_t* buf, const char* delims); #define ha_bufskip(buf) \ - ((buf)->_pp = (buf)->_rp) + ((buf)->_pp = (buf)->_rp) #define ha_bufeat(buf) \ - ((!ha_buferr(buf) && ha_buflen(buf) > 0) ? ++((buf)->_pp) : (buf)->_pp) + ((!ha_buferr(buf) && ha_buflen(buf) > 0) ? ++((buf)->_pp) : (buf)->_pp) /* Buffer output functions ----------------------------------------------- */ @@ -69,7 +71,7 @@ char* ha_bufncpy(ha_buffer_t* buf, const char* src, size_t len); /* Opens up the end of the current block so it can be joined by more data */ #define ha_bufjoin(buf) \ - ((buf)->_rp && ((buf)->_rp != (buf)->_pp) ? (buf)->_rp-- : (buf)->_rp) + ((buf)->_rp && ((buf)->_rp != (buf)->_pp) ? (buf)->_rp-- : (buf)->_rp) #define ha_bufcat ha_bufcpy @@ -102,7 +104,6 @@ void* ha_bufdechex(ha_buffer_t* buf, const char* src, size_t* bytes); struct ha_context; struct ha_request; -struct ha_response; /* * This function initializes the handler. It gets called @@ -131,18 +132,18 @@ typedef int (*auth_config_t)(struct ha_context* ctx, const char* name, const cha * for this handler. Note that all data access in this * function must be thread-safe. */ -typedef int (*auth_process_t)(const struct ha_request* req, struct ha_response* resp); +typedef int (*auth_process_t)(struct ha_request* rq); /* An authentication handler */ typedef struct ha_handler { - const char* type; - auth_init_t f_init; /* #1 Called to initialize handler */ - auth_destroy_t f_destroy; /* #3 Called when exiting */ - auth_config_t f_config; /* #0 Called for each config param */ - auth_process_t f_process; /* #2 Called for each auth request */ - const void* context_default; /* The default context */ - const size_t context_size; /* Bytes of extra context needed */ + const char* type; + auth_init_t f_init; /* #1 Called to initialize handler */ + auth_destroy_t f_destroy; /* #3 Called when exiting */ + auth_config_t f_config; /* #0 Called for each config param */ + auth_process_t f_process; /* #2 Called for each auth request */ + const void* context_default; /* The default context */ + const size_t context_size; /* Bytes of extra context needed */ } ha_handler_t; @@ -177,22 +178,22 @@ ha_handler_t; /* Context passed to the handler functions above */ typedef struct ha_context { - const char* name; /* A name assigned by the configuration file */ - const ha_handler_t* handler; /* The original handler structure */ - void* ctx_data; /* Handler specific data */ - - /* Context specific options */ - unsigned int allowed_types; - int cache_timeout; - int cache_max; - - /* For basic and digest auth: */ - const char* realm; - - /* For digest auth: */ - unsigned int digest_ignoreuri : 1; - unsigned int digest_ignorenc : 1; - const char* digest_debugnonce; + const char* name; /* A name assigned by the configuration file */ + const ha_handler_t* handler; /* The original handler structure */ + void* ctx_data; /* Handler specific data */ + + /* Context specific options */ + unsigned int allowed_types; + int cache_timeout; + int cache_max; + + /* For basic and digest auth: */ + const char* realm; + + /* For digest auth: */ + unsigned int digest_ignoreuri : 1; + unsigned int digest_ignorenc : 1; + const char* digest_debugnonce; } ha_context_t; @@ -228,8 +229,8 @@ ha_context_t; /* A single header in memory */ typedef struct ha_header { - const char* name; - const char* data; + const char* name; + const char* data; } ha_header_t; @@ -243,19 +244,25 @@ ha_header_t; #define AUTH_ARG_METHOD 1 #define AUTH_ARG_URI 2 -/* A single request from client */ +/* A single request from client along with response */ typedef struct ha_request { - int type; - const char* args[HA_MAX_ARGS]; - ha_header_t headers[HA_MAX_HEADERS]; + unsigned int id; /* Unique connection identifier */ + + int req_type; /* The command type */ + const char* req_args[HA_MAX_ARGS]; /* Arguments for the command */ + ha_header_t req_headers[HA_MAX_HEADERS]; /* Headers for command */ + + /* Additional request info */ + ha_context_t* context; + const char* digest_domain; - /* Additional request info */ - ha_context_t* context; - const char* digest_domain; + /* The buffer in use */ + ha_buffer_t* buf; - /* The buffer in use */ - ha_buffer_t* buf; + int resp_code; /* The response code */ + const char* resp_detail; /* The details for response */ + ha_header_t resp_headers[HA_MAX_HEADERS]; /* Headers for the response */ } ha_request_t; @@ -267,22 +274,12 @@ ha_request_t; #define HA_SERVER_BADREQ 400 #define HA_SERVER_BUSY 500 -/* A response to the client */ -typedef struct ha_response -{ - int code; - const char* detail; - ha_header_t headers[HA_MAX_HEADERS]; - ha_buffer_t* buf; -} -ha_response_t; - /* Request functions */ -const ha_header_t* ha_findheader(const ha_request_t* req, const char* name); -const char* ha_getheader(const ha_request_t* req, const char* name, const char* prefix); +const ha_header_t* ha_findheader(const ha_request_t* rq, const char* name); +const char* ha_getheader(const ha_request_t* rq, const char* name, const char* prefix); /* Response functions */ -void ha_addheader(ha_response_t* resp, const char* name, const char* data); +void ha_addheader(ha_request_t* rq, const char* name, const char* data); /* Configuration functions */ int ha_confbool(const char* name, const char* conf, int* value); @@ -292,8 +289,8 @@ int ha_confint(const char* name, const char* conf, int min, int max, int* value) * Error Handling */ -void ha_message(int level, const char* msg, ...); -void ha_messagex(int level, const char* msg, ...); +void ha_message(const ha_request_t* rq, int level, const char* msg, ...); +void ha_messagex(const ha_request_t* rq, int level, const char* msg, ...); /* ----------------------------------------------------------------------- @@ -318,14 +315,14 @@ void ha_messagex(int level, const char* msg, ...); typedef struct ha_uri { - const char* scheme; - const char* user; - const char* pw; - const char* host; - unsigned short port; - const char* path; - const char* query; - const char* fragment; + const char* scheme; + const char* user; + const char* pw; + const char* host; + unsigned short port; + const char* path; + const char* query; + const char* fragment; } ha_uri_t; -- cgit v1.2.3