Annotation of embedaddon/curl/docs/libcurl/curl_url_get.3, revision 1.1
1.1 ! misho 1: .\" **************************************************************************
! 2: .\" * _ _ ____ _
! 3: .\" * Project ___| | | | _ \| |
! 4: .\" * / __| | | | |_) | |
! 5: .\" * | (__| |_| | _ <| |___
! 6: .\" * \___|\___/|_| \_\_____|
! 7: .\" *
! 8: .\" * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
! 9: .\" *
! 10: .\" * This software is licensed as described in the file COPYING, which
! 11: .\" * you should have received as part of this distribution. The terms
! 12: .\" * are also available at https://curl.haxx.se/docs/copyright.html.
! 13: .\" *
! 14: .\" * You may opt to use, copy, modify, merge, publish, distribute and/or sell
! 15: .\" * copies of the Software, and permit persons to whom the Software is
! 16: .\" * furnished to do so, under the terms of the COPYING file.
! 17: .\" *
! 18: .\" * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
! 19: .\" * KIND, either express or implied.
! 20: .\" *
! 21: .\" **************************************************************************
! 22: .TH curl_url_get 3 "September 25, 2019" "libcurl 7.70.0" "libcurl Manual"
! 23:
! 24: .SH NAME
! 25: curl_url_get - extract a part from a URL
! 26: .SH SYNOPSIS
! 27: .B #include <curl/curl.h>
! 28:
! 29: .nf
! 30: CURLUcode curl_url_get(CURLU *url,
! 31: CURLUPart what,
! 32: char **part,
! 33: unsigned int flags)
! 34: .fi
! 35: .SH DESCRIPTION
! 36: Given the \fIurl\fP handle of an already parsed URL, this function lets the
! 37: user extract individual pieces from it.
! 38:
! 39: The \fIwhat\fP argument should be the particular part to extract (see list
! 40: below) and \fIpart\fP points to a 'char *' to get updated to point to a newly
! 41: allocated string with the contents.
! 42:
! 43: The \fIflags\fP argument is a bitmask with individual features.
! 44:
! 45: The returned part pointer must be freed with \fIcurl_free(3)\fP after use.
! 46: .SH FLAGS
! 47: The flags argument is zero, one or more bits set in a bitmask.
! 48: .IP CURLU_DEFAULT_PORT
! 49: If the handle has no port stored, this option will make \fIcurl_url_get(3)\fP
! 50: return the default port for the used scheme.
! 51: .IP CURLU_DEFAULT_SCHEME
! 52: If the handle has no scheme stored, this option will make
! 53: \fIcurl_url_get(3)\fP return the default scheme instead of error.
! 54: .IP CURLU_NO_DEFAULT_PORT
! 55: Instructs \fIcurl_url_get(3)\fP to not return a port number if it matches the
! 56: default port for the scheme.
! 57: .IP CURLU_URLDECODE
! 58: Asks \fIcurl_url_get(3)\fP to URL decode the contents before returning it. It
! 59: will not attempt to decode the scheme, the port number or the full URL.
! 60:
! 61: The query component will also get plus-to-space conversion as a bonus when
! 62: this bit is set.
! 63:
! 64: Note that this URL decoding is charset unaware and you will get a zero
! 65: terminated string back with data that could be intended for a particular
! 66: encoding.
! 67:
! 68: If there's any byte values lower than 32 in the decoded string, the get
! 69: operation will return an error instead.
! 70: .SH PARTS
! 71: .IP CURLUPART_URL
! 72: When asked to return the full URL, \fIcurl_url_get(3)\fP will return a
! 73: normalized and possibly cleaned up version of what was previously parsed.
! 74: .IP CURLUPART_SCHEME
! 75: Scheme cannot be URL decoded on get.
! 76: .IP CURLUPART_USER
! 77: .IP CURLUPART_PASSWORD
! 78: .IP CURLUPART_OPTIONS
! 79: .IP CURLUPART_HOST
! 80: The host name. If it is an IPv6 numeric address, the zoneid will not be part
! 81: of it but is provided separately in \fICURLUPART_ZONEID\fP. IPv6 numerical
! 82: addresses are returned within brackets ([]).
! 83: .IP CURLUPART_ZONEID
! 84: If the host name is a numeric IPv6 address, this field might also be set.
! 85: .IP CURLUPART_PORT
! 86: Port cannot be URL decoded on get.
! 87: .IP CURLUPART_PATH
! 88: .IP CURLUPART_QUERY
! 89: The query part will also get pluses converted to space when asked to URL
! 90: decode on get with the CURLU_URLDECODE bit.
! 91: .IP CURLUPART_FRAGMENT
! 92: .SH RETURN VALUE
! 93: Returns a CURLUcode error value, which is CURLUE_OK (0) if everything went
! 94: fine.
! 95:
! 96: If this function returns an error, no URL part is returned.
! 97: .SH EXAMPLE
! 98: .nf
! 99: CURLUcode rc;
! 100: CURLU *url = curl_url();
! 101: rc = curl_url_set(url, CURLUPART_URL, "https://example.com", 0);
! 102: if(!rc) {
! 103: char *scheme;
! 104: rc = curl_url_get(url, CURLUPART_SCHEME, &scheme, 0);
! 105: if(!rc) {
! 106: printf("the scheme is %s\\n", scheme);
! 107: curl_free(scheme);
! 108: }
! 109: curl_url_cleanup(url);
! 110: }
! 111: .fi
! 112: .SH AVAILABILITY
! 113: Added in curl 7.62.0. CURLUPART_ZONEID was added in 7.65.0.
! 114: .SH "SEE ALSO"
! 115: .BR curl_url_cleanup "(3), " curl_url "(3), " curl_url_set "(3), "
! 116: .BR curl_url_dup "(3), "
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>