From aab0b586a68a6d8df06b045d8043b434c0234bea Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Fri, 21 Mar 2014 11:38:12 +0100 Subject: [PATCH] yaz_use_attribute_create based on get_attributeList DRY --- src/pquery.c | 13 +++++++++++++ src/srwutil.c | 34 ---------------------------------- 2 files changed, 13 insertions(+), 34 deletions(-) diff --git a/src/pquery.c b/src/pquery.c index 002d9eb..3fdabe9 100644 --- a/src/pquery.c +++ b/src/pquery.c @@ -307,6 +307,19 @@ static Z_AttributeList *get_attributeList(ODR o, return attributes; } +Z_AttributeList *yaz_use_attribute_create(ODR o, const char *name) +{ + Odr_int attr_list[2]; + const 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)); diff --git a/src/srwutil.c b/src/srwutil.c index 493a7a3..81e1010 100644 --- a/src/srwutil.c +++ b/src/srwutil.c @@ -39,40 +39,6 @@ char *yaz_encode_sru_dbpath_odr(ODR out, const char *db) return dst; } -Z_AttributeElement *yaz_string_element_create(ODR o, int type, - const char *value) -{ - Z_AttributeElement *element = (Z_AttributeElement*) - odr_malloc(o, sizeof(*element)); - element->attributeType = odr_intdup(o, type); - element->attributeSet = 0; - element->which = Z_AttributeValue_complex; - element->value.complex = (Z_ComplexAttribute *) - odr_malloc(o, sizeof(Z_ComplexAttribute)); - element->value.complex->num_list = 1; - element->value.complex->list = (Z_StringOrNumeric **) - odr_malloc(o, 1 * sizeof(Z_StringOrNumeric *)); - element->value.complex->list[0] = (Z_StringOrNumeric *) - odr_malloc(o, sizeof(Z_StringOrNumeric)); - element->value.complex->list[0]->which = Z_StringOrNumeric_string; - element->value.complex->list[0]->u.string = odr_strdup(o, value); - element->value.complex->semanticAction = 0; - element->value.complex->num_semanticAction = 0; - return element; -} - -Z_AttributeList *yaz_use_attribute_create(ODR o, const char *name) -{ - Z_AttributeList *attributes = (Z_AttributeList *) - odr_malloc(o, sizeof(*attributes)); - - attributes->num_attributes = 1; - attributes->attributes = (Z_AttributeElement**) - odr_malloc(o, sizeof(*attributes->attributes)); - attributes->attributes[0] = yaz_string_element_create(o, 1, name); - return attributes; -} - #if YAZ_HAVE_XML2 const char *yaz_element_attribute_value_get(xmlNodePtr ptr, const char *node_name, -- 1.7.10.4