Source restructure. yaz-marcdump part of installation
[yaz-moved-to-github.git] / src / cqlstring.c
1 /* $Id: cqlstring.c,v 1.1 2003-10-27 12:21:30 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 for details.
8 */
9 #include <yaz/cql.h>
10
11 struct cql_buf_info {
12     const char *str;
13     int off;
14 };
15
16 int getbuf(void *vp)
17 {
18     struct cql_buf_info *bi = (struct cql_buf_info *) vp;
19     if (bi->str[bi->off] == 0)
20         return 0;
21     return bi->str[bi->off++];
22 }
23
24 void ungetbuf(int b, void *vp)
25 {
26     struct cql_buf_info *bi = (struct cql_buf_info *) vp;
27     if (b)
28         (bi->off--);
29 }
30
31 int cql_parser_string(CQL_parser cp, const char *str)
32 {
33     struct cql_buf_info b;
34
35     b.str = str;
36     b.off = 0;
37     
38     return cql_parser_stream(cp, getbuf, ungetbuf, &b);
39 }
40