2 * Copyright (c) 1995, Index Data
3 * See the file LICENSE for details.
4 * Sebastian Hammer, Adam Dickmeiss
7 * Revision 1.1 1999-06-08 10:10:16 adam
8 * New sub directory zutil. Moved YAZ Compiler to be part of YAZ tree.
10 * Revision 1.3 1996/01/02 11:46:56 quinn
11 * Changed 'operator' to 'roperator' to avoid C++ conflict.
13 * Revision 1.2 1995/05/16 08:51:14 quinn
14 * License, documentation, and memory fixes
16 * Revision 1.1 1995/04/10 10:28:47 quinn
17 * Added copy of CCL and MARC display
29 static Z_Complex *makecomplex(ODR o, char **buf);
30 static Z_Operand *makesimple(ODR o, char **buf);
31 Z_RPNStructure *makerpn(ODR o, char **buf);
33 void skip_spaces(char**p)
35 while (**p && isspace(**p))
39 static Z_Operand *makesimple(ODR o, char **buf)
42 Z_AttributesPlusTerm *t;
45 r = odr_malloc(o, sizeof(*r));
46 if (**buf == 's' && *((*buf) + 1) == '=')
48 char *b = odr_malloc(o, 100);
50 r->which = Z_Operand_resultSetId;
54 while (**buf && !isspace(**buf))
59 else if (**buf != '"')
62 r->which = Z_Operand_APT;
63 r->u.attributesPlusTerm = t = odr_malloc(o, sizeof(*t));
64 t->num_attributes = 0;
66 t->term = odr_malloc(o, sizeof(*t->term));
67 t->term->which = Z_Term_general;
68 t->term->u.general = odr_malloc(o, sizeof(Odr_oct));
69 t->term->u.general->buf = odr_malloc(o, 100);
70 t->term->u.general->size = 100;
71 t->term->u.general->len = 0;
72 b = (char*) t->term->u.general->buf;
73 while (**buf && **buf != '"')
76 t->term->u.general->len++;
84 static Z_Complex *makecomplex(ODR o, char **buf)
89 r = odr_malloc(o, sizeof(*r));
90 r->roperator = odr_malloc(o, sizeof(*r->roperator));
93 while (**buf && !isspace(**buf))
96 if (!strcmp(op, "and"))
97 r->roperator->which = Z_Operator_and;
98 else if (!strcmp(op, "or"))
99 r->roperator->which = Z_Operator_or;
100 else if (!strcmp(op, "not"))
101 r->roperator->which = Z_Operator_and_not;
102 r->roperator->u.and = "";
103 while (**buf && !isspace(**buf))
105 if (!(r->s1 = makerpn(o, buf)))
107 if (!(r->s2 = makerpn(o, buf)))
112 Z_RPNStructure *makerpn(ODR o, char **buf)
116 r = odr_malloc(o, sizeof(*r));
118 if (**buf == '"' || **buf == 's')
120 r->which = Z_RPNStructure_simple;
121 if (!(r->u.simple = makesimple(o, buf)))
125 r->which = Z_RPNStructure_complex;
126 if (!(r->u.complex = makecomplex(o, buf)))