main.c revision 9fc4cd65587bea7b5a4dd570f4e191a34c7685c8
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina/* ====================================================================
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina * Copyright (c) 1995-1999 The Apache Group. All rights reserved.
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina *
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina * Redistribution and use in source and binary forms, with or without
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina * modification, are permitted provided that the following conditions
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina * are met:
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina *
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina * 1. Redistributions of source code must retain the above copyright
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina * notice, this list of conditions and the following disclaimer.
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina *
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina * 2. Redistributions in binary form must reproduce the above copyright
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina * notice, this list of conditions and the following disclaimer in
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina * the documentation and/or other materials provided with the
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina * distribution.
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina *
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina * 3. All advertising materials mentioning features or use of this
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina * software must display the following acknowledgment:
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina * "This product includes software developed by the Apache Group
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina * for use in the Apache HTTP server project (http://www.apache.org/)."
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina *
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina * 4. The names "Apache Server" and "Apache Group" must not be used to
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina * endorse or promote products derived from this software without
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina * prior written permission. For written permission, please contact
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina * apache@apache.org.
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina *
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina * 5. Products derived from this software may not be called "Apache"
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina * nor may "Apache" appear in their names without prior written
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina * permission of the Apache Group.
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina *
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina * 6. Redistributions of any form whatsoever must retain the following
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina * acknowledgment:
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina * "This product includes software developed by the Apache Group
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina * for use in the Apache HTTP server project (http://www.apache.org/)."
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina *
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE APACHE GROUP OR
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina * OF THE POSSIBILITY OF SUCH DAMAGE.
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina * ====================================================================
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina *
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina * This software consists of voluntary contributions made by many
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina * individuals on behalf of the Apache Group and was originally based
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina * on public domain software written at the National Center for
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina * Supercomputing Applications, University of Illinois, Urbana-Champaign.
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina * For more information on the Apache Group and the Apache HTTP server
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina * project, please see <http://www.apache.org/>.
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina *
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina */
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina#define CORE_PRIVATE
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina#include "httpd.h"
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina#include "http_main.h"
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina#include "http_config.h"
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina#include "util_uri.h"
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina#include "ap_mpm.h"
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březinachar *ap_server_argv0;
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel BřezinaAPI_VAR_EXPORT const char *ap_server_root;
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březinaap_array_header_t *ap_server_pre_read_config;
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březinaap_array_header_t *ap_server_post_read_config;
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březinaap_array_header_t *ap_server_config_defines;
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březinastatic void show_compile_settings(void)
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina{
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina printf("Server version: %s\n", ap_get_server_version());
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina printf("Server built: %s\n", ap_get_server_built());
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina printf("Server's Module Magic Number: %u:%u\n",
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina MODULE_MAGIC_NUMBER_MAJOR, MODULE_MAGIC_NUMBER_MINOR);
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina printf("Server compiled with....\n");
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina#ifdef BIG_SECURITY_HOLE
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina printf(" -D BIG_SECURITY_HOLE\n");
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina#endif
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina#ifdef SECURITY_HOLE_PASS_AUTHORIZATION
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina printf(" -D SECURITY_HOLE_PASS_AUTHORIZATION\n");
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina#endif
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina#ifdef HAVE_MMAP
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina printf(" -D HAVE_MMAP\n");
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina#endif
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina#ifdef HAVE_SHMGET
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina printf(" -D HAVE_SHMGET\n");
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina#endif
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina#ifdef USE_MMAP_SCOREBOARD
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina printf(" -D USE_MMAP_SCOREBOARD\n");
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina#endif
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina#ifdef USE_SHMGET_SCOREBOARD
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina printf(" -D USE_SHMGET_SCOREBOARD\n");
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina#endif
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina#ifdef USE_OS2_SCOREBOARD
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina printf(" -D USE_OS2_SCOREBOARD\n");
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina#endif
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina#ifdef USE_POSIX_SCOREBOARD
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina printf(" -D USE_POSIX_SCOREBOARD\n");
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina#endif
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina#ifdef USE_MMAP_FILES
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina printf(" -D USE_MMAP_FILES\n");
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina#ifdef MMAP_SEGMENT_SIZE
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina printf(" -D MMAP_SEGMENT_SIZE=%ld\n",(long)MMAP_SEGMENT_SIZE);
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina#endif
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina#endif /*USE_MMAP_FILES*/
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina#ifdef NO_WRITEV
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina printf(" -D NO_WRITEV\n");
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina#endif
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina#ifdef NO_LINGCLOSE
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina printf(" -D NO_LINGCLOSE\n");
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina#endif
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina#ifdef USE_FCNTL_SERIALIZED_ACCEPT
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina printf(" -D USE_FCNTL_SERIALIZED_ACCEPT\n");
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina#endif
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina#ifdef USE_FLOCK_SERIALIZED_ACCEPT
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina printf(" -D USE_FLOCK_SERIALIZED_ACCEPT\n");
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina#endif
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina#ifdef USE_USLOCK_SERIALIZED_ACCEPT
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina printf(" -D USE_USLOCK_SERIALIZED_ACCEPT\n");
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina#endif
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina#ifdef USE_SYSVSEM_SERIALIZED_ACCEPT
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina printf(" -D USE_SYSVSEM_SERIALIZED_ACCEPT\n");
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina#endif
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina#ifdef USE_PTHREAD_SERIALIZED_ACCEPT
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina printf(" -D USE_PTHREAD_SERIALIZED_ACCEPT\n");
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina#endif
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina#ifdef SINGLE_LISTEN_UNSERIALIZED_ACCEPT
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina printf(" -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT\n");
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina#endif
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina#ifdef HAS_OTHER_CHILD
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina printf(" -D HAS_OTHER_CHILD\n");
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina#endif
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina#ifdef NO_RELIABLE_PIPED_LOGS
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina printf(" -D NO_RELIABLE_PIPED_LOGS\n");
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina#endif
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina#ifdef BUFFERED_LOGS
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina printf(" -D BUFFERED_LOGS\n");
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina#ifdef PIPE_BUF
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina printf(" -D PIPE_BUF=%ld\n",(long)PIPE_BUF);
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina#endif
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina#endif
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina#ifdef MULTITHREAD
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina printf(" -D MULTITHREAD\n");
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina#endif
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina#ifdef CHARSET_EBCDIC
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina printf(" -D CHARSET_EBCDIC\n");
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina#endif
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina#ifdef NEED_HASHBANG_EMUL
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina printf(" -D NEED_HASHBANG_EMUL\n");
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina#endif
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina#ifdef SHARED_CORE
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina printf(" -D SHARED_CORE\n");
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina#endif
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina/* This list displays the compiled ap_context_t n default paths: */
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina#ifdef HTTPD_ROOT
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina printf(" -D HTTPD_ROOT=\"" HTTPD_ROOT "\"\n");
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina#endif
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina#ifdef SUEXEC_BIN
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina printf(" -D SUEXEC_BIN=\"" SUEXEC_BIN "\"\n");
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina#endif
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina#if defined(SHARED_CORE) && defined(SHARED_CORE_DIR)
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina printf(" -D SHARED_CORE_DIR=\"" SHARED_CORE_DIR "\"\n");
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina#endif
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina#ifdef DEFAULT_PIDLOG
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina printf(" -D DEFAULT_PIDLOG=\"" DEFAULT_PIDLOG "\"\n");
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina#endif
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina#ifdef DEFAULT_SCOREBOARD
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina printf(" -D DEFAULT_SCOREBOARD=\"" DEFAULT_SCOREBOARD "\"\n");
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina#endif
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina#ifdef DEFAULT_LOCKFILE
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina printf(" -D DEFAULT_LOCKFILE=\"" DEFAULT_LOCKFILE "\"\n");
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina#endif
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina#ifdef DEFAULT_XFERLOG
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina printf(" -D DEFAULT_XFERLOG=\"" DEFAULT_XFERLOG "\"\n");
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina#endif
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina#ifdef DEFAULT_ERRORLOG
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina printf(" -D DEFAULT_ERRORLOG=\"" DEFAULT_ERRORLOG "\"\n");
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina#endif
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina#ifdef TYPES_CONFIG_FILE
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina printf(" -D TYPES_CONFIG_FILE=\"" TYPES_CONFIG_FILE "\"\n");
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina#endif
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina#ifdef SERVER_CONFIG_FILE
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina printf(" -D SERVER_CONFIG_FILE=\"" SERVER_CONFIG_FILE "\"\n");
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina#endif
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina#ifdef ACCESS_CONFIG_FILE
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina printf(" -D ACCESS_CONFIG_FILE=\"" ACCESS_CONFIG_FILE "\"\n");
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina#endif
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina#ifdef RESOURCE_CONFIG_FILE
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina printf(" -D RESOURCE_CONFIG_FILE=\"" RESOURCE_CONFIG_FILE "\"\n");
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina#endif
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina}
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březinastatic void usage(char *bin)
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina{
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina char pad[MAX_STRING_LEN];
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina unsigned i;
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina for (i = 0; i < strlen(bin); i++)
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina pad[i] = ' ';
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina pad[i] = '\0';
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina#ifdef SHARED_CORE
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina fprintf(stderr, "Usage: %s [-R directory] [-D name] [-d directory] [-f file]\n", bin);
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina#else
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina fprintf(stderr, "Usage: %s [-D name] [-d directory] [-f file]\n", bin);
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina#endif
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina fprintf(stderr, " %s [-C \"directive\"] [-c \"directive\"]\n", pad);
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina fprintf(stderr, " %s [-v] [-V] [-h] [-l] [-L] [-S] [-t] [-T]\n", pad);
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina fprintf(stderr, "Options:\n");
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina#ifdef SHARED_CORE
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina fprintf(stderr, " -R directory : specify an alternate location for shared object files\n");
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina#endif
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina fprintf(stderr, " -D name : define a name for use in <IfDefine name> directives\n");
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina fprintf(stderr, " -d directory : specify an alternate initial ServerRoot\n");
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina fprintf(stderr, " -f file : specify an alternate ServerConfigFile\n");
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina fprintf(stderr, " -C \"directive\" : process directive before reading config files\n");
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina fprintf(stderr, " -c \"directive\" : process directive after reading config files\n");
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina fprintf(stderr, " -v : show version number\n");
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina fprintf(stderr, " -V : show compile settings\n");
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina fprintf(stderr, " -h : list available command line options (this page)\n");
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina fprintf(stderr, " -l : list compiled ap_context_t n modules\n");
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina fprintf(stderr, " -L : list available configuration directives\n");
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina /* TODOC: -S has been replaced by '-t -D DUMP_VHOSTS' */
b407fe0474a674bb42f0f42ab47c7f530a07a367Pavel Březina /* fprintf(stderr, " -S : show parsed settings (currently only vhost settings)\n"); */
fprintf(stderr, " -t : run syntax check for config files (with docroot check)\n");
fprintf(stderr, " -T : run syntax check for config files (without docroot check)\n");
/* TODOC: -X goes away, expect MPMs to use -D options */
exit(1);
}
ap_context_t *g_pHookPool;
extern char *optarg;
#ifdef WIN32
__declspec(dllexport)
int apache_main(int argc, char *argv[])
#else
int main(int argc, char **argv)
#endif
{
int c;
int configtestonly = 0;
char *s;
const char *confname = SERVER_CONFIG_FILE;
const char *def_server_root = HTTPD_ROOT;
server_rec *server_conf;
ap_context_t *pglobal; /* Global pool */
ap_context_t *pconf; /* Pool for config stuff */
ap_context_t *plog; /* Pool for error-logging files */
ap_context_t *ptemp; /* Pool for temporart config stuff */
ap_context_t *pcommands; /* Pool for -C and -c switches */
/* TODO: PATHSEPARATOR should be one of the os defines */
#define PATHSEPARATOR '/'
if ((s = strrchr(argv[0], PATHSEPARATOR)) != NULL) {
ap_server_argv0 = ++s;
}
else {
ap_server_argv0 = argv[0];
}
ap_util_uri_init();
ap_create_context(&pglobal, NULL);
g_pHookPool=pglobal;
ap_create_context(&pcommands, pglobal);
ap_server_pre_read_config = ap_make_array(pcommands, 1, sizeof(char *));
ap_server_post_read_config = ap_make_array(pcommands, 1, sizeof(char *));
ap_server_config_defines = ap_make_array(pcommands, 1, sizeof(char *));
ap_setup_prelinked_modules();
while ((c = getopt(argc, argv, "C:c:d:f:vVlLth")) != -1) {
char **new;
switch (c) {
case 'c':
new = (char **)ap_push_array(ap_server_post_read_config);
*new = ap_pstrdup(pcommands, optarg);
break;
case 'C':
new = (char **)ap_push_array(ap_server_pre_read_config);
*new = ap_pstrdup(pcommands, optarg);
break;
case 'd':
def_server_root = optarg;
break;
case 'f':
confname = optarg;
break;
case 'v':
printf("Server version: %s\n", ap_get_server_version());
printf("Server built: %s\n", ap_get_server_built());
exit(0);
case 'V':
show_compile_settings();
exit(0);
case 'l':
ap_show_modules();
exit(0);
case 'L':
ap_show_directives();
exit(0);
case 't':
configtestonly = 1;
break;
case 'h':
usage(argv[0]);
case '?':
usage(argv[0]);
}
}
ap_create_context(&pconf, pglobal);
ap_create_context(&plog, pglobal);
ap_create_context(&ptemp, pconf);
/* for legacy reasons, we read the configuration twice before
we actually serve any requests */
ap_server_root = def_server_root;
ap_run_pre_config(pconf, plog, ptemp);
server_conf = ap_read_config(pconf, ptemp, confname);
if (configtestonly) {
fprintf(stderr, "Syntax OK\n");
exit(0);
}
ap_clear_pool(plog);
ap_run_open_logs(pconf, plog, ptemp, server_conf);
ap_post_config_hook(pconf, plog, ptemp, server_conf);
ap_clear_pool(ptemp);
for (;;) {
ap_clear_pool(pconf);
ap_create_context(&ptemp, pconf);
ap_server_root = def_server_root;
ap_run_pre_config(pconf, plog, ptemp);
server_conf = ap_read_config(pconf, ptemp, confname);
ap_clear_pool(plog);
ap_run_open_logs(pconf, plog, ptemp, server_conf);
ap_post_config_hook(pconf, plog, ptemp, server_conf);
ap_destroy_pool(ptemp);
if (ap_mpm_run(pconf, plog, server_conf)) break;
}
ap_clear_pool(pconf);
ap_clear_pool(plog);
ap_destroy_pool(pglobal);
exit(0);
}
/* force Expat to be linked into the server executable */
#if defined(USE_EXPAT) && !defined(SHARED_CORE_BOOTSTRAP)
#include "xmlparse.h"
const XML_LChar *suck_in_expat(void);
const XML_LChar *suck_in_expat(void)
{
return XML_ErrorString(XML_ERROR_NONE);
}
#endif /* USE_EXPAT */
#ifndef SHARED_CORE_BOOTSTRAP
/*
* Force ap_validate_password() into the image so that modules like
* mod_auth can use it even if they're dynamically loaded.
*/
void suck_in_ap_validate_password(void);
void suck_in_ap_validate_password(void)
{
ap_validate_password("a", "b");
}
#endif