New GFS search member: present_number
[yaz-moved-to-github.git] / src / seshigh.c
index bc16416..223239f 100644 (file)
@@ -1,5 +1,5 @@
 /* This file is part of the YAZ toolkit.
- * Copyright (C) 1995-2012 Index Data
+ * Copyright (C) 1995-2013 Index Data
  * See the file LICENSE for details.
  */
 /**
@@ -671,7 +671,7 @@ static int retrieve_fetch(association *assoc, bend_fetch_rr *rr)
 static int srw_bend_fetch(association *assoc, int pos,
                           Z_SRW_searchRetrieveRequest *srw_req,
                           Z_SRW_record *record,
-                          const char **addinfo)
+                          const char **addinfo, int *last_in_set)
 {
     bend_fetch_rr rr;
     ODR o = assoc->encode;
@@ -730,6 +730,8 @@ static int srw_bend_fetch(association *assoc, int pos,
 
     retrieve_fetch(assoc, &rr);
 
+    *last_in_set = rr.last_in_set;
+
     if (rr.errcode && rr.surrogate_flag)
     {
         int code = yaz_diag_bib1_to_srw(rr.errcode);
@@ -894,6 +896,8 @@ static void srw_bend_search(association *assoc,
         rr.query->u.type_1 = 0;
         rr.extra_args = sr->extra_args;
         rr.extra_response_data = 0;
+        rr.present_number = srw_req->maximumRecords ?
+            *srw_req->maximumRecords : 0;
 
         if (srw_req->query_type == Z_SRW_query_type_cql)
         {
@@ -1088,6 +1092,7 @@ static void srw_bend_search(association *assoc,
                         for (i = 0; i<number; i++)
                         {
                             int errcode;
+                            int last_in_set = 0;
                             const char *addinfo = 0;
 
                             srw_res->records[j].recordPacking = packing;
@@ -1096,7 +1101,7 @@ static void srw_bend_search(association *assoc,
                             yaz_log(YLOG_DEBUG, "srw_bend_fetch %d", i+start);
                             errcode = srw_bend_fetch(assoc, i+start, srw_req,
                                                      srw_res->records + j,
-                                                     &addinfo);
+                                                     &addinfo, &last_in_set);
                             if (errcode)
                             {
                                 yaz_add_srw_diagnostic(assoc->encode,
@@ -1109,6 +1114,8 @@ static void srw_bend_search(association *assoc,
                             }
                             if (srw_res->records[j].recordData_buf)
                                 j++;
+                            if (last_in_set)
+                                break;
                         }
                         srw_res->num_records = j;
                         if (!j)
@@ -2322,6 +2329,10 @@ static Z_APDU *process_initRequest(association *assoc, request *reqb)
                 assoc->init->implementation_id,
                 resp->implementationId);
 
+    resp->implementationVersion = odr_prepend(assoc->encode,
+                assoc->init->implementation_version,
+                resp->implementationVersion);
+
     resp->implementationName = odr_prepend(assoc->encode,
                 assoc->init->implementation_name,
                 odr_prepend(assoc->encode, "GFS", resp->implementationName));
@@ -2591,6 +2602,8 @@ static Z_Records *pack_records(association *a, char *setname, Odr_int start,
             return 0;
         reclist->records[reclist->num_records] = thisrec;
         reclist->num_records++;
+        if (freq.last_in_set)
+            break;
     }
     *num = reclist->num_records;
     return records;
@@ -2639,6 +2652,7 @@ static Z_APDU *process_searchRequest(association *assoc, request *reqb)
         bsrr->errstring = NULL;
         bsrr->search_info = NULL;
         bsrr->search_input = req->otherInfo;
+        bsrr->present_number = *req->mediumSetPresentNumber;
 
         if (assoc->server && assoc->server->cql_transform
             && req->query->which == Z_Query_type_104