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