CURLOPT_FNMATCH_DATA.3 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. .\" generated by cd2nroff 0.1 from CURLOPT_FNMATCH_DATA.md
  2. .TH CURLOPT_FNMATCH_DATA 3 "2025-01-17" libcurl
  3. .SH NAME
  4. CURLOPT_FNMATCH_DATA \- pointer passed to the fnmatch callback
  5. .SH SYNOPSIS
  6. .nf
  7. #include <curl/curl.h>
  8. CURLcode curl_easy_setopt(CURL *handle, CURLOPT_FNMATCH_DATA,
  9. void *pointer);
  10. .fi
  11. .SH DESCRIPTION
  12. Pass a pointer that is untouched by libcurl and passed as the ptr argument to
  13. the \fICURLOPT_FNMATCH_FUNCTION(3)\fP.
  14. .SH DEFAULT
  15. NULL
  16. .SH PROTOCOLS
  17. This functionality affects ftp only
  18. .SH EXAMPLE
  19. .nf
  20. extern int string_match(const char *s1, const char *s2);
  21. struct local_stuff {
  22. void *custom;
  23. };
  24. static int my_fnmatch(void *clientp,
  25. const char *pattern, const char *string)
  26. {
  27. struct local_stuff *my = clientp;
  28. printf("my ptr: %p\\n", my->custom);
  29. if(string_match(pattern, string))
  30. return CURL_FNMATCHFUNC_MATCH;
  31. else
  32. return CURL_FNMATCHFUNC_NOMATCH;
  33. }
  34. int main(void)
  35. {
  36. struct local_stuff local_data;
  37. CURL *curl = curl_easy_init();
  38. if(curl) {
  39. curl_easy_setopt(curl, CURLOPT_URL, "ftp://ftp.example.com/file*");
  40. curl_easy_setopt(curl, CURLOPT_WILDCARDMATCH, 1L);
  41. curl_easy_setopt(curl, CURLOPT_FNMATCH_FUNCTION, my_fnmatch);
  42. curl_easy_setopt(curl, CURLOPT_FNMATCH_DATA, &local_data);
  43. curl_easy_perform(curl);
  44. }
  45. }
  46. .fi
  47. .SH AVAILABILITY
  48. Added in curl 7.21.0
  49. .SH RETURN VALUE
  50. Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not.
  51. .SH SEE ALSO
  52. .BR CURLOPT_FNMATCH_FUNCTION (3),
  53. .BR CURLOPT_WILDCARDMATCH (3)