FairRoot
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
f_stccomm.h
Go to the documentation of this file.
1 /********************************************************************************
2  * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
3  * *
4  * This software is distributed under the terms of the *
5  * GNU Lesser General Public Licence (LGPL) version 3, *
6  * copied verbatim in the file "LICENSE" *
7  ********************************************************************************/
8 #ifndef F_STCCOMM
9 #define F_STCCOMM
10 
11 #include "typedefs.h" /* typedef INTS1, INTS2, ... */
12 
13 #ifndef OSK
23 
24 void f_stc_swap4(INTS4*);
25 
26 #endif
27 
28 #ifdef GSI__WINNT
29 
30 #include <errno.h>
31 #include <io.h>
32 #include <stdio.h>
33 #include <stdlib.h>
34 #include <string.h>
35 #include <sys/types.h>
36 #include <winsock.h>
37 #define bzero(a, n) memset(a, 0, n)
38 
39 #endif
40 /* **************** WINDOWS_NT ********************************/
41 
42 #ifdef VMS
43 INTS4 SYS$TRNLNM();
44 #endif
45 
46 #ifdef _HPUX_SOURCE
47 #include </usr/include/sys/errno.h>
48 #include <arpa/inet.h>
49 #include <netdb.h>
50 #include <netinet/in.h>
51 #include <signal.h>
52 #include <stdio.h>
53 #include <sys/socket.h>
54 #include <sys/types.h>
55 #include <sys/uio.h>
56 #include <time.h>
57 #endif
58 
59 #ifdef VMS
60 #include <ctype.h>
61 #include <errno.h>
62 #include <in.h>
63 #include <math.h>
64 #include <netdb.h>
65 #include <signal.h>
66 #include <stdio.h>
67 #include <stdlib.h>
68 #include <string.h>
69 #include <time.h>
70 #include <unixio.h>
71 /*
72  * The maximum number of file descriptors is now a configurable option
73  * (max_nofile variable in /sys/conf/{mips|vax}/param.c).
74  * The getdtablesize(2) system call should be used to obtain the
75  * current limit. The value returned by getdtablesize() must be greater
76  * than 64, and less than or equal to MAX_NOFILE in types.h . The
77  * MAX_NOFILE define is needed for backward compatability with broken
78  * programs that need a static sized array for selecting. These programs
79  * should be modified to use the getdtablesize() interface for sizing.
80  */
81 #define MAX_NOFILE 4096 /* This should not exist ! */
82 #define NBBY 8 /* number of bits in a byte */
83 /*
84  * Select uses bit masks of file descriptors in longs.
85  * These macros manipulate such bit fields (the filesystem macros use chars).
86  * FD_SETSIZE may be defined by the user, but the default here
87  * should be >= NOFILE (param.h).
88  */
89 #ifndef FD_SETSIZE
90 #define FD_SETSIZE MAX_NOFILE
91 #endif /* FD_SETSIZE */
92 
93 /* How many things we'll allow select to use. 0 if unlimited */
94 
95 #define MAXSELFD MAX_NOFILE
96 /*typedef INTS4 fd_mask;*/
97 #define NFDBITS (sizeof(fd_mask) * NBBY) /* bits per mask (power of 2!)*/
98 #define NFDSHIFT 5 /* Shift based on above */
99 #ifndef howmany
100 #define howmany(x, y) (((x) + ((y)-1)) / (y))
101 #endif /* howmany */
102 
103 #define bzero(a, n) memset(a, 0, n)
104 #define FD_SET(n, p) ((p)->fds_bits[(n) / NFDBITS] |= (1 << ((n) % NFDBITS)))
105 #define FD_CLR(n, p) ((p)->fds_bits[(n) / NFDBITS] &= ~(1 << ((n) % NFDBITS)))
106 #define FD_ISSET(n, p) ((p)->fds_bits[(n) / NFDBITS] & (1 << ((n) % NFDBITS)))
107 #define FD_ZERO(p) bzero((INTS1*)(p), sizeof(*(p)))
108 
109 #endif /* VMS */
110 
111 #ifdef OSK
112 #include <errno.h>
113 #include <in.h>
114 #include <netdb.h>
115 #include <signal.h>
116 #include <socket.h>
117 #include <stdio.h>
118 #include <time.h>
119 #include <types.h>
120 
121 struct timeval
122 {
123  INTS4 tv_sec;
124  INTS4 tv_usec;
125 };
126 
127 #endif /* OSK */
128 
129 #ifdef ultrix
130 #include <arpa/inet.h>
131 #include <errno.h>
132 #include <netdb.h>
133 #include <netinet/in.h>
134 #include <signal.h>
135 #include <stdio.h>
136 #include <sys/socket.h>
137 #include <sys/types.h>
138 #include <sys/uio.h>
139 #include <time.h>
140 #endif
141 
142 #ifdef Lynx
143 #include <arpa/inet.h>
144 #include <errno.h>
145 #include <netdb.h>
146 #include <netinet/in.h>
147 #include <signal.h>
148 #include <socket.h>
149 #include <stdio.h>
150 #include <sys/types.h>
151 #include <time.h>
152 #include <uio.h>
153 #endif
154 
155 #ifdef GSI__LINUX
156 #undef unix
157 #include <arpa/inet.h>
158 #include <errno.h>
159 #include <netdb.h>
160 #include <netinet/in.h>
161 #include <signal.h>
162 #include <stdio.h>
163 #include <string.h>
164 #include <strings.h>
165 #include <sys/socket.h>
166 #include <sys/types.h>
167 #include <sys/uio.h>
168 #include <time.h>
169 #include <unistd.h>
170 #endif
171 
172 #ifdef GSI__SOLARIS
173 #undef unix
174 #include <arpa/inet.h>
175 #include <errno.h>
176 #include <netdb.h>
177 #include <netinet/in.h>
178 #include <signal.h>
179 #include <stdio.h>
180 #include <string.h>
181 #include <strings.h>
182 #include <sys/socket.h>
183 #include <sys/types.h>
184 #include <sys/uio.h>
185 #include <time.h>
186 #include <unistd.h>
187 #endif
188 
189 #ifdef _AIX
190 #include <arpa/inet.h>
191 #include <errno.h>
192 #include <netdb.h>
193 #include <netinet/in.h>
194 #include <signal.h>
195 #include <stdio.h>
196 #include <sys/socket.h>
197 #include <sys/types.h>
198 #include <sys/uio.h>
199 #include <time.h>
200 #define _ALL_SOURCE /* for types.h typedef u_char... */
201 #define _POSIX_SOURCE /* any include is done */
202 
203 /*
204  * The maximum number of file descriptors is now a configurable option
205  * (max_nofile variable in /sys/conf/{mips|vax}/param.c).
206  * The getdtablesize(2) system call should be used to obtain the
207  * current limit. The value returned by getdtablesize() must be greater
208  * than 64, and less than or equal to MAX_NOFILE in types.h . The
209  * MAX_NOFILE define is needed for backward compatability with broken
210  * programs that need a static sized array for selecting. These programs
211  * should be modified to use the getdtablesize() interface for sizing.
212  */
213 #define MAX_NOFILE 4096 /* This should not exist ! */
214 #define NBBY 8 /* number of bits in a byte */
215 /*
216  * Select uses bit masks of file descriptors in longs.
217  * These macros manipulate such bit fields (the filesystem macros use chars).
218  * FD_SETSIZE may be defined by the user, but the default here
219  * should be >= NOFILE (param.h).
220  */
221 #ifndef FD_SETSIZE
222 #define FD_SETSIZE MAX_NOFILE
223 #endif /* FD_SETSIZE */
224 
225 /* How many things we'll allow select to use. 0 if unlimited */
226 
227 #define MAXSELFD MAX_NOFILE
228 typedef INTS4 fd_mask;
229 #define NFDBITS (sizeof(fd_mask) * NBBY) /* bits per mask (power of 2!)*/
230 #define NFDSHIFT 5 /* Shift based on above */
231 #ifndef howmany
232 #define howmany(x, y) (((x) + ((y)-1)) / (y))
233 #endif /* howmany */
234 /* fd_set and FD_x are defined in time.h
235 typedef struct fd_set {
236  fd_mask fds_bits[howmany(FD_SETSIZE, NFDBITS)];
237 } fd_set;
238 
239 #define bzero(a,n) memset(a,0,n)
240 #define FD_SET(n, p) ((p)->fds_bits[(n)/NFDBITS] |= (1 << ((n) % NFDBITS)))
241 #define FD_CLR(n, p) ((p)->fds_bits[(n)/NFDBITS] &= ~(1 << ((n) % NFDBITS)))
242 #define FD_ISSET(n, p) ((p)->fds_bits[(n)/NFDBITS] & (1 << ((n) % NFDBITS)))
243 #define FD_ZERO(p) bzero((INTS1 *)(p), sizeof(*(p)))
244 */
245 #endif /* AIX */
246 
247 #ifdef unix /* DEC OSF/1 */
248 #include <arpa/inet.h>
249 #include <errno.h>
250 #include <netdb.h>
251 #include <netinet/in.h>
252 #include <signal.h>
253 #include <stdio.h>
254 #include <stdlib.h>
255 #include <sys/socket.h>
256 #include <sys/types.h>
257 #include <sys/uio.h>
258 #include <time.h>
259 #define _ALL_SOURCE /* for types.h typedef u_char... */
260 #define _POSIX_SOURCE /* any include is done */
261 
262 /*
263  * The maximum number of file descriptors is now a configurable option
264  * (max_nofile variable in /sys/conf/{mips|vax}/param.c).
265  * The getdtablesize(2) system call should be used to obtain the
266  * current limit. The value returned by getdtablesize() must be greater
267  * than 64, and less than or equal to MAX_NOFILE in types.h . The
268  * MAX_NOFILE define is needed for backward compatability with broken
269  * programs that need a static sized array for selecting. These programs
270  * should be modified to use the getdtablesize() interface for sizing.
271  */
272 #define MAX_NOFILE 4096 /* This should not exist ! */
273 #define NBBY 8 /* number of bits in a byte */
274 /*
275  * Select uses bit masks of file descriptors in longs.
276  * These macros manipulate such bit fields (the filesystem macros use chars).
277  * FD_SETSIZE may be defined by the user, but the default here
278  * should be >= NOFILE (param.h).
279  */
280 #ifndef FD_SETSIZE
281 #define FD_SETSIZE MAX_NOFILE
282 #endif /* FD_SETSIZE */
283 
284 /* How many things we'll allow select to use. 0 if unlimited */
285 
286 #define MAXSELFD MAX_NOFILE
287 /*typedef INTS4 fd_mask;*/
288 #define NFDBITS (sizeof(fd_mask) * NBBY) /* bits per mask (power of 2!)*/
289 #define NFDSHIFT 5 /* Shift based on above */
290 #ifndef howmany
291 #define howmany(x, y) (((x) + ((y)-1)) / (y))
292 #endif /* howmany */
293 
294 /*typedef struct fd_set {
295  fd_mask fds_bits[howmany(FD_SETSIZE, NFDBITS)];
296 } fd_set;*/
297 
298 /*#define bzero(a,n) memset(a,0,n)*/
299 #define FD_SET(n, p) ((p)->fds_bits[(n) / NFDBITS] |= (1 << ((n) % NFDBITS)))
300 #define FD_CLR(n, p) ((p)->fds_bits[(n) / NFDBITS] &= ~(1 << ((n) % NFDBITS)))
301 #define FD_ISSET(n, p) ((p)->fds_bits[(n) / NFDBITS] & (1 << ((n) % NFDBITS)))
302 /*#define FD_ZERO(p) bzero((INTS1 *)(p), sizeof(*(p)))*/
303 
304 #endif /* unix */
305 
306 struct s_tcpcomm
307 {
310  struct sockaddr_in sock, sock_name;
311  struct hostent hostentstruct;
312  struct hostent* hostentptr;
314 };
315 
316 #ifdef vms
317 #define PORTSERV_DATA "portserv.dat;1"
318 #else
319 #define PORTSERV_DATA "portserv.dat"
320 #endif
321 
322 #define MAXSERVER 50
323 #define PORTSERVER_PORT 1000
324 #define PORTSERVER_M_DEF "VSBP"
325 #define PORTSERVER_S_DEF "DSAG"
326 
328 {
331 };
332 
334 {
339  INTS1 c_data[128];
341 };
342 
343 #ifdef vms
344 #include <descrip.h>
345 #include <errno.h>
346 #include <inet.h>
347 #include <iodef.h>
348 #include <lnmdef.h>
349 #include <socket.h>
350 #include <ssdef.h>
351 #include <time.h>
352 #include <types.h>
353 #include <ucx$inetdef.h>
354 #define $DSC_FXDLEN(name, string) \
355  name.dsc$w_length = strlen(string); \
356  strcpy(name.dsc$a_pointer, string);
357 #endif /* VMS */
358 
359 #define FALSE 0
360 #define TRUE 1
361 #define f_stc_nosig(ps_server) (ps_server)->i_signals = 100;
362 
363 /* ********************************************************************** */
364 /* error messages */
365 /* ********************************************************************** */
366 
367 #define STC__FAILURE 0
368 #define STC__SUCCESS 1
369 #define STC__INVSOCK 2
370 #define STC__INVBUF 3
371 #define STC__NGBUFSIZE 4
372 #define STC__INVTIME 5
373 #define STC__TIMEOUT 6
374 #define STC__NOTSOCK 7
375 #define STC__INVADDR 8
376 #define STC__INVADDRF 9
377 #define STC__SOCKNSUP 10
378 #define STC__INVPROTO 11
379 #define STC__SOCKTABF 12
380 #define STC__SOCKSPAF 13
381 #define STC__SOCKISC 14
382 #define STC__CONNTOUT 15
383 #define STC__NETUNREA 16
384 #define STC__PORTINUS 17
385 #define STC__SOCKISP 18
386 #define TPS__ECPORTS 19
387 #define TPS__EREGSERV 20
388 #define TPS__EWTOPORTS 21
389 #define TPS__ERMFRPORTS 22
390 #define TPS__EGSERVICE 23
391 #define STC__BROPIPE 24
392 #define STC__NODATA 25
393 #define STC__ECONNREF 26
394 #define STC__EINTR 27
395 #define STC__ECONNRES 28
396 
397 #define TCPCOMM_INCLUDE 1
398 
399 #endif
char INTS1
Definition: typedefs.h:17
INTS4 namelength
Definition: f_stccomm.h:308
INTS4 socket
Definition: f_stccomm.h:308
INTS4 f_stc_close(struct s_tcpcomm *ps_tcp)
Definition: f_stccomm.c:1095
struct hostent hostentstruct
Definition: f_stccomm.h:311
INTS4 f_stc_listenserver(struct s_tcpcomm *ps_server)
Definition: f_stccomm.c:1257
INTS1 c_status[12]
Definition: f_stccomm.h:330
INTS4 f_stc_disperror(INTS4 i_error, CHARS *c_dest, INTS4 i_out)
Definition: f_stccomm.c:1402
INTS4 f_stc_acceptclient(struct s_tcpcomm *ps_server, INTS4 *pi_channel)
Definition: f_stccomm.c:685
INTS4 sock_rw
Definition: f_stccomm.h:308
INTS4 f_stc_discclient(INTS4 i_channel)
Definition: f_stccomm.c:1175
INTS4 f_stc_connectserver(CHARS *c_node, INTS4 l_port, INTS4 *pi_channel, struct s_tcpcomm *ps_client)
Definition: f_stccomm.c:486
INTS1 c_serv_name[32]
Definition: f_stccomm.h:337
struct hostent * hostentptr
Definition: f_stccomm.h:312
int INTS4
Definition: typedefs.h:21
INTS1 c_message[128]
Definition: f_stccomm.h:329
INTS1 c_command[32]
Definition: f_stccomm.h:335
INTS1 c_serv_node[32]
Definition: f_stccomm.h:336
INTS4 i_signals
Definition: f_stccomm.h:309
INTS1 c_port[8]
Definition: f_stccomm.h:340
INTS1 c_data[128]
Definition: f_stccomm.h:339
INTS1 hostname[256]
Definition: f_stccomm.h:313
INTS4 f_stc_write(INTS1 *p_buffer, INTS4 i_buflen, INTS4 i_channel)
Definition: f_stccomm.c:324
void f_stc_swap4(INTS4 *)
struct sockaddr_in sock sock_name
Definition: f_stccomm.h:310
INTS4 f_stc_createserver(INTS4 *pl_port, struct s_tcpcomm *ps_server)
Definition: f_stccomm.c:846
INTS4 f_stc_read(INTS1 *p_buffer, INTS4 i_buflen, INTS4 i_channel, INTS4 i_timeout)
Definition: f_stccomm.c:123
INTS1 c_date[32]
Definition: f_stccomm.h:338