X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=ztest%2Fztest.c;h=8011e0f8d24aeae9875ea62d6d855a651b00b244;hp=170fba5e6c754b434d9239d75ff4ad08f3ad338e;hb=c82f99e98f3b27c06d68eac02871a9b92486a89d;hpb=1ccca650a133358c268ab3d0f9da58c621a663dc diff --git a/ztest/ztest.c b/ztest/ztest.c index 170fba5..8011e0f 100644 --- a/ztest/ztest.c +++ b/ztest/ztest.c @@ -38,9 +38,9 @@ int ztest_delete(void *handle, bend_delete_rr *rr); Only terms that looks a numeric is used.. Returns -1 if no sub tree has a hit count term */ -static int get_term_hit(Z_RPNStructure *s) +static Odr_int get_term_hit(Z_RPNStructure *s) { - int h = -1; + Odr_int h = -1; switch(s->which) { case Z_RPNStructure_simple: @@ -51,7 +51,17 @@ static int get_term_hit(Z_RPNStructure *s) { Odr_oct *oct = apt->term->u.general; if (oct->len > 0 && oct->buf[0] >= '0' && oct->buf[0] <= '9') - h = atoi_n((const char *) oct->buf, oct->len); + { + char *endptr; + WRBUF hits_str = wrbuf_alloc(); + wrbuf_write(hits_str, (const char *) oct->buf, oct->len); +#ifdef WIN32 + h = _strtoui64(wrbuf_cstr(hits_str), &endptr, 10); +#else + h = strtoll(wrbuf_cstr(hits_str), &endptr, 10); +#endif + wrbuf_destroy(hits_str); + } } } break; @@ -73,9 +83,9 @@ static int get_term_hit(Z_RPNStructure *s) have a way to trigger a certain hit count. Good for testing of client applications etc */ -static int get_hit_count(Z_Query *q) +static Odr_int get_hit_count(Z_Query *q) { - int h = -1; + Odr_int h = -1; if (q->which == Z_Query_type_1 || q->which == Z_Query_type_101) h = get_term_hit(q->u.type_1->RPNStructure); if (h == -1) @@ -137,6 +147,29 @@ int ztest_search(void *handle, bend_search_rr *rr) return 0; } + if (rr->extra_args) + { + Z_SRW_extra_arg *a; + WRBUF response_xml = wrbuf_alloc(); + wrbuf_puts(response_xml, ""); + for (a = rr->extra_args; a; a = a->next) + { + wrbuf_puts(response_xml, "name); + wrbuf_puts(response_xml, "\""); + if (a->value) + { + wrbuf_puts(response_xml, " value=\""); + wrbuf_xmlputs(response_xml, a->value); + wrbuf_puts(response_xml, "\""); + } + wrbuf_puts(response_xml, "/>"); + } + wrbuf_puts(response_xml, ""); + rr->extra_response_data = + odr_strdup(rr->stream, wrbuf_cstr(response_xml)); + wrbuf_destroy(response_xml); + } rr->hits = get_hit_count(rr->query); return 0; }