CURLOPT_RESOLVER_START_FUNCTION.3 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. .\" **************************************************************************
  2. .\" * _ _ ____ _
  3. .\" * Project ___| | | | _ \| |
  4. .\" * / __| | | | |_) | |
  5. .\" * | (__| |_| | _ <| |___
  6. .\" * \___|\___/|_| \_\_____|
  7. .\" *
  8. .\" * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
  9. .\" *
  10. .\" * This software is licensed as described in the file COPYING, which
  11. .\" * you should have received as part of this distribution. The terms
  12. .\" * are also available at https://curl.se/docs/copyright.html.
  13. .\" *
  14. .\" * You may opt to use, copy, modify, merge, publish, distribute and/or sell
  15. .\" * copies of the Software, and permit persons to whom the Software is
  16. .\" * furnished to do so, under the terms of the COPYING file.
  17. .\" *
  18. .\" * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
  19. .\" * KIND, either express or implied.
  20. .\" *
  21. .\" * SPDX-License-Identifier: curl
  22. .\" *
  23. .\" **************************************************************************
  24. .\"
  25. .TH CURLOPT_RESOLVER_START_FUNCTION 3 "14 Feb 2018" libcurl libcurl
  26. .SH NAME
  27. CURLOPT_RESOLVER_START_FUNCTION \- callback called before a new name resolve is started
  28. .SH SYNOPSIS
  29. .nf
  30. #include <curl/curl.h>
  31. int resolver_start_cb(void *resolver_state, void *reserved, void *userdata);
  32. CURLcode curl_easy_setopt(CURL *handle,
  33. CURLOPT_RESOLVER_START_FUNCTION,
  34. resolver_start_cb);
  35. .SH DESCRIPTION
  36. Pass a pointer to your callback function, which should match the prototype
  37. shown above.
  38. This callback function gets called by libcurl every time before a new resolve
  39. request is started.
  40. \fIresolver_state\fP points to a backend-specific resolver state. Currently
  41. only the ares resolver backend has a resolver state. It can be used to set up
  42. any desired option on the ares channel before it's used, for example setting up
  43. socket callback options.
  44. \fIreserved\fP is reserved.
  45. \fIuserdata\fP is the user pointer set with the
  46. \fICURLOPT_RESOLVER_START_DATA(3)\fP option.
  47. The callback must return 0 on success. Returning a non-zero value will cause
  48. the resolve to fail.
  49. .SH DEFAULT
  50. NULL (No callback)
  51. .SH PROTOCOLS
  52. All
  53. .SH EXAMPLE
  54. .nf
  55. static int resolver_start_cb(void *resolver_state, void *reserved,
  56. void *userdata)
  57. {
  58. (void)reserved;
  59. printf("Received resolver_state=%p userdata=%p\\n",
  60. resolver_state, userdata);
  61. return 0;
  62. }
  63. CURL *curl = curl_easy_init();
  64. if(curl) {
  65. curl_easy_setopt(curl, CURLOPT_RESOLVER_START_FUNCTION, resolver_start_cb);
  66. curl_easy_setopt(curl, CURLOPT_RESOLVER_START_DATA, curl);
  67. curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
  68. curl_easy_perform(curl);
  69. curl_easy_cleanup(curl);
  70. }
  71. .fi
  72. .SH AVAILABILITY
  73. Added in 7.59.0
  74. .SH RETURN VALUE
  75. Returns CURLE_OK
  76. .SH "SEE ALSO"
  77. .BR CURLOPT_RESOLVER_START_DATA "(3) "