xref: /curl/docs/libcurl/opts/CURLOPT_IOCTLDATA.md (revision 5a488251)
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
12Added-in: 7.12.3
13---
14
15# NAME
16
17CURLOPT_IOCTLDATA - pointer passed to I/O callback
18
19# SYNOPSIS
20
21~~~c
22#include <curl/curl.h>
23
24CURLcode curl_easy_setopt(CURL *handle, CURLOPT_IOCTLDATA, void *pointer);
25~~~
26
27# DESCRIPTION
28
29Pass the *pointer* that is untouched by libcurl and passed as the 3rd
30argument in the ioctl callback set with CURLOPT_IOCTLFUNCTION(3).
31
32# DEFAULT
33
34NULL
35
36# %PROTOCOLS%
37
38# EXAMPLE
39
40~~~c
41#include <unistd.h> /* for lseek */
42
43struct data {
44  int fd; /* our file descriptor */
45};
46
47static 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}
56int 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
69Deprecated since 7.18.0.
70
71# %AVAILABILITY%
72
73# RETURN VALUE
74
75Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not.
76