1CURLOPT_IOCTLFUNCTION(3) curl_easy_setopt options CURLOPT_IOCTLFUNCTION(3)
2
3
4
6 CURLOPT_IOCTLFUNCTION - callback for I/O operations
7
9 #include <curl/curl.h>
10
11 typedef enum {
12 CURLIOE_OK, /* I/O operation successful */
13 CURLIOE_UNKNOWNCMD, /* command was unknown to callback */
14 CURLIOE_FAILRESTART, /* failed to restart the read */
15 CURLIOE_LAST /* never use */
16 } curlioerr;
17
18 typedef enum {
19 CURLIOCMD_NOP, /* no operation */
20 CURLIOCMD_RESTARTREAD, /* restart the read stream from start */
21 CURLIOCMD_LAST /* never use */
22 } curliocmd;
23
24 curlioerr ioctl_callback(CURL *handle, int cmd, void *clientp);
25
26 CURLcode curl_easy_setopt(CURL *handle, CURLOPT_IOCTLFUNCTION, ioctl_callback);
27
29 Pass a pointer to your callback function, which should match the proto‐
30 type shown above.
31
32 This callback function gets called by libcurl when something special
33 I/O-related needs to be done that the library cannot do by itself. For
34 now, rewinding the read data stream is the only action it can request.
35 The rewinding of the read data stream may be necessary when doing an
36 HTTP PUT or POST with a multi-pass authentication method.
37
38 The callback MUST return CURLIOE_UNKNOWNCMD if the input cmd is not
39 CURLIOCMD_RESTARTREAD.
40
41 The clientp argument to the callback is set with the CURLOPT_IOCTL‐
42 DATA(3) option.
43
44 This option is deprecated! Do not use it. Use CURLOPT_SEEKFUNCTION(3)
45 instead to provide seeking! If CURLOPT_SEEKFUNCTION(3) is set, this pa‐
46 rameter will be ignored when seeking.
47
49 By default, this parameter is set to NULL. Not used.
50
52 Used with HTTP
53
55 static curlioerr ioctl_callback(CURL *handle, int cmd, void *clientp)
56 {
57 struct data *io = (struct data *)clientp;
58 if(cmd == CURLIOCMD_RESTARTREAD) {
59 lseek(fd, 0, SEEK_SET);
60 current_offset = 0;
61 return CURLIOE_OK;
62 }
63 return CURLIOE_UNKNOWNCMD;
64 }
65 {
66 struct data ioctl_data;
67 curl_easy_setopt(curl, CURLOPT_IOCTLFUNCTION, ioctl_callback);
68 curl_easy_setopt(curl, CURLOPT_IOCTLDATA, &ioctl_data);
69 }
70
72 Added in 7.12.3. Deprecated since 7.18.0.
73
75 Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION
76 if not.
77
79 CURLOPT_IOCTLDATA(3), CURLOPT_SEEKFUNCTION(3),
80
81
82
83libcurl 8.0.1 January 02, 2023 CURLOPT_IOCTLFUNCTION(3)