diff options
author | schmidt <douglascraigschmidt@users.noreply.github.com> | 1999-06-07 04:13:44 +0000 |
---|---|---|
committer | schmidt <douglascraigschmidt@users.noreply.github.com> | 1999-06-07 04:13:44 +0000 |
commit | bd3a5e20e335a01ed66170dd2d1e67090a288839 (patch) | |
tree | 5859974b2c581e814c037d0022b9fa92a2f44729 /examples | |
parent | 88130ddce8e30f654772c3a53c45ee065aaf4766 (diff) | |
download | ATCD-bd3a5e20e335a01ed66170dd2d1e67090a288839.tar.gz |
.
Diffstat (limited to 'examples')
-rw-r--r-- | examples/ASX/UPIPE_Event_Server/Options.h | 24 | ||||
-rw-r--r-- | examples/ASX/UPIPE_Event_Server/Options.i | 16 | ||||
-rw-r--r-- | examples/IPC_SAP/SPIPE_SAP/NPClient.cpp | 28 | ||||
-rw-r--r-- | examples/IPC_SAP/SPIPE_SAP/NPServer.cpp | 38 | ||||
-rw-r--r-- | examples/Log_Msg/test_log_msg.cpp | 124 | ||||
-rw-r--r-- | examples/Naming/test_multiple_contexts.cpp | 69 | ||||
-rw-r--r-- | examples/Naming/test_non_existent.cpp | 51 | ||||
-rw-r--r-- | examples/Naming/test_open.cpp | 72 | ||||
-rw-r--r-- | examples/Naming/test_writers.cpp | 75 | ||||
-rw-r--r-- | examples/Reactor/Misc/test_signals_2.cpp | 6 |
10 files changed, 334 insertions, 169 deletions
diff --git a/examples/ASX/UPIPE_Event_Server/Options.h b/examples/ASX/UPIPE_Event_Server/Options.h index e82729d965a..3badf1e9daf 100644 --- a/examples/ASX/UPIPE_Event_Server/Options.h +++ b/examples/ASX/UPIPE_Event_Server/Options.h @@ -47,17 +47,17 @@ public: void t_flags (long flag); long t_flags (void); - void supplier_port (char *port); - char *supplier_port (void); + void supplier_port (const char *port); + const char *supplier_port (void); - void consumer_port (char *port); - char *consumer_port (void); + void consumer_port (const char *port); + const char *consumer_port (void); - void supplier_file (char *file); - char *supplier_file (void); + void supplier_file (const char *file); + const char *supplier_file (void); - void consumer_file (char *file); - char *consumer_file (void); + void consumer_file (const char *file); + const char *consumer_file (void); int debug (void); int verbose (void); @@ -75,10 +75,10 @@ private: size_t iterations_; // Number of iterations to run the test program. int debugging_; // Extra debugging info. int verbosity_; // Extra verbose messages. - char *consumer_port_; // Port that the Consumer_Router is using. - char *supplier_port_; // Port that the Supplier_Router is using. - char *consumer_file_; // file that the Consumer_Router is using. - char *supplier_file_; // file that the Supplier_Router is using. + const char *consumer_port_; // Port that the Consumer_Router is using. + const char *supplier_port_; // Port that the Supplier_Router is using. + const char *consumer_file_; // file that the Consumer_Router is using. + const char *supplier_file_; // file that the Supplier_Router is using. }; extern Options options; diff --git a/examples/ASX/UPIPE_Event_Server/Options.i b/examples/ASX/UPIPE_Event_Server/Options.i index 4641b301473..2f9944ea4aa 100644 --- a/examples/ASX/UPIPE_Event_Server/Options.i +++ b/examples/ASX/UPIPE_Event_Server/Options.i @@ -4,48 +4,48 @@ // Option manager for ustreams. inline void -Options::supplier_port (char *port) +Options::supplier_port (const char *port) { this->supplier_port_ = port; } -inline char * +inline const char * Options::supplier_port (void) { return this->supplier_port_; } inline void -Options::supplier_file (char *file) +Options::supplier_file (const char *file) { this->supplier_file_ = file; } -inline char * +inline const char * Options::supplier_file (void) { return this->supplier_file_; } inline void -Options::consumer_file (char *file) +Options::consumer_file (const char *file) { this->consumer_file_ = file; } -inline char * +inline const char * Options::consumer_file (void) { return this->consumer_file_; } inline void -Options::consumer_port (char *port) +Options::consumer_port (const char *port) { this->consumer_port_ = port; } -inline char * +inline const char * Options::consumer_port (void) { return this->consumer_port_; diff --git a/examples/IPC_SAP/SPIPE_SAP/NPClient.cpp b/examples/IPC_SAP/SPIPE_SAP/NPClient.cpp index e0e76d4a4c9..036d30aeb20 100644 --- a/examples/IPC_SAP/SPIPE_SAP/NPClient.cpp +++ b/examples/IPC_SAP/SPIPE_SAP/NPClient.cpp @@ -19,10 +19,13 @@ main (int argc, char *argv[]) { int size = argc > 1 ? atoi (argv[1]) : DEFAULT_SIZE; int iterations = argc > 2 ? atoi (argv[2]) : DEFAULT_COUNT; - char *buf = new char[size]; + char *buf; - //char *pipe_name = ACE_DEFAULT_RENDEZVOUS; - char *pipe_name = "acepipe"; + ACE_NEW_RETURN (buf, + new char[size], + 1); + + const char *pipe_name = "acepipe"; char *rendezvous; rendezvous = MAKE_PIPE_NAME (pipe_name); @@ -30,18 +33,27 @@ main (int argc, char *argv[]) ACE_SPIPE_Connector con; int i; - if (con.connect (cli_stream, ACE_SPIPE_Addr (rendezvous)) == -1) - ACE_ERROR_RETURN ((LM_ERROR, "%p\n", rendezvous), -1); + if (con.connect (cli_stream, + ACE_SPIPE_Addr (rendezvous)) == -1) + ACE_ERROR_RETURN ((LM_ERROR, + "%p\n", + rendezvous), + -1); ACE_OS::strcpy (buf, "hello"); size = ACE_OS::strlen (buf) + 1; for (i = 0; i < iterations; i++) if (cli_stream.send (buf, size) != size) - ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "putmsg"), -1); + ACE_ERROR_RETURN ((LM_ERROR, + "%p\n", + "putmsg"), + -1); if (cli_stream.close () == -1) - ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "close"), -1); - + ACE_ERROR_RETURN ((LM_ERROR, + "%p\n", + "close"), + -1); return 0; } diff --git a/examples/IPC_SAP/SPIPE_SAP/NPServer.cpp b/examples/IPC_SAP/SPIPE_SAP/NPServer.cpp index 5d860ffa226..b1decbc976f 100644 --- a/examples/IPC_SAP/SPIPE_SAP/NPServer.cpp +++ b/examples/IPC_SAP/SPIPE_SAP/NPServer.cpp @@ -15,40 +15,54 @@ int main (int /* argc */, char * /* argv */ []) { ACE_SPIPE_Acceptor acceptor; - ACE_SPIPE_Stream new_stream; + ACE_SPIPE_Stream new_stream; char buf[BUFSIZ]; int n; - // char *pipe_name = ACE_DEFAULT_RENDEZVOUS; - char *pipe_name = "acepipe"; + const char *pipe_name = "acepipe"; char *rendezvous; rendezvous = MAKE_PIPE_NAME (pipe_name); - /* Initialize named pipe listener */ + // Initialize named pipe listener. if (acceptor.open (ACE_SPIPE_Addr (rendezvous)) == -1) - ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "open"), 1); + ACE_ERROR_RETURN ((LM_ERROR, + "%p\n", + + "open"), 1); for (;;) { - ACE_DEBUG ((LM_DEBUG, "waiting for connection\n")); + ACE_DEBUG ((LM_DEBUG, + "waiting for connection\n")); - /* Accept a client connection */ + // Accept a client connection. if (acceptor.accept (new_stream, 0) == -1) - ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "accept"), 1); + ACE_ERROR_RETURN ((LM_ERROR, + "%p\n", + "accept"), + 1); - ACE_DEBUG ((LM_DEBUG, "Accepted connection\n")); + ACE_DEBUG ((LM_DEBUG, + "Accepted connection\n")); while ((n = new_stream.recv (buf, sizeof buf)) > 0) { - ACE_OS::fprintf (stderr, "%s\n", buf); - ACE_OS::write (ACE_STDOUT, buf, n); + ACE_OS::fprintf (stderr, + "%s\n", + buf); + ACE_OS::write (ACE_STDOUT, + buf, + n); } + if (n == -1) { - ACE_DEBUG ((LM_DEBUG, "End of connection. Closing handle\n")); + ACE_DEBUG ((LM_DEBUG, + "End of connection. Closing handle\n")); new_stream.close (); } } + ACE_NOTREACHED(return 0); } diff --git a/examples/Log_Msg/test_log_msg.cpp b/examples/Log_Msg/test_log_msg.cpp index 815afa29cdf..09f0e913a63 100644 --- a/examples/Log_Msg/test_log_msg.cpp +++ b/examples/Log_Msg/test_log_msg.cpp @@ -13,11 +13,10 @@ // several use cases. // // = AUTHOR -// Douglas Schmidt +// Douglas Schmidt <schmidt@cs.wustl.edu> // // ============================================================================ - #include "ace/OS.h" #include "ace/streams.h" @@ -26,14 +25,16 @@ ACE_RCSID(Log_Msg, test_log_msg, "$Id$") static void cleanup (void) { - ACE_DEBUG ((LM_INFO, "leaving (%P)!\n")); + ACE_DEBUG ((LM_INFO, + "leaving (%P)!\n")); } static void cause_error (void) { errno = EWOULDBLOCK; - ACE_ERROR ((LM_DEBUG, "would block\n")); + ACE_ERROR ((LM_DEBUG, + "would block\n")); } int @@ -45,94 +46,143 @@ main (int argc, char *argv[]) if (argc > 1) { - if (ACE_LOG_MSG->open (argv[0], ACE_Log_Msg::OSTREAM) == -1) - ACE_ERROR ((LM_ERROR, "cannot open logger!!!\n")); + if (ACE_LOG_MSG->open (argv[0], + ACE_Log_Msg::OSTREAM) == -1) + ACE_ERROR ((LM_ERROR, + "cannot open logger!!!\n")); cause_error (); // Check to see what happened. if (ACE_LOG_MSG->op_status () == -1 && ACE_LOG_MSG->errnum () == EWOULDBLOCK) - ACE_DEBUG ((LM_DEBUG, "op_status and errnum work!\n")); + ACE_DEBUG ((LM_DEBUG, + "op_status and errnum work!\n")); else - ACE_ERROR ((LM_ERROR, "op_status and errnum failed!\n")); + ACE_ERROR ((LM_ERROR, + "op_status and errnum failed!\n")); } else { if (ACE_LOG_MSG->open (argv[0]) == -1) - ACE_ERROR ((LM_ERROR, "cannot open logger!!!\n")); + ACE_ERROR ((LM_ERROR, + "cannot open logger!!!\n")); cause_error (); // Check to see what happened. if (ACE_LOG_MSG->op_status () == -1 && ACE_LOG_MSG->errnum () == EWOULDBLOCK) - ACE_DEBUG ((LM_DEBUG, "op_status and errnum work!\n")); + ACE_DEBUG ((LM_DEBUG, + "op_status and errnum work!\n")); else - ACE_ERROR ((LM_ERROR, "op_status and errnum failed!\n")); + ACE_ERROR ((LM_ERROR, + "op_status and errnum failed!\n")); // Exercise many different combinations of STDERR and OSTREAM. - ACE_DEBUG ((LM_INFO, "%10f, %*s%s = %d\n", - 3.1416 * counter++, 8, "", "hello", 10000)); + ACE_DEBUG ((LM_INFO, + "%10f, %*s%s = %d\n", + 3.1416 * counter++, + 8, + "", + "hello", + 10000)); ACE_LOG_MSG->set_flags (ACE_Log_Msg::OSTREAM); ACE_LOG_MSG->msg_ostream (&cout); - ACE_DEBUG ((LM_INFO, "%10f, %*s%s = %d\n", - 3.1416 * counter, 8, "", "world", 10000 * counter++)); + ACE_DEBUG ((LM_INFO, + "%10f, %*s%s = %d\n", + 3.1416 * counter, + 8, + "", + "world", + 10000 * counter++)); ACE_LOG_MSG->clr_flags (ACE_Log_Msg::STDERR); - ACE_DEBUG ((LM_INFO, "%10f, %*s%s = %d\n", - 3.1416 * counter, 8, "", "world", 10000 * counter++)); + ACE_DEBUG ((LM_INFO, + "%10f, %*s%s = %d\n", + 3.1416 * counter, + 8, + "", + "world", + 10000 * counter++)); ACE_LOG_MSG->msg_ostream (0); ACE_LOG_MSG->set_flags (ACE_Log_Msg::STDERR); - ACE_DEBUG ((LM_INFO, "%10f, %*s%s = %d\n", - 3.1416 * counter, 8, "", "world", 10000 * counter++)); + ACE_DEBUG ((LM_INFO, + "%10f, %*s%s = %d\n", + 3.1416 * counter, + 8, + "", + "world", + 10000 * counter++)); ACE_LOG_MSG->clr_flags (ACE_Log_Msg::OSTREAM); ACE_LOG_MSG->msg_ostream (&cerr); - ACE_DEBUG ((LM_INFO, "%10f, %*s%s = %d\n", - 3.1416 * counter, 8, "", "world", 10000 * counter++)); + ACE_DEBUG ((LM_INFO, + "%10f, %*s%s = %d\n", + 3.1416 * counter, + 8, + "", + "world", + 10000 * counter++)); static int array[] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048}; // Print out the binary bytes of the array in hex form. - ACE_LOG_MSG->log_hexdump (LM_DEBUG, (char *) array, sizeof array); + ACE_LOG_MSG->log_hexdump (LM_DEBUG, + (char *) array, + sizeof array); // Disable the LM_DEBUG and LM_INFO messages. int priority_mask = ACE_LOG_MSG->priority_mask (); - ACE_CLR_BITS (priority_mask, LM_DEBUG | LM_INFO); + ACE_CLR_BITS (priority_mask, + LM_DEBUG | LM_INFO); ACE_LOG_MSG->priority_mask (priority_mask); - ACE_DEBUG ((LM_INFO, "This LM_INFO message should not print!\n")); - ACE_DEBUG ((LM_DEBUG, "This LM_DEBUG message should not print!\n")); + ACE_DEBUG ((LM_INFO, + "This LM_INFO message should not print!\n")); + ACE_DEBUG ((LM_DEBUG, + "This LM_DEBUG message should not print!\n")); - ACE_SET_BITS (priority_mask, LM_INFO); - ACE_LOG_MSG->priority_mask (priority_mask, ACE_Log_Msg::PROCESS); + ACE_SET_BITS (priority_mask, + LM_INFO); + ACE_LOG_MSG->priority_mask (priority_mask, + ACE_Log_Msg::PROCESS); - ACE_DEBUG ((LM_INFO, "This LM_INFO message should print!\n")); - ACE_DEBUG ((LM_DEBUG, "This LM_DEBUG message should not print!\n")); + ACE_DEBUG ((LM_INFO, + "This LM_INFO message should print!\n")); + ACE_DEBUG ((LM_DEBUG, + "This LM_DEBUG message should not print!\n")); ACE_CLR_BITS (priority_mask, LM_INFO); - ACE_LOG_MSG->priority_mask (priority_mask, ACE_Log_Msg::PROCESS); - - ACE_DEBUG ((LM_INFO, "This LM_INFO message should not print!\n")); - ACE_DEBUG ((LM_DEBUG, "This LM_DEBUG message should not print!\n")); + ACE_LOG_MSG->priority_mask (priority_mask, + ACE_Log_Msg::PROCESS); + + ACE_DEBUG ((LM_INFO, + "This LM_INFO message should not print!\n")); + ACE_DEBUG ((LM_DEBUG, + "This LM_DEBUG message should not print!\n")); - char *badname = "badname"; + const char badname[] = "badname"; char *l_argv[2]; l_argv[0] = badname; l_argv[1] = 0; - if (ACE_OS::execv (badname, l_argv) == -1) - ACE_ERROR ((LM_ERROR, "%n: (%x), %p%r%a\n", - 10000, badname, cleanup, 1)); + if (ACE_OS::execv (badname, + l_argv) == -1) + ACE_ERROR ((LM_ERROR, + "%n: (%x), %p%r%a\n", + 10000, + badname, + cleanup, + 1)); } return 0; } diff --git a/examples/Naming/test_multiple_contexts.cpp b/examples/Naming/test_multiple_contexts.cpp index 5bd6e2cc383..828cea2c030 100644 --- a/examples/Naming/test_multiple_contexts.cpp +++ b/examples/Naming/test_multiple_contexts.cpp @@ -6,44 +6,71 @@ ACE_RCSID(Naming, test_multiple_contexts, "$Id$") int main (int, char *[]) { - static u_long ACE_DEFAULT_BASE_ADDR_1 = (1 * 64 * 1024 * 1024); static u_long ACE_DEFAULT_BASE_ADDR_2 = (2 * 64 * 1024 * 1024); int i; - ACE_Naming_Context * ns_ptr = new ACE_Naming_Context (); - ACE_Name_Options *name_options = ns_ptr->name_options (); + ACE_Naming_Context *ns_ptr; + ACE_NEW_RETURN (ns_ptr, + ACE_Naming_Context, + 1); + ACE_Name_Options *name_options = + ns_ptr->name_options (); - ACE_Naming_Context * ns_ptr1 = new ACE_Naming_Context (); - ACE_Name_Options *name_options1 = ns_ptr1->name_options (); + ACE_Naming_Context *ns_ptr1; + ACE_NEW_RETURN (ns_ptr1, + ACE_Naming_Context, + 1); + ACE_Name_Options *name_options1 = + ns_ptr1->name_options (); char address_arg1[BUFSIZ]; char address_arg2[BUFSIZ]; - ACE_OS::sprintf (address_arg1, "-b%d", ACE_DEFAULT_BASE_ADDR_1); + ACE_OS::sprintf (address_arg1, + "-b%d", + ACE_DEFAULT_BASE_ADDR_1); + + const char *m_argv[] = + { + "MyName1", + "-cNODE_LOCAL", + address_arg1, + NULL + }; + int m_argc = + sizeof (m_argv) / sizeof (char *) -1; - char * m_argv[] = {"MyName1", - "-cNODE_LOCAL", - address_arg1, - NULL}; - int m_argc = sizeof (m_argv) / sizeof (char *) -1; + ACE_OS::sprintf (address_arg2, + "-b%d", + ACE_DEFAULT_BASE_ADDR_2); + const char *n_argv[] = + { + "MyName2", + "-cNODE_LOCAL", + address_arg2, + NULL + }; - ACE_OS::sprintf (address_arg2, "-b%d", ACE_DEFAULT_BASE_ADDR_2); - char * n_argv[] = {"MyName2", - "-cNODE_LOCAL", - address_arg2, - NULL}; - int n_argc = sizeof (n_argv) / sizeof (char *) -1; + int n_argc = + sizeof (n_argv) / sizeof (char *) -1; name_options->parse_args (m_argc, m_argv); i = ns_ptr->open (ACE_Naming_Context::NODE_LOCAL); - ACE_DEBUG ((LM_DEBUG, "(%P) opened with %d\n", i)); - if (i != 0) return -1; + + ACE_DEBUG ((LM_DEBUG, + "(%P) opened with %d\n", + i)); + + if (i != 0) + return -1; name_options1->parse_args (n_argc, n_argv); i = ns_ptr1->open (ACE_Naming_Context::NODE_LOCAL); - ACE_DEBUG ((LM_DEBUG, "(%P) 1 opened with %d\n", i)); - if (i != 0) return -1; + ACE_DEBUG ((LM_DEBUG, + "(%P) 1 opened with %d\n", i)); + if (i != 0) + return -1; return 0; } diff --git a/examples/Naming/test_non_existent.cpp b/examples/Naming/test_non_existent.cpp index 17c035237af..c2ffb5cd0b6 100644 --- a/examples/Naming/test_non_existent.cpp +++ b/examples/Naming/test_non_existent.cpp @@ -8,29 +8,44 @@ int main (int, char *[]) { int i; - ACE_Naming_Context * ns_ptr = new ACE_Naming_Context (); + ACE_Naming_Context *ns_ptr; + ACE_NEW_RETURN (ns_ptr, + ACE_Naming_Context, + 1); + ACE_Name_Options *name_options = ns_ptr->name_options (); + const char *m_argv[] = + { + "MyName", + "-cNODE_LOCAL" , #if defined (ACE_WIN32) - char * m_argv[] = {"MyName", - "-cNODE_LOCAL" , - "-lC:\\temp\\non_existent", - NULL}; + "-lC:\\temp\\non_existent", #else - char * m_argv[] = {"MyName", - "-cNODE_LOCAL" , - "-l/tmp/foobar.mine", - NULL}; -#endif - int m_argc = sizeof (m_argv) / sizeof (char *) -1; - - name_options->parse_args (m_argc,m_argv); - i = ns_ptr->open (ACE_Naming_Context::NODE_LOCAL); - ACE_DEBUG ((LM_DEBUG, "(%P) opened with %d\n", i)); - if (i != 0) return -1; + "-l/tmp/foobar.mine", +#endif /* ACE_WIN32 */ + NULL + }; - i = ns_ptr->bind ("Key_Value","Val_Value","-"); - ACE_DEBUG ((LM_DEBUG, "(%P) bound with %d\n", i)); + int m_argc = + sizeof (m_argv) / sizeof (char *) -1; + name_options->parse_args (m_argc, + m_argv); + + i = ns_ptr->open (ACE_Naming_Context::NODE_LOCAL); + ACE_DEBUG ((LM_DEBUG, + "(%P) opened with %d\n", + i)); + if (i != 0) + return -1; + + i = ns_ptr->bind ("Key_Value", + "Val_Value", + "-"); + + ACE_DEBUG ((LM_DEBUG, + "(%P) bound with %d\n", + i)); return 0; } diff --git a/examples/Naming/test_open.cpp b/examples/Naming/test_open.cpp index ca64a01ddda..adcc1fb0962 100644 --- a/examples/Naming/test_open.cpp +++ b/examples/Naming/test_open.cpp @@ -7,49 +7,69 @@ ACE_RCSID(Naming, test_open, "$Id$") int main (int argc, char **argv) { - char *host = argc > 1 ? argv[1] : "-hlocalhost"; - char *port = argc > 2 ? argv[2] : "-p20012"; + const char *host = argc > 1 ? argv[1] : "-hlocalhost"; + const char *port = argc > 2 ? argv[2] : "-p20012"; ACE_Naming_Context ns; ACE_Name_Options *name_options = ns.name_options (); - char * m_argv[] = { "MyName", - "-cNET_LOCAL", - host, - port, - NULL }; - int m_argc = sizeof ( m_argv ) / sizeof ( char * ) -1; - - name_options->parse_args( m_argc, m_argv ); - - int result = 0; - result = ns.open ( ACE_Naming_Context::NET_LOCAL ); - ACE_DEBUG ((LM_DEBUG, "ACE_Naming_Context::open returned %d\n", result)); + const char *m_argv[] = + { + "MyName", + "-cNET_LOCAL", + host, + port, + NULL + }; + int m_argc = + sizeof (m_argv) / sizeof (char *) -1; + + name_options->parse_args (m_argc, m_argv); + + int result = ns.open (ACE_Naming_Context::NET_LOCAL); + ACE_DEBUG ((LM_DEBUG, + "ACE_Naming_Context::open returned %d\n", + result)); if (result != 0) return result; else { - char Key[128]; - char Val[32]; - char Type[2]; + char key[128]; + char val[32]; + char type[2]; - Type[0] = '-'; - Type[1] = '\0'; + type[0] = '-'; + type[1] = '\0'; int i = 0; + for (int l = 1; l <= 1000 ; l++) { - ACE_OS::sprintf (Key, "K_%05d_%05d", ACE_OS::getpid(), l); - ACE_OS::sprintf (Val, "Val%05d", l); - i = ns.bind (Key, Val, Type); - cout << ACE_OS::getpid() << ": bind of " << Key << " :" << i << endl; - if (i != 0) { + ACE_OS::sprintf (key, + "K_%05d_%05d", + ACE_OS::getpid (), + l); + ACE_OS::sprintf (val, + "Val%05d", + l); + i = ns.bind (key, + val, + type); + ACE_DEBUG ((LM_DEBUG, + "%d: bind of %s: %d\n", + ACE_OS::getpid (), + key, + i)); + + if (i != 0) return -1; - } + } result = ns.close (); - ACE_DEBUG ((LM_DEBUG, "ACE_Naming_Context::close returned %d\n", result)); + ACE_DEBUG ((LM_DEBUG, + "ACE_Naming_Context::close returned %d\n", + result)); } return result; diff --git a/examples/Naming/test_writers.cpp b/examples/Naming/test_writers.cpp index bfd8eb85e8f..1a23d2e91f8 100644 --- a/examples/Naming/test_writers.cpp +++ b/examples/Naming/test_writers.cpp @@ -8,36 +8,63 @@ int main (int, char *[]) { int i; - ACE_Naming_Context * ns_ptr = new ACE_Naming_Context (); - ACE_Name_Options *name_options = ns_ptr->name_options (); + ACE_Naming_Context *ns_ptr; + ACE_NEW_RETURN (ns_ptr, + ACE_Naming_Context, + 1); + ACE_Name_Options *name_options = + ns_ptr->name_options (); - char * m_argv[] = {"MyName", - "-cNODE_LOCAL", - NULL}; + const char *m_argv[] = + { + "MyName", + "-cNODE_LOCAL", + NULL + }; int m_argc = sizeof (m_argv) / sizeof (char *) -1; name_options->parse_args (m_argc,m_argv); i = ns_ptr->open (ACE_Naming_Context::NODE_LOCAL); - ACE_DEBUG ((LM_DEBUG, "(%P) opened with %d\n", i)); - if (i != 0) return -1; - - char Key[128]; - char Val[32]; - char Type[2]; - - Type[0] = '-'; - Type[1] = '\0'; - - for (int l = 1; l <= 1000 ; l++) { - ACE_OS::sprintf (Key, "K_%05d_%05d", ACE_OS::getpid(), l); - ACE_OS::sprintf (Val, "Val%05d", l); - i = ns_ptr->bind (Key, Val, Type); - ACE_DEBUG ((LM_DEBUG, "(%P) bind of %s: %d\n", Key, i)); - if (i != 0) { - return -1; - } - } + ACE_DEBUG ((LM_DEBUG, + "(%P) opened with %d\n", + i)); + if (i != 0) + return -1; + else + { + char key[128]; + char val[32]; + char type[2]; + + type[0] = '-'; + type[1] = '\0'; + + int i = 0; + + for (int l = 1; l <= 1000 ; l++) + { + ACE_OS::sprintf (key, + "K_%05d_%05d", + ACE_OS::getpid (), + l); + ACE_OS::sprintf (val, + "Val%05d", + l); + i = ns.bind (key, + val, + type); + ACE_DEBUG ((LM_DEBUG, + "%d: bind of %s: %d\n", + ACE_OS::getpid (), + key, + i)); + + if (i != 0) + return -1; + + } + } return 0; } diff --git a/examples/Reactor/Misc/test_signals_2.cpp b/examples/Reactor/Misc/test_signals_2.cpp index f25c329bfe8..0378aea8b20 100644 --- a/examples/Reactor/Misc/test_signals_2.cpp +++ b/examples/Reactor/Misc/test_signals_2.cpp @@ -106,7 +106,7 @@ ACE_RCSID(Misc, test_signals_2, "$Id$") class Sig_Handler_1 : public ACE_Event_Handler { public: - Sig_Handler_1 (ACE_Reactor &reactor, char *msg) + Sig_Handler_1 (ACE_Reactor &reactor, const char *msg) : msg_ (msg), count_ (0), reactor_ (reactor) @@ -174,7 +174,7 @@ public: } protected: - char *msg_; + const char *msg_; int count_; int int_sigkey_; int quit_sigkey_; @@ -184,7 +184,7 @@ protected: class Sig_Handler_2 : public Sig_Handler_1 { public: - Sig_Handler_2 (ACE_Reactor &reactor, char *msg) + Sig_Handler_2 (ACE_Reactor &reactor, const char *msg) : Sig_Handler_1 (reactor, msg) { } |