2 * Copyright (c) 1995, Index Data
3 * See the file LICENSE for details.
4 * Sebastian Hammer, Adam Dickmeiss
7 * Revision 1.3 1996-01-02 11:46:56 quinn
8 * Changed 'operator' to 'roperator' to avoid C++ conflict.
10 * Revision 1.2 1995/05/16 08:51:14 quinn
11 * License, documentation, and memory fixes
13 * Revision 1.1 1995/04/10 10:28:47 quinn
14 * Added copy of CCL and MARC display
26 static Z_Complex *makecomplex(ODR o, char **buf);
27 static Z_Operand *makesimple(ODR o, char **buf);
28 Z_RPNStructure *makerpn(ODR o, char **buf);
30 void skip_spaces(char**p)
32 while (**p && isspace(**p))
36 static Z_Operand *makesimple(ODR o, char **buf)
39 Z_AttributesPlusTerm *t;
42 r = odr_malloc(o, sizeof(*r));
43 if (**buf == 's' && *((*buf) + 1) == '=')
45 char *b = odr_malloc(o, 100);
47 r->which = Z_Operand_resultSetId;
51 while (**buf && !isspace(**buf))
56 else if (**buf != '"')
59 r->which = Z_Operand_APT;
60 r->u.attributesPlusTerm = t = odr_malloc(o, sizeof(*t));
61 t->num_attributes = 0;
63 t->term = odr_malloc(o, sizeof(*t->term));
64 t->term->which = Z_Term_general;
65 t->term->u.general = odr_malloc(o, sizeof(Odr_oct));
66 t->term->u.general->buf = odr_malloc(o, 100);
67 t->term->u.general->size = 100;
68 t->term->u.general->len = 0;
69 b = (char*) t->term->u.general->buf;
70 while (**buf && **buf != '"')
73 t->term->u.general->len++;
81 static Z_Complex *makecomplex(ODR o, char **buf)
86 r = odr_malloc(o, sizeof(*r));
87 r->roperator = odr_malloc(o, sizeof(*r->roperator));
90 while (**buf && !isspace(**buf))
93 if (!strcmp(op, "and"))
94 r->roperator->which = Z_Operator_and;
95 else if (!strcmp(op, "or"))
96 r->roperator->which = Z_Operator_or;
97 else if (!strcmp(op, "not"))
98 r->roperator->which = Z_Operator_and_not;
99 r->roperator->u.and = "";
100 while (**buf && !isspace(**buf))
102 if (!(r->s1 = makerpn(o, buf)))
104 if (!(r->s2 = makerpn(o, buf)))
109 Z_RPNStructure *makerpn(ODR o, char **buf)
113 r = odr_malloc(o, sizeof(*r));
115 if (**buf == '"' || **buf == 's')
117 r->which = Z_RPNStructure_simple;
118 if (!(r->u.simple = makesimple(o, buf)))
122 r->which = Z_RPNStructure_complex;
123 if (!(r->u.complex = makecomplex(o, buf)))