Fix local attribute setting for pquery.
[yaz-moved-to-github.git] / zutil / pquery.c
index f507ac7..08cec42 100644 (file)
@@ -3,7 +3,17 @@
  * See the file LICENSE for details.
  *
  * $Log: pquery.c,v $
- * Revision 1.7  2001-05-09 23:31:35  adam
+ * Revision 1.10  2001-10-28 23:10:03  adam
+ * Fix local attribute setting for pquery.
+ *
+ * Revision 1.9  2001/09/24 21:51:56  adam
+ * New Z39.50 OID utilities: yaz_oidval_to_z3950oid, yaz_str_to_z3950oid
+ * and yaz_z3950oid_to_str.
+ *
+ * Revision 1.8  2001/07/19 19:14:53  adam
+ * C++ compile.
+ *
+ * Revision 1.7  2001/05/09 23:31:35  adam
  * String attribute values for PQF. Proper C-backslash escaping for PQF.
  *
  * Revision 1.6  2001/03/07 13:24:40  adam
@@ -301,7 +311,7 @@ static int p_query_parse_attr(struct lex_info *li, ODR o,
     {
        int len = li->lex_len - (cp - li->lex_buf);
        attr_list[2*num_attr+1] = 0;
-       attr_clist[num_attr] = odr_malloc (o, len+1);
+       attr_clist[num_attr] = (char *) odr_malloc (o, len+1);
        len = escape_string(attr_clist[num_attr], cp, len);
        attr_clist[num_attr][len] = '\0';
     }
@@ -345,20 +355,8 @@ static Z_AttributesPlusTerm *rpn_term (struct lex_info *li, ODR o,
             elements[k] =
                 (Z_AttributeElement*)odr_malloc (o,sizeof(**elements));
             elements[k]->attributeType = &attr_tmp[2*i];
-            if (attr_set[i] == VAL_NONE)
-                elements[k]->attributeSet = 0;
-            else
-            {
-                oident attrid;
-                int oid[OID_SIZE];
-               
-                attrid.proto = PROTO_Z3950;
-                attrid.oclass = CLASS_ATTSET;
-                attrid.value = attr_set[i];
-                   
-                elements[k]->attributeSet =
-                   odr_oiddup (o, oid_ent_to_oid (&attrid, oid));
-            }
+           elements[k]->attributeSet =
+               yaz_oidval_to_z3950oid(o, CLASS_ATTSET, attr_set[i]);
            if (attr_clist[i])
            {
                elements[k]->which = Z_AttributeValue_complex;
@@ -403,7 +401,7 @@ static Z_AttributesPlusTerm *rpn_term (struct lex_info *li, ODR o,
     term->u.general = term_octet;
     term_octet->buf = (unsigned char *)odr_malloc (o, li->lex_len);
     term_octet->size = term_octet->len =
-       escape_string (term_octet->buf, li->lex_buf, li->lex_len);
+       escape_string ((char *) (term_octet->buf), li->lex_buf, li->lex_len);
     return zapt;
 }
 
@@ -618,8 +616,6 @@ Z_RPNQuery *p_query_rpn_mk (ODR o, struct lex_info *li, oid_proto proto,
     char *attr_clist[512];
     oid_value attr_set[512];
     oid_value topSet = VAL_NONE;
-    oident oset;
-    int oid[OID_SIZE];
 
     zq = (Z_RPNQuery *)odr_malloc (o, sizeof(*zq));
     lex (li);
@@ -636,13 +632,11 @@ Z_RPNQuery *p_query_rpn_mk (ODR o, struct lex_info *li, oid_proto proto,
         topSet = p_query_dfset;
     if (topSet == VAL_NONE)
         topSet = VAL_BIB1;
-    oset.proto = proto;
-    oset.oclass = CLASS_ATTSET;
-    oset.value = topSet;
 
-    if (!oid_ent_to_oid (&oset, oid))
-       return NULL;
-    zq->attributeSetId = odr_oiddup (o, oid);
+    zq->attributeSetId = yaz_oidval_to_z3950oid(o, CLASS_ATTSET, topSet);
+
+    if (!zq->attributeSetId)
+       return 0;
 
     if (!(zq->RPNStructure = rpn_structure (li, o, proto, 0, 512,
                                             attr_array, attr_clist, attr_set)))
@@ -675,8 +669,6 @@ Z_AttributesPlusTerm *p_query_scan_mk (struct lex_info *li,
     int num_attr = 0;
     int max_attr = 512;
     oid_value topSet = VAL_NONE;
-    oident oset;
-    int oid[OID_SIZE];
 
     lex (li);
     if (li->query_look == 'r')
@@ -690,11 +682,8 @@ Z_AttributesPlusTerm *p_query_scan_mk (struct lex_info *li,
         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));
+    *attributeSetP = yaz_oidval_to_z3950oid (o, CLASS_ATTSET, topSet);
 
     while (li->query_look == 'l')
     {