1CURLOPT_WILDCARDMATCH(3) curl_easy_setopt options CURLOPT_WILDCARDMATCH(3)
2
3
4
6 CURLOPT_WILDCARDMATCH - directory wildcard transfers
7
9 #include <curl/curl.h>
10
11 CURLcode curl_easy_setopt(CURL *handle, CURLOPT_WILDCARDMATCH, long onoff);
12
14 Set onoff to 1 if you want to transfer multiple files according to a
15 file name pattern. The pattern can be specified as part of the CUR‐
16 LOPT_URL(3) option, using an fnmatch-like pattern (Shell Pattern Match‐
17 ing) in the last part of URL (file name).
18
19 By default, libcurl uses its internal wildcard matching implementation.
20 You can provide your own matching function by the CURLOPT_FNMATCH_FUNC‐
21 TION(3) option.
22
23 A brief introduction of its syntax follows:
24
25 * - ASTERISK
26 ftp://example.com/some/path/*.txt
27 for all txt's from the root directory. Only two asterisks
28 are allowed within the same pattern string.
29
30 ? - QUESTION MARK
31 Question mark matches any (exactly one) character.
32 ftp://example.com/some/path/photo?.jpg
33
34 [ - BRACKET EXPRESSION
35 The left bracket opens a bracket expression. The question
36 mark and asterisk have no special meaning in a bracket
37 expression. Each bracket expression ends by the right
38 bracket and matches exactly one character. Some examples
39 follow:
40
41 [a-zA-Z0-9] or [f-gF-G] - character interval
42
43 [abc] - character enumeration
44
45 [^abc] or [!abc] - negation
46
47 [[:name:]] class expression. Supported classes are al‐
48 num,lower, space, alpha, digit, print, upper, blank,
49 graph, xdigit.
50
51 [][-!^] - special case - matches only '-', ']', '[', '!'
52 or '^'. These characters have no special purpose.
53
54 [\[\]\\] - escape syntax. Matches '[', ']' or '\'.
55
56 Using the rules above, a file name pattern can be con‐
57 structed:
58 ftp://example.com/some/path/[a-z[:upper:]\\].jpg
59
61 This feature is only supported for FTP download.
62
64 /* initialization of easy handle */
65 handle = curl_easy_init();
66
67 /* turn on wildcard matching */
68 curl_easy_setopt(handle, CURLOPT_WILDCARDMATCH, 1L);
69
70 /* callback is called before download of concrete file started */
71 curl_easy_setopt(handle, CURLOPT_CHUNK_BGN_FUNCTION, file_is_coming);
72
73 /* callback is called after data from the file have been transferred */
74 curl_easy_setopt(handle, CURLOPT_CHUNK_END_FUNCTION, file_is_downloaded);
75
76 /* See more on https://curl.se/libcurl/c/ftp-wildcard.html */
77
79 Added in 7.21.0
80
82 Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION
83 if not.
84
86 CURLOPT_FNMATCH_FUNCTION(3), CURLOPT_URL(3),
87
88
89
90libcurl 8.0.1 January 02, 2023 CURLOPT_WILDCARDMATCH(3)