summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--examples/C++NPv1/Logging_Client.cpp23
-rw-r--r--examples/C++NPv2/Select_Reactor_Logging_Server.cpp19
-rw-r--r--examples/C++NPv2/Server_Shutdown.cpp23
-rw-r--r--examples/C++NPv2/TP_Reactor_Logging_Server.cpp19
4 files changed, 70 insertions, 14 deletions
diff --git a/examples/C++NPv1/Logging_Client.cpp b/examples/C++NPv1/Logging_Client.cpp
index fec006d72e1..4f17cbe2b3f 100644
--- a/examples/C++NPv1/Logging_Client.cpp
+++ b/examples/C++NPv1/Logging_Client.cpp
@@ -12,11 +12,11 @@
#include "ace/Log_Record.h"
#include "ace/streams.h"
-#include <string>
-
#if defined (ACE_WIN32) && (!defined (ACE_HAS_STANDARD_CPP_LIBRARY) || \
(ACE_HAS_STANDARD_CPP_LIBRARY == 0))
-# error "Must add to config.h: #define ACE_HAS_STANDARD_CPP_LIBRARY 1"
+# include <stdio.h>
+#else
+# include <string>
#endif
int operator<< (ACE_OutputCDR &cdr, const ACE_Log_Record &log_record)
@@ -111,6 +111,22 @@ int main (int argc, char *argv[])
if (connector.connect (logging_client.peer (), server_addr) < 0)
ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "connect()"), 1);
+#if defined (ACE_WIN32) && (!defined (ACE_HAS_STANDARD_CPP_LIBRARY) || \
+ (ACE_HAS_STANDARD_CPP_LIBRARY == 0))
+ for (;;) {
+ char user_input[ACE_Log_Record::MAXLOGMSGLEN];
+ if (!gets (user_input))
+ break;
+
+ ACE_Time_Value now (ACE_OS::gettimeofday ());
+ ACE_Log_Record log_record (LM_INFO, now, ACE_OS::getpid ());
+ log_record.msg_data (user_input);
+ if (logging_client.send (log_record) == -1)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "%p\n", "logging_client.send()"), 1);
+ }
+#else
+
// Limit the number of characters read on each record
cin.width (ACE_Log_Record::MAXLOGMSGLEN);
@@ -127,6 +143,7 @@ int main (int argc, char *argv[])
ACE_ERROR_RETURN ((LM_ERROR,
"%p\n", "logging_client.send()"), 1);
}
+#endif
return 0; // Logging_Client destructor closes TCP connection.
}
diff --git a/examples/C++NPv2/Select_Reactor_Logging_Server.cpp b/examples/C++NPv2/Select_Reactor_Logging_Server.cpp
index 4f1dfcee48d..778e5fd3262 100644
--- a/examples/C++NPv2/Select_Reactor_Logging_Server.cpp
+++ b/examples/C++NPv2/Select_Reactor_Logging_Server.cpp
@@ -9,11 +9,11 @@
#include "ace/Select_Reactor.h"
#include "ace/Thread_Manager.h"
-#include <string>
-
#if defined (ACE_WIN32) && (!defined (ACE_HAS_STANDARD_CPP_LIBRARY) || \
(ACE_HAS_STANDARD_CPP_LIBRARY == 0))
-# error "Must add to config.h: #define ACE_HAS_STANDARD_CPP_LIBRARY 1"
+# include <stdio.h>
+#else
+# include <string>
#endif
#include "Reactor_Logging_Server.h"
@@ -58,6 +58,17 @@ static ACE_THR_FUNC_RETURN controller (void *arg) {
Quit_Handler *quit_handler = 0;
ACE_NEW_RETURN (quit_handler, Quit_Handler (reactor), 0);
+#if defined (ACE_WIN32) && (!defined (ACE_HAS_STANDARD_CPP_LIBRARY) || \
+ (ACE_HAS_STANDARD_CPP_LIBRARY == 0))
+ for (;;) {
+ char user_input[80];
+ gets (user_input);
+ if (ACE_OS_String::strcmp (user_input, "quit") == 0) {
+ reactor->notify (quit_handler);
+ break;
+ }
+ }
+#else
for (;;) {
std::string user_input;
std::getline (cin, user_input, '\n');
@@ -66,6 +77,8 @@ static ACE_THR_FUNC_RETURN controller (void *arg) {
break;
}
}
+#endif
+
return 0;
}
diff --git a/examples/C++NPv2/Server_Shutdown.cpp b/examples/C++NPv2/Server_Shutdown.cpp
index 9e371d81f01..7aa53224ec0 100644
--- a/examples/C++NPv2/Server_Shutdown.cpp
+++ b/examples/C++NPv2/Server_Shutdown.cpp
@@ -11,15 +11,15 @@
#include "ace/Thread_Manager.h"
#include "ace/streams.h"
-#include <string>
-
-#include "SLDEX_export.h"
-
#if defined (ACE_WIN32) && (!defined (ACE_HAS_STANDARD_CPP_LIBRARY) || \
(ACE_HAS_STANDARD_CPP_LIBRARY == 0))
-# error "Must add to config.h: #define ACE_HAS_STANDARD_CPP_LIBRARY 1"
+# include <stdio.h>
+#else
+# include <string>
#endif
+#include "SLDEX_export.h"
+
class Quit_Handler : public ACE_Event_Handler {
friend class ace_dewarn_gplusplus;
@@ -47,6 +47,17 @@ static ACE_THR_FUNC_RETURN controller (void *arg) {
Quit_Handler *quit_handler = 0;
ACE_NEW_RETURN (quit_handler, Quit_Handler (reactor), 0);
+#if defined (ACE_WIN32) && (!defined (ACE_HAS_STANDARD_CPP_LIBRARY) || \
+ (ACE_HAS_STANDARD_CPP_LIBRARY == 0))
+ for (;;) {
+ char user_input[80];
+ gets (user_input);
+ if (ACE_OS_String::strcmp (user_input, "quit") == 0) {
+ reactor->notify (quit_handler);
+ break;
+ }
+ }
+#else
for (;;) {
std::string user_input;
std::getline (cin, user_input, '\n');
@@ -55,6 +66,8 @@ static ACE_THR_FUNC_RETURN controller (void *arg) {
break;
}
}
+#endif
+
return 0;
}
diff --git a/examples/C++NPv2/TP_Reactor_Logging_Server.cpp b/examples/C++NPv2/TP_Reactor_Logging_Server.cpp
index 5d4a3b37aba..16d575d055f 100644
--- a/examples/C++NPv2/TP_Reactor_Logging_Server.cpp
+++ b/examples/C++NPv2/TP_Reactor_Logging_Server.cpp
@@ -10,11 +10,11 @@
#include "ace/TP_Reactor.h"
#include "ace/Thread_Manager.h"
-#include <string>
-
#if defined (ACE_WIN32) && (!defined (ACE_HAS_STANDARD_CPP_LIBRARY) || \
(ACE_HAS_STANDARD_CPP_LIBRARY == 0))
-# error "Must add to config.h: #define ACE_HAS_STANDARD_CPP_LIBRARY 1"
+# include <stdio.h>
+#else
+# include <string>
#endif
#include "Reactor_Logging_Server.h"
@@ -59,6 +59,17 @@ static ACE_THR_FUNC_RETURN controller (void *arg) {
Quit_Handler *quit_handler = 0;
ACE_NEW_RETURN (quit_handler, Quit_Handler (reactor), 0);
+#if defined (ACE_WIN32) && (!defined (ACE_HAS_STANDARD_CPP_LIBRARY) || \
+ (ACE_HAS_STANDARD_CPP_LIBRARY == 0))
+ for (;;) {
+ char user_input[80];
+ gets (user_input);
+ if (ACE_OS_String::strcmp (user_input, "quit") == 0) {
+ reactor->notify (quit_handler);
+ break;
+ }
+ }
+#else
for (;;) {
std::string user_input;
std::getline (cin, user_input, '\n');
@@ -67,6 +78,8 @@ static ACE_THR_FUNC_RETURN controller (void *arg) {
break;
}
}
+#endif
+
return 0;
}