- case Z_RPNStructure_complex: {
- SV *tmp;
- Z_Complex *c = s->u.complex;
- char *type = 0; /* vacuous assignment satisfies gcc -Wall */
- switch (c->roperator->which) {
- case Z_Operator_and: type = "Net::Z3950::RPN::And"; break;
- case Z_Operator_or: type = "Net::Z3950::RPN::Or"; break;
- case Z_Operator_and_not: type = "Net::Z3950::RPN::AndNot"; break;
- case Z_Operator_prox: fatal("proximity not yet supported");
- default: fatal("unknown RPN operator %d", (int) c->roperator->which);
- }
- sv = newObject(type, (SV*) (av = newAV()));
- if ((tmp = rpn2perl(c->s1)) == 0)
- return 0;
- av_push(av, tmp);
- if ((tmp = rpn2perl(c->s2)) == 0)
- return 0;
- av_push(av, tmp);
- return sv;
+
+ return 1;
+}
+
+
+/* Decode the Z_SortKeySpec struct and store the whole thing in a perl hash */
+int simpleserver_SortKeySpecToHash (HV *sort_spec, Z_SortKeySpec *spec)
+{
+ Z_SortElement *element = spec->sortElement;
+
+ hv_store(sort_spec, "RELATION", 8, newSViv(*spec->sortRelation), 0);
+ hv_store(sort_spec, "CASE", 4, newSViv(*spec->caseSensitivity), 0);
+ hv_store(sort_spec, "MISSING", 7, newSViv(spec->which), 0);
+
+ if (element->which == Z_SortElement_generic)
+ {
+ Z_SortKey *key = element->u.generic;
+
+ if (key->which == Z_SortKey_sortField)
+ {
+ hv_store(sort_spec, "SORTFIELD", 9,
+ newSVpv((char *) key->u.sortField, 0), 0);
+ }
+ else if (key->which == Z_SortKey_elementSpec)
+ {
+ Z_Specification *zspec = key->u.elementSpec;
+
+ hv_store(sort_spec, "ELEMENTSPEC_TYPE", 16,
+ newSViv(zspec->which), 0);
+
+ if (zspec->which == Z_Schema_oid)
+ {
+ WRBUF elementSpec = wrbuf_alloc();
+
+ oid2str(zspec->schema.oid, elementSpec);
+ hv_store(sort_spec, "ELEMENTSPEC_VALUE", 17,
+ newSVpv(elementSpec->buf, elementSpec->pos), 0);
+ wrbuf_destroy(elementSpec);
+ }
+ else if (zspec->which == Z_Schema_uri)
+ {
+ hv_store(sort_spec, "ELEMENTSPEC_VALUE", 17,
+ newSVpv((char *) zspec->schema.uri, 0), 0);
+ }
+ }
+ else if (key->which == Z_SortKey_sortAttributes)
+ {
+ return simpleserver_ExpandSortAttributes(sort_spec,
+ key->u.sortAttributes);
+ }
+ else
+ {
+ return 0;
+ }