CURLOPT_IOCTLFUNCTION.3 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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_IOCTLFUNCTION 3 "16 Jun 2014" libcurl libcurl
  26. .SH NAME
  27. CURLOPT_IOCTLFUNCTION \- callback for I/O operations
  28. .SH SYNOPSIS
  29. .nf
  30. #include <curl/curl.h>
  31. typedef enum {
  32. CURLIOE_OK, /* I/O operation successful */
  33. CURLIOE_UNKNOWNCMD, /* command was unknown to callback */
  34. CURLIOE_FAILRESTART, /* failed to restart the read */
  35. CURLIOE_LAST /* never use */
  36. } curlioerr;
  37. typedef enum {
  38. CURLIOCMD_NOP, /* no operation */
  39. CURLIOCMD_RESTARTREAD, /* restart the read stream from start */
  40. CURLIOCMD_LAST /* never use */
  41. } curliocmd;
  42. curlioerr ioctl_callback(CURL *handle, int cmd, void *clientp);
  43. CURLcode curl_easy_setopt(CURL *handle, CURLOPT_IOCTLFUNCTION, ioctl_callback);
  44. .SH DESCRIPTION
  45. Pass a pointer to your callback function, which should match the prototype
  46. shown above.
  47. This callback function gets called by libcurl when something special
  48. I/O-related needs to be done that the library cannot do by itself. For now,
  49. rewinding the read data stream is the only action it can request. The
  50. rewinding of the read data stream may be necessary when doing an HTTP PUT or
  51. POST with a multi-pass authentication method.
  52. The callback MUST return \fICURLIOE_UNKNOWNCMD\fP if the input \fIcmd\fP is
  53. not \fICURLIOCMD_RESTARTREAD\fP.
  54. The \fIclientp\fP argument to the callback is set with the
  55. \fICURLOPT_IOCTLDATA(3)\fP option.
  56. This option is deprecated! Do not use it. Use \fICURLOPT_SEEKFUNCTION(3)\fP
  57. instead to provide seeking! If \fICURLOPT_SEEKFUNCTION(3)\fP is set, this
  58. parameter will be ignored when seeking.
  59. .SH DEFAULT
  60. By default, this parameter is set to NULL. Not used.
  61. .SH PROTOCOLS
  62. Used with HTTP
  63. .SH EXAMPLE
  64. .nf
  65. static curlioerr ioctl_callback(CURL *handle, int cmd, void *clientp)
  66. {
  67. struct data *io = (struct data *)clientp;
  68. if(cmd == CURLIOCMD_RESTARTREAD) {
  69. lseek(fd, 0, SEEK_SET);
  70. current_offset = 0;
  71. return CURLIOE_OK;
  72. }
  73. return CURLIOE_UNKNOWNCMD;
  74. }
  75. {
  76. struct data ioctl_data;
  77. curl_easy_setopt(curl, CURLOPT_IOCTLFUNCTION, ioctl_callback);
  78. curl_easy_setopt(curl, CURLOPT_IOCTLDATA, &ioctl_data);
  79. }
  80. .fi
  81. .SH AVAILABILITY
  82. Added in 7.12.3. Deprecated since 7.18.0.
  83. .SH RETURN VALUE
  84. Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not.
  85. .SH "SEE ALSO"
  86. .BR CURLOPT_IOCTLDATA "(3), " CURLOPT_SEEKFUNCTION "(3), "