YAZ 5.35.1
cqlstring.c
Go to the documentation of this file.
1/* This file is part of the YAZ toolkit.
2 * Copyright (C) Index Data
3 * See the file LICENSE for details.
4 */
9#if HAVE_CONFIG_H
10#include <config.h>
11#endif
12
13#include <yaz/cql.h>
14
16 const char *str;
17 int off;
18};
19
20static int getbuf(void *vp)
21{
22 struct cql_buf_info *bi = (struct cql_buf_info *) vp;
23 if (bi->str[bi->off] == 0)
24 return 0;
25 return bi->str[bi->off++];
26}
27
28static void ungetbuf(int b, void *vp)
29{
30 struct cql_buf_info *bi = (struct cql_buf_info *) vp;
31 if (b)
32 (bi->off--);
33}
34
35int cql_parser_string(CQL_parser cp, const char *str)
36{
37 struct cql_buf_info b;
38
39 b.str = str;
40 b.off = 0;
41
42 return cql_parser_stream(cp, getbuf, ungetbuf, &b);
43}
44
45/*
46 * Local variables:
47 * c-basic-offset: 4
48 * c-file-style: "Stroustrup"
49 * indent-tabs-mode: nil
50 * End:
51 * vim: shiftwidth=4 tabstop=8 expandtab
52 */
53
int cql_parser_stream(CQL_parser cp, int(*getbyte)(void *client_data), void(*ungetbyte)(int b, void *client_data), void *client_data)
parses CQL query (query stream)
Definition cql.c:1864
Header with public definitions about CQL.
static int getbuf(void *vp)
Definition cqlstring.c:20
static void ungetbuf(int b, void *vp)
Definition cqlstring.c:28
int cql_parser_string(CQL_parser cp, const char *str)
parses a CQL query (string)
Definition cqlstring.c:35
const char * str
Definition cqlstring.c:16