From 14507ff5775af3d6453c1d0f856ca20002eaf045 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Wed, 18 Sep 2013 14:44:52 +0200 Subject: [PATCH] Add yaz_facet_list_to_wrbuf YAZ-683 --- include/yaz/querytowrbuf.h | 3 +++ src/querytowrbuf.c | 24 ++++++++++++++++++++---- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/include/yaz/querytowrbuf.h b/include/yaz/querytowrbuf.h index f40daae..def2c59 100644 --- a/include/yaz/querytowrbuf.h +++ b/include/yaz/querytowrbuf.h @@ -45,6 +45,9 @@ YAZ_EXPORT void yaz_rpnquery_to_wrbuf(WRBUF b, const Z_RPNQuery *rpn); YAZ_EXPORT void wrbuf_diags(WRBUF b, int num_diagnostics,Z_DiagRec **diags); YAZ_EXPORT void yaz_encode_pqf_term(WRBUF b, const char *term, int len); + +YAZ_EXPORT void yaz_facet_list_to_wrbuf(WRBUF w, const Z_FacetList *fl); + YAZ_END_CDECL #endif diff --git a/src/querytowrbuf.c b/src/querytowrbuf.c index f36844d..5f8db4d 100644 --- a/src/querytowrbuf.c +++ b/src/querytowrbuf.c @@ -107,13 +107,16 @@ static const char *complex_op_name(const Z_Operator *op) } } -static void yaz_apt_to_wrbuf(WRBUF b, const Z_AttributesPlusTerm *zapt) +static void yaz_attributes_to_wrbuf(WRBUF w, const Z_AttributeList *al) { - int num_attributes = zapt->attributes->num_attributes; int i; - for (i = 0; i < num_attributes; i++) - yaz_attribute_element_to_wrbuf(b,zapt->attributes->attributes[i]); + for (i = 0; i < al->num_attributes; i++) + yaz_attribute_element_to_wrbuf(w, al->attributes[i]); +} +static void yaz_apt_to_wrbuf(WRBUF b, const Z_AttributesPlusTerm *zapt) +{ + yaz_attributes_to_wrbuf(b, zapt->attributes); switch (zapt->term->which) { case Z_Term_general: @@ -266,6 +269,19 @@ void wrbuf_diags(WRBUF b, int num_diagnostics, Z_DiagRec **diags) } } +void yaz_facet_list_to_wrbuf(WRBUF w, const Z_FacetList *fl) +{ + int i; + for (i = 0; i < fl->num; i++) + { + Z_FacetField *ff = fl->elements[i]; + + if (i) + wrbuf_puts(w, ", "); + yaz_attributes_to_wrbuf(w, ff->attributes); + } +} + /* * Local variables: * c-basic-offset: 4 -- 1.7.10.4