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.
21 #ifndef INCLUDED_dbuf_h
22 #define INCLUDED_dbuf_h
23 #ifndef INCLUDED_sys_types_h
24 #include <sys/types.h> /* size_t */
25 #define INCLUDED_sys_types_h
29 * These two globals should be considered read only
31 extern int DBufAllocCount; /* GLOBAL - count of dbufs allocated */
32 extern int DBufUsedCount; /* GLOBAL - count of dbufs in use */
37 unsigned int length; /* Current number of bytes stored */
38 struct DBufBuffer *head; /* First data buffer, if length > 0 */
39 struct DBufBuffer *tail; /* last data buffer, if length > 0 */
43 * DBufLength - Returns the current number of bytes stored into the buffer.
45 #define DBufLength(dyn) ((dyn)->length)
48 * DBufClear - Scratch the current content of the buffer.
49 * Release all allocated buffers and make it empty.
51 #define DBufClear(dyn) dbuf_delete((dyn), DBufLength(dyn))
56 extern void dbuf_delete(struct DBuf *dyn, unsigned int length);
57 extern int dbuf_put(struct DBuf *dyn, const char *buf, unsigned int length);
58 extern const char *dbuf_map(const struct DBuf *dyn, unsigned int *length);
59 extern unsigned int dbuf_get(struct DBuf *dyn, char *buf, unsigned int length);
60 extern unsigned int dbuf_getmsg(struct DBuf *dyn, char *buf, unsigned int length);
61 extern void dbuf_count_memory(size_t *allocated, size_t *used);
64 #endif /* INCLUDED_dbuf_h */