1 /* This file is part of the YAZ toolkit.
2 * Copyright (C) 1995-2009 Index Data
3 * See the file LICENSE for details.
10 #include <yaz/ccl_xml.h>
11 #include <yaz/options.h>
13 #if HAVE_READLINE_READLINE_H
14 #include <readline/readline.h>
16 #if HAVE_READLINE_HISTORY_H
17 #include <readline/history.h>
24 void usage(const char *prog)
26 fprintf(stderr, "%s: [-d] [-b configfile] [-x xmlconfig]\n", prog);
30 int main(int argc, char **argv)
44 bibset = ccl_qual_mk();
46 while ((ret = options("db:x:", argv, argc, &arg)) != -2)
55 bib_inf = fopen(bib_fname, "r");
58 fprintf(stderr, "%s: cannot open %s\n", prog,
62 ccl_qual_file(bibset, bib_inf);
67 doc = xmlParseFile(arg);
70 fprintf(stderr, "%s: could not read %s\n", prog, arg);
73 if (ccl_xml_config(bibset, xmlDocGetRootElement(doc), &addinfo))
75 fprintf(stderr, "%s: error in %s: %s\n", prog, arg, addinfo);
83 wrbuf_puts(q_wrbuf, " ");
85 q_wrbuf = wrbuf_alloc();
86 wrbuf_puts(q_wrbuf, arg);
94 CCL_parser cclp = ccl_parser_create(bibset);
96 struct ccl_rpn_node *rpn;
98 rpn = ccl_parser_find_str(cclp, wrbuf_cstr(q_wrbuf));
100 error = ccl_parser_get_error(cclp, 0);
104 printf("%s\n", ccl_err_msg(error));
110 ccl_pr_tree(rpn, stdout);
114 ccl_parser_destroy(cclp);
117 wrbuf_destroy(q_wrbuf);
124 struct ccl_rpn_node *rpn;
126 #if HAVE_READLINE_READLINE_H
128 line_in=readline("CCLSH>");
131 #if HAVE_READLINE_HISTORY_H
133 add_history(line_in);
135 if (strlen(line_in) > 999) {
136 fprintf(stderr,"Input line to long\n");
142 printf("CCLSH>"); fflush(stdout);
143 if (!fgets(buf, 999, stdin))
147 for (i = 0; i<1; i++)
149 CCL_parser cclp = ccl_parser_create(bibset);
152 rpn = ccl_parser_find_str(cclp, buf);
154 error = ccl_parser_get_error(cclp, &pos);
158 printf("%*s^ - ", 6+pos, " ");
159 printf("%s\n", ccl_err_msg(error));
165 ccl_stop_words_t csw = ccl_stop_words_create();
168 ccl_pr_tree(rpn, stdout);
169 if (ccl_stop_words_tree(csw, bibset, &rpn))
172 ccl_pr_tree(rpn, stdout);
175 for (idx = 0; ; idx++)
179 if (!ccl_stop_words_info(csw, idx,
182 printf("Removed from %s: %s\n",
183 qname ? qname : "none", term);
186 ccl_stop_words_destroy(csw);
189 ccl_parser_destroy(cclp);
195 ccl_qual_rm(&bibset);
201 * indent-tabs-mode: nil
203 * vim: shiftwidth=4 tabstop=8 expandtab