dbuffer.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifdef DBUFFER_H
00020 struct dbuffer;
00021 #else
00022 #define DBUFFER_H
00023
00024 #include <sys/types.h>
00025
00037 struct dbuffer_element;
00038
00047 struct dbuffer
00048 {
00050 size_t len;
00051
00054 size_t space;
00055
00057 struct dbuffer_element *head;
00058
00060 struct dbuffer_element *tail;
00061
00067 char *start;
00068
00077 char *end;
00078
00081 struct dbuffer *next_free;
00082 };
00083
00084 extern struct dbuffer *new_dbuffer(void) __attribute__((malloc));
00085 extern void free_dbuffer(struct dbuffer *);
00086
00087
00088 extern void dbuffer_add(struct dbuffer *, const char *, size_t);
00089
00090 extern size_t dbuffer_get(const struct dbuffer *, char *, size_t);
00091
00092 extern size_t dbuffer_get_at(const struct dbuffer *, size_t, char *, size_t);
00093
00094 extern size_t dbuffer_remove(struct dbuffer *, size_t);
00095
00096 extern size_t dbuffer_extract(struct dbuffer *, char *, size_t);
00097
00098 extern struct dbuffer *dbuffer_dup(struct dbuffer *);
00099
00100 extern struct dbuffer *dbuffer_prepend(struct dbuffer *old, const char *data, size_t len);
00101
00102 struct dbuffer *dbuffer_merge(struct dbuffer *old, struct dbuffer *old2);
00103
00104 void dbuffer_shutdown(void);
00105 void dbuffer_init(void);
00106
00107 #define dbuffer_len(A) (A ? (A)->len : 0)
00108
00109 #endif