diff options
author | schmidt <douglascraigschmidt@users.noreply.github.com> | 1996-11-18 06:51:10 +0000 |
---|---|---|
committer | schmidt <douglascraigschmidt@users.noreply.github.com> | 1996-11-18 06:51:10 +0000 |
commit | 16d93002bf5208ce8642a2a095815b184503fbad (patch) | |
tree | 4a2ffefc1e386fba5a0fedcc0bc5a617accf3711 /examples | |
parent | 71526e6d725759bdcef2aac3ac17f0ce42808dcd (diff) | |
download | ATCD-16d93002bf5208ce8642a2a095815b184503fbad.tar.gz |
Foo
Diffstat (limited to 'examples')
-rw-r--r-- | examples/ASX/Event_Server/Event_Server/Options.cpp | 4 | ||||
-rw-r--r-- | examples/Misc/Makefile | 1 | ||||
-rw-r--r-- | examples/Misc/test_get_opt.cpp | 51 | ||||
-rw-r--r-- | examples/Reactor/Multicast/Log_Wrapper.cpp | 7 | ||||
-rw-r--r-- | examples/Reactor/Multicast/client.cpp | 19 | ||||
-rw-r--r-- | examples/Reactor/Multicast/server.cpp | 6 | ||||
-rw-r--r-- | examples/Reactor/Ntalker/ntalker.cpp | 16 |
7 files changed, 73 insertions, 31 deletions
diff --git a/examples/ASX/Event_Server/Event_Server/Options.cpp b/examples/ASX/Event_Server/Event_Server/Options.cpp index 48ee387030e..58fe1c59529 100644 --- a/examples/ASX/Event_Server/Event_Server/Options.cpp +++ b/examples/ASX/Event_Server/Event_Server/Options.cpp @@ -1,6 +1,6 @@ -#include "ace/Get_Opt.h" // $Id$ +#include "ace/Get_Opt.h" #include "ace/Synch.h" #include "ace/Thread.h" #include "ace/Log_Msg.h" @@ -97,7 +97,7 @@ Options::parse_args (int argc, char *argv[]) ACE_Get_Opt get_opt (argc, argv, "c:bdH:i:L:l:M:ns:t:T:v"); int c; - while ((c = get_opt ()) != -1) + while ((c = get_opt ()) != EOF) switch (c) { case 'b': diff --git a/examples/Misc/Makefile b/examples/Misc/Makefile index 8f950973535..fd4a1a9afc8 100644 --- a/examples/Misc/Makefile +++ b/examples/Misc/Makefile @@ -9,6 +9,7 @@ #---------------------------------------------------------------------------- BIN = test_dump \ + test_get_opt \ test_profile_timer \ test_read_buffer \ test_sstring \ diff --git a/examples/Misc/test_get_opt.cpp b/examples/Misc/test_get_opt.cpp new file mode 100644 index 00000000000..a35216ed956 --- /dev/null +++ b/examples/Misc/test_get_opt.cpp @@ -0,0 +1,51 @@ +// $Id$ + +// Test the ACE_Get_Opt class. + +#include "ace/Get_Opt.h" +#include "ace/Log_Msg.h" + +int +main (int argc, char *argv[]) +{ + ACE_Get_Opt get_opt (argc, argv, "ab:cd:ef:gh:"); + int c; + + while ((c = get_opt ()) != EOF) + switch (c) + { + case 'a': + ACE_DEBUG ((LM_DEBUG, "got a\n")); + break; + case 'b': + ACE_DEBUG ((LM_DEBUG, "got b with arg %s\n", get_opt.optarg)); + break; + case 'c': + ACE_DEBUG ((LM_DEBUG, "got c\n")); + break; + case 'd': + ACE_DEBUG ((LM_DEBUG, "got d with arg %s\n", get_opt.optarg)); + break; + case 'e': + ACE_DEBUG ((LM_DEBUG, "got e\n")); + break; + case 'f': + ACE_DEBUG ((LM_DEBUG, "got f with arg %s\n", get_opt.optarg)); + break; + case 'g': + ACE_DEBUG ((LM_DEBUG, "got g\n")); + break; + case 'h': + ACE_DEBUG ((LM_DEBUG, "got h with arg %s\n", get_opt.optarg)); + break; + default: + ACE_DEBUG ((LM_DEBUG, "got %c, which is unrecognized!\n", c)); + break; + } + + for (int i = get_opt.optind; i < argc; i++) + ACE_DEBUG ((LM_DEBUG, "optind = %d, argv[optind] = %s\n", + i, argv[i])); + + return 0; +} diff --git a/examples/Reactor/Multicast/Log_Wrapper.cpp b/examples/Reactor/Multicast/Log_Wrapper.cpp index 5043974cdf1..38b4cdea09f 100644 --- a/examples/Reactor/Multicast/Log_Wrapper.cpp +++ b/examples/Reactor/Multicast/Log_Wrapper.cpp @@ -1,13 +1,13 @@ -// client.C // $Id$ +// client.C #include "Log_Wrapper.h" Log_Wrapper::Log_Wrapper (void) { this->log_msg_.sequence_number = 0; - this->log_msg_.app_id = ACE_OS::getpid(); + this->log_msg_.app_id = ACE_OS::getpid (); } Log_Wrapper::~Log_Wrapper (void) @@ -15,7 +15,6 @@ Log_Wrapper::~Log_Wrapper (void) } // Set the log_msg_ host address. -// Get a binding to a logger object from orbixd int Log_Wrapper::open (const int port, const char *mcast_addr) @@ -71,5 +70,3 @@ Log_Wrapper::log_message (ACE_Log_Priority type, char *message) return 0; } - - diff --git a/examples/Reactor/Multicast/client.cpp b/examples/Reactor/Multicast/client.cpp index 7b2c963a6e3..23e009e0549 100644 --- a/examples/Reactor/Multicast/client.cpp +++ b/examples/Reactor/Multicast/client.cpp @@ -1,18 +1,13 @@ -// client.C (written by Tim Harrison) // $Id$ -// This program reads in messages from stdin and sends them -// to a Log_Wrapper. +// This program reads in messages from stdin and sends them to a +// Log_Wrapper. #include "ace/Log_Msg.h" #include "Log_Wrapper.h" const char *MCAST_ADDR = ACE_DEFAULT_MULTICAST_ADDR; -// this is hardware specific. -// use netstat(1M) to find whether your interface -// is le0 or ie0 - const int UDP_PORT = ACE_DEFAULT_MULTICAST_PORT; // maximum message size @@ -24,8 +19,6 @@ static int iterations = 0; static void parse_args (int argc, char *argv[]) { - extern char *optarg; - extern int optind; int c; ACE_LOG_MSG->open (argv[0]); @@ -63,10 +56,12 @@ main (int argc, char **argv) if (log.open (UDP_PORT, MCAST_ADDR) == -1) ACE_OS::perror ("connect failed"), ACE_OS::exit (1); - char *buf = new char[::max_message_size]; + char *buf; + + ACE_NEW_RETURN (buf, char[::max_message_size], -1); - // if -i has been specified, send max_message_size messages - // iterations number of times + // If -i has been specified, send max_message_size messages + // iterations number of times. if (iterations) { ACE_OS::memset (buf,1,::max_message_size); diff --git a/examples/Reactor/Multicast/server.cpp b/examples/Reactor/Multicast/server.cpp index 2f1e29b287f..f6946a38649 100644 --- a/examples/Reactor/Multicast/server.cpp +++ b/examples/Reactor/Multicast/server.cpp @@ -97,7 +97,7 @@ Server_Events::~Server_Events (void) } int -Server_Events::handle_input (ACE_HANDLE fd) +Server_Events::handle_input (ACE_HANDLE) { // after the first message, point this to a timer // that way, the next time reactor::handle_events is called, @@ -126,7 +126,7 @@ static const char MCAST_ADDR[] = ACE_DEFAULT_MULTICAST_ADDR; static const int UDP_PORT = ACE_DEFAULT_MULTICAST_PORT; int -main(int argc, char *argv[]) +main(int, char *[]) { int duration = 5; @@ -148,7 +148,7 @@ main(int argc, char *argv[]) } #else int -main (int argc, char *argv[]) +main (int, char *argv[]) { ACE_ERROR_RETURN ((LM_ERROR, "error: %s must be run on a platform that support IP multicast\n", diff --git a/examples/Reactor/Ntalker/ntalker.cpp b/examples/Reactor/Ntalker/ntalker.cpp index 76c940e9a11..e49c94eedf0 100644 --- a/examples/Reactor/Ntalker/ntalker.cpp +++ b/examples/Reactor/Ntalker/ntalker.cpp @@ -15,7 +15,7 @@ // use netstat(1M) to find whether your interface // is le0 or ie0 -static const char *interface = "le0"; +static const char *INTERFACE = "le0"; static const char *MCAST_ADDR = ACE_DEFAULT_MULTICAST_ADDR; static const u_short UDP_PORT = ACE_DEFAULT_MULTICAST_PORT; @@ -132,21 +132,19 @@ Handle_Events::Handle_Events (u_short udp_port, static void parse_args (int argc, char *argv[]) { - extern char *optarg; - extern int optind; int c; while ((c = ACE_OS::getopt (argc, argv, "i:u")) != -1) switch (c) { case 'i': - interface = optarg; + INTERFACE = optarg; break; case 'u': - // usage fallthrough + // Usage fallthrough. default: - cerr << argv[0] << " -i interface\n"; - ::exit (1); + ACE_DEBUG ((LM_DEBUG, "%s -i interface\n", argv[0])); + ACE_OS::exit (1); } } @@ -166,8 +164,8 @@ main (int argc, char *argv[]) ACE_Sig_Action sig ((ACE_SignalHandler) handler, SIGINT); parse_args (argc, argv); - ACE_Reactor reactor; - Handle_Events handle_events (UDP_PORT, MCAST_ADDR, interface, reactor); + ACE_Reactor reactor; + Handle_Events handle_events (UDP_PORT, MCAST_ADDR, INTERFACE, reactor); // main loop |