Version 1.8.0.1
[socat.git] / xio-streams.c
blobe470f3e48136d9fbf58a8539dde6f12f14e2c113
1 /* source: xio-streams.c */
2 /* Copyright Gerhard Rieger and contributors (see file CHANGES) */
3 /* Published under the GNU General Public License V.2, see file COPYING */
5 /* this file contains definitions and functions for handling POSIX STREAMS */
7 /* with this source file a new experimental approach is being introduced:
8 normally when adding a new option at least four existing files have to be
9 adapted; this is similar for new address types.
11 in the future i would like to have a more automatic assembling of socat from
12 topic oriented source files. this should make integration and control of
13 contributions more easy.
15 all code of a new topic - address and option definitions, open code, option
16 handing code, ev.parser code, etc. should go into one source file. the
17 selection of the desired code parts during the compilation is done by
18 setting cpp defines.
20 in the same was all public declarations should go in one header (.h) file.
23 /* do not compile this file directly but include it from other .c files. with
24 CPP defines you select one part you want to really get included:
26 ENABLE_OPTIONS: activate the definition of the address option records
27 ENABLE_APPLYOPTS: C code that applies the address option passed in opt
30 #ifdef ENABLE_OPTIONS
32 #ifdef I_POP
33 const struct optdesc opt_streams_i_pop_all = { "streams-i-pop-all", "pop-all", OPT_STREAMS_I_POP_ALL, GROUP_FD, PH_FD, TYPE_BOOL, OFUNC_STREAMS_I_POP_ALL, 0, 0 };
34 #endif
35 #ifdef I_PUSH
36 const struct optdesc opt_streams_i_push = { "streams-i-push", "push", OPT_STREAMS_I_PUSH, GROUP_FD, PH_FD, TYPE_STRING, OFUNC_STREAMS_I_PUSH, 0, 0 };
37 #endif
39 #elif defined(ENABLE_APPLYOPT)
41 #if 0
42 void dummy(void) {
43 if (0) { { ;
44 #endif
45 #ifdef I_POP
46 case OFUNC_STREAMS_I_POP_ALL:
47 while (Ioctl(fd, I_POP, 0) >= 0) {
48 Warn2("ioctl(%d, I_POP, 0): %s", fd, strerror(errno));
50 break;
51 #endif
52 #ifdef I_PUSH
53 case OFUNC_STREAMS_I_PUSH:
54 if (Ioctl(fd, I_PUSH, opt->value.u_string) < 0) {
55 Warn3("ioctl(%d, I_PUSH, \"%s\"): %s",
56 fd, opt->value.u_string, strerror(errno));
57 rc = -1;
59 break;
60 #endif
61 #if 0
62 } } }
63 #endif
65 #else /* !defined(ENABLE_APPLYOPT) */
67 #include "xiosysincludes.h"
68 #if WITH_STREAMS /* make this address configure dependend */
69 #include "xioopen.h"
71 #include "xio-fd.h"
72 #include "xio-socket.h" /* _xioopen_connect() */
73 #include "xio-listen.h"
74 #include "xio-ipapp.h"
75 #include "xio-openssl.h"
79 #endif /* WITH_STREAMS */
81 #endif /* !defined(ENABLE_OPTIONS) */