+ const char *str;
+ int extend_recs = 0;
+ int number = cl->hits - cl->record_offset;
+
+ str = session_setting_oneval(sdb, PZ_EXTENDRECS);
+ if (!str || !*str)
+ return 0;
+
+ extend_recs = atoi(str);
+
+ 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 fetch more", client_get_id(cl));
+
+ if (number > extend_recs)
+ number = extend_recs;
+ 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;
+ return 0;
+}
+
+/*
+ * TODO consider how to extend the range
+ * */
+int client_parse_range(struct client *cl, const char *startrecs,
+ const char *maxrecs)
+{
+ if (maxrecs && atoi(maxrecs) != cl->maxrecs)
+ {
+ cl->same_search = 0;
+ cl->maxrecs = atoi(maxrecs);
+ }
+
+ if (startrecs && atoi(startrecs) != cl->startrecs)
+ {
+ cl->same_search = 0;
+ cl->startrecs = atoi(startrecs);
+ }
+
+ return 0;
+}
+
+int client_start_search(struct client *cl)
+{
+ struct session_database *sdb = client_get_database(cl);
+ struct connection *co = 0;
+ ZOOM_connection link = 0;