2
* $Id: getline.h,v 1.9 2003/07/15 09:07:55 rmanfredi Exp $
4
* Copyright (c) 2001-2003, Raphael Manfredi
6
*----------------------------------------------------------------------
7
* This file is part of gtk-gnutella.
9
* gtk-gnutella 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
* gtk-gnutella 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 gtk-gnutella; if not, write to the Free Software
22
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23
*----------------------------------------------------------------------
31
#define MAX_LINE_SIZE 1024 /* Maximum length for regular line */
34
* getline() return codes.
37
#define READ_MORE 0 /* OK, expecting more */
38
#define READ_DONE 1 /* OK, got whole line */
39
#define READ_OVERFLOW 2 /* Reached max line size */
45
typedef struct getline {
46
guint maxlen; /* Maximum authorized length */
47
guint size; /* Current allocated size for `line' */
48
gchar *line; /* Accumulator, NUL terminated when done */
49
guint pos; /* Next writing position in line[] */
52
#define getline_maxlen(o) ((o)->maxlen)
58
getline_t *getline_make(gint maxsize);
59
void getline_free(getline_t *o);
60
void getline_reset(getline_t *o);
61
gint getline_read(getline_t *o, gchar *data, gint len, gint *used);
62
gchar *getline_str(getline_t *o);
63
gint getline_length(getline_t *o);
64
void getline_copy(getline_t *source, getline_t *dest);
66
#endif /* _getline_h_ */