From 30102243920c57c8c73120186ef6f23d00357499 Mon Sep 17 00:00:00 2001 From: "William R. Otte" Date: Thu, 27 Jul 2006 20:43:46 +0000 Subject: Thu Jul 27 20:30:26 UTC 2006 William R. Otte --- .../IPC-tests/server/Handle_Broadcast.cpp | 2 +- .../IPC-tests/server/Handle_Broadcast.h | 2 +- .../IPC-tests/server/Handle_Broadcast.i | 116 ---------------- .../IPC-tests/server/Handle_Broadcast.inl | 116 ++++++++++++++++ .../IPC-tests/server/Handle_L_CODgram.cpp | 2 +- .../IPC-tests/server/Handle_L_CODgram.h | 2 +- .../IPC-tests/server/Handle_L_CODgram.i | 123 ----------------- .../IPC-tests/server/Handle_L_CODgram.inl | 123 +++++++++++++++++ .../IPC-tests/server/Handle_L_Dgram.cpp | 2 +- .../IPC-tests/server/Handle_L_Dgram.h | 2 +- .../IPC-tests/server/Handle_L_Dgram.i | 116 ---------------- .../IPC-tests/server/Handle_L_Dgram.inl | 116 ++++++++++++++++ .../IPC-tests/server/Handle_L_FIFO.cpp | 2 +- .../IPC-tests/server/Handle_L_FIFO.h | 2 +- .../IPC-tests/server/Handle_L_FIFO.i | 101 -------------- .../IPC-tests/server/Handle_L_FIFO.inl | 101 ++++++++++++++ .../IPC-tests/server/Handle_L_Pipe.cpp | 2 +- .../IPC-tests/server/Handle_L_Pipe.h | 2 +- .../IPC-tests/server/Handle_L_Pipe.i | 96 ------------- .../IPC-tests/server/Handle_L_Pipe.inl | 96 +++++++++++++ .../IPC-tests/server/Handle_L_SPIPE.cpp | 2 +- .../IPC-tests/server/Handle_L_SPIPE.h | 2 +- .../IPC-tests/server/Handle_L_SPIPE.i | 131 ------------------ .../IPC-tests/server/Handle_L_SPIPE.inl | 131 ++++++++++++++++++ .../IPC-tests/server/Handle_L_Stream.cpp | 2 +- .../IPC-tests/server/Handle_L_Stream.h | 2 +- .../IPC-tests/server/Handle_L_Stream.i | 149 -------------------- .../IPC-tests/server/Handle_L_Stream.inl | 149 ++++++++++++++++++++ .../IPC-tests/server/Handle_R_Dgram.cpp | 2 +- .../IPC-tests/server/Handle_R_Dgram.h | 2 +- .../IPC-tests/server/Handle_R_Dgram.i | 111 --------------- .../IPC-tests/server/Handle_R_Dgram.inl | 111 +++++++++++++++ .../IPC-tests/server/Handle_R_Stream.cpp | 2 +- .../IPC-tests/server/Handle_R_Stream.h | 2 +- .../IPC-tests/server/Handle_R_Stream.i | 153 --------------------- .../IPC-tests/server/Handle_R_Stream.inl | 153 +++++++++++++++++++++ .../IPC-tests/server/Handle_Timeout.cpp | 2 +- .../IPC-tests/server/Handle_Timeout.h | 2 +- .../IPC-tests/server/Handle_Timeout.i | 86 ------------ .../IPC-tests/server/Handle_Timeout.inl | 86 ++++++++++++ 40 files changed, 1202 insertions(+), 1202 deletions(-) delete mode 100644 ACE/examples/Service_Configurator/IPC-tests/server/Handle_Broadcast.i create mode 100644 ACE/examples/Service_Configurator/IPC-tests/server/Handle_Broadcast.inl delete mode 100644 ACE/examples/Service_Configurator/IPC-tests/server/Handle_L_CODgram.i create mode 100644 ACE/examples/Service_Configurator/IPC-tests/server/Handle_L_CODgram.inl delete mode 100644 ACE/examples/Service_Configurator/IPC-tests/server/Handle_L_Dgram.i create mode 100644 ACE/examples/Service_Configurator/IPC-tests/server/Handle_L_Dgram.inl delete mode 100644 ACE/examples/Service_Configurator/IPC-tests/server/Handle_L_FIFO.i create mode 100644 ACE/examples/Service_Configurator/IPC-tests/server/Handle_L_FIFO.inl delete mode 100644 ACE/examples/Service_Configurator/IPC-tests/server/Handle_L_Pipe.i create mode 100644 ACE/examples/Service_Configurator/IPC-tests/server/Handle_L_Pipe.inl delete mode 100644 ACE/examples/Service_Configurator/IPC-tests/server/Handle_L_SPIPE.i create mode 100644 ACE/examples/Service_Configurator/IPC-tests/server/Handle_L_SPIPE.inl delete mode 100644 ACE/examples/Service_Configurator/IPC-tests/server/Handle_L_Stream.i create mode 100644 ACE/examples/Service_Configurator/IPC-tests/server/Handle_L_Stream.inl delete mode 100644 ACE/examples/Service_Configurator/IPC-tests/server/Handle_R_Dgram.i create mode 100644 ACE/examples/Service_Configurator/IPC-tests/server/Handle_R_Dgram.inl delete mode 100644 ACE/examples/Service_Configurator/IPC-tests/server/Handle_R_Stream.i create mode 100644 ACE/examples/Service_Configurator/IPC-tests/server/Handle_R_Stream.inl delete mode 100644 ACE/examples/Service_Configurator/IPC-tests/server/Handle_Timeout.i create mode 100644 ACE/examples/Service_Configurator/IPC-tests/server/Handle_Timeout.inl (limited to 'ACE/examples/Service_Configurator/IPC-tests') diff --git a/ACE/examples/Service_Configurator/IPC-tests/server/Handle_Broadcast.cpp b/ACE/examples/Service_Configurator/IPC-tests/server/Handle_Broadcast.cpp index 30db7825244..d81213805cd 100644 --- a/ACE/examples/Service_Configurator/IPC-tests/server/Handle_Broadcast.cpp +++ b/ACE/examples/Service_Configurator/IPC-tests/server/Handle_Broadcast.cpp @@ -31,7 +31,7 @@ fini (void) unsigned short Handle_Broadcast::DEFAULT_PORT = ACE_DEFAULT_BROADCAST_PORT; #if !defined (__ACE_INLINE__) -#include "Handle_Broadcast.i" +#include "Handle_Broadcast.inl" #endif /* __ACE_INLINE__ */ Handle_Broadcast remote_broadcast; diff --git a/ACE/examples/Service_Configurator/IPC-tests/server/Handle_Broadcast.h b/ACE/examples/Service_Configurator/IPC-tests/server/Handle_Broadcast.h index 8b382f9fd73..39c115b8c46 100644 --- a/ACE/examples/Service_Configurator/IPC-tests/server/Handle_Broadcast.h +++ b/ACE/examples/Service_Configurator/IPC-tests/server/Handle_Broadcast.h @@ -42,7 +42,7 @@ extern ACE_Service_Object_Type rb; #if defined (__ACE_INLINE__) #define ACE_INLINE inline -#include "Handle_Broadcast.i" +#include "Handle_Broadcast.inl" #else #define ACE_INLINE #endif /* __ACE_INLINE__ */ diff --git a/ACE/examples/Service_Configurator/IPC-tests/server/Handle_Broadcast.i b/ACE/examples/Service_Configurator/IPC-tests/server/Handle_Broadcast.i deleted file mode 100644 index ce7f42617e7..00000000000 --- a/ACE/examples/Service_Configurator/IPC-tests/server/Handle_Broadcast.i +++ /dev/null @@ -1,116 +0,0 @@ -/* -*- C++ -*- */ -// $Id$ - -#include "ace/Get_Opt.h" -#include "ace/OS_NS_stdio.h" -#include "ace/OS_NS_string.h" -#include "ace/OS_NS_unistd.h" - -ACE_INLINE -Handle_Broadcast::~Handle_Broadcast (void) -{ -} - -ACE_INLINE -Handle_Broadcast::Handle_Broadcast (void) -{ -} - -ACE_INLINE int -Handle_Broadcast::open (const ACE_INET_Addr &r, int async) -{ - if (this->ACE_SOCK_Dgram::open (r) == -1) - return -1; - else if (async && ACE_SOCK_Dgram::enable (ACE_SIGIO) == -1) - return -1; - else - return 0; -} - -ACE_INLINE int -Handle_Broadcast::info (ACE_TCHAR **strp, size_t length) const -{ - ACE_TCHAR buf[BUFSIZ]; - ACE_INET_Addr sa; - - if (this->get_local_addr (sa) == -1) - return -1; - - ACE_OS::sprintf (buf, ACE_TEXT("%d/"), sa.get_port_number ()); - ACE_OS::strcat (buf, ACE_TEXT("udp # tests broadcasting\n")); - - if (*strp == 0 && (*strp = ACE_OS::strdup (buf)) == 0) - return -1; - else - ACE_OS::strncpy (*strp, buf, length); - return ACE_OS::strlen (buf); -} - -ACE_INLINE int -Handle_Broadcast::init (int argc, ACE_TCHAR *argv[]) -{ - ACE_INET_Addr sba (Handle_Broadcast::DEFAULT_PORT); - ACE_Get_Opt get_opt (argc, argv, ACE_TEXT("p:"), 0); - - for (int c; (c = get_opt ()) != -1; ) - switch (c) - { - case 'p': - sba.set (ACE_OS::atoi (get_opt.opt_arg ())); - break; - default: - break; - } - - if (this->open (sba) == -1) - ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("open")), -1); - else if (ACE_Reactor::instance ()->register_handler - (this, ACE_Event_Handler::ACCEPT_MASK) == -1) - ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), - ACE_TEXT ("registering service with ACE_Reactor")), -1); - return 0; -} - -ACE_INLINE int -Handle_Broadcast::fini (void) -{ - return ACE_Reactor::instance ()->remove_handler - (this, ACE_Event_Handler::ACCEPT_MASK); -} - -ACE_INLINE ACE_HANDLE -Handle_Broadcast::get_handle (void) const -{ - return this->ACE_SOCK_Dgram::get_handle (); -} - -ACE_INLINE int -Handle_Broadcast::handle_input (ACE_HANDLE) -{ - ACE_INET_Addr sa; - char buf[8 * 1024]; /* 8 k buffer */ - ssize_t n = this->recv (buf, sizeof buf, sa); - - if (n== -1) - return -1; - else - ACE_DEBUG ((LM_INFO, - ACE_TEXT ("received broadcast datagram from host %C\n"), - sa.get_host_name ())); - - ACE_OS::puts (ACE_TEXT ("----------------------------------------")); - ACE_OS::write (ACE_STDOUT, buf, n); - - if (buf[n - 1] != '\n') - putchar ('\n'); - - ACE_OS::puts (ACE_TEXT ("----------------------------------------")); - - return 0; -} - -ACE_INLINE int -Handle_Broadcast::handle_close (ACE_HANDLE, ACE_Reactor_Mask) -{ - return this->ACE_SOCK_Dgram::close (); -} diff --git a/ACE/examples/Service_Configurator/IPC-tests/server/Handle_Broadcast.inl b/ACE/examples/Service_Configurator/IPC-tests/server/Handle_Broadcast.inl new file mode 100644 index 00000000000..ce7f42617e7 --- /dev/null +++ b/ACE/examples/Service_Configurator/IPC-tests/server/Handle_Broadcast.inl @@ -0,0 +1,116 @@ +/* -*- C++ -*- */ +// $Id$ + +#include "ace/Get_Opt.h" +#include "ace/OS_NS_stdio.h" +#include "ace/OS_NS_string.h" +#include "ace/OS_NS_unistd.h" + +ACE_INLINE +Handle_Broadcast::~Handle_Broadcast (void) +{ +} + +ACE_INLINE +Handle_Broadcast::Handle_Broadcast (void) +{ +} + +ACE_INLINE int +Handle_Broadcast::open (const ACE_INET_Addr &r, int async) +{ + if (this->ACE_SOCK_Dgram::open (r) == -1) + return -1; + else if (async && ACE_SOCK_Dgram::enable (ACE_SIGIO) == -1) + return -1; + else + return 0; +} + +ACE_INLINE int +Handle_Broadcast::info (ACE_TCHAR **strp, size_t length) const +{ + ACE_TCHAR buf[BUFSIZ]; + ACE_INET_Addr sa; + + if (this->get_local_addr (sa) == -1) + return -1; + + ACE_OS::sprintf (buf, ACE_TEXT("%d/"), sa.get_port_number ()); + ACE_OS::strcat (buf, ACE_TEXT("udp # tests broadcasting\n")); + + if (*strp == 0 && (*strp = ACE_OS::strdup (buf)) == 0) + return -1; + else + ACE_OS::strncpy (*strp, buf, length); + return ACE_OS::strlen (buf); +} + +ACE_INLINE int +Handle_Broadcast::init (int argc, ACE_TCHAR *argv[]) +{ + ACE_INET_Addr sba (Handle_Broadcast::DEFAULT_PORT); + ACE_Get_Opt get_opt (argc, argv, ACE_TEXT("p:"), 0); + + for (int c; (c = get_opt ()) != -1; ) + switch (c) + { + case 'p': + sba.set (ACE_OS::atoi (get_opt.opt_arg ())); + break; + default: + break; + } + + if (this->open (sba) == -1) + ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("open")), -1); + else if (ACE_Reactor::instance ()->register_handler + (this, ACE_Event_Handler::ACCEPT_MASK) == -1) + ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), + ACE_TEXT ("registering service with ACE_Reactor")), -1); + return 0; +} + +ACE_INLINE int +Handle_Broadcast::fini (void) +{ + return ACE_Reactor::instance ()->remove_handler + (this, ACE_Event_Handler::ACCEPT_MASK); +} + +ACE_INLINE ACE_HANDLE +Handle_Broadcast::get_handle (void) const +{ + return this->ACE_SOCK_Dgram::get_handle (); +} + +ACE_INLINE int +Handle_Broadcast::handle_input (ACE_HANDLE) +{ + ACE_INET_Addr sa; + char buf[8 * 1024]; /* 8 k buffer */ + ssize_t n = this->recv (buf, sizeof buf, sa); + + if (n== -1) + return -1; + else + ACE_DEBUG ((LM_INFO, + ACE_TEXT ("received broadcast datagram from host %C\n"), + sa.get_host_name ())); + + ACE_OS::puts (ACE_TEXT ("----------------------------------------")); + ACE_OS::write (ACE_STDOUT, buf, n); + + if (buf[n - 1] != '\n') + putchar ('\n'); + + ACE_OS::puts (ACE_TEXT ("----------------------------------------")); + + return 0; +} + +ACE_INLINE int +Handle_Broadcast::handle_close (ACE_HANDLE, ACE_Reactor_Mask) +{ + return this->ACE_SOCK_Dgram::close (); +} diff --git a/ACE/examples/Service_Configurator/IPC-tests/server/Handle_L_CODgram.cpp b/ACE/examples/Service_Configurator/IPC-tests/server/Handle_L_CODgram.cpp index 6fe631fdb41..1654eff8573 100644 --- a/ACE/examples/Service_Configurator/IPC-tests/server/Handle_L_CODgram.cpp +++ b/ACE/examples/Service_Configurator/IPC-tests/server/Handle_L_CODgram.cpp @@ -10,7 +10,7 @@ const ACE_TCHAR *Handle_L_CODgram::DEFAULT_RENDEZVOUS = ACE_TEXT ("/tmp/foo_codgram"); #if !defined (__ACE_INLINE__) -#include "Handle_L_CODgram.i" +#include "Handle_L_CODgram.inl" #endif /* __ACE_INLINE__ */ Handle_L_CODgram local_codgram; diff --git a/ACE/examples/Service_Configurator/IPC-tests/server/Handle_L_CODgram.h b/ACE/examples/Service_Configurator/IPC-tests/server/Handle_L_CODgram.h index 852c0557cda..c0b158dea08 100644 --- a/ACE/examples/Service_Configurator/IPC-tests/server/Handle_L_CODgram.h +++ b/ACE/examples/Service_Configurator/IPC-tests/server/Handle_L_CODgram.h @@ -42,7 +42,7 @@ extern ACE_Service_Object_Type lc; #if defined (__ACE_INLINE__) #define ACE_INLINE inline -#include "Handle_L_CODgram.i" +#include "Handle_L_CODgram.inl" #else #define ACE_INLINE #endif /* __ACE_INLINE__ */ diff --git a/ACE/examples/Service_Configurator/IPC-tests/server/Handle_L_CODgram.i b/ACE/examples/Service_Configurator/IPC-tests/server/Handle_L_CODgram.i deleted file mode 100644 index a77d75e1fa8..00000000000 --- a/ACE/examples/Service_Configurator/IPC-tests/server/Handle_L_CODgram.i +++ /dev/null @@ -1,123 +0,0 @@ -/* -*- C++ -*- */ -// $Id$ - -#include "ace/Get_Opt.h" -#include "ace/OS_NS_stdio.h" -#include "ace/OS_NS_string.h" -#include "ace/OS_NS_unistd.h" - -ACE_INLINE -Handle_L_CODgram::Handle_L_CODgram (void) -{ -} - -ACE_INLINE int -Handle_L_CODgram::open (const ACE_UNIX_Addr &suad, int async) -{ - if (this->ACE_LSOCK_CODgram::open (ACE_Addr::sap_any, suad) == -1) - return -1; - else if (async && this->ACE_LSOCK_CODgram::enable (ACE_SIGIO) == -1) - return -1; - else - return 0; -} - -ACE_INLINE int -Handle_L_CODgram::info (ACE_TCHAR **strp, size_t length) const -{ - ACE_TCHAR buf[BUFSIZ]; - ACE_UNIX_Addr sa; - - if (ACE_LSOCK_CODgram::get_local_addr (sa) == -1) - return -1; - - ACE_OS::strcpy (buf, ACE_TEXT_CHAR_TO_TCHAR (sa.get_path_name ())); - ACE_OS::strcat (buf, ACE_TEXT (" # tests local connected datagram\n")); - - if (*strp == 0 && (*strp = ACE_OS::strdup (buf)) == 0) - return -1; - else - ACE_OS::strncpy (*strp, buf, length); - return ACE_OS::strlen (buf); -} - -ACE_INLINE int -Handle_L_CODgram::init (int argc, ACE_TCHAR *argv[]) -{ - ACE_UNIX_Addr sucd; - ACE_Get_Opt get_opt (argc, argv, ACE_TEXT ("r:"), 0); - const ACE_TCHAR *r = Handle_L_CODgram::DEFAULT_RENDEZVOUS; - - for (int c; (c = get_opt ()) != -1; ) - switch (c) - { - case 'r': - r = get_opt.opt_arg (); - break; - default: - break; - } - - ACE_OS::strncpy (this->rendezvous, r, MAXPATHLEN); - ACE_OS::unlink (this->rendezvous); - sucd.set (this->rendezvous); - if (this->open (sucd) == -1) - ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("open")), -1); - else if (ACE_Reactor::instance ()->register_handler - (this, ACE_Event_Handler::ACCEPT_MASK) == -1) - ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), - ACE_TEXT ("registering service with ACE_Reactor")), - -1); - return 0; -} - -ACE_INLINE int -Handle_L_CODgram::fini(void) -{ - return ACE_Reactor::instance ()->remove_handler - (this, ACE_Event_Handler::ACCEPT_MASK); -} - -ACE_INLINE ACE_HANDLE -Handle_L_CODgram::get_handle (void) const -{ - return ACE_LSOCK_CODgram::get_handle (); -} - -ACE_INLINE int -Handle_L_CODgram::handle_input (ACE_HANDLE) -{ - ACE_HANDLE handle = ACE_INVALID_HANDLE; - char buf[BUFSIZ]; - - if (this->recv_handle (handle) == -1) - return -1; - else - ACE_DEBUG ((LM_INFO, ACE_TEXT ("received handle (%d)\n"), handle)); - - ACE_OS::puts ("----------------------------------------"); - - for (;;) - { - ssize_t n = ACE_OS::read (handle, buf, sizeof buf); - - if (n <= 0) - break; - - ACE_OS::write (ACE_STDOUT, buf, n); - } - - ACE_OS::puts ("----------------------------------------"); - - if (ACE_OS::close (handle) == -1) - return -1; - - return 0; -} - -ACE_INLINE int -Handle_L_CODgram::handle_close (ACE_HANDLE, ACE_Reactor_Mask) -{ - this->ACE_LSOCK_CODgram::close (); - return ACE_OS::unlink (this->rendezvous); -} diff --git a/ACE/examples/Service_Configurator/IPC-tests/server/Handle_L_CODgram.inl b/ACE/examples/Service_Configurator/IPC-tests/server/Handle_L_CODgram.inl new file mode 100644 index 00000000000..a77d75e1fa8 --- /dev/null +++ b/ACE/examples/Service_Configurator/IPC-tests/server/Handle_L_CODgram.inl @@ -0,0 +1,123 @@ +/* -*- C++ -*- */ +// $Id$ + +#include "ace/Get_Opt.h" +#include "ace/OS_NS_stdio.h" +#include "ace/OS_NS_string.h" +#include "ace/OS_NS_unistd.h" + +ACE_INLINE +Handle_L_CODgram::Handle_L_CODgram (void) +{ +} + +ACE_INLINE int +Handle_L_CODgram::open (const ACE_UNIX_Addr &suad, int async) +{ + if (this->ACE_LSOCK_CODgram::open (ACE_Addr::sap_any, suad) == -1) + return -1; + else if (async && this->ACE_LSOCK_CODgram::enable (ACE_SIGIO) == -1) + return -1; + else + return 0; +} + +ACE_INLINE int +Handle_L_CODgram::info (ACE_TCHAR **strp, size_t length) const +{ + ACE_TCHAR buf[BUFSIZ]; + ACE_UNIX_Addr sa; + + if (ACE_LSOCK_CODgram::get_local_addr (sa) == -1) + return -1; + + ACE_OS::strcpy (buf, ACE_TEXT_CHAR_TO_TCHAR (sa.get_path_name ())); + ACE_OS::strcat (buf, ACE_TEXT (" # tests local connected datagram\n")); + + if (*strp == 0 && (*strp = ACE_OS::strdup (buf)) == 0) + return -1; + else + ACE_OS::strncpy (*strp, buf, length); + return ACE_OS::strlen (buf); +} + +ACE_INLINE int +Handle_L_CODgram::init (int argc, ACE_TCHAR *argv[]) +{ + ACE_UNIX_Addr sucd; + ACE_Get_Opt get_opt (argc, argv, ACE_TEXT ("r:"), 0); + const ACE_TCHAR *r = Handle_L_CODgram::DEFAULT_RENDEZVOUS; + + for (int c; (c = get_opt ()) != -1; ) + switch (c) + { + case 'r': + r = get_opt.opt_arg (); + break; + default: + break; + } + + ACE_OS::strncpy (this->rendezvous, r, MAXPATHLEN); + ACE_OS::unlink (this->rendezvous); + sucd.set (this->rendezvous); + if (this->open (sucd) == -1) + ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("open")), -1); + else if (ACE_Reactor::instance ()->register_handler + (this, ACE_Event_Handler::ACCEPT_MASK) == -1) + ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), + ACE_TEXT ("registering service with ACE_Reactor")), + -1); + return 0; +} + +ACE_INLINE int +Handle_L_CODgram::fini(void) +{ + return ACE_Reactor::instance ()->remove_handler + (this, ACE_Event_Handler::ACCEPT_MASK); +} + +ACE_INLINE ACE_HANDLE +Handle_L_CODgram::get_handle (void) const +{ + return ACE_LSOCK_CODgram::get_handle (); +} + +ACE_INLINE int +Handle_L_CODgram::handle_input (ACE_HANDLE) +{ + ACE_HANDLE handle = ACE_INVALID_HANDLE; + char buf[BUFSIZ]; + + if (this->recv_handle (handle) == -1) + return -1; + else + ACE_DEBUG ((LM_INFO, ACE_TEXT ("received handle (%d)\n"), handle)); + + ACE_OS::puts ("----------------------------------------"); + + for (;;) + { + ssize_t n = ACE_OS::read (handle, buf, sizeof buf); + + if (n <= 0) + break; + + ACE_OS::write (ACE_STDOUT, buf, n); + } + + ACE_OS::puts ("----------------------------------------"); + + if (ACE_OS::close (handle) == -1) + return -1; + + return 0; +} + +ACE_INLINE int +Handle_L_CODgram::handle_close (ACE_HANDLE, ACE_Reactor_Mask) +{ + this->ACE_LSOCK_CODgram::close (); + return ACE_OS::unlink (this->rendezvous); +} diff --git a/ACE/examples/Service_Configurator/IPC-tests/server/Handle_L_Dgram.cpp b/ACE/examples/Service_Configurator/IPC-tests/server/Handle_L_Dgram.cpp index c502da057f7..606f6f014fc 100644 --- a/ACE/examples/Service_Configurator/IPC-tests/server/Handle_L_Dgram.cpp +++ b/ACE/examples/Service_Configurator/IPC-tests/server/Handle_L_Dgram.cpp @@ -10,7 +10,7 @@ const ACE_TCHAR *Handle_L_Dgram::DEFAULT_RENDEZVOUS = ACE_TEXT ("/tmp/foo_dgram"); #if !defined (__ACE_INLINE__) -#include "Handle_L_Dgram.i" +#include "Handle_L_Dgram.inl" #endif /* __ACE_INLINE__ */ Handle_L_Dgram local_dgram; diff --git a/ACE/examples/Service_Configurator/IPC-tests/server/Handle_L_Dgram.h b/ACE/examples/Service_Configurator/IPC-tests/server/Handle_L_Dgram.h index ac1eac69117..b9fdc6324c0 100644 --- a/ACE/examples/Service_Configurator/IPC-tests/server/Handle_L_Dgram.h +++ b/ACE/examples/Service_Configurator/IPC-tests/server/Handle_L_Dgram.h @@ -42,7 +42,7 @@ extern ACE_Service_Object_Type ld; #if defined (__ACE_INLINE__) #define ACE_INLINE inline -#include "Handle_L_Dgram.i" +#include "Handle_L_Dgram.inl" #else #define ACE_INLINE #endif /* __ACE_INLINE__ */ diff --git a/ACE/examples/Service_Configurator/IPC-tests/server/Handle_L_Dgram.i b/ACE/examples/Service_Configurator/IPC-tests/server/Handle_L_Dgram.i deleted file mode 100644 index 3b2ab29331f..00000000000 --- a/ACE/examples/Service_Configurator/IPC-tests/server/Handle_L_Dgram.i +++ /dev/null @@ -1,116 +0,0 @@ -/* -*- C++ -*- */ -// $Id$ - -#include "ace/Get_Opt.h" -#include "ace/OS_NS_stdio.h" -#include "ace/OS_NS_string.h" -#include "ace/OS_NS_unistd.h" - -ACE_INLINE -Handle_L_Dgram::Handle_L_Dgram (void) -{ -} - -ACE_INLINE int -Handle_L_Dgram::open (const ACE_UNIX_Addr &suad, int async) -{ - if (this->ACE_LSOCK_Dgram::open (suad) == -1) - return -1; - else if (async && this->ACE_LSOCK_Dgram::enable (ACE_SIGIO) == -1) - return -1; - else - return 0; -} - -ACE_INLINE int -Handle_L_Dgram::info (ACE_TCHAR **strp, size_t length) const -{ - ACE_TCHAR buf[BUFSIZ]; - ACE_UNIX_Addr sa; - - if (this->ACE_LSOCK_Dgram::get_local_addr (sa) == -1) - return -1; - - ACE_OS::strcpy (buf, ACE_TEXT_CHAR_TO_TCHAR (sa.get_path_name ())); - ACE_OS::strcat (buf, ACE_TEXT (" # tests local datagram\n")); - - if (*strp == 0 && (*strp = ACE_OS::strdup (buf)) == 0) - return -1; - else - ACE_OS::strncpy (*strp, buf, length); - return ACE_OS::strlen (buf); -} - -ACE_INLINE int -Handle_L_Dgram::init (int argc, ACE_TCHAR *argv[]) -{ - ACE_UNIX_Addr sudg; - ACE_Get_Opt get_opt (argc, argv, ACE_TEXT ("r:"), 0); - const ACE_TCHAR *r = Handle_L_Dgram::DEFAULT_RENDEZVOUS; - - for (int c; (c = get_opt ()) != -1; ) - switch (c) - { - case 'r': - r = get_opt.opt_arg (); - break; - default: - break; - } - - ACE_OS::strncpy (this->rendezvous, r, MAXPATHLEN); - ACE_OS::unlink (this->rendezvous); - sudg.set (this->rendezvous); - if (this->open (sudg) == -1) - ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("open")), -1); - else if (ACE_Reactor::instance ()->register_handler (this, - ACE_Event_Handler::ACCEPT_MASK) == -1) - ACE_ERROR_RETURN ((LM_ERROR, - ACE_TEXT ("%p\n"), - ACE_TEXT ("registering service with ACE_Reactor")), - -1); - return 0; -} - -ACE_INLINE int -Handle_L_Dgram::fini (void) -{ - return ACE_Reactor::instance ()->remove_handler (this, ACE_Event_Handler::ACCEPT_MASK); -} - -ACE_INLINE int -Handle_L_Dgram::get_handle (void) const -{ - return this->ACE_LSOCK_Dgram::get_handle (); -} - -ACE_INLINE int -Handle_L_Dgram::handle_input (int) -{ - ACE_UNIX_Addr sa; - char buf[8 * 1024]; /* 8 k buffer */ - int n; - - if ((n = this->recv (buf, sizeof buf, sa)) == -1) - return -1; - else - ACE_DEBUG ((LM_INFO, ACE_TEXT ("received datagram from %s\n"), - sa.get_path_name ())); - - ACE_OS::puts ("----------------------------------------"); - ACE_OS::write (ACE_STDOUT, buf, n); - - if (buf[n - 1] != '\n') - putchar ('\n'); - - ACE_OS::puts ("----------------------------------------"); - - return 0; -} - -ACE_INLINE int -Handle_L_Dgram::handle_close (int, ACE_Reactor_Mask) -{ - this->ACE_LSOCK_Dgram::close (); - return ACE_OS::unlink (this->rendezvous); -} diff --git a/ACE/examples/Service_Configurator/IPC-tests/server/Handle_L_Dgram.inl b/ACE/examples/Service_Configurator/IPC-tests/server/Handle_L_Dgram.inl new file mode 100644 index 00000000000..3b2ab29331f --- /dev/null +++ b/ACE/examples/Service_Configurator/IPC-tests/server/Handle_L_Dgram.inl @@ -0,0 +1,116 @@ +/* -*- C++ -*- */ +// $Id$ + +#include "ace/Get_Opt.h" +#include "ace/OS_NS_stdio.h" +#include "ace/OS_NS_string.h" +#include "ace/OS_NS_unistd.h" + +ACE_INLINE +Handle_L_Dgram::Handle_L_Dgram (void) +{ +} + +ACE_INLINE int +Handle_L_Dgram::open (const ACE_UNIX_Addr &suad, int async) +{ + if (this->ACE_LSOCK_Dgram::open (suad) == -1) + return -1; + else if (async && this->ACE_LSOCK_Dgram::enable (ACE_SIGIO) == -1) + return -1; + else + return 0; +} + +ACE_INLINE int +Handle_L_Dgram::info (ACE_TCHAR **strp, size_t length) const +{ + ACE_TCHAR buf[BUFSIZ]; + ACE_UNIX_Addr sa; + + if (this->ACE_LSOCK_Dgram::get_local_addr (sa) == -1) + return -1; + + ACE_OS::strcpy (buf, ACE_TEXT_CHAR_TO_TCHAR (sa.get_path_name ())); + ACE_OS::strcat (buf, ACE_TEXT (" # tests local datagram\n")); + + if (*strp == 0 && (*strp = ACE_OS::strdup (buf)) == 0) + return -1; + else + ACE_OS::strncpy (*strp, buf, length); + return ACE_OS::strlen (buf); +} + +ACE_INLINE int +Handle_L_Dgram::init (int argc, ACE_TCHAR *argv[]) +{ + ACE_UNIX_Addr sudg; + ACE_Get_Opt get_opt (argc, argv, ACE_TEXT ("r:"), 0); + const ACE_TCHAR *r = Handle_L_Dgram::DEFAULT_RENDEZVOUS; + + for (int c; (c = get_opt ()) != -1; ) + switch (c) + { + case 'r': + r = get_opt.opt_arg (); + break; + default: + break; + } + + ACE_OS::strncpy (this->rendezvous, r, MAXPATHLEN); + ACE_OS::unlink (this->rendezvous); + sudg.set (this->rendezvous); + if (this->open (sudg) == -1) + ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("open")), -1); + else if (ACE_Reactor::instance ()->register_handler (this, + ACE_Event_Handler::ACCEPT_MASK) == -1) + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("%p\n"), + ACE_TEXT ("registering service with ACE_Reactor")), + -1); + return 0; +} + +ACE_INLINE int +Handle_L_Dgram::fini (void) +{ + return ACE_Reactor::instance ()->remove_handler (this, ACE_Event_Handler::ACCEPT_MASK); +} + +ACE_INLINE int +Handle_L_Dgram::get_handle (void) const +{ + return this->ACE_LSOCK_Dgram::get_handle (); +} + +ACE_INLINE int +Handle_L_Dgram::handle_input (int) +{ + ACE_UNIX_Addr sa; + char buf[8 * 1024]; /* 8 k buffer */ + int n; + + if ((n = this->recv (buf, sizeof buf, sa)) == -1) + return -1; + else + ACE_DEBUG ((LM_INFO, ACE_TEXT ("received datagram from %s\n"), + sa.get_path_name ())); + + ACE_OS::puts ("----------------------------------------"); + ACE_OS::write (ACE_STDOUT, buf, n); + + if (buf[n - 1] != '\n') + putchar ('\n'); + + ACE_OS::puts ("----------------------------------------"); + + return 0; +} + +ACE_INLINE int +Handle_L_Dgram::handle_close (int, ACE_Reactor_Mask) +{ + this->ACE_LSOCK_Dgram::close (); + return ACE_OS::unlink (this->rendezvous); +} diff --git a/ACE/examples/Service_Configurator/IPC-tests/server/Handle_L_FIFO.cpp b/ACE/examples/Service_Configurator/IPC-tests/server/Handle_L_FIFO.cpp index 609f7b3c24f..3be991cc36e 100644 --- a/ACE/examples/Service_Configurator/IPC-tests/server/Handle_L_FIFO.cpp +++ b/ACE/examples/Service_Configurator/IPC-tests/server/Handle_L_FIFO.cpp @@ -31,7 +31,7 @@ fini (void) const ACE_TCHAR *Handle_L_FIFO::DEFAULT_RENDEZVOUS = ACE_TEXT("/tmp/foo_fifo"); #if !defined (__ACE_INLINE__) -#include "Handle_L_FIFO.i" +#include "Handle_L_FIFO.inl" #endif /* __ACE_INLINE__ */ Handle_L_FIFO local_fifo; diff --git a/ACE/examples/Service_Configurator/IPC-tests/server/Handle_L_FIFO.h b/ACE/examples/Service_Configurator/IPC-tests/server/Handle_L_FIFO.h index 4375b2d105c..fcd51a43a1a 100644 --- a/ACE/examples/Service_Configurator/IPC-tests/server/Handle_L_FIFO.h +++ b/ACE/examples/Service_Configurator/IPC-tests/server/Handle_L_FIFO.h @@ -41,7 +41,7 @@ extern ACE_Service_Object_Type lf; #if defined (__ACE_INLINE__) #define ACE_INLINE inline -#include "Handle_L_FIFO.i" +#include "Handle_L_FIFO.inl" #else #define ACE_INLINE #endif /* __ACE_INLINE__ */ diff --git a/ACE/examples/Service_Configurator/IPC-tests/server/Handle_L_FIFO.i b/ACE/examples/Service_Configurator/IPC-tests/server/Handle_L_FIFO.i deleted file mode 100644 index f6cd0cda734..00000000000 --- a/ACE/examples/Service_Configurator/IPC-tests/server/Handle_L_FIFO.i +++ /dev/null @@ -1,101 +0,0 @@ -/* -*- C++ -*- */ -// $Id$ - -#include "ace/Get_Opt.h" -#include "ace/OS_NS_stdio.h" -#include "ace/OS_NS_string.h" -#include "ace/OS_NS_stropts.h" -#include "ace/OS_NS_unistd.h" - -ACE_INLINE -Handle_L_FIFO::Handle_L_FIFO (void) -{ -} - -ACE_INLINE int -Handle_L_FIFO::open (const ACE_TCHAR *rendezvous_fifo) -{ - if (this->ACE_FIFO_Recv_Msg::open (rendezvous_fifo) == -1) - return -1; - else - return 0; -} - -ACE_INLINE int -Handle_L_FIFO::info (ACE_TCHAR **strp, size_t length) const -{ - ACE_TCHAR buf[BUFSIZ]; - const ACE_TCHAR *rendezvous_fifo; - - this->get_local_addr (rendezvous_fifo); - - ACE_OS::strcpy (buf, rendezvous_fifo); - ACE_OS::strcat (buf, ACE_TEXT(" # tests local ACE_FIFO\n")); - - if (*strp == 0 && (*strp = ACE_OS::strdup (buf)) == 0) - return -1; - else - ACE_OS::strncpy (*strp, buf, length); - return ACE_OS::strlen (buf); -} - -ACE_INLINE int -Handle_L_FIFO::init (int argc, ACE_TCHAR *argv[]) -{ - const ACE_TCHAR *rendezvous_fifo = Handle_L_FIFO::DEFAULT_RENDEZVOUS; - ACE_Get_Opt get_opt (argc, argv, ACE_TEXT("r:"), 0); - - for (int c; (c = get_opt ()) != -1; ) - switch (c) - { - case 'r': - rendezvous_fifo = get_opt.opt_arg (); - break; - default: - break; - } - - ACE_OS::unlink (rendezvous_fifo); - if (this->open (rendezvous_fifo) == -1) - ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("open")), -1); - else if (ACE_Reactor::instance ()->register_handler - (this, ACE_Event_Handler::READ_MASK) == -1) - ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), - ACE_TEXT ("registering service with ACE_Reactor")), - -1); - return 0; -} - -ACE_INLINE int -Handle_L_FIFO::fini (void) -{ - return ACE_Reactor::instance ()->remove_handler - (this, ACE_Event_Handler::ACCEPT_MASK); -} - -ACE_INLINE ACE_HANDLE -Handle_L_FIFO::get_handle (void) const -{ - return this->ACE_FIFO::get_handle (); -} - -ACE_INLINE int -Handle_L_FIFO::handle_input (ACE_HANDLE) -{ - char buf[PIPE_BUF]; - ACE_Str_Buf msg (buf, 0, sizeof buf); - - /* Accept communication requests */ - if (this->recv (msg) == -1) - return -1; - else - - ACE_OS::write (ACE_STDOUT, (const char *) msg.buf, (int) msg.len); - return 0; -} - -ACE_INLINE int -Handle_L_FIFO::handle_close (ACE_HANDLE, ACE_Reactor_Mask) -{ - return this->ACE_FIFO::remove (); -} diff --git a/ACE/examples/Service_Configurator/IPC-tests/server/Handle_L_FIFO.inl b/ACE/examples/Service_Configurator/IPC-tests/server/Handle_L_FIFO.inl new file mode 100644 index 00000000000..f6cd0cda734 --- /dev/null +++ b/ACE/examples/Service_Configurator/IPC-tests/server/Handle_L_FIFO.inl @@ -0,0 +1,101 @@ +/* -*- C++ -*- */ +// $Id$ + +#include "ace/Get_Opt.h" +#include "ace/OS_NS_stdio.h" +#include "ace/OS_NS_string.h" +#include "ace/OS_NS_stropts.h" +#include "ace/OS_NS_unistd.h" + +ACE_INLINE +Handle_L_FIFO::Handle_L_FIFO (void) +{ +} + +ACE_INLINE int +Handle_L_FIFO::open (const ACE_TCHAR *rendezvous_fifo) +{ + if (this->ACE_FIFO_Recv_Msg::open (rendezvous_fifo) == -1) + return -1; + else + return 0; +} + +ACE_INLINE int +Handle_L_FIFO::info (ACE_TCHAR **strp, size_t length) const +{ + ACE_TCHAR buf[BUFSIZ]; + const ACE_TCHAR *rendezvous_fifo; + + this->get_local_addr (rendezvous_fifo); + + ACE_OS::strcpy (buf, rendezvous_fifo); + ACE_OS::strcat (buf, ACE_TEXT(" # tests local ACE_FIFO\n")); + + if (*strp == 0 && (*strp = ACE_OS::strdup (buf)) == 0) + return -1; + else + ACE_OS::strncpy (*strp, buf, length); + return ACE_OS::strlen (buf); +} + +ACE_INLINE int +Handle_L_FIFO::init (int argc, ACE_TCHAR *argv[]) +{ + const ACE_TCHAR *rendezvous_fifo = Handle_L_FIFO::DEFAULT_RENDEZVOUS; + ACE_Get_Opt get_opt (argc, argv, ACE_TEXT("r:"), 0); + + for (int c; (c = get_opt ()) != -1; ) + switch (c) + { + case 'r': + rendezvous_fifo = get_opt.opt_arg (); + break; + default: + break; + } + + ACE_OS::unlink (rendezvous_fifo); + if (this->open (rendezvous_fifo) == -1) + ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("open")), -1); + else if (ACE_Reactor::instance ()->register_handler + (this, ACE_Event_Handler::READ_MASK) == -1) + ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), + ACE_TEXT ("registering service with ACE_Reactor")), + -1); + return 0; +} + +ACE_INLINE int +Handle_L_FIFO::fini (void) +{ + return ACE_Reactor::instance ()->remove_handler + (this, ACE_Event_Handler::ACCEPT_MASK); +} + +ACE_INLINE ACE_HANDLE +Handle_L_FIFO::get_handle (void) const +{ + return this->ACE_FIFO::get_handle (); +} + +ACE_INLINE int +Handle_L_FIFO::handle_input (ACE_HANDLE) +{ + char buf[PIPE_BUF]; + ACE_Str_Buf msg (buf, 0, sizeof buf); + + /* Accept communication requests */ + if (this->recv (msg) == -1) + return -1; + else + + ACE_OS::write (ACE_STDOUT, (const char *) msg.buf, (int) msg.len); + return 0; +} + +ACE_INLINE int +Handle_L_FIFO::handle_close (ACE_HANDLE, ACE_Reactor_Mask) +{ + return this->ACE_FIFO::remove (); +} diff --git a/ACE/examples/Service_Configurator/IPC-tests/server/Handle_L_Pipe.cpp b/ACE/examples/Service_Configurator/IPC-tests/server/Handle_L_Pipe.cpp index a4508266363..ebd5d618f41 100644 --- a/ACE/examples/Service_Configurator/IPC-tests/server/Handle_L_Pipe.cpp +++ b/ACE/examples/Service_Configurator/IPC-tests/server/Handle_L_Pipe.cpp @@ -57,7 +57,7 @@ Handle_L_Pipe::handle_input (ACE_HANDLE) const ACE_TCHAR *Handle_L_Pipe::DEFAULT_RENDEZVOUS = ACE_TEXT ("/tmp/foo_pipe"); #if !defined (__ACE_INLINE__) -#include "Handle_L_Pipe.i" +#include "Handle_L_Pipe.inl" #endif /* __ACE_INLINE__ */ Handle_L_Pipe local_pipe; diff --git a/ACE/examples/Service_Configurator/IPC-tests/server/Handle_L_Pipe.h b/ACE/examples/Service_Configurator/IPC-tests/server/Handle_L_Pipe.h index 51d5bae1dac..5f6fac87ecf 100644 --- a/ACE/examples/Service_Configurator/IPC-tests/server/Handle_L_Pipe.h +++ b/ACE/examples/Service_Configurator/IPC-tests/server/Handle_L_Pipe.h @@ -46,7 +46,7 @@ extern ACE_Service_Object_Type lp; #if defined (__ACE_INLINE__) #define ACE_INLINE inline -#include "Handle_L_Pipe.i" +#include "Handle_L_Pipe.inl" #else #define ACE_INLINE #endif /* __ACE_INLINE__ */ diff --git a/ACE/examples/Service_Configurator/IPC-tests/server/Handle_L_Pipe.i b/ACE/examples/Service_Configurator/IPC-tests/server/Handle_L_Pipe.i deleted file mode 100644 index ce978aa85ea..00000000000 --- a/ACE/examples/Service_Configurator/IPC-tests/server/Handle_L_Pipe.i +++ /dev/null @@ -1,96 +0,0 @@ -/* -*- C++ -*- */ -// $Id$ - -#include "ace/Get_Opt.h" -#include "ace/OS_NS_stdio.h" -#include "ace/OS_NS_string.h" -#include "ace/OS_NS_unistd.h" - -ACE_INLINE -Handle_L_Pipe::~Handle_L_Pipe (void) -{ -} - -ACE_INLINE -Handle_L_Pipe::Handle_L_Pipe (void) -{ -} - -ACE_INLINE int -Handle_L_Pipe::open (const ACE_UNIX_Addr &suap, int async) -{ - if (this->ACE_LSOCK_Acceptor::open (suap) == -1) - return -1; - else if (async && this->ACE_LSOCK_Acceptor::enable (ACE_SIGIO) == -1) - return -1; - else - return 0; -} - -ACE_INLINE int -Handle_L_Pipe::info (ACE_TCHAR **strp, size_t length) const -{ - ACE_TCHAR buf[BUFSIZ]; - ACE_UNIX_Addr sa; - - if (ACE_LSOCK_Acceptor::get_local_addr (sa) == -1) - return -1; - - ACE_OS::strcpy (buf, ACE_TEXT_CHAR_TO_TCHAR (sa.get_path_name ())); - ACE_OS::strcat (buf, ACE_TEXT (" # tests local pipe\n")); - - if (*strp == 0 && (*strp = ACE_OS::strdup (buf)) == 0) - return -1; - else - ACE_OS::strncpy (*strp, buf, length); - return ACE_OS::strlen (buf); -} - -ACE_INLINE int -Handle_L_Pipe::init (int argc, ACE_TCHAR *argv[]) -{ - ACE_UNIX_Addr sup; - const ACE_TCHAR *r = Handle_L_Pipe::DEFAULT_RENDEZVOUS; - ACE_Get_Opt get_opt (argc, argv, ACE_TEXT ("r:"), 0); - - for (int c; (c = get_opt ()) != -1; ) - switch (c) - { - case 'r': - r = get_opt.opt_arg (); - break; - default: - break; - } - - ACE_OS::strncpy (this->rendezvous, r, MAXPATHLEN); - ACE_OS::unlink (this->rendezvous); - sup.set (this->rendezvous); - if (this->open (sup) == -1) - ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("open")), -1); - else if (ACE_Reactor::instance ()->register_handler - (this, ACE_Event_Handler::ACCEPT_MASK) == -1) - ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), - ACE_TEXT ("registering service with ACE_Reactor")), -1); - return 0; -} - -ACE_INLINE int -Handle_L_Pipe::fini (void) -{ - return ACE_Reactor::instance ()->remove_handler - (this, ACE_Event_Handler::ACCEPT_MASK); -} - -ACE_INLINE int -Handle_L_Pipe::get_handle (void) const -{ - return ACE_LSOCK_Acceptor::get_handle (); -} - -ACE_INLINE int -Handle_L_Pipe::handle_close (ACE_HANDLE, ACE_Reactor_Mask) -{ - this->ACE_LSOCK_Acceptor::close (); - return ACE_OS::unlink (this->rendezvous); -} diff --git a/ACE/examples/Service_Configurator/IPC-tests/server/Handle_L_Pipe.inl b/ACE/examples/Service_Configurator/IPC-tests/server/Handle_L_Pipe.inl new file mode 100644 index 00000000000..ce978aa85ea --- /dev/null +++ b/ACE/examples/Service_Configurator/IPC-tests/server/Handle_L_Pipe.inl @@ -0,0 +1,96 @@ +/* -*- C++ -*- */ +// $Id$ + +#include "ace/Get_Opt.h" +#include "ace/OS_NS_stdio.h" +#include "ace/OS_NS_string.h" +#include "ace/OS_NS_unistd.h" + +ACE_INLINE +Handle_L_Pipe::~Handle_L_Pipe (void) +{ +} + +ACE_INLINE +Handle_L_Pipe::Handle_L_Pipe (void) +{ +} + +ACE_INLINE int +Handle_L_Pipe::open (const ACE_UNIX_Addr &suap, int async) +{ + if (this->ACE_LSOCK_Acceptor::open (suap) == -1) + return -1; + else if (async && this->ACE_LSOCK_Acceptor::enable (ACE_SIGIO) == -1) + return -1; + else + return 0; +} + +ACE_INLINE int +Handle_L_Pipe::info (ACE_TCHAR **strp, size_t length) const +{ + ACE_TCHAR buf[BUFSIZ]; + ACE_UNIX_Addr sa; + + if (ACE_LSOCK_Acceptor::get_local_addr (sa) == -1) + return -1; + + ACE_OS::strcpy (buf, ACE_TEXT_CHAR_TO_TCHAR (sa.get_path_name ())); + ACE_OS::strcat (buf, ACE_TEXT (" # tests local pipe\n")); + + if (*strp == 0 && (*strp = ACE_OS::strdup (buf)) == 0) + return -1; + else + ACE_OS::strncpy (*strp, buf, length); + return ACE_OS::strlen (buf); +} + +ACE_INLINE int +Handle_L_Pipe::init (int argc, ACE_TCHAR *argv[]) +{ + ACE_UNIX_Addr sup; + const ACE_TCHAR *r = Handle_L_Pipe::DEFAULT_RENDEZVOUS; + ACE_Get_Opt get_opt (argc, argv, ACE_TEXT ("r:"), 0); + + for (int c; (c = get_opt ()) != -1; ) + switch (c) + { + case 'r': + r = get_opt.opt_arg (); + break; + default: + break; + } + + ACE_OS::strncpy (this->rendezvous, r, MAXPATHLEN); + ACE_OS::unlink (this->rendezvous); + sup.set (this->rendezvous); + if (this->open (sup) == -1) + ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("open")), -1); + else if (ACE_Reactor::instance ()->register_handler + (this, ACE_Event_Handler::ACCEPT_MASK) == -1) + ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), + ACE_TEXT ("registering service with ACE_Reactor")), -1); + return 0; +} + +ACE_INLINE int +Handle_L_Pipe::fini (void) +{ + return ACE_Reactor::instance ()->remove_handler + (this, ACE_Event_Handler::ACCEPT_MASK); +} + +ACE_INLINE int +Handle_L_Pipe::get_handle (void) const +{ + return ACE_LSOCK_Acceptor::get_handle (); +} + +ACE_INLINE int +Handle_L_Pipe::handle_close (ACE_HANDLE, ACE_Reactor_Mask) +{ + this->ACE_LSOCK_Acceptor::close (); + return ACE_OS::unlink (this->rendezvous); +} diff --git a/ACE/examples/Service_Configurator/IPC-tests/server/Handle_L_SPIPE.cpp b/ACE/examples/Service_Configurator/IPC-tests/server/Handle_L_SPIPE.cpp index 9bbb4e7ead7..fcdc2b7f0bf 100644 --- a/ACE/examples/Service_Configurator/IPC-tests/server/Handle_L_SPIPE.cpp +++ b/ACE/examples/Service_Configurator/IPC-tests/server/Handle_L_SPIPE.cpp @@ -5,7 +5,7 @@ ACE_RCSID(server, Handle_L_SPIPE, "$Id$") #if !defined (__ACE_INLINE__) -#include "Handle_L_SPIPE.i" +#include "Handle_L_SPIPE.inl" #endif /* __ACE_INLINE__ */ #if defined (ACE_HAS_STREAM_PIPES) diff --git a/ACE/examples/Service_Configurator/IPC-tests/server/Handle_L_SPIPE.h b/ACE/examples/Service_Configurator/IPC-tests/server/Handle_L_SPIPE.h index 02a4aba2044..baa8d89ea8f 100644 --- a/ACE/examples/Service_Configurator/IPC-tests/server/Handle_L_SPIPE.h +++ b/ACE/examples/Service_Configurator/IPC-tests/server/Handle_L_SPIPE.h @@ -41,7 +41,7 @@ extern ACE_Service_Object_Type lsp; #if defined (__ACE_INLINE__) #define ACE_INLINE inline -#include "Handle_L_SPIPE.i" +#include "Handle_L_SPIPE.inl" #else #define ACE_INLINE #endif /* __ACE_INLINE__ */ diff --git a/ACE/examples/Service_Configurator/IPC-tests/server/Handle_L_SPIPE.i b/ACE/examples/Service_Configurator/IPC-tests/server/Handle_L_SPIPE.i deleted file mode 100644 index 910938d8648..00000000000 --- a/ACE/examples/Service_Configurator/IPC-tests/server/Handle_L_SPIPE.i +++ /dev/null @@ -1,131 +0,0 @@ -// -*- C++ -*- -// -// $Id$ - - -#include "ace/SPIPE_Stream.h" - -#if defined (ACE_HAS_STREAM_PIPES) - -#include "ace/Reactor.h" -#include "ace/Get_Opt.h" -#include "ace/OS_NS_stdio.h" -#include "ace/OS_NS_unistd.h" -#include "ace/OS_NS_string.h" - - -ACE_INLINE -Handle_L_SPIPE::Handle_L_SPIPE (void) -{ -} - -ACE_INLINE int -Handle_L_SPIPE::open (const ACE_SPIPE_Addr &rendezvous_spipe) -{ - if (this->ACE_SPIPE_Acceptor::open (rendezvous_spipe) == -1) - return -1; - else - return 0; -} - -ACE_INLINE int -Handle_L_SPIPE::info (ACE_TCHAR **strp, size_t length) const -{ - ACE_TCHAR buf[BUFSIZ]; - ACE_SPIPE_Addr sa; - - if (ACE_SPIPE_Acceptor::get_local_addr (sa) == -1) - return -1; - - ACE_OS::strcpy (buf, sa.get_path_name ()); - ACE_OS::strcat (buf, ACE_TEXT (" # tests local STREAM pipe\n")); - - if (*strp == 0 && (*strp = ACE_OS::strdup (buf)) == 0) - return -1; - else - ACE_OS::strncpy (*strp, buf, length); - return ACE_OS::strlen (buf); -} - -ACE_INLINE int -Handle_L_SPIPE::init (int argc, ACE_TCHAR *argv[]) -{ - ACE_SPIPE_Addr susp; - const ACE_TCHAR *rendezvous = Handle_L_SPIPE::DEFAULT_RENDEZVOUS; - ACE_Get_Opt get_opt (argc, argv, ACE_TEXT ("r:"), 0); - - for (int c; (c = get_opt ()) != -1; ) - switch (c) - { - case 'r': - rendezvous = get_opt.opt_arg (); - break; - default: - break; - } - - ACE_OS::unlink (rendezvous); - susp.set (rendezvous); - if (this->open (susp) == -1) - ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("open")), -1); - else if (ACE_Reactor::instance ()->register_handler - (this, ACE_Event_Handler::ACCEPT_MASK) == -1) - ACE_ERROR_RETURN ((LM_ERROR, - ACE_TEXT ("%p\n"), - ACE_TEXT ("registering service with ACE_Reactor")), - -1); - return 0; -} - -ACE_INLINE int -Handle_L_SPIPE::fini (void) -{ - return ACE_Reactor::instance ()->remove_handler - (this, ACE_Event_Handler::ACCEPT_MASK); -} - -ACE_INLINE int -Handle_L_SPIPE::get_handle (void) const -{ - return ACE_SPIPE::get_handle(); -} - -ACE_INLINE int -Handle_L_SPIPE::handle_input (int) -{ - ACE_SPIPE_Stream new_spipe; - char buf[PIPE_BUF]; - ACE_Str_Buf msg (buf, 0, sizeof buf); - int flags = 0; - - /* Accept communication requests */ - if (this->ACE_SPIPE_Acceptor::accept (new_spipe) == -1) - return -1; - else - { - ACE_SPIPE_Addr sa; - - new_spipe.get_remote_addr (sa); - - ACE_DEBUG ((LM_INFO, - ACE_TEXT ("accepted request from %s (gid = %d, uid = %d)\n"), - sa.get_path_name (), sa.group_id (), sa.user_id ())); - } - - while (new_spipe.recv ((ACE_Str_Buf *) 0, &msg, &flags) >= 0) - if (msg.len != 0) - ACE_OS::write (ACE_STDOUT, (const char *) msg.buf, (int) msg.len); - else - break; - - if (new_spipe.close () == -1) - return -1; - return 0; -} - -ACE_INLINE int -Handle_L_SPIPE::handle_close (int, ACE_Reactor_Mask) -{ - return this->ACE_SPIPE_Acceptor::remove (); -} -#endif /* ACE_HAS_STREAM_PIPES */ diff --git a/ACE/examples/Service_Configurator/IPC-tests/server/Handle_L_SPIPE.inl b/ACE/examples/Service_Configurator/IPC-tests/server/Handle_L_SPIPE.inl new file mode 100644 index 00000000000..910938d8648 --- /dev/null +++ b/ACE/examples/Service_Configurator/IPC-tests/server/Handle_L_SPIPE.inl @@ -0,0 +1,131 @@ +// -*- C++ -*- +// +// $Id$ + + +#include "ace/SPIPE_Stream.h" + +#if defined (ACE_HAS_STREAM_PIPES) + +#include "ace/Reactor.h" +#include "ace/Get_Opt.h" +#include "ace/OS_NS_stdio.h" +#include "ace/OS_NS_unistd.h" +#include "ace/OS_NS_string.h" + + +ACE_INLINE +Handle_L_SPIPE::Handle_L_SPIPE (void) +{ +} + +ACE_INLINE int +Handle_L_SPIPE::open (const ACE_SPIPE_Addr &rendezvous_spipe) +{ + if (this->ACE_SPIPE_Acceptor::open (rendezvous_spipe) == -1) + return -1; + else + return 0; +} + +ACE_INLINE int +Handle_L_SPIPE::info (ACE_TCHAR **strp, size_t length) const +{ + ACE_TCHAR buf[BUFSIZ]; + ACE_SPIPE_Addr sa; + + if (ACE_SPIPE_Acceptor::get_local_addr (sa) == -1) + return -1; + + ACE_OS::strcpy (buf, sa.get_path_name ()); + ACE_OS::strcat (buf, ACE_TEXT (" # tests local STREAM pipe\n")); + + if (*strp == 0 && (*strp = ACE_OS::strdup (buf)) == 0) + return -1; + else + ACE_OS::strncpy (*strp, buf, length); + return ACE_OS::strlen (buf); +} + +ACE_INLINE int +Handle_L_SPIPE::init (int argc, ACE_TCHAR *argv[]) +{ + ACE_SPIPE_Addr susp; + const ACE_TCHAR *rendezvous = Handle_L_SPIPE::DEFAULT_RENDEZVOUS; + ACE_Get_Opt get_opt (argc, argv, ACE_TEXT ("r:"), 0); + + for (int c; (c = get_opt ()) != -1; ) + switch (c) + { + case 'r': + rendezvous = get_opt.opt_arg (); + break; + default: + break; + } + + ACE_OS::unlink (rendezvous); + susp.set (rendezvous); + if (this->open (susp) == -1) + ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("open")), -1); + else if (ACE_Reactor::instance ()->register_handler + (this, ACE_Event_Handler::ACCEPT_MASK) == -1) + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("%p\n"), + ACE_TEXT ("registering service with ACE_Reactor")), + -1); + return 0; +} + +ACE_INLINE int +Handle_L_SPIPE::fini (void) +{ + return ACE_Reactor::instance ()->remove_handler + (this, ACE_Event_Handler::ACCEPT_MASK); +} + +ACE_INLINE int +Handle_L_SPIPE::get_handle (void) const +{ + return ACE_SPIPE::get_handle(); +} + +ACE_INLINE int +Handle_L_SPIPE::handle_input (int) +{ + ACE_SPIPE_Stream new_spipe; + char buf[PIPE_BUF]; + ACE_Str_Buf msg (buf, 0, sizeof buf); + int flags = 0; + + /* Accept communication requests */ + if (this->ACE_SPIPE_Acceptor::accept (new_spipe) == -1) + return -1; + else + { + ACE_SPIPE_Addr sa; + + new_spipe.get_remote_addr (sa); + + ACE_DEBUG ((LM_INFO, + ACE_TEXT ("accepted request from %s (gid = %d, uid = %d)\n"), + sa.get_path_name (), sa.group_id (), sa.user_id ())); + } + + while (new_spipe.recv ((ACE_Str_Buf *) 0, &msg, &flags) >= 0) + if (msg.len != 0) + ACE_OS::write (ACE_STDOUT, (const char *) msg.buf, (int) msg.len); + else + break; + + if (new_spipe.close () == -1) + return -1; + return 0; +} + +ACE_INLINE int +Handle_L_SPIPE::handle_close (int, ACE_Reactor_Mask) +{ + return this->ACE_SPIPE_Acceptor::remove (); +} +#endif /* ACE_HAS_STREAM_PIPES */ diff --git a/ACE/examples/Service_Configurator/IPC-tests/server/Handle_L_Stream.cpp b/ACE/examples/Service_Configurator/IPC-tests/server/Handle_L_Stream.cpp index 074f0057e74..8a0a6a46033 100644 --- a/ACE/examples/Service_Configurator/IPC-tests/server/Handle_L_Stream.cpp +++ b/ACE/examples/Service_Configurator/IPC-tests/server/Handle_L_Stream.cpp @@ -13,7 +13,7 @@ char *Handle_L_Stream::login_name = 0; char Handle_L_Stream::login[ACE_MAX_USERID]; #if !defined (__ACE_INLINE__) -#include "Handle_L_Stream.i" +#include "Handle_L_Stream.inl" #endif /* __ACE_INLINE__ */ Handle_L_Stream local_stream; diff --git a/ACE/examples/Service_Configurator/IPC-tests/server/Handle_L_Stream.h b/ACE/examples/Service_Configurator/IPC-tests/server/Handle_L_Stream.h index 912af48a292..aa3840bfede 100644 --- a/ACE/examples/Service_Configurator/IPC-tests/server/Handle_L_Stream.h +++ b/ACE/examples/Service_Configurator/IPC-tests/server/Handle_L_Stream.h @@ -45,7 +45,7 @@ extern ACE_Service_Object_Type ls; #if defined (__ACE_INLINE__) #define ACE_INLINE inline -#include "Handle_L_Stream.i" +#include "Handle_L_Stream.inl" #else #define ACE_INLINE #endif /* __ACE_INLINE__ */ diff --git a/ACE/examples/Service_Configurator/IPC-tests/server/Handle_L_Stream.i b/ACE/examples/Service_Configurator/IPC-tests/server/Handle_L_Stream.i deleted file mode 100644 index 80b21852293..00000000000 --- a/ACE/examples/Service_Configurator/IPC-tests/server/Handle_L_Stream.i +++ /dev/null @@ -1,149 +0,0 @@ -/* -*- C++ -*- */ -// $Id$ - -#include "ace/Get_Opt.h" -#include "ace/OS_NS_stdio.h" -#include "ace/OS_NS_string.h" -#include "ace/OS_NS_time.h" -#include "ace/OS_NS_unistd.h" - -ACE_INLINE -Handle_L_Stream::~Handle_L_Stream (void) -{ -} - -ACE_INLINE -Handle_L_Stream::Handle_L_Stream (void) -{ - if (Handle_L_Stream::login_name == 0) - Handle_L_Stream::login_name = ACE_OS::cuserid (Handle_L_Stream::login); -} - -ACE_INLINE int -Handle_L_Stream::open (const ACE_UNIX_Addr &suas, - int async) -{ - if (this->ACE_LSOCK_Acceptor::open (suas) == -1) - return -1; - else if (async && this->ACE_LSOCK_Acceptor::enable (ACE_SIGIO) == -1) - return -1; - else - return 0; -} - -ACE_INLINE int -Handle_L_Stream::info (ACE_TCHAR **strp, size_t length) const -{ - ACE_TCHAR buf[BUFSIZ]; - ACE_UNIX_Addr sa; - - if (this->get_local_addr (sa) == -1) - return -1; - - ACE_OS::strcpy (buf, ACE_TEXT_CHAR_TO_TCHAR (sa.get_path_name ())); - ACE_OS::strcat (buf, ACE_TEXT (" # tests local ACE_Stream\n")); - - if (*strp == 0 && (*strp = ACE_OS::strdup (buf)) == 0) - return -1; - else - ACE_OS::strncpy (*strp, buf, length); - return ACE_OS::strlen (buf); -} - -ACE_INLINE int -Handle_L_Stream::init (int argc, ACE_TCHAR *argv[]) -{ - ACE_UNIX_Addr sus; - const ACE_TCHAR *r = Handle_L_Stream::DEFAULT_RENDEZVOUS; - ACE_Get_Opt get_opt (argc, argv, ACE_TEXT ("r:"), 0); - - for (int c; (c = get_opt ()) != -1; ) - switch (c) - { - case 'r': - r = get_opt.opt_arg (); - break; - default: - break; - } - - ACE_OS::strncpy (this->rendezvous, r, MAXPATHLEN); - ACE_OS::unlink (this->rendezvous); - sus.set (this->rendezvous); - - if (this->open (sus) == -1) - ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("open")), -1); - else if (ACE_Reactor::instance ()->register_handler - (this, ACE_Event_Handler::ACCEPT_MASK) == -1) - ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), - ACE_TEXT ("registering service with ACE_Reactor")), -1); - return 0; -} - -ACE_INLINE int -Handle_L_Stream::fini (void) -{ - return ACE_Reactor::instance ()->remove_handler - (this, ACE_Event_Handler::ACCEPT_MASK); -} - -ACE_INLINE ACE_HANDLE -Handle_L_Stream::get_handle (void) const -{ - return ACE_LSOCK_Acceptor::get_handle (); -} - -ACE_INLINE int -Handle_L_Stream::handle_input (ACE_HANDLE) -{ - ACE_LSOCK_Stream new_local_stream; - ACE_UNIX_Addr sa; - ACE_HANDLE handle = ACE_INVALID_HANDLE; - char buf[BUFSIZ]; - - if (this->accept (new_local_stream, &sa) == -1) - return -1; - else if (new_local_stream.recv_handle (handle) == -1) - return -1; - else - ACE_DEBUG ((LM_INFO, - ACE_TEXT ("received file descriptor %d on ACE_Stream %s\n"), - handle, sa.get_path_name ())); - - ACE_OS::puts ("----------------------------------------"); - - for (;;) - { - ssize_t n = ACE_OS::read (handle, buf, sizeof buf); - - if (n <= 0) - break; - - ACE_OS::write (ACE_STDOUT, buf, n); - } - - ACE_OS::puts ("----------------------------------------"); - - time_t t = ACE_OS::time (0L); - ACE_TCHAR *cs = ACE_OS::ctime (&t); - - if (new_local_stream.send (4, - Handle_L_Stream::login_name, - ACE_OS::strlen (Handle_L_Stream::login_name), - ACE_TEXT_ALWAYS_CHAR (cs), - ACE_OS::strlen (cs)) == -1) - return -1; - else if (ACE_OS::close (handle) == -1) - return -1; - else if (new_local_stream.close () == -1) - return -1; - else - return 0; -} - -ACE_INLINE int -Handle_L_Stream::handle_close (ACE_HANDLE, ACE_Reactor_Mask) -{ - this->ACE_LSOCK_Acceptor::close (); - return ACE_OS::unlink (this->rendezvous); -} diff --git a/ACE/examples/Service_Configurator/IPC-tests/server/Handle_L_Stream.inl b/ACE/examples/Service_Configurator/IPC-tests/server/Handle_L_Stream.inl new file mode 100644 index 00000000000..80b21852293 --- /dev/null +++ b/ACE/examples/Service_Configurator/IPC-tests/server/Handle_L_Stream.inl @@ -0,0 +1,149 @@ +/* -*- C++ -*- */ +// $Id$ + +#include "ace/Get_Opt.h" +#include "ace/OS_NS_stdio.h" +#include "ace/OS_NS_string.h" +#include "ace/OS_NS_time.h" +#include "ace/OS_NS_unistd.h" + +ACE_INLINE +Handle_L_Stream::~Handle_L_Stream (void) +{ +} + +ACE_INLINE +Handle_L_Stream::Handle_L_Stream (void) +{ + if (Handle_L_Stream::login_name == 0) + Handle_L_Stream::login_name = ACE_OS::cuserid (Handle_L_Stream::login); +} + +ACE_INLINE int +Handle_L_Stream::open (const ACE_UNIX_Addr &suas, + int async) +{ + if (this->ACE_LSOCK_Acceptor::open (suas) == -1) + return -1; + else if (async && this->ACE_LSOCK_Acceptor::enable (ACE_SIGIO) == -1) + return -1; + else + return 0; +} + +ACE_INLINE int +Handle_L_Stream::info (ACE_TCHAR **strp, size_t length) const +{ + ACE_TCHAR buf[BUFSIZ]; + ACE_UNIX_Addr sa; + + if (this->get_local_addr (sa) == -1) + return -1; + + ACE_OS::strcpy (buf, ACE_TEXT_CHAR_TO_TCHAR (sa.get_path_name ())); + ACE_OS::strcat (buf, ACE_TEXT (" # tests local ACE_Stream\n")); + + if (*strp == 0 && (*strp = ACE_OS::strdup (buf)) == 0) + return -1; + else + ACE_OS::strncpy (*strp, buf, length); + return ACE_OS::strlen (buf); +} + +ACE_INLINE int +Handle_L_Stream::init (int argc, ACE_TCHAR *argv[]) +{ + ACE_UNIX_Addr sus; + const ACE_TCHAR *r = Handle_L_Stream::DEFAULT_RENDEZVOUS; + ACE_Get_Opt get_opt (argc, argv, ACE_TEXT ("r:"), 0); + + for (int c; (c = get_opt ()) != -1; ) + switch (c) + { + case 'r': + r = get_opt.opt_arg (); + break; + default: + break; + } + + ACE_OS::strncpy (this->rendezvous, r, MAXPATHLEN); + ACE_OS::unlink (this->rendezvous); + sus.set (this->rendezvous); + + if (this->open (sus) == -1) + ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("open")), -1); + else if (ACE_Reactor::instance ()->register_handler + (this, ACE_Event_Handler::ACCEPT_MASK) == -1) + ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), + ACE_TEXT ("registering service with ACE_Reactor")), -1); + return 0; +} + +ACE_INLINE int +Handle_L_Stream::fini (void) +{ + return ACE_Reactor::instance ()->remove_handler + (this, ACE_Event_Handler::ACCEPT_MASK); +} + +ACE_INLINE ACE_HANDLE +Handle_L_Stream::get_handle (void) const +{ + return ACE_LSOCK_Acceptor::get_handle (); +} + +ACE_INLINE int +Handle_L_Stream::handle_input (ACE_HANDLE) +{ + ACE_LSOCK_Stream new_local_stream; + ACE_UNIX_Addr sa; + ACE_HANDLE handle = ACE_INVALID_HANDLE; + char buf[BUFSIZ]; + + if (this->accept (new_local_stream, &sa) == -1) + return -1; + else if (new_local_stream.recv_handle (handle) == -1) + return -1; + else + ACE_DEBUG ((LM_INFO, + ACE_TEXT ("received file descriptor %d on ACE_Stream %s\n"), + handle, sa.get_path_name ())); + + ACE_OS::puts ("----------------------------------------"); + + for (;;) + { + ssize_t n = ACE_OS::read (handle, buf, sizeof buf); + + if (n <= 0) + break; + + ACE_OS::write (ACE_STDOUT, buf, n); + } + + ACE_OS::puts ("----------------------------------------"); + + time_t t = ACE_OS::time (0L); + ACE_TCHAR *cs = ACE_OS::ctime (&t); + + if (new_local_stream.send (4, + Handle_L_Stream::login_name, + ACE_OS::strlen (Handle_L_Stream::login_name), + ACE_TEXT_ALWAYS_CHAR (cs), + ACE_OS::strlen (cs)) == -1) + return -1; + else if (ACE_OS::close (handle) == -1) + return -1; + else if (new_local_stream.close () == -1) + return -1; + else + return 0; +} + +ACE_INLINE int +Handle_L_Stream::handle_close (ACE_HANDLE, ACE_Reactor_Mask) +{ + this->ACE_LSOCK_Acceptor::close (); + return ACE_OS::unlink (this->rendezvous); +} diff --git a/ACE/examples/Service_Configurator/IPC-tests/server/Handle_R_Dgram.cpp b/ACE/examples/Service_Configurator/IPC-tests/server/Handle_R_Dgram.cpp index 0cab7190ca8..6b684f40e6b 100644 --- a/ACE/examples/Service_Configurator/IPC-tests/server/Handle_R_Dgram.cpp +++ b/ACE/examples/Service_Configurator/IPC-tests/server/Handle_R_Dgram.cpp @@ -31,7 +31,7 @@ fini (void) unsigned short Handle_R_Dgram::DEFAULT_PORT = ACE_DEFAULT_SERVER_PORT; #if !defined (__ACE_INLINE__) -#include "Handle_R_Dgram.i" +#include "Handle_R_Dgram.inl" #endif /* __ACE_INLINE__ */ Handle_R_Dgram remote_dgram; diff --git a/ACE/examples/Service_Configurator/IPC-tests/server/Handle_R_Dgram.h b/ACE/examples/Service_Configurator/IPC-tests/server/Handle_R_Dgram.h index 858d72ff993..e3ef8c0e802 100644 --- a/ACE/examples/Service_Configurator/IPC-tests/server/Handle_R_Dgram.h +++ b/ACE/examples/Service_Configurator/IPC-tests/server/Handle_R_Dgram.h @@ -39,7 +39,7 @@ extern ACE_Service_Object_Type rd; #if defined (__ACE_INLINE__) #define ACE_INLINE inline -#include "Handle_R_Dgram.i" +#include "Handle_R_Dgram.inl" #else #define ACE_INLINE #endif /* __ACE_INLINE__ */ diff --git a/ACE/examples/Service_Configurator/IPC-tests/server/Handle_R_Dgram.i b/ACE/examples/Service_Configurator/IPC-tests/server/Handle_R_Dgram.i deleted file mode 100644 index 88212a988f0..00000000000 --- a/ACE/examples/Service_Configurator/IPC-tests/server/Handle_R_Dgram.i +++ /dev/null @@ -1,111 +0,0 @@ -/* -*- C++ -*- */ -// $Id$ - -#include "ace/Get_Opt.h" -#include "ace/OS_NS_stdio.h" -#include "ace/OS_NS_string.h" -#include "ace/OS_NS_unistd.h" - -ACE_INLINE -Handle_R_Dgram::Handle_R_Dgram (void) -{ -} - -ACE_INLINE int -Handle_R_Dgram::open (const ACE_INET_Addr &r, int async) -{ - if (this->ACE_SOCK_Dgram::open (r) == -1) - return -1; - else if (async && this->ACE_SOCK_Dgram::enable (ACE_SIGIO) == -1) - return -1; - else - return 0; -} - -ACE_INLINE int -Handle_R_Dgram::info (ACE_TCHAR **strp, size_t length) const -{ - ACE_TCHAR buf[BUFSIZ]; - ACE_INET_Addr sa; - - if (this->get_local_addr (sa) == -1) - return -1; - - ACE_OS::sprintf (buf, ACE_TEXT ("%d/"), sa.get_port_number ()); - ACE_OS::strcat (buf, ACE_TEXT ("udp # tests remote dgram\n")); - - if (*strp == 0 && (*strp = ACE_OS::strdup (buf)) == 0) - return -1; - else - ACE_OS::strncpy (*strp, buf, length); - return ACE_OS::strlen (buf); -} - -ACE_INLINE int -Handle_R_Dgram::init (int argc, ACE_TCHAR *argv[]) -{ - ACE_INET_Addr sidg (Handle_R_Dgram::DEFAULT_PORT); - ACE_Get_Opt get_opt (argc, argv, ACE_TEXT ("p:"), 0); - - for (int c; (c = get_opt ()) != -1; ) - switch (c) - { - case 'p': - sidg.set (ACE_OS::atoi (get_opt.opt_arg ())); - break; - default: - break; - } - - if (this->open (sidg) == -1) - ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("open")), -1); - else if (ACE_Reactor::instance ()->register_handler - (this, ACE_Event_Handler::ACCEPT_MASK) == -1) - ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), - ACE_TEXT ("registering service with ACE_Reactor")), -1); - return 0; -} - -ACE_INLINE int -Handle_R_Dgram::fini (void) -{ - return ACE_Reactor::instance ()->remove_handler - (this, ACE_Event_Handler::ACCEPT_MASK); -} - -ACE_INLINE ACE_HANDLE -Handle_R_Dgram::get_handle (void) const -{ - return ACE_SOCK_Dgram::get_handle (); -} - -ACE_INLINE int -Handle_R_Dgram::handle_input (ACE_HANDLE) -{ - ACE_INET_Addr sa; - char buf[8 * 1024]; /* 8 k buffer */ - ssize_t n = this->recv (buf, sizeof buf, sa); - - if (n == -1) - return -1; - else - ACE_DEBUG ((LM_INFO, - ACE_TEXT ("received datagram from host %C on port %d\n"), - sa.get_host_name (), sa.get_port_number ())); - - ACE_OS::puts ("----------------------------------------"); - ACE_OS::write (ACE_STDOUT, buf, n); - - if (buf[n - 1] != '\n') - putchar ('\n'); - - ACE_OS::puts ("----------------------------------------"); - - return 0; -} - -ACE_INLINE int -Handle_R_Dgram::handle_close (ACE_HANDLE, ACE_Reactor_Mask) -{ - return this->ACE_SOCK_Dgram::close (); -} diff --git a/ACE/examples/Service_Configurator/IPC-tests/server/Handle_R_Dgram.inl b/ACE/examples/Service_Configurator/IPC-tests/server/Handle_R_Dgram.inl new file mode 100644 index 00000000000..88212a988f0 --- /dev/null +++ b/ACE/examples/Service_Configurator/IPC-tests/server/Handle_R_Dgram.inl @@ -0,0 +1,111 @@ +/* -*- C++ -*- */ +// $Id$ + +#include "ace/Get_Opt.h" +#include "ace/OS_NS_stdio.h" +#include "ace/OS_NS_string.h" +#include "ace/OS_NS_unistd.h" + +ACE_INLINE +Handle_R_Dgram::Handle_R_Dgram (void) +{ +} + +ACE_INLINE int +Handle_R_Dgram::open (const ACE_INET_Addr &r, int async) +{ + if (this->ACE_SOCK_Dgram::open (r) == -1) + return -1; + else if (async && this->ACE_SOCK_Dgram::enable (ACE_SIGIO) == -1) + return -1; + else + return 0; +} + +ACE_INLINE int +Handle_R_Dgram::info (ACE_TCHAR **strp, size_t length) const +{ + ACE_TCHAR buf[BUFSIZ]; + ACE_INET_Addr sa; + + if (this->get_local_addr (sa) == -1) + return -1; + + ACE_OS::sprintf (buf, ACE_TEXT ("%d/"), sa.get_port_number ()); + ACE_OS::strcat (buf, ACE_TEXT ("udp # tests remote dgram\n")); + + if (*strp == 0 && (*strp = ACE_OS::strdup (buf)) == 0) + return -1; + else + ACE_OS::strncpy (*strp, buf, length); + return ACE_OS::strlen (buf); +} + +ACE_INLINE int +Handle_R_Dgram::init (int argc, ACE_TCHAR *argv[]) +{ + ACE_INET_Addr sidg (Handle_R_Dgram::DEFAULT_PORT); + ACE_Get_Opt get_opt (argc, argv, ACE_TEXT ("p:"), 0); + + for (int c; (c = get_opt ()) != -1; ) + switch (c) + { + case 'p': + sidg.set (ACE_OS::atoi (get_opt.opt_arg ())); + break; + default: + break; + } + + if (this->open (sidg) == -1) + ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("open")), -1); + else if (ACE_Reactor::instance ()->register_handler + (this, ACE_Event_Handler::ACCEPT_MASK) == -1) + ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), + ACE_TEXT ("registering service with ACE_Reactor")), -1); + return 0; +} + +ACE_INLINE int +Handle_R_Dgram::fini (void) +{ + return ACE_Reactor::instance ()->remove_handler + (this, ACE_Event_Handler::ACCEPT_MASK); +} + +ACE_INLINE ACE_HANDLE +Handle_R_Dgram::get_handle (void) const +{ + return ACE_SOCK_Dgram::get_handle (); +} + +ACE_INLINE int +Handle_R_Dgram::handle_input (ACE_HANDLE) +{ + ACE_INET_Addr sa; + char buf[8 * 1024]; /* 8 k buffer */ + ssize_t n = this->recv (buf, sizeof buf, sa); + + if (n == -1) + return -1; + else + ACE_DEBUG ((LM_INFO, + ACE_TEXT ("received datagram from host %C on port %d\n"), + sa.get_host_name (), sa.get_port_number ())); + + ACE_OS::puts ("----------------------------------------"); + ACE_OS::write (ACE_STDOUT, buf, n); + + if (buf[n - 1] != '\n') + putchar ('\n'); + + ACE_OS::puts ("----------------------------------------"); + + return 0; +} + +ACE_INLINE int +Handle_R_Dgram::handle_close (ACE_HANDLE, ACE_Reactor_Mask) +{ + return this->ACE_SOCK_Dgram::close (); +} diff --git a/ACE/examples/Service_Configurator/IPC-tests/server/Handle_R_Stream.cpp b/ACE/examples/Service_Configurator/IPC-tests/server/Handle_R_Stream.cpp index 95553833e72..ee49a28a2ef 100644 --- a/ACE/examples/Service_Configurator/IPC-tests/server/Handle_R_Stream.cpp +++ b/ACE/examples/Service_Configurator/IPC-tests/server/Handle_R_Stream.cpp @@ -35,7 +35,7 @@ char *Handle_R_Stream::login_name = 0; char Handle_R_Stream::login[ACE_MAX_USERID]; #if !defined (__ACE_INLINE__) -#include "Handle_R_Stream.i" +#include "Handle_R_Stream.inl" #endif /* __ACE_INLINE__ */ Handle_R_Stream remote_stream; diff --git a/ACE/examples/Service_Configurator/IPC-tests/server/Handle_R_Stream.h b/ACE/examples/Service_Configurator/IPC-tests/server/Handle_R_Stream.h index 9878321cec8..fb06f525073 100644 --- a/ACE/examples/Service_Configurator/IPC-tests/server/Handle_R_Stream.h +++ b/ACE/examples/Service_Configurator/IPC-tests/server/Handle_R_Stream.h @@ -45,7 +45,7 @@ extern ACE_Service_Object_Type rs; #if defined (__ACE_INLINE__) #define ACE_INLINE inline -#include "Handle_R_Stream.i" +#include "Handle_R_Stream.inl" #else #define ACE_INLINE #endif /* __ACE_INLINE__ */ diff --git a/ACE/examples/Service_Configurator/IPC-tests/server/Handle_R_Stream.i b/ACE/examples/Service_Configurator/IPC-tests/server/Handle_R_Stream.i deleted file mode 100644 index f126cd13aee..00000000000 --- a/ACE/examples/Service_Configurator/IPC-tests/server/Handle_R_Stream.i +++ /dev/null @@ -1,153 +0,0 @@ -/* -*- C++ -*- */ -// $Id$ - -#include "ace/Get_Opt.h" -#include "ace/WFMO_Reactor.h" -#include "ace/OS_NS_stdio.h" -#include "ace/OS_NS_string.h" -#include "ace/OS_NS_time.h" -#include "ace/OS_NS_unistd.h" - -ACE_INLINE -Handle_R_Stream::Handle_R_Stream (void) -{ - if (Handle_R_Stream::login_name == 0) - Handle_R_Stream::login_name = ACE_OS::cuserid (Handle_R_Stream::login); -} - -ACE_INLINE int -Handle_R_Stream::open (const ACE_INET_Addr &sia, int async) -{ - if (this->ACE_SOCK_Acceptor::open (sia) == -1) - return -1; - else if (async && this->ACE_SOCK_Acceptor::enable (ACE_SIGIO) == -1) - return -1; - else - return 0; -} - -ACE_INLINE int -Handle_R_Stream::info (ACE_TCHAR **strp, size_t length) const -{ - ACE_TCHAR buf[BUFSIZ]; - ACE_INET_Addr sa; - - if (this->get_local_addr (sa) == -1) - return -1; - - ACE_OS::sprintf (buf, - ACE_TEXT("%d/%s %s"), - sa.get_port_number (), - ACE_TEXT("tcp"), - ACE_TEXT("# tests remote stream\n")); - - if (*strp == 0 && (*strp = ACE_OS::strdup (buf)) == 0) - return -1; - else - ACE_OS::strncpy (*strp, buf, length); - return ACE_OS::strlen (buf); -} - -ACE_INLINE int -Handle_R_Stream::init (int argc, ACE_TCHAR *argv[]) -{ - ACE_INET_Addr sis (Handle_R_Stream::DEFAULT_PORT); - ACE_Get_Opt get_opt (argc, argv, ACE_TEXT("p:"), 0); - - for (int c; (c = get_opt ()) != -1; ) - switch (c) - { - case 'p': - sis.set (ACE_OS::atoi (get_opt.opt_arg ())); - break; - default: - break; - } - - if (this->open (sis) == -1) - ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "open"), -1); - - else if (ACE_Reactor::instance ()->register_handler - (this, ACE_Event_Handler::ACCEPT_MASK) == -1) - ACE_ERROR_RETURN ((LM_ERROR, - "registering service with ACE_Reactor\n"), - -1); - return 0; -} - -ACE_INLINE int -Handle_R_Stream::fini (void) -{ - return ACE_Reactor::instance ()->remove_handler - (this, ACE_Event_Handler::ACCEPT_MASK); -} - -ACE_INLINE ACE_HANDLE -Handle_R_Stream::get_handle (void) const -{ - return ACE_SOCK_Acceptor::get_handle (); -} - -ACE_INLINE int -Handle_R_Stream::handle_input (ACE_HANDLE) -{ - char buf[BUFSIZ]; - int bytes; - - // Try to find out if the implementation of the reactor that we are - // using requires us to reset the event association for the newly - // created handle. This is because the newly created handle will - // inherit the properties of the listen handle, including its event - // associations. - int reset_new_handle = - ACE_Reactor::instance ()->uses_event_associations (); - - if (this->accept (this->new_remote_stream, // stream - 0, // remote address - 0, // timeout - 1, // restart - reset_new_handle // reset new handler - ) == -1) - return -1; - else - ACE_DEBUG ((LM_INFO, "new_remote_stream fd = %d\n", - this->new_remote_stream.get_handle ())); - - ACE_INET_Addr sa; - - if (this->new_remote_stream.get_remote_addr (sa) == -1) - return -1; - - ACE_DEBUG ((LM_INFO, - "accepted from host %s at port %d\n", - sa.get_host_name (), - sa.get_port_number ())); - - ACE_OS::puts (ACE_TEXT ("----------------------------------------")); - - while ((bytes = this->new_remote_stream.recv (buf, sizeof buf)) > 0) - ACE_OS::write (ACE_STDOUT, buf, bytes); - - ACE_OS::puts (ACE_TEXT ("----------------------------------------")); - - time_t t = ACE_OS::time (0L); - ACE_TCHAR *cs = ACE_OS::ctime (&t); - - if (this->new_remote_stream.send (4, - Handle_R_Stream::login_name, - ACE_OS::strlen (Handle_R_Stream::login_name), - cs, - ACE_OS::strlen (cs)) == -1) - return -1; - - if (this->new_remote_stream.close () == -1) - return -1; - - return 0; -} - -ACE_INLINE int -Handle_R_Stream::handle_close (ACE_HANDLE, ACE_Reactor_Mask) -{ - return this->ACE_SOCK_Acceptor::close (); -} diff --git a/ACE/examples/Service_Configurator/IPC-tests/server/Handle_R_Stream.inl b/ACE/examples/Service_Configurator/IPC-tests/server/Handle_R_Stream.inl new file mode 100644 index 00000000000..f126cd13aee --- /dev/null +++ b/ACE/examples/Service_Configurator/IPC-tests/server/Handle_R_Stream.inl @@ -0,0 +1,153 @@ +/* -*- C++ -*- */ +// $Id$ + +#include "ace/Get_Opt.h" +#include "ace/WFMO_Reactor.h" +#include "ace/OS_NS_stdio.h" +#include "ace/OS_NS_string.h" +#include "ace/OS_NS_time.h" +#include "ace/OS_NS_unistd.h" + +ACE_INLINE +Handle_R_Stream::Handle_R_Stream (void) +{ + if (Handle_R_Stream::login_name == 0) + Handle_R_Stream::login_name = ACE_OS::cuserid (Handle_R_Stream::login); +} + +ACE_INLINE int +Handle_R_Stream::open (const ACE_INET_Addr &sia, int async) +{ + if (this->ACE_SOCK_Acceptor::open (sia) == -1) + return -1; + else if (async && this->ACE_SOCK_Acceptor::enable (ACE_SIGIO) == -1) + return -1; + else + return 0; +} + +ACE_INLINE int +Handle_R_Stream::info (ACE_TCHAR **strp, size_t length) const +{ + ACE_TCHAR buf[BUFSIZ]; + ACE_INET_Addr sa; + + if (this->get_local_addr (sa) == -1) + return -1; + + ACE_OS::sprintf (buf, + ACE_TEXT("%d/%s %s"), + sa.get_port_number (), + ACE_TEXT("tcp"), + ACE_TEXT("# tests remote stream\n")); + + if (*strp == 0 && (*strp = ACE_OS::strdup (buf)) == 0) + return -1; + else + ACE_OS::strncpy (*strp, buf, length); + return ACE_OS::strlen (buf); +} + +ACE_INLINE int +Handle_R_Stream::init (int argc, ACE_TCHAR *argv[]) +{ + ACE_INET_Addr sis (Handle_R_Stream::DEFAULT_PORT); + ACE_Get_Opt get_opt (argc, argv, ACE_TEXT("p:"), 0); + + for (int c; (c = get_opt ()) != -1; ) + switch (c) + { + case 'p': + sis.set (ACE_OS::atoi (get_opt.opt_arg ())); + break; + default: + break; + } + + if (this->open (sis) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "open"), -1); + + else if (ACE_Reactor::instance ()->register_handler + (this, ACE_Event_Handler::ACCEPT_MASK) == -1) + ACE_ERROR_RETURN ((LM_ERROR, + "registering service with ACE_Reactor\n"), + -1); + return 0; +} + +ACE_INLINE int +Handle_R_Stream::fini (void) +{ + return ACE_Reactor::instance ()->remove_handler + (this, ACE_Event_Handler::ACCEPT_MASK); +} + +ACE_INLINE ACE_HANDLE +Handle_R_Stream::get_handle (void) const +{ + return ACE_SOCK_Acceptor::get_handle (); +} + +ACE_INLINE int +Handle_R_Stream::handle_input (ACE_HANDLE) +{ + char buf[BUFSIZ]; + int bytes; + + // Try to find out if the implementation of the reactor that we are + // using requires us to reset the event association for the newly + // created handle. This is because the newly created handle will + // inherit the properties of the listen handle, including its event + // associations. + int reset_new_handle = + ACE_Reactor::instance ()->uses_event_associations (); + + if (this->accept (this->new_remote_stream, // stream + 0, // remote address + 0, // timeout + 1, // restart + reset_new_handle // reset new handler + ) == -1) + return -1; + else + ACE_DEBUG ((LM_INFO, "new_remote_stream fd = %d\n", + this->new_remote_stream.get_handle ())); + + ACE_INET_Addr sa; + + if (this->new_remote_stream.get_remote_addr (sa) == -1) + return -1; + + ACE_DEBUG ((LM_INFO, + "accepted from host %s at port %d\n", + sa.get_host_name (), + sa.get_port_number ())); + + ACE_OS::puts (ACE_TEXT ("----------------------------------------")); + + while ((bytes = this->new_remote_stream.recv (buf, sizeof buf)) > 0) + ACE_OS::write (ACE_STDOUT, buf, bytes); + + ACE_OS::puts (ACE_TEXT ("----------------------------------------")); + + time_t t = ACE_OS::time (0L); + ACE_TCHAR *cs = ACE_OS::ctime (&t); + + if (this->new_remote_stream.send (4, + Handle_R_Stream::login_name, + ACE_OS::strlen (Handle_R_Stream::login_name), + cs, + ACE_OS::strlen (cs)) == -1) + return -1; + + if (this->new_remote_stream.close () == -1) + return -1; + + return 0; +} + +ACE_INLINE int +Handle_R_Stream::handle_close (ACE_HANDLE, ACE_Reactor_Mask) +{ + return this->ACE_SOCK_Acceptor::close (); +} diff --git a/ACE/examples/Service_Configurator/IPC-tests/server/Handle_Timeout.cpp b/ACE/examples/Service_Configurator/IPC-tests/server/Handle_Timeout.cpp index 9eccf88ef43..18e9c154e91 100644 --- a/ACE/examples/Service_Configurator/IPC-tests/server/Handle_Timeout.cpp +++ b/ACE/examples/Service_Configurator/IPC-tests/server/Handle_Timeout.cpp @@ -29,7 +29,7 @@ fini (void) #endif /* SunOS4 */ #if !defined (__ACE_INLINE__) -#include "Handle_Timeout.i" +#include "Handle_Timeout.inl" #endif /* __ACE_INLINE__ */ Handle_Timeout timer_1; diff --git a/ACE/examples/Service_Configurator/IPC-tests/server/Handle_Timeout.h b/ACE/examples/Service_Configurator/IPC-tests/server/Handle_Timeout.h index 88b6e673aaf..e07cc247ca9 100644 --- a/ACE/examples/Service_Configurator/IPC-tests/server/Handle_Timeout.h +++ b/ACE/examples/Service_Configurator/IPC-tests/server/Handle_Timeout.h @@ -37,7 +37,7 @@ extern ACE_Service_Object_Type t1; #if defined (__ACE_INLINE__) #define ACE_INLINE inline -#include "Handle_Timeout.i" +#include "Handle_Timeout.inl" #else #define ACE_INLINE #endif /* __ACE_INLINE__ */ diff --git a/ACE/examples/Service_Configurator/IPC-tests/server/Handle_Timeout.i b/ACE/examples/Service_Configurator/IPC-tests/server/Handle_Timeout.i deleted file mode 100644 index 346a22e773c..00000000000 --- a/ACE/examples/Service_Configurator/IPC-tests/server/Handle_Timeout.i +++ /dev/null @@ -1,86 +0,0 @@ -/* -*- C++ -*- */ -// $Id$ - -#include "ace/Service_Config.h" -#include "ace/Get_Opt.h" -#include "ace/OS_NS_stdio.h" -#include "ace/OS_NS_string.h" - -ACE_INLINE -Handle_Timeout::Handle_Timeout (void): count (0) -{ -} - -ACE_INLINE int -Handle_Timeout::info (ACE_TCHAR **strp, size_t length) const -{ - ACE_TCHAR buf[BUFSIZ]; - - ACE_OS::strcpy (buf, ACE_TEXT("# tests timeout facility\n")); - - if (*strp == 0 && (*strp = ACE_OS::strdup (buf)) == 0) - return -1; - else - ACE_OS::strncpy (*strp, buf, length); - return ACE_OS::strlen (buf); -} - -ACE_INLINE int -Handle_Timeout::init (int argc, ACE_TCHAR *argv[]) -{ - ACE_Time_Value delta (10); - ACE_Time_Value interval (1); - ACE_Get_Opt get_opt (argc, argv, ACE_TEXT("a:d:i:"), 0); - int arg = 0; - - for (int c; (c = get_opt ()) != -1; ) - switch (c) - { - case 'd': - delta.sec (ACE_OS::atoi (get_opt.opt_arg ())); - break; - case 'i': - interval.sec (ACE_OS::atoi (get_opt.opt_arg ())); - break; - case 'a': - arg = ACE_OS::atoi (get_opt.opt_arg ()); - break; - default: - break; - } - - if (ACE_Reactor::instance ()->schedule_timer (this, - reinterpret_cast (arg), - delta, - interval) == -1) - return -1; - else - return 0; -} - -ACE_INLINE int -Handle_Timeout::fini (void) -{ - return 0; -} - -ACE_INLINE ACE_HANDLE -Handle_Timeout::get_handle (void) const -{ - return ACE_INVALID_HANDLE; -} - -ACE_INLINE int -Handle_Timeout::handle_timeout (const ACE_Time_Value &tv, - const void *arg) -{ - if (this->count++ >= 10) - return -1; // Automatically cancel periodic timer... - - // Cast arg to a long, first, because a pointer is the same - // size as a long on all current ACE platforms. - ACE_DEBUG ((LM_INFO, - ACE_TEXT ("time for this(%u) expired at (%d, %d) with arg = %d\n"), - this, tv.sec (), tv.usec (), (int) (long) arg)); - return 0; -} diff --git a/ACE/examples/Service_Configurator/IPC-tests/server/Handle_Timeout.inl b/ACE/examples/Service_Configurator/IPC-tests/server/Handle_Timeout.inl new file mode 100644 index 00000000000..346a22e773c --- /dev/null +++ b/ACE/examples/Service_Configurator/IPC-tests/server/Handle_Timeout.inl @@ -0,0 +1,86 @@ +/* -*- C++ -*- */ +// $Id$ + +#include "ace/Service_Config.h" +#include "ace/Get_Opt.h" +#include "ace/OS_NS_stdio.h" +#include "ace/OS_NS_string.h" + +ACE_INLINE +Handle_Timeout::Handle_Timeout (void): count (0) +{ +} + +ACE_INLINE int +Handle_Timeout::info (ACE_TCHAR **strp, size_t length) const +{ + ACE_TCHAR buf[BUFSIZ]; + + ACE_OS::strcpy (buf, ACE_TEXT("# tests timeout facility\n")); + + if (*strp == 0 && (*strp = ACE_OS::strdup (buf)) == 0) + return -1; + else + ACE_OS::strncpy (*strp, buf, length); + return ACE_OS::strlen (buf); +} + +ACE_INLINE int +Handle_Timeout::init (int argc, ACE_TCHAR *argv[]) +{ + ACE_Time_Value delta (10); + ACE_Time_Value interval (1); + ACE_Get_Opt get_opt (argc, argv, ACE_TEXT("a:d:i:"), 0); + int arg = 0; + + for (int c; (c = get_opt ()) != -1; ) + switch (c) + { + case 'd': + delta.sec (ACE_OS::atoi (get_opt.opt_arg ())); + break; + case 'i': + interval.sec (ACE_OS::atoi (get_opt.opt_arg ())); + break; + case 'a': + arg = ACE_OS::atoi (get_opt.opt_arg ()); + break; + default: + break; + } + + if (ACE_Reactor::instance ()->schedule_timer (this, + reinterpret_cast (arg), + delta, + interval) == -1) + return -1; + else + return 0; +} + +ACE_INLINE int +Handle_Timeout::fini (void) +{ + return 0; +} + +ACE_INLINE ACE_HANDLE +Handle_Timeout::get_handle (void) const +{ + return ACE_INVALID_HANDLE; +} + +ACE_INLINE int +Handle_Timeout::handle_timeout (const ACE_Time_Value &tv, + const void *arg) +{ + if (this->count++ >= 10) + return -1; // Automatically cancel periodic timer... + + // Cast arg to a long, first, because a pointer is the same + // size as a long on all current ACE platforms. + ACE_DEBUG ((LM_INFO, + ACE_TEXT ("time for this(%u) expired at (%d, %d) with arg = %d\n"), + this, tv.sec (), tv.usec (), (int) (long) arg)); + return 0; +} -- cgit v1.2.1