1
#ifndef __CS_PROXY_COMM_H__
2
#define __CS_PROXY_COMM_H__
4
/*============================================================================
5
* Base communication functions for use with proxy
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
*----------------------------------------------------------------------------*/
36
/*----------------------------------------------------------------------------*/
40
/*============================================================================
42
*============================================================================*/
44
#define CS_PROXY_COMM_CMD_ABORT "cmd:abort"
45
#define CS_PROXY_COMM_CMD_STOP "cmd:stop"
46
#define CS_PROXY_COMM_FORWARD "forward"
48
#define CS_PROXY_COMM_L_SEC_NAME 32
50
/*============================================================================
51
* Type and structure definitions
52
*============================================================================*/
63
CS_PROXY_COMM_MSG_NONE, /* Not a message */
64
CS_PROXY_COMM_MSG_ABORT, /* Emergency stop */
65
CS_PROXY_COMM_MSG_STOP, /* End of communication */
66
CS_PROXY_COMM_MSG_FORWARD, /* Message to forward */
67
CS_PROXY_COMM_MSG_OTHER /* Undefined message type */
69
} cs_proxy_comm_msg_t;
73
CS_PROXY_COMM_TYPE_SOCKET, /* Communicate through sockets */
74
CS_PROXY_COMM_TYPE_NULL /* Null communicator */
76
} cs_proxy_comm_type_t;
78
typedef struct _cs_proxy_comm_t cs_proxy_comm_t;
80
/* Public structure used to save data from a message header, simplifying
81
the transfer of this data to processing functions */
85
cs_proxy_comm_msg_t msg_type;
87
char sec_name[CS_PROXY_COMM_L_SEC_NAME + 1];
91
} cs_proxy_comm_msg_header_t;
93
/*============================================================================
95
*============================================================================*/
97
/*============================================================================
98
* Public function prototypes
99
*============================================================================*/
101
/*----------------------------------------------------------------------------
102
* Establish a connection to a proxy.
105
* port_name <-- name of server port (host:port for IP sockets)
106
* key <-- key for authentification
107
* type <-- communication type
108
*----------------------------------------------------------------------------*/
111
cs_proxy_comm_initialize(const char *port_name,
113
cs_proxy_comm_type_t type);
115
/*----------------------------------------------------------------------------
116
* Finalize a connection to a proxy.
117
*----------------------------------------------------------------------------*/
120
cs_proxy_comm_finalize(void);
122
/*----------------------------------------------------------------------------
123
* Write a record to a proxy.
126
* rec <-- pointer to data to write
127
* size <-- size of each data element, in bytes
128
* count <-- number of data elements
129
*----------------------------------------------------------------------------*/
132
cs_proxy_comm_write(const void *rec,
136
/*----------------------------------------------------------------------------
137
* Read a record from a proxy.
140
* rec --> pointer to data to write
141
* size <-- size of each data element, in bytes
142
* count <-- number of data elements
143
*----------------------------------------------------------------------------*/
146
cs_proxy_comm_read(void *rec,
150
/*----------------------------------------------------------------------------
151
* Send a function-relay request to a proxy.
154
* func_name <-- name of function associated with request
155
* comp_id <-- associated component id
156
* n_ints <-- number of integer arguments
157
* n_doubles <-- number of floating-point arguments
158
* n_strings <-- number of string arguments
159
* int_vals <-- integer argument values
160
* double_vals <-- floating-point argument values
161
* string_vals <-- string argument values
162
*----------------------------------------------------------------------------*/
165
cs_proxy_comm_write_request(const char *func_name,
170
const int int_vals[],
171
const double double_vals[],
172
const char *string_vals[]);
174
/*----------------------------------------------------------------------------
175
* Read a function-relay response from a proxy.
177
* Return value arrays must be large enough to receive all values.
180
* n_ints <-- number of integer arguments
181
* n_doubles <-- number of floating-point arguments
182
* n_strings <-- number of string arguments
183
* int_vals --> integer argument values
184
* double_vals --> floating-point argument values
185
* string_vals --> string argument values
188
* the relayed function's return value
189
*----------------------------------------------------------------------------*/
192
cs_proxy_comm_read_response(int n_ints,
196
double double_vals[],
197
char *string_vals[]);
199
/*----------------------------------------------------------------------------*/
203
#endif /* __CS_PROXY_COMM_H__ */