~ubuntu-branches/ubuntu/karmic/gtk-gnutella/karmic

« back to all changes in this revision

Viewing changes to src/getline.h

  • Committer: Bazaar Package Importer
  • Author(s): Anand Kumria
  • Date: 2005-08-04 11:32:05 UTC
  • mfrom: (1.2.1 upstream) (2.1.1 sarge)
  • Revision ID: james.westby@ubuntu.com-20050804113205-q746i4lgo3rtlegn
Tags: 0.95.4-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * $Id: getline.h,v 1.9 2003/07/15 09:07:55 rmanfredi Exp $
3
 
 *
4
 
 * Copyright (c) 2001-2003, Raphael Manfredi
5
 
 *
6
 
 *----------------------------------------------------------------------
7
 
 * This file is part of gtk-gnutella.
8
 
 *
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.
13
 
 *
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.
18
 
 *
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
21
 
 *  Foundation, Inc.:
22
 
 *      59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
23
 
 *----------------------------------------------------------------------
24
 
 */
25
 
 
26
 
#ifndef _getline_h_
27
 
#define _getline_h_
28
 
 
29
 
#include <glib.h>
30
 
 
31
 
#define MAX_LINE_SIZE   1024    /* Maximum length for regular line */
32
 
 
33
 
/*
34
 
 * getline() return codes.
35
 
 */
36
 
 
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 */
40
 
 
41
 
/*
42
 
 * A getline "object".
43
 
 */
44
 
 
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[] */
50
 
} getline_t;
51
 
 
52
 
#define getline_maxlen(o)       ((o)->maxlen)
53
 
 
54
 
/*
55
 
 * Public interface.
56
 
 */
57
 
 
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);
65
 
 
66
 
#endif  /* _getline_h_ */
67
 
 
68
 
/* vi: set ts=4: */
69