+ return p_query_scan_attributes_mk(p, o, attributeSetP);
+}
+
+static Z_FacetField* parse_facet(ODR odr, const char *facet)
+{
+ YAZ_PQF_Parser pqf_parser = yaz_pqf_create();
+ Odr_oid *attributeSetId;
+ Z_FacetField *facet_field = 0;
+ Z_AttributeList *attribute_list =
+ yaz_pqf_scan_attribute_list(pqf_parser, odr, &attributeSetId, facet);
+
+ if (attribute_list)
+ {
+ facet_field = (Z_FacetField *) odr_malloc(odr, sizeof(*facet_field));
+ facet_field->attributes = attribute_list;
+ facet_field->num_terms = 0;
+ facet_field->terms = 0;
+ }
+ yaz_pqf_destroy(pqf_parser);
+ return facet_field;
+}
+
+Z_FacetList *yaz_pqf_parse_facet_list(ODR o, const char *qbuf)
+{
+ char **darray;
+ int num;
+
+ nmem_strsplit(odr_getmem(o), ",", qbuf, &darray, &num);
+ if (num > 0)
+ {
+ int i;
+ Z_FacetList *fl = (Z_FacetList*) odr_malloc(o, sizeof(*fl));
+ fl->num = num;
+ fl->elements = (Z_FacetField **)
+ odr_malloc(o, num * sizeof(*fl->elements));
+ for (i = 0; i < num; i++)
+ fl->elements[i] = parse_facet(o, darray[i]);
+ return fl;
+ }
+ else
+ return 0;