2 * ircd-ratbox: A slightly useful ircd.
3 * linebuf.h: A header for the linebuf code.
5 * Copyright (C) 1990 Jarkko Oikarinen and University of Oulu, Co Center
6 * Copyright (C) 1996-2002 Hybrid Development Team
7 * Copyright (C) 2002-2004 ircd-ratbox development team
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
24 * $Id: linebuf.h 26 2006-09-20 18:02:06Z spb $
32 /* How big we want a buffer - 510 data bytes, plus space for a '\0' */
33 #define BUF_DATA_SIZE 511
35 #define LINEBUF_COMPLETE 0
36 #define LINEBUF_PARTIAL 1
37 #define LINEBUF_PARSED 0
43 typedef struct _buf_line buf_line_t
;
44 typedef struct _buf_head buf_head_t
;
48 char buf
[BUF_DATA_SIZE
+ 2];
49 unsigned int terminated
; /* Whether we've terminated the buffer */
50 unsigned int flushing
; /* Whether we're flushing .. */
51 unsigned int raw
; /* Whether this linebuf may hold 8-bit data */
52 int len
; /* How much data we've got */
53 int refcount
; /* how many linked lists are we in? */
54 struct _buf_line
*next
; /* next in free list */
59 dlink_list list
; /* the actual dlink list */
60 int len
; /* length of all the data */
61 int alloclen
; /* Actual allocated data length */
62 int writeofs
; /* offset in the first line for the write */
63 int numlines
; /* number of lines */
66 /* they should be functions, but .. */
67 #define linebuf_len(x) ((x)->len)
68 #define linebuf_alloclen(x) ((x)->alloclen)
69 #define linebuf_numlines(x) ((x)->numlines)
71 extern void linebuf_init(void);
72 /* declared as static */
73 /* extern buf_line_t *linebuf_new_line(buf_head_t *); */
74 /* extern void linebuf_done_line(buf_head_t *, buf_line_t *, dlink_node *); */
75 /* extern int linebuf_skip_crlf(char *, int); */
76 /* extern void linebuf_terminate_crlf(buf_head_t *, buf_line_t *); */
77 extern void linebuf_newbuf(buf_head_t
*);
78 extern void client_flush_input(struct Client
*);
79 extern void linebuf_donebuf(buf_head_t
*);
80 extern int linebuf_parse(buf_head_t
*, char *, int, int);
81 extern int linebuf_get(buf_head_t
*, char *, int, int, int);
82 extern void linebuf_putmsg(buf_head_t
*, const char *, va_list *, const char *, ...);
83 extern int linebuf_flush(int, buf_head_t
*);
84 extern void linebuf_attach(buf_head_t
*, buf_head_t
*);
85 extern void count_linebuf_memory(size_t *, size_t *);