Update to use Odr_int
authorAdam Dickmeiss <adam@indexdata.dk>
Tue, 1 Dec 2009 21:03:58 +0000 (22:03 +0100)
committerAdam Dickmeiss <adam@indexdata.dk>
Tue, 1 Dec 2009 21:03:58 +0000 (22:03 +0100)
src/filter_multi.cpp
src/filter_session_shared.cpp
src/filter_sru_to_z3950.cpp
src/gduutil.cpp

index 33367e7..f728724 100644 (file)
@@ -976,7 +976,7 @@ void yf::Multi::Frontend::scan2(mp::Package &package, Z_APDU *apdu_req)
                     {
                         ScanTermInfo my;
 
-                        int *occur = ent->u.termInfo->globalOccurrences;
+                        Odr_int *occur = ent->u.termInfo->globalOccurrences;
                         my.m_count = occur ? *occur : 0;
 
                         if (ent->u.termInfo->term->which == Z_Term_general)
@@ -1017,7 +1017,7 @@ void yf::Multi::Frontend::scan2(mp::Package &package, Z_APDU *apdu_req)
                     {
                         ScanTermInfo my;
 
-                        int *occur = ent->u.termInfo->globalOccurrences;
+                        Odr_int *occur = ent->u.termInfo->globalOccurrences;
                         my.m_count = occur ? *occur : 0;
 
                         if (ent->u.termInfo->term->which == Z_Term_general)
index cd6a237..056a568 100644 (file)
@@ -846,7 +846,8 @@ void yf::SessionShared::Frontend::present(mp::Package &package,
         Z_APDU *f_apdu_res = odr.create_presentResponse(apdu_req, 0, 0);
         Z_PresentResponse *f_resp = f_apdu_res->u.presentResponse;
 
-        yaz_log(YLOG_LOG, "Found %d+%d records in cache %p",
+        yaz_log(YLOG_LOG, "Found " ODR_INT_PRINTF "+" ODR_INT_PRINTF 
+                " records in cache %p",
                 *req->resultSetStartPoint,                      
                 *req->numberOfRecordsRequested,
                 &found_set->m_record_cache);        
@@ -897,7 +898,8 @@ void yf::SessionShared::Frontend::present(mp::Package &package,
 
         if (b_resp->records && b_resp->records->which ==  Z_Records_DBOSD)
         {
-            yaz_log(YLOG_LOG, "Adding %d+%d records to cache %p",
+            yaz_log(YLOG_LOG, "Adding " ODR_INT_PRINTF "+" ODR_INT_PRINTF
+                    " records to cache %p",
                     *req->resultSetStartPoint,                      
                     *f_resp->numberOfRecordsReturned,
                     &found_set->m_record_cache);        
index fea86c1..7ccebd3 100644 (file)
@@ -40,7 +40,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #include <iostream>
 #include <sstream>
 #include <string>
-#include <algorithm>
+/* #include <algorithm> */
 #include <map>
 
 namespace mp = metaproxy_1;
@@ -538,8 +538,7 @@ bool yf::SRUtoZ3950::Impl::z3950_search_request(mp::Package &package,
 
     // Finally, roll on and srw'fy number of records
     sru_pdu_res->u.response->numberOfRecords 
-        = (int *) odr_malloc(odr_en, sizeof(int *));
-    *(sru_pdu_res->u.response->numberOfRecords) = *(sr->resultCount);
+        = odr_intdup(odr_en, *sr->resultCount);
     
     // srw'fy nextRecordPosition
     //sru_pdu_res->u.response->nextRecordPosition 
@@ -643,10 +642,12 @@ yf::SRUtoZ3950::Impl::z3950_present_request(mp::Package &package,
     
     // z3950'fy number of records requested 
     // protect against requesting records out of range
-    *apdu->u.presentRequest->numberOfRecordsRequested
-        = std::min(max_recs, 
-                   *sru_pdu_res->u.response->numberOfRecords - start + 1);
-    
+    if (max_recs < *sru_pdu_res->u.response->numberOfRecords - start + 1)
+        *apdu->u.presentRequest->numberOfRecordsRequested = max_recs;
+    else
+        *apdu->u.presentRequest->numberOfRecordsRequested =
+            *sru_pdu_res->u.response->numberOfRecords - start + 1;
+        
     // z3950'fy recordPacking
     int record_packing = Z_SRW_recordPacking_XML;
     if (sr_req->recordPacking && 's' == *(sr_req->recordPacking))
index 4993074..976b091 100644 (file)
@@ -139,7 +139,7 @@ static void dump_opt_string(std::ostream& os, const char *s)
         os << "-";
 }
 
-static void dump_opt_int(std::ostream& os, const int *i)
+static void dump_opt_int(std::ostream& os, const Odr_int *i)
 {
     os << " ";
     if (i)