Use size_t for get_record index.
[yazpp-moved-to-github.git] / src / yaz-marc-sample.cpp
index 9895359..037fdf6 100644 (file)
@@ -2,12 +2,12 @@
  * Copyright (c) 2000-2001, Index Data.
  * See the file LICENSE for details.
  * 
- * $Id: yaz-marc-sample.cpp,v 1.4 2003-09-23 16:26:16 mike Exp $
+ * $Id: yaz-marc-sample.cpp,v 1.7 2005-05-17 20:34:36 adam Exp $
  */
 
 #include <yaz++/z-server.h>
 
-static char *marc_records[] = {
+static const char *marc_records[] = {
   "\x30\x30\x33\x36\x36\x6E\x61\x6D\x20\x20\x32\x32\x30\x30\x31\x36"
   "\x39\x38\x61\x20\x34\x35\x30\x30\x30\x30\x31\x30\x30\x31\x33\x30"
   "\x30\x30\x30\x30\x30\x30\x33\x30\x30\x30\x34\x30\x30\x30\x31\x33"
@@ -1478,9 +1478,10 @@ static char *marc_records[] = {
   "\x77\x6F\x72\x6B\x2C\x20\x4E\x44\x4E\x2E\x1E\x1D"
 };
 
-const char *Yaz_USMARC::get_record(int position)
+const char *Yaz_USMARC::get_record(size_t position)
 {
-    int max = sizeof(marc_records) / sizeof(*marc_records);
-    int eff_pos = (position-1) % max;
-    return marc_records[eff_pos];
+    if (position >= 1 && position <= (
+           sizeof(marc_records) / sizeof(*marc_records)))
+       return marc_records[position-1];
+    return 0;
 }