]> jfr.im git - irc/rqf/shadowircd.git/blame - libcharybdis/linebuf.h
dlink -> rb_dlink
[irc/rqf/shadowircd.git] / libcharybdis / linebuf.h
CommitLineData
212380e3 1/*
2 * ircd-ratbox: A slightly useful ircd.
3 * linebuf.h: A header for the linebuf code.
4 *
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
8 *
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.
13 *
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.
18 *
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
22 * USA
23 *
24 * $Id: linebuf.h 376 2005-12-07 15:00:41Z nenolod $
25 */
26
27#ifndef __LINEBUF_H__
28#define __LINEBUF_H__
29
30#include "tools.h"
5cd74a3b 31#include "commio.h"
212380e3 32
33/* How big we want a buffer - 510 data bytes, plus space for a '\0' */
34#define BUF_DATA_SIZE 511
35
36#define LINEBUF_COMPLETE 0
37#define LINEBUF_PARTIAL 1
38#define LINEBUF_PARSED 0
39#define LINEBUF_RAW 1
40
41struct _buf_line;
42struct _buf_head;
43
44typedef struct _buf_line buf_line_t;
45typedef struct _buf_head buf_head_t;
46
47struct _buf_line
48{
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 */
56};
57
58struct _buf_head
59{
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 */
65};
66
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)
71
72extern 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 *); */
78extern void linebuf_newbuf(buf_head_t *);
79extern void client_flush_input(struct Client *);
80extern void linebuf_donebuf(buf_head_t *);
81extern int linebuf_parse(buf_head_t *, char *, int, int);
82extern int linebuf_get(buf_head_t *, char *, int, int, int);
83extern void linebuf_putmsg(buf_head_t *, const char *, va_list *, const char *, ...);
5cd74a3b 84extern int linebuf_flush(fde_t *, buf_head_t *);
212380e3 85extern void linebuf_attach(buf_head_t *, buf_head_t *);
86extern void count_linebuf_memory(size_t *, size_t *);
87#endif