]>
jfr.im git - irc/rqf/shadowircd.git/blob - libcharybdis/linebuf.h
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 376 2005-12-07 15:00:41Z nenolod $
33 /* How big we want a buffer - 510 data bytes, plus space for a '\0' */
34 #define BUF_DATA_SIZE 511
36 #define LINEBUF_COMPLETE 0
37 #define LINEBUF_PARTIAL 1
38 #define LINEBUF_PARSED 0
44 typedef struct _buf_line buf_line_t
;
45 typedef struct _buf_head buf_head_t
;
49 char buf
[BUF_DATA_SIZE
+ 2];
50 unsigned int terminated
; /* Whether we've terminated the buffer */
51 unsigned int flushing
; /* Whether we're flushing .. */
52 unsigned int raw
; /* Whether this linebuf may hold 8-bit data */
53 int len
; /* How much data we've got */
54 int refcount
; /* how many linked lists are we in? */
55 struct _buf_line
*next
; /* next in free list */
60 dlink_list list
; /* the actual dlink list */
61 int len
; /* length of all the data */
62 int alloclen
; /* Actual allocated data length */
63 int writeofs
; /* offset in the first line for the write */
64 int numlines
; /* number of lines */
67 /* they should be functions, but .. */
68 #define linebuf_len(x) ((x)->len)
69 #define linebuf_alloclen(x) ((x)->alloclen)
70 #define linebuf_numlines(x) ((x)->numlines)
72 extern void linebuf_init(void);
73 /* declared as static */
74 /* extern buf_line_t *linebuf_new_line(buf_head_t *); */
75 /* extern void linebuf_done_line(buf_head_t *, buf_line_t *, dlink_node *); */
76 /* extern int linebuf_skip_crlf(char *, int); */
77 /* extern void linebuf_terminate_crlf(buf_head_t *, buf_line_t *); */
78 extern void linebuf_newbuf(buf_head_t
*);
79 extern void client_flush_input(struct Client
*);
80 extern void linebuf_donebuf(buf_head_t
*);
81 extern int linebuf_parse(buf_head_t
*, char *, int, int);
82 extern int linebuf_get(buf_head_t
*, char *, int, int, int);
83 extern void linebuf_putmsg(buf_head_t
*, const char *, va_list *, const char *, ...);
84 extern int linebuf_flush(fde_t
*, buf_head_t
*);
85 extern void linebuf_attach(buf_head_t
*, buf_head_t
*);
86 extern void count_linebuf_memory(size_t *, size_t *);