X-Git-Url: http://git.madism.org/?a=blobdiff_plain;f=buffer.h;h=c94714dabac842b3daaff32efbd7bb466b657efa;hb=dc1c24f73dfe8a1e7d92897cb741c52be2a15c4d;hp=e3075ba032154f6a8182b751ddd3d42501f3f0f3;hpb=9a4efa4f0dc893f243ee69d1b20f024666ca943d;p=apps%2Fpfixtools.git diff --git a/buffer.h b/buffer.h index e3075ba..c94714d 100644 --- a/buffer.h +++ b/buffer.h @@ -1,5 +1,5 @@ /******************************************************************************/ -/* postlicyd: a postfix policy daemon with a lot of features */ +/* pfixtools: a collection of postfix related tools */ /* ~~~~~~~~~ */ /* ________________________________________________________________________ */ /* */ @@ -30,11 +30,11 @@ /******************************************************************************/ /* - * Copyright © 2006 Pierre Habouzit + * Copyright © 2006-2007 Pierre Habouzit */ -#ifndef MUTT_LIB_LIB_BUFFER_H -#define MUTT_LIB_LIB_BUFFER_H +#ifndef POSTLICYD_BUFFER_H +#define POSTLICYD_BUFFER_H #include "mem.h" #include "str.h" @@ -45,6 +45,8 @@ typedef struct buffer_t { ssize_t size; } buffer_t; +#define BUFFER_INIT {NULL, 0, 0} + DO_INIT(buffer_t, buffer); static inline void buffer_wipe(buffer_t *buf) { p_delete(&buf->data); @@ -52,6 +54,10 @@ static inline void buffer_wipe(buffer_t *buf) { DO_NEW(buffer_t, buffer); DO_DELETE(buffer_t, buffer); +static inline void buffer_reset(buffer_t *buf) { + buf->data[buf->len = 0] = '\0'; +} + static inline char *buffer_unwrap(buffer_t **buf) { char *res = (*buf)->data; (*buf)->data = NULL; @@ -96,4 +102,8 @@ static inline void buffer_addch(buffer_t *buf, int c) { buffer_extendch(buf, 1, c); } -#endif /* MUTT_LIB_LIB_BUFFER_H */ +void buffer_consume(buffer_t *buf, ssize_t len); + +ssize_t buffer_read(buffer_t *buf, int fd, ssize_t count); + +#endif /* POSTLICYD_BUFFER_H */