2 #include "ace/Get_Opt.h"
3 #include "ace/OS_NS_stdio.h"
4 #include "ace/OS_NS_string.h"
5 #include "ace/OS_NS_unistd.h"
8 Handle_L_Pipe::~Handle_L_Pipe ()
13 Handle_L_Pipe::Handle_L_Pipe ()
18 Handle_L_Pipe::open (const ACE_UNIX_Addr &suap, int async)
20 if (this->ACE_LSOCK_Acceptor::open (suap) == -1)
22 else if (async && this->ACE_LSOCK_Acceptor::enable (ACE_SIGIO) == -1)
29 Handle_L_Pipe::info (ACE_TCHAR **strp, size_t length) const
31 ACE_TCHAR buf[BUFSIZ];
34 if (ACE_LSOCK_Acceptor::get_local_addr (sa) == -1)
37 ACE_OS::strcpy (buf, ACE_TEXT_CHAR_TO_TCHAR (sa.get_path_name ()));
38 ACE_OS::strcat (buf, ACE_TEXT (" # tests local pipe\n"));
40 if (*strp == 0 && (*strp = ACE_OS::strdup (buf)) == 0)
43 ACE_OS::strncpy (*strp, buf, length);
44 return ACE_OS::strlen (buf);
48 Handle_L_Pipe::init (int argc, ACE_TCHAR *argv[])
51 const ACE_TCHAR *r = Handle_L_Pipe::DEFAULT_RENDEZVOUS;
52 ACE_Get_Opt get_opt (argc, argv, ACE_TEXT ("r:"), 0);
54 for (int c; (c = get_opt ()) != -1; )
58 r = get_opt.opt_arg ();
64 ACE_OS::strncpy (this->rendezvous, r, MAXPATHLEN);
65 ACE_OS::unlink (this->rendezvous);
66 sup.set (this->rendezvous);
67 if (this->open (sup) == -1)
68 ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("open")), -1);
69 else if (ACE_Reactor::instance ()->register_handler (this, ACE_Event_Handler::ACCEPT_MASK) == -1)
70 ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"),
71 ACE_TEXT ("registering service with ACE_Reactor")), -1);
76 Handle_L_Pipe::fini ()
78 return ACE_Reactor::instance ()->remove_handler
79 (this, ACE_Event_Handler::ACCEPT_MASK);
83 Handle_L_Pipe::get_handle () const
85 return ACE_LSOCK_Acceptor::get_handle ();
89 Handle_L_Pipe::handle_close (ACE_HANDLE, ACE_Reactor_Mask)
91 this->ACE_LSOCK_Acceptor::close ();
92 return ACE_OS::unlink (this->rendezvous);