1 /* inputbuf.h */
2 
3 /*
4     Copyright (C) 2008 Micah Cowan
5 
6     This file is part of GNU teseq.
7 
8     GNU teseq is free software: you can redistribute it and/or modify
9     it under the terms of the GNU General Public License as published by
10     the Free Software Foundation, either version 3 of the License, or
11     (at your option) any later version.
12 
13     GNU teseq is distributed in the hope that it will be useful,
14     but WITHOUT ANY WARRANTY; without even the implied warranty of
15     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16     GNU General Public License for more details.
17 
18     You should have received a copy of the GNU General Public License
19     along with this program.  If not, see <http://www.gnu.org/licenses/>.
20 */
21 
22 /*
23     Input buffer.
24 
25     Fetches characters one at a time from an input stream.  The
26     inputbuf_saving function is used to initiate "look-ahead" mode, to
27     begin saving the characters into a buffer. The inputbuf_rewind
28     function is used to re-read the saved characters; and
29     inputbuf_forget is used to indicate that we are done processing
30     the saved characters, and they should be forgotten.
31 
32     See test-inputbuf.cm for usage.
33 */
34 
35 #ifndef INPUTBUF_H
36 #define INPUTBUF_H
37 
38 #include <stdio.h>
39 
40 struct inputbuf;
41 
42 struct inputbuf *inputbuf_new (FILE *, size_t);
43 void inputbuf_delete (struct inputbuf *);
44 int inputbuf_io_error (struct inputbuf *);
45 
46 int inputbuf_get (struct inputbuf *);
47 int inputbuf_saving (struct inputbuf *);
48 int inputbuf_rewind (struct inputbuf *);
49 int inputbuf_forget (struct inputbuf *);
50 size_t inputbuf_get_count (struct inputbuf *);
51 void inputbuf_reset_count (struct inputbuf *);
52 int inputbuf_avail (struct inputbuf *);
53 
54 #endif
55