1---
2c: Copyright (C) Daniel Stenberg, <daniel.se>, et al.
3SPDX-License-Identifier: curl
4Title: CURLOPT_PREREQDATA
5Section: 3
6Source: libcurl
7See-also:
8  - CURLINFO_PRIMARY_IP (3)
9  - CURLINFO_PRIMARY_PORT (3)
10  - CURLOPT_PREREQFUNCTION (3)
11---
12
13# NAME
14
15CURLOPT_PREREQDATA - pointer passed to the pre-request callback
16
17# SYNOPSIS
18
19~~~c
20#include <curl/curl.h>
21
22CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PREREQDATA, void *pointer);
23~~~
24
25# DESCRIPTION
26
27Pass a *pointer* that is untouched by libcurl and passed as the first
28argument in the pre-request callback set with CURLOPT_PREREQFUNCTION(3).
29
30# DEFAULT
31
32NULL
33
34# PROTOCOLS
35
36All
37
38# EXAMPLE
39
40~~~c
41struct priv {
42  void *custom;
43};
44
45static int prereq_callback(void *clientp,
46                           char *conn_primary_ip,
47                           char *conn_local_ip,
48                           int conn_primary_port,
49                           int conn_local_port)
50{
51  printf("Connection made to %s:%d\n", conn_primary_ip, conn_primary_port);
52  return CURL_PREREQFUNC_OK;
53}
54
55int main(void)
56{
57  struct priv prereq_data;
58  CURL *curl = curl_easy_init();
59  if(curl) {
60    curl_easy_setopt(curl, CURLOPT_PREREQFUNCTION, prereq_callback);
61    curl_easy_setopt(curl, CURLOPT_PREREQDATA, &prereq_data);
62    curl_easy_perform(curl);
63  }
64}
65~~~
66
67# AVAILABILITY
68
69Added in 7.80.0
70
71# RETURN VALUE
72
73Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not.
74