summaryrefslogtreecommitdiff
path: root/src/tool_help.c
diff options
context:
space:
mode:
authorPatrick Monnerat <patrick@monnerat.net>2022-11-09 00:37:49 +0100
committerDaniel Stenberg <daniel@haxx.se>2022-11-14 09:19:10 +0100
commit184fc6f07a39a2a9f91aae17062d35e9d91421c3 (patch)
tree6a1ddbc6134194463a3b8ae01679a33e5bbe384d /src/tool_help.c
parente1e482517fdbbea04374b961acb4b39fcf978011 (diff)
downloadcurl-184fc6f07a39a2a9f91aae17062d35e9d91421c3.tar.gz
tool: use feature names instead of bit mask, when possible
If the run-time libcurl is too old to support feature names, the name array is created locally from the bit masks. This is the only sequence left that uses feature bit masks. Closes #9583
Diffstat (limited to 'src/tool_help.c')
-rw-r--r--src/tool_help.c62
1 files changed, 9 insertions, 53 deletions
diff --git a/src/tool_help.c b/src/tool_help.c
index 65a1f43df..e25917f57 100644
--- a/src/tool_help.c
+++ b/src/tool_help.c
@@ -76,42 +76,6 @@ static const struct category_descriptors categories[] = {
extern const struct helptxt helptext[];
-struct feat {
- const char *name;
- int bitmask;
-};
-
-static const struct feat feats[] = {
- {"AsynchDNS", CURL_VERSION_ASYNCHDNS},
- {"Debug", CURL_VERSION_DEBUG},
- {"TrackMemory", CURL_VERSION_CURLDEBUG},
- {"IDN", CURL_VERSION_IDN},
- {"IPv6", CURL_VERSION_IPV6},
- {"Largefile", CURL_VERSION_LARGEFILE},
- {"Unicode", CURL_VERSION_UNICODE},
- {"SSPI", CURL_VERSION_SSPI},
- {"GSS-API", CURL_VERSION_GSSAPI},
- {"Kerberos", CURL_VERSION_KERBEROS5},
- {"SPNEGO", CURL_VERSION_SPNEGO},
- {"NTLM", CURL_VERSION_NTLM},
- {"NTLM_WB", CURL_VERSION_NTLM_WB},
- {"SSL", CURL_VERSION_SSL},
- {"libz", CURL_VERSION_LIBZ},
- {"brotli", CURL_VERSION_BROTLI},
- {"zstd", CURL_VERSION_ZSTD},
- {"CharConv", CURL_VERSION_CONV},
- {"TLS-SRP", CURL_VERSION_TLSAUTH_SRP},
- {"HTTP2", CURL_VERSION_HTTP2},
- {"HTTP3", CURL_VERSION_HTTP3},
- {"UnixSockets", CURL_VERSION_UNIX_SOCKETS},
- {"HTTPS-proxy", CURL_VERSION_HTTPS_PROXY},
- {"MultiSSL", CURL_VERSION_MULTI_SSL},
- {"PSL", CURL_VERSION_PSL},
- {"alt-svc", CURL_VERSION_ALTSVC},
- {"HSTS", CURL_VERSION_HSTS},
- {"gsasl", CURL_VERSION_GSASL},
- {"threadsafe", CURL_VERSION_THREADSAFE},
-};
static void print_category(curlhelp_t category)
{
@@ -191,7 +155,7 @@ void tool_help(char *category)
void tool_version_info(void)
{
- const char *const *proto;
+ const char *const *builtin;
printf(CURL_ID "%s\n", curl_version());
#ifdef CURL_PATCHSTAMP
@@ -200,28 +164,20 @@ void tool_version_info(void)
#else
printf("Release-Date: %s\n", LIBCURL_TIMESTAMP);
#endif
- if(curlinfo->protocols) {
- printf("Protocols: ");
- for(proto = curlinfo->protocols; *proto; ++proto) {
+ if(built_in_protos[0]) {
+ printf("Protocols:");
+ for(builtin = built_in_protos; *builtin; ++builtin) {
/* Special case: do not list rtmp?* protocols.
They may only appear together with "rtmp" */
- if(!curl_strnequal(*proto, "rtmp", 4) || !proto[0][4])
- printf("%s ", *proto);
+ if(!curl_strnequal(*builtin, "rtmp", 4) || !builtin[0][4])
+ printf(" %s", *builtin);
}
puts(""); /* newline */
}
- if(curlinfo->features) {
- char *featp[ sizeof(feats) / sizeof(feats[0]) + 1];
- size_t numfeat = 0;
- unsigned int i;
+ if(feature_names[0]) {
printf("Features:");
- for(i = 0; i < sizeof(feats)/sizeof(feats[0]); i++) {
- if(curlinfo->features & feats[i].bitmask)
- featp[numfeat++] = (char *)feats[i].name;
- }
- qsort(&featp[0], numfeat, sizeof(char *), struplocompare4sort);
- for(i = 0; i< numfeat; i++)
- printf(" %s", featp[i]);
+ for(builtin = feature_names; *builtin; ++builtin)
+ printf(" %s", *builtin);
puts(""); /* newline */
}
if(strcmp(CURL_VERSION, curlinfo->version)) {