From 495ccb3f35ea7511302ff3fa0f43f1b8a6e736e3 Mon Sep 17 00:00:00 2001 From: Stef Walter Date: Mon, 9 Aug 2004 18:48:27 +0000 Subject: Reorganized files --- common/buffer.c | 2 +- common/buffer.h | 97 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ daemon/Makefile.am | 11 ++++--- daemon/httpauthd.h | 95 +--------------------------------------------------- 4 files changed, 106 insertions(+), 99 deletions(-) create mode 100644 common/buffer.h diff --git a/common/buffer.c b/common/buffer.c index 07fa059..ea8f5a7 100644 --- a/common/buffer.c +++ b/common/buffer.c @@ -1,6 +1,6 @@ #include "usuals.h" -#include "httpauthd.h" +#include "buffer.h" #include "stringx.h" #include diff --git a/common/buffer.h b/common/buffer.h new file mode 100644 index 0000000..e9a6b8a --- /dev/null +++ b/common/buffer.h @@ -0,0 +1,97 @@ + +#ifndef _BUFFER_H_ +#define _BUFFER_H_ + +/* ----------------------------------------------------------------------- + * Memory Buffers + */ + +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; +} +ha_buffer_t; + +/* Initializes a buffer */ +void ha_bufinit(ha_buffer_t* buf); + +/* Frees all memory associated with a buffer */ +void ha_buffree(ha_buffer_t* buf); + +/* Resets a buffer for later reuse */ +void ha_bufreset(ha_buffer_t* buf); + +#define ha_buflen(buf) \ + ((buf)->_rp - (buf)->_pp) + +#define ha_bufchar(buf) \ + ((!ha_buferr(buf) && ha_buflen(buf) > 0) ? *((buf)->_pp) : '\0' ) + +#define ha_bufdata(buf) \ + ((buf)->_pp) + +#define ha_buferr(buf) \ + ((buf)->_dt == NULL) + +/* Buffer input functions ------------------------------------------------ */ + +/* Read a line from an input handle */ +int ha_bufreadline(int fd, ha_buffer_t* buf); + +/* Parse the current line */ +char* ha_bufparseline(ha_buffer_t* buf, int trim); + +/* Parse a word from the current block */ +char* ha_bufparseword(ha_buffer_t* buf, const char* delims); + +#define ha_bufskip(buf) \ + ((buf)->_pp = (buf)->_rp) + +#define ha_bufeat(buf) \ + ((!ha_buferr(buf) && ha_buflen(buf) > 0) ? ++((buf)->_pp) : (buf)->_pp) + +/* Buffer output functions ----------------------------------------------- */ + +/* Adds multiple strings together */ +char* ha_bufmcat(ha_buffer_t* buf, ...); + +/* Copies a string to the buffer */ +char* ha_bufcpy(ha_buffer_t* buf, const char* src); + +/* Copies a portion of a string to the buffer */ +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) + +#define ha_bufcat ha_bufcpy + +/* Buffer allocation functions ------------------------------------------- */ + +/* Memory allocation */ +void* ha_bufmalloc(ha_buffer_t* buf, size_t bytes); + +void* ha_bufmemdup(ha_buffer_t* buf, const void* src, size_t bytes); + +/* Buffer Encoding Functions --------------------------------------------- */ + +/* Encode an array of bytes in base 64 */ +char* ha_bufenc64(ha_buffer_t* buf, const void* src, size_t bytes); + +/* Decode an array of bytes from base 64 */ +void* ha_bufdec64(ha_buffer_t* buf, const char* src, size_t* bytes); + +/* Encode an array of bytes in hex */ +char* ha_bufenchex(ha_buffer_t* buf, const void* src, size_t bytes); + +/* Decode an array of bytes in hex */ +void* ha_bufdechex(ha_buffer_t* buf, const char* src, size_t* bytes); + +#endif /* _BUFFER_H_ */ diff --git a/daemon/Makefile.am b/daemon/Makefile.am index c669f04..3d80d4c 100644 --- a/daemon/Makefile.am +++ b/daemon/Makefile.am @@ -1,10 +1,13 @@ sbin_PROGRAMS = httpauthd -httpauthd_SOURCES = httpauthd.c httpauthd.h usuals.h compat.h compat.c bd.h bd.c\ - buffer.c misc.c basic.h basic.c ntlm.c hash.c hash.h ntlmssp.h ntlmssp.c \ - md5.c md5.h sha1.c sha1.h digest.h digest.c ldap.c defaults.h simple.c \ - ../common/sock_any.c ../common/sock_any.h ../common/stringx.c\ +httpauthd_SOURCES = httpauthd.c httpauthd.h usuals.h bd.h bd.c misc.c basic.h basic.c \ + ntlm.c ntlmssp.h ntlmssp.c digest.h digest.c ldap.c defaults.h simple.c \ + \ + ../common/compat.h ../common/compat.c ../common/buffer.h ../common/buffer.c \ + ../common/hash.h ../common/hash.c ../common/md5.h ../common/md5.c \ + ../common/sha1.h ../common/sha1.c ../common/sock_any.c ../common/sock_any.h \ + ../common/stringx.c ../common/stringx.h \ \ smblib/smblib.c smblib/smblib-util.c smblib/file.c smblib/smb-errors.c \ smblib/exper.c smblib/smblib-api.c smblib/smblib.h smblib/std-defines.h \ diff --git a/daemon/httpauthd.h b/daemon/httpauthd.h index 39bf94e..680994e 100644 --- a/daemon/httpauthd.h +++ b/daemon/httpauthd.h @@ -2,102 +2,9 @@ #ifndef __HTTPAUTHD_H__ #define __HTTPAUTHD_H__ +#include "buffer.h" #include -/* ----------------------------------------------------------------------- - * Memory Buffers - */ - -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; -} -ha_buffer_t; - -/* Initializes a buffer */ -void ha_bufinit(ha_buffer_t* buf); - -/* Frees all memory associated with a buffer */ -void ha_buffree(ha_buffer_t* buf); - -/* Resets a buffer for later reuse */ -void ha_bufreset(ha_buffer_t* buf); - -#define ha_buflen(buf) \ - ((buf)->_rp - (buf)->_pp) - -#define ha_bufchar(buf) \ - ((!ha_buferr(buf) && ha_buflen(buf) > 0) ? *((buf)->_pp) : '\0' ) - -#define ha_bufdata(buf) \ - ((buf)->_pp) - -#define ha_buferr(buf) \ - ((buf)->_dt == NULL) - -/* Buffer input functions ------------------------------------------------ */ - -/* Read a line from an input handle */ -int ha_bufreadline(int fd, ha_buffer_t* buf); - -/* Parse the current line */ -char* ha_bufparseline(ha_buffer_t* buf, int trim); - -/* Parse a word from the current block */ -char* ha_bufparseword(ha_buffer_t* buf, const char* delims); - -#define ha_bufskip(buf) \ - ((buf)->_pp = (buf)->_rp) - -#define ha_bufeat(buf) \ - ((!ha_buferr(buf) && ha_buflen(buf) > 0) ? ++((buf)->_pp) : (buf)->_pp) - -/* Buffer output functions ----------------------------------------------- */ - -/* Adds multiple strings together */ -char* ha_bufmcat(ha_buffer_t* buf, ...); - -/* Copies a string to the buffer */ -char* ha_bufcpy(ha_buffer_t* buf, const char* src); - -/* Copies a portion of a string to the buffer */ -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) - -#define ha_bufcat ha_bufcpy - -/* Buffer allocation functions ------------------------------------------- */ - -/* Memory allocation */ -void* ha_bufmalloc(ha_buffer_t* buf, size_t bytes); - -void* ha_bufmemdup(ha_buffer_t* buf, const void* src, size_t bytes); - -/* Buffer Encoding Functions --------------------------------------------- */ - -/* Encode an array of bytes in base 64 */ -char* ha_bufenc64(ha_buffer_t* buf, const void* src, size_t bytes); - -/* Decode an array of bytes from base 64 */ -void* ha_bufdec64(ha_buffer_t* buf, const char* src, size_t* bytes); - -/* Encode an array of bytes in hex */ -char* ha_bufenchex(ha_buffer_t* buf, const void* src, size_t bytes); - -/* Decode an array of bytes in hex */ -void* ha_bufdechex(ha_buffer_t* buf, const char* src, size_t* bytes); - - - /* ----------------------------------------------------------------------- * HTTP Auth Handlers */ -- cgit v1.2.3