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 #if defined (ACE_LACKS_CONST_STRBUF_PTR)
17 typedef struct strbuf *ACE_STRBUF_TYPE;
19 typedef const struct strbuf *ACE_STRBUF_TYPE;
20 #endif /* ACE_LACKS_CONST_STRBUF_PTR */
23 ACE_Str_Buf::ACE_Str_Buf (void *b, int l, int max)
27 this->buf = (char *) b;
31 ACE_Str_Buf::ACE_Str_Buf (strbuf &sb)
33 this->maxlen = sb.maxlen;
38 /*****************************************************************************/
41 ACE_OS::getmsg (ACE_HANDLE handle,
46 ACE_OS_TRACE ("ACE_OS::getmsg");
47 #if defined (ACE_HAS_STREAM_PIPES)
48 ACE_OSCALL_RETURN (::getmsg (handle, ctl, data, flags), int, -1);
50 ACE_UNUSED_ARG (handle);
52 ACE_UNUSED_ARG (data);
53 ACE_UNUSED_ARG (flags);
55 // I'm not sure how to implement this correctly.
56 ACE_NOTSUP_RETURN (-1);
57 #endif /* ACE_HAS_STREAM_PIPES */
61 ACE_OS::getpmsg (ACE_HANDLE handle,
67 ACE_OS_TRACE ("ACE_OS::getpmsg");
68 #if defined (ACE_HAS_STREAM_PIPES)
69 ACE_OSCALL_RETURN (::getpmsg (handle, ctl, data, band, flags), int, -1);
71 ACE_UNUSED_ARG (handle);
73 ACE_UNUSED_ARG (data);
74 ACE_UNUSED_ARG (band);
75 ACE_UNUSED_ARG (flags);
77 // I'm not sure how to implement this correctly.
78 ACE_NOTSUP_RETURN (-1);
79 #endif /* ACE_HAS_STREAM_PIPES */
83 ACE_OS::fattach (int handle, const char *path)
85 ACE_OS_TRACE ("ACE_OS::fattach");
86 #if defined (ACE_HAS_STREAM_PIPES)
87 ACE_OSCALL_RETURN (::fattach (handle, path), int, -1);
89 ACE_UNUSED_ARG (handle);
90 ACE_UNUSED_ARG (path);
92 ACE_NOTSUP_RETURN (-1);
93 #endif /* ACE_HAS_STREAM_PIPES */
97 ACE_OS::fdetach (const char *file)
99 ACE_OS_TRACE ("ACE_OS::fdetach");
100 #if defined (ACE_HAS_STREAM_PIPES)
101 ACE_OSCALL_RETURN (::fdetach (file), int, -1);
103 ACE_UNUSED_ARG (file);
105 ACE_NOTSUP_RETURN (-1);
106 #endif /* ACE_HAS_STREAM_PIPES */
110 ACE_OS::ioctl (ACE_HANDLE handle,
111 ACE_IOCTL_TYPE_ARG2 cmd,
114 ACE_OS_TRACE ("ACE_OS::ioctl");
115 #if defined (ACE_LACKS_IOCTL)
116 ACE_UNUSED_ARG (handle);
117 ACE_UNUSED_ARG (cmd);
118 ACE_UNUSED_ARG (val);
119 ACE_NOTSUP_RETURN (-1);
120 #elif defined (ACE_WIN32)
121 ACE_SOCKET sock = (ACE_SOCKET) handle;
122 ACE_SOCKCALL_RETURN (::ioctlsocket (sock, cmd, reinterpret_cast<unsigned long *> (val)), int, -1);
123 #elif defined (ACE_HAS_IOCTL_INT_3_PARAM)
124 ACE_OSCALL_RETURN (::ioctl (handle, cmd, reinterpret_cast<int> (val)),
126 #elif defined (ACE_MQX)
127 // TBD: See if there is a way to provide this functionality
128 ACE_NOTSUP_RETURN (0);
130 ACE_OSCALL_RETURN (::ioctl (handle, cmd, val), int, -1);
131 #endif /* ACE_WIN32 */
135 ACE_OS::isastream (ACE_HANDLE handle)
137 ACE_OS_TRACE ("ACE_OS::isastream");
138 #if defined (ACE_HAS_STREAM_PIPES)
139 ACE_OSCALL_RETURN (::isastream (handle), int, -1);
141 ACE_UNUSED_ARG (handle);
143 ACE_NOTSUP_RETURN (-1);
144 #endif /* ACE_HAS_STREAM_PIPES */
148 ACE_OS::putmsg (ACE_HANDLE handle, const struct strbuf *ctl,
149 const struct strbuf *data, int flags)
151 ACE_OS_TRACE ("ACE_OS::putmsg");
152 #if defined (ACE_HAS_STREAM_PIPES)
153 ACE_OSCALL_RETURN (::putmsg (handle,
154 (ACE_STRBUF_TYPE) ctl,
155 (ACE_STRBUF_TYPE) data,
158 ACE_UNUSED_ARG (flags);
160 if (ctl == 0 && data == 0)
165 // Handle the two easy cases.
168 result = ACE_OS::write (handle, ctl->buf, ctl->len);
169 return static_cast<int> (result);
173 result = ACE_OS::write (handle, data->buf, data->len);
174 return static_cast<int> (result);
178 // This is the hard case.
180 #if defined (ACE_HAS_ALLOC_HOOKS)
181 ACE_ALLOCATOR_RETURN (buf, static_cast<char*>(ACE_Allocator::instance()->malloc(sizeof(char) * (ctl->len + data->len))), -1);
183 ACE_NEW_RETURN (buf, char [ctl->len + data->len], -1);
184 #endif /* ACE_HAS_ALLOC_HOOKS */
185 ACE_OS::memcpy (buf, ctl->buf, ctl->len);
186 ACE_OS::memcpy (buf + ctl->len, data->buf, data->len);
187 result = ACE_OS::write (handle, buf, ctl->len + data->len);
188 #if defined (ACE_HAS_ALLOC_HOOKS)
189 ACE_Allocator::instance()->free(buf);
192 #endif /* ACE_HAS_ALLOC_HOOKS */
194 return static_cast<int> (result);
196 #endif /* ACE_HAS_STREAM_PIPES */
200 ACE_OS::putpmsg (ACE_HANDLE handle,
201 const struct strbuf *ctl,
202 const struct strbuf *data,
206 ACE_OS_TRACE ("ACE_OS::putpmsg");
207 #if defined (ACE_HAS_STREAM_PIPES)
208 ACE_OSCALL_RETURN (::putpmsg (handle,
209 (ACE_STRBUF_TYPE) ctl,
210 (ACE_STRBUF_TYPE) data,
211 band, flags), int, -1);
213 ACE_UNUSED_ARG (flags);
214 ACE_UNUSED_ARG (band);
215 return ACE_OS::putmsg (handle, ctl, data, flags);
216 #endif /* ACE_HAS_STREAM_PIPES */
219 ACE_END_VERSIONED_NAMESPACE_DECL