2 * IRC - Internet Relay Chat, include/dbuf.h
3 * Copyright (C) 1990 Markku Savela
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2, or (at your option)
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 #ifndef INCLUDED_dbuf_h
20 #define INCLUDED_dbuf_h
21 #ifndef INCLUDED_sys_types_h
22 #include <sys/types.h> /* size_t */
23 #define INCLUDED_sys_types_h
27 * These two globals should be considered read only
29 extern int DBufAllocCount; /* GLOBAL - count of dbufs allocated */
30 extern int DBufUsedCount; /* GLOBAL - count of dbufs in use */
35 size_t length; /* Current number of bytes stored */
36 struct DBufBuffer *head; /* First data buffer, if length > 0 */
37 struct DBufBuffer *tail; /* last data buffer, if length > 0 */
41 * DBufLength - Returns the current number of bytes stored into the buffer.
43 #define DBufLength(dyn) ((dyn)->length)
46 * DBufClear - Scratch the current content of the buffer.
47 * Release all allocated buffers and make it empty.
49 #define DBufClear(dyn) dbuf_delete((dyn), DBufLength(dyn))
54 extern void dbuf_delete(struct DBuf *dyn, size_t length);
55 extern int dbuf_put(struct DBuf *dyn, const char *buf, size_t length);
56 extern const char *dbuf_map(const struct DBuf *dyn, size_t *length);
57 extern size_t dbuf_get(struct DBuf *dyn, char *buf, size_t length);
58 extern size_t dbuf_getmsg(struct DBuf *dyn, char *buf, size_t length);
59 extern void dbuf_count_memory(size_t *allocated, size_t *used);
62 #endif /* INCLUDED_dbuf_h */