]> jfr.im git - irc/rqf/shadowircd.git/blame - libcharybdis/linebuf.h
[svn] - update config files
[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"
31
32/* How big we want a buffer - 510 data bytes, plus space for a '\0' */
33#define BUF_DATA_SIZE 511
34
35#define LINEBUF_COMPLETE 0
36#define LINEBUF_PARTIAL 1
37#define LINEBUF_PARSED 0
38#define LINEBUF_RAW 1
39
40struct _buf_line;
41struct _buf_head;
42
43typedef struct _buf_line buf_line_t;
44typedef struct _buf_head buf_head_t;
45
46struct _buf_line
47{
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 */
55};
56
57struct _buf_head
58{
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 */
64};
65
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)
70
71extern 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 *); */
77extern void linebuf_newbuf(buf_head_t *);
78extern void client_flush_input(struct Client *);
79extern void linebuf_donebuf(buf_head_t *);
80extern int linebuf_parse(buf_head_t *, char *, int, int);
81extern int linebuf_get(buf_head_t *, char *, int, int, int);
82extern void linebuf_putmsg(buf_head_t *, const char *, va_list *, const char *, ...);
83extern int linebuf_flush(int, buf_head_t *);
84extern void linebuf_attach(buf_head_t *, buf_head_t *);
85extern void count_linebuf_memory(size_t *, size_t *);
86#endif