Grid Community Toolkit  6.2.1705709074 (tag: v6.2.20240202)
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
globus_xio_system.h
1 /*
2  * Copyright 1999-2006 University of Chicago
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
21 #ifndef GLOBUS_XIO_SYSTEM_INCLUDE
22 #define GLOBUS_XIO_SYSTEM_INCLUDE
23 
24 #include "globus_common.h"
25 #include "globus_xio_types.h"
26 
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30 
31 #define GLOBUS_XIO_SYSTEM_MODULE (&globus_i_xio_system_module)
32 extern globus_module_descriptor_t globus_i_xio_system_module;
33 
34 #ifdef WIN32
35 
36 #include <windows.h>
37 #include <winsock2.h>
38 #define GLOBUS_XIO_SYSTEM_INVALID_FILE INVALID_HANDLE_VALUE
39 #define GLOBUS_XIO_SYSTEM_INVALID_SOCKET INVALID_SOCKET
40 
41 typedef struct globus_l_xio_win32_file_s * globus_xio_system_file_handle_t;
42 typedef struct globus_l_xio_win32_socket_s * globus_xio_system_socket_handle_t;
43 
44 typedef SOCKET globus_xio_system_socket_t;
45 typedef HANDLE globus_xio_system_file_t;
46 
47 #else
48 
49 #define GLOBUS_XIO_SYSTEM_INVALID_FILE -1
50 #define GLOBUS_XIO_SYSTEM_INVALID_SOCKET -1
51 
52 /* these are handles to this interface */
53 typedef struct globus_l_xio_system_s * globus_xio_system_file_handle_t;
54 typedef struct globus_l_xio_system_s * globus_xio_system_socket_handle_t;
55 
56 /* these are the native descriptor types */
57 typedef int globus_xio_system_socket_t;
58 typedef int globus_xio_system_file_t;
59 
60 /* deprecated, do not use! */
61 typedef int globus_xio_system_native_handle_t;
62 #endif
63 
64 typedef enum
65 {
66  GLOBUS_XIO_SYSTEM_ERROR_SYSTEM_ERROR = 1024,
67  GLOBUS_XIO_SYSTEM_ERROR_TOO_MANY_FDS,
68  GLOBUS_XIO_SYSTEM_ERROR_ALREADY_REGISTERED,
69  GLOBUS_XIO_SYSTEM_ERROR_OPERATION_CANCELED,
70  GLOBUS_XIO_SYSTEM_ERROR_NOT_REGISTERED
71 } globus_xio_system_error_type_t;
72 
73 typedef enum
74 {
75  GLOBUS_XIO_SYSTEM_FILE = 1,
76  GLOBUS_XIO_SYSTEM_TCP,
77  GLOBUS_XIO_SYSTEM_TCP_LISTENER,
78  GLOBUS_XIO_SYSTEM_UDP
79 } globus_xio_system_type_t;
80 
81 typedef void
82 (*globus_xio_system_callback_t)(
83  globus_result_t result,
84  void * user_arg);
85 
86 typedef void
87 (*globus_xio_system_data_callback_t)(
88  globus_result_t result,
89  globus_size_t nbytes,
90  void * user_arg);
91 
101 globus_xio_system_file_init(
102  globus_xio_system_file_handle_t * handle,
103  globus_xio_system_file_t fd);
104 
105 /* this does *not* close the native handle.
106  * It should remove the non-blocking setting
107  *
108  * do not call this with outstanding operations. you can call it from with
109  * a callback
110  */
111 void
112 globus_xio_system_file_destroy(
113  globus_xio_system_file_handle_t handle);
114 
116 globus_xio_system_file_register_read(
117  globus_xio_operation_t op,
118  globus_xio_system_file_handle_t handle,
119  globus_off_t offset,
120  const globus_xio_iovec_t * iov,
121  int iovc,
122  globus_size_t waitforbytes,
123  globus_xio_system_data_callback_t callback,
124  void * user_arg);
125 
127 globus_xio_system_file_register_write(
128  globus_xio_operation_t op,
129  globus_xio_system_file_handle_t handle,
130  globus_off_t offset,
131  const globus_xio_iovec_t * iov,
132  int iovc,
133  globus_size_t waitforbytes,
134  globus_xio_system_data_callback_t callback,
135  void * user_arg);
136 
137 /* pass 0 for waitforbytes to not block */
139 globus_xio_system_file_read(
140  globus_xio_system_file_handle_t handle,
141  globus_off_t offset,
142  const globus_xio_iovec_t * iov,
143  int iovc,
144  globus_size_t waitforbytes,
145  globus_size_t * nbytes);
146 
148 globus_xio_system_file_write(
149  globus_xio_system_file_handle_t handle,
150  globus_off_t offset,
151  const globus_xio_iovec_t * iov,
152  int iovc,
153  globus_size_t waitforbytes,
154  globus_size_t * nbytes);
155 
156 /* syscall abstractions */
157 globus_off_t
158 globus_xio_system_file_get_position(
159  globus_xio_system_file_t fd);
160 
161 globus_off_t
162 globus_xio_system_file_get_size(
163  globus_xio_system_file_t fd);
164 
165 globus_xio_system_file_t
166 globus_xio_system_convert_stdio(
167  const char * stdio);
168 
170 globus_xio_system_file_truncate(
171  globus_xio_system_file_t fd,
172  globus_off_t size);
173 
175 globus_xio_system_file_open(
176  globus_xio_system_file_t * fd,
177  const char * filename,
178  int flags,
179  unsigned long mode);
180 
182 globus_xio_system_file_close(
183  globus_xio_system_file_t fd);
184 
191 globus_xio_system_socket_init(
192  globus_xio_system_socket_handle_t * handle,
193  globus_xio_system_socket_t socket,
194  globus_xio_system_type_t type);
195 
196 /* this does *not* close the native handle.
197  * It should remove the non-blocking setting
198  *
199  * do not call this with outstanding operations. you can call it from with
200  * a callback
201  */
202 void
203 globus_xio_system_socket_destroy(
204  globus_xio_system_socket_handle_t handle);
205 
207 globus_xio_system_socket_register_connect(
208  globus_xio_operation_t op,
209  globus_xio_system_socket_handle_t handle,
210  globus_sockaddr_t * addr,
211  globus_xio_system_callback_t callback,
212  void * user_arg);
213 
215 globus_xio_system_socket_register_accept(
216  globus_xio_operation_t op,
217  globus_xio_system_socket_handle_t listener_handle,
218  globus_xio_system_socket_t * out_handle,
219  globus_xio_system_callback_t callback,
220  void * user_arg);
221 
222 /* if using from, probably want waitforbytes to be 1 */
223 /* if waitforbytes == 0 and iov[0].iov_len == 0
224  * behave like select()... ie notify when data ready
225  */
227 globus_xio_system_socket_register_read(
228  globus_xio_operation_t op,
229  globus_xio_system_socket_handle_t handle,
230  const globus_xio_iovec_t * iov,
231  int iovc,
232  globus_size_t waitforbytes,
233  int flags,
234  globus_sockaddr_t * out_from,
235  globus_xio_system_data_callback_t callback,
236  void * user_arg);
237 
238 /* if waitforbytes == 0 and iov[0].iov_len == 0
239  * behave like select()... ie notify when data ready
240  */
242 globus_xio_system_socket_register_write(
243  globus_xio_operation_t op,
244  globus_xio_system_socket_handle_t handle,
245  const globus_xio_iovec_t * iov,
246  int iovc,
247  globus_size_t waitforbytes,
248  int flags,
249  globus_sockaddr_t * to,
250  globus_xio_system_data_callback_t callback,
251  void * user_arg);
252 
253 /* if waitforbytes == 0, do a non-blocking read */
255 globus_xio_system_socket_read(
256  globus_xio_system_socket_handle_t handle,
257  const globus_xio_iovec_t * iov,
258  int iovc,
259  globus_size_t waitforbytes,
260  int flags,
261  globus_sockaddr_t * from,
262  globus_size_t * nbytes);
263 
264 /* if waitforbytes == 0, do a non-blocking write */
266 globus_xio_system_socket_write(
267  globus_xio_system_socket_handle_t handle,
268  const globus_xio_iovec_t * iov,
269  int iovc,
270  globus_size_t waitforbytes,
271  int flags,
272  globus_sockaddr_t * to,
273  globus_size_t * nbytes);
274 
275 /* syscall abstractions */
277 globus_xio_system_socket_create(
278  globus_xio_system_socket_t * socket,
279  int domain,
280  int type,
281  int protocol);
282 
284 globus_xio_system_socket_setsockopt(
285  globus_xio_system_socket_t socket,
286  int level,
287  int optname,
288  const void * optval,
289  globus_socklen_t optlen);
290 
292 globus_xio_system_socket_getsockopt(
293  globus_xio_system_socket_t socket,
294  int level,
295  int optname,
296  void * optval,
297  globus_socklen_t * optlen);
298 
300 globus_xio_system_socket_getsockname(
301  globus_xio_system_socket_t socket,
302  struct sockaddr * name,
303  globus_socklen_t * namelen);
304 
306 globus_xio_system_socket_getpeername(
307  globus_xio_system_socket_t socket,
308  struct sockaddr * name,
309  globus_socklen_t * namelen);
310 
312 globus_xio_system_socket_bind(
313  globus_xio_system_socket_t socket,
314  struct sockaddr * addr,
315  globus_socklen_t addrlen);
316 
318 globus_xio_system_socket_listen(
319  globus_xio_system_socket_t socket,
320  int backlog);
321 
323 globus_xio_system_socket_connect(
324  globus_xio_system_socket_t socket,
325  const struct sockaddr * addr,
326  globus_socklen_t addrlen);
327 
329 globus_xio_system_socket_close(
330  globus_xio_system_socket_t socket);
331 
332 #ifdef WIN32
333 
340 #undef S_IRWXU
341 #define S_IRWXU 0
342 #undef S_IRUSR
343 #define S_IRUSR 0
344 #undef S_IWUSR
345 #define S_IWUSR 0
346 #undef S_IXUSR
347 #define S_IXUSR 0
348 #undef S_IRWXO
349 #define S_IRWXO 0
350 #undef S_IROTH
351 #define S_IROTH 0
352 #undef S_IWOTH
353 #define S_IWOTH 0
354 #undef S_IXOTH
355 #define S_IXOTH 0
356 #undef S_IRWXG
357 #define S_IRWXG 0
358 #undef S_IRGRP
359 #define S_IRGRP 0
360 #undef S_IWGRP
361 #define S_IWGRP 0
362 #undef S_IXGRP
363 #define S_IXGRP 0
364 
365 #endif
366 
367 #ifdef __cplusplus
368 }
369 #endif
370 
371 #endif
socklen_t globus_socklen_t
Size of a socket length parameter.
Definition: globus_types.h:68
size_t globus_size_t
Standard size of memory objectThe globus_size_t is the size of a memory object. It is identical to si...
Definition: globus_types.h:48
Headers common to all of Globus.
uint32_t globus_result_t
Definition: globus_types.h:99
Module Descriptor.
Definition: globus_module.h:71