1--- 2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 3SPDX-License-Identifier: curl 4Title: curl_url 5Section: 3 6Source: libcurl 7See-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) 14Protocol: 15 - All 16Added-in: 7.62.0 17--- 18 19# NAME 20 21curl_url - create a URL handle 22 23# SYNOPSIS 24 25~~~c 26#include <curl/curl.h> 27 28CURLU *curl_url(); 29~~~ 30 31# DESCRIPTION 32 33This function allocates a URL object and returns a *CURLU* handle for it, 34to be used as input to all other URL API functions. 35 36This is a handle to a URL object that holds or can hold URL components for a 37single URL. When the object is first created, there is of course no components 38stored. They are then set in the object with the curl_url_set(3) 39function. 40 41# %PROTOCOLS% 42 43# EXAMPLE 44 45~~~c 46int 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 67Returns a **CURLU *** if successful, or NULL if out of memory. 68