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