X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=ztest%2Fztest.c;h=f27cb92f4bf44ff4debf2f38fb87c4dc52286769;hb=22a1022ca71a2b44b0f2e03dcf782be16375e0c1;hp=c786d8929e25c6fad20fbca0581d751243f33c73;hpb=79e871ca9f4d35a123a8a0dddb60b4a8c8b62dbd;p=yaz-moved-to-github.git diff --git a/ztest/ztest.c b/ztest/ztest.c index c786d89..f27cb92 100644 --- a/ztest/ztest.c +++ b/ztest/ztest.c @@ -2,10 +2,13 @@ * Copyright (C) 1995-2010 Index Data * See the file LICENSE for details. */ - /** \file * \brief yaz-ztest Generic Frontend Server */ +#if HAVE_CONFIG_H +#include +#endif + #include #include @@ -210,8 +213,8 @@ static void ztest_sleep(double d) Sleep( (DWORD) (d * 1000)); #else struct timeval tv; - tv.tv_sec = floor(d); - tv.tv_usec = (d - floor(d)) * 1000000; + tv.tv_sec = d; + tv.tv_usec = (d - (long) d) * 1000000; select(0, 0, 0, 0, &tv); #endif } @@ -232,7 +235,7 @@ static void addterms(ODR odr, Z_FacetField *facet_field, const char *facet_name) int index; int freq = 100; int length = strlen(facet_name) + 10; - char key[length]; + char *key = odr_malloc(odr, length); key[0] = '\0'; for (index = 0; index < facet_field->num_terms; index++) { Z_Term *term; @@ -252,9 +255,10 @@ Z_OtherInformation *build_facet_response(ODR odr, Z_FacetList *facet_list) { for (index = 0; index < facet_list->num; index++) { struct yaz_facet_attr attrvalues; - facet_struct_init(&attrvalues); - attrvalues.limit = 10; - facetattrs(facet_list->elements[index]->attributes, &attrvalues); + yaz_facet_attr_init(&attrvalues); + attrvalues.limit = 0; + yaz_facet_attr_get_z_attributes(facet_list->elements[index]->attributes, + &attrvalues); yaz_log(YLOG_LOG, "Attributes: %s %d ", attrvalues.useattr, attrvalues.limit); if (attrvalues.errstring) yaz_log(YLOG_LOG, "Error parsing attributes: %s", attrvalues.errstring); @@ -395,9 +399,7 @@ int ztest_search(void *handle, bend_search_rr *rr) if (1) { - /* TODO Not general. Only handles one (Facet) OtherInformation. Overwrite */ - Z_FacetList *facet_list = extract_facet_request(rr->stream, rr->search_input); - + Z_FacetList *facet_list = yaz_oi_get_facetlist(&rr->search_input); if (facet_list) { yaz_log(YLOG_LOG, "%d Facets in search request.", facet_list->num); rr->search_info = build_facet_response(rr->stream, facet_list);