* 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.6 2005-05-17 13:00:56 adam Exp $
*/
#include <yaz++/z-server.h>
const char *Yaz_USMARC::get_record(int 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;
}
* Copyright (c) 1998-2001, Index Data.
* See the file LICENSE for details.
*
- * $Id: yaz-my-server.cpp,v 1.15 2005-01-17 09:55:58 adam Exp $
+ * $Id: yaz-my-server.cpp,v 1.16 2005-05-17 13:00:56 adam Exp $
*/
#include <stdlib.h>
#include <yaz/log.h>
+#include <yaz/diagbib1.h>
#include <yaz/options.h>
#include <yaz++/z-server.h>
#include <yaz++/pdu-assoc.h>
{
yaz_log (YLOG_LOG, "MyServer::recv_Z_record");
const char *rec = get_record(position);
- create_databaseRecord (odr_encode(), namePlusRecord, 0, VAL_USMARC, rec,
- strlen(rec));
+ if (rec)
+ create_databaseRecord (odr_encode(), namePlusRecord, 0,
+ VAL_USMARC, rec, strlen(rec));
+ else
+ create_surrogateDiagnostics(odr_encode(), namePlusRecord, 0,
+ YAZ_BIB1_PRESENT_REQUEST_OUT_OF_RANGE, 0);
}
MyServer::~MyServer()