1*6236dae4SAndroid Build Coastguard Worker--- 2*6236dae4SAndroid Build Coastguard Workerc: Copyright (C) Daniel Stenberg, <[email protected]>, et al. 3*6236dae4SAndroid Build Coastguard WorkerSPDX-License-Identifier: curl 4*6236dae4SAndroid Build Coastguard WorkerTitle: CURLOPT_WILDCARDMATCH 5*6236dae4SAndroid Build Coastguard WorkerSection: 3 6*6236dae4SAndroid Build Coastguard WorkerSource: libcurl 7*6236dae4SAndroid Build Coastguard WorkerSee-also: 8*6236dae4SAndroid Build Coastguard Worker - CURLOPT_CHUNK_BGN_FUNCTION (3) 9*6236dae4SAndroid Build Coastguard Worker - CURLOPT_CHUNK_END_FUNCTION (3) 10*6236dae4SAndroid Build Coastguard Worker - CURLOPT_FNMATCH_FUNCTION (3) 11*6236dae4SAndroid Build Coastguard Worker - CURLOPT_URL (3) 12*6236dae4SAndroid Build Coastguard WorkerProtocol: 13*6236dae4SAndroid Build Coastguard Worker - FTP 14*6236dae4SAndroid Build Coastguard WorkerAdded-in: 7.21.0 15*6236dae4SAndroid Build Coastguard Worker--- 16*6236dae4SAndroid Build Coastguard Worker 17*6236dae4SAndroid Build Coastguard Worker# NAME 18*6236dae4SAndroid Build Coastguard Worker 19*6236dae4SAndroid Build Coastguard WorkerCURLOPT_WILDCARDMATCH - directory wildcard transfers 20*6236dae4SAndroid Build Coastguard Worker 21*6236dae4SAndroid Build Coastguard Worker# SYNOPSIS 22*6236dae4SAndroid Build Coastguard Worker 23*6236dae4SAndroid Build Coastguard Worker~~~c 24*6236dae4SAndroid Build Coastguard Worker#include <curl/curl.h> 25*6236dae4SAndroid Build Coastguard Worker 26*6236dae4SAndroid Build Coastguard WorkerCURLcode curl_easy_setopt(CURL *handle, CURLOPT_WILDCARDMATCH, long onoff); 27*6236dae4SAndroid Build Coastguard Worker~~~ 28*6236dae4SAndroid Build Coastguard Worker 29*6236dae4SAndroid Build Coastguard Worker# DESCRIPTION 30*6236dae4SAndroid Build Coastguard Worker 31*6236dae4SAndroid Build Coastguard WorkerSet *onoff* to 1 if you want to transfer multiple files according to a 32*6236dae4SAndroid Build Coastguard Workerfilename pattern. The pattern can be specified as part of the CURLOPT_URL(3) 33*6236dae4SAndroid Build Coastguard Workeroption, using an **fnmatch**-like pattern (Shell Pattern Matching) in the last 34*6236dae4SAndroid Build Coastguard Workerpart of URL (filename). 35*6236dae4SAndroid Build Coastguard Worker 36*6236dae4SAndroid Build Coastguard WorkerBy default, libcurl uses its internal wildcard matching implementation. You 37*6236dae4SAndroid Build Coastguard Workercan provide your own matching function by the 38*6236dae4SAndroid Build Coastguard WorkerCURLOPT_FNMATCH_FUNCTION(3) option. 39*6236dae4SAndroid Build Coastguard Worker 40*6236dae4SAndroid Build Coastguard WorkerA brief introduction of its syntax follows: 41*6236dae4SAndroid Build Coastguard Worker 42*6236dae4SAndroid Build Coastguard Worker## * - ASTERISK 43*6236dae4SAndroid Build Coastguard Worker 44*6236dae4SAndroid Build Coastguard Worker ftp://example.com/some/path/*.txt 45*6236dae4SAndroid Build Coastguard Worker 46*6236dae4SAndroid Build Coastguard Workermatches all `.txt` files in the root directory. Only two asterisks are allowed 47*6236dae4SAndroid Build Coastguard Workerwithin the same pattern string. 48*6236dae4SAndroid Build Coastguard Worker 49*6236dae4SAndroid Build Coastguard Worker## ? - QUESTION MARK 50*6236dae4SAndroid Build Coastguard Worker 51*6236dae4SAndroid Build Coastguard WorkerQuestion mark matches any (exactly one) character. 52*6236dae4SAndroid Build Coastguard Worker 53*6236dae4SAndroid Build Coastguard Worker ftp://example.com/some/path/photo?.jpg 54*6236dae4SAndroid Build Coastguard Worker 55*6236dae4SAndroid Build Coastguard Worker## [ - BRACKET EXPRESSION 56*6236dae4SAndroid Build Coastguard Worker 57*6236dae4SAndroid Build Coastguard WorkerThe left bracket opens a bracket expression. The question mark and asterisk have 58*6236dae4SAndroid Build Coastguard Workerno special meaning in a bracket expression. Each bracket expression ends by the 59*6236dae4SAndroid Build Coastguard Workerright bracket and matches exactly one character. Some examples follow: 60*6236dae4SAndroid Build Coastguard Worker 61*6236dae4SAndroid Build Coastguard Worker**[a-zA-Z0-9]** or **[f-gF-G]** - character interval 62*6236dae4SAndroid Build Coastguard Worker 63*6236dae4SAndroid Build Coastguard Worker**[abc]** - character enumeration 64*6236dae4SAndroid Build Coastguard Worker 65*6236dae4SAndroid Build Coastguard Worker**[^abc]** or **[!abc]** - negation 66*6236dae4SAndroid Build Coastguard Worker 67*6236dae4SAndroid Build Coastguard Worker**[[:name:]]** class expression. Supported classes are **alnum**,**lower**, 68*6236dae4SAndroid Build Coastguard Worker**space**, **alpha**, **digit**, **print**, **upper**, **blank**, **graph**, 69*6236dae4SAndroid Build Coastguard Worker**xdigit**. 70*6236dae4SAndroid Build Coastguard Worker 71*6236dae4SAndroid Build Coastguard Worker**[][-!^]** - special case - matches only '-', ']', '[', '!' or '^'. These 72*6236dae4SAndroid Build Coastguard Workercharacters have no special purpose. 73*6236dae4SAndroid Build Coastguard Worker 74*6236dae4SAndroid Build Coastguard Worker**[[]]** - escape syntax. Matches '[', ']' or 'e'. 75*6236dae4SAndroid Build Coastguard Worker 76*6236dae4SAndroid Build Coastguard WorkerUsing the rules above, a filename pattern can be constructed: 77*6236dae4SAndroid Build Coastguard Worker 78*6236dae4SAndroid Build Coastguard Worker ftp://example.com/some/path/[a-z[:upper:]\\].jpg 79*6236dae4SAndroid Build Coastguard Worker 80*6236dae4SAndroid Build Coastguard Worker# %PROTOCOLS% 81*6236dae4SAndroid Build Coastguard Worker 82*6236dae4SAndroid Build Coastguard Worker# EXAMPLE 83*6236dae4SAndroid Build Coastguard Worker 84*6236dae4SAndroid Build Coastguard Worker~~~c 85*6236dae4SAndroid Build Coastguard Workerextern long begin_cb(struct curl_fileinfo *, void *, int); 86*6236dae4SAndroid Build Coastguard Workerextern long end_cb(void *ptr); 87*6236dae4SAndroid Build Coastguard Worker 88*6236dae4SAndroid Build Coastguard Workerint main(void) 89*6236dae4SAndroid Build Coastguard Worker{ 90*6236dae4SAndroid Build Coastguard Worker CURL *curl = curl_easy_init(); 91*6236dae4SAndroid Build Coastguard Worker if(curl) { 92*6236dae4SAndroid Build Coastguard Worker /* turn on wildcard matching */ 93*6236dae4SAndroid Build Coastguard Worker curl_easy_setopt(curl, CURLOPT_WILDCARDMATCH, 1L); 94*6236dae4SAndroid Build Coastguard Worker 95*6236dae4SAndroid Build Coastguard Worker /* callback is called before download of concrete file started */ 96*6236dae4SAndroid Build Coastguard Worker curl_easy_setopt(curl, CURLOPT_CHUNK_BGN_FUNCTION, begin_cb); 97*6236dae4SAndroid Build Coastguard Worker 98*6236dae4SAndroid Build Coastguard Worker /* callback is called after data from the file have been transferred */ 99*6236dae4SAndroid Build Coastguard Worker curl_easy_setopt(curl, CURLOPT_CHUNK_END_FUNCTION, end_cb); 100*6236dae4SAndroid Build Coastguard Worker 101*6236dae4SAndroid Build Coastguard Worker /* See more on https://curl.se/libcurl/c/ftp-wildcard.html */ 102*6236dae4SAndroid Build Coastguard Worker } 103*6236dae4SAndroid Build Coastguard Worker} 104*6236dae4SAndroid Build Coastguard Worker~~~ 105*6236dae4SAndroid Build Coastguard Worker 106*6236dae4SAndroid Build Coastguard Worker# %AVAILABILITY% 107*6236dae4SAndroid Build Coastguard Worker 108*6236dae4SAndroid Build Coastguard Worker# RETURN VALUE 109*6236dae4SAndroid Build Coastguard Worker 110*6236dae4SAndroid Build Coastguard WorkerReturns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. 111