X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Fclient.c;h=d3491035c5aa8ea9e7cedc4c5d90e1dbcc21d57b;hb=ae06d921f11a9f25da573362dd1995ea57b3059e;hp=bbafde0f86389aaf573dd09e12616707b11d3033;hpb=0aa1114a00aa7d78e6e9dd8099f4c9b3d93f5f94;p=pazpar2-moved-to-github.git diff --git a/src/client.c b/src/client.c index bbafde0..d349103 100644 --- a/src/client.c +++ b/src/client.c @@ -1,5 +1,5 @@ /* This file is part of Pazpar2. - Copyright (C) 2006-2012 Index Data + Copyright (C) 2006-2013 Index Data Pazpar2 is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free @@ -115,6 +115,7 @@ struct client { char *addinfo; // diagnostic info for most resent error Odr_int hits; int record_offset; + int show_stat_no; int filtered; // When using local:, this will count the number of filtered records. int maxrecs; int startrecs; @@ -645,7 +646,7 @@ static void client_record_ingest(struct client *cl) } } -void client_record_response(struct client *cl) +void client_record_response(struct client *cl, int *got_records) { struct connection *co = cl->connection; ZOOM_connection link = connection_get_link(co); @@ -678,6 +679,7 @@ void client_record_response(struct client *cl) else { client_record_ingest(cl); + *got_records = 1; } } } @@ -762,6 +764,58 @@ static const char *get_strategy_plus_sort(struct client *l, const char *field) return strategy_plus_sort; } +void client_update_show_stat(struct client *cl, int cmd) +{ + if (cmd == 0) + cl->show_stat_no = 0; + else if (cmd == 1) + cl->show_stat_no++; +} + +int client_fetch_more(struct client *cl) +{ + struct session_database *sdb = client_get_database(cl); + const char *str; + int extend_recs = 0; + int number; + + yaz_log(YLOG_LOG, "cl=%s show_stat_no=%d got=%d", + client_get_id(cl), cl->show_stat_no, cl->record_offset); + if (cl->show_stat_no < cl->record_offset) + return 0; + yaz_log(YLOG_LOG, "cl=%s Trying to get more", client_get_id(cl)); + + str = session_setting_oneval(sdb, PZ_EXTENDRECS); + if (str && *str) + extend_recs = atoi(str); + + if (extend_recs > cl->hits) + extend_recs = cl->hits; + + number = extend_recs - cl->record_offset; + if (number > 0) + { + ZOOM_resultset set = cl->resultset; + struct connection *co = client_get_connection(cl); + + str = session_setting_oneval(sdb, PZ_REQUESTSYNTAX); + ZOOM_resultset_option_set(set, "preferredRecordSyntax", str); + str = session_setting_oneval(sdb, PZ_ELEMENTS); + if (str && *str) + ZOOM_resultset_option_set(set, "elementSetName", str); + + ZOOM_resultset_records(set, 0, cl->record_offset, number); + client_set_state(cl, Client_Working); + connection_continue(co); + return 1; + } + else + { + yaz_log(YLOG_LOG, "cl=%s. OK no more in total set", client_get_id(cl)); + } + return 0; +} + int client_parse_init(struct client *cl, int same_search) { cl->same_search = same_search; @@ -1263,8 +1317,8 @@ static int apply_limit(struct session_database *sdb, sdb->database->id, cvalue); ret = -1; /* bad limitmap */ } - break; } + break; } } if (!s)