X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=src%2Fpquery.c;h=f913a0f135409c1c3451a3c2d19458b885519eb7;hp=f2c39e87b75df42f8e83df1aec33bca16d8263de;hb=01e36a11adc97a240cc595f89280c8a619770251;hpb=69b1d8e7b437179163fe97b7cbead51a56835f2a diff --git a/src/pquery.c b/src/pquery.c index f2c39e8..f913a0f 100644 --- a/src/pquery.c +++ b/src/pquery.c @@ -1,5 +1,5 @@ /* This file is part of the YAZ toolkit. - * Copyright (C) 1995-2013 Index Data + * Copyright (C) Index Data * See the file LICENSE for details. */ /** @@ -307,32 +307,35 @@ static Z_AttributeList *get_attributeList(ODR o, return attributes; } +Z_AttributeList *zget_AttributeList_use_string(ODR o, const char *name) +{ + Odr_int attr_list[2]; + char *attr_clist[1]; + Odr_oid *attr_set[1]; + + attr_list[0] = 1; + attr_list[1] = 0; /* not used */ + attr_clist[0] = odr_strdup(o, name); + attr_set[0] = 0; + return get_attributeList(o, 1, attr_list, attr_clist, attr_set); +} + Z_Term *z_Term_create(ODR o, int term_type, const char *buf, size_t len) { Z_Term *term = (Z_Term *)odr_malloc(o, sizeof(*term)); - Odr_oct *term_octet = (Odr_oct *)odr_malloc(o, sizeof(*term_octet)); - term_octet->buf = (char *)odr_malloc(o, 1 + len); - memcpy(term_octet->buf, buf, len); - term_octet->len = len; -#if OCT_SIZE - term_octet->size = len; -#endif - term_octet->buf[term_octet->len] = 0; /* null terminate */ - switch (term_type) { case Z_Term_general: term->which = Z_Term_general; - term->u.general = term_octet; + term->u.general = odr_create_Odr_oct(o, buf, len); break; case Z_Term_characterString: term->which = Z_Term_characterString; - term->u.characterString = (char*) term_octet->buf; - /* null terminated above */ + term->u.characterString = odr_strdupn(o, buf, len); break; case Z_Term_numeric: term->which = Z_Term_numeric; - term->u.numeric = odr_intdup(o, odr_atoi((const char*) term_octet->buf)); + term->u.numeric = odr_intdup(o, odr_atoi(odr_strdupn(o, buf, len))); break; case Z_Term_null: term->which = Z_Term_null; @@ -396,9 +399,7 @@ static Z_Operand *rpn_simple(struct yaz_pqf_parser *li, ODR o, return 0; } zo->which = Z_Operand_resultSetId; - zo->u.resultSetId = (char *)odr_malloc(o, li->lex_len+1); - memcpy(zo->u.resultSetId, li->lex_buf, li->lex_len); - zo->u.resultSetId[li->lex_len] = '\0'; + zo->u.resultSetId = odr_strdupn(o, li->lex_buf, li->lex_len); lex(li); break; default: @@ -844,7 +845,7 @@ static Z_FacetField* parse_facet(ODR odr, const char *facet) { YAZ_PQF_Parser pqf_parser = yaz_pqf_create(); struct yaz_pqf_parser *li = pqf_parser; - Odr_oid *attributeSetId; + Odr_oid *attributeSetId = 0; Z_FacetField *facet_field = 0; Z_AttributeList *attribute_list;