2 ** Copyright 2002 Addison Wesley. All Rights Reserved.
5 #ifndef _REACTOR_LOGGING_SERVER_ADAPTER_C
6 #define _REACTOR_LOGGING_SERVER_ADAPTER_C
9 #include "ace/INET_Addr.h"
10 #include "ace/Truncate.h"
11 #include "Reactor_Logging_Server_Adapter.h"
12 #include "ace/OS_NS_string.h"
13 #include "ace/OS_NS_stdio.h"
16 template <class ACCEPTOR
> int
17 Reactor_Logging_Server_Adapter
<ACCEPTOR
>::init (int argc
,
21 ACE_NEW_RETURN (array
, char*[argc
], -1);
22 std::unique_ptr
<char *[]> char_argv (array
);
24 for (i
= 0; i
< argc
; ++i
)
25 char_argv
[i
] = ACE::strnew (ACE_TEXT_ALWAYS_CHAR (argv
[i
]));
26 ACE_NEW_NORETURN (server_
, Reactor_Logging_Server
<ACCEPTOR
>
28 ACE_Reactor::instance ()));
29 for (i
= 0; i
< argc
; ++i
) ACE::strdelete (char_argv
[i
]);
30 return server_
== 0 ? -1 : 0;
33 // NOTE! The (ACCEPTOR*) cast below is NOT technically necessary, but it
34 // works around a bug in IBM XL C++ 9 that resolves to the wrong version of
36 template <class ACCEPTOR
> int
37 Reactor_Logging_Server_Adapter
<ACCEPTOR
>::fini ()
38 { ((ACCEPTOR
*)server_
)->handle_close (); server_
= 0; return 0; }
41 template <class ACCEPTOR
> int
42 Reactor_Logging_Server_Adapter
<ACCEPTOR
>::info
43 (ACE_TCHAR
**bufferp
, size_t length
) const {
44 ACE_INET_Addr local_addr
;
45 server_
->acceptor ().get_local_addr (local_addr
);
47 ACE_TCHAR buf
[BUFSIZ
];
50 local_addr
.get_port_number ());
52 (buf
, ACE_TEXT ("/tcp # Reactor-based logging server\n"));
54 *bufferp
= ACE::strnew (buf
);
56 ACE_OS::strncpy (*bufferp
, buf
, length
);
58 return ACE_Utils::truncate_cast
<int> (ACE_OS::strlen (*bufferp
));
62 template <class ACCEPTOR
> int
63 Reactor_Logging_Server_Adapter
<ACCEPTOR
>::suspend ()
64 { return server_
->reactor ()->suspend_handler (server_
); }
67 template <class ACCEPTOR
> int
68 Reactor_Logging_Server_Adapter
<ACCEPTOR
>::resume ()
69 { return server_
->reactor ()->resume_handler (server_
); }
71 #endif /* _REACTOR_LOGGING_SERVER_ADAPTER_C */