CURLOPT_IOCTLDATA.md (1434B)
1 --- 2 c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 3 SPDX-License-Identifier: curl 4 Title: CURLOPT_IOCTLDATA 5 Section: 3 6 Source: libcurl 7 See-also: 8 - CURLOPT_IOCTLFUNCTION (3) 9 - CURLOPT_SEEKFUNCTION (3) 10 Protocol: 11 - All 12 Added-in: 7.12.3 13 --- 14 15 # NAME 16 17 CURLOPT_IOCTLDATA - pointer passed to I/O callback 18 19 # SYNOPSIS 20 21 ~~~c 22 #include <curl/curl.h> 23 24 CURLcode curl_easy_setopt(CURL *handle, CURLOPT_IOCTLDATA, void *pointer); 25 ~~~ 26 27 # DESCRIPTION 28 29 Pass the *pointer* that is untouched by libcurl and passed as the 3rd 30 argument in the ioctl callback set with CURLOPT_IOCTLFUNCTION(3). 31 32 # DEFAULT 33 34 NULL 35 36 # %PROTOCOLS% 37 38 # EXAMPLE 39 40 ~~~c 41 #include <unistd.h> /* for lseek */ 42 43 struct data { 44 int fd; /* our file descriptor */ 45 }; 46 47 static curlioerr ioctl_callback(CURL *handle, int cmd, void *clientp) 48 { 49 struct data *io = (struct data *)clientp; 50 if(cmd == CURLIOCMD_RESTARTREAD) { 51 lseek(io->fd, 0, SEEK_SET); 52 return CURLIOE_OK; 53 } 54 return CURLIOE_UNKNOWNCMD; 55 } 56 int main(void) 57 { 58 struct data ioctl_data; 59 CURL *curl = curl_easy_init(); 60 if(curl) { 61 curl_easy_setopt(curl, CURLOPT_IOCTLFUNCTION, ioctl_callback); 62 curl_easy_setopt(curl, CURLOPT_IOCTLDATA, &ioctl_data); 63 } 64 } 65 ~~~ 66 67 # DEPRECATED 68 69 Deprecated since 7.18.0. 70 71 # %AVAILABILITY% 72 73 # RETURN VALUE 74 75 curl_easy_setopt(3) returns a CURLcode indicating success or error. 76 77 CURLE_OK (0) means everything was OK, non-zero means an error occurred, see 78 libcurl-errors(3).