CURLOPT_FNMATCH_DATA.md (1642B)
1 --- 2 c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 3 SPDX-License-Identifier: curl 4 Title: CURLOPT_FNMATCH_DATA 5 Section: 3 6 Source: libcurl 7 See-also: 8 - CURLOPT_FNMATCH_FUNCTION (3) 9 - CURLOPT_WILDCARDMATCH (3) 10 Protocol: 11 - FTP 12 Added-in: 7.21.0 13 --- 14 15 # NAME 16 17 CURLOPT_FNMATCH_DATA - pointer passed to the fnmatch callback 18 19 # SYNOPSIS 20 21 ~~~c 22 #include <curl/curl.h> 23 24 CURLcode curl_easy_setopt(CURL *handle, CURLOPT_FNMATCH_DATA, 25 void *pointer); 26 ~~~ 27 28 # DESCRIPTION 29 30 Pass a pointer that is untouched by libcurl and passed as the ptr argument to 31 the CURLOPT_FNMATCH_FUNCTION(3). 32 33 # DEFAULT 34 35 NULL 36 37 # %PROTOCOLS% 38 39 # EXAMPLE 40 41 ~~~c 42 extern int string_match(const char *s1, const char *s2); 43 44 struct local_stuff { 45 void *custom; 46 }; 47 48 static int my_fnmatch(void *clientp, 49 const char *pattern, const char *string) 50 { 51 struct local_stuff *my = clientp; 52 printf("my ptr: %p\n", my->custom); 53 54 if(string_match(pattern, string)) 55 return CURL_FNMATCHFUNC_MATCH; 56 else 57 return CURL_FNMATCHFUNC_NOMATCH; 58 } 59 60 int main(void) 61 { 62 struct local_stuff local_data; 63 CURL *curl = curl_easy_init(); 64 if(curl) { 65 curl_easy_setopt(curl, CURLOPT_URL, "ftp://ftp.example.com/file*"); 66 curl_easy_setopt(curl, CURLOPT_WILDCARDMATCH, 1L); 67 curl_easy_setopt(curl, CURLOPT_FNMATCH_FUNCTION, my_fnmatch); 68 curl_easy_setopt(curl, CURLOPT_FNMATCH_DATA, &local_data); 69 70 curl_easy_perform(curl); 71 } 72 } 73 ~~~ 74 75 # %AVAILABILITY% 76 77 # RETURN VALUE 78 79 curl_easy_setopt(3) returns a CURLcode indicating success or error. 80 81 CURLE_OK (0) means everything was OK, non-zero means an error occurred, see 82 libcurl-errors(3).