2
* Copyright 1999-2006 University of Chicago
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
8
* http://www.apache.org/licenses/LICENSE-2.0
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.
17
#ifndef GLOBUS_I_GFS_IPC_H
18
#define GLOBUS_I_GFS_IPC_H
20
#include "globus_i_gridftp_server.h"
22
/************************************************************************
25
***********************************************************************/
26
#define GFSEncodeUInt32(_start, _len, _buf, _w) \
31
_ndx = (globus_byte_t *)_buf - (globus_byte_t *)_start; \
32
/* verify buffer size */ \
36
_start = globus_libc_realloc(_start, _len); \
37
_buf = _start + _ndx; \
39
_cw = htonl((uint32_t)_w); \
40
memcpy(_buf, &_cw, 4); \
44
#define GFSDecodeUInt32P(_buf, _len, _w) \
48
/* verify buffer size */ \
53
memcpy(&_cw, _buf, 4); \
54
_w = (void *) htonl((uint32_t)_cw); \
59
#define GFSDecodeUInt32(_buf, _len, _w) \
63
/* verify buffer size */ \
68
memcpy(&_cw, _buf, 4); \
69
_w = htonl((uint32_t)_cw); \
76
* if architecture is big endian already
78
#if defined(WORDS_BIGENDIAN)
80
#define GFSEncodeUInt64(_start, _len, _buf, _w) \
84
_ndx = (globus_byte_t *)_buf - (globus_byte_t *)_start; \
88
_start = globus_libc_realloc(_start, _len); \
89
_buf = _start + _ndx; \
91
memcpy(_buf, &_w, 8); \
95
#define GFSDecodeUInt64(_buf, _len, _w) \
103
memcpy(&_w, _buf, 8); \
109
/* not a big indian arch */
110
#define GFSEncodeUInt64(_start, _len, _buf, _w) \
113
globus_size_t _ndx; \
115
uint32_t _lo = _w & 0xffffffff; \
116
uint32_t _hi = _w >> 32U; \
118
_ndx = (globus_byte_t *)_buf - (globus_byte_t *)_start; \
119
if(_ndx + 8 > _len) \
122
_start = globus_libc_realloc(_start, _len); \
123
_buf = _start + _ndx; \
128
_cw = ((uint64_t) _lo) << 32U | _hi; \
129
memcpy(_buf, &_cw, 8); \
133
#define GFSDecodeUInt64(_buf, _len, _w) \
145
memcpy(&_cw, _buf, 8); \
146
_lo = _cw & 0xffffffff; \
150
_w = ((uint64_t) _lo) << 32U | _hi; \
156
#define GFSEncodeChar(_start, _len, _buf, _w) \
159
globus_size_t _ndx; \
160
_ndx = (globus_byte_t *)_buf - (globus_byte_t *)_start; \
164
_start = globus_libc_realloc(_start, _len); \
165
_buf = _start + _ndx; \
171
#define GFSDecodeChar(_buf, _len, _w) \
183
#define GFSEncodeString(_start, _len, _buf, _w) \
186
char * _str=(char*)_w; \
189
GFSEncodeUInt32(_start, _len, _buf, 0); \
193
GFSEncodeUInt32(_start, _len, _buf, strlen(_str)+1); \
194
for(_str = (char *)_w; *_str != '\0'; _str++) \
196
GFSEncodeChar(_start, _len, _buf, *_str); \
201
#define GFSDecodeString(_buf, _len, _w) \
206
/* make sure that strip in terminated properly */ \
207
GFSDecodeUInt32(_buf, _len, _sz); \
211
for(_ctr = 0; _ctr < _sz - 1; _ctr++) \
213
GFSDecodeChar(_buf, _len, _w[_ctr]); \
223
typedef struct globus_i_gfs_community_s
230
} globus_i_gfs_community_t;
232
extern globus_xio_stack_t globus_i_gfs_ipc_xio_stack;
233
extern globus_i_gfs_community_t * globus_i_gfs_ipc_community_default;
234
extern globus_xio_driver_t globus_i_gfs_tcp_driver;