2 * Copyright (c) 1995, Index Data
3 * See the file LICENSE for details.
4 * Sebastian Hammer, Adam Dickmeiss
7 * Revision 1.2 1995-05-16 08:51:14 quinn
8 * License, documentation, and memory fixes
10 * Revision 1.1 1995/04/10 10:28:47 quinn
11 * Added copy of CCL and MARC display
23 static Z_Complex *makecomplex(ODR o, char **buf);
24 static Z_Operand *makesimple(ODR o, char **buf);
25 Z_RPNStructure *makerpn(ODR o, char **buf);
27 void skip_spaces(char**p)
29 while (**p && isspace(**p))
33 static Z_Operand *makesimple(ODR o, char **buf)
36 Z_AttributesPlusTerm *t;
39 r = odr_malloc(o, sizeof(*r));
40 if (**buf == 's' && *((*buf) + 1) == '=')
42 char *b = odr_malloc(o, 100);
44 r->which = Z_Operand_resultSetId;
48 while (**buf && !isspace(**buf))
53 else if (**buf != '"')
56 r->which = Z_Operand_APT;
57 r->u.attributesPlusTerm = t = odr_malloc(o, sizeof(*t));
58 t->num_attributes = 0;
60 t->term = odr_malloc(o, sizeof(*t->term));
61 t->term->which = Z_Term_general;
62 t->term->u.general = odr_malloc(o, sizeof(Odr_oct));
63 t->term->u.general->buf = odr_malloc(o, 100);
64 t->term->u.general->size = 100;
65 t->term->u.general->len = 0;
66 b = (char*) t->term->u.general->buf;
67 while (**buf && **buf != '"')
70 t->term->u.general->len++;
78 static Z_Complex *makecomplex(ODR o, char **buf)
83 r = odr_malloc(o, sizeof(*r));
84 r->operator = odr_malloc(o, sizeof(*r->operator));
87 while (**buf && !isspace(**buf))
90 if (!strcmp(op, "and"))
91 r->operator->which = Z_Operator_and;
92 else if (!strcmp(op, "or"))
93 r->operator->which = Z_Operator_or;
94 else if (!strcmp(op, "not"))
95 r->operator->which = Z_Operator_and_not;
96 r->operator->u.and = "";
97 while (**buf && !isspace(**buf))
99 if (!(r->s1 = makerpn(o, buf)))
101 if (!(r->s2 = makerpn(o, buf)))
106 Z_RPNStructure *makerpn(ODR o, char **buf)
110 r = odr_malloc(o, sizeof(*r));
112 if (**buf == '"' || **buf == 's')
114 r->which = Z_RPNStructure_simple;
115 if (!(r->u.simple = makesimple(o, buf)))
119 r->which = Z_RPNStructure_complex;
120 if (!(r->u.complex = makecomplex(o, buf)))