CURLOPT_IOCTLFUNCTION.3 3.3 KB

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