2 #include "ace/os_include/os_errno.h"
3 #include "ace/OS_NS_unistd.h"
4 #include "ace/OS_NS_string.h"
5 #include "ace/OS_NS_macros.h"
6 #include "ace/OS_Memory.h"
7 #include "ace/OS_QoS.h"
8 #include "ace/Global_Macros.h"
10 #if defined (ACE_HAS_ALLOC_HOOKS)
11 # include "ace/Malloc_Base.h"
12 #endif /* ACE_HAS_ALLOC_HOOKS */
14 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
16 typedef const struct strbuf *ACE_STRBUF_TYPE;
19 ACE_Str_Buf::ACE_Str_Buf (void *b, int l, int max)
23 this->buf = (char *) b;
27 ACE_Str_Buf::ACE_Str_Buf (strbuf &sb)
29 this->maxlen = sb.maxlen;
34 /*****************************************************************************/
37 ACE_OS::getmsg (ACE_HANDLE handle,
42 ACE_OS_TRACE ("ACE_OS::getmsg");
43 #if defined (ACE_HAS_STREAM_PIPES)
44 return ::getmsg (handle, ctl, data, flags);
46 ACE_UNUSED_ARG (handle);
48 ACE_UNUSED_ARG (data);
49 ACE_UNUSED_ARG (flags);
51 // I'm not sure how to implement this correctly.
52 ACE_NOTSUP_RETURN (-1);
53 #endif /* ACE_HAS_STREAM_PIPES */
57 ACE_OS::getpmsg (ACE_HANDLE handle,
63 ACE_OS_TRACE ("ACE_OS::getpmsg");
64 #if defined (ACE_HAS_STREAM_PIPES)
65 return ::getpmsg (handle, ctl, data, band, flags);
67 ACE_UNUSED_ARG (handle);
69 ACE_UNUSED_ARG (data);
70 ACE_UNUSED_ARG (band);
71 ACE_UNUSED_ARG (flags);
73 // I'm not sure how to implement this correctly.
74 ACE_NOTSUP_RETURN (-1);
75 #endif /* ACE_HAS_STREAM_PIPES */
79 ACE_OS::fattach (int handle, const char *path)
81 ACE_OS_TRACE ("ACE_OS::fattach");
82 #if defined (ACE_HAS_STREAM_PIPES)
83 return ::fattach (handle, path);
85 ACE_UNUSED_ARG (handle);
86 ACE_UNUSED_ARG (path);
88 ACE_NOTSUP_RETURN (-1);
89 #endif /* ACE_HAS_STREAM_PIPES */
93 ACE_OS::fdetach (const char *file)
95 ACE_OS_TRACE ("ACE_OS::fdetach");
96 #if defined (ACE_HAS_STREAM_PIPES)
97 return ::fdetach (file);
99 ACE_UNUSED_ARG (file);
101 ACE_NOTSUP_RETURN (-1);
102 #endif /* ACE_HAS_STREAM_PIPES */
106 ACE_OS::ioctl (ACE_HANDLE handle,
107 ACE_IOCTL_TYPE_ARG2 cmd,
110 ACE_OS_TRACE ("ACE_OS::ioctl");
111 #if defined (ACE_LACKS_IOCTL)
112 ACE_UNUSED_ARG (handle);
113 ACE_UNUSED_ARG (cmd);
114 ACE_UNUSED_ARG (val);
115 ACE_NOTSUP_RETURN (-1);
116 #elif defined (ACE_WIN32)
117 ACE_SOCKET sock = (ACE_SOCKET) handle;
118 ACE_SOCKCALL_RETURN (::ioctlsocket (sock, cmd, reinterpret_cast<unsigned long *> (val)), int, -1);
119 #elif defined (ACE_HAS_IOCTL_INT_3_PARAM)
120 return ::ioctl (handle, cmd, reinterpret_cast<int> (val));
121 #elif defined (ACE_MQX)
122 // TBD: See if there is a way to provide this functionality
123 ACE_NOTSUP_RETURN (0);
125 return ::ioctl (handle, cmd, val);
126 #endif /* ACE_WIN32 */
130 ACE_OS::isastream (ACE_HANDLE handle)
132 ACE_OS_TRACE ("ACE_OS::isastream");
133 #if defined (ACE_HAS_STREAM_PIPES)
134 return ::isastream (handle);
136 ACE_UNUSED_ARG (handle);
138 ACE_NOTSUP_RETURN (-1);
139 #endif /* ACE_HAS_STREAM_PIPES */
143 ACE_OS::putmsg (ACE_HANDLE handle, const struct strbuf *ctl,
144 const struct strbuf *data, int flags)
146 ACE_OS_TRACE ("ACE_OS::putmsg");
147 #if defined (ACE_HAS_STREAM_PIPES)
148 return ::putmsg (handle, (ACE_STRBUF_TYPE) ctl, (ACE_STRBUF_TYPE) data, flags);
150 ACE_UNUSED_ARG (flags);
152 if (ctl == 0 && data == 0)
157 // Handle the two easy cases.
160 result = ACE_OS::write (handle, ctl->buf, ctl->len);
161 return static_cast<int> (result);
165 result = ACE_OS::write (handle, data->buf, data->len);
166 return static_cast<int> (result);
170 // This is the hard case.
172 #if defined (ACE_HAS_ALLOC_HOOKS)
173 ACE_ALLOCATOR_RETURN (buf, static_cast<char*>(ACE_Allocator::instance()->malloc(sizeof(char) * (ctl->len + data->len))), -1);
175 ACE_NEW_RETURN (buf, char [ctl->len + data->len], -1);
176 #endif /* ACE_HAS_ALLOC_HOOKS */
177 ACE_OS::memcpy (buf, ctl->buf, ctl->len);
178 ACE_OS::memcpy (buf + ctl->len, data->buf, data->len);
179 result = ACE_OS::write (handle, buf, ctl->len + data->len);
180 #if defined (ACE_HAS_ALLOC_HOOKS)
181 ACE_Allocator::instance()->free(buf);
184 #endif /* ACE_HAS_ALLOC_HOOKS */
186 return static_cast<int> (result);
188 #endif /* ACE_HAS_STREAM_PIPES */
192 ACE_OS::putpmsg (ACE_HANDLE handle,
193 const struct strbuf *ctl,
194 const struct strbuf *data,
198 ACE_OS_TRACE ("ACE_OS::putpmsg");
199 #if defined (ACE_HAS_STREAM_PIPES)
200 return ::putpmsg (handle, (ACE_STRBUF_TYPE) ctl, (ACE_STRBUF_TYPE) data, band, flags);
202 ACE_UNUSED_ARG (flags);
203 ACE_UNUSED_ARG (band);
204 return ACE_OS::putmsg (handle, ctl, data, flags);
205 #endif /* ACE_HAS_STREAM_PIPES */
208 ACE_END_VERSIONED_NAMESPACE_DECL