Mercurial > hg > octave-nkf > gnulib-hg
annotate lib/linebuffer.h @ 4397:c6450308f123
Assume C89, so PARAMS isn't needed.
author | Paul Eggert <eggert@cs.ucla.edu> |
---|---|
date | Wed, 18 Jun 2003 05:52:19 +0000 |
parents | df44e79ce676 |
children | a48fb0e98c8c |
rev | line source |
---|---|
14 | 1 /* linebuffer.h -- declarations for reading arbitrarily long lines |
4169
f3219f604940
(readlinebuffer): Renamed from readline.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4103
diff
changeset
|
2 |
f3219f604940
(readlinebuffer): Renamed from readline.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4103
diff
changeset
|
3 Copyright (C) 1986, 1991, 1998, 1999, 2002, 2003 Free Software |
f3219f604940
(readlinebuffer): Renamed from readline.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4103
diff
changeset
|
4 Foundation, Inc. |
14 | 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 | |
756 | 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. */ | |
1216
cf3c93b52b9b
Make PARAMS-defining conditionals consistent.
Jim Meyering <jim@meyering.net>
parents:
756
diff
changeset
|
19 |
cf3c93b52b9b
Make PARAMS-defining conditionals consistent.
Jim Meyering <jim@meyering.net>
parents:
756
diff
changeset
|
20 #if !defined LINEBUFFER_H |
cf3c93b52b9b
Make PARAMS-defining conditionals consistent.
Jim Meyering <jim@meyering.net>
parents:
756
diff
changeset
|
21 # define LINEBUFFER_H |
cf3c93b52b9b
Make PARAMS-defining conditionals consistent.
Jim Meyering <jim@meyering.net>
parents:
756
diff
changeset
|
22 |
4347
df44e79ce676
.h files should stand alone, but we shouldn't include <sys/types.h>
Paul Eggert <eggert@cs.ucla.edu>
parents:
4169
diff
changeset
|
23 # include <stdio.h> |
df44e79ce676
.h files should stand alone, but we shouldn't include <sys/types.h>
Paul Eggert <eggert@cs.ucla.edu>
parents:
4169
diff
changeset
|
24 |
14 | 25 /* A `struct linebuffer' holds a line of text. */ |
26 | |
27 struct linebuffer | |
28 { | |
1867
8cac4427bbda
[struct linebuffer] (size): Declare to be of type size_t, not long.
Jim Meyering <jim@meyering.net>
parents:
1216
diff
changeset
|
29 size_t size; /* Allocated. */ |
8cac4427bbda
[struct linebuffer] (size): Declare to be of type size_t, not long.
Jim Meyering <jim@meyering.net>
parents:
1216
diff
changeset
|
30 size_t length; /* Used. */ |
14 | 31 char *buffer; |
32 }; | |
33 | |
34 /* Initialize linebuffer LINEBUFFER for use. */ | |
4397
c6450308f123
Assume C89, so PARAMS isn't needed.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4347
diff
changeset
|
35 void initbuffer (struct linebuffer *linebuffer); |
14 | 36 |
37 /* Read an arbitrarily long line of text from STREAM into LINEBUFFER. | |
1867
8cac4427bbda
[struct linebuffer] (size): Declare to be of type size_t, not long.
Jim Meyering <jim@meyering.net>
parents:
1216
diff
changeset
|
38 Keep the newline; append a newline if it's the last line of a file |
8cac4427bbda
[struct linebuffer] (size): Declare to be of type size_t, not long.
Jim Meyering <jim@meyering.net>
parents:
1216
diff
changeset
|
39 that ends in a non-newline character. Do not null terminate. |
14 | 40 Return LINEBUFFER, except at end of file return 0. */ |
4397
c6450308f123
Assume C89, so PARAMS isn't needed.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4347
diff
changeset
|
41 struct linebuffer *readlinebuffer (struct linebuffer *linebuffer, FILE *stream); |
14 | 42 |
43 /* Free linebuffer LINEBUFFER and its data, all allocated with malloc. */ | |
4397
c6450308f123
Assume C89, so PARAMS isn't needed.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4347
diff
changeset
|
44 void freebuffer (struct linebuffer *); |
1216
cf3c93b52b9b
Make PARAMS-defining conditionals consistent.
Jim Meyering <jim@meyering.net>
parents:
756
diff
changeset
|
45 |
cf3c93b52b9b
Make PARAMS-defining conditionals consistent.
Jim Meyering <jim@meyering.net>
parents:
756
diff
changeset
|
46 #endif /* LINEBUFFER_H */ |