1 /* PSPP - a program for statistical analysis.
2 Copyright (C) 2010, 2011 Free Software Foundation, Inc.
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */
17 #ifndef LIBPSPP_LINE_READER_H
18 #define LIBPSPP_LINE_READER_H 1
22 #include <sys/types.h>
26 Reads a text file in an arbitrary encoding one line at a time, with
27 optional automatic encoding detection.
30 #define LINE_READER_BUFFER_SIZE 4096
34 struct line_reader *line_reader_for_fd (const char *encoding, int fd);
35 struct line_reader *line_reader_for_file (const char *encoding,
36 const char *filename, int flags);
38 int line_reader_close (struct line_reader *);
39 void line_reader_free (struct line_reader *);
41 bool line_reader_read (struct line_reader *, struct string *,
44 int line_reader_fileno (const struct line_reader *);
45 off_t line_reader_tell (const struct line_reader *);
47 bool line_reader_eof (const struct line_reader *);
48 int line_reader_error (const struct line_reader *);
50 const char *line_reader_get_encoding (const struct line_reader *);
52 bool line_reader_is_auto (const struct line_reader *);
54 #endif /* libpspp/line-reader.h */