Ranges for ordered qualfiers implemented (e.g. pd=1980-1990).
[egate.git] / ccl / cclsh.c
1 /* CCL shell.
2  * Europagate 1995
3  *
4  * $Log: cclsh.c,v $
5  * Revision 1.4  1995/02/14 14:12:42  adam
6  * Ranges for ordered qualfiers implemented (e.g. pd=1980-1990).
7  *
8  * Revision 1.3  1995/02/14  10:25:57  adam
9  * The constructions 'qualifier rel term ...' implemented.
10  *
11  * Revision 1.2  1995/02/13  15:15:07  adam
12  * Added handling of qualifiers. Not finished yet.
13  *
14  * Revision 1.1  1995/02/13  12:35:21  adam
15  * First version of CCL. Qualifiers aren't handled yet.
16  *
17  */
18
19 #include <stdio.h>
20 #include <stdlib.h>
21 #include <assert.h>
22
23 #include "ccl.h"
24
25 static int debug = 0;
26 static char *prog;
27
28 static int ti_attr[] = {
29     CCL_BIB1_USE, 4,
30     CCL_BIB1_STR, CCL_BIB1_STR_WP
31 };
32
33 static int au_attr[] = {
34     CCL_BIB1_USE, 1,
35     CCL_BIB1_STR, CCL_BIB1_STR_WP
36 };
37
38 static int pd_attr[] = {
39     CCL_BIB1_USE, 31,
40     CCL_BIB1_REL, CCL_BIB1_REL_ORDER
41 };
42
43 int main (int argc, char **argv)
44 {
45     CCL_bibset bibset;
46
47     prog = *argv;
48     bibset = ccl_qual_mk ();    
49     while (--argc > 0)
50     {
51         ++argv;
52         if (**++argv == '-')
53         {
54             switch (argv[0][1])
55             {
56             case 'd':
57                 debug = 1;
58                 break;
59             default:
60                 fprintf (stderr, "%s: unknown option '%s'\n",
61                     prog, *argv);
62                 exit (1);
63             }
64         }
65         else
66         {
67             fprintf (stderr, "%s: no filenames, please\n", prog);
68             exit (1);
69         }
70     }
71     ccl_qual_add (bibset, "ti", sizeof(ti_attr)/(2*sizeof(int)), ti_attr);
72     ccl_qual_add (bibset, "au", sizeof(au_attr)/(2*sizeof(int)), au_attr);
73     ccl_qual_add (bibset, "pd", sizeof(pd_attr)/(2*sizeof(int)), pd_attr);
74     while (1)
75     {
76         char buf[80];
77         int error, pos;
78         struct ccl_rpn_node *rpn;
79
80         printf ("CCLSH>"); fflush (stdout);
81         if (!fgets (buf, 79, stdin))
82             break;
83         rpn = ccl_find_str (bibset, buf, &error, &pos);
84         if (error)
85         {
86             printf ("%*s^ - ", 6+pos, " ");
87             printf ("%s\n", ccl_err_msg (error));
88         }
89         else
90         {
91             assert (rpn);
92             ccl_pr_tree (rpn);
93             putchar ('\n');
94         }
95     }
96     putchar ('\n');
97     return 0;
98 }
99
100