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",
26 #if HAVE_STRUCT_LINGER
29 #if HAVE_STRUCT_IP_MREQN
31 #elif HAVE_STRUCT_IP_MREQ
37 /* keep consistent with xioopts.h:#define GROUP_* ! */
38 static const char *addressgroupnames
[] = {
39 "FD", "FIFO", "CHR", "BLK",
40 "REG", "SOCKET", "READLINE", "undef",
41 "NAMED", "OPEN", "EXEC", "FORK",
42 "LISTEN", "DEVICE", "CHILD", "RETRY",
43 "TERMIOS", "RANGE", "PTY", "PARENT",
44 "UNIX", "IP4", "IP6", "INTERFACE",
45 "UDP", "TCP", "SOCKS4", "OPENSSL",
46 "PROCESS", "APPL", "HTTP", "SCTP"
50 /* keep consistent with xioopts.h:enum ephase ! */
51 static char *optionphasenames
[] = {
52 "ALL", "INIT", "EARLY",
53 "PREOPEN", "OPEN", "PASTOPEN",
54 "PRESOCKET", "SOCKET", "PASTSOCKET",
55 "PREBIGEN", "BIGEN", "PASTBIGEN",
57 "PREBIND", "BIND", "PASTBIND",
58 "PRELISTEN", "LISTEN", "PASTLISTEN",
59 "PRECONNECT", "CONNECT", "PASTCONNECT",
60 "PREACCEPT", "ACCEPT", "PASTACCEPT",
62 "PREFORK", "FORK", "PASTFORK",
64 "PREEXEC", "EXEC", "SPECIFIC",
69 /* print a line about a single option */
70 static int xiohelp_option(FILE *of
, const struct optname
*on
, const char *name
) {
75 fprintf(of
, " %s\tgroups=", name
);
76 groups
= on
->desc
->group
; occurred
= false;
77 for (j
= 0; j
< 32; ++j
) {
79 if (occurred
) { fputc(',', of
); }
80 fprintf(of
, "%s", addressgroupnames
[j
]);
85 fprintf(of
, "\tphase=%s", optionphasenames
[on
->desc
->phase
]);
86 fprintf(of
, "\ttype=%s", optiontypenames
[on
->desc
->type
]);
91 int xioopenhelp(FILE *of
,
92 int level
/* 0..only addresses, 1..and options */
94 const struct addrname
*an
;
95 const struct optname
*on
;
100 fputs(" bi-address:\n", of
);
101 fputs(" pipe[,<opts>]\tgroups=FD,FIFO\n", of
);
103 fputs(" echo is an alias for pipe\n", of
);
104 fputs(" fifo is an alias for pipe\n", of
);
106 fputs(" <single-address>!!<single-address>\n", of
);
107 fputs(" <single-address>\n", of
);
108 fputs(" single-address:\n", of
);
109 fputs(" <address-head>[,<opts>]\n", of
);
110 fputs(" address-head:\n", of
);
111 an
= &addressnames
[0];
113 while (addressnames
[i
].name
) {
114 if (!strcmp(an
->name
, an
->desc
->defname
)) {
115 /* it is a canonical address name */
116 fprintf(of
, " %s", an
->name
);
117 if (an
->desc
->syntax
) {
118 fputs(an
->desc
->syntax
, of
); }
119 fputs("\tgroups=", of
);
120 groups
= an
->desc
->groups
; occurred
= false;
121 for (j
= 0; j
< 32; ++j
) {
123 if (occurred
) { fputc(',', of
); }
124 fprintf(of
, "%s", addressgroupnames
[j
]);
130 } else if (level
== 2) {
131 fprintf(of
, " %s is an alias name for %s\n", an
->name
, an
->desc
->defname
);
136 fputs(" <num> is a short form for fd:<num>\n", of
);
137 fputs(" <filename> is a short form for gopen:<filename>\n", of
);
140 if (level
<= 0) return 0;
142 fputs(" opts:\n", of
);
143 fputs(" <opt>{,<opts>}:\n", of
);
144 fputs(" opt:\n", of
);
146 while (on
->name
!= NULL
) {
147 if (on
->desc
->nickname
!= NULL
148 && !strcmp(on
->name
, on
->desc
->nickname
)) {
150 fprintf(of
, " %s is an alias for %s\n", on
->name
, on
->desc
->defname
);
152 xiohelp_option(of
, on
, on
->name
);
154 } else if (on
->desc
->nickname
== NULL
&&
155 !strcmp(on
->name
, on
->desc
->defname
)) {
156 xiohelp_option(of
, on
, on
->name
);
157 } else if (level
== 2) {
158 if (!strcmp(on
->name
, on
->desc
->defname
)) {
159 xiohelp_option(of
, on
, on
->name
);
161 fprintf(of
, " %s is an alias for %s\n", on
->name
, on
->desc
->defname
);
170 #endif /* WITH_HELP */