17 #ifndef GLOBUS_XIO_UTIL_INCLUDE
18 #define GLOBUS_XIO_UTIL_INCLUDE
20 #include "globus_xio.h"
27 globus_xio_get_env_pair(
28 const char * env_name,
33 globus_xio_error_is_eof(
37 globus_xio_error_is_canceled(
41 globus_xio_driver_error_match(
42 globus_xio_driver_t driver,
43 globus_object_t * error,
47 globus_xio_driver_error_match_with_cb(
48 globus_xio_driver_t driver,
49 globus_object_t * error,
50 globus_extension_error_match_cb_t callback,
54 globus_xio_error_match(
59 globus_xio_contact_destroy(
60 globus_xio_contact_t * contact_info);
63 globus_xio_contact_parse(
64 globus_xio_contact_t * contact_info,
65 const char * contact_string);
68 globus_xio_contact_info_to_string(
69 const globus_xio_contact_t * contact_info,
70 char ** contact_string);
73 globus_xio_contact_info_to_url(
74 const globus_xio_contact_t * contact_info,
75 char ** contact_string);
78 globus_xio_contact_info_to_encoded_string(
79 const globus_xio_contact_t * contact_info,
80 const globus_xio_contact_t * encode_chars,
81 char ** contact_string);
84 globus_xio_contact_copy(
85 globus_xio_contact_t * dst,
86 const globus_xio_contact_t * src);
96 #define GlobusXIOName(func) static const char * _xio_name __attribute__((__unused__)) = #func
98 #define GlobusXIOName(func) static const char * _xio_name = #func
101 #define GlobusXIOErrorCanceled() \
102 globus_error_put(GlobusXIOErrorObjCanceled())
104 #define GlobusXIOErrorObjCanceled() \
105 globus_error_construct_error( \
108 GLOBUS_XIO_ERROR_CANCELED, \
112 _XIOSL("Operation was canceled"))
113 #define GlobusXIOErrorTimeout() \
114 globus_error_put(GlobusXIOErrorObjTimeout())
116 #define GlobusXIOErrorObjTimeout() \
117 globus_error_construct_error( \
119 GlobusXIOErrorObjTimeoutOnly(), \
120 GLOBUS_XIO_ERROR_CANCELED, \
124 _XIOSL("Operation was canceled"))
126 #define GlobusXIOErrorObjTimeoutOnly() \
127 globus_error_construct_error( \
130 GLOBUS_XIO_ERROR_TIMEOUT, \
134 _XIOSL("Operation timed out"))
136 #define GlobusXIOErrorObjEOF() \
137 globus_error_construct_error( \
140 GLOBUS_XIO_ERROR_EOF, \
144 _XIOSL("An end of file occurred"))
146 #define GlobusXIOErrorEOF() \
148 GlobusXIOErrorObjEOF()) \
150 #define GlobusXIOErrorInvalidCommand(cmd_number) \
152 globus_error_construct_error( \
155 GLOBUS_XIO_ERROR_COMMAND, \
159 _XIOSL("An invalid command (%d) was issued"), \
162 #define GlobusXIOErrorContactString(reason) \
164 globus_error_construct_error( \
167 GLOBUS_XIO_ERROR_CONTACT_STRING, \
171 _XIOSL("Contact string invalid. %s"), \
174 #define GlobusXIOErrorObjParameter(param_name) \
175 globus_error_construct_error( \
178 GLOBUS_XIO_ERROR_PARAMETER, \
182 _XIOSL("Bad parameter, %s"), \
185 #define GlobusXIOErrorParameter(param_name) \
187 GlobusXIOErrorObjParameter(param_name))
189 #define GlobusXIOErrorObjMemory(mem_name) \
190 globus_error_construct_error( \
193 GLOBUS_XIO_ERROR_MEMORY, \
197 _XIOSL("Memory allocation failed on %s"), \
200 #define GlobusXIOErrorMemory(mem_name_obj) \
202 GlobusXIOErrorObjMemory(mem_name_obj))
204 #define GlobusXIOErrorObjSystemError(system_func, _errno) \
205 globus_error_wrap_errno_error( \
208 GLOBUS_XIO_ERROR_SYSTEM_ERROR, \
212 _XIOSL("System error in %s"), \
215 #define GlobusXIOErrorSystemError(system_func, _errno) \
217 GlobusXIOErrorObjSystemError(system_func, _errno))
219 #define GlobusXIOErrorSystemResource(reason) \
221 globus_error_construct_error( \
224 GLOBUS_XIO_ERROR_SYSTEM_RESOURCE, \
228 _XIOSL("System resource error, %s"), \
231 #define GlobusXIOErrorInvalidStack(reason) \
233 globus_error_construct_error( \
236 GLOBUS_XIO_ERROR_STACK, \
240 _XIOSL("Invalid stack, %s"), \
243 #define GlobusXIOErrorInvalidDriver(reason) \
245 globus_error_construct_error( \
248 GLOBUS_XIO_ERROR_DRIVER, \
252 _XIOSL("Invalid Driver, %s"), \
255 #define GlobusXIOErrorPass() \
257 globus_error_construct_error( \
260 GLOBUS_XIO_ERROR_PASS, \
264 _XIOSL("Operation passed too far")))
266 #define GlobusXIOErrorAlreadyRegistered() \
268 globus_error_construct_error( \
271 GLOBUS_XIO_ERROR_ALREADY_REGISTERED, \
275 _XIOSL("Operation already registered")))
277 #define GlobusXIOErrorInvalidState(state) \
279 globus_error_construct_error( \
282 GLOBUS_XIO_ERROR_STATE, \
286 _XIOSL("Unexpected state, %d"), \
289 #define GlobusXIOErrorWrapFailed(failed_func, result) \
291 globus_error_construct_error( \
293 globus_error_get((result)), \
294 GLOBUS_XIO_ERROR_WRAPPED, \
298 _XIOSL("%s failed."), \
301 #define GlobusXIOErrorWrapFailedWithMessage(result, format, arg) \
303 globus_error_construct_error( \
305 globus_error_get((result)), \
306 GLOBUS_XIO_ERROR_WRAPPED, \
313 #define GlobusXIOErrorWrapFailedWithMessage2(result, format, arg1, arg2) \
315 globus_error_construct_error( \
317 globus_error_get((result)), \
318 GLOBUS_XIO_ERROR_WRAPPED, \
325 #define GlobusXIOErrorNotRegistered() \
327 globus_error_construct_error( \
330 GLOBUS_XIO_ERROR_NOT_REGISTERED, \
334 _XIOSL("Not registered.")))
336 #define GlobusXIOErrorNotActivated() \
338 globus_error_construct_error( \
341 GLOBUS_XIO_ERROR_NOT_ACTIVATED, \
345 _XIOSL("Module not activated.")))
347 #define GlobusXIOErrorUnloaded() \
349 globus_error_construct_error( \
352 GLOBUS_XIO_ERROR_UNLOADED, \
356 _XIOSL("Driver in handle has been unloaded.")))
358 #define GlobusXIOErrorParse(arg) \
360 globus_error_construct_error( \
363 GLOBUS_XIO_ERROR_PARSE, \
367 _XIOSL("An error occurred parsing the string: %s"), arg))
370 #define GlobusIXIOUtilCopyNIovec(iov, iovc, siov, siovc, bytes) \
374 globus_size_t _tb = 0; \
375 globus_size_t _bytes; \
376 const struct iovec * _siov; \
377 struct iovec * _iov; \
387 for(_i = 0; _i < _siovc && _tb < _bytes; _i++) \
389 if(_tb + _siov[_i].iov_len > _bytes) \
391 _iov[_i].iov_len = _bytes - _tb; \
395 _iov[_i].iov_len = _siov[_i].iov_len; \
397 _tb += _siov[_i].iov_len; \
398 _iov[_i].iov_base = _siov[_i].iov_base; \
405 #define GlobusIXIOUtilTransferIovec(iov, siov, iovc) \
409 const struct iovec * _siov; \
410 struct iovec * _iov; \
417 for(_i = 0; _i < _iovc; _i++) \
419 _iov[_i].iov_base = _siov[_i].iov_base; \
420 _iov[_i].iov_len = _siov[_i].iov_len; \
424 #define GlobusIXIOUtilAdjustIovec(iov, iovc, nbytes) \
427 globus_size_t _n = (nbytes); \
431 struct iovec * _iov = (iov); \
432 int _iovc = (iovc); \
437 _i < _iovc && _n >= _iov[_i].iov_len; \
438 _n -= _iov[_i].iov_len, _i++); \
442 _iov[_i].iov_base = (char *) _iov[_i].iov_base + _n; \
443 _iov[_i].iov_len -= _n; \
451 #define GlobusIXIOUtilTransferAdjustedIovec( \
452 new_iov, new_iovc, iov, iovc, nbytes) \
456 const struct iovec * _iov; \
458 struct iovec * _new_iov; \
464 _new_iov = (new_iov); \
467 for(_i = 0, _n = (nbytes); \
468 _i < _iovc && _n >= _iov[_i].iov_len; \
469 _n -= _iov[_i].iov_len, _i++); \
471 (new_iovc) = _iovc - _i; \
474 _new_iov[0].iov_base = (char *) _iov[_i].iov_base + _n; \
475 _new_iov[0].iov_len = _iov[_i].iov_len - _n; \
478 for(_j = 1, _i++; _i < _iovc; _j++, _i++) \
480 _new_iov[_j].iov_base = _iov[_i].iov_base; \
481 _new_iov[_j].iov_len = _iov[_i].iov_len; \
486 #define GlobusXIOUtilIovTotalLength( \
487 out_len, iov, iovc) \
491 const struct iovec * _iov; \
493 globus_size_t _out_len; \
497 for(_i = 0; _i < _iovc; _i++) \
499 _out_len += _iov[_i].iov_len; \
501 out_len = _out_len; \
504 #define GlobusXIOUtilIovSerialize( \
505 out_buf, iov, iovc) \
510 for(_i = 0; _i < iovc; _i++) \
512 memcpy(&(out_buf)[_ndx], (iov)[_i].iov_base, (iov)[_i].iov_len);\
513 _ndx += (iov)[_i].iov_len; \
int globus_bool_t
Boolean type.
Definition: globus_types.h:93
uint32_t globus_result_t
Definition: globus_types.h:99