2 * Copyright (c) 1995-1999, Index Data
3 * See the file LICENSE for details.
4 * Sebastian Hammer, Adam Dickmeiss
7 * Revision 1.2 1999-06-09 14:01:33 adam
8 * Fixed for compiled ASN.1.
10 * Revision 1.1 1999/06/08 10:10:16 adam
11 * New sub directory zutil. Moved YAZ Compiler to be part of YAZ tree.
13 * Revision 1.3 1996/01/02 11:46:56 quinn
14 * Changed 'operator' to 'roperator' to avoid C++ conflict.
16 * Revision 1.2 1995/05/16 08:51:14 quinn
17 * License, documentation, and memory fixes
19 * Revision 1.1 1995/04/10 10:28:47 quinn
20 * Added copy of CCL and MARC display
32 static Z_Complex *makecomplex(ODR o, char **buf);
33 static Z_Operand *makesimple(ODR o, char **buf);
34 Z_RPNStructure *makerpn(ODR o, char **buf);
36 void skip_spaces(char**p)
38 while (**p && isspace(**p))
42 static Z_Operand *makesimple(ODR o, char **buf)
45 Z_AttributesPlusTerm *t;
48 r = odr_malloc(o, sizeof(*r));
49 if (**buf == 's' && *((*buf) + 1) == '=')
51 char *b = odr_malloc(o, 100);
53 r->which = Z_Operand_resultSetId;
57 while (**buf && !isspace(**buf))
62 else if (**buf != '"')
65 r->which = Z_Operand_APT;
66 r->u.attributesPlusTerm = t = odr_malloc(o, sizeof(*t));
68 t->attributes = odr_malloc(o, sizeof(*t));
69 t->attributes->num_attributes = 0;
70 t->attributes->attributes = 0;
72 t->num_attributes = 0;
75 t->term = odr_malloc(o, sizeof(*t->term));
76 t->term->which = Z_Term_general;
77 t->term->u.general = odr_malloc(o, sizeof(Odr_oct));
78 t->term->u.general->buf = odr_malloc(o, 100);
79 t->term->u.general->size = 100;
80 t->term->u.general->len = 0;
81 b = (char*) t->term->u.general->buf;
82 while (**buf && **buf != '"')
85 t->term->u.general->len++;
93 static Z_Complex *makecomplex(ODR o, char **buf)
98 r = odr_malloc(o, sizeof(*r));
99 r->roperator = odr_malloc(o, sizeof(*r->roperator));
102 while (**buf && !isspace(**buf))
103 *(b++) = *((*buf)++);
105 if (!strcmp(op, "and"))
106 r->roperator->which = Z_Operator_and;
107 else if (!strcmp(op, "or"))
108 r->roperator->which = Z_Operator_or;
109 else if (!strcmp(op, "not"))
110 r->roperator->which = Z_Operator_and_not;
111 r->roperator->u.and = "";
112 while (**buf && !isspace(**buf))
114 if (!(r->s1 = makerpn(o, buf)))
116 if (!(r->s2 = makerpn(o, buf)))
121 Z_RPNStructure *makerpn(ODR o, char **buf)
125 r = odr_malloc(o, sizeof(*r));
127 if (**buf == '"' || **buf == 's')
129 r->which = Z_RPNStructure_simple;
130 if (!(r->u.simple = makesimple(o, buf)))
134 r->which = Z_RPNStructure_complex;
135 if (!(r->u.complex = makecomplex(o, buf)))