mirror of
https://github.com/curl/curl.git
synced 2026-08-25 05:23:32 +03:00
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
This commit is contained in:
parent
e1e482517f
commit
184fc6f07a
6 changed files with 160 additions and 129 deletions
|
|
@ -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)) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue