From: Adam Dickmeiss Date: Wed, 8 Aug 2012 07:27:38 +0000 (+0200) Subject: yaz-client: don't display bogus records from SRU servers X-Git-Tag: v4.2.36~10 X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=commitdiff_plain;h=e81dcf324298802ffbd45c85650b94ce245f65ce;hp=bb44e503b21c87aabdb54bea64944132302ce77b yaz-client: don't display bogus records from SRU servers Some SRU servers return more records than given by *maximumRecords*. Skipping those in display! --- diff --git a/client/client.c b/client/client.c index 1728307..5af4e26 100644 --- a/client/client.c +++ b/client/client.c @@ -147,6 +147,7 @@ static int scan_size = 20; static char cur_host[200]; static Odr_int last_hit_count = 0; static int pretty_xml = 0; +static Odr_int sru_maximumRecords = 0; typedef enum { QueryType_Prefix, @@ -1478,6 +1479,7 @@ static int send_SRW_searchRequest(const char *arg) printf("Only CQL and PQF supported in SRW\n"); return 0; } + sru_maximumRecords = 0; sr->u.request->maximumRecords = odr_intdup(out, 0); sr->u.request->facetList = facet_list; if (record_schema) @@ -3173,6 +3175,7 @@ static int send_SRW_presentRequest(const char *arg) if (!parse_show_args(arg, setstring, &setno, &nos)) return 0; sr->u.request->startRecord = odr_intdup(out, setno); + sru_maximumRecords = nos; sr->u.request->maximumRecords = odr_intdup(out, nos); if (record_schema) sr->u.request->recordSchema = record_schema; @@ -4367,8 +4370,17 @@ static void handle_srw_response(Z_SRW_searchRetrieveResponse *res) display_facets(res->facetList); if (res->suggestions) printf("Suggestions:\n%s\n", res->suggestions); - for (i = 0; inum_records; i++) + for (i = 0; i < res->num_records; i++) + { + if (i >= sru_maximumRecords) + { + printf("SRU server returns extra records. Skipping " + ODR_INT_PRINTF " records.\n", + res->num_records - sru_maximumRecords); + break; + } handle_srw_record(res->records + i); + } } static void handle_srw_scan_term(Z_SRW_scanTerm *term)