2 * Copyright (c) 1996, Index Data.
3 * See the file LICENSE for details.
4 * Sebastian Hammer, Adam Dickmeiss
7 * Revision 1.8 1996-10-29 13:36:27 adam
19 static Z_RPNStructure *ccl_rpn_structure (struct ccl_rpn_node *p);
21 static Z_AttributesPlusTerm *ccl_rpn_term (struct ccl_rpn_node *p)
23 struct ccl_rpn_attr *attr;
25 Z_AttributesPlusTerm *zapt;
29 zapt = xmalloc (sizeof(*zapt));
32 term_octet = xmalloc (sizeof(*term_octet));
35 term = xmalloc(sizeof(*term));
38 for (attr = p->u.t.attr_list; attr; attr = attr->next)
40 zapt->num_attributes = num;
44 zapt->attributeList = xmalloc (num*sizeof(*zapt->attributeList));
45 assert (zapt->attributeList);
46 for (attr = p->u.t.attr_list; attr; attr = attr->next, i++)
48 zapt->attributeList[i] = xmalloc (sizeof(**zapt->attributeList));
49 assert (zapt->attributeList[i]);
50 zapt->attributeList[i]->attributeType =
53 zapt->attributeList[i]->attributeSet = 0;
54 zapt->attributeList[i]->which = Z_AttributeValue_numeric;
55 zapt->attributeList[i]->value.numeric = &attr->value;
57 zapt->attributeList[i]->attributeValue =
63 zapt->attributeList = ODR_NULLVAL;
66 term->which = Z_Term_general;
67 term->u.general = term_octet;
68 term_octet->buf = (unsigned char*) p->u.t.term;
69 term_octet->len = term_octet->size = strlen (p->u.t.term);
73 static Z_Operand *ccl_rpn_simple (struct ccl_rpn_node *p)
77 zo = xmalloc (sizeof(*zo));
83 zo->which = Z_Operand_APT;
84 zo->u.attributesPlusTerm = ccl_rpn_term (p);
87 zo->which = Z_Operand_resultSetId;
88 zo->u.resultSetId = p->u.setname;
96 static Z_Complex *ccl_rpn_complex (struct ccl_rpn_node *p)
101 zc = xmalloc (sizeof(*zc));
103 zo = xmalloc (sizeof(*zo));
110 zo->which = Z_Operator_and;
111 zo->u.and = ODR_NULLVAL;
114 zo->which = Z_Operator_or;
115 zo->u.and = ODR_NULLVAL;
118 zo->which = Z_Operator_and_not;
119 zo->u.and = ODR_NULLVAL;
124 zc->s1 = ccl_rpn_structure (p->u.p[0]);
125 zc->s2 = ccl_rpn_structure (p->u.p[1]);
129 static Z_RPNStructure *ccl_rpn_structure (struct ccl_rpn_node *p)
133 zs = xmalloc (sizeof(*zs));
141 zs->which = Z_RPNStructure_complex;
142 zs->u.complex = ccl_rpn_complex (p);
146 zs->which = Z_RPNStructure_simple;
147 zs->u.simple = ccl_rpn_simple (p);
155 Z_RPNQuery *ccl_rpn_query (struct ccl_rpn_node *p)
159 zq = xmalloc (sizeof(*zq));
161 zq->attributeSetId = NULL;
162 zq->RPNStructure = ccl_rpn_structure (p);
166 Z_AttributesPlusTerm *ccl_scan_query (struct ccl_rpn_node *p)
168 if (p->kind != CCL_RPN_TERM)
170 return ccl_rpn_term (p);