Working fetch more, but settings/tests needs updating
[pazpar2-moved-to-github.git] / src / client.c
index bbafde0..d3265c3 100644 (file)
@@ -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
@@ -762,6 +762,35 @@ static const char *get_strategy_plus_sort(struct client *l, const char *field)
     return strategy_plus_sort;
 }
 
+int client_fetch_more(struct client *cl)
+{
+    struct session_database *sdb = client_get_database(cl);
+    const char *str;
+    int extra = cl->hits - cl->record_offset;
+
+    if (extra > 0)
+    {
+        ZOOM_resultset set = cl->resultset;
+        struct connection *co = client_get_connection(cl);
+        int max_extra = 10;
+
+        if (extra > max_extra)
+            extra = max_extra;
+
+        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, extra);
+        client_set_state(cl, Client_Working);
+        connection_continue(co);
+        return 1;
+    }
+    return 0;
+}
+
 int client_parse_init(struct client *cl, int same_search)
 {
     cl->same_search = same_search;