[dovecot-cvs] dovecot/src/lib base64.c,1.8,1.9 base64.h,1.8,1.9 buffer.c,1.6,1.7 buffer.h,1.3,1.4 compat.h,1.15,1.16 data-stack.c,1.15,1.16 env-util.c,1.5,1.6 failures.h,1.5,1.6 hash.c,1.6,1.7 hash.h,1.3,1.4 hex-binary.c,1.4,1.5 hex-binary.h,1.5,1.6 imem.c,1.6,1.7 Message-Id: <20030105130956.ACFBA23999@danu.procontrol.fi>
cras at procontrol.fi
cras at procontrol.fi
Sun Jan 5 15:09:56 EET 2003
- Previous message: [dovecot-cvs] dovecot/src/lib-mail message-address.c,NONE,1.1 message-address.h,NONE,1.1 message-date.c,NONE,1.1 message-date.h,NONE,1.1 message-tokenize.c,NONE,1.1 message-tokenize.h,NONE,1.1 Makefile.am,1.6,1.7 message-body-search.c,1.8,1.9 Message-Id: <20030105130956.8F2DA23997@danu.procontrol.fi>
- Next message: [dovecot-cvs] dovecot configure.in,1.81,1.82
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /home/cvs/dovecot/src/lib
In directory danu:/tmp/cvs-serv25916/src/lib
Modified Files:
base64.c base64.h buffer.c buffer.h compat.h data-stack.c
env-util.c failures.h hash.c hash.h hex-binary.c hex-binary.h
imem.c imem.h ioloop-internal.h ioloop-poll.c ioloop-select.c
ioloop.c ioloop.h iostream-internal.h iostream.c
istream-data.c istream-file.c istream-internal.h
istream-mmap.c istream.c istream.h lib.h macros.h md5.c md5.h
mempool-alloconly.c mempool-datastack.c mempool-system.c
mempool.h network.c network.h ostream-file.c
ostream-internal.h ostream.c ostream.h str.c str.h strescape.c
strescape.h strfuncs.c strfuncs.h
Log Message:
Naming style changes, finally got tired of most of the typedefs. Also the
previous enum -> macro change reverted so that we don't use the highest bit
anymore, that's incompatible with old indexes so they will be rebuilt.
Index: base64.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib/base64.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- base64.c 9 Dec 2002 16:14:38 -0000 1.8
+++ base64.c 5 Jan 2003 13:09:51 -0000 1.9
@@ -46,7 +46,7 @@
static const char basis_64[] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
-int base64_encode(const unsigned char *src, size_t src_size, Buffer *dest)
+int base64_encode(const unsigned char *src, size_t src_size, buffer_t *dest)
{
size_t src_pos;
int c1, c2, c3;
@@ -108,7 +108,7 @@
};
int base64_decode(const unsigned char *src, size_t src_size,
- size_t *src_pos_r, Buffer *dest)
+ size_t *src_pos_r, buffer_t *dest)
{
size_t src_pos;
unsigned char buf[4];
Index: base64.h
===================================================================
RCS file: /home/cvs/dovecot/src/lib/base64.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- base64.h 8 Dec 2002 05:23:07 -0000 1.8
+++ base64.h 5 Jan 2003 13:09:51 -0000 1.9
@@ -3,7 +3,7 @@
/* Translates binary data into base64. The src must not point to dest buffer.
Returns 1 if all ok, 0 if dest buffer got full. */
-int base64_encode(const unsigned char *src, size_t src_size, Buffer *dest);
+int base64_encode(const unsigned char *src, size_t src_size, buffer_t *dest);
/* Translates base64 data into binary and appends it to dest buffer. dest may
point to same buffer as src. Returns 1 if all ok, 0 if dest buffer got full
@@ -14,7 +14,7 @@
If src_pos is non-NULL, it's updated to first non-translated character in
src. */
int base64_decode(const unsigned char *src, size_t src_size,
- size_t *src_pos_r, Buffer *dest);
+ size_t *src_pos_r, buffer_t *dest);
/* max. buffer size required for base64_encode() */
#define MAX_BASE64_ENCODED_SIZE(size) \
Index: buffer.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib/buffer.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- buffer.c 22 Dec 2002 16:46:16 -0000 1.6
+++ buffer.c 5 Jan 2003 13:09:51 -0000 1.7
@@ -26,8 +26,8 @@
#include "lib.h"
#include "buffer.h"
-struct _Buffer {
- Pool pool;
+struct buffer {
+ pool_t pool;
const unsigned char *r_buffer;
unsigned char *w_buffer;
@@ -45,7 +45,7 @@
unsigned int hard:1;
};
-static void buffer_alloc(Buffer *buf, size_t size)
+static void buffer_alloc(buffer_t *buf, size_t size)
{
i_assert(buf->w_buffer == NULL || buf->alloced);
@@ -63,7 +63,8 @@
buf->alloced = TRUE;
}
-static int buffer_check_read(const Buffer *buf, size_t *pos, size_t *data_size)
+static int buffer_check_read(const buffer_t *buf,
+ size_t *pos, size_t *data_size)
{
size_t used_size, max_size;
@@ -78,8 +79,8 @@
return TRUE;
}
-static int buffer_check_write(Buffer *buf, size_t *pos, size_t *data_size,
- int accept_partial)
+static int buffer_check_write(buffer_t *buf, size_t *pos,
+ size_t *data_size, int accept_partial)
{
size_t max_size, new_size, alloc_size;
@@ -132,42 +133,42 @@
return TRUE;
}
-Buffer *buffer_create_static(Pool pool, size_t size)
+buffer_t *buffer_create_static(pool_t pool, size_t size)
{
- Buffer *buf;
+ buffer_t *buf;
- buf = p_new(pool, Buffer, 1);
+ buf = p_new(pool, buffer_t, 1);
buf->pool = pool;
buf->max_alloc = buf->limit = size;
buffer_alloc(buf, size);
return buf;
}
-Buffer *buffer_create_static_hard(Pool pool, size_t size)
+buffer_t *buffer_create_static_hard(pool_t pool, size_t size)
{
- Buffer *buf;
+ buffer_t *buf;
buf = buffer_create_static(pool, size);
buf->hard = TRUE;
return buf;
}
-Buffer *buffer_create_data(Pool pool, void *data, size_t size)
+buffer_t *buffer_create_data(pool_t pool, void *data, size_t size)
{
- Buffer *buf;
+ buffer_t *buf;
- buf = p_new(pool, Buffer, 1);
+ buf = p_new(pool, buffer_t, 1);
buf->pool = pool;
buf->alloc = buf->max_alloc = buf->limit = size;
buf->r_buffer = buf->w_buffer = data;
return buf;
}
-Buffer *buffer_create_const_data(Pool pool, const void *data, size_t size)
+buffer_t *buffer_create_const_data(pool_t pool, const void *data, size_t size)
{
- Buffer *buf;
+ buffer_t *buf;
- buf = p_new(pool, Buffer, 1);
+ buf = p_new(pool, buffer_t, 1);
buf->pool = pool;
buf->used = buf->alloc = buf->max_alloc = buf->limit = size;
buf->r_buffer = data;
@@ -175,25 +176,25 @@
return buf;
}
-Buffer *buffer_create_dynamic(Pool pool, size_t init_size, size_t max_size)
+buffer_t *buffer_create_dynamic(pool_t pool, size_t init_size, size_t max_size)
{
- Buffer *buf;
+ buffer_t *buf;
- buf = p_new(pool, Buffer, 1);
+ buf = p_new(pool, buffer_t, 1);
buf->pool = pool;
buf->max_alloc = buf->limit = max_size;
buffer_alloc(buf, init_size);
return buf;
}
-void buffer_free(Buffer *buf)
+void buffer_free(buffer_t *buf)
{
if (buf->alloced)
p_free(buf->pool, buf->w_buffer);
p_free(buf->pool, buf);
}
-void *buffer_free_without_data(Buffer *buf)
+void *buffer_free_without_data(buffer_t *buf)
{
void *data;
@@ -202,7 +203,7 @@
return data;
}
-size_t buffer_write(Buffer *buf, size_t pos,
+size_t buffer_write(buffer_t *buf, size_t pos,
const void *data, size_t data_size)
{
if (!buffer_check_write(buf, &pos, &data_size, TRUE))
@@ -212,12 +213,12 @@
return data_size;
}
-size_t buffer_append(Buffer *buf, const void *data, size_t data_size)
+size_t buffer_append(buffer_t *buf, const void *data, size_t data_size)
{
return buffer_write(buf, buf->used - buf->start_pos, data, data_size);
}
-size_t buffer_append_c(Buffer *buf, char chr)
+size_t buffer_append_c(buffer_t *buf, char chr)
{
size_t pos, data_size = 1;
@@ -230,7 +231,7 @@
return data_size;
}
-size_t buffer_insert(Buffer *buf, size_t pos,
+size_t buffer_insert(buffer_t *buf, size_t pos,
const void *data, size_t data_size)
{
size_t move_size, size;
@@ -259,7 +260,7 @@
return size;
}
-size_t buffer_delete(Buffer *buf, size_t pos, size_t size)
+size_t buffer_delete(buffer_t *buf, size_t pos, size_t size)
{
size_t end_size;
@@ -286,8 +287,8 @@
return size;
}
-size_t buffer_copy(Buffer *dest, size_t dest_pos,
- const Buffer *src, size_t src_pos, size_t copy_size)
+size_t buffer_copy(buffer_t *dest, size_t dest_pos,
+ const buffer_t *src, size_t src_pos, size_t copy_size)
{
if (!buffer_check_read(src, &src_pos, ©_size))
return 0;
@@ -305,14 +306,14 @@
return copy_size;
}
-size_t buffer_append_buf(Buffer *dest, const Buffer *src,
+size_t buffer_append_buf(buffer_t *dest, const buffer_t *src,
size_t src_pos, size_t copy_size)
{
return buffer_copy(dest, dest->used - dest->start_pos,
src, src_pos, copy_size);
}
-void *buffer_get_space(Buffer *buf, size_t pos, size_t size)
+void *buffer_get_space(buffer_t *buf, size_t pos, size_t size)
{
if (!buffer_check_write(buf, &pos, &size, FALSE))
return NULL;
@@ -320,38 +321,38 @@
return buf->w_buffer + pos;
}
-void *buffer_append_space(Buffer *buf, size_t size)
+void *buffer_append_space(buffer_t *buf, size_t size)
{
return buffer_get_space(buf, buf->used - buf->start_pos, size);
}
-const void *buffer_get_data(const Buffer *buf, size_t *used_size)
+const void *buffer_get_data(const buffer_t *buf, size_t *used_size)
{
if (used_size != NULL)
*used_size = I_MIN(buf->used, buf->limit) - buf->start_pos;
return buf->r_buffer + buf->start_pos;
}
-void *buffer_get_modifyable_data(const Buffer *buf, size_t *used_size)
+void *buffer_get_modifyable_data(const buffer_t *buf, size_t *used_size)
{
if (used_size != NULL)
*used_size = I_MIN(buf->used, buf->limit) - buf->start_pos;
return buf->w_buffer + buf->start_pos;
}
-void buffer_set_used_size(Buffer *buf, size_t used_size)
+void buffer_set_used_size(buffer_t *buf, size_t used_size)
{
i_assert(used_size <= I_MIN(buf->alloc, buf->limit) - buf->start_pos);
buf->used = used_size + buf->start_pos;
}
-size_t buffer_get_used_size(const Buffer *buf)
+size_t buffer_get_used_size(const buffer_t *buf)
{
return I_MIN(buf->used, buf->limit) - buf->start_pos;
}
-size_t buffer_set_start_pos(Buffer *buf, size_t abs_pos)
+size_t buffer_set_start_pos(buffer_t *buf, size_t abs_pos)
{
size_t old = buf->start_pos;
@@ -361,12 +362,12 @@
return old;
}
-size_t buffer_get_start_pos(const Buffer *buf)
+size_t buffer_get_start_pos(const buffer_t *buf)
{
return buf->start_pos;
}
-size_t buffer_set_limit(Buffer *buf, size_t limit)
+size_t buffer_set_limit(buffer_t *buf, size_t limit)
{
size_t old = buf->limit;
@@ -379,12 +380,12 @@
return old - buf->start_pos;
}
-size_t buffer_get_limit(const Buffer *buf)
+size_t buffer_get_limit(const buffer_t *buf)
{
return buf->limit - buf->start_pos;
}
-size_t buffer_get_size(const Buffer *buf)
+size_t buffer_get_size(const buffer_t *buf)
{
return buf->alloc - buf->start_pos;
}
@@ -393,7 +394,7 @@
/* gcc buffer.c -o testbuffer liblib.a -Wall -DHAVE_CONFIG_H -DBUFFER_TEST -g */
int main(void)
{
- Buffer *buf;
+ buffer_t *buf;
char data[12], *bufdata;
size_t bufsize;
Index: buffer.h
===================================================================
RCS file: /home/cvs/dovecot/src/lib/buffer.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- buffer.h 18 Dec 2002 15:15:41 -0000 1.3
+++ buffer.h 5 Jan 2003 13:09:51 -0000 1.4
@@ -3,83 +3,83 @@
/* Create a static sized buffer. Writes past this size will simply not
succeed. */
-Buffer *buffer_create_static(Pool pool, size_t size);
+buffer_t *buffer_create_static(pool_t pool, size_t size);
/* Create a static sized buffer. Writes past this size will kill the program. */
-Buffer *buffer_create_static_hard(Pool pool, size_t size);
+buffer_t *buffer_create_static_hard(pool_t pool, size_t size);
/* Create a modifyable buffer from given data. */
-Buffer *buffer_create_data(Pool pool, void *data, size_t size);
+buffer_t *buffer_create_data(pool_t pool, void *data, size_t size);
/* Create a non-modifyable buffer from given data. */
-Buffer *buffer_create_const_data(Pool pool, const void *data, size_t size);
+buffer_t *buffer_create_const_data(pool_t pool, const void *data, size_t size);
/* Creates a dynamically growing buffer. Whenever write would exceed the
current size it's grown. */
-Buffer *buffer_create_dynamic(Pool pool, size_t init_size, size_t max_size);
+buffer_t *buffer_create_dynamic(pool_t pool, size_t init_size, size_t max_size);
/* Free the memory used by buffer. Not needed if the memory is free'd
directly from the memory pool. */
-void buffer_free(Buffer *buf);
+void buffer_free(buffer_t *buf);
/* Free the memory used by buffer structure, but return the buffer data
unfree'd. NOTE: Current start_pos doesn't affect the returned value. */
-void *buffer_free_without_data(Buffer *buf);
+void *buffer_free_without_data(buffer_t *buf);
/* Write data to buffer at specified position, returns number of bytes
written. */
-size_t buffer_write(Buffer *buf, size_t pos,
+size_t buffer_write(buffer_t *buf, size_t pos,
const void *data, size_t data_size);
/* Append data to buffer, returns number of bytes written. */
-size_t buffer_append(Buffer *buf, const void *data, size_t data_size);
+size_t buffer_append(buffer_t *buf, const void *data, size_t data_size);
/* Append character to buffer, returns 1 if written, 0 if not. */
-size_t buffer_append_c(Buffer *buf, char chr);
+size_t buffer_append_c(buffer_t *buf, char chr);
/* Insert data to buffer, returns number of bytes inserted. */
-size_t buffer_insert(Buffer *buf, size_t pos,
+size_t buffer_insert(buffer_t *buf, size_t pos,
const void *data, size_t data_size);
/* Delete data from buffer, returns number of bytes deleted. */
-size_t buffer_delete(Buffer *buf, size_t pos, size_t size);
+size_t buffer_delete(buffer_t *buf, size_t pos, size_t size);
/* Copy data from buffer to another. The buffers may be same in which case
it's internal copying, possibly with overlapping positions (ie. memmove()
like functionality). copy_size may be set to (size_t)-1 to copy the rest of
the used data in buffer. Returns the number of bytes actually copied. */
-size_t buffer_copy(Buffer *dest, size_t dest_pos,
- const Buffer *src, size_t src_pos, size_t copy_size);
+size_t buffer_copy(buffer_t *dest, size_t dest_pos,
+ const buffer_t *src, size_t src_pos, size_t copy_size);
/* Append data to buffer from another. copy_size may be set to (size_t)-1 to
copy the rest of the used data in buffer. */
-size_t buffer_append_buf(Buffer *dest, const Buffer *src,
+size_t buffer_append_buf(buffer_t *dest, const buffer_t *src,
size_t src_pos, size_t copy_size);
/* Returns pointer to specified position in buffer, or NULL if there's not
enough space. */
-void *buffer_get_space(Buffer *buf, size_t pos, size_t size);
+void *buffer_get_space(buffer_t *buf, size_t pos, size_t size);
/* Increase the buffer usage by given size, and return a pointer to beginning
of it, or NULL if there's not enough space in buffer. */
-void *buffer_append_space(Buffer *buf, size_t size);
+void *buffer_append_space(buffer_t *buf, size_t size);
/* Returns pointer to beginning of buffer data. Current used size of buffer is
stored in used_size if it's non-NULL. */
-const void *buffer_get_data(const Buffer *buf, size_t *used_size);
+const void *buffer_get_data(const buffer_t *buf, size_t *used_size);
/* Like buffer_get_data(), but don't return it as const. Returns NULL if the
buffer is non-modifyable. */
-void *buffer_get_modifyable_data(const Buffer *buf, size_t *used_size);
+void *buffer_get_modifyable_data(const buffer_t *buf, size_t *used_size);
/* Set the "used size" of buffer, ie. 0 would set the buffer empty.
Must not be used to grow buffer. */
-void buffer_set_used_size(Buffer *buf, size_t used_size);
+void buffer_set_used_size(buffer_t *buf, size_t used_size);
/* Returns the current used buffer size. */
-size_t buffer_get_used_size(const Buffer *buf);
+size_t buffer_get_used_size(const buffer_t *buf);
/* Change the buffer start position. The buffer acts as if data was removed or
inserted to beginning. Returns the old start position. */
-size_t buffer_set_start_pos(Buffer *buf, size_t abs_pos);
+size_t buffer_set_start_pos(buffer_t *buf, size_t abs_pos);
/* Returns the current start position. */
-size_t buffer_get_start_pos(const Buffer *buf);
+size_t buffer_get_start_pos(const buffer_t *buf);
/* Limit buffer size temporarily. All handling is treated as if this is the
current allocated memory size, except dynamic buffer won't be grown.
Setting the limit to (size_t)-1 removes it. Returns the old limit. */
-size_t buffer_set_limit(Buffer *buf, size_t limit);
+size_t buffer_set_limit(buffer_t *buf, size_t limit);
/* Returns the current buffer limit, or (size_t)-1 if there's none. */
-size_t buffer_get_limit(const Buffer *buf);
+size_t buffer_get_limit(const buffer_t *buf);
/* Returns the current buffer size. */
-size_t buffer_get_size(const Buffer *buf);
+size_t buffer_get_size(const buffer_t *buf);
#endif
Index: compat.h
===================================================================
RCS file: /home/cvs/dovecot/src/lib/compat.h,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- compat.h 18 Dec 2002 15:15:41 -0000 1.15
+++ compat.h 5 Jan 2003 13:09:51 -0000 1.16
@@ -23,6 +23,12 @@
# else
typedef unsigned long uintmax_t;
# endif
+
+# if SIZEOF_INT >= 4
+typedef unsigned int uint_fast32_t;
+# else
+typedef unsigned long uint_fast32_t;
+# endif
#endif
#ifndef HAVE_SOCKLEN_T
Index: data-stack.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib/data-stack.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- data-stack.c 27 Dec 2002 14:01:42 -0000 1.15
+++ data-stack.c 5 Jan 2003 13:09:51 -0000 1.16
@@ -44,29 +44,27 @@
# define INITIAL_STACK_SIZE (1024*32)
#endif
-typedef struct _StackBlock StackBlock;
-typedef struct _StackFrameBlock StackFrameBlock;
-
-struct _StackBlock {
- StackBlock *next;
+struct stack_block {
+ struct stack_block *next;
size_t size, left;
/* unsigned char data[]; */
};
-#define SIZEOF_MEMBLOCK MEM_ALIGN(sizeof(StackBlock))
+#define SIZEOF_MEMBLOCK MEM_ALIGN(sizeof(struct stack_block))
#define STACK_BLOCK_DATA(block) \
((char *) (block) + SIZEOF_MEMBLOCK)
/* current_frame_block contains last t_push()ed frames. After that new
- StackFrameBlock is created and it's ->prev is set to current_frame_block. */
+ stack_frame_block is created and it's ->prev is set to
+ current_frame_block. */
#define BLOCK_FRAME_COUNT 32
-struct _StackFrameBlock {
- StackFrameBlock *prev;
+struct stack_frame_block {
+ struct stack_frame_block *prev;
- StackBlock *block[BLOCK_FRAME_COUNT];
+ struct stack_block *block[BLOCK_FRAME_COUNT];
size_t block_space_used[BLOCK_FRAME_COUNT];
size_t last_alloc_size[BLOCK_FRAME_COUNT];
};
@@ -74,18 +72,18 @@
unsigned int data_stack_frame;
static int frame_pos; /* current frame position current_frame_block */
-static StackFrameBlock *current_frame_block; /* current stack frame block */
-static StackFrameBlock *unused_frame_blocks; /* unused stack frames */
+static struct stack_frame_block *current_frame_block;
+static struct stack_frame_block *unused_frame_blocks;
-static StackBlock *current_block; /* block currently used for allocation */
-static StackBlock *unused_block; /* largest unused block is kept here */
+static struct stack_block *current_block; /* block now used for allocation */
+static struct stack_block *unused_block; /* largest unused block is kept here */
-static StackBlock *last_buffer_block;
+static struct stack_block *last_buffer_block;
static size_t last_buffer_size;
unsigned int t_push(void)
{
- StackFrameBlock *frame_block;
+ struct stack_frame_block *frame_block;
frame_pos++;
if (frame_pos == BLOCK_FRAME_COUNT) {
@@ -93,7 +91,7 @@
frame_pos = 0;
if (unused_frame_blocks == NULL) {
/* allocate new block */
- frame_block = calloc(sizeof(StackFrameBlock), 1);
+ frame_block = calloc(sizeof(*frame_block), 1);
if (frame_block == NULL)
i_panic("t_push(): Out of memory");
} else {
@@ -114,7 +112,7 @@
return data_stack_frame++;
}
-static void free_blocks(StackBlock *block)
+static void free_blocks(struct stack_block *block)
{
/* free all the blocks, except if any of them is bigger than
unused_block, replace it */
@@ -132,7 +130,7 @@
unsigned int t_pop(void)
{
- StackFrameBlock *frame_block;
+ struct stack_frame_block *frame_block;
int popped_frame_pos;
if (frame_pos < 0)
@@ -169,9 +167,9 @@
return --data_stack_frame;
}
-static StackBlock *mem_block_alloc(size_t min_size)
+static struct stack_block *mem_block_alloc(size_t min_size)
{
- StackBlock *block;
+ struct stack_block *block;
size_t prev_size, alloc_size;
prev_size = current_block == NULL ? 0 : current_block->size;
@@ -191,7 +189,7 @@
static void *t_malloc_real(size_t size, int permanent)
{
- StackBlock *block;
+ struct stack_block *block;
void *ret;
#ifdef DEBUG
int warn = FALSE;
@@ -355,7 +353,7 @@
i_panic("Missing t_pop() call");
while (unused_frame_blocks != NULL) {
- StackFrameBlock *frame_block = unused_frame_blocks;
+ struct stack_frame_block *frame_block = unused_frame_blocks;
unused_frame_blocks = unused_frame_blocks->prev;
free(frame_block);
@@ -367,29 +365,26 @@
#else
-typedef struct _StackFrame StackFrame;
-typedef struct _FrameAlloc FrameAlloc;
-
-struct _StackFrame {
- StackFrame *next;
- FrameAlloc *allocs;
+struct stack_frame {
+ struct stack_frame *next;
+ struct frame_alloc *allocs;
};
-struct _FrameAlloc {
- FrameAlloc *next;
+struct frame_alloc {
+ struct frame_alloc *next;
void *mem;
};
unsigned int data_stack_frame;
-static StackFrame *current_frame;
+static struct stack_frame *current_frame;
static void *buffer_mem;
unsigned int t_push(void)
{
- StackFrame *frame;
+ struct stack_frame *frame;
- frame = malloc(sizeof(StackFrame));
+ frame = malloc(sizeof(struct stack_frame));
if (frame == NULL)
i_panic("t_push(): Out of memory");
frame->allocs = NULL;
@@ -401,8 +396,8 @@
unsigned int t_pop(void)
{
- StackFrame *frame;
- FrameAlloc *alloc;
+ struct stack_frame *frame;
+ struct frame_alloc *alloc;
frame = current_frame;
current_frame = frame->next;
@@ -421,9 +416,9 @@
static void add_alloc(void *mem)
{
- FrameAlloc *alloc;
+ struct frame_alloc *alloc;
- alloc = malloc(sizeof(FrameAlloc));
+ alloc = malloc(sizeof(struct frame_alloc));
if (alloc == NULL)
i_panic("add_alloc(): Out of memory");
alloc->mem = mem;
Index: env-util.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib/env-util.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- env-util.c 21 Dec 2002 13:08:49 -0000 1.5
+++ env-util.c 5 Jan 2003 13:09:51 -0000 1.6
@@ -28,7 +28,7 @@
#include <stdlib.h>
-static Pool pool = NULL;
+static pool_t pool = NULL;
void env_put(const char *env)
{
Index: failures.h
===================================================================
RCS file: /home/cvs/dovecot/src/lib/failures.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- failures.h 28 Dec 2002 08:06:34 -0000 1.5
+++ failures.h 5 Jan 2003 13:09:51 -0000 1.6
@@ -2,7 +2,7 @@
#define __FAILURES_H
/* Default exit status codes that we could use. */
-typedef enum {
+enum fatal_exit_status {
FATAL_LOGOPEN = 80, /* Can't open log file */
FATAL_LOGWRITE = 81, /* Can't write to log file */
FATAL_LOGERROR = 82, /* Internal logging error */
@@ -10,7 +10,7 @@
FATAL_EXEC = 84, /* exec() failed */
FATAL_DEFAULT = 89
-} FatalExitStatus;
+};
#define DEFAULT_FAILURE_STAMP_FORMAT "%b %d %H:%M:%S "
Index: hash.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib/hash.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- hash.c 26 Nov 2002 20:35:47 -0000 1.6
+++ hash.c 5 Jan 2003 13:09:51 -0000 1.7
@@ -35,28 +35,28 @@
#define HASH_TABLE_MIN_SIZE 11
#define HASH_TABLE_MAX_SIZE 13845163
-typedef struct _HashNode {
+struct hash_node {
void *key;
void *value;
int destroyed;
- struct _HashNode *next;
-} HashNode;
+ struct hash_node *next;
+};
-struct _HashTable {
- Pool pool;
+struct hash_table {
+ pool_t pool;
unsigned int size;
unsigned int nodes_count, nodes_destroyed;
int frozen;
- HashNode **nodes;
+ struct hash_node **nodes;
HashFunc hash_func;
HashCompareFunc key_compare_func;
};
-static void hash_cleanup(HashTable *table);
-static int hash_resize(HashTable *table);
+static void hash_cleanup(struct hash_table *table);
+static int hash_resize(struct hash_table *table);
static int foreach_stop;
@@ -66,20 +66,20 @@
return POINTER_CAST_TO(p, unsigned int);
}
-static HashNode *hash_node_create(Pool pool, void *key, void *value)
+static struct hash_node *hash_node_create(pool_t pool, void *key, void *value)
{
- HashNode *node;
+ struct hash_node *node;
- node = p_new(pool, HashNode, 1);
+ node = p_new(pool, struct hash_node, 1);
node->key = key;
node->value = value;
return node;
}
-static void hash_nodes_destroy(HashTable *table, HashNode *node)
+static void hash_nodes_destroy(struct hash_table *table, struct hash_node *node)
{
- HashNode *next;
+ struct hash_node *next;
while (node != NULL) {
next = node->next;
@@ -88,14 +88,15 @@
}
}
-HashTable *hash_create(Pool pool, unsigned int initial_size,
- HashFunc hash_func, HashCompareFunc key_compare_func)
+struct hash_table *hash_create(pool_t pool, unsigned int initial_size,
+ HashFunc hash_func,
+ HashCompareFunc key_compare_func)
{
- HashTable *table;
+ struct hash_table *table;
i_assert(pool != NULL);
- table = p_new(pool, HashTable, 1);
+ table = p_new(pool, struct hash_table, 1);
table->pool = pool;
table->size = CLAMP(primes_closest(initial_size),
HASH_TABLE_MIN_SIZE,
@@ -103,12 +104,12 @@
table->hash_func = hash_func != NULL ? hash_func : direct_hash;
table->key_compare_func = key_compare_func;
- table->nodes = p_new(pool, HashNode *, table->size);
+ table->nodes = p_new(pool, struct hash_node *, table->size);
return table;
}
-void hash_destroy(HashTable *table)
+void hash_destroy(struct hash_table *table)
{
unsigned int i;
@@ -122,7 +123,7 @@
p_free(table->pool, table);
}
-void hash_clear(HashTable *table)
+void hash_clear(struct hash_table *table)
{
unsigned int i;
@@ -134,10 +135,10 @@
}
}
-static inline HashNode **
-hash_lookup_node(HashTable *table, const void *key)
+static inline struct hash_node **
+hash_lookup_node(struct hash_table *table, const void *key)
{
- HashNode **node;
+ struct hash_node **node;
node = &table->nodes[table->hash_func(key) % table->size];
@@ -160,9 +161,9 @@
return node;
}
-void *hash_lookup(HashTable *table, const void *key)
+void *hash_lookup(struct hash_table *table, const void *key)
{
- HashNode *node;
+ struct hash_node *node;
i_assert(table != NULL);
@@ -170,10 +171,10 @@
return node != NULL && !node->destroyed ? node->value : NULL;
}
-int hash_lookup_full(HashTable *table, const void *lookup_key,
+int hash_lookup_full(struct hash_table *table, const void *lookup_key,
void **orig_key, void **value)
{
- HashNode *node;
+ struct hash_node *node;
i_assert(table != NULL);
@@ -188,10 +189,10 @@
return TRUE;
}
-static void hash_insert_full(HashTable *table, void *key, void *value,
+static void hash_insert_full(struct hash_table *table, void *key, void *value,
int replace_key)
{
- HashNode **node;
+ struct hash_node **node;
i_assert(table != NULL);
@@ -212,19 +213,19 @@
}
}
-void hash_insert(HashTable *table, void *key, void *value)
+void hash_insert(struct hash_table *table, void *key, void *value)
{
hash_insert_full(table, key, value, TRUE);
}
-void hash_update(HashTable *table, void *key, void *value)
+void hash_update(struct hash_table *table, void *key, void *value)
{
hash_insert_full(table, key, value, FALSE);
}
-void hash_remove(HashTable *table, const void *key)
+void hash_remove(struct hash_table *table, const void *key)
{
- HashNode **node, *old_node;
+ struct hash_node **node, *old_node;
i_assert(table != NULL);
@@ -245,14 +246,14 @@
}
}
-void hash_freeze(HashTable *table)
+void hash_freeze(struct hash_table *table)
{
i_assert(table != NULL);
table->frozen++;
}
-void hash_thaw(HashTable *table)
+void hash_thaw(struct hash_table *table)
{
i_assert(table != NULL);
i_assert(table->frozen > 0);
@@ -261,9 +262,9 @@
hash_cleanup(table);
}
-void hash_foreach(HashTable *table, HashForeachFunc func, void *context)
+void hash_foreach(struct hash_table *table, HashForeachFunc func, void *context)
{
- HashNode *node;
+ struct hash_node *node;
unsigned int i;
i_assert(table != NULL);
@@ -294,17 +295,17 @@
}
/* Returns the number of elements contained in the hash table. */
-unsigned int hash_size(HashTable *table)
+unsigned int hash_size(struct hash_table *table)
{
i_assert(table != NULL);
return table->nodes_count;
}
-static int hash_resize(HashTable *table)
+static int hash_resize(struct hash_table *table)
{
HashFunc hash_func;
- HashNode *node, *next, **new_nodes;
+ struct hash_node *node, *next, **new_nodes;
float nodes_per_list;
unsigned int hash_val, new_size, i;
@@ -317,7 +318,7 @@
HASH_TABLE_MIN_SIZE,
HASH_TABLE_MAX_SIZE);
- new_nodes = p_new(table->pool, HashNode *, new_size);
+ new_nodes = p_new(table->pool, struct hash_node *, new_size);
hash_func = table->hash_func;
for (i = 0; i < table->size; i++) {
@@ -342,9 +343,9 @@
return TRUE;
}
-static void hash_cleanup(HashTable *table)
+static void hash_cleanup(struct hash_table *table)
{
- HashNode **node, **next, *old_node;
+ struct hash_node **node, **next, *old_node;
unsigned int i;
if (hash_resize(table))
Index: hash.h
===================================================================
RCS file: /home/cvs/dovecot/src/lib/hash.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- hash.h 26 Nov 2002 20:35:47 -0000 1.3
+++ hash.h 5 Jan 2003 13:09:51 -0000 1.4
@@ -7,14 +7,13 @@
typedef int (*HashCompareFunc) (const void *p1, const void *p2);
typedef void (*HashForeachFunc) (void *key, void *value, void *context);
-typedef struct _HashTable HashTable;
-
/* Create a new hash table. If initial_size is 0, the default value is used.
If hash_func or key_compare_func is NULL, direct hashing/comparing
is used. */
-HashTable *hash_create(Pool pool, unsigned int initial_size,
- HashFunc hash_func, HashCompareFunc key_compare_func);
-void hash_destroy(HashTable *table);
+struct hash_table *hash_create(pool_t pool, unsigned int initial_size,
+ HashFunc hash_func,
+ HashCompareFunc key_compare_func);
+void hash_destroy(struct hash_table *table);
#ifdef POOL_CHECK_LEAKS
# define hash_destroy_clean(table) hash_destroy(table)
@@ -22,31 +21,32 @@
# define hash_destroy_clean(table)
#endif
-void hash_clear(HashTable *table);
+void hash_clear(struct hash_table *table);
-void *hash_lookup(HashTable *table, const void *key);
-int hash_lookup_full(HashTable *table, const void *lookup_key,
+void *hash_lookup(struct hash_table *table, const void *key);
+int hash_lookup_full(struct hash_table *table, const void *lookup_key,
void **orig_key, void **value);
/* Insert/update node in hash table. The difference is that hash_insert()
replaces the key in table to given one, while hash_update() doesnt. */
-void hash_insert(HashTable *table, void *key, void *value);
-void hash_update(HashTable *table, void *key, void *value);
+void hash_insert(struct hash_table *table, void *key, void *value);
+void hash_update(struct hash_table *table, void *key, void *value);
-void hash_remove(HashTable *table, const void *key);
-unsigned int hash_size(HashTable *table);
+void hash_remove(struct hash_table *table, const void *key);
+unsigned int hash_size(struct hash_table *table);
/* Calls the given function for each node in hash table. You may safely
call hash_*() functions inside your function, but if you add any
new nodes, they may or may not be called for in this foreach loop. */
-void hash_foreach(HashTable *table, HashForeachFunc func, void *context);
+void hash_foreach(struct hash_table *table,
+ HashForeachFunc func, void *context);
/* Stop the active hash_foreach() loop */
void hash_foreach_stop(void);
/* Hash table isn't resized, and removed nodes aren't removed from
the list while hash table is freezed. Supports nesting. */
-void hash_freeze(HashTable *table);
-void hash_thaw(HashTable *table);
+void hash_freeze(struct hash_table *table);
+void hash_thaw(struct hash_table *table);
/* hash function for strings */
unsigned int str_hash(const void *p);
Index: hex-binary.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib/hex-binary.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- hex-binary.c 18 Dec 2002 15:15:41 -0000 1.4
+++ hex-binary.c 5 Jan 2003 13:09:51 -0000 1.5
@@ -48,7 +48,7 @@
return buf;
}
-int hex_to_binary(const char *data, Buffer *dest)
+int hex_to_binary(const char *data, buffer_t *dest)
{
int value;
Index: hex-binary.h
===================================================================
RCS file: /home/cvs/dovecot/src/lib/hex-binary.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- hex-binary.h 8 Dec 2002 05:23:07 -0000 1.5
+++ hex-binary.h 5 Jan 2003 13:09:51 -0000 1.6
@@ -8,6 +8,6 @@
/* Convert hex to binary. data and dest may point to same value.
Returns TRUE if successful. Returns 1 if all ok, 0 if dest buffer got full
or -1 if data is invalid. */
-int hex_to_binary(const char *data, Buffer *dest);
+int hex_to_binary(const char *data, buffer_t *dest);
#endif
Index: imem.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib/imem.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- imem.c 4 Jan 2003 17:26:29 -0000 1.6
+++ imem.c 5 Jan 2003 13:09:51 -0000 1.7
@@ -25,7 +25,7 @@
#include "lib.h"
-Pool default_pool;
+pool_t default_pool;
void *i_malloc(size_t size)
{
Index: imem.h
===================================================================
RCS file: /home/cvs/dovecot/src/lib/imem.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- imem.h 4 Jan 2003 17:26:29 -0000 1.6
+++ imem.h 5 Jan 2003 13:09:51 -0000 1.7
@@ -1,7 +1,7 @@
#ifndef __IMEM_H
#define __IMEM_H
-extern Pool default_pool;
+extern pool_t default_pool;
/* For easy allocation of memory from default memory pool. */
#define i_new(type, count) \
Index: ioloop-internal.h
===================================================================
RCS file: /home/cvs/dovecot/src/lib/ioloop-internal.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- ioloop-internal.h 22 Aug 2002 12:48:38 -0000 1.2
+++ ioloop-internal.h 5 Jan 2003 13:09:51 -0000 1.3
@@ -5,24 +5,22 @@
#include <sys/time.h>
-typedef struct _IOLoopHandlerData IOLoopHandlerData;
-
-struct _IOLoop {
- struct _IOLoop *prev;
+struct ioloop {
+ struct ioloop *prev;
- Pool pool;
+ pool_t pool;
int highest_fd;
- IO ios; /* sorted by priority */
- Timeout timeouts; /* sorted by next_run */
+ struct io *ios; /* sorted by priority */
+ struct timeout *timeouts; /* sorted by next_run */
- IOLoopHandlerData *handler_data;
+ struct ioloop_handler_data *handler_data;
unsigned int running:1;
};
-struct _IO {
- IO prev, next;
+struct io {
+ struct io *prev, *next;
int fd;
int priority;
@@ -35,8 +33,8 @@
void *context;
};
-struct _Timeout {
- Timeout next;
+struct timeout {
+ struct timeout *next;
struct timeval next_run;
int msecs;
@@ -47,20 +45,20 @@
void *context;
};
-int io_loop_get_wait_time(Timeout timeout, struct timeval *tv,
+int io_loop_get_wait_time(struct timeout *timeout, struct timeval *tv,
struct timeval *tv_now);
-void io_loop_handle_timeouts(IOLoop ioloop);
+void io_loop_handle_timeouts(struct ioloop *ioloop);
/* call only when io->destroyed is TRUE */
-void io_destroy(IOLoop ioloop, IO io);
+void io_destroy(struct ioloop *ioloop, struct io *io);
/* call only when timeout->destroyed is TRUE */
-void timeout_destroy(IOLoop ioloop, Timeout timeout);
+void timeout_destroy(struct ioloop *ioloop, struct timeout *timeout);
/* I/O handler calls */
-void io_loop_handle_add(IOLoop ioloop, int fd, int condition);
-void io_loop_handle_remove(IOLoop ioloop, int fd, int condition);
+void io_loop_handle_add(struct ioloop *ioloop, int fd, int condition);
+void io_loop_handle_remove(struct ioloop *ioloop, int fd, int condition);
-void io_loop_handler_init(IOLoop ioloop);
-void io_loop_handler_deinit(IOLoop ioloop);
+void io_loop_handler_init(struct ioloop *ioloop);
+void io_loop_handler_deinit(struct ioloop *ioloop);
#endif
Index: ioloop-poll.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib/ioloop-poll.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- ioloop-poll.c 4 Jan 2003 17:34:02 -0000 1.6
+++ ioloop-poll.c 5 Jan 2003 13:09:51 -0000 1.7
@@ -36,7 +36,7 @@
# define INITIAL_POLL_FDS 128
#endif
-struct _IOLoopHandlerData {
+struct ioloop_handler_data {
unsigned int fds_size, fds_pos;
struct pollfd *fds;
@@ -44,12 +44,12 @@
int *fd_index;
};
-void io_loop_handler_init(IOLoop ioloop)
+void io_loop_handler_init(struct ioloop *ioloop)
{
- IOLoopHandlerData *data;
+ struct ioloop_handler_data *data;
ioloop->handler_data = data =
- p_new(ioloop->pool, IOLoopHandlerData, 1);
+ p_new(ioloop->pool, struct ioloop_handler_data, 1);
data->fds_size = INITIAL_POLL_FDS;
data->fds = p_new(ioloop->pool, struct pollfd, data->fds_size);
@@ -58,7 +58,7 @@
memset(data->fd_index, 0xff, sizeof(int) * data->idx_size);
}
-void io_loop_handler_deinit(IOLoop ioloop)
+void io_loop_handler_deinit(struct ioloop *ioloop)
{
p_free(ioloop->pool, ioloop->handler_data->fds);
p_free(ioloop->pool, ioloop->handler_data->fd_index);
@@ -68,12 +68,11 @@
#define IO_POLL_INPUT (POLLIN|POLLPRI|POLLERR|POLLHUP|POLLNVAL)
#define IO_POLL_OUTPUT (POLLOUT|POLLERR|POLLHUP|POLLNVAL)
-void io_loop_handle_add(IOLoop ioloop, int fd, int condition)
+void io_loop_handle_add(struct ioloop *ioloop, int fd, int condition)
{
- IOLoopHandlerData *data;
+ struct ioloop_handler_data *data = ioloop->handler_data;
int index, old_size;
- data = ioloop->handler_data;
if ((unsigned int) fd >= data->idx_size) {
/* grow the fd -> index array */
old_size = data->idx_size;
@@ -111,12 +110,11 @@
data->fds[index].events |= IO_POLL_OUTPUT;
}
-void io_loop_handle_remove(IOLoop ioloop, int fd, int condition)
+void io_loop_handle_remove(struct ioloop *ioloop, int fd, int condition)
{
- IOLoopHandlerData *data;
+ struct ioloop_handler_data *data = ioloop->handler_data;
int index;
- data = ioloop->handler_data;
index = data->fd_index[fd];
i_assert(index >= 0 && (unsigned int) index < data->fds_size);
@@ -137,16 +135,14 @@
}
}
-void io_loop_handler_run(IOLoop ioloop)
+void io_loop_handler_run(struct ioloop *ioloop)
{
- IOLoopHandlerData *data;
+ struct ioloop_handler_data *data = ioloop->handler_data;
struct pollfd *pollfd;
struct timeval tv;
- IO io, next;
+ struct io *io, *next;
unsigned int t_id;
int msecs, ret;
-
- data = ioloop->handler_data;
/* get the time left for next timeout task */
msecs = io_loop_get_wait_time(ioloop->timeouts, &tv, NULL);
Index: ioloop-select.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib/ioloop-select.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- ioloop-select.c 21 Dec 2002 14:06:21 -0000 1.8
+++ ioloop-select.c 5 Jan 2003 13:09:51 -0000 1.9
@@ -34,25 +34,26 @@
#include <sys/time.h>
#include <unistd.h>
-struct _IOLoopHandlerData {
+struct ioloop_handler_data {
fd_set read_fds, write_fds;
};
static fd_set tmp_read_fds, tmp_write_fds;
-void io_loop_handler_init(IOLoop ioloop)
+void io_loop_handler_init(struct ioloop *ioloop)
{
- ioloop->handler_data = p_new(ioloop->pool, IOLoopHandlerData, 1);
+ ioloop->handler_data =
+ p_new(ioloop->pool, struct ioloop_handler_data, 1);
FD_ZERO(&ioloop->handler_data->read_fds);
FD_ZERO(&ioloop->handler_data->write_fds);
}
-void io_loop_handler_deinit(IOLoop ioloop)
+void io_loop_handler_deinit(struct ioloop *ioloop)
{
p_free(ioloop->pool, ioloop->handler_data);
}
-void io_loop_handle_add(IOLoop ioloop, int fd, int condition)
+void io_loop_handle_add(struct ioloop *ioloop, int fd, int condition)
{
i_assert(fd >= 0);
@@ -65,7 +66,7 @@
FD_SET(fd, &ioloop->handler_data->write_fds);
}
-void io_loop_handle_remove(IOLoop ioloop, int fd, int condition)
+void io_loop_handle_remove(struct ioloop *ioloop, int fd, int condition)
{
i_assert(fd >= 0 && fd < FD_SETSIZE);
@@ -76,15 +77,13 @@
}
#define io_check_condition(fd, condition) \
- ((((condition) & IO_READ) && \
- FD_ISSET((fd), &tmp_read_fds)) || \
- (((condition) & IO_WRITE) && \
- FD_ISSET((fd), &tmp_write_fds)))
+ ((((condition) & IO_READ) && FD_ISSET((fd), &tmp_read_fds)) || \
+ (((condition) & IO_WRITE) && FD_ISSET((fd), &tmp_write_fds)))
-void io_loop_handler_run(IOLoop ioloop)
+void io_loop_handler_run(struct ioloop *ioloop)
{
struct timeval tv;
- IO io, next;
+ struct io *io, *next;
unsigned int t_id;
int ret, fd, condition;
Index: ioloop.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib/ioloop.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- ioloop.c 4 Jan 2003 17:34:02 -0000 1.8
+++ ioloop.c 5 Jan 2003 13:09:51 -0000 1.9
@@ -23,7 +23,7 @@
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
-/* FIXME: inserting IO is slow if there's lots of them. I should add a linked
+/* FIXME: inserting io is slow if there's lots of them. I should add a linked
list of priorities pointing to first item in the list with the priority. */
#include "lib.h"
@@ -39,11 +39,11 @@
struct timeval ioloop_timeval;
struct timezone ioloop_timezone;
-static IOLoop current_ioloop = NULL;
+static struct ioloop *current_ioloop = NULL;
-static void update_highest_fd(IOLoop ioloop)
+static void update_highest_fd(struct ioloop *ioloop)
{
- IO io;
+ struct io *io;
int max_highest_fd;
max_highest_fd = ioloop->highest_fd-1;
@@ -59,9 +59,9 @@
}
}
-static void io_list_insert(IOLoop ioloop, IO io)
+static void io_list_insert(struct ioloop *ioloop, struct io *io)
{
- IO prev, next;
+ struct io *prev, *next;
prev = NULL;
for (next = ioloop->ios; next != NULL; next = next->next) {
@@ -83,21 +83,21 @@
}
}
-IO io_add(int fd, int condition, IOFunc func, void *data)
+struct io *io_add(int fd, int condition, IOFunc func, void *data)
{
return io_add_priority(fd, IO_PRIORITY_DEFAULT,
condition, func, data);
}
-IO io_add_priority(int fd, int priority, int condition,
- IOFunc func, void *context)
+struct io *io_add_priority(int fd, int priority, int condition,
+ IOFunc func, void *context)
{
- IO io;
+ struct io *io;
i_assert(fd >= 0);
i_assert(func != NULL);
- io = p_new(current_ioloop->pool, struct _IO, 1);
+ io = p_new(current_ioloop->pool, struct io, 1);
io->fd = fd;
io->priority = priority;
io->condition = condition;
@@ -114,7 +114,7 @@
return io;
}
-void io_remove(IO io)
+void io_remove(struct io *io)
{
i_assert(io != NULL);
i_assert(io->fd >= 0);
@@ -131,7 +131,7 @@
io->fd = -1;
}
-void io_destroy(IOLoop ioloop, IO io)
+void io_destroy(struct ioloop *ioloop, struct io *io)
{
/* remove from list */
if (io->prev == NULL)
@@ -145,9 +145,9 @@
p_free(ioloop->pool, io);
}
-static void timeout_list_insert(IOLoop ioloop, Timeout timeout)
+static void timeout_list_insert(struct ioloop *ioloop, struct timeout *timeout)
{
- Timeout *t;
+ struct timeout **t;
struct timeval *next_run;
next_run = &timeout->next_run;
@@ -160,7 +160,8 @@
*t = timeout;
}
-inline static void timeout_update_next(Timeout timeout, struct timeval *tv_now)
+inline static void
+timeout_update_next(struct timeout *timeout, struct timeval *tv_now)
{
if (tv_now == NULL)
gettimeofday(&timeout->next_run, NULL);
@@ -183,11 +184,11 @@
}
}
-Timeout timeout_add(int msecs, TimeoutFunc func, void *context)
+struct timeout *timeout_add(int msecs, TimeoutFunc func, void *context)
{
- Timeout timeout;
+ struct timeout *timeout;
- timeout = p_new(current_ioloop->pool, struct _Timeout, 1);
+ timeout = p_new(current_ioloop->pool, struct timeout, 1);
timeout->msecs = msecs;
timeout->func = func;
@@ -199,16 +200,16 @@
return timeout;
}
-void timeout_remove(Timeout timeout)
+void timeout_remove(struct timeout *timeout)
{
i_assert(timeout != NULL);
timeout->destroyed = TRUE;
}
-void timeout_destroy(IOLoop ioloop, Timeout timeout)
+void timeout_destroy(struct ioloop *ioloop, struct timeout *timeout)
{
- Timeout *t;
+ struct timeout **t;
for (t = &ioloop->timeouts; *t != NULL; t = &(*t)->next) {
if (*t == timeout)
@@ -219,7 +220,7 @@
p_free(ioloop->pool, timeout);
}
-int io_loop_get_wait_time(Timeout timeout, struct timeval *tv,
+int io_loop_get_wait_time(struct timeout *timeout, struct timeval *tv,
struct timeval *tv_now)
{
if (timeout == NULL)
@@ -248,9 +249,9 @@
return 0;
}
-void io_loop_handle_timeouts(IOLoop ioloop)
+void io_loop_handle_timeouts(struct ioloop *ioloop)
{
- Timeout t, next;
+ struct timeout *t, *next;
struct timeval tv;
unsigned int t_id;
@@ -285,32 +286,32 @@
}
}
-void io_loop_run(IOLoop ioloop)
+void io_loop_run(struct ioloop *ioloop)
{
ioloop->running = TRUE;
while (ioloop->running)
io_loop_handler_run(ioloop);
}
-void io_loop_stop(IOLoop ioloop)
+void io_loop_stop(struct ioloop *ioloop)
{
ioloop->running = FALSE;
}
-void io_loop_set_running(IOLoop ioloop)
+void io_loop_set_running(struct ioloop *ioloop)
{
ioloop->running = TRUE;
}
-IOLoop io_loop_create(Pool pool)
+struct ioloop *io_loop_create(pool_t pool)
{
- IOLoop ioloop;
+ struct ioloop *ioloop;
/* initialize time */
gettimeofday(&ioloop_timeval, &ioloop_timezone);
ioloop_time = ioloop_timeval.tv_sec;
- ioloop = p_new(pool, struct _IOLoop, 1);
+ ioloop = p_new(pool, struct ioloop, 1);
pool_ref(pool);
ioloop->pool = pool;
ioloop->highest_fd = -1;
@@ -323,10 +324,10 @@
return ioloop;
}
-void io_loop_destroy(IOLoop ioloop)
+void io_loop_destroy(struct ioloop *ioloop)
{
while (ioloop->ios != NULL) {
- IO io = ioloop->ios;
+ struct io *io = ioloop->ios;
if (!io->destroyed) {
i_warning("I/O leak: %p (%d)",
@@ -337,7 +338,7 @@
}
while (ioloop->timeouts != NULL) {
- Timeout to = ioloop->timeouts;
+ struct timeout *to = ioloop->timeouts;
if (!to->destroyed) {
i_warning("Timeout leak: %p", (void *) to->func);
Index: ioloop.h
===================================================================
RCS file: /home/cvs/dovecot/src/lib/ioloop.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- ioloop.h 24 Oct 2002 00:15:38 -0000 1.4
+++ ioloop.h 5 Jan 2003 13:09:51 -0000 1.5
@@ -10,8 +10,12 @@
#define IO_PRIORITY_DEFAULT 0
#define IO_PRIORITY_HIGH -100
-typedef void (*IOFunc) (void *context, int fd, IO io);
-typedef void (*TimeoutFunc) (void *context, Timeout timeout);
+struct io;
+struct timeout;
+struct ioloop;
+
+typedef void (*IOFunc) (void *context, int fd, struct io *io);
+typedef void (*TimeoutFunc) (void *context, struct timeout *timeout);
/* Time when the I/O loop started calling handlers.
Can be used instead of time(NULL). */
@@ -22,23 +26,23 @@
/* I/O listeners - you can create different handlers for IO_READ and IO_WRITE,
but make sure you don't create multiple handlers of same type, it's not
checked and removing one will stop the other from working as well. */
-IO io_add(int fd, int condition, IOFunc func, void *context);
-IO io_add_priority(int fd, int priority, int condition,
- IOFunc func, void *context);
-void io_remove(IO io);
+struct io *io_add(int fd, int condition, IOFunc func, void *context);
+struct io *io_add_priority(int fd, int priority, int condition,
+ IOFunc func, void *context);
+void io_remove(struct io *io);
/* Timeout handlers */
-Timeout timeout_add(int msecs, TimeoutFunc func, void *context);
-void timeout_remove(Timeout timeout);
+struct timeout *timeout_add(int msecs, TimeoutFunc func, void *context);
+void timeout_remove(struct timeout *timeout);
-void io_loop_run(IOLoop ioloop);
-void io_loop_stop(IOLoop ioloop); /* safe to run in signal handler */
+void io_loop_run(struct ioloop *ioloop);
+void io_loop_stop(struct ioloop *ioloop); /* safe to run in signal handler */
/* call these if you wish to run the iteration only once */
-void io_loop_set_running(IOLoop ioloop);
-void io_loop_handler_run(IOLoop ioloop);
+void io_loop_set_running(struct ioloop *ioloop);
+void io_loop_handler_run(struct ioloop *ioloop);
-IOLoop io_loop_create(Pool pool);
-void io_loop_destroy(IOLoop ioloop);
+struct ioloop *io_loop_create(pool_t pool);
+void io_loop_destroy(struct ioloop *ioloop);
#endif
Index: iostream-internal.h
===================================================================
RCS file: /home/cvs/dovecot/src/lib/iostream-internal.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- iostream-internal.h 6 Dec 2002 01:09:22 -0000 1.1
+++ iostream-internal.h 5 Jan 2003 13:09:51 -0000 1.2
@@ -3,25 +3,23 @@
/* This file is private to IStream and OStream implementation */
-typedef struct _IOStream _IOStream;
-
-struct _IOStream {
- Pool pool;
+struct _iostream {
+ pool_t pool;
int refcount;
- void (*close)(_IOStream *stream);
- void (*destroy)(_IOStream *stream);
- void (*set_max_buffer_size)(_IOStream *stream, size_t max_size);
- void (*set_blocking)(_IOStream *stream, int timeout_msecs,
+ void (*close)(struct _iostream *stream);
+ void (*destroy)(struct _iostream *stream);
+ void (*set_max_buffer_size)(struct _iostream *stream, size_t max_size);
+ void (*set_blocking)(struct _iostream *stream, int timeout_msecs,
void (*timeout_func)(void *), void *context);
};
-void _io_stream_init(Pool pool, _IOStream *stream);
-void _io_stream_ref(_IOStream *stream);
-void _io_stream_unref(_IOStream *stream);
-void _io_stream_close(_IOStream *stream);
-void _io_stream_set_max_buffer_size(_IOStream *stream, size_t max_size);
-void _io_stream_set_blocking(_IOStream *stream, int timeout_msecs,
+void _io_stream_init(pool_t pool, struct _iostream *stream);
+void _io_stream_ref(struct _iostream *stream);
+void _io_stream_unref(struct _iostream *stream);
+void _io_stream_close(struct _iostream *stream);
+void _io_stream_set_max_buffer_size(struct _iostream *stream, size_t max_size);
+void _io_stream_set_blocking(struct _iostream *stream, int timeout_msecs,
void (*timeout_func)(void *), void *context);
#define GET_TIMEOUT_TIME(fstream) \
Index: iostream.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib/iostream.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- iostream.c 6 Dec 2002 01:09:22 -0000 1.1
+++ iostream.c 5 Jan 2003 13:09:51 -0000 1.2
@@ -26,20 +26,20 @@
#include "lib.h"
#include "iostream-internal.h"
-void _io_stream_init(Pool pool, _IOStream *stream)
+void _io_stream_init(pool_t pool, struct _iostream *stream)
{
stream->pool = pool;
stream->refcount = 1;
}
-void _io_stream_ref(_IOStream *stream)
+void _io_stream_ref(struct _iostream *stream)
{
stream->refcount++;
}
-void _io_stream_unref(_IOStream *stream)
+void _io_stream_unref(struct _iostream *stream)
{
- Pool pool;
+ pool_t pool;
i_assert(stream->refcount > 0);
if (--stream->refcount != 0)
@@ -53,17 +53,17 @@
pool_unref(pool);
}
-void _io_stream_close(_IOStream *stream)
+void _io_stream_close(struct _iostream *stream)
{
stream->close(stream);
}
-void _io_stream_set_max_buffer_size(_IOStream *stream, size_t max_size)
+void _io_stream_set_max_buffer_size(struct _iostream *stream, size_t max_size)
{
stream->set_max_buffer_size(stream, max_size);
}
-void _io_stream_set_blocking(_IOStream *stream, int timeout_msecs,
+void _io_stream_set_blocking(struct _iostream *stream, int timeout_msecs,
void (*timeout_func)(void *), void *context)
{
stream->set_blocking(stream, timeout_msecs, timeout_func, context);
Index: istream-data.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib/istream-data.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- istream-data.c 4 Jan 2003 17:26:29 -0000 1.2
+++ istream-data.c 5 Jan 2003 13:09:51 -0000 1.3
@@ -26,48 +26,49 @@
#include "lib.h"
#include "istream-internal.h"
-static void _close(_IOStream *stream __attr_unused__)
+static void _close(struct _iostream *stream __attr_unused__)
{
}
-static void _destroy(_IOStream *stream __attr_unused__)
+static void _destroy(struct _iostream *stream __attr_unused__)
{
}
-static void _set_max_buffer_size(_IOStream *stream __attr_unused__,
+static void _set_max_buffer_size(struct _iostream *stream __attr_unused__,
size_t max_size __attr_unused__)
{
}
-static void _set_blocking(_IOStream *stream __attr_unused__,
+static void _set_blocking(struct _iostream *stream __attr_unused__,
int timeout_msecs __attr_unused__,
void (*timeout_func)(void *) __attr_unused__,
void *context __attr_unused__)
{
}
-static ssize_t _read(_IStream *stream)
+static ssize_t _read(struct _istream *stream)
{
return stream->pos - stream->skip;
}
-static void _seek(_IStream *stream, uoff_t v_offset)
+static void _seek(struct _istream *stream, uoff_t v_offset)
{
stream->skip = v_offset;
stream->istream.v_offset = v_offset;
}
-static void _skip(_IStream *stream, uoff_t count)
+static void _skip(struct _istream *stream, uoff_t count)
{
stream->skip += count;
stream->istream.v_offset += count;
}
-IStream *i_stream_create_from_data(Pool pool, const void *data, size_t size)
+struct istream *i_stream_create_from_data(pool_t pool, const void *data,
+ size_t size)
{
- _IStream *stream;
+ struct _istream *stream;
- stream = p_new(pool, _IStream, 1);
+ stream = p_new(pool, struct _istream, 1);
stream->buffer = data;
stream->pos = size;
Index: istream-file.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib/istream-file.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- istream-file.c 18 Dec 2002 15:15:41 -0000 1.3
+++ istream-file.c 5 Jan 2003 13:09:51 -0000 1.4
@@ -39,8 +39,8 @@
#define STREAM_IS_BLOCKING(fstream) \
((fstream)->timeout_msecs != 0)
-typedef struct {
- _IStream istream;
+struct file_istream {
+ struct _istream istream;
size_t max_buffer_size;
uoff_t skip_left;
@@ -51,38 +51,38 @@
unsigned int file:1;
unsigned int autoclose_fd:1;
-} FileIStream;
+};
-static void _close(_IOStream *stream)
+static void _close(struct _iostream *stream)
{
- FileIStream *fstream = (FileIStream *) stream;
- _IStream *_stream = (_IStream *) stream;
+ struct file_istream *fstream = (struct file_istream *) stream;
+ struct _istream *_stream = (struct _istream *) stream;
if (fstream->autoclose_fd && _stream->fd != -1) {
if (close(_stream->fd) < 0)
- i_error("FileIStream.close() failed: %m");
+ i_error("file_istream.close() failed: %m");
_stream->fd = -1;
}
}
-static void _destroy(_IOStream *stream)
+static void _destroy(struct _iostream *stream)
{
- _IStream *_stream = (_IStream *) stream;
+ struct _istream *_stream = (struct _istream *) stream;
p_free(_stream->iostream.pool, _stream->w_buffer);
}
-static void _set_max_buffer_size(_IOStream *stream, size_t max_size)
+static void _set_max_buffer_size(struct _iostream *stream, size_t max_size)
{
- FileIStream *fstream = (FileIStream *) stream;
+ struct file_istream *fstream = (struct file_istream *) stream;
fstream->max_buffer_size = max_size;
}
-static void _set_blocking(_IOStream *stream, int timeout_msecs,
+static void _set_blocking(struct _iostream *stream, int timeout_msecs,
void (*timeout_func)(void *), void *context)
{
- FileIStream *fstream = (FileIStream *) stream;
+ struct file_istream *fstream = (struct file_istream *) stream;
fstream->timeout_msecs = timeout_msecs;
fstream->timeout_func = timeout_func;
@@ -94,9 +94,9 @@
alarm_hup_init();
}
-static void i_stream_grow_buffer(_IStream *stream, size_t bytes)
+static void i_stream_grow_buffer(struct _istream *stream, size_t bytes)
{
- FileIStream *fstream = (FileIStream *) stream;
+ struct file_istream *fstream = (struct file_istream *) stream;
stream->buffer_size = stream->pos + bytes;
stream->buffer_size =
@@ -112,7 +112,7 @@
stream->buffer_size);
}
-static void i_stream_compress(_IStream *stream)
+static void i_stream_compress(struct _istream *stream)
{
memmove(stream->w_buffer, stream->w_buffer + stream->skip,
stream->pos - stream->skip);
@@ -126,9 +126,9 @@
stream->skip = 0;
}
-static ssize_t _read(_IStream *stream)
+static ssize_t _read(struct _istream *stream)
{
- FileIStream *fstream = (FileIStream *) stream;
+ struct file_istream *fstream = (struct file_istream *) stream;
time_t timeout_time;
uoff_t read_limit;
size_t size;
@@ -232,18 +232,18 @@
return ret;
}
-static void _skip(_IStream *stream, uoff_t count)
+static void _skip(struct _istream *stream, uoff_t count)
{
- FileIStream *fstream = (FileIStream *) stream;
+ struct file_istream *fstream = (struct file_istream *) stream;
fstream->skip_left += count - (stream->pos - stream->skip);
stream->skip = stream->pos = 0;
stream->istream.v_offset += count;
}
-static void _seek(_IStream *stream, uoff_t v_offset)
+static void _seek(struct _istream *stream, uoff_t v_offset)
{
- FileIStream *fstream = (FileIStream *) stream;
+ struct file_istream *fstream = (struct file_istream *) stream;
uoff_t real_offset;
off_t ret;
@@ -272,13 +272,13 @@
}
}
-IStream *i_stream_create_file(int fd, Pool pool, size_t max_buffer_size,
- int autoclose_fd)
+struct istream *i_stream_create_file(int fd, pool_t pool,
+ size_t max_buffer_size, int autoclose_fd)
{
- FileIStream *fstream;
+ struct file_istream *fstream;
struct stat st;
- fstream = p_new(pool, FileIStream, 1);
+ fstream = p_new(pool, struct file_istream, 1);
fstream->max_buffer_size = max_buffer_size;
fstream->autoclose_fd = autoclose_fd;
Index: istream-internal.h
===================================================================
RCS file: /home/cvs/dovecot/src/lib/istream-internal.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- istream-internal.h 6 Dec 2002 01:09:22 -0000 1.1
+++ istream-internal.h 5 Jan 2003 13:09:51 -0000 1.2
@@ -4,19 +4,17 @@
#include "istream.h"
#include "iostream-internal.h"
-typedef struct __IStream _IStream;
-
-struct __IStream {
+struct _istream {
/* inheritance: */
- _IOStream iostream;
+ struct _iostream iostream;
/* methods: */
- ssize_t (*read)(_IStream *stream);
- void (*skip_count)(_IStream *stream, uoff_t count);
- void (*seek)(_IStream *stream, uoff_t v_offset);
+ ssize_t (*read)(struct _istream *stream);
+ void (*skip_count)(struct _istream *stream, uoff_t count);
+ void (*seek)(struct _istream *stream, uoff_t v_offset);
/* data: */
- IStream istream;
+ struct istream istream;
int fd;
const unsigned char *buffer;
@@ -26,7 +24,7 @@
size_t skip, pos, cr_lookup_pos;
};
-IStream *_i_stream_create(_IStream *_buf, Pool pool, int fd,
- uoff_t start_offset, uoff_t v_size);
+struct istream *_i_stream_create(struct _istream *_buf, pool_t pool, int fd,
+ uoff_t start_offset, uoff_t v_size);
#endif
Index: istream-mmap.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib/istream-mmap.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- istream-mmap.c 6 Dec 2002 01:09:22 -0000 1.1
+++ istream-mmap.c 5 Jan 2003 13:09:51 -0000 1.2
@@ -30,8 +30,8 @@
#include <unistd.h>
#include <sys/stat.h>
-typedef struct {
- _IStream istream;
+struct mmap_istream {
+ struct _istream istream;
int fd;
void *mmap_base;
@@ -39,29 +39,29 @@
size_t mmap_block_size;
unsigned int autoclose_fd:1;
-} MmapIStream;
+};
static size_t mmap_pagesize = 0;
static size_t mmap_pagemask = 0;
-static void _close(_IOStream *stream)
+static void _close(struct _iostream *stream)
{
- MmapIStream *mstream = (MmapIStream *) stream;
+ struct mmap_istream *mstream = (struct mmap_istream *) stream;
if (mstream->autoclose_fd && mstream->fd != -1) {
if (close(mstream->fd) < 0)
- i_error("MmapIStream.close() failed: %m");
+ i_error("mmap_istream.close() failed: %m");
mstream->fd = -1;
}
}
-static void i_stream_munmap(MmapIStream *mstream)
+static void i_stream_munmap(struct mmap_istream *mstream)
{
- _IStream *_stream = &mstream->istream;
+ struct _istream *_stream = &mstream->istream;
if (_stream->buffer != NULL) {
if (munmap(mstream->mmap_base, _stream->buffer_size) < 0)
- i_error("MmapIStream.munmap() failed: %m");
+ i_error("mmap_istream.munmap() failed: %m");
mstream->mmap_base = NULL;
_stream->buffer = NULL;
_stream->buffer_size = 0;
@@ -69,21 +69,21 @@
}
}
-static void _destroy(_IOStream *stream)
+static void _destroy(struct _iostream *stream)
{
- MmapIStream *mstream = (MmapIStream *) stream;
+ struct mmap_istream *mstream = (struct mmap_istream *) stream;
i_stream_munmap(mstream);
}
-static void _set_max_buffer_size(_IOStream *stream, size_t max_size)
+static void _set_max_buffer_size(struct _iostream *stream, size_t max_size)
{
- MmapIStream *mstream = (MmapIStream *) stream;
+ struct mmap_istream *mstream = (struct mmap_istream *) stream;
mstream->mmap_block_size = max_size;
}
-static void _set_blocking(_IOStream *stream __attr_unused__,
+static void _set_blocking(struct _iostream *stream __attr_unused__,
int timeout_msecs __attr_unused__,
void (*timeout_func)(void *) __attr_unused__,
void *context __attr_unused__)
@@ -91,9 +91,9 @@
/* we never block */
}
-static ssize_t io_stream_set_mmaped_pos(_IStream *stream)
+static ssize_t io_stream_set_mmaped_pos(struct _istream *stream)
{
- MmapIStream *mstream = (MmapIStream *) stream;
+ struct mmap_istream *mstream = (struct mmap_istream *) stream;
i_assert((uoff_t)mstream->mmap_offset <=
stream->istream.start_offset + stream->istream.v_limit);
@@ -106,9 +106,9 @@
return stream->pos - stream->skip;
}
-static ssize_t _read(_IStream *stream)
+static ssize_t _read(struct _istream *stream)
{
- MmapIStream *mstream = (MmapIStream *) stream;
+ struct mmap_istream *mstream = (struct mmap_istream *) stream;
size_t aligned_skip, limit_size;
if (stream->istream.start_offset + stream->istream.v_limit <=
@@ -148,16 +148,16 @@
mstream->mmap_base = mmap(NULL, stream->buffer_size,
PROT_READ, MAP_PRIVATE,
mstream->fd, mstream->mmap_offset);
- stream->buffer = mstream->mmap_base;
if (mstream->mmap_base == MAP_FAILED) {
stream->istream.stream_errno = errno;
mstream->mmap_base = NULL;
stream->buffer = NULL;
stream->buffer_size = 0;
stream->skip = stream->pos = 0;
- i_error("MmapIStream.mmap() failed: %m");
+ i_error("mmap_istream.mmap() failed: %m");
return -1;
}
+ stream->buffer = mstream->mmap_base;
/* madvise() only if non-limited mmap()ed buffer area larger than
page size */
@@ -167,16 +167,17 @@
if (limit_size > stream->buffer_size)
limit_size = stream->buffer_size;
- if (madvise(mstream->mmap_base, limit_size, MADV_SEQUENTIAL) < 0)
- i_error("MmapIStream.madvise(): %m");
+ if (madvise(mstream->mmap_base, limit_size,
+ MADV_SEQUENTIAL) < 0)
+ i_error("mmap_istream.madvise(): %m");
}
return io_stream_set_mmaped_pos(stream);
}
-static void _seek(_IStream *stream, uoff_t v_offset)
+static void _seek(struct _istream *stream, uoff_t v_offset)
{
- MmapIStream *mstream = (MmapIStream *) stream;
+ struct mmap_istream *mstream = (struct mmap_istream *) stream;
uoff_t abs_offset;
abs_offset = stream->istream.start_offset + v_offset;
@@ -194,16 +195,16 @@
stream->istream.v_offset = v_offset;
}
-static void _skip(_IStream *stream, uoff_t count)
+static void _skip(struct _istream *stream, uoff_t count)
{
_seek(stream, stream->istream.v_offset + count);
}
-IStream *i_stream_create_mmap(int fd, Pool pool, size_t block_size,
- uoff_t start_offset, uoff_t v_size,
- int autoclose_fd)
+struct istream *i_stream_create_mmap(int fd, pool_t pool, size_t block_size,
+ uoff_t start_offset, uoff_t v_size,
+ int autoclose_fd)
{
- MmapIStream *mstream;
+ struct mmap_istream *mstream;
struct stat st;
if (mmap_pagesize == 0) {
@@ -223,7 +224,7 @@
}
}
- mstream = p_new(pool, MmapIStream, 1);
+ mstream = p_new(pool, struct mmap_istream, 1);
mstream->fd = fd;
mstream->mmap_block_size = block_size;
mstream->autoclose_fd = autoclose_fd;
@@ -237,5 +238,6 @@
mstream->istream.skip_count = _skip;
mstream->istream.seek = _seek;
- return _i_stream_create(&mstream->istream, pool, fd, start_offset, v_size);
+ return _i_stream_create(&mstream->istream, pool, fd,
+ start_offset, v_size);
}
Index: istream.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib/istream.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- istream.c 18 Dec 2002 15:15:41 -0000 1.2
+++ istream.c 5 Jan 2003 13:09:51 -0000 1.3
@@ -26,44 +26,44 @@
#include "lib.h"
#include "istream-internal.h"
-void i_stream_ref(IStream *stream)
+void i_stream_ref(struct istream *stream)
{
_io_stream_ref(stream->real_stream);
}
-void i_stream_unref(IStream *stream)
+void i_stream_unref(struct istream *stream)
{
_io_stream_unref(stream->real_stream);
}
-int i_stream_get_fd(IStream *stream)
+int i_stream_get_fd(struct istream *stream)
{
- _IStream *_stream = stream->real_stream;
+ struct _istream *_stream = stream->real_stream;
return _stream->fd;
}
-void i_stream_close(IStream *stream)
+void i_stream_close(struct istream *stream)
{
_io_stream_close(stream->real_stream);
stream->closed = TRUE;
}
-void i_stream_set_max_buffer_size(IStream *stream, size_t max_size)
+void i_stream_set_max_buffer_size(struct istream *stream, size_t max_size)
{
_io_stream_set_max_buffer_size(stream->real_stream, max_size);
}
-void i_stream_set_blocking(IStream *stream, int timeout_msecs,
+void i_stream_set_blocking(struct istream *stream, int timeout_msecs,
void (*timeout_func)(void *), void *context)
{
_io_stream_set_blocking(stream->real_stream, timeout_msecs,
timeout_func, context);
}
-void i_stream_set_start_offset(IStream *stream, uoff_t offset)
+void i_stream_set_start_offset(struct istream *stream, uoff_t offset)
{
- _IStream *_stream = stream->real_stream;
+ struct _istream *_stream = stream->real_stream;
off_t diff;
i_assert(stream->v_size == 0 ||
@@ -84,9 +84,9 @@
_stream->skip = _stream->pos = _stream->cr_lookup_pos = 0;
}
-void i_stream_set_read_limit(IStream *stream, uoff_t v_offset)
+void i_stream_set_read_limit(struct istream *stream, uoff_t v_offset)
{
- _IStream *_stream = stream->real_stream;
+ struct _istream *_stream = stream->real_stream;
uoff_t max_pos;
i_assert(stream->v_size == 0 || v_offset <= stream->v_size);
@@ -103,9 +103,9 @@
}
}
-ssize_t i_stream_read(IStream *stream)
+ssize_t i_stream_read(struct istream *stream)
{
- _IStream *_stream = stream->real_stream;
+ struct _istream *_stream = stream->real_stream;
if (stream->closed)
return -1;
@@ -113,9 +113,9 @@
return _stream->read(_stream);
}
-void i_stream_skip(IStream *stream, uoff_t count)
+void i_stream_skip(struct istream *stream, uoff_t count)
{
- _IStream *_stream = stream->real_stream;
+ struct _istream *_stream = stream->real_stream;
size_t data_size;
i_assert(stream->v_size == 0 ||
@@ -139,9 +139,9 @@
_stream->skip_count(_stream, count);
}
-void i_stream_seek(IStream *stream, uoff_t v_offset)
+void i_stream_seek(struct istream *stream, uoff_t v_offset)
{
- _IStream *_stream = stream->real_stream;
+ struct _istream *_stream = stream->real_stream;
i_assert(v_offset <= stream->v_size);
@@ -151,9 +151,9 @@
_stream->seek(_stream, v_offset);
}
-char *i_stream_next_line(IStream *stream)
+char *i_stream_next_line(struct istream *stream)
{
- _IStream *_stream = stream->real_stream;
+ struct _istream *_stream = stream->real_stream;
char *ret_buf;
size_t i;
@@ -189,9 +189,9 @@
return ret_buf;
}
-const unsigned char *i_stream_get_data(IStream *stream, size_t *size)
+const unsigned char *i_stream_get_data(struct istream *stream, size_t *size)
{
- _IStream *_stream = stream->real_stream;
+ struct _istream *_stream = stream->real_stream;
if (_stream->skip >= _stream->pos) {
*size = 0;
@@ -202,9 +202,10 @@
return _stream->buffer + _stream->skip;
}
-unsigned char *i_stream_get_modifyable_data(IStream *stream, size_t *size)
+unsigned char *i_stream_get_modifyable_data(struct istream *stream,
+ size_t *size)
{
- _IStream *_stream = stream->real_stream;
+ struct _istream *_stream = stream->real_stream;
if (_stream->skip >= _stream->pos || _stream->w_buffer == NULL) {
*size = 0;
@@ -215,10 +216,10 @@
return _stream->w_buffer + _stream->skip;
}
-int i_stream_read_data(IStream *stream, const unsigned char **data,
+int i_stream_read_data(struct istream *stream, const unsigned char **data,
size_t *size, size_t threshold)
{
- _IStream *_stream = stream->real_stream;
+ struct _istream *_stream = stream->real_stream;
ssize_t ret = 0;
while (_stream->pos - _stream->skip <= threshold) {
@@ -234,8 +235,8 @@
*size > 0 ? 0 : -1;
}
-IStream *_i_stream_create(_IStream *_stream, Pool pool, int fd,
- uoff_t start_offset, uoff_t v_size)
+struct istream *_i_stream_create(struct _istream *_stream, pool_t pool, int fd,
+ uoff_t start_offset, uoff_t v_size)
{
_stream->fd = fd;
_stream->istream.start_offset = start_offset;
Index: istream.h
===================================================================
RCS file: /home/cvs/dovecot/src/lib/istream.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- istream.h 4 Jan 2003 17:26:29 -0000 1.2
+++ istream.h 5 Jan 2003 13:09:51 -0000 1.3
@@ -1,7 +1,7 @@
#ifndef __ISTREAM_H
#define __ISTREAM_H
-struct _IStream {
+struct istream {
uoff_t start_offset;
uoff_t v_offset, v_size, v_limit; /* relative to start_offset */
@@ -11,64 +11,66 @@
void *real_stream;
};
-IStream *i_stream_create_file(int fd, Pool pool, size_t max_buffer_size,
- int autoclose_fd);
-IStream *i_stream_create_mmap(int fd, Pool pool, size_t block_size,
- uoff_t start_offset, uoff_t v_size,
- int autoclose_fd);
-IStream *i_stream_create_from_data(Pool pool, const void *data, size_t size);
+struct istream *i_stream_create_file(int fd, pool_t pool,
+ size_t max_buffer_size, int autoclose_fd);
+struct istream *i_stream_create_mmap(int fd, pool_t pool, size_t block_size,
+ uoff_t start_offset, uoff_t v_size,
+ int autoclose_fd);
+struct istream *i_stream_create_from_data(pool_t pool, const void *data,
+ size_t size);
/* Reference counting. References start from 1, so calling i_stream_unref()
destroys the stream if i_stream_ref() is never used. */
-void i_stream_ref(IStream *stream);
-void i_stream_unref(IStream *stream);
+void i_stream_ref(struct istream *stream);
+void i_stream_unref(struct istream *stream);
/* Return file descriptor for stream, or -1 if none is available. */
-int i_stream_get_fd(IStream *stream);
+int i_stream_get_fd(struct istream *stream);
/* Mark the stream closed. Any reads after this will return -1. The data
already read can still be used. */
-void i_stream_close(IStream *stream);
+void i_stream_close(struct istream *stream);
/* Change the maximum size for stream's input buffer to grow. Useful only
for buffered streams (currently only file). */
-void i_stream_set_max_buffer_size(IStream *stream, size_t max_size);
+void i_stream_set_max_buffer_size(struct istream *stream, size_t max_size);
/* Change the start_offset and drop all data in buffers. Doesn't do anything
if offset is the same as existing start_offset. */
-void i_stream_set_start_offset(IStream *stream, uoff_t offset);
+void i_stream_set_start_offset(struct istream *stream, uoff_t offset);
/* Stream won't be read past specified offset. Giving 0 as offset
removes the limit. */
-void i_stream_set_read_limit(IStream *stream, uoff_t v_offset);
+void i_stream_set_read_limit(struct istream *stream, uoff_t v_offset);
/* Makes reads blocking until at least one byte is read. timeout_func is
called if nothing is read in specified time. Setting timeout_msecs to 0
makes it non-blocking. This call changes non-blocking state of file
descriptor. */
-void i_stream_set_blocking(IStream *stream, int timeout_msecs,
+void i_stream_set_blocking(struct istream *stream, int timeout_msecs,
void (*timeout_func)(void *), void *context);
/* Returns number of bytes read if read was ok, -1 if EOF or error, -2 if the
input buffer is full. */
-ssize_t i_stream_read(IStream *stream);
+ssize_t i_stream_read(struct istream *stream);
/* Skip forward a number of bytes. Never fails, the next read tells if it
was successful. */
-void i_stream_skip(IStream *stream, uoff_t count);
+void i_stream_skip(struct istream *stream, uoff_t count);
/* Seek to specified position from beginning of file. Never fails, the next
read tells if it was successful. This works only for files. */
-void i_stream_seek(IStream *stream, uoff_t v_offset);
+void i_stream_seek(struct istream *stream, uoff_t v_offset);
/* Reads the next line from stream and returns it, or NULL if more data is
needed to make a full line. NOTE: modifies the data in buffer for the \0,
so it works only with buffered streams (currently only file). */
-char *i_stream_next_line(IStream *stream);
+char *i_stream_next_line(struct istream *stream);
/* Returns pointer to beginning of read data, or NULL if there's no data
buffered. */
-const unsigned char *i_stream_get_data(IStream *stream, size_t *size);
+const unsigned char *i_stream_get_data(struct istream *stream, size_t *size);
/* Like i_stream_get_data(), but returns non-const data. This only works with
buffered streams (currently only file), others return NULL. */
-unsigned char *i_stream_get_modifyable_data(IStream *stream, size_t *size);
+unsigned char *i_stream_get_modifyable_data(struct istream *stream,
+ size_t *size);
/* Like i_stream_get_data(), but read more when needed. Returns 1 if more
than threshold bytes are available, 0 if less, -1 if error or EOF with no
bytes available, or -2 if stream's input buffer is full. */
-int i_stream_read_data(IStream *stream, const unsigned char **data,
+int i_stream_read_data(struct istream *stream, const unsigned char **data,
size_t *size, size_t threshold);
#endif
Index: lib.h
===================================================================
RCS file: /home/cvs/dovecot/src/lib/lib.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- lib.h 21 Dec 2002 22:02:58 -0000 1.12
+++ lib.h 5 Jan 2003 13:09:51 -0000 1.13
@@ -17,16 +17,6 @@
# include <stdint.h> /* C99 int types, we mostly need uintmax_t */
#endif
-typedef struct _IOLoop *IOLoop;
-typedef struct _IO *IO;
-typedef struct _Timeout *Timeout;
-
-typedef struct _IPADDR IPADDR;
-typedef struct _IStream IStream;
-typedef struct _OStream OStream;
-typedef struct _Buffer Buffer;
-typedef struct _Buffer String;
-
#include "compat.h"
#include "macros.h"
#include "failures.h"
@@ -36,6 +26,12 @@
#include "imem.h"
#include "strfuncs.h"
+
+typedef struct buffer buffer_t;
+typedef struct buffer string_t;
+
+struct istream;
+struct ostream;
size_t nearest_power(size_t num);
Index: macros.h
===================================================================
RCS file: /home/cvs/dovecot/src/lib/macros.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- macros.h 4 Jan 2003 17:46:34 -0000 1.10
+++ macros.h 5 Jan 2003 13:09:51 -0000 1.11
@@ -27,7 +27,8 @@
#define I_MAX(a, b) (((a) > (b)) ? (a) : (b))
#undef CLAMP
-#define CLAMP(x, low, high) (((x) > (high)) ? (high) : (((x) < (low)) ? (low) : (x)))
+#define CLAMP(x, low, high) \
+ (((x) > (high)) ? (high) : (((x) < (low)) ? (low) : (x)))
#undef NVL
#define NVL(str, nullstr) ((str) != NULL ? (str) : (nullstr))
@@ -43,7 +44,8 @@
/* Define VA_COPY() to do the right thing for copying va_list variables.
config.h may have already defined VA_COPY as va_copy or __va_copy. */
#ifndef VA_COPY
-# if defined (__GNUC__) && defined (__PPC__) && (defined (_CALL_SYSV) || defined (_WIN32))
+# if defined (__GNUC__) && defined (__PPC__) && \
+ (defined (_CALL_SYSV) || defined (_WIN32))
# define VA_COPY(ap1, ap2) (*(ap1) = *(ap2))
# elif defined (VA_COPY_AS_ARRAY)
# define VA_COPY(ap1, ap2) i_memmove ((ap1), (ap2), sizeof (va_list))
Index: md5.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib/md5.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- md5.c 18 Dec 2002 15:15:41 -0000 1.6
+++ md5.c 5 Jan 2003 13:09:51 -0000 1.7
@@ -15,8 +15,7 @@
* and avoid compile-time configuration.
*/
-#include <string.h>
-
+#include "lib.h"
#include "md5.h"
/*
@@ -48,16 +47,16 @@
*/
#if defined(__i386__) || defined(__vax__)
#define SET(n) \
- (*(const MD5_u32plus *)&ptr[(n) * 4])
+ (*(const uint_fast32_t *)&ptr[(n) * 4])
#define GET(n) \
SET(n)
#else
#define SET(n) \
(ctx->block[(n)] = \
- (MD5_u32plus)ptr[(n) * 4] | \
- ((MD5_u32plus)ptr[(n) * 4 + 1] << 8) | \
- ((MD5_u32plus)ptr[(n) * 4 + 2] << 16) | \
- ((MD5_u32plus)ptr[(n) * 4 + 3] << 24))
+ (uint_fast32_t)ptr[(n) * 4] | \
+ ((uint_fast32_t)ptr[(n) * 4 + 1] << 8) | \
+ ((uint_fast32_t)ptr[(n) * 4 + 2] << 16) | \
+ ((uint_fast32_t)ptr[(n) * 4 + 3] << 24))
#define GET(n) \
(ctx->block[(n)])
#endif
@@ -66,11 +65,11 @@
* This processes one or more 64-byte data blocks, but does NOT update
* the bit counters. There're no alignment requirements.
*/
-static const void *body(MD5Context *ctx, const void *data, size_t size)
+static const void *body(struct md5_context *ctx, const void *data, size_t size)
{
const unsigned char *ptr;
- MD5_u32plus a, b, c, d;
- MD5_u32plus saved_a, saved_b, saved_c, saved_d;
+ uint_fast32_t a, b, c, d;
+ uint_fast32_t saved_a, saved_b, saved_c, saved_d;
ptr = data;
@@ -173,7 +172,7 @@
return ptr;
}
-void md5_init(MD5Context *ctx)
+void md5_init(struct md5_context *ctx)
{
ctx->a = 0x67452301;
ctx->b = 0xefcdab89;
@@ -184,10 +183,10 @@
ctx->hi = 0;
}
-void md5_update(MD5Context *ctx, const void *data, size_t size)
+void md5_update(struct md5_context *ctx, const void *data, size_t size)
{
/* @UNSAFE */
- MD5_u32plus saved_lo;
+ uint_fast32_t saved_lo;
unsigned long used, free;
saved_lo = ctx->lo;
@@ -219,7 +218,7 @@
memcpy(ctx->buffer, data, size);
}
-void md5_final(MD5Context *ctx, unsigned char result[16])
+void md5_final(struct md5_context *ctx, unsigned char result[16])
{
/* @UNSAFE */
unsigned long used, free;
@@ -273,7 +272,7 @@
void md5_get_digest(const void *data, size_t size, unsigned char result[16])
{
- MD5Context ctx;
+ struct md5_context ctx;
md5_init(&ctx);
md5_update(&ctx, data, size);
Index: md5.h
===================================================================
RCS file: /home/cvs/dovecot/src/lib/md5.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- md5.h 8 Sep 2002 13:20:28 -0000 1.3
+++ md5.h 5 Jan 2003 13:09:51 -0000 1.4
@@ -9,19 +9,16 @@
#ifndef __MD5_H
#define __MD5_H
-/* Any 32-bit or wider integer data type will do */
-typedef unsigned long MD5_u32plus;
-
-typedef struct {
- MD5_u32plus lo, hi;
- MD5_u32plus a, b, c, d;
+struct md5_context {
+ uint_fast32_t lo, hi;
+ uint_fast32_t a, b, c, d;
unsigned char buffer[64];
- MD5_u32plus block[16];
-} MD5Context;
+ uint_fast32_t block[16];
+};
-void md5_init(MD5Context *ctx);
-void md5_update(MD5Context *ctx, const void *data, size_t size);
-void md5_final(MD5Context *ctx, unsigned char result[16]);
+void md5_init(struct md5_context *ctx);
+void md5_update(struct md5_context *ctx, const void *data, size_t size);
+void md5_final(struct md5_context *ctx, unsigned char result[16]);
void md5_get_digest(const void *data, size_t size, unsigned char result[16]);
Index: mempool-alloconly.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib/mempool-alloconly.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- mempool-alloconly.c 27 Dec 2002 14:01:42 -0000 1.15
+++ mempool-alloconly.c 5 Jan 2003 13:09:51 -0000 1.16
@@ -33,20 +33,18 @@
#define MAX_ALLOC_SIZE SSIZE_T_MAX
-typedef struct _PoolBlock PoolBlock;
-
-typedef struct {
- struct Pool pool;
+struct alloconly_pool {
+ struct pool pool;
int refcount;
- PoolBlock *block;
+ struct pool_block *block;
char name[MEM_ALIGN_SIZE]; /* variable size */
-} AlloconlyPool;
-#define SIZEOF_ALLOCONLYPOOL (sizeof(AlloconlyPool)-MEM_ALIGN_SIZE)
+};
+#define SIZEOF_ALLOCONLYPOOL (sizeof(struct alloconly_pool)-MEM_ALIGN_SIZE)
-struct _PoolBlock {
- PoolBlock *prev;
+struct pool_block {
+ struct pool_block *prev;
size_t size;
size_t left;
@@ -54,30 +52,30 @@
/* unsigned char data[]; */
};
-#define SIZEOF_POOLBLOCK (MEM_ALIGN(sizeof(PoolBlock)))
+#define SIZEOF_POOLBLOCK (MEM_ALIGN(sizeof(struct pool_block)))
#define POOL_BLOCK_DATA(block) \
((char *) (block) + SIZEOF_POOLBLOCK)
-typedef struct {
+struct pool_alloc {
union {
size_t size;
unsigned char alignment[MEM_ALIGN_SIZE];
} size;
unsigned char data[MEM_ALIGN_SIZE]; /* variable size */
-} PoolAlloc;
-#define SIZEOF_POOLALLOC (sizeof(PoolAlloc)-MEM_ALIGN_SIZE)
+};
+#define SIZEOF_POOLALLOC (sizeof(struct pool_alloc)-MEM_ALIGN_SIZE)
-static void pool_alloconly_ref(Pool pool);
-static void pool_alloconly_unref(Pool pool);
-static void *pool_alloconly_malloc(Pool pool, size_t size);
-static void pool_alloconly_free(Pool pool, void *mem);
-static void *pool_alloconly_realloc(Pool pool, void *mem, size_t size);
-static void pool_alloconly_clear(Pool pool);
+static void pool_alloconly_ref(pool_t pool);
+static void pool_alloconly_unref(pool_t pool);
+static void *pool_alloconly_malloc(pool_t pool, size_t size);
+static void pool_alloconly_free(pool_t pool, void *mem);
+static void *pool_alloconly_realloc(pool_t pool, void *mem, size_t size);
+static void pool_alloconly_clear(pool_t pool);
-static void block_alloc(AlloconlyPool *pool, size_t size);
+static void block_alloc(struct alloconly_pool *pool, size_t size);
-static struct Pool static_alloconly_pool = {
+static struct pool static_alloconly_pool = {
pool_alloconly_ref,
pool_alloconly_unref,
@@ -89,9 +87,9 @@
pool_alloconly_clear
};
-Pool pool_alloconly_create(const char *name, size_t size)
+pool_t pool_alloconly_create(const char *name, size_t size)
{
- AlloconlyPool *apool;
+ struct alloconly_pool *apool;
int len;
len = strlen(name);
@@ -104,10 +102,10 @@
memcpy(apool->name, name, len+1);
block_alloc(apool, size);
- return (Pool) apool;
+ return (struct pool *) apool;
}
-static void pool_alloconly_destroy(AlloconlyPool *apool)
+static void pool_alloconly_destroy(struct alloconly_pool *apool)
{
/* destroy all but the last block */
pool_alloconly_clear(&apool->pool);
@@ -117,24 +115,24 @@
free(apool);
}
-static void pool_alloconly_ref(Pool pool)
+static void pool_alloconly_ref(pool_t pool)
{
- AlloconlyPool *apool = (AlloconlyPool *) pool;
+ struct alloconly_pool *apool = (struct alloconly_pool *) pool;
apool->refcount++;
}
-static void pool_alloconly_unref(Pool pool)
+static void pool_alloconly_unref(pool_t pool)
{
- AlloconlyPool *apool = (AlloconlyPool *) pool;
+ struct alloconly_pool *apool = (struct alloconly_pool *) pool;
if (--apool->refcount == 0)
pool_alloconly_destroy(apool);
}
-static void block_alloc(AlloconlyPool *apool, size_t size)
+static void block_alloc(struct alloconly_pool *apool, size_t size)
{
- PoolBlock *block;
+ struct pool_block *block;
/* each block is at least twice the size of the previous one */
if (apool->block != NULL && size <= apool->block->size)
@@ -159,10 +157,10 @@
block->left = block->size;
}
-static void *pool_alloconly_malloc(Pool pool, size_t size)
+static void *pool_alloconly_malloc(pool_t pool, size_t size)
{
- AlloconlyPool *apool = (AlloconlyPool *) pool;
- PoolAlloc *alloc;
+ struct alloconly_pool *apool = (struct alloconly_pool *) pool;
+ struct pool_alloc *alloc;
if (size == 0 || size > SSIZE_T_MAX)
i_panic("Trying to allocate %"PRIuSIZE_T" bytes", size);
@@ -174,8 +172,8 @@
block_alloc(apool, size);
}
- alloc = (PoolAlloc *) (POOL_BLOCK_DATA(apool->block) +
- apool->block->size - apool->block->left);
+ alloc = (struct pool_alloc *) (POOL_BLOCK_DATA(apool->block) +
+ apool->block->size - apool->block->left);
alloc->size.size = size;
apool->block->left -= size + SIZEOF_POOLALLOC;
@@ -183,13 +181,13 @@
return alloc->data;
}
-static void pool_alloconly_free(Pool pool __attr_unused__,
+static void pool_alloconly_free(pool_t pool __attr_unused__,
void *mem __attr_unused__)
{
/* ignore */
}
-static int pool_try_grow(AlloconlyPool *apool, void *mem, size_t size)
+static int pool_try_grow(struct alloconly_pool *apool, void *mem, size_t size)
{
/* see if we want to grow the memory we allocated last */
if (POOL_BLOCK_DATA(apool->block) +
@@ -208,10 +206,10 @@
return FALSE;
}
-static void *pool_alloconly_realloc(Pool pool, void *mem, size_t size)
+static void *pool_alloconly_realloc(pool_t pool, void *mem, size_t size)
{
- AlloconlyPool *apool = (AlloconlyPool *) pool;
- PoolAlloc *alloc;
+ struct alloconly_pool *apool = (struct alloconly_pool *) pool;
+ struct pool_alloc *alloc;
unsigned char *new_mem;
size_t old_size;
@@ -222,7 +220,7 @@
return pool_alloconly_malloc(pool, size);
/* get old size */
- alloc = (PoolAlloc *) ((char *) mem - SIZEOF_POOLALLOC);
+ alloc = (struct pool_alloc *) ((char *) mem - SIZEOF_POOLALLOC);
old_size = alloc->size.size;
if (size <= old_size)
@@ -246,10 +244,10 @@
return mem;
}
-static void pool_alloconly_clear(Pool pool)
+static void pool_alloconly_clear(pool_t pool)
{
- AlloconlyPool *apool = (AlloconlyPool *) pool;
- PoolBlock *block;
+ struct alloconly_pool *apool = (struct alloconly_pool *) pool;
+ struct pool_block *block;
/* destroy all blocks but the last, which is the largest */
while (apool->block->prev != NULL) {
Index: mempool-datastack.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib/mempool-datastack.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- mempool-datastack.c 27 Dec 2002 14:01:42 -0000 1.4
+++ mempool-datastack.c 5 Jan 2003 13:09:51 -0000 1.5
@@ -28,22 +28,22 @@
#include <stdlib.h>
-typedef struct {
+struct pool_alloc {
union {
size_t size;
unsigned char alignment[MEM_ALIGN_SIZE];
} size;
/* void data[]; */
-} PoolAlloc;
+};
-static void pool_data_stack_ref(Pool pool);
-static void pool_data_stack_unref(Pool pool);
-static void *pool_data_stack_malloc(Pool pool, size_t size);
-static void pool_data_stack_free(Pool pool, void *mem);
-static void *pool_data_stack_realloc(Pool pool, void *mem, size_t size);
-static void pool_data_stack_clear(Pool pool);
+static void pool_data_stack_ref(pool_t pool);
+static void pool_data_stack_unref(pool_t pool);
+static void *pool_data_stack_malloc(pool_t pool, size_t size);
+static void pool_data_stack_free(pool_t pool, void *mem);
+static void *pool_data_stack_realloc(pool_t pool, void *mem, size_t size);
+static void pool_data_stack_clear(pool_t pool);
-static struct Pool static_data_stack_pool = {
+static struct pool static_data_stack_pool = {
pool_data_stack_ref,
pool_data_stack_unref,
@@ -55,39 +55,39 @@
pool_data_stack_clear
};
-Pool data_stack_pool = &static_data_stack_pool;
+pool_t data_stack_pool = &static_data_stack_pool;
-static void pool_data_stack_ref(Pool pool __attr_unused__)
+static void pool_data_stack_ref(pool_t pool __attr_unused__)
{
}
-static void pool_data_stack_unref(Pool pool __attr_unused__)
+static void pool_data_stack_unref(pool_t pool __attr_unused__)
{
}
-static void *pool_data_stack_malloc(Pool pool __attr_unused__, size_t size)
+static void *pool_data_stack_malloc(pool_t pool __attr_unused__, size_t size)
{
- PoolAlloc *alloc;
+ struct pool_alloc *alloc;
if (size == 0 || size > SSIZE_T_MAX)
i_panic("Trying to allocate %"PRIuSIZE_T" bytes", size);
- alloc = t_malloc0(sizeof(PoolAlloc) + size);
+ alloc = t_malloc0(sizeof(struct pool_alloc) + size);
alloc->size.size = size;
- return (char *) alloc + sizeof(PoolAlloc);
+ return (char *) alloc + sizeof(struct pool_alloc);
}
-static void pool_data_stack_free(Pool pool __attr_unused__,
+static void pool_data_stack_free(pool_t pool __attr_unused__,
void *mem __attr_unused__)
{
}
-static void *pool_data_stack_realloc(Pool pool __attr_unused__,
+static void *pool_data_stack_realloc(pool_t pool __attr_unused__,
void *mem, size_t size)
{
/* @UNSAFE */
- PoolAlloc *alloc, *new_alloc;
+ struct pool_alloc *alloc, *new_alloc;
size_t old_size;
unsigned char *rmem;
@@ -98,24 +98,25 @@
return pool_data_stack_malloc(pool, size);
/* get old size */
- alloc = (PoolAlloc *) ((char *) mem - sizeof(PoolAlloc));
+ alloc = (struct pool_alloc *)
+ ((char *) mem - sizeof(struct pool_alloc));
old_size = alloc->size.size;
if (old_size >= size)
return mem;
- if (!t_try_realloc(alloc, sizeof(PoolAlloc) + size)) {
- new_alloc = t_malloc(sizeof(PoolAlloc) + size);
- memcpy(new_alloc, alloc, old_size + sizeof(PoolAlloc));
+ if (!t_try_realloc(alloc, sizeof(struct pool_alloc) + size)) {
+ new_alloc = t_malloc(sizeof(struct pool_alloc) + size);
+ memcpy(new_alloc, alloc, old_size + sizeof(struct pool_alloc));
alloc = new_alloc;
}
alloc->size.size = size;
- rmem = (unsigned char *) alloc + sizeof(PoolAlloc);
+ rmem = (unsigned char *) alloc + sizeof(struct pool_alloc);
memset(rmem + old_size, 0, size-old_size);
return rmem;
}
-static void pool_data_stack_clear(Pool pool __attr_unused__)
+static void pool_data_stack_clear(pool_t pool __attr_unused__)
{
}
Index: mempool-system.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib/mempool-system.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- mempool-system.c 27 Dec 2002 14:01:42 -0000 1.7
+++ mempool-system.c 5 Jan 2003 13:09:51 -0000 1.8
@@ -30,22 +30,22 @@
#include <stdlib.h>
-typedef struct {
+struct pool_alloc {
union {
size_t size;
unsigned char alignment[MEM_ALIGN_SIZE];
} size;
/* void data[]; */
-} PoolAlloc;
+};
-static void pool_system_ref(Pool pool);
-static void pool_system_unref(Pool pool);
-static void *pool_system_malloc(Pool pool, size_t size);
-static void pool_system_free(Pool pool, void *mem);
-static void *pool_system_realloc(Pool pool, void *mem, size_t size);
-static void pool_system_clear(Pool pool);
+static void pool_system_ref(pool_t pool);
+static void pool_system_unref(pool_t pool);
+static void *pool_system_malloc(pool_t pool, size_t size);
+static void pool_system_free(pool_t pool, void *mem);
+static void *pool_system_realloc(pool_t pool, void *mem, size_t size);
+static void pool_system_clear(pool_t pool);
-static struct Pool static_system_pool = {
+static struct pool static_system_pool = {
pool_system_ref,
pool_system_unref,
@@ -57,41 +57,41 @@
pool_system_clear
};
-Pool system_pool = &static_system_pool;
+pool_t system_pool = &static_system_pool;
-static void pool_system_ref(Pool pool __attr_unused__)
+static void pool_system_ref(pool_t pool __attr_unused__)
{
}
-static void pool_system_unref(Pool pool __attr_unused__)
+static void pool_system_unref(pool_t pool __attr_unused__)
{
}
-static void *pool_system_malloc(Pool pool __attr_unused__, size_t size)
+static void *pool_system_malloc(pool_t pool __attr_unused__, size_t size)
{
- PoolAlloc *alloc;
+ struct pool_alloc *alloc;
if (size == 0 || size > SSIZE_T_MAX)
i_panic("Trying to allocate %"PRIuSIZE_T" bytes", size);
- alloc = calloc(sizeof(PoolAlloc) + size, 1);
+ alloc = calloc(sizeof(struct pool_alloc) + size, 1);
if (alloc == NULL)
i_panic("pool_system_malloc(): Out of memory");
alloc->size.size = size;
- return (char *) alloc + sizeof(PoolAlloc);
+ return (char *) alloc + sizeof(struct pool_alloc);
}
-static void pool_system_free(Pool pool __attr_unused__, void *mem)
+static void pool_system_free(pool_t pool __attr_unused__, void *mem)
{
if (mem != NULL)
- free((char *) mem - sizeof(PoolAlloc));
+ free((char *) mem - sizeof(struct pool_alloc));
}
-static void *pool_system_realloc(Pool pool __attr_unused__, void *mem,
+static void *pool_system_realloc(pool_t pool __attr_unused__, void *mem,
size_t size)
{
- PoolAlloc *alloc;
+ struct pool_alloc *alloc;
size_t old_size;
char *rmem;
@@ -103,17 +103,18 @@
old_size = 0;
} else {
/* get old size */
- alloc = (PoolAlloc *) ((char *) mem - sizeof(PoolAlloc));
+ alloc = (struct pool_alloc *)
+ ((char *) mem - sizeof(struct pool_alloc));
old_size = alloc->size.size;
}
/* alloc & set new size */
- alloc = realloc(alloc, sizeof(PoolAlloc) + size);
+ alloc = realloc(alloc, sizeof(struct pool_alloc) + size);
if (alloc == NULL)
i_panic("pool_system_realloc(): Out of memory");
alloc->size.size = size;
- rmem = (char *) alloc + sizeof(PoolAlloc);
+ rmem = (char *) alloc + sizeof(struct pool_alloc);
if (size > old_size) {
/* clear new data */
memset(rmem + old_size, 0, size-old_size);
@@ -122,7 +123,7 @@
return rmem;
}
-static void pool_system_clear(Pool pool __attr_unused__)
+static void pool_system_clear(pool_t pool __attr_unused__)
{
i_panic("pool_system_clear() must not be called");
}
Index: mempool.h
===================================================================
RCS file: /home/cvs/dovecot/src/lib/mempool.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- mempool.h 27 Dec 2002 14:01:42 -0000 1.7
+++ mempool.h 5 Jan 2003 13:09:51 -0000 1.8
@@ -9,32 +9,32 @@
zeroed, it will cost only a few CPU cycles and may well save some debug
time. */
-typedef struct Pool *Pool;
+typedef struct pool *pool_t;
-struct Pool {
- void (*ref)(Pool pool);
- void (*unref)(Pool pool);
+struct pool {
+ void (*ref)(pool_t pool);
+ void (*unref)(pool_t pool);
- void *(*malloc)(Pool pool, size_t size);
- void (*free)(Pool pool, void *mem);
+ void *(*malloc)(pool_t pool, size_t size);
+ void (*free)(pool_t pool, void *mem);
/* reallocate the `mem' to be exactly `size' */
- void *(*realloc)(Pool pool, void *mem, size_t size);
+ void *(*realloc)(pool_t pool, void *mem, size_t size);
/* Frees all the memory in pool. NOTE: system_pool doesn't support
this and crashes if it's used */
- void (*clear)(Pool pool);
+ void (*clear)(pool_t pool);
};
/* system_pool uses calloc() + realloc() + free() */
-extern Pool system_pool;
+extern pool_t system_pool;
/* memory allocated from data_stack is valid only until next t_pop() call. */
-extern Pool data_stack_pool;
+extern pool_t data_stack_pool;
/* Create a new alloc-only pool. Note that `size' specifies the initial
malloc()ed block size, part of it is used internally. */
-Pool pool_alloconly_create(const char *name, size_t size);
+pool_t pool_alloconly_create(const char *name, size_t size);
/* Pools should be used through these macros: */
#define pool_ref(pool) (pool)->ref(pool)
Index: network.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib/network.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- network.c 19 Dec 2002 01:02:35 -0000 1.15
+++ network.c 5 Jan 2003 13:09:51 -0000 1.16
@@ -49,7 +49,7 @@
# define SIZEOF_SOCKADDR(so) (sizeof(so.sin))
#endif
-int net_ip_compare(const IPADDR *ip1, const IPADDR *ip2)
+int net_ip_compare(const struct ip_addr *ip1, const struct ip_addr *ip2)
{
if (ip1->family != ip2->family)
return 0;
@@ -64,7 +64,8 @@
/* copy IP to sockaddr */
-static inline void sin_set_ip(union sockaddr_union *so, const IPADDR *ip)
+static inline void
+sin_set_ip(union sockaddr_union *so, const struct ip_addr *ip)
{
if (ip == NULL) {
#ifdef HAVE_IPV6
@@ -86,7 +87,8 @@
memcpy(&so->sin.sin_addr, &ip->ip, 4);
}
-static inline void sin_get_ip(const union sockaddr_union *so, IPADDR *ip)
+static inline void
+sin_get_ip(const union sockaddr_union *so, struct ip_addr *ip)
{
ip->family = so->sin.sin_family;
@@ -125,7 +127,8 @@
}
/* Connect to socket with ip address */
-int net_connect_ip(const IPADDR *ip, unsigned int port, const IPADDR *my_ip)
+int net_connect_ip(const struct ip_addr *ip, unsigned int port,
+ const struct ip_addr *my_ip)
{
union sockaddr_union so;
int fd, ret, opt = 1;
@@ -233,7 +236,7 @@
#endif
}
-void net_get_ip_any4(IPADDR *ip)
+void net_get_ip_any4(struct ip_addr *ip)
{
struct in_addr *in_ip = (struct in_addr *) &ip->ip;
@@ -241,19 +244,19 @@
in_ip->s_addr = INADDR_ANY;
}
-void net_get_ip_any6(IPADDR *ip)
+void net_get_ip_any6(struct ip_addr *ip)
{
#ifdef HAVE_IPV6
ip->family = AF_INET6;
ip->ip = in6addr_any;
#else
- memset(ip, 0, sizeof(IPADDR));
+ memset(ip, 0, sizeof(struct ip_addr));
#endif
}
/* Listen for connections on a socket. if `my_ip' is NULL, listen in any
address. */
-int net_listen(const IPADDR *my_ip, unsigned int *port)
+int net_listen(const struct ip_addr *my_ip, unsigned int *port)
{
union sockaddr_union so;
int ret, fd, opt = 1;
@@ -338,7 +341,7 @@
}
/* Accept a connection on a socket */
-int net_accept(int fd, IPADDR *addr, unsigned int *port)
+int net_accept(int fd, struct ip_addr *addr, unsigned int *port)
{
union sockaddr_union so;
int ret;
@@ -414,7 +417,7 @@
/* Get IP addresses for host. ips contains ips_count of IPs, they don't need
to be free'd. Returns 0 = ok, others = error code for net_gethosterror() */
-int net_gethostbyname(const char *addr, IPADDR **ips, int *ips_count)
+int net_gethostbyname(const char *addr, struct ip_addr **ips, int *ips_count)
{
/* @UNSAFE */
#ifdef HAVE_IPV6
@@ -454,7 +457,7 @@
count++;
*ips_count = count;
- *ips = t_malloc(sizeof(IPADDR) * count);
+ *ips = t_malloc(sizeof(struct ip_addr) * count);
count = 0;
for (ai = origai; ai != NULL; ai = ai->ai_next, count++) {
@@ -474,7 +477,7 @@
count++;
*ips_count = count;
- *ips = t_malloc(sizeof(IPADDR) * count);
+ *ips = t_malloc(sizeof(struct ip_addr) * count);
while (count > 0) {
count--;
@@ -488,7 +491,7 @@
}
/* Get socket address/port */
-int net_getsockname(int fd, IPADDR *addr, unsigned int *port)
+int net_getsockname(int fd, struct ip_addr *addr, unsigned int *port)
{
union sockaddr_union so;
socklen_t addrlen;
@@ -505,7 +508,7 @@
return 0;
}
-const char *net_ip2host(const IPADDR *ip)
+const char *net_ip2host(const struct ip_addr *ip)
{
#ifdef HAVE_IPV6
char host[MAX_IP_LEN+1];
@@ -531,7 +534,7 @@
return 0;
}
-int net_host2ip(const char *host, IPADDR *ip)
+int net_host2ip(const char *host, struct ip_addr *ip)
{
if (strchr(host, ':') != NULL) {
/* IPv6 */
Index: network.h
===================================================================
RCS file: /home/cvs/dovecot/src/lib/network.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- network.h 18 Dec 2002 15:15:41 -0000 1.8
+++ network.h 5 Jan 2003 13:09:51 -0000 1.9
@@ -20,7 +20,7 @@
# endif
#endif
-struct _IPADDR {
+struct ip_addr {
unsigned short family;
#ifdef HAVE_IPV6
struct in6_addr ip;
@@ -40,10 +40,11 @@
#define IPADDR_IS_V6(ip) ((ip)->family == AF_INET6)
/* returns 1 if IPADDRs are the same */
-int net_ip_compare(const IPADDR *ip1, const IPADDR *ip2);
+int net_ip_compare(const struct ip_addr *ip1, const struct ip_addr *ip2);
/* Connect to socket with ip address */
-int net_connect_ip(const IPADDR *ip, unsigned int port, const IPADDR *my_ip);
+int net_connect_ip(const struct ip_addr *ip, unsigned int port,
+ const struct ip_addr *my_ip);
/* Connect to named UNIX socket */
int net_connect_unix(const char *path);
/* Disconnect socket */
@@ -60,16 +61,16 @@
/* Set IP to contain INADDR_ANY for IPv4 or IPv6. The IPv6 any address may
include IPv4 depending on the system (Linux yes, BSD no). */
-void net_get_ip_any4(IPADDR *ip);
-void net_get_ip_any6(IPADDR *ip);
+void net_get_ip_any4(struct ip_addr *ip);
+void net_get_ip_any6(struct ip_addr *ip);
/* Listen for connections on a socket */
-int net_listen(const IPADDR *my_ip, unsigned int *port);
+int net_listen(const struct ip_addr *my_ip, unsigned int *port);
/* Listen for connections on an UNIX socket */
int net_listen_unix(const char *path);
/* Accept a connection on a socket. Returns -1 for temporary failure,
-2 for fatal failure */
-int net_accept(int fd, IPADDR *addr, unsigned int *port);
+int net_accept(int fd, struct ip_addr *addr, unsigned int *port);
/* Read data from socket, return number of bytes read,
-1 = error, -2 = disconnected */
@@ -79,7 +80,7 @@
/* Get IP addresses for host. ips contains ips_count of IPs, they don't need
to be free'd. Returns 0 = ok, others = error code for net_gethosterror() */
-int net_gethostbyname(const char *addr, IPADDR **ips, int *ips_count);
+int net_gethostbyname(const char *addr, struct ip_addr **ips, int *ips_count);
/* get error of net_gethostname() */
const char *net_gethosterror(int error);
/* return TRUE if host lookup failed because it didn't exist (ie. not
@@ -87,12 +88,12 @@
int net_hosterror_notfound(int error);
/* Get socket address/port */
-int net_getsockname(int fd, IPADDR *addr, unsigned int *port);
+int net_getsockname(int fd, struct ip_addr *addr, unsigned int *port);
-/* Returns IPADDR as string, or NULL if ip is invalid. */
-const char *net_ip2host(const IPADDR *ip);
-/* char* -> IPADDR translation. */
-int net_host2ip(const char *host, IPADDR *ip);
+/* Returns ip_addr as string, or NULL if ip is invalid. */
+const char *net_ip2host(const struct ip_addr *ip);
+/* char* -> struct ip_addr translation. */
+int net_host2ip(const char *host, struct ip_addr *ip);
/* Get socket error */
int net_geterror(int fd);
Index: ostream-file.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib/ostream-file.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- ostream-file.c 18 Dec 2002 15:15:41 -0000 1.2
+++ ostream-file.c 5 Jan 2003 13:09:51 -0000 1.3
@@ -46,12 +46,12 @@
#define MAX_SSIZE_T(size) \
((size) < SSIZE_T_MAX ? (size_t)(size) : SSIZE_T_MAX)
-typedef struct {
- _OStream ostream;
+struct file_ostream {
+ struct _ostream ostream;
int fd;
int priority;
- IO io;
+ struct io *io;
unsigned char *buffer; /* ring-buffer */
size_t buffer_size, max_buffer_size;
@@ -65,13 +65,13 @@
unsigned int corked:1;
unsigned int no_socket_cork:1;
unsigned int autoclose_fd:1;
-} FileOStream;
+};
-static void stream_closed(FileOStream *fstream)
+static void stream_closed(struct file_ostream *fstream)
{
if (fstream->autoclose_fd && fstream->fd != -1) {
if (close(fstream->fd) < 0)
- i_error("FileOStream.close() failed: %m");
+ i_error("file_ostream.close() failed: %m");
fstream->fd = -1;
}
@@ -83,9 +83,9 @@
fstream->ostream.ostream.closed = TRUE;
}
-static void _close(_IOStream *stream)
+static void _close(struct _iostream *stream)
{
- FileOStream *fstream = (FileOStream *) stream;
+ struct file_ostream *fstream = (struct file_ostream *) stream;
/* flush output before really closing it */
o_stream_flush(&fstream->ostream.ostream);
@@ -93,24 +93,24 @@
stream_closed(fstream);
}
-static void _destroy(_IOStream *stream)
+static void _destroy(struct _iostream *stream)
{
- FileOStream *fstream = (FileOStream *) stream;
+ struct file_ostream *fstream = (struct file_ostream *) stream;
p_free(fstream->ostream.iostream.pool, fstream->buffer);
}
-static void _set_max_buffer_size(_IOStream *stream, size_t max_size)
+static void _set_max_buffer_size(struct _iostream *stream, size_t max_size)
{
- FileOStream *fstream = (FileOStream *) stream;
+ struct file_ostream *fstream = (struct file_ostream *) stream;
fstream->max_buffer_size = max_size;
}
-static void _set_blocking(_IOStream *stream, int timeout_msecs,
+static void _set_blocking(struct _iostream *stream, int timeout_msecs,
void (*timeout_func)(void *), void *context)
{
- FileOStream *fstream = (FileOStream *) stream;
+ struct file_ostream *fstream = (struct file_ostream *) stream;
fstream->timeout_msecs = timeout_msecs;
fstream->timeout_func = timeout_func;
@@ -122,9 +122,9 @@
alarm_hup_init();
}
-static void _cork(_OStream *stream)
+static void _cork(struct _ostream *stream)
{
- FileOStream *fstream = (FileOStream *) stream;
+ struct file_ostream *fstream = (struct file_ostream *) stream;
if (!fstream->corked) {
if (!fstream->no_socket_cork) {
@@ -153,7 +153,7 @@
}
}
-static void update_buffer(FileOStream *fstream, size_t size)
+static void update_buffer(struct file_ostream *fstream, size_t size)
{
size_t used;
@@ -191,7 +191,7 @@
/* NOTE: modifies iov */
static ssize_t
-o_stream_writev(FileOStream *fstream, struct iovec *iov, int iov_size)
+o_stream_writev(struct file_ostream *fstream, struct iovec *iov, int iov_size)
{
ssize_t ret;
@@ -218,7 +218,8 @@
}
/* returns how much of vector was used */
-static int o_stream_fill_iovec(FileOStream *fstream, struct iovec iov[2])
+static int o_stream_fill_iovec(struct file_ostream *fstream,
+ struct iovec iov[2])
{
if (IS_STREAM_EMPTY(fstream))
return 0;
@@ -240,8 +241,8 @@
}
}
-static int o_stream_send_blocking(FileOStream *fstream, const void *data,
- size_t size)
+static int o_stream_send_blocking(struct file_ostream *fstream,
+ const void *data, size_t size)
{
time_t timeout_time;
struct iovec iov[3];
@@ -275,7 +276,7 @@
return 1;
}
-static int buffer_flush(FileOStream *fstream)
+static int buffer_flush(struct file_ostream *fstream)
{
struct iovec iov[2];
int iov_len;
@@ -294,9 +295,9 @@
return 1;
}
-static int _flush(_OStream *stream)
+static int _flush(struct _ostream *stream)
{
- FileOStream *fstream = (FileOStream *) stream;
+ struct file_ostream *fstream = (struct file_ostream *) stream;
int ret;
ret = buffer_flush(fstream);
@@ -313,7 +314,7 @@
return ret;
}
-static size_t get_unused_space(FileOStream *fstream)
+static size_t get_unused_space(struct file_ostream *fstream)
{
if (fstream->head > fstream->tail) {
/* XXXT...HXXX */
@@ -327,9 +328,9 @@
}
}
-static int _have_space(_OStream *stream, size_t size)
+static int _have_space(struct _ostream *stream, size_t size)
{
- FileOStream *fstream = (FileOStream *) stream;
+ struct file_ostream *fstream = (struct file_ostream *) stream;
size_t unused;
if (fstream->max_buffer_size == 0)
@@ -343,9 +344,9 @@
return size <= unused ? 1 : 0;
}
-static int _seek(_OStream *stream, uoff_t offset)
+static int _seek(struct _ostream *stream, uoff_t offset)
{
- FileOStream *fstream = (FileOStream *) stream;
+ struct file_ostream *fstream = (struct file_ostream *) stream;
off_t ret;
if (offset > OFF_T_MAX) {
@@ -369,7 +370,7 @@
return 1;
}
-static void o_stream_grow_buffer(FileOStream *fstream, size_t bytes)
+static void o_stream_grow_buffer(struct file_ostream *fstream, size_t bytes)
{
size_t size, head_size;
@@ -409,9 +410,9 @@
}
static void stream_send_io(void *context, int fd __attr_unused__,
- IO io __attr_unused__)
+ struct io *io __attr_unused__)
{
- FileOStream *fstream = context;
+ struct file_ostream *fstream = context;
struct iovec iov[2];
int iov_len;
@@ -425,7 +426,8 @@
}
}
-static size_t o_stream_add(FileOStream *fstream, const void *data, size_t size)
+static size_t o_stream_add(struct file_ostream *fstream,
+ const void *data, size_t size)
{
size_t unused, sent;
int i;
@@ -463,9 +465,9 @@
return sent;
}
-static ssize_t _send(_OStream *stream, const void *data, size_t size)
+static ssize_t _send(struct _ostream *stream, const void *data, size_t size)
{
- FileOStream *fstream = (FileOStream *) stream;
+ struct file_ostream *fstream = (struct file_ostream *) stream;
struct iovec iov;
ssize_t ret;
@@ -501,9 +503,10 @@
}
}
-static off_t io_stream_sendfile(_OStream *outstream, IStream *instream)
+static off_t io_stream_sendfile(struct _ostream *outstream,
+ struct istream *instream)
{
- FileOStream *foutstream = (FileOStream *) outstream;
+ struct file_ostream *foutstream = (struct file_ostream *) outstream;
time_t timeout_time;
uoff_t start_offset;
uoff_t offset, send_size;
@@ -573,9 +576,10 @@
return (off_t) (instream->v_offset - start_offset);
}
-static off_t io_stream_copy(_OStream *outstream, IStream *instream)
+static off_t io_stream_copy(struct _ostream *outstream,
+ struct istream *instream)
{
- FileOStream *foutstream = (FileOStream *) outstream;
+ struct file_ostream *foutstream = (struct file_ostream *) outstream;
time_t timeout_time;
uoff_t start_offset;
struct iovec iov[3];
@@ -638,7 +642,7 @@
return (off_t) (instream->v_offset - start_offset);
}
-static off_t _send_istream(_OStream *outstream, IStream *instream)
+static off_t _send_istream(struct _ostream *outstream, struct istream *instream)
{
off_t ret;
@@ -659,12 +663,13 @@
return io_stream_copy(outstream, instream);
}
-OStream *o_stream_create_file(int fd, Pool pool, size_t max_buffer_size,
- int priority, int autoclose_fd)
+struct ostream *
+o_stream_create_file(int fd, pool_t pool, size_t max_buffer_size,
+ int priority, int autoclose_fd)
{
- FileOStream *fstream;
+ struct file_ostream *fstream;
- fstream = p_new(pool, FileOStream, 1);
+ fstream = p_new(pool, struct file_ostream, 1);
fstream->fd = fd;
fstream->priority = priority;
fstream->max_buffer_size = max_buffer_size;
Index: ostream-internal.h
===================================================================
RCS file: /home/cvs/dovecot/src/lib/ostream-internal.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- ostream-internal.h 6 Dec 2002 01:09:22 -0000 1.1
+++ ostream-internal.h 5 Jan 2003 13:09:51 -0000 1.2
@@ -4,24 +4,23 @@
#include "ostream.h"
#include "iostream-internal.h"
-typedef struct __OStream _OStream;
-
-struct __OStream {
+struct _ostream {
/* inheritance: */
- _IOStream iostream;
+ struct _iostream iostream;
/* methods: */
- void (*cork)(_OStream *stream);
- int (*flush)(_OStream *stream);
- int (*have_space)(_OStream *stream, size_t size);
- int (*seek)(_OStream *stream, uoff_t offset);
- ssize_t (*send)(_OStream *stream, const void *data, size_t size);
- off_t (*send_istream)(_OStream *outstream, IStream *instream);
+ void (*cork)(struct _ostream *stream);
+ int (*flush)(struct _ostream *stream);
+ int (*have_space)(struct _ostream *stream, size_t size);
+ int (*seek)(struct _ostream *stream, uoff_t offset);
+ ssize_t (*send)(struct _ostream *stream, const void *data, size_t size);
+ off_t (*send_istream)(struct _ostream *outstream,
+ struct istream *instream);
/* data: */
- OStream ostream;
+ struct ostream ostream;
};
-OStream *_o_stream_create(_OStream *_stream, Pool pool);
+struct ostream *_o_stream_create(struct _ostream *_stream, pool_t pool);
#endif
Index: ostream.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib/ostream.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- ostream.c 19 Dec 2002 01:02:35 -0000 1.2
+++ ostream.c 5 Jan 2003 13:09:51 -0000 1.3
@@ -27,37 +27,37 @@
#include "istream.h"
#include "ostream-internal.h"
-void o_stream_ref(OStream *stream)
+void o_stream_ref(struct ostream *stream)
{
_io_stream_ref(stream->real_stream);
}
-void o_stream_unref(OStream *stream)
+void o_stream_unref(struct ostream *stream)
{
_io_stream_unref(stream->real_stream);
}
-void o_stream_close(OStream *stream)
+void o_stream_close(struct ostream *stream)
{
_io_stream_close(stream->real_stream);
stream->closed = TRUE;
}
-void o_stream_set_max_buffer_size(OStream *stream, size_t max_size)
+void o_stream_set_max_buffer_size(struct ostream *stream, size_t max_size)
{
_io_stream_set_max_buffer_size(stream->real_stream, max_size);
}
-void o_stream_set_blocking(OStream *stream, int timeout_msecs,
+void o_stream_set_blocking(struct ostream *stream, int timeout_msecs,
void (*timeout_func)(void *), void *context)
{
_io_stream_set_blocking(stream->real_stream, timeout_msecs,
timeout_func, context);
}
-void o_stream_cork(OStream *stream)
+void o_stream_cork(struct ostream *stream)
{
- _OStream *_stream = stream->real_stream;
+ struct _ostream *_stream = stream->real_stream;
if (stream->closed)
return;
@@ -65,9 +65,9 @@
_stream->cork(_stream);
}
-int o_stream_flush(OStream *stream)
+int o_stream_flush(struct ostream *stream)
{
- _OStream *_stream = stream->real_stream;
+ struct _ostream *_stream = stream->real_stream;
if (stream->closed)
return -1;
@@ -75,16 +75,16 @@
return _stream->flush(_stream);
}
-int o_stream_have_space(OStream *stream, size_t size)
+int o_stream_have_space(struct ostream *stream, size_t size)
{
- _OStream *_stream = stream->real_stream;
+ struct _ostream *_stream = stream->real_stream;
return _stream->have_space(_stream, size);
}
-int o_stream_seek(OStream *stream, uoff_t offset)
+int o_stream_seek(struct ostream *stream, uoff_t offset)
{
- _OStream *_stream = stream->real_stream;
+ struct _ostream *_stream = stream->real_stream;
if (stream->closed)
return -1;
@@ -92,9 +92,9 @@
return _stream->seek(_stream, offset);
}
-ssize_t o_stream_send(OStream *stream, const void *data, size_t size)
+ssize_t o_stream_send(struct ostream *stream, const void *data, size_t size)
{
- _OStream *_stream = stream->real_stream;
+ struct _ostream *_stream = stream->real_stream;
if (stream->closed)
return -1;
@@ -105,14 +105,15 @@
return _stream->send(_stream, data, size);
}
-ssize_t o_stream_send_str(OStream *stream, const char *str)
+ssize_t o_stream_send_str(struct ostream *stream, const char *str)
{
return o_stream_send(stream, str, strlen(str));
}
-off_t o_stream_send_istream(OStream *outstream, IStream *instream)
+off_t o_stream_send_istream(struct ostream *outstream,
+ struct istream *instream)
{
- _OStream *_outstream = outstream->real_stream;
+ struct _ostream *_outstream = outstream->real_stream;
if (outstream->closed || instream->closed)
return -1;
@@ -120,7 +121,7 @@
return _outstream->send_istream(_outstream, instream);
}
-OStream *_o_stream_create(_OStream *_stream, Pool pool)
+struct ostream *_o_stream_create(struct _ostream *_stream, pool_t pool)
{
_stream->ostream.real_stream = _stream;
Index: ostream.h
===================================================================
RCS file: /home/cvs/dovecot/src/lib/ostream.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- ostream.h 19 Dec 2002 01:02:35 -0000 1.2
+++ ostream.h 5 Jan 2003 13:09:51 -0000 1.3
@@ -1,7 +1,7 @@
#ifndef __OSTREAM_H
#define __OSTREAM_H
-struct _OStream {
+struct ostream {
uoff_t offset;
int stream_errno;
@@ -10,45 +10,47 @@
void *real_stream;
};
-OStream *o_stream_create_file(int fd, Pool pool, size_t max_buffer_size,
- int priority, int autoclose_fd);
+struct ostream *
+o_stream_create_file(int fd, pool_t pool, size_t max_buffer_size,
+ int priority, int autoclose_fd);
/* Reference counting. References start from 1, so calling o_stream_unref()
destroys the stream if o_stream_ref() is never used. */
-void o_stream_ref(OStream *stream);
-void o_stream_unref(OStream *stream);
+void o_stream_ref(struct ostream *stream);
+void o_stream_unref(struct ostream *stream);
/* Mark the stream closed. Nothing will be sent after this call. */
-void o_stream_close(OStream *stream);
+void o_stream_close(struct ostream *stream);
/* Change the maximum size for stream's output buffer to grow. */
-void o_stream_set_max_buffer_size(OStream *stream, size_t max_size);
+void o_stream_set_max_buffer_size(struct ostream *stream, size_t max_size);
/* Stream is made to be flushed out whenever it gets full (assumes max_size
is already set), ie. writes will never be partial. Also makes any blocking
writes to fail after specified timeout, calling timeout_func if it's
set. This call changes non-blocking state of file descriptor. */
-void o_stream_set_blocking(OStream *stream, int timeout_msecs,
+void o_stream_set_blocking(struct ostream *stream, int timeout_msecs,
void (*timeout_func)(void *), void *context);
/* Delays sending as far as possible, writing only full buffers. Also sets
TCP_CORK on if supported. o_stream_flush() removes the cork. */
-void o_stream_cork(OStream *stream);
+void o_stream_cork(struct ostream *stream);
/* Flush the output stream, blocks until everything is sent.
Returns 1 if ok, -1 if error. */
-int o_stream_flush(OStream *stream);
+int o_stream_flush(struct ostream *stream);
/* Returns 1 if specified amount of data currently fits into stream's output
buffer, 0 if not. */
-int o_stream_have_space(OStream *stream, size_t size);
+int o_stream_have_space(struct ostream *stream, size_t size);
/* Seek to specified position from beginning of file. This works only for
files. Returns 1 if successful, -1 if error. */
-int o_stream_seek(OStream *stream, uoff_t offset);
+int o_stream_seek(struct ostream *stream, uoff_t offset);
/* Returns number of bytes sent or buffered, or -1 if disconnected */
-ssize_t o_stream_send(OStream *stream, const void *data, size_t size);
-ssize_t o_stream_send_str(OStream *stream, const char *str);
+ssize_t o_stream_send(struct ostream *stream, const void *data, size_t size);
+ssize_t o_stream_send_str(struct ostream *stream, const char *str);
/* Send data from input stream. Returns number of bytes sent, or -1 if error.
Note that this function may block if either instream or outstream is
blocking. */
-off_t o_stream_send_istream(OStream *outstream, IStream *instream);
+off_t o_stream_send_istream(struct ostream *outstream,
+ struct istream *instream);
#endif
Index: str.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib/str.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- str.c 4 Jan 2003 17:26:29 -0000 1.6
+++ str.c 5 Jan 2003 13:09:51 -0000 1.7
@@ -28,17 +28,17 @@
#include <stdio.h>
-String *str_new(Pool pool, size_t initial_size)
+string_t *str_new(pool_t pool, size_t initial_size)
{
return buffer_create_dynamic(pool, initial_size, (size_t)-1);
}
-String *t_str_new(size_t initial_size)
+string_t *t_str_new(size_t initial_size)
{
return str_new(data_stack_pool, initial_size);
}
-static int str_add_nul(String *str)
+static int str_add_nul(string_t *str)
{
size_t len;
@@ -59,7 +59,7 @@
return TRUE;
}
-const char *str_c(String *str)
+const char *str_c(string_t *str)
{
if (!str_add_nul(str))
return "";
@@ -67,12 +67,12 @@
return buffer_get_data(str, NULL);
}
-const unsigned char *str_data(const String *str)
+const unsigned char *str_data(const string_t *str)
{
return buffer_get_data(str, NULL);
}
-char *str_c_modifyable(String *str)
+char *str_c_modifyable(string_t *str)
{
if (!str_add_nul(str))
return NULL;
@@ -80,17 +80,17 @@
return buffer_get_modifyable_data(str, NULL);
}
-size_t str_len(const String *str)
+size_t str_len(const string_t *str)
{
return buffer_get_used_size(str);
}
-void str_append(String *str, const char *cstr)
+void str_append(string_t *str, const char *cstr)
{
buffer_append(str, cstr, strlen(cstr));
}
-void str_append_n(String *str, const void *cstr, size_t max_len)
+void str_append_n(string_t *str, const void *cstr, size_t max_len)
{
size_t len;
@@ -101,12 +101,12 @@
buffer_append(str, cstr, len);
}
-void str_append_c(String *str, char chr)
+void str_append_c(string_t *str, char chr)
{
buffer_append_c(str, chr);
}
-void str_append_str(String *dest, const String *src)
+void str_append_str(string_t *dest, const string_t *src)
{
const char *cstr;
size_t len;
@@ -115,7 +115,7 @@
buffer_append(dest, cstr, len);
}
-void str_printfa(String *str, const char *fmt, ...)
+void str_printfa(string_t *str, const char *fmt, ...)
{
va_list args;
@@ -124,7 +124,7 @@
va_end(args);
}
-void str_vprintfa(String *str, const char *fmt, va_list args)
+void str_vprintfa(string_t *str, const char *fmt, va_list args)
{
char *buf;
int ret;
@@ -153,12 +153,12 @@
buffer_set_used_size(str, len);
}
-void str_delete(String *str, size_t pos, size_t len)
+void str_delete(string_t *str, size_t pos, size_t len)
{
buffer_delete(str, pos, len);
}
-void str_truncate(String *str, size_t len)
+void str_truncate(string_t *str, size_t len)
{
buffer_set_used_size(str, len);
}
Index: str.h
===================================================================
RCS file: /home/cvs/dovecot/src/lib/str.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- str.h 4 Jan 2003 17:26:29 -0000 1.2
+++ str.h 5 Jan 2003 13:09:51 -0000 1.3
@@ -1,27 +1,27 @@
#ifndef __STR_H
#define __STR_H
-String *str_new(Pool pool, size_t initial_size);
-String *t_str_new(size_t initial_size);
+string_t *str_new(pool_t pool, size_t initial_size);
+string_t *t_str_new(size_t initial_size);
-const char *str_c(String *str);
-const unsigned char *str_data(const String *str);
-char *str_c_modifyable(String *str);
-size_t str_len(const String *str);
+const char *str_c(string_t *str);
+const unsigned char *str_data(const string_t *str);
+char *str_c_modifyable(string_t *str);
+size_t str_len(const string_t *str);
/* Append string/character */
-void str_append(String *str, const char *cstr);
-void str_append_n(String *str, const void *cstr, size_t max_len);
-void str_append_c(String *str, char chr);
-void str_append_str(String *dest, const String *src);
+void str_append(string_t *str, const char *cstr);
+void str_append_n(string_t *str, const void *cstr, size_t max_len);
+void str_append_c(string_t *str, char chr);
+void str_append_str(string_t *dest, const string_t *src);
/* Append printf()-like data */
-void str_printfa(String *str, const char *fmt, ...)
+void str_printfa(string_t *str, const char *fmt, ...)
__attr_format__(2, 3);
-void str_vprintfa(String *str, const char *fmt, va_list args);
+void str_vprintfa(string_t *str, const char *fmt, va_list args);
/* Delete/truncate */
-void str_delete(String *str, size_t pos, size_t len);
-void str_truncate(String *str, size_t len);
+void str_delete(string_t *str, size_t pos, size_t len);
+void str_truncate(string_t *str, size_t len);
#endif
Index: strescape.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib/strescape.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- strescape.c 4 Jan 2003 17:26:29 -0000 1.2
+++ strescape.c 5 Jan 2003 13:09:51 -0000 1.3
@@ -51,7 +51,7 @@
return ret;
}
-void str_append_unescaped(String *dest, const void *src, size_t src_size)
+void str_append_unescaped(string_t *dest, const void *src, size_t src_size)
{
const unsigned char *src_c = src;
size_t start = 0, i = 0;
Index: strescape.h
===================================================================
RCS file: /home/cvs/dovecot/src/lib/strescape.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- strescape.h 4 Jan 2003 17:26:29 -0000 1.2
+++ strescape.h 5 Jan 2003 13:09:51 -0000 1.3
@@ -7,7 +7,7 @@
const char *str_escape(const char *str);
/* remove all '\' characters, append to given string */
-void str_append_unescaped(String *dest, const void *src, size_t src_size);
+void str_append_unescaped(string_t *dest, const void *src, size_t src_size);
/* remove all '\' characters */
void str_unescape(char *str);
Index: strfuncs.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib/strfuncs.c,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -d -r1.27 -r1.28
--- strfuncs.c 4 Jan 2003 17:26:29 -0000 1.27
+++ strfuncs.c 5 Jan 2003 13:09:51 -0000 1.28
@@ -142,7 +142,7 @@
return ret;
}
-char *p_strdup(Pool pool, const char *str)
+char *p_strdup(pool_t pool, const char *str)
{
void *mem;
size_t len;
@@ -159,7 +159,7 @@
return mem;
}
-char *p_strdup_empty(Pool pool, const char *str)
+char *p_strdup_empty(pool_t pool, const char *str)
{
if (str == NULL || *str == '\0')
return NULL;
@@ -167,7 +167,7 @@
return p_strdup(pool, str);
}
-char *p_strdup_until(Pool pool, const void *start, const void *end)
+char *p_strdup_until(pool_t pool, const void *start, const void *end)
{
size_t size;
char *mem;
@@ -181,7 +181,7 @@
return mem;
}
-char *p_strndup(Pool pool, const void *str, size_t max_chars)
+char *p_strndup(pool_t pool, const void *str, size_t max_chars)
{
char *mem;
size_t len;
@@ -201,7 +201,7 @@
return mem;
}
-char *p_strdup_printf(Pool pool, const char *format, ...)
+char *p_strdup_printf(pool_t pool, const char *format, ...)
{
va_list args;
char *ret;
@@ -213,7 +213,7 @@
return ret;
}
-char *p_strdup_vprintf(Pool pool, const char *format, va_list args)
+char *p_strdup_vprintf(pool_t pool, const char *format, va_list args)
{
char *ret;
va_list args2;
@@ -280,7 +280,7 @@
return temp;
}
-char *p_strconcat(Pool pool, const char *str1, ...)
+char *p_strconcat(pool_t pool, const char *str1, ...)
{
va_list args;
const char *temp;
Index: strfuncs.h
===================================================================
RCS file: /home/cvs/dovecot/src/lib/strfuncs.h,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- strfuncs.h 4 Jan 2003 17:26:29 -0000 1.15
+++ strfuncs.h 5 Jan 2003 13:09:51 -0000 1.16
@@ -12,13 +12,14 @@
int i_snprintf(char *dest, size_t max_chars, const char *format, ...)
__attr_format__(3, 4);
-char *p_strdup(Pool pool, const char *str);
-char *p_strdup_empty(Pool pool, const char *str); /* return NULL if str = "" */
-char *p_strdup_until(Pool pool, const void *start, const void *end); /* *end isn't included */
-char *p_strndup(Pool pool, const void *str, size_t max_chars);
-char *p_strdup_printf(Pool pool, const char *format, ...) __attr_format__(2, 3);
-char *p_strdup_vprintf(Pool pool, const char *format, va_list args);
-char *p_strconcat(Pool pool, const char *str1, ...); /* NULL terminated */
+char *p_strdup(pool_t pool, const char *str);
+char *p_strdup_empty(pool_t pool, const char *str); /* return NULL if str = "" */
+char *p_strdup_until(pool_t pool, const void *start, const void *end); /* *end isn't included */
+char *p_strndup(pool_t pool, const void *str, size_t max_chars);
+char *p_strdup_printf(pool_t pool, const char *format, ...)
+ __attr_format__(2, 3);
+char *p_strdup_vprintf(pool_t pool, const char *format, va_list args);
+char *p_strconcat(pool_t pool, const char *str1, ...); /* NULL terminated */
/* same with temporary memory allocations: */
const char *t_strdup(const char *str);
- Previous message: [dovecot-cvs] dovecot/src/lib-mail message-address.c,NONE,1.1 message-address.h,NONE,1.1 message-date.c,NONE,1.1 message-date.h,NONE,1.1 message-tokenize.c,NONE,1.1 message-tokenize.h,NONE,1.1 Makefile.am,1.6,1.7 message-body-search.c,1.8,1.9 Message-Id: <20030105130956.8F2DA23997@danu.procontrol.fi>
- Next message: [dovecot-cvs] dovecot configure.in,1.81,1.82
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the dovecot-cvs
mailing list