1 /* source: xiohelp.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 the source for the help function */
7 #include "xiosysincludes.h"
14 /* keep consistent with xioopts.h:enum e_types ! */
15 static const char *optiontypenames
[] = {
16 "CONST", "BIN", "BOOL", "BYTE",
17 "INT", "LONG", "STRING", "PTRDIFF",
18 "SHORT", "SIZE_T", "SOCKADDR", "UNSIGNED-INT",
19 "UNSIGNED-LONG","UNSIGNED-SHORT","MODE_T", "GID_T",
20 "UID_T", "INT[3]", "STRUCT-TIMEVAL", "STRUCT-TIMESPEC",
21 "DOUBLE", "STRING-NULL", "LONG-LONG", "OFF_T",
22 "OFF64_T", "INT:INT", "INT:INTP", "INT:BIN",
23 "INT:STRING", "INT:INT:INT", "INT:INT:BIN", "INT:INT:STRING",
27 #if HAVE_STRUCT_LINGER
30 #if HAVE_STRUCT_IP_MREQN
32 #elif HAVE_STRUCT_IP_MREQ
35 #if HAVE_STRUCT_IP_MREQ_SOURCE
42 /* keep consistent with xioopts.h:#define GROUP_* ! */
43 static const char *addressgroupnames
[] = {
44 "FD", "FIFO", "CHR", "BLK",
45 "REG", "SOCKET", "READLINE", "undef",
46 "NAMED", "OPEN", "EXEC", "FORK",
47 "LISTEN", "DEVICE", "CHILD", "RETRY",
48 "TERMIOS", "RANGE", "PTY", "PARENT",
49 "UNIX", "IP4", "IP6", "INTERFACE",
50 "UDP", "TCP", "SOCKS4", "OPENSSL",
51 "PROCESS", "APPL", "HTTP", "SCTP"
55 /* keep consistent with xioopts.h:enum ephase ! */
56 static char *optionphasenames
[] = {
57 "ALL", "INIT", "EARLY",
58 "PREOPEN", "OPEN", "PASTOPEN",
59 "PRESOCKET", "SOCKET", "PASTSOCKET",
60 "PREBIGEN", "BIGEN", "PASTBIGEN",
62 "PREBIND", "BIND", "PASTBIND",
63 "PRELISTEN", "LISTEN", "PASTLISTEN",
64 "PRECONNECT", "CONNECT", "PASTCONNECT",
65 "PREACCEPT", "ACCEPT", "PASTACCEPT",
67 "PREFORK", "FORK", "PASTFORK",
69 "PREEXEC", "EXEC", "SPECIFIC",
74 /* print a line about a single option */
75 static int xiohelp_option(FILE *of
, const struct optname
*on
, const char *name
) {
80 fprintf(of
, " %s\tgroups=", name
);
81 groups
= on
->desc
->group
; occurred
= false;
82 for (j
= 0; j
< 32; ++j
) {
84 if (occurred
) { fputc(',', of
); }
85 fprintf(of
, "%s", addressgroupnames
[j
]);
90 fprintf(of
, "\tphase=%s", optionphasenames
[on
->desc
->phase
]);
91 fprintf(of
, "\ttype=%s", optiontypenames
[on
->desc
->type
]);
96 int xioopenhelp(FILE *of
,
97 int level
/* 0..only addresses, 1..and options */
99 const struct addrname
*an
;
100 const struct optname
*on
;
105 fputs(" bi-address:\n", of
);
106 fputs(" pipe[,<opts>]\tgroups=FD,FIFO\n", of
);
108 fputs(" echo is an alias for pipe\n", of
);
109 fputs(" fifo is an alias for pipe\n", of
);
111 fputs(" <single-address>!!<single-address>\n", of
);
112 fputs(" <single-address>\n", of
);
113 fputs(" single-address:\n", of
);
114 fputs(" <address-head>[,<opts>]\n", of
);
115 fputs(" address-head:\n", of
);
116 an
= &addressnames
[0];
118 while (addressnames
[i
].name
) {
119 if (!strcmp(an
->name
, an
->desc
->defname
)) {
120 /* it is a canonical address name */
121 fprintf(of
, " %s", an
->name
);
122 if (an
->desc
->syntax
) {
123 fputs(an
->desc
->syntax
, of
); }
124 fputs("\tgroups=", of
);
125 groups
= an
->desc
->groups
; occurred
= false;
126 for (j
= 0; j
< 32; ++j
) {
128 if (occurred
) { fputc(',', of
); }
129 fprintf(of
, "%s", addressgroupnames
[j
]);
135 } else if (level
== 2) {
136 fprintf(of
, " %s is an alias name for %s\n", an
->name
, an
->desc
->defname
);
141 fputs(" <num> is a short form for fd:<num>\n", of
);
142 fputs(" <filename> is a short form for gopen:<filename>\n", of
);
145 if (level
<= 0) return 0;
147 fputs(" opts:\n", of
);
148 fputs(" <opt>{,<opts>}:\n", of
);
149 fputs(" opt:\n", of
);
151 while (on
->name
!= NULL
) {
152 if (on
->desc
->nickname
!= NULL
153 && !strcmp(on
->name
, on
->desc
->nickname
)) {
155 fprintf(of
, " %s is an alias for %s\n", on
->name
, on
->desc
->defname
);
157 xiohelp_option(of
, on
, on
->name
);
159 } else if (on
->desc
->nickname
== NULL
&&
160 !strcmp(on
->name
, on
->desc
->defname
)) {
161 xiohelp_option(of
, on
, on
->name
);
162 } else if (level
== 2) {
163 if (!strcmp(on
->name
, on
->desc
->defname
)) {
164 xiohelp_option(of
, on
, on
->name
);
166 fprintf(of
, " %s is an alias for %s\n", on
->name
, on
->desc
->defname
);
175 #endif /* WITH_HELP */