Fix sample PQF
[yaz-moved-to-github.git] / cql / cqlstdio.c
1 /* $Id: cqlstdio.c,v 1.1 2003-01-06 08:20:27 adam Exp $
2    Copyright (C) 2002-2003
3    Index Data Aps
4
5 This file is part of the YAZ toolkit.
6
7 See the file LICENSE.
8 */
9
10 #include <yaz/cql.h>
11
12 int getbyte_stream(void *client_data)
13 {
14     FILE *f = (FILE*) client_data;
15
16     int c = fgetc(f);
17     if (c == EOF)
18         return 0;
19     return c;
20 }
21
22 void ungetbyte_stream (int c, void *client_data)
23 {
24     FILE *f = (FILE*) client_data;
25
26     if (c == 0)
27         c = EOF;
28     ungetc(c, f);
29 }
30
31 int cql_parser_stdio(CQL_parser cp, FILE *f)
32 {
33     return cql_parser_stream(cp, getbyte_stream, ungetbyte_stream, f);
34 }
35
36