curl.h: change some enums to defines with L suffix

To help applications do the right thing easier, change some enum values
into defines with L suffixes so that they get the corect type (long)
easier when used with curl_easy_setopt(). This also fixes a few of our
own libtests.

To reduce the risk that this change breaks the compile for any existing
users, the previously provided enums are still provided, but the values
to use are not defined by the enums.

This change "magically" fixes a few RTSP test failures we have had on
64-bit platforms because those options were not see using longs
properly.

Closes #16482
This commit is contained in:
Daniel Stenberg 2025-02-25 17:33:17 +01:00
parent 7826927d9b
commit 2ec00372a1
No known key found for this signature in database
GPG Key ID: 5CC908FDB71E12C2
4 changed files with 42 additions and 36 deletions

View File

@ -2302,32 +2302,33 @@ enum {
/* /*
* Public API enums for RTSP requests * Public API enums for RTSP requests
*/ */
enum {
CURL_RTSPREQ_NONE, /* first in list */ #define CURL_RTSPREQ_NONE 0L
CURL_RTSPREQ_OPTIONS, #define CURL_RTSPREQ_OPTIONS 1L
CURL_RTSPREQ_DESCRIBE, #define CURL_RTSPREQ_DESCRIBE 2L
CURL_RTSPREQ_ANNOUNCE, #define CURL_RTSPREQ_ANNOUNCE 3L
CURL_RTSPREQ_SETUP, #define CURL_RTSPREQ_SETUP 4L
CURL_RTSPREQ_PLAY, #define CURL_RTSPREQ_PLAY 5L
CURL_RTSPREQ_PAUSE, #define CURL_RTSPREQ_PAUSE 6L
CURL_RTSPREQ_TEARDOWN, #define CURL_RTSPREQ_TEARDOWN 7L
CURL_RTSPREQ_GET_PARAMETER, #define CURL_RTSPREQ_GET_PARAMETER 8L
CURL_RTSPREQ_SET_PARAMETER, #define CURL_RTSPREQ_SET_PARAMETER 9L
CURL_RTSPREQ_RECORD, #define CURL_RTSPREQ_RECORD 10L
CURL_RTSPREQ_RECEIVE, #define CURL_RTSPREQ_RECEIVE 11L
CURL_RTSPREQ_LAST /* last in list */ #define CURL_RTSPREQ_LAST 12L /* not used */
};
/* These enums are for use with the CURLOPT_NETRC option. */ /* These enums are for use with the CURLOPT_NETRC option. */
#define CURL_NETRC_IGNORED 0L /* The .netrc will never be read.
This is the default. */
#define CURL_NETRC_OPTIONAL 1L /* A user:password in the URL will be preferred
to one in the .netrc. */
#define CURL_NETRC_REQUIRED 2L /* A user:password in the URL will be ignored.
Unless one is set programmatically, the
.netrc will be queried. */
enum CURL_NETRC_OPTION { enum CURL_NETRC_OPTION {
CURL_NETRC_IGNORED, /* The .netrc will never be read. /* we set a single member here, just to make sure we still provide the enum,
* This is the default. */ but the values to use are defined above with L suffixes */
CURL_NETRC_OPTIONAL, /* A user:password in the URL will be preferred CURL_NETRC_LAST = 3
* to one in the .netrc. */
CURL_NETRC_REQUIRED, /* A user:password in the URL will be ignored.
* Unless one is set programmatically, the .netrc
* will be queried. */
CURL_NETRC_LAST
}; };
#define CURL_SSLVERSION_DEFAULT 0 #define CURL_SSLVERSION_DEFAULT 0
@ -2351,10 +2352,13 @@ enum CURL_NETRC_OPTION {
/* never use, keep last */ /* never use, keep last */
#define CURL_SSLVERSION_MAX_LAST (CURL_SSLVERSION_LAST << 16) #define CURL_SSLVERSION_MAX_LAST (CURL_SSLVERSION_LAST << 16)
#define CURL_TLSAUTH_NONE 0L
#define CURL_TLSAUTH_SRP 1L
enum CURL_TLSAUTH { enum CURL_TLSAUTH {
CURL_TLSAUTH_NONE, /* we set a single member here, just to make sure we still provide the enum,
CURL_TLSAUTH_SRP, but the values to use are defined above with L suffixes */
CURL_TLSAUTH_LAST /* never use, keep last */ CURL_TLSAUTH_LAST = 2
}; };
/* symbols to use with CURLOPT_POSTREDIR. /* symbols to use with CURLOPT_POSTREDIR.
@ -2369,14 +2373,16 @@ enum CURL_TLSAUTH {
#define CURL_REDIR_POST_ALL \ #define CURL_REDIR_POST_ALL \
(CURL_REDIR_POST_301|CURL_REDIR_POST_302|CURL_REDIR_POST_303) (CURL_REDIR_POST_301|CURL_REDIR_POST_302|CURL_REDIR_POST_303)
#define CURL_TIMECOND_NONE 0L
#define CURL_TIMECOND_IFMODSINCE 1L
#define CURL_TIMECOND_IFUNMODSINCE 2L
#define CURL_TIMECOND_LASTMOD 3L
typedef enum { typedef enum {
CURL_TIMECOND_NONE, /* we set a single member here, just to make sure we still provide
the enum typedef, but the values to use are defined above with L
CURL_TIMECOND_IFMODSINCE, suffixes */
CURL_TIMECOND_IFUNMODSINCE, CURL_TIMECOND_LAST = 4
CURL_TIMECOND_LASTMOD,
CURL_TIMECOND_LAST
} curl_TimeCond; } curl_TimeCond;
/* Special size_t value signaling a null-terminated string. */ /* Special size_t value signaling a null-terminated string. */

