X-Git-Url: http://sru.miketaylor.org.uk/?a=blobdiff_plain;f=src%2Fyaz-marc-sample.cpp;h=906fdd28dd0ab9a4df2ee1ea73abda217747ab3f;hb=9245208f93f95246e44cb597317f9e13c8b60e67;hp=4af243a2ff41be671dcc11ceb7152fad448a3ddd;hpb=6acf28a0195560e01bac84460171b54f176a0d92;p=yazpp-moved-to-github.git diff --git a/src/yaz-marc-sample.cpp b/src/yaz-marc-sample.cpp index 4af243a..906fdd2 100644 --- a/src/yaz-marc-sample.cpp +++ b/src/yaz-marc-sample.cpp @@ -2,11 +2,13 @@ * Copyright (c) 2000-2001, Index Data. * See the file LICENSE for details. * - * $Id: yaz-marc-sample.cpp,v 1.5 2003-10-16 10:26:58 adam Exp $ + * $Id: yaz-marc-sample.cpp,v 1.9 2005-06-25 15:53:19 adam Exp $ */ #include +using namespace yazpp_1; + 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" @@ -1478,9 +1480,18 @@ static const 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; } +/* + * Local variables: + * c-basic-offset: 4 + * indent-tabs-mode: nil + * End: + * vim: shiftwidth=4 tabstop=8 expandtab + */ +