Fixed bug #830: pkg-config support. YAZ installs yaz.pc for Debian
[yaz-moved-to-github.git] / src / cqlstdio.c
1 /* $Id: cqlstdio.c,v 1.5 2007-01-03 08:42:15 adam Exp $
2    Copyright (C) 1995-2007, Index Data ApS
3    Index Data Aps
4
5 This file is part of the YAZ toolkit.
6
7 See the file LICENSE for details.
8 */
9
10 /**
11  * \file cqlstdio.c
12  * \brief Implements query stream reading using FILE handle.
13  */
14
15 #include <yaz/cql.h>
16
17 int getbyte_stream(void *client_data)
18 {
19     FILE *f = (FILE*) client_data;
20
21     int c = fgetc(f);
22     if (c == EOF)
23         return 0;
24     return c;
25 }
26
27 void ungetbyte_stream (int c, void *client_data)
28 {
29     FILE *f = (FILE*) client_data;
30
31     if (c == 0)
32         c = EOF;
33     ungetc(c, f);
34 }
35
36 int cql_parser_stdio(CQL_parser cp, FILE *f)
37 {
38     return cql_parser_stream(cp, getbyte_stream, ungetbyte_stream, f);
39 }
40
41
42 /*
43  * Local variables:
44  * c-basic-offset: 4
45  * indent-tabs-mode: nil
46  * End:
47  * vim: shiftwidth=4 tabstop=8 expandtab
48  */
49