1--- 2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 3SPDX-License-Identifier: curl 4Title: CURLMOPT_TIMERDATA 5Section: 3 6Source: libcurl 7See-also: 8 - CURLMOPT_SOCKETFUNCTION (3) 9 - CURLMOPT_TIMERFUNCTION (3) 10Protocol: 11 - All 12--- 13 14# NAME 15 16CURLMOPT_TIMERDATA - custom pointer to pass to timer callback 17 18# SYNOPSIS 19 20~~~c 21#include <curl/curl.h> 22 23CURLMcode curl_multi_setopt(CURLM *handle, CURLMOPT_TIMERDATA, void *pointer); 24~~~ 25 26# DESCRIPTION 27 28A data **pointer** to pass to the timer callback set with the 29CURLMOPT_TIMERFUNCTION(3) option. 30 31This pointer is not touched by libcurl but is only be passed in to the timer 32callback's **clientp** argument. 33 34# DEFAULT 35 36NULL 37 38# EXAMPLE 39 40~~~c 41struct priv { 42 void *custom; 43}; 44 45static int timerfunc(CURLM *multi, long timeout_ms, void *clientp) 46{ 47 struct priv *mydata = clientp; 48 printf("our ptr: %p\n", mydata->custom); 49 50 if(timeout_ms) { 51 /* this is the new single timeout to wait for */ 52 } 53 else { 54 /* delete the timeout, nothing to wait for now */ 55 } 56} 57 58int main(void) 59{ 60 struct priv mydata; 61 CURLM *multi = curl_multi_init(); 62 curl_multi_setopt(multi, CURLMOPT_TIMERFUNCTION, timerfunc); 63 curl_multi_setopt(multi, CURLMOPT_TIMERDATA, &mydata); 64} 65~~~ 66 67# AVAILABILITY 68 69Added in 7.16.0 70 71# RETURN VALUE 72 73Returns CURLM_OK if the option is supported, and CURLM_UNKNOWN_OPTION if not. 74