8 static Z_RPNStructure *ccl_rpn_structure (struct ccl_rpn_node *p);
10 static Z_AttributesPlusTerm *ccl_rpn_term (struct ccl_rpn_node *p)
12 struct ccl_rpn_attr *attr;
14 Z_AttributesPlusTerm *zapt;
18 zapt = xmalloc (sizeof(*zapt));
21 term_octet = xmalloc (sizeof(*term_octet));
24 term = xmalloc(sizeof(*term));
27 for (attr = p->u.t.attr_list; attr; attr = attr->next)
29 zapt->num_attributes = num;
33 zapt->attributeList = xmalloc (num*sizeof(*zapt->attributeList));
34 assert (zapt->attributeList);
35 for (attr = p->u.t.attr_list; attr; attr = attr->next, i++)
37 zapt->attributeList[i] = xmalloc (sizeof(**zapt->attributeList));
38 assert (zapt->attributeList[i]);
39 zapt->attributeList[i]->attributeType =
42 zapt->attributeList[i]->attributeSet = 0;
43 zapt->attributeList[i]->which = Z_AttributeValue_numeric;
44 zapt->attributeList[i]->value.numeric = &attr->value;
46 zapt->attributeList[i]->attributeValue =
52 zapt->attributeList = ODR_NULLVAL;
55 term->which = Z_Term_general;
56 term->u.general = term_octet;
57 term_octet->buf = (unsigned char*) p->u.t.term;
58 term_octet->len = term_octet->size = strlen (p->u.t.term);
62 static Z_Operand *ccl_rpn_simple (struct ccl_rpn_node *p)
66 zo = xmalloc (sizeof(*zo));
72 zo->which = Z_Operand_APT;
73 zo->u.attributesPlusTerm = ccl_rpn_term (p);
76 zo->which = Z_Operand_resultSetId;
77 zo->u.resultSetId = p->u.setname;
85 static Z_Complex *ccl_rpn_complex (struct ccl_rpn_node *p)
90 zc = xmalloc (sizeof(*zc));
92 zo = xmalloc (sizeof(*zo));
99 zo->which = Z_Operator_and;
100 zo->u.and = ODR_NULLVAL;
103 zo->which = Z_Operator_or;
104 zo->u.and = ODR_NULLVAL;
107 zo->which = Z_Operator_and_not;
108 zo->u.and = ODR_NULLVAL;
113 zc->s1 = ccl_rpn_structure (p->u.p[0]);
114 zc->s2 = ccl_rpn_structure (p->u.p[1]);
118 static Z_RPNStructure *ccl_rpn_structure (struct ccl_rpn_node *p)
122 zs = xmalloc (sizeof(*zs));
130 zs->which = Z_RPNStructure_complex;
131 zs->u.complex = ccl_rpn_complex (p);
135 zs->which = Z_RPNStructure_simple;
136 zs->u.simple = ccl_rpn_simple (p);
144 Z_RPNQuery *ccl_rpn_query (struct ccl_rpn_node *p)
148 zq = xmalloc (sizeof(*zq));
150 zq->attributeSetId = NULL;
151 zq->RPNStructure = ccl_rpn_structure (p);
155 Z_AttributesPlusTerm *ccl_scan_query (struct ccl_rpn_node *p)
157 if (p->kind != CCL_RPN_TERM)
159 return ccl_rpn_term (p);