1
#ifndef _CFD_PROXY_COMM_H_
2
#define _CFD_PROXY_COMM_H_
4
//============================================================================
5
// Definitions of base communication functions
6
//============================================================================
9
This file is part of Code_Saturne, a general-purpose CFD tool.
11
Copyright (C) 1998-2011 EDF S.A.
13
This program is free software; you can redistribute it and/or modify it under
14
the terms of the GNU General Public License as published by the Free Software
15
Foundation; either version 2 of the License, or (at your option) any later
18
This program is distributed in the hope that it will be useful, but WITHOUT
19
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
20
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
23
You should have received a copy of the GNU General Public License along with
24
this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
25
Street, Fifth Floor, Boston, MA 02110-1301, USA.
28
//----------------------------------------------------------------------------
30
//----------------------------------------------------------------------------
32
//----------------------------------------------------------------------------
34
//----------------------------------------------------------------------------
36
#include "cfd_proxy_defs.h"
38
//----------------------------------------------------------------------------
43
} /* Fake brace to force Emacs auto-indentation back to column 0 */
45
#endif /* __cplusplus */
47
//----------------------------------------------------------------------------
49
//----------------------------------------------------------------------------
53
CFD_PROXY_COMM_MSG_NONE, // Not a message
54
CFD_PROXY_COMM_MSG_ABORT, // Emergency stop
55
CFD_PROXY_COMM_MSG_STOP, // End of communication
56
CFD_PROXY_COMM_MSG_FORWARD, // Message to forward
57
CFD_PROXY_COMM_MSG_OTHER // Undefined message type
59
} cfd_proxy_comm_msg_t;
63
CFD_PROXY_COMM_TYPE_SOCKET, // Communicate through sockets
64
CFD_PROXY_COMM_TYPE_NULL // Null communicator
66
} cfd_proxy_comm_type_t;
68
//----------------------------------------------------------------------------
70
//----------------------------------------------------------------------------
72
#define CFD_PROXY_COMM_CMD_ABORT "cmd:abort"
73
#define CFD_PROXY_COMM_CMD_STOP "cmd:stop"
74
#define CFD_PROXY_COMM_FORWARD "forward"
76
#define CFD_PROXY_COMM_PROC_ALL -1
78
#define CFD_PROXY_COMM_L_SEC_NAME 32
80
//----------------------------------------------------------------------------
81
// Structure definitions
82
//----------------------------------------------------------------------------
84
typedef struct _cfd_proxy_comm_t cfd_proxy_comm_t;
86
// Public structure used to save data from a message header, simplifying
87
// the transfer of this data to processing functions
91
char func_name[32]; // Function name
93
int comp_id; // Component id
95
int n_ints; // Number of integer values
96
int n_doubles; // Number of double-precision values
97
int n_strings; // Number of string values
99
int ints_size; // Size of array containing ints
100
int doubles_size; // Size of array containing doubles
101
int strings_size; // Size of array containing strings
103
int *int_vals; // Array of integer values
104
double *double_vals; // Array of double-precision values
105
char *string_vals; // Array of string values
107
} cfd_proxy_comm_request_t;
109
//============================================================================
111
//============================================================================
113
//============================================================================
114
// Public function prototypes
115
//============================================================================
117
//----------------------------------------------------------------------------
118
// Initialize a communicator
121
// type <-- communication type
122
// echo <-- echo on main output
123
//----------------------------------------------------------------------------
126
cfd_proxy_comm_initialize(cfd_proxy_comm_type_t type,
129
//----------------------------------------------------------------------------
130
// Finalize a communicator
131
//----------------------------------------------------------------------------
134
cfd_proxy_comm_finalize(cfd_proxy_comm_t *comm);
136
//----------------------------------------------------------------------------
137
// Establish a communicator connection
140
// comm <-> communicator
141
// magic_string <-- magic string for verification
144
// 0 in case of success, -1 otherwise;
145
//----------------------------------------------------------------------------
148
cfd_proxy_comm_connect(cfd_proxy_comm_t *comm,
149
const char *magic_string);
151
//----------------------------------------------------------------------------
152
// Get a communicator's name
154
// This function returns a pointer to an existing name, so the string
155
// returned should not be freed by the user.
156
//----------------------------------------------------------------------------
159
cfd_proxy_comm_get_name(const cfd_proxy_comm_t *comm);
161
//----------------------------------------------------------------------------
162
// Get a communicator's associated connection key
163
//----------------------------------------------------------------------------
166
cfd_proxy_comm_get_key(const cfd_proxy_comm_t *comm);
168
//----------------------------------------------------------------------------
169
// Initialize a function request structure.
172
// r <-> pointer to function request structure
173
//----------------------------------------------------------------------------
176
cfd_proxy_comm_init_request(cfd_proxy_comm_request_t *r);
178
//----------------------------------------------------------------------------
179
// Finalize a function request structure.
182
// r <-> pointer to function request structure
183
//----------------------------------------------------------------------------
186
cfd_proxy_comm_finalize_request(cfd_proxy_comm_request_t *r);
188
//----------------------------------------------------------------------------
189
// Write a record to a client.
192
// comm <-- communicator
193
// rec <-- pointer to data to write
194
// size <-- size of each data element, in bytes
195
// count <-- number of data elements
198
// 0 if request was written correctly, -2 for error
199
//----------------------------------------------------------------------------
202
cfd_proxy_comm_write(cfd_proxy_comm_t *comm,
207
//----------------------------------------------------------------------------
208
// Read a record from a proxy.
211
// comm <-- communicator
212
// rec --> pointer to data to write
213
// size <-- size of each data element, in bytes
214
// count <-- number of data elements
217
// 0 if request was read correctly, -1 for end-of-file, -2 for error
218
//----------------------------------------------------------------------------
221
cfd_proxy_comm_read(cfd_proxy_comm_t *comm,
226
//----------------------------------------------------------------------------
227
// Read a function-relay response from a proxy.
230
// comm <-> communicator
231
// r <-> pointer to function request structure
234
// 0 if request was read correctly, -1 for end-of-file, -2 for error
235
//----------------------------------------------------------------------------*/
238
cfd_proxy_comm_read_request(cfd_proxy_comm_t *comm,
239
cfd_proxy_comm_request_t *r);
241
//----------------------------------------------------------------------------
242
// Send a function-relay response to a proxy.
245
// comm <-- communicator
246
// retcode <-- function return code
247
// comp_id <-- associated component id
248
// n_ints <-- number of integer arguments
249
// n_doubles <-- number of floating-point arguments
250
// n_strings <-- number of string arguments
251
// int_vals <-- integer argument values
252
// double_vals <-- floating-point argument values
253
// string_vals <-- string argument values
256
// 0 if response was written correctly, -2 for error
257
//----------------------------------------------------------------------------
260
cfd_proxy_comm_write_response(cfd_proxy_comm_t *comm,
265
const int int_vals[],
266
const double double_vals[],
267
const char *string_vals[]);
269
//----------------------------------------------------------------------------
273
#endif /* __cplusplus */
275
#endif /* _CFD_PROXY_COMM_H_ */