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