Use yazpp rather than yaz++.
[yazproxy-moved-to-github.git] / src / t-server.cpp
index ca63da7..3a4acef 100644 (file)
@@ -1,8 +1,8 @@
 /*
- * Copyright (c) 1998-2005, Index Data.
+ * Copyright (c) 2005, Index Data.
  * See the file LICENSE for details.
  * 
- * $Id: t-server.cpp,v 1.3 2005-09-11 20:06:54 adam Exp $
+ * $Id: t-server.cpp,v 1.8 2006-03-29 13:33:47 adam Exp $
  */
 
 #include <stdlib.h>
 #include <yaz/diagbib1.h>
 #include <yaz/options.h>
 #include "msg-thread.h"
-#include <yaz++/z-assoc.h>
-#include <yaz++/pdu-assoc.h>
-#include <yaz++/gdu.h>
-#include <yaz++/socket-manager.h>
+#include <yazpp/z-assoc.h>
+#include <yazpp/pdu-assoc.h>
+#include <yazpp/gdu.h>
+#include <yazpp/gduqueue.h>
+#include <yazpp/socket-manager.h>
 
 using namespace yazpp_1;
 
@@ -58,11 +59,16 @@ IMsg_Thread *Auth_Msg::handle()
         {
         case Z_APDU_initRequest:
             apdu = zget_APDU(odr, Z_APDU_initResponse);
+            ODR_MASK_SET(apdu->u.initResponse->options, Z_Options_triggerResourceCtrl);
+            ODR_MASK_SET(apdu->u.initResponse->options, Z_Options_search);
+            ODR_MASK_SET(apdu->u.initResponse->options, Z_Options_present);
             break;
         case Z_APDU_searchRequest:
             sleep(5);
             apdu = zget_APDU(odr, Z_APDU_searchResponse);
             break;
+        case Z_APDU_triggerResourceControlRequest:
+            break;
         default:
             apdu = zget_APDU(odr, Z_APDU_close);
             m_close_flag = 1;
@@ -116,6 +122,7 @@ void Auth_Msg::result()
     }
     if (m_front->m_delete_flag && m_front->m_no_requests == 0)
         delete m_front;
+    delete this;
 }
 
 MyServer::MyServer(IPDU_Observable *the_PDU_Observable,
@@ -184,14 +191,18 @@ int main(int argc, char **argv)
     int ret;
     const char *addr = "tcp:@:9999";
     char *apdu_log = 0;
+    int no_threads = 1;
 
-    while ((ret = options("a:v:T", argv, argc, &arg)) != -2)
+    while ((ret = options("n:a:v:T", argv, argc, &arg)) != -2)
     {
         switch (ret)
         {
         case 0:
             addr = xstrdup(arg);
             break;
+        case 'n':
+            no_threads = atoi(arg);
+            break;
         case 'a':
             apdu_log = xstrdup(arg);
             break;
@@ -213,7 +224,7 @@ int main(int argc, char **argv)
     
     MyServer *z = 0;
 
-    Msg_Thread *my_thread = new Msg_Thread(&mySocketManager);
+    Msg_Thread *my_thread = new Msg_Thread(&mySocketManager, no_threads);
 
 #if YAZ_POSIX_THREADS
     if (thread_flag)