(copy_file_preserving): Declare buf_size to be of type size_t, not int.
[gnulib.git] / lib / linebuffer.h
1 /* linebuffer.h -- declarations for reading arbitrarily long lines
2
3    Copyright (C) 1986, 1991, 1998, 1999, 2002, 2003 Free Software
4    Foundation, Inc.
5
6    This program is free software; you can redistribute it and/or modify
7    it under the terms of the GNU General Public License as published by
8    the Free Software Foundation; either version 2, or (at your option)
9    any later version.
10
11    This program is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14    GNU General Public License for more details.
15
16    You should have received a copy of the GNU General Public License
17    along with this program; if not, write to the Free Software Foundation,
18    Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
19
20 #if !defined LINEBUFFER_H
21 # define LINEBUFFER_H
22
23 /* A `struct linebuffer' holds a line of text. */
24
25 struct linebuffer
26 {
27   size_t size;                  /* Allocated. */
28   size_t length;                /* Used. */
29   char *buffer;
30 };
31
32 # ifndef PARAMS
33 #  if defined PROTOTYPES || (defined __STDC__ && __STDC__)
34 #   define PARAMS(Args) Args
35 #  else
36 #   define PARAMS(Args) ()
37 #  endif
38 # endif
39
40 /* Initialize linebuffer LINEBUFFER for use. */
41 void initbuffer PARAMS ((struct linebuffer *linebuffer));
42
43 /* Read an arbitrarily long line of text from STREAM into LINEBUFFER.
44    Keep the newline; append a newline if it's the last line of a file
45    that ends in a non-newline character.  Do not null terminate.
46    Return LINEBUFFER, except at end of file return 0.  */
47 struct linebuffer *readlinebuffer PARAMS ((struct linebuffer *linebuffer,
48                                            FILE *stream));
49
50 /* Free linebuffer LINEBUFFER and its data, all allocated with malloc. */
51 void freebuffer PARAMS ((struct linebuffer *));
52
53 #endif /* LINEBUFFER_H */