curl_share_init.md (1255B)
1 --- 2 c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 3 SPDX-License-Identifier: curl 4 Title: curl_share_init 5 Section: 3 6 Source: libcurl 7 See-also: 8 - curl_share_cleanup (3) 9 - curl_share_setopt (3) 10 Protocol: 11 - All 12 Added-in: 7.10 13 --- 14 15 # NAME 16 17 curl_share_init - create a share object 18 19 # SYNOPSIS 20 21 ~~~c 22 #include <curl/curl.h> 23 24 CURLSH *curl_share_init(); 25 ~~~ 26 27 # DESCRIPTION 28 29 This function returns a pointer to a *CURLSH* handle to be used as input 30 to all the other share-functions, sometimes referred to as a share handle in 31 some places in the documentation. This init call MUST have a corresponding 32 call to curl_share_cleanup(3) when all operations using the share are 33 complete. 34 35 This *share handle* is what you pass to curl using the 36 CURLOPT_SHARE(3) option with curl_easy_setopt(3), to make that 37 specific curl handle use the data in this share. 38 39 # %PROTOCOLS% 40 41 # EXAMPLE 42 43 ~~~c 44 int main(void) 45 { 46 CURLSHcode sh; 47 CURLSH *share = curl_share_init(); 48 sh = curl_share_setopt(share, CURLSHOPT_SHARE, CURL_LOCK_DATA_CONNECT); 49 if(sh) 50 printf("Error: %s\n", curl_share_strerror(sh)); 51 } 52 ~~~ 53 54 # %AVAILABILITY% 55 56 # RETURN VALUE 57 58 If this function returns NULL, something went wrong (out of memory, etc.) 59 and therefore the share object was not created.