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