cli tool: do not use disabled protocols

As they are now rejected by the library, take care of not passing
disabled protocol names to CURLOPT_PROTOCOLS_STR and
CURLOPT_REDIR_PROTOCOLS_STR.

Rather than using the CURLPROTO_* constants, dynamically assign protocol
numbers based on the order they are listed by curl_version_info().

New type proto_set_t implements prototype bit masks: it should therefore
be large enough to accomodate all library-enabled protocols. If not,
protocol numbers beyond the bit count of proto_set_t are recognized but
"inaccessible": when used, a warning is displayed and the value is
ignored. Should proto_set_t overflows, enabled protocols are reordered to
force those having a public CURLPROTO_* representation to be accessible.

Code has been added to subordinate RTMP?* protocols to the presence of
RTMP in the enabled protocol list, being returned by curl_version_info()
or not.
This commit is contained in:
Patrick Monnerat 2022-09-15 14:31:36 +02:00 committed by Daniel Stenberg
parent 9d51329047
commit dd2a024323
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
10 changed files with 274 additions and 197 deletions

View file

@ -221,7 +221,10 @@ void tool_version_info(void)
if(curlinfo->protocols) {
printf("Protocols: ");
for(proto = curlinfo->protocols; *proto; ++proto) {
printf("%s ", *proto);
/* 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);
}
puts(""); /* newline */
}