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