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