CURLOPT_WILDCARDMATCH.3 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. .\" generated by cd2nroff 0.1 from CURLOPT_WILDCARDMATCH.md
  2. .TH CURLOPT_WILDCARDMATCH 3 "2025-01-17" libcurl
  3. .SH NAME
  4. CURLOPT_WILDCARDMATCH \- directory wildcard transfers
  5. .SH SYNOPSIS
  6. .nf
  7. #include <curl/curl.h>
  8. CURLcode curl_easy_setopt(CURL *handle, CURLOPT_WILDCARDMATCH, long onoff);
  9. .fi
  10. .SH DESCRIPTION
  11. Set \fIonoff\fP to 1 if you want to transfer multiple files according to a
  12. filename pattern. The pattern can be specified as part of the \fICURLOPT_URL(3)\fP
  13. option, using an \fBfnmatch\fP\-like pattern (Shell Pattern Matching) in the last
  14. part of URL (filename).
  15. By default, libcurl uses its internal wildcard matching implementation. You
  16. can provide your own matching function by the
  17. \fICURLOPT_FNMATCH_FUNCTION(3)\fP option.
  18. A brief introduction of its syntax follows:
  19. .IP "* - ASTERISK"
  20. .nf
  21. ftp://example.com/some/path/*.txt
  22. .fi
  23. matches all \fI.txt\fP files in the root directory. Only two asterisks are allowed
  24. within the same pattern string.
  25. .IP "? - QUESTION MARK"
  26. Question mark matches any (exactly one) character.
  27. .nf
  28. ftp://example.com/some/path/photo?.jpg
  29. .fi
  30. .IP "[ - BRACKET EXPRESSION"
  31. The left bracket opens a bracket expression. The question mark and asterisk have
  32. no special meaning in a bracket expression. Each bracket expression ends by the
  33. right bracket and matches exactly one character. Some examples follow:
  34. \fB[a\-zA\-Z0\-9]\fP or \fB[f\-gF\-G]\fP \- character interval
  35. \fB[abc]\fP \- character enumeration
  36. \fB[^abc]\fP or \fB[!abc]\fP \- negation
  37. \fB[[:name:]]\fP class expression. Supported classes are \fBalnum\fP,\fBlower\fP,
  38. \fBspace\fP, \fBalpha\fP, \fBdigit\fP, \fBprint\fP, \fBupper\fP, \fBblank\fP, \fBgraph\fP,
  39. \fBxdigit\fP.
  40. \fB[][\-!^]\fP \- special case \- matches only \(aq\-\(aq, \(aq]\(aq, \(aq[\(aq, \(aq!\(aq or \(aq^\(aq. These
  41. characters have no special purpose.
  42. \fB[[]]\fP \- escape syntax. Matches \(aq[\(aq, \(aq]\(aq or \(aqe\(aq.
  43. Using the rules above, a filename pattern can be constructed:
  44. .nf
  45. ftp://example.com/some/path/[a-z[:upper:]\\].jpg
  46. .fi
  47. .SH PROTOCOLS
  48. This functionality affects ftp only
  49. .SH EXAMPLE
  50. .nf
  51. extern long begin_cb(struct curl_fileinfo *, void *, int);
  52. extern long end_cb(void *ptr);
  53. int main(void)
  54. {
  55. CURL *curl = curl_easy_init();
  56. if(curl) {
  57. /* turn on wildcard matching */
  58. curl_easy_setopt(curl, CURLOPT_WILDCARDMATCH, 1L);
  59. /* callback is called before download of concrete file started */
  60. curl_easy_setopt(curl, CURLOPT_CHUNK_BGN_FUNCTION, begin_cb);
  61. /* callback is called after data from the file have been transferred */
  62. curl_easy_setopt(curl, CURLOPT_CHUNK_END_FUNCTION, end_cb);
  63. /* See more on https://curl.se/libcurl/c/ftp-wildcard.html */
  64. }
  65. }
  66. .fi
  67. .SH AVAILABILITY
  68. Added in curl 7.21.0
  69. .SH RETURN VALUE
  70. Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not.
  71. .SH SEE ALSO
  72. .BR CURLOPT_CHUNK_BGN_FUNCTION (3),
  73. .BR CURLOPT_CHUNK_END_FUNCTION (3),
  74. .BR CURLOPT_FNMATCH_FUNCTION (3),
  75. .BR CURLOPT_URL (3)