curl_url.md (1271B)
1 --- 2 c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 3 SPDX-License-Identifier: curl 4 Title: curl_url 5 Section: 3 6 Source: libcurl 7 See-also: 8 - CURLOPT_CURLU (3) 9 - curl_url_cleanup (3) 10 - curl_url_dup (3) 11 - curl_url_get (3) 12 - curl_url_set (3) 13 - curl_url_strerror (3) 14 Protocol: 15 - All 16 Added-in: 7.62.0 17 --- 18 19 # NAME 20 21 curl_url - create a URL handle 22 23 # SYNOPSIS 24 25 ~~~c 26 #include <curl/curl.h> 27 28 CURLU *curl_url(); 29 ~~~ 30 31 # DESCRIPTION 32 33 This function allocates a URL object and returns a *CURLU* handle for it, 34 to be used as input to all other URL API functions. 35 36 This is a handle to a URL object that holds or can hold URL components for a 37 single URL. When the object is first created, there is of course no components 38 stored. They are then set in the object with the curl_url_set(3) 39 function. 40 41 # %PROTOCOLS% 42 43 # EXAMPLE 44 45 ~~~c 46 int main(void) 47 { 48 CURLUcode rc; 49 CURLU *url = curl_url(); 50 rc = curl_url_set(url, CURLUPART_URL, "https://example.com", 0); 51 if(!rc) { 52 char *scheme; 53 rc = curl_url_get(url, CURLUPART_SCHEME, &scheme, 0); 54 if(!rc) { 55 printf("the scheme is %s\n", scheme); 56 curl_free(scheme); 57 } 58 curl_url_cleanup(url); 59 } 60 } 61 ~~~ 62 63 # %AVAILABILITY% 64 65 # RETURN VALUE 66 67 Returns a **CURLU *** if successful, or NULL if out of memory.