github.com/krum110487/go-htaccess@v0.0.0-20240316004156-60641c8e7598/tests/data/apache_2_4_58/include/http_vhost.h (about) 1 /* Licensed to the Apache Software Foundation (ASF) under one or more 2 * contributor license agreements. See the NOTICE file distributed with 3 * this work for additional information regarding copyright ownership. 4 * The ASF licenses this file to You under the Apache License, Version 2.0 5 * (the "License"); you may not use this file except in compliance with 6 * the License. You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 /** 18 * @file http_vhost.h 19 * @brief Virtual Host package 20 * 21 * @defgroup APACHE_CORE_VHOST Virtual Host Package 22 * @ingroup APACHE_CORE 23 * @{ 24 */ 25 26 #ifndef APACHE_HTTP_VHOST_H 27 #define APACHE_HTTP_VHOST_H 28 29 #ifdef __cplusplus 30 extern "C" { 31 #endif 32 33 /** 34 * called before any config is read 35 * @param p Pool to allocate out of 36 */ 37 AP_DECLARE(void) ap_init_vhost_config(apr_pool_t *p); 38 39 /** 40 * called after the config has been read to compile the tables needed to do 41 * the run-time vhost lookups 42 * @param p The pool to allocate out of 43 * @param main_server The start of the virtual host list 44 */ 45 AP_DECLARE(void) ap_fini_vhost_config(apr_pool_t *p, server_rec *main_server); 46 47 /** 48 * handle addresses in "<VirtualHost>" statement 49 * @param p The pool to allocate out of 50 * @param hostname The hostname in the VirtualHost statement 51 * @param s The list of Virtual Hosts. 52 */ 53 const char *ap_parse_vhost_addrs(apr_pool_t *p, const char *hostname, server_rec *s); 54 55 /** 56 * handle NameVirtualHost directive 57 * @param cmd Command Parameters structure 58 * @param dummy NOT USED 59 * @param arg a host of the form "<address>[:port]" 60 */ 61 AP_DECLARE_NONSTD(const char *)ap_set_name_virtual_host(cmd_parms *cmd, 62 void *dummy, 63 const char *arg); 64 65 /** 66 * Callback function for every Name Based Virtual Host. 67 * @param baton Opaque user object 68 * @param conn The current Connection 69 * @param s The current Server 70 * @see ap_vhost_iterate_given_conn 71 * @return 0 on success, any non-zero return will stop the iteration. 72 */ 73 typedef int(*ap_vhost_iterate_conn_cb)(void* baton, conn_rec* conn, server_rec* s); 74 75 /** 76 * For every virtual host on this connection, call func_cb. 77 * @param conn The current connection 78 * @param func_cb Function called for every Name Based Virtual Host for this 79 * connection. 80 * @param baton Opaque object passed to func_cb. 81 * @return The return value from func_cb. 82 * @note If func_cb returns non-zero, the function will return at this point, 83 * and not continue iterating the virtual hosts. 84 */ 85 AP_DECLARE(int) ap_vhost_iterate_given_conn(conn_rec *conn, 86 ap_vhost_iterate_conn_cb func_cb, 87 void* baton); 88 89 /** 90 * given an ip address only, give our best guess as to what vhost it is 91 * @param conn The current connection 92 */ 93 AP_DECLARE(void) ap_update_vhost_given_ip(conn_rec *conn); 94 95 /** 96 * ap_update_vhost_given_ip is never enough, and this is always called after 97 * the headers have been read. It may change r->server. 98 * @param r The current request 99 */ 100 AP_DECLARE(void) ap_update_vhost_from_headers(request_rec *r); 101 102 /** 103 * Updates r->server with the best name-based virtual host match, within 104 * the chain of matching virtual hosts selected by ap_update_vhost_given_ip. 105 * @param r The current request 106 * @param require_match 1 to return an HTTP error if the requested hostname is 107 * not explicitly matched to a VirtualHost. 108 * @return return HTTP_OK unless require_match was specified and the requested 109 * hostname did not match any ServerName, ServerAlias, or VirtualHost 110 * address-spec. 111 */ 112 AP_DECLARE(int) ap_update_vhost_from_headers_ex(request_rec *r, int require_match); 113 114 115 /** 116 * Match the host in the header with the hostname of the server for this 117 * request. 118 * @param r The current request 119 * @param host The hostname in the headers 120 * @param port The port from the headers 121 * @return return 1 if the host:port matches any of the aliases of r->server, 122 * return 0 otherwise 123 */ 124 AP_DECLARE(int) ap_matches_request_vhost(request_rec *r, const char *host, 125 apr_port_t port); 126 127 #ifdef __cplusplus 128 } 129 #endif 130 131 #endif /* !APACHE_HTTP_VHOST_H */ 132 /** @} */