CCL combo qualifier should allow forward references YAZ-779
[yaz-moved-to-github.git] / src / cqlstdio.c
1 /* This file is part of the YAZ toolkit.
2  * Copyright (C) Index Data
3  * See the file LICENSE for details.
4  */
5 /**
6  * \file cqlstdio.c
7  * \brief Implements query stream reading using FILE handle.
8  */
9 #if HAVE_CONFIG_H
10 #include <config.h>
11 #endif
12
13 #include <yaz/cql.h>
14
15 static int getbyte_stream(void *client_data)
16 {
17     FILE *f = (FILE*) client_data;
18
19     int c = fgetc(f);
20     if (c == EOF)
21         return 0;
22     return c;
23 }
24
25 static void ungetbyte_stream(int c, void *client_data)
26 {
27     FILE *f = (FILE*) client_data;
28
29     if (c == 0)
30         c = EOF;
31     ungetc(c, f);
32 }
33
34 int cql_parser_stdio(CQL_parser cp, FILE *f)
35 {
36     return cql_parser_stream(cp, getbyte_stream, ungetbyte_stream, f);
37 }
38
39
40 /*
41  * Local variables:
42  * c-basic-offset: 4
43  * c-file-style: "Stroustrup"
44  * indent-tabs-mode: nil
45  * End:
46  * vim: shiftwidth=4 tabstop=8 expandtab
47  */
48