1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
|
// -*- C++ -*-
//
// $Id$
#include "ace/os_include/os_errno.h"
#include "ace/OS_NS_unistd.h"
#include "ace/OS_NS_string.h"
#include "ace/OS_NS_macros.h"
#include "ace/OS_Memory.h"
#include "ace/OS_QoS.h"
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
#if defined (ACE_LACKS_CONST_STRBUF_PTR)
typedef struct strbuf *ACE_STRBUF_TYPE;
#else
typedef const struct strbuf *ACE_STRBUF_TYPE;
#endif /* ACE_LACKS_CONST_STRBUF_PTR */
ACE_INLINE
ACE_Str_Buf::ACE_Str_Buf (void *b, int l, int max)
{
this->maxlen = max;
this->len = l;
this->buf = (char *) b;
}
ACE_INLINE
ACE_Str_Buf::ACE_Str_Buf (strbuf &sb)
{
this->maxlen = sb.maxlen;
this->len = sb.len;
this->buf = sb.buf;
}
/*****************************************************************************/
ACE_INLINE int
ACE_OS::getmsg (ACE_HANDLE handle,
struct strbuf *ctl,
struct strbuf *data,
int *flags)
{
ACE_OS_TRACE ("ACE_OS::getmsg");
#if defined (ACE_HAS_STREAM_PIPES)
ACE_OSCALL_RETURN (::getmsg (handle, ctl, data, flags), int, -1);
#else
ACE_UNUSED_ARG (handle);
ACE_UNUSED_ARG (ctl);
ACE_UNUSED_ARG (data);
ACE_UNUSED_ARG (flags);
// I'm not sure how to implement this correctly.
ACE_NOTSUP_RETURN (-1);
#endif /* ACE_HAS_STREAM_PIPES */
}
ACE_INLINE int
ACE_OS::getpmsg (ACE_HANDLE handle,
struct strbuf *ctl,
struct strbuf *data,
int *band,
int *flags)
{
ACE_OS_TRACE ("ACE_OS::getpmsg");
#if defined (ACE_HAS_STREAM_PIPES)
ACE_OSCALL_RETURN (::getpmsg (handle, ctl, data, band, flags), int, -1);
#else
ACE_UNUSED_ARG (handle);
ACE_UNUSED_ARG (ctl);
ACE_UNUSED_ARG (data);
ACE_UNUSED_ARG (band);
ACE_UNUSED_ARG (flags);
// I'm not sure how to implement this correctly.
ACE_NOTSUP_RETURN (-1);
#endif /* ACE_HAS_STREAM_PIPES */
}
ACE_INLINE int
ACE_OS::fattach (int handle, const char *path)
{
ACE_OS_TRACE ("ACE_OS::fattach");
#if defined (ACE_HAS_STREAM_PIPES)
ACE_OSCALL_RETURN (::fattach (handle, path), int, -1);
#else
ACE_UNUSED_ARG (handle);
ACE_UNUSED_ARG (path);
ACE_NOTSUP_RETURN (-1);
#endif /* ACE_HAS_STREAM_PIPES */
}
ACE_INLINE int
ACE_OS::fdetach (const char *file)
{
ACE_OS_TRACE ("ACE_OS::fdetach");
#if defined (ACE_HAS_STREAM_PIPES)
ACE_OSCALL_RETURN (::fdetach (file), int, -1);
#else
ACE_UNUSED_ARG (file);
ACE_NOTSUP_RETURN (-1);
#endif /* ACE_HAS_STREAM_PIPES */
}
ACE_INLINE int
ACE_OS::ioctl (ACE_HANDLE handle,
ACE_IOCTL_TYPE_ARG2 cmd,
void *val)
{
ACE_OS_TRACE ("ACE_OS::ioctl");
#if defined (ACE_WIN32)
ACE_SOCKET sock = (ACE_SOCKET) handle;
ACE_SOCKCALL_RETURN (::ioctlsocket (sock, cmd, reinterpret_cast<unsigned long *> (val)), int, -1);
#elif defined (ACE_HAS_IOCTL_INT_3_PARAM)
ACE_OSCALL_RETURN (::ioctl (handle, cmd, reinterpret_cast<int> (val)),
int, -1);
#else
ACE_OSCALL_RETURN (::ioctl (handle, cmd, val), int, -1);
#endif /* ACE_WIN32 */
}
ACE_INLINE int
ACE_OS::isastream (ACE_HANDLE handle)
{
ACE_OS_TRACE ("ACE_OS::isastream");
#if defined (ACE_HAS_STREAM_PIPES)
ACE_OSCALL_RETURN (::isastream (handle), int, -1);
#else
ACE_UNUSED_ARG (handle);
ACE_NOTSUP_RETURN (-1);
#endif /* ACE_HAS_STREAM_PIPES */
}
ACE_INLINE int
ACE_OS::putmsg (ACE_HANDLE handle, const struct strbuf *ctl,
const struct strbuf *data, int flags)
{
ACE_OS_TRACE ("ACE_OS::putmsg");
#if defined (ACE_HAS_STREAM_PIPES)
ACE_OSCALL_RETURN (::putmsg (handle,
(ACE_STRBUF_TYPE) ctl,
(ACE_STRBUF_TYPE) data,
flags), int, -1);
#else
ACE_UNUSED_ARG (flags);
ssize_t result;
if (ctl == 0 && data == 0)
{
errno = EINVAL;
return 0;
}
// Handle the two easy cases.
else if (ctl != 0)
{
result = ACE_OS::write (handle, ctl->buf, ctl->len);
return static_cast<int> (result);
}
else if (data != 0)
{
result = ACE_OS::write (handle, data->buf, data->len);
return static_cast<int> (result);
}
else
{
// This is the hard case.
char *buf;
ACE_NEW_RETURN (buf, char [ctl->len + data->len], -1);
ACE_OS::memcpy (buf, ctl->buf, ctl->len);
ACE_OS::memcpy (buf + ctl->len, data->buf, data->len);
result = ACE_OS::write (handle, buf, ctl->len + data->len);
delete [] buf;
return static_cast<int> (result);
}
#endif /* ACE_HAS_STREAM_PIPES */
}
ACE_INLINE int
ACE_OS::putpmsg (ACE_HANDLE handle,
const struct strbuf *ctl,
const struct strbuf *data,
int band,
int flags)
{
ACE_OS_TRACE ("ACE_OS::putpmsg");
#if defined (ACE_HAS_STREAM_PIPES)
ACE_OSCALL_RETURN (::putpmsg (handle,
(ACE_STRBUF_TYPE) ctl,
(ACE_STRBUF_TYPE) data,
band, flags), int, -1);
#else
ACE_UNUSED_ARG (flags);
ACE_UNUSED_ARG (band);
return ACE_OS::putmsg (handle, ctl, data, flags);
#endif /* ACE_HAS_STREAM_PIPES */
}
ACE_END_VERSIONED_NAMESPACE_DECL
|