util_uri.h revision e9633214ea8ef133fe0756c9edc7676bdb210963
3112N/A/* ==================================================================== 3112N/A * The Apache Software License, Version 1.1 3112N/A * Copyright (c) 2000 The Apache Software Foundation. All rights 3112N/A * Redistribution and use in source and binary forms, with or without 3112N/A * modification, are permitted provided that the following conditions 3112N/A * 1. Redistributions of source code must retain the above copyright 3112N/A * notice, this list of conditions and the following disclaimer. 3112N/A * 2. Redistributions in binary form must reproduce the above copyright 3112N/A * notice, this list of conditions and the following disclaimer in 3112N/A * the documentation and/or other materials provided with the 3112N/A * 3. The end-user documentation included with the redistribution, 3112N/A * if any, must include the following acknowledgment: 3112N/A * "This product includes software developed by the 3112N/A * Alternately, this acknowledgment may appear in the software itself, 5065N/A * if and wherever such third-party acknowledgments normally appear. 5065N/A * 4. The names "Apache" and "Apache Software Foundation" must 5065N/A * not be used to endorse or promote products derived from this 5065N/A * software without prior written permission. For written 3112N/A * permission, please contact apache@apache.org. 880N/A * 5. Products derived from this software may not be called "Apache", 880N/A * nor may "Apache" appear in their name, without prior written 880N/A * permission of the Apache Software Foundation. 880N/A * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 880N/A * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 880N/A * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 927N/A * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR 5065N/A * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 5065N/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 927N/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 880N/A * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 880N/A * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 880N/A * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 927N/A * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 927N/A * ==================================================================== 4458N/A * This software consists of voluntary contributions made by many 4458N/A * individuals on behalf of the Apache Software Foundation. For more 4714N/A * information on the Apache Software Foundation, please see 4714N/A * Portions of this software are based upon public domain software 4754N/A * originally written at the National Center for Supercomputing Applications, 5759N/A * University of Illinois, Urbana-Champaign. 927N/A * @package Apache URI library 5417N/A/** Structure to store various schemes and their default ports */ 3361N/A /** The name of the scheme */ 927N/A /** The default port for the scheme */ /* Flags passed to unparse_uri_components(): */ #
define UNP_REVEALPASSWORD (
1U<<
3)
/* Show plain text password (default: show XXXXXXXX) */#
define UNP_OMITQUERY (
1U<<
5)
/* Omit the "?queryarg" from the path */ * A structure to encompass all of the fields in a uri /** scheme ("http"/"ftp"/...) */ /** combined [user[:password]@]host[:port] */ /** hostname from URI (or from Host: header) */ /** port string (integer representation is in "port") */ /** the request path (or "/" if only scheme://host was given) */ /** Everything after a '?' in the path, if present */ /** Trailing "#fragment" string, if present */ /** structure returned from gethostbyname() * @defvar struct hostent *hostent */ /** The port number, numeric, valid only if port_str != NULL */ /** has the structure been initialized */ /** has the DNS been looked up yet */ /** has the dns been resolved yet */ * Return the default port for a given scheme. The schemes recognized are * http, ftp, https, gopher, wais, nntp, snews, and prospero * @param scheme_str The string that contains the current scheme * @return The default port for this scheme * @deffunc unsigned short ap_default_port_for_scheme(const char *scheme_str) * Return the default for the current request * @param r The current request * @return The default port * @deffunc unsigned short ap_default_port_for_request(const request_rec *r) * Create a copy of a "struct hostent" record; it was presumably returned * from a call to gethostbyname() and lives in static storage. * By creating a copy we can tuck it away for later use. * @param p Pool to allocate out of * @param hp hostent to duplicate * @deffunc struct hostent * ap_pduphostent(apr_pool_t *p, const struct hostent *hp) * resolve hostname, if successful return an ALLOCATED COPY OF the hostent * structure, intended to be stored and used later. * @param p The pool to allocate out of * @param hostname The hostname to resolve * @return The allocated hostent structure * @deffunc struct hostent * ap_pgethostbyname(apr_pool_t *p, const char *hostname) * Unparse a uri_components structure to an URI string. Optionally suppress * the password for security reasons. * @param p The pool to allocate out of * @param uri_components All of the parts of the uri * @param flags How to unparse the uri. One of: * UNP_OMITSITEPART suppress "scheme://user@site:port" * UNP_OMITUSER Just omit user * UNP_OMITPASSWORD Just omit password * UNP_OMITUSERINFO omit "user:password@" part * UNP_REVEALPASSWORD Show plain text password (default: show XXXXXXXX) * UNP_OMITPATHINFO Show "scheme://user@site:port" only * UNP_OMITQUERY Omit the "?queryarg" from the path * @return The uri as a string * @deffunc char * ap_unparse_uri_components(apr_pool_t *p, const uri_components *uptr, unsigned flags) * Parse a given URI, fill in all supplied fields of a uri_components * structure. This eliminates the necessity of extracting host, port, * path, query info repeatedly in the modules. * @param p The pool to allocate out of * @param uri The uri to parse * @param uptr The uri_components to fill out * @return An HTTP status code * @deffunc int ap_parse_uri_components(apr_pool_t *p, const char *uri, uri_components *uptr) * Special case for CONNECT parsing: it comes with the hostinfo part only * @param p The pool to allocate out of * @param hostinfo The hostinfo string to parse * @param uptr The uri_components to fill out * @return An HTTP status code * @deffunc int ap_parse_hostinfo_components(apr_pool_t *p, const char *hostinfo, uri_components *uptr) * Setup everything necessary to parse uri's * @deffunc void ap_util_uri_init(void)