CURLOPT_RESOLVER_START_FUNCTION.3 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. .\" generated by cd2nroff 0.1 from CURLOPT_RESOLVER_START_FUNCTION.md
  2. .TH CURLOPT_RESOLVER_START_FUNCTION 3 "2025-01-17" libcurl
  3. .SH NAME
  4. CURLOPT_RESOLVER_START_FUNCTION \- callback called before a new name resolve is started
  5. .SH SYNOPSIS
  6. .nf
  7. #include <curl/curl.h>
  8. int resolver_start_cb(void *resolver_state, void *reserved, void *userdata);
  9. CURLcode curl_easy_setopt(CURL *handle,
  10. CURLOPT_RESOLVER_START_FUNCTION,
  11. resolver_start_cb);
  12. .fi
  13. .SH DESCRIPTION
  14. Pass a pointer to your callback function, which should match the prototype
  15. shown above.
  16. This callback function gets called by libcurl every time before a new resolve
  17. request is started.
  18. \fIresolver_state\fP points to a backend\-specific resolver state. Currently only
  19. the ares resolver backend has a resolver state. It can be used to set up any
  20. desired option on the ares channel before it is used, for example setting up
  21. socket callback options.
  22. \fIreserved\fP is reserved.
  23. \fIuserdata\fP is the user pointer set with the
  24. \fICURLOPT_RESOLVER_START_DATA(3)\fP option.
  25. The callback must return 0 on success. Returning a non\-zero value causes the
  26. resolve to fail.
  27. .SH DEFAULT
  28. NULL (No callback)
  29. .SH PROTOCOLS
  30. This functionality affects all supported protocols
  31. .SH EXAMPLE
  32. .nf
  33. static int start_cb(void *resolver_state, void *reserved,
  34. void *userdata)
  35. {
  36. (void)reserved;
  37. printf("Received resolver_state=%p userdata=%p\\n",
  38. resolver_state, userdata);
  39. return 0;
  40. }
  41. int main(void)
  42. {
  43. CURL *curl = curl_easy_init();
  44. if(curl) {
  45. curl_easy_setopt(curl, CURLOPT_RESOLVER_START_FUNCTION, start_cb);
  46. curl_easy_setopt(curl, CURLOPT_RESOLVER_START_DATA, curl);
  47. curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
  48. curl_easy_perform(curl);
  49. curl_easy_cleanup(curl);
  50. }
  51. }
  52. .fi
  53. .SH AVAILABILITY
  54. Added in curl 7.59.0
  55. .SH RETURN VALUE
  56. Returns CURLE_OK
  57. .SH SEE ALSO
  58. .BR CURLOPT_PREREQFUNCTION (3),
  59. .BR CURLOPT_RESOLVER_START_DATA (3)