Skip to content

Commit

Permalink
add imap-options feature detection
Browse files Browse the repository at this point in the history
Some tests require this feature present in libcurl to pass.
  • Loading branch information
vszakats committed Nov 17, 2023
1 parent 71d039b commit 67d81bf
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions tests.json
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,7 @@
"{options}"
]
},
"required": ["imap-options"],
"expected": {
"stdout": "crazy\n",
"stderr": "",
Expand Down Expand Up @@ -1680,6 +1681,7 @@
"--json"
]
},
"required": ["imap-options"],
"expected": {
"returncode": 0,
"stdout": [
Expand Down
14 changes: 14 additions & 0 deletions trurl.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@
#if CURL_AT_LEAST_VERSION(8,3,0)
#define SUPPORTS_PUNY2IDN
#endif
#if CURL_AT_LEAST_VERSION(7,30,0)
#define SUPPORTS_IMAP_OPTIONS
#endif

#define OUTPUT_URL 0 /* default */
#define OUTPUT_SCHEME 1
Expand Down Expand Up @@ -203,6 +206,14 @@ static void show_version(void)
#if defined(SUPPORTS_PUNYCODE) || defined(SUPPORTS_PUNY2IDN)
bool supports_puny = (data->features & CURL_VERSION_IDN) != 0;
#endif
#if defined(SUPPORTS_IMAP_OPTIONS)
bool supports_imap = false;
const char *const *protocol_name = data->protocols;
while(*protocol_name && !supports_imap) {
supports_imap = !strncmp(*protocol_name, "IMAP", 3);
protocol_name++;
}
#endif

fprintf(stdout, "%s version %s libcurl/%s [built-with %s]\n",
PROGNAME, TRURL_VERSION_TXT, data->version, LIBCURL_VERSION);
Expand All @@ -223,6 +234,9 @@ static void show_version(void)
#ifdef SUPPORTS_NORM_IPV4
fprintf(stdout, " normalize-ipv4");
#endif
#ifdef SUPPORTS_IMAP_OPTIONS
fprintf(stdout, " imap-options");
#endif
#ifdef SUPPORTS_PUNY2IDN
if(supports_puny)
fprintf(stdout, " punycode2idn");
Expand Down

0 comments on commit 67d81bf

Please sign in to comment.