2 * Copyright (C) 1994, Index Data I/S
4 * Sebastian Hammer, Adam Dickmeiss
7 * Revision 1.1 1995-04-10 10:28:47 quinn
8 * Added copy of CCL and MARC display
20 static Z_Complex *makecomplex(ODR o, char **buf);
21 static Z_Operand *makesimple(ODR o, char **buf);
22 Z_RPNStructure *makerpn(ODR o, char **buf);
24 void skip_spaces(char**p)
26 while (**p && isspace(**p))
30 static Z_Operand *makesimple(ODR o, char **buf)
33 Z_AttributesPlusTerm *t;
36 r = odr_malloc(o, sizeof(*r));
37 if (**buf == 's' && *((*buf) + 1) == '=')
39 char *b = odr_malloc(o, 100);
41 r->which = Z_Operand_resultSetId;
45 while (**buf && !isspace(**buf))
50 else if (**buf != '"')
53 r->which = Z_Operand_APT;
54 r->u.attributesPlusTerm = t = odr_malloc(o, sizeof(*t));
55 t->num_attributes = 0;
57 t->term = odr_malloc(o, sizeof(*t->term));
58 t->term->which = Z_Term_general;
59 t->term->u.general = odr_malloc(o, sizeof(Odr_oct));
60 t->term->u.general->buf = odr_malloc(o, 100);
61 t->term->u.general->size = 100;
62 t->term->u.general->len = 0;
63 b = (char*) t->term->u.general->buf;
64 while (**buf && **buf != '"')
67 t->term->u.general->len++;
75 static Z_Complex *makecomplex(ODR o, char **buf)
80 r = odr_malloc(o, sizeof(*r));
81 r->operator = odr_malloc(o, sizeof(*r->operator));
84 while (**buf && !isspace(**buf))
87 if (!strcmp(op, "and"))
88 r->operator->which = Z_Operator_and;
89 else if (!strcmp(op, "or"))
90 r->operator->which = Z_Operator_or;
91 else if (!strcmp(op, "not"))
92 r->operator->which = Z_Operator_and_not;
93 r->operator->u.and = "";
94 while (**buf && !isspace(**buf))
96 if (!(r->s1 = makerpn(o, buf)))
98 if (!(r->s2 = makerpn(o, buf)))
103 Z_RPNStructure *makerpn(ODR o, char **buf)
107 r = odr_malloc(o, sizeof(*r));
109 if (**buf == '"' || **buf == 's')
111 r->which = Z_RPNStructure_simple;
112 if (!(r->u.simple = makesimple(o, buf)))
116 r->which = Z_RPNStructure_complex;
117 if (!(r->u.complex = makecomplex(o, buf)))