Introducing namespace yazpp_1 for all YAZ++ functions. This will
[yazpp-moved-to-github.git] / src / yaz-my-server.cpp
index 4d145ab..b636088 100644 (file)
@@ -2,15 +2,19 @@
  * Copyright (c) 1998-2001, Index Data.
  * See the file LICENSE for details.
  * 
- * $Id: yaz-my-server.cpp,v 1.14 2004-12-13 20:50:54 adam Exp $
+ * $Id: yaz-my-server.cpp,v 1.17 2005-06-02 06:40:21 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>
 #include <yaz++/socket-manager.h>
 
+using namespace yazpp_1;
+
 class MyILL : public Yaz_Facility_ILL {
 public:
     void ill_service (Z_ExtendedServicesRequest *req,
@@ -126,8 +130,12 @@ void MyRetrieval::sr_record (const char *resultSetName,
 {
     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()