View File

@ -438,7 +438,7 @@ static CURLcode setopt_long(struct Curl_easy *data, CURLoption option,
*/ */
if((arg < CURL_TIMECOND_NONE) || (arg >= CURL_TIMECOND_LAST)) if((arg < CURL_TIMECOND_NONE) || (arg >= CURL_TIMECOND_LAST))
return CURLE_BAD_FUNCTION_ARGUMENT; return CURLE_BAD_FUNCTION_ARGUMENT;
data->set.timecondition = (unsigned char)(curl_TimeCond)arg; data->set.timecondition = (unsigned char)arg;
break; break;
case CURLOPT_TIMEVALUE: case CURLOPT_TIMEVALUE:
/* /*

View File

@ -200,7 +200,7 @@ struct OperationConfig {
long expect100timeout_ms; long expect100timeout_ms;
long happy_eyeballs_timeout_ms; /* happy eyeballs timeout in milliseconds. long happy_eyeballs_timeout_ms; /* happy eyeballs timeout in milliseconds.
0 is valid. default: CURL_HET_DEFAULT. */ 0 is valid. default: CURL_HET_DEFAULT. */
curl_TimeCond timecond; unsigned long timecond;
HttpReq httpreq; HttpReq httpreq;
int proxyver; /* set to CURLPROXY_HTTP* define */ int proxyver; /* set to CURLPROXY_HTTP* define */
int ftp_ssl_ccc_mode; int ftp_ssl_ccc_mode;

View File

@ -1397,7 +1397,7 @@ static CURLcode config2setopts(struct GlobalConfig *global,
my_setopt(curl, CURLOPT_COOKIESESSION, config->cookiesession ? my_setopt(curl, CURLOPT_COOKIESESSION, config->cookiesession ?
1L : 0L); 1L : 0L);
my_setopt_enum(curl, CURLOPT_TIMECONDITION, (long)config->timecond); my_setopt_enum(curl, CURLOPT_TIMECONDITION, config->timecond);
my_setopt(curl, CURLOPT_TIMEVALUE_LARGE, config->condtime); my_setopt(curl, CURLOPT_TIMEVALUE_LARGE, config->condtime);
my_setopt_str(curl, CURLOPT_CUSTOMREQUEST, config->customrequest); my_setopt_str(curl, CURLOPT_CUSTOMREQUEST, config->customrequest);
customrequest_helper(config, config->httpreq, config->customrequest); customrequest_helper(config, config->httpreq, config->customrequest);