diff --git a/util/mkconf.c b/util/mkconf.c index ea1d6e21..ba5115df 100644 --- a/util/mkconf.c +++ b/util/mkconf.c @@ -13,39 +13,39 @@ enum optval { OPT_DISABLE }; -static struct cfgopt options[] = +static const struct cfgopt options[] = { - { "debug", "DEBUG", "Include debug code" }, - { "multicast", "MULTICAST", "Include IP multicast code by Jim Martin" }, - { "bind", "BIND", "Include Bind resolver code" }, - { "bsd-api", "BSD_API", "Include BSD-sockets" }, - { "bsd-fatal", "BSD_FATAL", "Exit application on BSD-socket fatal errors" }, - { "bootp", "BOOTP", "Include BOOTP client code" }, - { "dhcp", "DHCP", "Include DHCP boot client code" }, + { "debug", "DEBUG", "Include debug code." }, + { "multicast", "MULTICAST", "Include IP multicast code by Jim Martin." }, + { "bind", "BIND", "Include Bind resolver code." }, + { "bsd-api", "BSD_API", "Include BSD-sockets." }, + { "bsd-fatal", "BSD_FATAL", "Exit application on BSD-socket fatal errors." }, + { "bootp", "BOOTP", "Include BOOTP client code." }, + { "dhcp", "DHCP", "Include DHCP boot client code." }, { "rarp", "RARP", "Include RARP boot client code. Contributed by Dan Kegel." }, - { "geoip", "GEOIP", "Include GeoIP support. From Tor's geoip.c" }, - { "ipv6", "IPV6", "Include IPv6 dual-stack support" }, - { "language", "LANGUAGE", "Include Language translation code" }, - { "fragments", "FRAGMENTS", "Include IP-fragment handling" }, - { "statistics", "STATISTICS", "Include protocol statistics count" }, + { "geoip", "GEOIP", "Include GeoIP support. From Tor's geoip.c." }, + { "ipv6", "IPV6", "Include IPv6 dual-stack support." }, + { "language", "LANGUAGE", "Include Language translation code." }, + { "fragments", "FRAGMENTS", "Include IP-fragment handling." }, + { "statistics", "STATISTICS", "Include protocol statistics count." }, { "stackwalker", "STACKWALKER", "Use StackWalker for allocations and crash-dumps." }, - { "fsext", "FSEXT", "Use djgpp's File Extensions for file I/O functions" }, - { "loopback", "LOOPBACK", "Use the simple loopback device" }, - { "embedded", "EMBEDDED", "Make an embeddable (ROM-able) target. See note in config.h" }, - { "buffered-io", "BUFFERED_IO", "Use buffered file I/O in pcconfig.c. Otherwise use a simple read-ahead cache" }, - { "tftp", "TFTP", "Include TFTP protocol for simple file retrival" }, - { "udp-only", "UDP_ONLY", "Exclude all stuff related to the TCP protocol" }, - { "tcp-sack", "TCP_SACK", "Include TCP Selective ACK feature (not yet)" }, - { "echo-disc", "ECHO_DISC", "Include echo/discard servers" }, - { "pppoe", "PPPOE", "PPP-over-Ethernet encapsulation" }, - { "fast-pkt", "FAST_PKT", "Use faster all real-mode PKTDRVR receiver (DOSX only)" }, - { "dead-gwd", "DEAD_GWD", "Dead Gateway detection in ARP module" }, + { "fsext", "FSEXT", "Use djgpp's File Extensions for file I/O functions." }, + { "loopback", "LOOPBACK", "Use the simple loopback device." }, + { "embedded", "EMBEDDED", "Make an embeddable (ROM-able) target. See note in config.h." }, + { "buffered-io", "BUFFERED_IO", "Use buffered file I/O in pcconfig.c. Otherwise use a simple read-ahead cache." }, + { "tftp", "TFTP", "Include TFTP protocol for simple file retrival." }, + { "udp-only", "UDP_ONLY", "Exclude all stuff related to the TCP protocol." }, + { "tcp-sack", "TCP_SACK", "Include TCP Selective ACK feature (not yet)." }, + { "echo-disc", "ECHO_DISC", "Include echo/discard servers." }, + { "pppoe", "PPPOE", "PPP-over-Ethernet encapsulation." }, + { "fast-pkt", "FAST_PKT", "Use faster all real-mode PKTDRVR receiver (DOSX only)." }, + { "dead-gwd", "DEAD_GWD", "Dead Gateway detection in ARP module." }, { "gzip", "GZIP", "Use gzip compression for PPP and/or pcap debug file. Also for SCTP." }, - { "profiler", "PROFILER", "Include simple execution profiler (only DOSX with 64-bit types)" }, - { "tcp-md5", "TCP_MD5", "TCP MD5 signature option" }, + { "profiler", "PROFILER", "Include simple execution profiler (only DOSX with 64-bit types)." }, + { "tcp-md5", "TCP_MD5", "TCP MD5 signature option." }, { "idna", "IDNA", "Support national characters in DNS name lookups." }, - { "dynip-cli", "DYNIP_CLI", "Support DynDNS.org name/IP client" }, - { "sctp", "SCTP", "Stream Control Transfer Protocol; experimental" } + { "dynip-cli", "DYNIP_CLI", "Support DynDNS.org name/IP client." }, + { "sctp", "SCTP", "Stream Control Transfer Protocol; experimental." } }; #define NUM_OPTIONS (sizeof (options) / sizeof (struct cfgopt)) @@ -65,12 +65,50 @@ static int skip (const char* prefix, const char** arg) static void usage (void) { + const char * const prefix = " --[en|dis]able-"; + const int wrap_at = 80; + const int name_len = 13; + const int option_len = strlen (prefix) + name_len; + const int help_len = wrap_at - option_len; + const char *p, *space; int i; - printf("Available options:\n"); + printf ("Available options:\n"); for (i = 0; i < NUM_OPTIONS; ++i) - printf (" --[en|dis]able-%-12s %s\n", - options[i].name, options[i].help); + { + p = options[i].help; + while (*p) + { + /* Skip spaces. */ + while (*p == ' ') ++p; + + space = p + strlen (p); + if (space - p > help_len) + { + /* Find last space character before wrap point. */ + const char *q = p; + while (1) + { + q = strchr (q, ' '); + if (q && q - p < help_len) + space = q; + else break; + ++q; + } + } + + /* Print option name. */ + if (p == options[i].help) + printf ("%s%-*s", prefix, name_len, options[i].name); + else + printf ("%*c", option_len, ' '); + + /* Print description. */ + printf ("%.*s\n", (int)(space - p), p); + + p = space; + } + } } int main (int argc, char** argv)