mirror of
https://repo.or.cz/socat.git
synced 2025-07-12 14:43:24 +00:00
Formatted help output; address keywords in help now uppercase
This commit is contained in:
parent
797d0f9695
commit
d36f78d854
44 changed files with 374 additions and 340 deletions
79
xiohelp.c
79
xiohelp.c
|
@ -73,22 +73,40 @@ static char *optionphasenames[] = {
|
|||
|
||||
/* print a line about a single option */
|
||||
static int xiohelp_option(FILE *of, const struct optname *on, const char *name) {
|
||||
int j;
|
||||
int chars;
|
||||
int i, j;
|
||||
groups_t groups;
|
||||
bool occurred;
|
||||
|
||||
fprintf(of, " %s\tgroups=", name);
|
||||
groups = on->desc->group; occurred = false;
|
||||
for (j = 0; j < 32; ++j) {
|
||||
chars = fprintf(of, " %s", name);
|
||||
i = (16 - chars + 7) / 8;
|
||||
for (; i > 0; --i) { fputc('\t', of); }
|
||||
fputc('\t', of);
|
||||
|
||||
fputs("groups=", of);
|
||||
groups = on->desc->group;
|
||||
occurred = false;
|
||||
chars = 7;
|
||||
for (j = 0; j < 8*sizeof(groups_t); ++j) {
|
||||
if (groups & 1) {
|
||||
if (occurred) { fputc(',', of); }
|
||||
fprintf(of, "%s", addressgroupnames[j]);
|
||||
if (occurred) {
|
||||
fputc(',', of);
|
||||
++chars;
|
||||
}
|
||||
fputs(addressgroupnames[j], of);
|
||||
chars += strlen(addressgroupnames[j]);
|
||||
occurred = true;
|
||||
}
|
||||
groups >>= 1;
|
||||
}
|
||||
fprintf(of, "\tphase=%s", optionphasenames[on->desc->phase]);
|
||||
fprintf(of, "\ttype=%s", optiontypenames[on->desc->type]);
|
||||
i = (24 - chars + 7) / 8;
|
||||
for (; i > 0; --i) { fputc('\t', of); }
|
||||
|
||||
chars = fprintf(of, "phase=%s", optionphasenames[on->desc->phase]);
|
||||
i = (24 - chars + 7) / 8;
|
||||
for (; i > 0; --i) { fputc('\t', of); }
|
||||
|
||||
fprintf(of, "type=%s", optiontypenames[on->desc->type]);
|
||||
fputc('\n', of);
|
||||
return 0;
|
||||
}
|
||||
|
@ -102,14 +120,9 @@ int xioopenhelp(FILE *of,
|
|||
groups_t groups;
|
||||
bool occurred;
|
||||
|
||||
fputs(" bi-address:\n", of);
|
||||
fputs(" pipe[,<opts>]\tgroups=FD,FIFO\n", of);
|
||||
if (level == 2) {
|
||||
fputs(" echo is an alias for pipe\n", of);
|
||||
fputs(" fifo is an alias for pipe\n", of);
|
||||
}
|
||||
fputs(" <single-address>!!<single-address>\n", of);
|
||||
fputs(" bi-address: /* is an address that may act both as data sync and source */\n", of);
|
||||
fputs(" <single-address>\n", of);
|
||||
fputs(" <single-address>!!<single-address>\n", of);
|
||||
fputs(" single-address:\n", of);
|
||||
fputs(" <address-head>[,<opts>]\n", of);
|
||||
fputs(" address-head:\n", of);
|
||||
|
@ -117,10 +130,16 @@ int xioopenhelp(FILE *of,
|
|||
i = 0;
|
||||
while (addressnames[i].name) {
|
||||
if (!strcmp(an->name, an->desc->defname)) {
|
||||
int chars, i;
|
||||
|
||||
/* it is a canonical address name */
|
||||
fprintf(of, " %s", an->name);
|
||||
chars = fprintf(of, " %s", an->name);
|
||||
if (an->desc->syntax) {
|
||||
fputs(an->desc->syntax, of); }
|
||||
fputs(an->desc->syntax, of);
|
||||
chars += strlen(an->desc->syntax);
|
||||
}
|
||||
i = (40 - chars + 7) / 8;
|
||||
for (; i > 0; --i) { fputc('\t', of); }
|
||||
fputs("\tgroups=", of);
|
||||
groups = an->desc->groups; occurred = false;
|
||||
for (j = 0; j < 32; ++j) {
|
||||
|
@ -133,7 +152,13 @@ int xioopenhelp(FILE *of,
|
|||
}
|
||||
fputc('\n', of);
|
||||
} else if (level == 2) {
|
||||
fprintf(of, " %s is an alias name for %s\n", an->name, an->desc->defname);
|
||||
int chars, i;
|
||||
|
||||
chars = fprintf(of, " %s", an->name);
|
||||
i = (40 - chars + 7) / 8;
|
||||
for (; i > 0; --i) { fputc('\t', of); }
|
||||
|
||||
fprintf(of, "\tis an alias name for %s\n", an->desc->defname);
|
||||
}
|
||||
++an; ++i;
|
||||
}
|
||||
|
@ -149,10 +174,16 @@ int xioopenhelp(FILE *of,
|
|||
fputs(" opt:\n", of);
|
||||
on = optionnames;
|
||||
while (on->name != NULL) {
|
||||
if (on->desc->nickname!= NULL
|
||||
if (on->desc->nickname != NULL
|
||||
&& !strcmp(on->name, on->desc->nickname)) {
|
||||
if (level == 2) {
|
||||
fprintf(of, " %s is an alias for %s\n", on->name, on->desc->defname);
|
||||
int chars, i;
|
||||
|
||||
chars = fprintf(of, " %s", on->name);
|
||||
i = (16 - chars + 7) / 8;
|
||||
for (; i > 0; --i) { fputc('\t', of); }
|
||||
|
||||
fprintf(of, "\tis an alias for %s\n", on->desc->defname);
|
||||
} else {
|
||||
xiohelp_option(of, on, on->name);
|
||||
}
|
||||
|
@ -163,7 +194,13 @@ int xioopenhelp(FILE *of,
|
|||
if (!strcmp(on->name, on->desc->defname)) {
|
||||
xiohelp_option(of, on, on->name);
|
||||
} else {
|
||||
fprintf(of, " %s is an alias for %s\n", on->name, on->desc->defname);
|
||||
int chars, i;
|
||||
|
||||
chars = fprintf(of, " %s", on->name);
|
||||
i = (16 - chars + 7) / 8;
|
||||
for (; i > 0; --i) { fputc('\t', of); }
|
||||
|
||||
fprintf(of, "\tis an alias for %s\n", on->desc->defname);
|
||||
}
|
||||
}
|
||||
++on;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue