X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;ds=sidebyside;f=zutil%2Fyaz-ccl.c;h=4c86dfe130fa01f10537996d23ffad42b898359a;hb=db9768c3988f9536c898250880c13923a2dde32d;hp=661321184d02ff4359bf812146d854d07a98dd7a;hpb=b04a1b2d9a23bea37512d2219e2a3551afffd702;p=yaz-moved-to-github.git diff --git a/zutil/yaz-ccl.c b/zutil/yaz-ccl.c index 6613211..4c86dfe 100644 --- a/zutil/yaz-ccl.c +++ b/zutil/yaz-ccl.c @@ -1,10 +1,35 @@ /* - * Copyright (c) 1996-2000, Index Data. + * Copyright (c) 1996-2001, Index Data. * See the file LICENSE for details. - * Sebastian Hammer, Adam Dickmeiss * * $Log: yaz-ccl.c,v $ - * Revision 1.6 2000-02-02 15:13:23 adam + * Revision 1.14 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.13 2001/05/09 23:31:35 adam + * String attribute values for PQF. Proper C-backslash escaping for PQF. + * + * Revision 1.12 2001/03/07 13:24:40 adam + * Member and_not in Z_Operator is kept for backwards compatibility. + * Added support for definition of CCL operators in field spec file. + * + * Revision 1.11 2001/02/21 13:46:54 adam + * C++ fixes. + * + * Revision 1.10 2001/02/20 11:23:50 adam + * Updated ccl_pquery to consider local attribute set too. + * + * Revision 1.9 2000/11/27 14:16:55 adam + * Fixed bug in ccl_rpn_simple regarding resultSetId's. + * + * Revision 1.8 2000/11/16 13:03:13 adam + * Function ccl_rpn_query sets attributeSet to Bib-1. + * + * Revision 1.7 2000/11/16 09:58:02 adam + * Implemented local AttributeSet setting for CCL field maps. + * + * Revision 1.6 2000/02/02 15:13:23 adam * Minor change. * * Revision 1.5 2000/01/31 13:15:22 adam @@ -85,6 +110,16 @@ static Z_AttributesPlusTerm *ccl_rpn_term (ODR o, struct ccl_rpn_node *p) (int *)odr_malloc(o, sizeof(int)); *elements[i]->attributeType = attr->type; elements[i]->attributeSet = 0; + if (attr->set && *attr->set) + { + int value = oid_getvalbyname (attr->set); + + if (value != VAL_NONE) + { + elements[i]->attributeSet = + yaz_oidval_to_z3950oid(o, CLASS_ATTSET, value); + } + } elements[i]->which = Z_AttributeValue_numeric; elements[i]->value.numeric = (int *)odr_malloc (o, sizeof(int)); @@ -123,7 +158,7 @@ static Z_Operand *ccl_rpn_simple (ODR o, struct ccl_rpn_node *p) break; case CCL_RPN_SET: zo->which = Z_Operand_resultSetId; - zo->u.resultSetId = p->u.setname; + zo->u.resultSetId = odr_strdup (o, p->u.setname); break; default: return 0; @@ -144,15 +179,15 @@ static Z_Complex *ccl_rpn_complex (ODR o, struct ccl_rpn_node *p) { case CCL_RPN_AND: zo->which = Z_Operator_and; - zo->u.and = odr_nullval(); + zo->u.and_not = odr_nullval(); break; case CCL_RPN_OR: zo->which = Z_Operator_or; - zo->u.and = odr_nullval(); + zo->u.and_not = odr_nullval(); break; case CCL_RPN_NOT: zo->which = Z_Operator_and_not; - zo->u.and = odr_nullval(); + zo->u.and_not = odr_nullval(); break; case CCL_RPN_PROX: zo->which = Z_Operator_prox; @@ -174,7 +209,7 @@ static Z_Complex *ccl_rpn_complex (ODR o, struct ccl_rpn_node *p) *zo->u.prox->relationType = Z_ProximityOperator_Prox_lessThan; zo->u.prox->which = Z_ProximityOperator_known; zo->u.prox->u.known = - odr_malloc (o, sizeof(*zo->u.prox->u.known)); + (Z_ProxUnit *) odr_malloc (o, sizeof(*zo->u.prox->u.known)); *zo->u.prox->u.known = Z_ProxUnit_word; #else *zo->u.prox->relationType = Z_Prox_lessThan; @@ -219,10 +254,8 @@ static Z_RPNStructure *ccl_rpn_structure (ODR o, struct ccl_rpn_node *p) Z_RPNQuery *ccl_rpn_query (ODR o, struct ccl_rpn_node *p) { - Z_RPNQuery *zq; - - zq = (Z_RPNQuery *)odr_malloc (o, sizeof(*zq)); - zq->attributeSetId = NULL; + Z_RPNQuery *zq = (Z_RPNQuery *)odr_malloc (o, sizeof(*zq)); + zq->attributeSetId = yaz_oidval_to_z3950oid (o, CLASS_ATTSET, VAL_BIB1); zq->RPNStructure = ccl_rpn_structure (o, p); return zq; } @@ -260,6 +293,7 @@ static void ccl_pquery_complex (WRBUF w, struct ccl_rpn_node *p) void ccl_pquery (WRBUF w, struct ccl_rpn_node *p) { struct ccl_rpn_attr *att; + const char *cp; switch (p->kind) { @@ -278,12 +312,22 @@ void ccl_pquery (WRBUF w, struct ccl_rpn_node *p) for (att = p->u.t.attr_list; att; att = att->next) { char tmpattr[128]; - sprintf(tmpattr, "@attr %d=%d ", att->type, att->value); + wrbuf_puts (w, "@attr "); + if (att->set) + { + wrbuf_puts (w, att->set); + wrbuf_puts (w, " "); + } + sprintf(tmpattr, "%d=%d ", att->type, att->value); wrbuf_puts (w, tmpattr); } - wrbuf_puts (w, "{"); - wrbuf_puts (w, p->u.t.term); - wrbuf_puts (w, "} "); + for (cp = p->u.t.term; *cp; cp++) + { + if (*cp == ' ' || *cp == '\\') + wrbuf_putc (w, '\\'); + wrbuf_putc (w, *cp); + } + wrbuf_puts (w, " "); break; } }