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
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
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 };
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 };
39 #elif defined(ENABLE_APPLYOPT)
46 } else if (opt
->desc
->func
== OFUNC_STREAMS_I_POP_ALL
) {
47 while (Ioctl(fd
, I_POP
, 0) >= 0) {
48 Warn2("ioctl(%d, I_POP, 0): %s", fd
, strerror(errno
));
52 } else if (opt
->desc
->func
== OFUNC_STREAMS_I_PUSH
) {
53 if (Ioctl(fd
, I_PUSH
, opt
->value
.u_string
) < 0) {
54 Warn3("ioctl(%d, I_PUSH, \"%s\"): %s",
55 fd
, opt
->value
.u_string
, strerror(errno
));
56 opt
->desc
= ODESC_ERROR
; ++opt
; continue;
63 #else /* !defined(ENABLE_APPLYOPT) */
65 #include "xiosysincludes.h"
66 #if WITH_STREAMS /* make this address configure dependend */
70 #include "xio-socket.h" /* _xioopen_connect() */
71 #include "xio-listen.h"
72 #include "xio-ipapp.h"
73 #include "xio-openssl.h"
77 #endif /* WITH_STREAMS */
79 #endif /* !defined(ENABLE_OPTIONS) */