summaryrefslogtreecommitdiff
path: root/examples/Logger
diff options
context:
space:
mode:
authorSteve Huston <shuston@riverace.com>2004-10-27 21:07:30 +0000
committerSteve Huston <shuston@riverace.com>2004-10-27 21:07:30 +0000
commit4c8a6efdc2fb418184d035aa4090142110b6e923 (patch)
tree65d03494026685e8a1f1f21f00b11846d88c8bfe /examples/Logger
parente8d6692635980cec76f553e15e00ad3022297dae (diff)
downloadATCD-4c8a6efdc2fb418184d035aa4090142110b6e923.tar.gz
ChangeLogTag:Wed Oct 27 16:22:49 2004 Steve Huston <shuston@riverace.com>
Diffstat (limited to 'examples/Logger')
-rw-r--r--examples/Logger/Acceptor-server/server_loggerd.cpp49
-rw-r--r--examples/Logger/Acceptor-server/server_loggerd.h2
-rw-r--r--examples/Logger/client/logging_app.cpp22
-rw-r--r--examples/Logger/simple-server/Logging_Handler.cpp28
-rw-r--r--examples/Logger/simple-server/server_loggerd.cpp14
5 files changed, 62 insertions, 53 deletions
diff --git a/examples/Logger/Acceptor-server/server_loggerd.cpp b/examples/Logger/Acceptor-server/server_loggerd.cpp
index 434428d4909..e77bba0d832 100644
--- a/examples/Logger/Acceptor-server/server_loggerd.cpp
+++ b/examples/Logger/Acceptor-server/server_loggerd.cpp
@@ -1,4 +1,5 @@
// $Id$
+// server_loggerd.cpp,v 4.29 2003/12/30 23:18:59 shuston Exp
// This server daemon collects, formats, and displays logging
// information forwarded from client daemons running on other hosts in
@@ -37,11 +38,11 @@ Options::port (void)
// Parse the command-line options.
void
-Options::parse_args (int argc, char *argv[])
+Options::parse_args (int argc, ACE_TCHAR *argv[])
{
this->port_ = ACE_DEFAULT_SERVER_PORT;
- ACE_Get_Opt get_opt (argc, argv, "p:");
+ ACE_Get_Opt get_opt (argc, argv, ACE_TEXT ("p:"));
for (int c; (c = get_opt ()) != -1; )
switch (c)
@@ -89,7 +90,8 @@ Logging_Handler::handle_timeout (const ACE_Time_Value &,
#endif /* ACE_NDEBUG */
ACE_ASSERT (arg == this);
- ACE_DEBUG ((LM_DEBUG, "(%P|%t) handling timeout from this = %u\n", this));
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("(%P|%t) handling timeout from this = %@\n"), this));
return 0;
}
@@ -110,12 +112,12 @@ Logging_Handler::handle_input (ACE_HANDLE)
switch (n)
{
case -1:
- ACE_ERROR_RETURN ((LM_ERROR, "(%P|%t) %p at host %s\n",
- "client logger", this->peer_name_), -1);
+ ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("(%P|%t) %p at host %C\n"),
+ ACE_TEXT ("client logger"), this->peer_name_), -1);
/* NOTREACHED */
case 0:
ACE_ERROR_RETURN ((LM_ERROR,
- "(%P|%t) closing log daemon at host %s (fd = %d)\n",
+ ACE_TEXT ("(%P|%t) closing log daemon at host %C (fd = %d)\n"),
this->peer_name_, this->get_handle ()), -1);
/* NOTREACHED */
case sizeof (size_t):
@@ -126,25 +128,26 @@ Logging_Handler::handle_input (ACE_HANDLE)
n = this->peer ().recv_n ((void *) &lp, len);
if (n != len)
- ACE_ERROR_RETURN ((LM_ERROR, "(%P|%t) %p at host %s\n",
- "client logger", this->peer_name_), -1);
+ ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("(%P|%t) %p at host %C\n"),
+ ACE_TEXT ("client logger"), this->peer_name_),-1);
/* NOTREACHED */
lp.decode ();
if (lp.length () == n)
{
- ACE_DEBUG ((LM_DEBUG, "(%P|%t) "));
- lp.print (this->peer_name_, 1, cerr);
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%P|%t) ")));
+ lp.print (ACE_TEXT_CHAR_TO_TCHAR (this->peer_name_), 1, cerr);
}
else
- ACE_ERROR ((LM_ERROR, "(%P|%t) error, lp.length = %d, n = %d\n",
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("(%P|%t) error, lp.length = %d, n = %d\n"),
lp.length (), n));
break;
}
default:
- ACE_ERROR_RETURN ((LM_ERROR, "(%P|%t) %p at host %s\n",
- "client logger", this->peer_name_), -1);
+ ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("(%P|%t) %p at host %C\n"),
+ ACE_TEXT ("client logger"), this->peer_name_), -1);
/* NOTREACHED */
}
@@ -166,23 +169,26 @@ Logging_Handler::open (void *)
if (REACTOR::instance ()->register_handler (this, READ_MASK) == -1)
ACE_ERROR_RETURN ((LM_ERROR,
- "(%P|%t) can't register with reactor\n"), -1);
+ ACE_TEXT ("(%P|%t) can't register with reactor\n")),
+ -1);
else if (REACTOR::instance ()->schedule_timer
(this,
(const void *) this,
ACE_Time_Value (2),
ACE_Time_Value (2)) == -1)
ACE_ERROR_RETURN ((LM_ERROR,
- "can'(%P|%t) t register with reactor\n"), -1);
+ ACE_TEXT ("(%P|%t) can't register with reactor\n")),
+ -1);
else
ACE_DEBUG ((LM_DEBUG,
- "(%P|%t) connected with %s\n", this->peer_name_));
+ ACE_TEXT ("(%P|%t) connected with %C\n"),
+ this->peer_name_));
return 0;
}
}
int
-main (int argc, char *argv[])
+ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
// Acceptor factory.
Logging_Acceptor peer_acceptor;
@@ -195,7 +201,7 @@ main (int argc, char *argv[])
if (peer_acceptor.open
(ACE_INET_Addr (OPTIONS::instance ()->port ()),
REACTOR::instance ()) == -1)
- ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "open"), -1);
+ ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("open")), -1);
// Register QUIT_HANDLER to receive SIGINT commands. When received,
// QUIT_HANDLER becomes "set" and thus, the event loop below will
@@ -203,19 +209,20 @@ main (int argc, char *argv[])
else if (REACTOR::instance ()->register_handler
(SIGINT, QUIT_HANDLER::instance ()) == -1)
ACE_ERROR_RETURN ((LM_ERROR,
- "registering service with ACE_Reactor\n"), -1);
+ ACE_TEXT ("registering service with ACE_Reactor\n")),
+ -1);
// Run forever, performing logging service.
ACE_DEBUG ((LM_DEBUG,
- "(%P|%t) starting up server logging daemon\n"));
+ ACE_TEXT ("(%P|%t) starting up server logging daemon\n")));
// Perform logging service until QUIT_HANDLER receives SIGINT.
while (QUIT_HANDLER::instance ()->is_set () == 0)
REACTOR::instance ()->handle_events ();
ACE_DEBUG ((LM_DEBUG,
- "(%P|%t) shutting down server logging daemon\n"));
+ ACE_TEXT ("(%P|%t) shutting down server logging daemon\n")));
return 0;
}
diff --git a/examples/Logger/Acceptor-server/server_loggerd.h b/examples/Logger/Acceptor-server/server_loggerd.h
index 45bc1f6cec0..33d5f0042ee 100644
--- a/examples/Logger/Acceptor-server/server_loggerd.h
+++ b/examples/Logger/Acceptor-server/server_loggerd.h
@@ -14,7 +14,7 @@ class Options
// = TITLE
// Keeps track of the options.
public:
- void parse_args (int argc, char *argv[]);
+ void parse_args (int argc, ACE_TCHAR *argv[]);
u_short port (void);
private:
diff --git a/examples/Logger/client/logging_app.cpp b/examples/Logger/client/logging_app.cpp
index dadccde4f3b..ba5bb24295e 100644
--- a/examples/Logger/client/logging_app.cpp
+++ b/examples/Logger/client/logging_app.cpp
@@ -14,13 +14,13 @@
ACE_RCSID(client, logging_app, "$Id$")
static u_short LOGGER_PORT = ACE_DEFAULT_SERVER_PORT;
-static const char *const LOGGER_HOST = ACE_DEFAULT_SERVER_HOST;
+static const ACE_TCHAR *const LOGGER_HOST = ACE_DEFAULT_SERVER_HOST;
static const int MAX_ITERATIONS = 10;
int
-main (int argc, char *argv[])
+ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
- const char *logger_host = argc > 1 ? argv[1] : LOGGER_HOST;
+ const ACE_TCHAR *logger_host = argc > 1 ? argv[1] : LOGGER_HOST;
u_short logger_port = argc > 2 ? ACE_OS::atoi (argv[2]) : LOGGER_PORT;
int max_iterations = argc > 3 ? ACE_OS::atoi (argv[3]) : MAX_ITERATIONS;
@@ -29,16 +29,16 @@ main (int argc, char *argv[])
ACE_INET_Addr addr (logger_port, logger_host);
if (connector.connect (logger, addr) == -1)
- ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "open"), -1);
+ ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("open")), -1);
for (int i = 0; i < max_iterations; i++)
{
- ACE_Log_Record log_record (LM_DEBUG,
- ACE_OS::time ((time_t *) 0),
- ACE_OS::getpid ());
+ ACE_Log_Record log_record (LM_DEBUG,
+ ACE_OS::time ((time_t *) 0),
+ ACE_OS::getpid ());
- char buf[BUFSIZ];
- ACE_OS::sprintf (buf, "message = %d\n", i + 1);
+ ACE_TCHAR buf[BUFSIZ];
+ ACE_OS::sprintf (buf, ACE_TEXT ("message = %d\n"), i + 1);
log_record.msg_data (buf);
size_t len = log_record.length ();
size_t encoded_len = htonl (len);
@@ -47,13 +47,13 @@ main (int argc, char *argv[])
if (logger.send (4, &encoded_len, sizeof encoded_len,
(char *) &log_record, len) == -1)
- ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "send"), -1);
+ ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("send")),-1);
else
ACE_OS::sleep (1);
}
if (logger.close () == -1)
- ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "close"), -1);
+ ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("close")), -1);
return 0;
}
diff --git a/examples/Logger/simple-server/Logging_Handler.cpp b/examples/Logger/simple-server/Logging_Handler.cpp
index 72afed83497..111a26248fc 100644
--- a/examples/Logger/simple-server/Logging_Handler.cpp
+++ b/examples/Logger/simple-server/Logging_Handler.cpp
@@ -41,7 +41,8 @@ Logging_Handler::handle_timeout (const ACE_Time_Value &,
#endif /* ACE_NDEBUG */
ACE_ASSERT (arg == this);
- ACE_DEBUG ((LM_DEBUG, "(%P|%t) handling timeout from this = %u\n", this));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%P|%t) handling timeout from this = %@\n"),
+ this));
return 0;
}
@@ -62,8 +63,8 @@ Logging_Handler::handle_input (ACE_HANDLE)
switch (n = this->cli_stream_.recv ((void *) &len, sizeof len))
{
case -1:
- ACE_ERROR_RETURN ((LM_ERROR, "(%P|%t) %p at host %s\n",
- "client logger", this->host_name_), -1);
+ ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("(%P|%t) %p at host %C\n"),
+ ACE_TEXT ("client logger"), this->host_name_), -1);
/* NOTREACHED */
case 0:
ACE_ERROR_RETURN ((LM_ERROR,
@@ -77,25 +78,26 @@ Logging_Handler::handle_input (ACE_HANDLE)
len = ntohl (len);
n = this->cli_stream_.recv_n ((void *) &lp, len);
if (n != (ssize_t) len)
- ACE_ERROR_RETURN ((LM_ERROR, "(%P|%t) %p at host %s\n",
- "client logger", this->host_name_), -1);
+ ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("(%P|%t) %p at host %C\n"),
+ ACE_TEXT ("client logger"), this->host_name_), -1);
/* NOTREACHED */
lp.decode ();
if (lp.length () == n)
{
- ACE_DEBUG ((LM_DEBUG, "(%P|%t) "));
- lp.print (this->host_name_, 1);
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%P|%t) ")));
+ lp.print (ACE_TEXT_CHAR_TO_TCHAR (this->host_name_), 1);
}
else
- ACE_ERROR ((LM_ERROR, "(%P|%t) error, lp.length = %d, n = %d\n",
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("(%P|%t) error, lp.length = %d, n = %d\n"),
lp.length (), n));
break;
}
default:
- ACE_ERROR_RETURN ((LM_ERROR, "(%P|%t) %p at host %s\n",
- "client logger", this->host_name_), -1);
+ ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("(%P|%t) %p at host %C\n"),
+ ACE_TEXT ("client logger"), this->host_name_), -1);
/* NOTREACHED */
}
@@ -125,18 +127,18 @@ Logging_Handler::open (void)
if (REACTOR::instance ()->register_handler (this, READ_MASK) == -1)
ACE_ERROR_RETURN ((LM_ERROR,
- "(%P|%t) can't register with reactor\n"),
+ ACE_TEXT ("(%P|%t) can't register with reactor\n")),
-1);
else if (REACTOR::instance ()->schedule_timer
(this, (const void *) this,
ACE_Time_Value (2),
ACE_Time_Value (2)) == -1)
ACE_ERROR_RETURN ((LM_ERROR,
- "can'(%P|%t) t register with reactor\n"),
+ ACE_TEXT ("(%P|%t) can't register with reactor\n")),
-1);
else
ACE_DEBUG ((LM_DEBUG,
- "(%P|%t) connected with %s\n",
+ ACE_TEXT ("(%P|%t) connected with %C\n"),
this->host_name_));
return 0;
}
diff --git a/examples/Logger/simple-server/server_loggerd.cpp b/examples/Logger/simple-server/server_loggerd.cpp
index 323eea5b2d1..49981dc92ff 100644
--- a/examples/Logger/simple-server/server_loggerd.cpp
+++ b/examples/Logger/simple-server/server_loggerd.cpp
@@ -28,7 +28,7 @@ handler (int)
static const u_short PORT = ACE_DEFAULT_SERVER_PORT;
int
-main (int argc, char *argv[])
+ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
// Register a signal handler.
ACE_Sig_Action sa ((ACE_SignalHandler) handler, SIGINT);
@@ -41,7 +41,7 @@ main (int argc, char *argv[])
ACE_INET_Addr addr (PORT);
- ACE_Get_Opt get_opt (argc, argv, "p:");
+ ACE_Get_Opt get_opt (argc, argv, ACE_TEXT ("p:"));
for (int c; (c = get_opt ()) != -1; )
switch (c)
@@ -55,26 +55,26 @@ main (int argc, char *argv[])
if (peer_acceptor->open (addr) == -1)
ACE_ERROR_RETURN ((LM_ERROR,
- "%p\n",
- "open"),
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("open")),
-1);
else if (REACTOR::instance ()->register_handler
(peer_acceptor,
ACE_Event_Handler::ACCEPT_MASK) == -1)
ACE_ERROR_RETURN ((LM_ERROR,
- "registering service with ACE_Reactor\n"),
+ ACE_TEXT ("registering service with ACE_Reactor\n")),
-1);
// Run forever, performing the logging service.
ACE_DEBUG ((LM_DEBUG,
- "(%P|%t) starting up server logging daemon\n"));
+ ACE_TEXT ("(%P|%t) starting up server logging daemon\n")));
while (!finished)
REACTOR::instance ()->handle_events ();
ACE_DEBUG ((LM_DEBUG,
- "(%P|%t) shutting down server logging daemon\n"));
+ ACE_TEXT ("(%P|%t) shutting down server logging daemon\n")));
return 0;
}