2 #include "ace/Get_Opt.h"
3 #include "ace/Truncate.h"
4 #include "ace/OS_NS_stdio.h"
5 #include "ace/OS_NS_string.h"
6 #include "ace/OS_NS_stropts.h"
7 #include "ace/OS_NS_unistd.h"
10 Handle_L_FIFO::Handle_L_FIFO ()
15 Handle_L_FIFO::open (const ACE_TCHAR *rendezvous_fifo)
17 if (this->ACE_FIFO_Recv_Msg::open (rendezvous_fifo) == -1)
24 Handle_L_FIFO::info (ACE_TCHAR **strp, size_t length) const
26 ACE_TCHAR buf[BUFSIZ];
27 const ACE_TCHAR *rendezvous_fifo;
29 this->get_local_addr (rendezvous_fifo);
31 ACE_OS::strcpy (buf, rendezvous_fifo);
32 ACE_OS::strcat (buf, ACE_TEXT(" # tests local ACE_FIFO\n"));
34 if (*strp == 0 && (*strp = ACE_OS::strdup (buf)) == 0)
40 ACE_OS::strncpy (*strp, buf, length);
43 return ACE_Utils::truncate_cast<int> (ACE_OS::strlen (buf));
47 Handle_L_FIFO::init (int argc, ACE_TCHAR *argv[])
49 const ACE_TCHAR *rendezvous_fifo = Handle_L_FIFO::DEFAULT_RENDEZVOUS;
50 ACE_Get_Opt get_opt (argc, argv, ACE_TEXT("r:"), 0);
52 for (int c; (c = get_opt ()) != -1; )
56 rendezvous_fifo = get_opt.opt_arg ();
62 ACE_OS::unlink (rendezvous_fifo);
63 if (this->open (rendezvous_fifo) == -1)
64 ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("open")), -1);
65 else if (ACE_Reactor::instance ()->register_handler (this, ACE_Event_Handler::READ_MASK) == -1)
66 ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"),
67 ACE_TEXT ("registering service with ACE_Reactor")),
73 Handle_L_FIFO::fini ()
75 return ACE_Reactor::instance ()->remove_handler
76 (this, ACE_Event_Handler::ACCEPT_MASK);
80 Handle_L_FIFO::get_handle () const
82 return this->ACE_FIFO::get_handle ();
86 Handle_L_FIFO::handle_input (ACE_HANDLE)
89 ACE_Str_Buf msg (buf, 0, sizeof buf);
91 /* Accept communication requests */
92 if (this->recv (msg) == -1)
96 ACE_OS::write (ACE_STDOUT, (const char *) msg.buf, (int) msg.len);
101 Handle_L_FIFO::handle_close (ACE_HANDLE, ACE_Reactor_Mask)
103 return this->ACE_FIFO::remove ();