Fix URL of SRU diagnostics list.
[yaz-moved-to-github.git] / src / cqlstring.c
1 /* $Id: cqlstring.c,v 1.5 2005-06-25 15:46:03 adam Exp $
2    Copyright (C) 1995-2005, 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 cqlstring.c
12  * \brief Implements query stream reader that reads from a C string.
13  */
14
15 #include <yaz/cql.h>
16
17 struct cql_buf_info {
18     const char *str;
19     int off;
20 };
21
22 static int getbuf(void *vp)
23 {
24     struct cql_buf_info *bi = (struct cql_buf_info *) vp;
25     if (bi->str[bi->off] == 0)
26         return 0;
27     return bi->str[bi->off++];
28 }
29
30 static void ungetbuf(int b, void *vp)
31 {
32     struct cql_buf_info *bi = (struct cql_buf_info *) vp;
33     if (b)
34         (bi->off--);
35 }
36
37 int cql_parser_string(CQL_parser cp, const char *str)
38 {
39     struct cql_buf_info b;
40
41     b.str = str;
42     b.off = 0;
43     
44     return cql_parser_stream(cp, getbuf, ungetbuf, &b);
45 }
46
47 /*
48  * Local variables:
49  * c-basic-offset: 4
50  * indent-tabs-mode: nil
51  * End:
52  * vim: shiftwidth=4 tabstop=8 expandtab
53  */
54