+Z_RPNQuery *p_query_rpn (ODR o, oid_proto proto,
+ const char *qbuf)
+{
+ struct lex_info li;
+
+ li.left_sep = "{\"";
+ li.right_sep = "}\"";
+ li.escape_char = '@';
+ li.term_type = Z_Term_general;
+ li.query_buf = qbuf;
+ return p_query_rpn_mk (o, &li, proto, qbuf);
+}
+
+Z_AttributesPlusTerm *p_query_scan_mk (struct lex_info *li,
+ ODR o, oid_proto proto,
+ Odr_oid **attributeSetP,
+ const char *qbuf)
+{
+ int attr_list[1024];
+ oid_value attr_set[512];
+ int num_attr = 0;
+ int max_attr = 512;
+ const char *cp;
+ oid_value topSet = VAL_NONE;
+ oident oset;
+ int oid[OID_SIZE];
+
+ lex (li);
+ if (li->query_look == 'r')
+ {
+ lex (li);
+ topSet = query_oid_getvalbyname (li);
+
+ lex (li);
+ }
+ if (topSet == VAL_NONE)
+ topSet = p_query_dfset;
+ if (topSet == VAL_NONE)
+ topSet = VAL_BIB1;
+ oset.proto = proto;
+ oset.oclass = CLASS_ATTSET;
+ oset.value = topSet;
+
+ *attributeSetP = odr_oiddup (o, oid_ent_to_oid (&oset, oid));
+
+ while (li->query_look == 'l')
+ {
+ lex (li);
+ if (!li->query_look)
+ return NULL;
+ if (num_attr >= max_attr)
+ return NULL;
+
+ if (!(cp = strchr (li->lex_buf, '=')) ||
+ (size_t) (cp-li->lex_buf) > li->lex_len)
+ {
+ attr_set[num_attr] = query_oid_getvalbyname (li);
+ lex (li);
+
+ if (!(cp = strchr (li->lex_buf, '=')))
+ return NULL;
+ }
+ else
+ {
+ if (num_attr > 0)
+ attr_set[num_attr] = attr_set[num_attr-1];
+ else
+ attr_set[num_attr] = VAL_NONE;
+ }
+ attr_list[2*num_attr] = atoi (li->lex_buf);
+ attr_list[2*num_attr+1] = atoi (cp+1);
+ num_attr++;
+ lex (li);
+ }
+ if (!li->query_look)
+ return NULL;
+ return rpn_term (li, o, proto, num_attr, attr_list, attr_set);
+}
+
+Z_AttributesPlusTerm *p_query_scan (ODR o, oid_proto proto,
+ Odr_oid **attributeSetP,
+ const char *qbuf)
+{
+ struct lex_info li;
+
+ li.left_sep = "{\"";
+ li.right_sep = "}\"";
+ li.escape_char = '@';
+ li.term_type = Z_Term_general;
+ li.query_buf = qbuf;
+
+ return p_query_scan_mk (&li, o, proto, attributeSetP, qbuf);
+}
+
+int p_query_attset (const char *arg)
+{
+ p_query_dfset = oid_getvalbyname (arg);
+ return (p_query_dfset == VAL_NONE) ? -1 : 0;
+}
+