1 /* This file is part of the YAZ toolkit.
2 * Copyright (C) 1995-2012 Index Data
3 * See the file LICENSE for details.
13 #include <yaz/ccl_xml.h>
14 #include <yaz/options.h>
16 #if HAVE_READLINE_READLINE_H
17 #include <readline/readline.h>
19 #if HAVE_READLINE_HISTORY_H
20 #include <readline/history.h>
27 void usage(const char *prog)
29 fprintf(stderr, "%s: [-d] [-b configfile] [-x xmlconfig]\n", prog);
33 int main(int argc, char **argv)
47 bibset = ccl_qual_mk();
49 while ((ret = options("db:x:", argv, argc, &arg)) != -2)
58 bib_inf = fopen(bib_fname, "r");
61 fprintf(stderr, "%s: cannot open %s\n", prog,
65 ccl_qual_file(bibset, bib_inf);
70 doc = xmlParseFile(arg);
73 fprintf(stderr, "%s: could not read %s\n", prog, arg);
76 if (ccl_xml_config(bibset, xmlDocGetRootElement(doc), &addinfo))
78 fprintf(stderr, "%s: error in %s: %s\n", prog, arg, addinfo);
86 wrbuf_puts(q_wrbuf, " ");
88 q_wrbuf = wrbuf_alloc();
89 wrbuf_puts(q_wrbuf, arg);
97 CCL_parser cclp = ccl_parser_create(bibset);
99 struct ccl_rpn_node *rpn;
101 rpn = ccl_parser_find_str(cclp, wrbuf_cstr(q_wrbuf));
103 error = ccl_parser_get_error(cclp, 0);
107 printf("%s\n", ccl_err_msg(error));
113 ccl_pr_tree(rpn, stdout);
117 ccl_parser_destroy(cclp);
120 wrbuf_destroy(q_wrbuf);
127 struct ccl_rpn_node *rpn;
129 #if HAVE_READLINE_READLINE_H
131 line_in=readline("CCLSH>");
134 #if HAVE_READLINE_HISTORY_H
136 add_history(line_in);
138 if (strlen(line_in) > 999) {
139 fprintf(stderr,"Input line to long\n");
145 printf("CCLSH>"); fflush(stdout);
146 if (!fgets(buf, 999, stdin))
150 for (i = 0; i<1; i++)
152 CCL_parser cclp = ccl_parser_create(bibset);
155 rpn = ccl_parser_find_str(cclp, buf);
157 error = ccl_parser_get_error(cclp, &pos);
161 printf("%*s^ - ", 6+pos, " ");
162 printf("%s\n", ccl_err_msg(error));
168 ccl_stop_words_t csw = ccl_stop_words_create();
171 ccl_pr_tree(rpn, stdout);
172 if (ccl_stop_words_tree(csw, bibset, &rpn))
175 ccl_pr_tree(rpn, stdout);
178 for (idx = 0; ; idx++)
182 if (!ccl_stop_words_info(csw, idx,
185 printf("Removed from %s: %s\n",
186 qname ? qname : "none", term);
189 ccl_stop_words_destroy(csw);
192 ccl_parser_destroy(cclp);
198 ccl_qual_rm(&bibset);
204 * c-file-style: "Stroustrup"
205 * indent-tabs-mode: nil
207 * vim: shiftwidth=4 tabstop=8 expandtab