CURLOPT_FNMATCH_FUNCTION.3 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. .\" generated by cd2nroff 0.1 from CURLOPT_FNMATCH_FUNCTION.md
  2. .TH CURLOPT_FNMATCH_FUNCTION 3 "2025-01-17" libcurl
  3. .SH NAME
  4. CURLOPT_FNMATCH_FUNCTION \- wildcard match callback
  5. .SH SYNOPSIS
  6. .nf
  7. #include <curl/curl.h>
  8. int fnmatch_callback(void *ptr,
  9. const char *pattern,
  10. const char *string);
  11. CURLcode curl_easy_setopt(CURL *handle, CURLOPT_FNMATCH_FUNCTION,
  12. fnmatch_callback);
  13. .fi
  14. .SH DESCRIPTION
  15. Pass a pointer to your callback function, which should match the prototype
  16. shown above.
  17. This callback is used for wildcard matching.
  18. Return \fICURL_FNMATCHFUNC_MATCH\fP if pattern matches the string,
  19. \fICURL_FNMATCHFUNC_NOMATCH\fP if not or \fICURL_FNMATCHFUNC_FAIL\fP if an
  20. error occurred.
  21. .SH DEFAULT
  22. NULL == an internal function for wildcard matching.
  23. .SH PROTOCOLS
  24. This functionality affects ftp only
  25. .SH EXAMPLE
  26. .nf
  27. extern int string_match(const char *s1, const char *s2);
  28. struct local_stuff {
  29. void *custom;
  30. };
  31. static int my_fnmatch(void *clientp,
  32. const char *pattern, const char *string)
  33. {
  34. struct local_stuff *data = clientp;
  35. printf("my pointer: %p\\n", data->custom);
  36. if(string_match(pattern, string))
  37. return CURL_FNMATCHFUNC_MATCH;
  38. else
  39. return CURL_FNMATCHFUNC_NOMATCH;
  40. }
  41. int main(void)
  42. {
  43. struct local_stuff local_data;
  44. CURL *curl = curl_easy_init();
  45. if(curl) {
  46. curl_easy_setopt(curl, CURLOPT_URL, "ftp://ftp.example.com/file*");
  47. curl_easy_setopt(curl, CURLOPT_WILDCARDMATCH, 1L);
  48. curl_easy_setopt(curl, CURLOPT_FNMATCH_FUNCTION, my_fnmatch);
  49. curl_easy_setopt(curl, CURLOPT_FNMATCH_DATA, &local_data);
  50. curl_easy_perform(curl);
  51. }
  52. }
  53. .fi
  54. .SH AVAILABILITY
  55. Added in curl 7.21.0
  56. .SH RETURN VALUE
  57. Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not.
  58. .SH SEE ALSO
  59. .BR CURLOPT_DEBUGFUNCTION (3),
  60. .BR CURLOPT_FNMATCH_DATA (3),
  61. .BR CURLOPT_WILDCARDMATCH (3)