main.c revision 18b197c6ba1d5b8bb5b2fb372ef752f87e56912a
a78048ccbdb6256da15e6b0e7e95355e480c2301nd/* ====================================================================
a78048ccbdb6256da15e6b0e7e95355e480c2301nd * The Apache Software License, Version 1.1
fd9abdda70912b99b24e3bf1a38f26fde908a74cnd *
fd9abdda70912b99b24e3bf1a38f26fde908a74cnd * Copyright (c) 2000 The Apache Software Foundation. All rights
fd9abdda70912b99b24e3bf1a38f26fde908a74cnd * reserved.
a78048ccbdb6256da15e6b0e7e95355e480c2301nd *
a78048ccbdb6256da15e6b0e7e95355e480c2301nd * Redistribution and use in source and binary forms, with or without
a78048ccbdb6256da15e6b0e7e95355e480c2301nd * modification, are permitted provided that the following conditions
a78048ccbdb6256da15e6b0e7e95355e480c2301nd * are met:
96ad5d81ee4a2cc66a4ae19893efc8aa6d06fae7jailletc *
a78048ccbdb6256da15e6b0e7e95355e480c2301nd * 1. Redistributions of source code must retain the above copyright
a78048ccbdb6256da15e6b0e7e95355e480c2301nd * notice, this list of conditions and the following disclaimer.
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen *
2e545ce2450a9953665f701bb05350f0d3f26275nd * 2. Redistributions in binary form must reproduce the above copyright
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen * notice, this list of conditions and the following disclaimer in
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen * the documentation and/or other materials provided with the
a78048ccbdb6256da15e6b0e7e95355e480c2301nd * distribution.
a78048ccbdb6256da15e6b0e7e95355e480c2301nd *
a78048ccbdb6256da15e6b0e7e95355e480c2301nd * 3. The end-user documentation included with the redistribution,
af33a4994ae2ff15bc67d19ff1a7feb906745bf8rbowen * if any, must include the following acknowledgment:
3f08db06526d6901aa08c110b5bc7dde6bc39905nd * "This product includes software developed by the
a78048ccbdb6256da15e6b0e7e95355e480c2301nd * Apache Software Foundation (http://www.apache.org/)."
a78048ccbdb6256da15e6b0e7e95355e480c2301nd * Alternately, this acknowledgment may appear in the software itself,
a78048ccbdb6256da15e6b0e7e95355e480c2301nd * if and wherever such third-party acknowledgments normally appear.
3f08db06526d6901aa08c110b5bc7dde6bc39905nd *
a78048ccbdb6256da15e6b0e7e95355e480c2301nd * 4. The names "Apache" and "Apache Software Foundation" must
a78048ccbdb6256da15e6b0e7e95355e480c2301nd * not be used to endorse or promote products derived from this
a78048ccbdb6256da15e6b0e7e95355e480c2301nd * software without prior written permission. For written
a78048ccbdb6256da15e6b0e7e95355e480c2301nd * permission, please contact apache@apache.org.
bc9d4698fce0238d2f6f2682e99423ebb1149976rbowen *
a78048ccbdb6256da15e6b0e7e95355e480c2301nd * 5. Products derived from this software may not be called "Apache",
f086b4b402fa9a2fefc7dda85de2a3cc1cd0a654rjung * nor may "Apache" appear in their name, without prior written
a78048ccbdb6256da15e6b0e7e95355e480c2301nd * permission of the Apache Software Foundation.
4b575a6b6704b516f22d65a3ad35696d7b9ba372rpluem *
4b575a6b6704b516f22d65a3ad35696d7b9ba372rpluem * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
a78048ccbdb6256da15e6b0e7e95355e480c2301nd * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
a78048ccbdb6256da15e6b0e7e95355e480c2301nd * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
a78048ccbdb6256da15e6b0e7e95355e480c2301nd * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
a78048ccbdb6256da15e6b0e7e95355e480c2301nd * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
a78048ccbdb6256da15e6b0e7e95355e480c2301nd * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
a78048ccbdb6256da15e6b0e7e95355e480c2301nd * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
a78048ccbdb6256da15e6b0e7e95355e480c2301nd * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
a78048ccbdb6256da15e6b0e7e95355e480c2301nd * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
a78048ccbdb6256da15e6b0e7e95355e480c2301nd * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
a78048ccbdb6256da15e6b0e7e95355e480c2301nd * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
a78048ccbdb6256da15e6b0e7e95355e480c2301nd * SUCH DAMAGE.
a78048ccbdb6256da15e6b0e7e95355e480c2301nd * ====================================================================
a78048ccbdb6256da15e6b0e7e95355e480c2301nd *
a78048ccbdb6256da15e6b0e7e95355e480c2301nd * This software consists of voluntary contributions made by many
a78048ccbdb6256da15e6b0e7e95355e480c2301nd * individuals on behalf of the Apache Software Foundation. For more
1f1b6bf13313fdd14a45e52e553d3ff28689b717coar * information on the Apache Software Foundation, please see
a78048ccbdb6256da15e6b0e7e95355e480c2301nd * <http://www.apache.org/>.
a78048ccbdb6256da15e6b0e7e95355e480c2301nd *
1f1b6bf13313fdd14a45e52e553d3ff28689b717coar * Portions of this software are based upon public domain software
1f1b6bf13313fdd14a45e52e553d3ff28689b717coar * originally written at the National Center for Supercomputing Applications,
1f1b6bf13313fdd14a45e52e553d3ff28689b717coar * University of Illinois, Urbana-Champaign.
a78048ccbdb6256da15e6b0e7e95355e480c2301nd */
a78048ccbdb6256da15e6b0e7e95355e480c2301nd
a78048ccbdb6256da15e6b0e7e95355e480c2301nd#include "apr.h"
a78048ccbdb6256da15e6b0e7e95355e480c2301nd#include "apr_strings.h"
a78048ccbdb6256da15e6b0e7e95355e480c2301nd#include "apr_getopt.h"
a78048ccbdb6256da15e6b0e7e95355e480c2301nd#include "apr_general.h"
a78048ccbdb6256da15e6b0e7e95355e480c2301nd
a78048ccbdb6256da15e6b0e7e95355e480c2301nd#if APR_HAVE_STDIO_H
a78048ccbdb6256da15e6b0e7e95355e480c2301nd#include <stdio.h>
a78048ccbdb6256da15e6b0e7e95355e480c2301nd#endif
a78048ccbdb6256da15e6b0e7e95355e480c2301nd
a78048ccbdb6256da15e6b0e7e95355e480c2301nd#define CORE_PRIVATE
a78048ccbdb6256da15e6b0e7e95355e480c2301nd#include "ap_config.h"
a78048ccbdb6256da15e6b0e7e95355e480c2301nd#include "httpd.h"
a78048ccbdb6256da15e6b0e7e95355e480c2301nd#include "http_main.h"
a78048ccbdb6256da15e6b0e7e95355e480c2301nd#include "http_log.h"
a78048ccbdb6256da15e6b0e7e95355e480c2301nd#include "http_config.h"
a78048ccbdb6256da15e6b0e7e95355e480c2301nd#include "http_vhost.h"
a78048ccbdb6256da15e6b0e7e95355e480c2301nd#include "util_uri.h"
a78048ccbdb6256da15e6b0e7e95355e480c2301nd#include "util_ebcdic.h"
a78048ccbdb6256da15e6b0e7e95355e480c2301nd#include "ap_mpm.h"
a78048ccbdb6256da15e6b0e7e95355e480c2301nd
a78048ccbdb6256da15e6b0e7e95355e480c2301nd/* WARNING: Win32 binds http_main.c dynamically to the server. Please place
a78048ccbdb6256da15e6b0e7e95355e480c2301nd * extern functions and global data in another appropriate module.
a78048ccbdb6256da15e6b0e7e95355e480c2301nd *
a78048ccbdb6256da15e6b0e7e95355e480c2301nd * Most significant main() global data can be found in http_config.c
a78048ccbdb6256da15e6b0e7e95355e480c2301nd */
a78048ccbdb6256da15e6b0e7e95355e480c2301nd
a78048ccbdb6256da15e6b0e7e95355e480c2301nd/* XXX - We should be able to grab the per-MPM settings here too */
a78048ccbdb6256da15e6b0e7e95355e480c2301ndstatic void show_compile_settings(void)
a78048ccbdb6256da15e6b0e7e95355e480c2301nd{
a78048ccbdb6256da15e6b0e7e95355e480c2301nd printf("Server version: %s\n", ap_get_server_version());
a78048ccbdb6256da15e6b0e7e95355e480c2301nd printf("Server built: %s\n", ap_get_server_built());
a78048ccbdb6256da15e6b0e7e95355e480c2301nd printf("Server's Module Magic Number: %u:%u\n",
a78048ccbdb6256da15e6b0e7e95355e480c2301nd MODULE_MAGIC_NUMBER_MAJOR, MODULE_MAGIC_NUMBER_MINOR);
a78048ccbdb6256da15e6b0e7e95355e480c2301nd printf("Server compiled with....\n");
a78048ccbdb6256da15e6b0e7e95355e480c2301nd#ifdef BIG_SECURITY_HOLE
a78048ccbdb6256da15e6b0e7e95355e480c2301nd printf(" -D BIG_SECURITY_HOLE\n");
a78048ccbdb6256da15e6b0e7e95355e480c2301nd#endif
a78048ccbdb6256da15e6b0e7e95355e480c2301nd#ifdef SECURITY_HOLE_PASS_AUTHORIZATION
a78048ccbdb6256da15e6b0e7e95355e480c2301nd printf(" -D SECURITY_HOLE_PASS_AUTHORIZATION\n");
a78048ccbdb6256da15e6b0e7e95355e480c2301nd#endif
a78048ccbdb6256da15e6b0e7e95355e480c2301nd#if APR_HAS_MMAP
a78048ccbdb6256da15e6b0e7e95355e480c2301nd printf(" -D HAVE_MMAP\n");
a78048ccbdb6256da15e6b0e7e95355e480c2301nd#endif
a78048ccbdb6256da15e6b0e7e95355e480c2301nd#ifdef HAVE_SHMGET
a78048ccbdb6256da15e6b0e7e95355e480c2301nd printf(" -D HAVE_SHMGET\n");
a78048ccbdb6256da15e6b0e7e95355e480c2301nd#endif
a78048ccbdb6256da15e6b0e7e95355e480c2301nd#ifdef AP_USE_FILE_BASED_SCOREBOARD
a78048ccbdb6256da15e6b0e7e95355e480c2301nd printf(" -D AP_USE_FILE_BASED_SCOREBOARD\n");
a78048ccbdb6256da15e6b0e7e95355e480c2301nd#endif
a78048ccbdb6256da15e6b0e7e95355e480c2301nd#ifdef AP_USE_MEM_BASED_SCOREBOARD
a78048ccbdb6256da15e6b0e7e95355e480c2301nd printf(" -D AP_USE_MEM_BASED_SCOREBOARD\n");
a78048ccbdb6256da15e6b0e7e95355e480c2301nd#endif
a78048ccbdb6256da15e6b0e7e95355e480c2301nd#ifdef APR_HAS_MMAP
a78048ccbdb6256da15e6b0e7e95355e480c2301nd printf(" -D APR_HAS_MMAP\n");
a78048ccbdb6256da15e6b0e7e95355e480c2301nd#endif /*APR_HAS_MMAP*/
a78048ccbdb6256da15e6b0e7e95355e480c2301nd#ifdef NO_WRITEV
a78048ccbdb6256da15e6b0e7e95355e480c2301nd printf(" -D NO_WRITEV\n");
a78048ccbdb6256da15e6b0e7e95355e480c2301nd#endif
a78048ccbdb6256da15e6b0e7e95355e480c2301nd#ifdef NO_LINGCLOSE
a78048ccbdb6256da15e6b0e7e95355e480c2301nd printf(" -D NO_LINGCLOSE\n");
a78048ccbdb6256da15e6b0e7e95355e480c2301nd#endif
a78048ccbdb6256da15e6b0e7e95355e480c2301nd#if APR_HAVE_IPV6
a78048ccbdb6256da15e6b0e7e95355e480c2301nd printf(" -D APR_HAVE_IPV6\n");
a78048ccbdb6256da15e6b0e7e95355e480c2301nd#endif
a78048ccbdb6256da15e6b0e7e95355e480c2301nd#if APR_USE_FLOCK_SERIALIZE
a78048ccbdb6256da15e6b0e7e95355e480c2301nd printf(" -D APR_USE_FLOCK_SERIALIZE\n");
a78048ccbdb6256da15e6b0e7e95355e480c2301nd#endif
a78048ccbdb6256da15e6b0e7e95355e480c2301nd#if APR_USE_SYSVSEM_SERIALIZE
a78048ccbdb6256da15e6b0e7e95355e480c2301nd printf(" -D APR_USE_SYSVSEM_SERIALIZE\n");
a78048ccbdb6256da15e6b0e7e95355e480c2301nd#endif
a78048ccbdb6256da15e6b0e7e95355e480c2301nd#if APR_USE_FCNTL_SERIALIZE
a78048ccbdb6256da15e6b0e7e95355e480c2301nd printf(" -D APR_USE_FCNTL_SERIALIZE\n");
a78048ccbdb6256da15e6b0e7e95355e480c2301nd#endif
a78048ccbdb6256da15e6b0e7e95355e480c2301nd#if APR_USE_PROC_PTHREAD_SERIALIZE
a78048ccbdb6256da15e6b0e7e95355e480c2301nd printf(" -D APR_USE_PROC_PTHREAD_SERIALIZE\n");
a78048ccbdb6256da15e6b0e7e95355e480c2301nd#endif
a78048ccbdb6256da15e6b0e7e95355e480c2301nd#if APR_USE_PTHREAD_SERIALIZE
a78048ccbdb6256da15e6b0e7e95355e480c2301nd printf(" -D APR_USE_PTHREAD_SERIALIZE\n");
a78048ccbdb6256da15e6b0e7e95355e480c2301nd#endif
a78048ccbdb6256da15e6b0e7e95355e480c2301nd#if APR_PROCESS_LOCK_IS_GLOBAL
a78048ccbdb6256da15e6b0e7e95355e480c2301nd printf(" -D APR_PROCESS_LOCK_IS_GLOBAL\n");
a78048ccbdb6256da15e6b0e7e95355e480c2301nd#endif
a78048ccbdb6256da15e6b0e7e95355e480c2301nd#ifdef SINGLE_LISTEN_UNSERIALIZED_ACCEPT
a78048ccbdb6256da15e6b0e7e95355e480c2301nd printf(" -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT\n");
a78048ccbdb6256da15e6b0e7e95355e480c2301nd#endif
a78048ccbdb6256da15e6b0e7e95355e480c2301nd#if APR_HAS_OTHER_CHILD
a78048ccbdb6256da15e6b0e7e95355e480c2301nd printf(" -D APR_HAS_OTHER_CHILD\n");
a78048ccbdb6256da15e6b0e7e95355e480c2301nd#endif
a78048ccbdb6256da15e6b0e7e95355e480c2301nd#ifdef AP_HAVE_RELIABLE_PIPED_LOGS
a78048ccbdb6256da15e6b0e7e95355e480c2301nd printf(" -D AP_HAVE_RELIABLE_PIPED_LOGS\n");
a78048ccbdb6256da15e6b0e7e95355e480c2301nd#endif
a78048ccbdb6256da15e6b0e7e95355e480c2301nd#ifdef BUFFERED_LOGS
a78048ccbdb6256da15e6b0e7e95355e480c2301nd printf(" -D BUFFERED_LOGS\n");
a78048ccbdb6256da15e6b0e7e95355e480c2301nd#ifdef PIPE_BUF
a78048ccbdb6256da15e6b0e7e95355e480c2301nd printf(" -D PIPE_BUF=%ld\n",(long)PIPE_BUF);
a78048ccbdb6256da15e6b0e7e95355e480c2301nd#endif
a78048ccbdb6256da15e6b0e7e95355e480c2301nd#endif
a78048ccbdb6256da15e6b0e7e95355e480c2301nd#if APR_CHARSET_EBCDIC
a78048ccbdb6256da15e6b0e7e95355e480c2301nd printf(" -D APR_CHARSET_EBCDIC\n");
a78048ccbdb6256da15e6b0e7e95355e480c2301nd#endif
a78048ccbdb6256da15e6b0e7e95355e480c2301nd#ifdef APACHE_XLATE
a78048ccbdb6256da15e6b0e7e95355e480c2301nd printf(" -D APACHE_XLATE\n");
a78048ccbdb6256da15e6b0e7e95355e480c2301nd#endif
a78048ccbdb6256da15e6b0e7e95355e480c2301nd#ifdef NEED_HASHBANG_EMUL
a78048ccbdb6256da15e6b0e7e95355e480c2301nd printf(" -D NEED_HASHBANG_EMUL\n");
a78048ccbdb6256da15e6b0e7e95355e480c2301nd#endif
a78048ccbdb6256da15e6b0e7e95355e480c2301nd#ifdef SHARED_CORE
a78048ccbdb6256da15e6b0e7e95355e480c2301nd printf(" -D SHARED_CORE\n");
a78048ccbdb6256da15e6b0e7e95355e480c2301nd#endif
a78048ccbdb6256da15e6b0e7e95355e480c2301nd
a78048ccbdb6256da15e6b0e7e95355e480c2301nd/* This list displays the compiled in default paths: */
a78048ccbdb6256da15e6b0e7e95355e480c2301nd#ifdef HTTPD_ROOT
a78048ccbdb6256da15e6b0e7e95355e480c2301nd printf(" -D HTTPD_ROOT=\"" HTTPD_ROOT "\"\n");
a78048ccbdb6256da15e6b0e7e95355e480c2301nd#endif
a78048ccbdb6256da15e6b0e7e95355e480c2301nd#ifdef SUEXEC_BIN
a78048ccbdb6256da15e6b0e7e95355e480c2301nd printf(" -D SUEXEC_BIN=\"" SUEXEC_BIN "\"\n");
a78048ccbdb6256da15e6b0e7e95355e480c2301nd#endif
a78048ccbdb6256da15e6b0e7e95355e480c2301nd#if defined(SHARED_CORE) && defined(SHARED_CORE_DIR)
a78048ccbdb6256da15e6b0e7e95355e480c2301nd printf(" -D SHARED_CORE_DIR=\"" SHARED_CORE_DIR "\"\n");
a78048ccbdb6256da15e6b0e7e95355e480c2301nd#endif
a78048ccbdb6256da15e6b0e7e95355e480c2301nd#ifdef DEFAULT_PIDLOG
a78048ccbdb6256da15e6b0e7e95355e480c2301nd printf(" -D DEFAULT_PIDLOG=\"" DEFAULT_PIDLOG "\"\n");
a78048ccbdb6256da15e6b0e7e95355e480c2301nd#endif
a78048ccbdb6256da15e6b0e7e95355e480c2301nd#ifdef DEFAULT_SCOREBOARD
a78048ccbdb6256da15e6b0e7e95355e480c2301nd printf(" -D DEFAULT_SCOREBOARD=\"" DEFAULT_SCOREBOARD "\"\n");
a78048ccbdb6256da15e6b0e7e95355e480c2301nd#endif
a78048ccbdb6256da15e6b0e7e95355e480c2301nd#ifdef DEFAULT_LOCKFILE
a78048ccbdb6256da15e6b0e7e95355e480c2301nd printf(" -D DEFAULT_LOCKFILE=\"" DEFAULT_LOCKFILE "\"\n");
a78048ccbdb6256da15e6b0e7e95355e480c2301nd#endif
a78048ccbdb6256da15e6b0e7e95355e480c2301nd#ifdef DEFAULT_XFERLOG
a78048ccbdb6256da15e6b0e7e95355e480c2301nd printf(" -D DEFAULT_XFERLOG=\"" DEFAULT_XFERLOG "\"\n");
a78048ccbdb6256da15e6b0e7e95355e480c2301nd#endif
a78048ccbdb6256da15e6b0e7e95355e480c2301nd#ifdef DEFAULT_ERRORLOG
bc9d4698fce0238d2f6f2682e99423ebb1149976rbowen printf(" -D DEFAULT_ERRORLOG=\"" DEFAULT_ERRORLOG "\"\n");
a78048ccbdb6256da15e6b0e7e95355e480c2301nd#endif
f086b4b402fa9a2fefc7dda85de2a3cc1cd0a654rjung#ifdef TYPES_CONFIG_FILE
727872d18412fc021f03969b8641810d8896820bhumbedooh printf(" -D TYPES_CONFIG_FILE=\"" TYPES_CONFIG_FILE "\"\n");
0d0ba3a410038e179b695446bb149cce6264e0abnd#endif
727872d18412fc021f03969b8641810d8896820bhumbedooh#ifdef SERVER_CONFIG_FILE
cc7e1025de9ac63bd4db6fe7f71c158b2cf09fe4humbedooh printf(" -D SERVER_CONFIG_FILE=\"" SERVER_CONFIG_FILE "\"\n");
0d0ba3a410038e179b695446bb149cce6264e0abnd#endif
cc7e1025de9ac63bd4db6fe7f71c158b2cf09fe4humbedooh}
727872d18412fc021f03969b8641810d8896820bhumbedooh
0d0ba3a410038e179b695446bb149cce6264e0abndstatic void destroy_and_exit_process(process_rec *process, int process_exit_value)
0d0ba3a410038e179b695446bb149cce6264e0abnd{
0d0ba3a410038e179b695446bb149cce6264e0abnd apr_destroy_pool(process->pool); /* and destroy all descendent pools */
ac082aefa89416cbdc9a1836eaf3bed9698201c8humbedooh apr_terminate();
0d0ba3a410038e179b695446bb149cce6264e0abnd exit(process_exit_value);
0d0ba3a410038e179b695446bb149cce6264e0abnd}
0d0ba3a410038e179b695446bb149cce6264e0abnd
727872d18412fc021f03969b8641810d8896820bhumbedoohstatic process_rec *create_process(int argc, const char * const *argv)
0d0ba3a410038e179b695446bb149cce6264e0abnd{
0d0ba3a410038e179b695446bb149cce6264e0abnd process_rec *process;
30471a4650391f57975f60bbb6e4a90be7b284bfhumbedooh apr_pool_t *cntx;
205f749042ed530040a4f0080dbcb47ceae8a374rjung apr_status_t stat;
af33a4994ae2ff15bc67d19ff1a7feb906745bf8rbowen
0d0ba3a410038e179b695446bb149cce6264e0abnd stat = apr_create_pool(&cntx, NULL);
7fec19672a491661b2fe4b29f685bc7f4efa64d4nd if (stat != APR_SUCCESS) {
7fec19672a491661b2fe4b29f685bc7f4efa64d4nd /* XXX From the time that we took away the NULL pool->malloc mapping
7fec19672a491661b2fe4b29f685bc7f4efa64d4nd * we have been unable to log here without segfaulting.
a78048ccbdb6256da15e6b0e7e95355e480c2301nd */
ap_log_error(APLOG_MARK, APLOG_ERR|APLOG_NOERRNO, 0, NULL,
"apr_create_pool() failed to create "
"initial context");
apr_terminate();
exit(1);
}
ap_open_stderr_log(cntx);
process = apr_palloc(cntx, sizeof(process_rec));
process->pool = cntx;
apr_create_pool(&process->pconf, process->pool);
process->argc = argc;
process->argv = argv;
process->short_name = apr_filename_of_pathname(argv[0]);
return process;
}
static void usage(process_rec *process)
{
const char *bin = process->argv[0];
char pad[MAX_STRING_LEN];
unsigned i;
for (i = 0; i < strlen(bin); i++)
pad[i] = ' ';
pad[i] = '\0';
#ifdef SHARED_CORE
ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0,NULL , "Usage: %s [-R directory] [-D name] [-d directory] [-f file]", bin);
#else
ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, "Usage: %s [-D name] [-d directory] [-f file]", bin);
#endif
ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, " %s [-C \"directive\"] [-c \"directive\"]", pad);
#ifdef WIN32
ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, " %s [-k restart|shutdown|start]", pad);
ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, " %s [-n service_name]", pad);
ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, " %s [-i] [-u]", pad);
#endif
ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, " %s [-v] [-V] [-h] [-l] [-L] [-t] [-T]", pad);
ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, "Options:");
#ifdef SHARED_CORE
ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, " -R directory : specify an alternate location for shared object files");
#endif
ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, " -D name : define a name for use in <IfDefine name> directives");
ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, " -d directory : specify an alternate initial ServerRoot");
ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, " -f file : specify an alternate ServerConfigFile");
ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, " -C \"directive\" : process directive before reading config files");
ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, " -c \"directive\" : process directive after reading config files");
#ifdef WIN32
ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, " -n name : set service name and use its ServerConfigFile");
ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, " -k shutdown : tell running Apache to shutdown");
ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, " -k restart : tell running Apache to do a graceful restart");
ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, " -k start : tell Apache to start");
ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, " -i : install an Apache service");
ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, " -u : uninstall an Apache service");
#endif
ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, " -v : show version number");
ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, " -V : show compile settings");
ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, " -h : list available command line options (this page)");
ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, " -l : list compiled in modules");
ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, " -L : list available configuration directives");
ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, " -t -D DUMP_VHOSTS : show parsed settings (currently only vhost settings)");
ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, " -t : run syntax check for config files (with docroot check)");
ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, " -T : run syntax check for config files (without docroot check)");
/* TODOC: -X goes away, expect MPMs to use -D options */
destroy_and_exit_process(process, 1);
}
int main(int argc, const char * const argv[])
{
char c;
int configtestonly = 0;
const char *confname = SERVER_CONFIG_FILE;
const char *def_server_root = HTTPD_ROOT;
process_rec *process;
server_rec *server_conf;
apr_pool_t *pglobal;
apr_pool_t *pconf;
apr_pool_t *plog; /* Pool of log streams, reset _after_ each read of conf */
apr_pool_t *ptemp; /* Pool for temporary config stuff, reset often */
apr_pool_t *pcommands; /* Pool for -D, -C and -c switches */
apr_getopt_t *opt;
module **mod;
const char *optarg;
apr_initialize();
process = create_process(argc, argv);
pglobal = process->pool;
pconf = process->pconf;
ap_server_argv0 = process->short_name;
#if APR_CHARSET_EBCDIC
if (ap_init_ebcdic(pglobal) != APR_SUCCESS) {
destroy_and_exit_process(process, 1);
}
#endif
ap_util_uri_init();
ap_setup_prelinked_modules(process);
apr_create_pool(&pcommands, pglobal);
ap_server_pre_read_config = apr_make_array(pcommands, 1, sizeof(char *));
ap_server_post_read_config = apr_make_array(pcommands, 1, sizeof(char *));
ap_server_config_defines = apr_make_array(pcommands, 1, sizeof(char *));
ap_run_rewrite_args(process);
/* Maintain AP_SERVER_BASEARGS list in http_main.h to allow the MPM
* to safely pass on our args from its rewrite_args() handler.
*/
apr_initopt(&opt, pcommands, process->argc, process->argv);
while (apr_getopt(opt, AP_SERVER_BASEARGS, &c, &optarg)
== APR_SUCCESS) {
char **new;
switch (c) {
case 'c':
new = (char **)apr_push_array(ap_server_post_read_config);
*new = apr_pstrdup(pcommands, optarg);
break;
case 'C':
new = (char **)apr_push_array(ap_server_pre_read_config);
*new = apr_pstrdup(pcommands, optarg);
break;
case 'd':
def_server_root = optarg;
break;
case 'D':
new = (char **)apr_push_array(ap_server_config_defines);
*new = apr_pstrdup(pcommands, 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());
destroy_and_exit_process(process, 0);
case 'V':
show_compile_settings();
destroy_and_exit_process(process, 0);
case 'l':
ap_show_modules();
destroy_and_exit_process(process, 0);
case 'L':
ap_show_directives();
destroy_and_exit_process(process, 0);
case 't':
configtestonly = 1;
break;
case '?':
case 'h':
usage(process);
}
}
apr_create_pool(&plog, pglobal);
apr_create_pool(&ptemp, pconf);
/* Note that we preflight the config file once
before reading it _again_ in the main loop.
This allows things, log files configuration
for example, to settle down. */
ap_server_root = def_server_root;
server_conf = ap_read_config(process, ptemp, confname, &ap_conftree);
ap_run_pre_config(pconf, plog, ptemp);
ap_process_config_tree(server_conf, ap_conftree, process->pconf, ptemp);
ap_fixup_virtual_hosts(pconf, server_conf);
ap_fini_vhost_config(pconf, server_conf);
ap_sort_hooks();
if (configtestonly) {
ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, "Syntax OK\n");
destroy_and_exit_process(process, 0);
}
apr_clear_pool(plog);
ap_run_open_logs(pconf, plog, ptemp, server_conf);
ap_post_config_hook(pconf, plog, ptemp, server_conf);
apr_destroy_pool(ptemp);
for (;;) {
ap_hook_deregister_all();
apr_clear_pool(pconf);
for (mod = ap_prelinked_modules; *mod != NULL; mod++) {
ap_register_hooks(*mod);
}
/* This is a hack until we finish the code so that it only reads
* the config file once and just operates on the tree already in
* memory. rbb
*/
ap_conftree = NULL;
apr_create_pool(&ptemp, pconf);
ap_server_root = def_server_root;
server_conf = ap_read_config(process, ptemp, confname, &ap_conftree);
ap_run_pre_config(pconf, plog, ptemp);
ap_process_config_tree(server_conf, ap_conftree, process->pconf, ptemp);
ap_fixup_virtual_hosts(pconf, server_conf);
ap_fini_vhost_config(pconf, server_conf);
ap_sort_hooks();
apr_clear_pool(plog);
ap_run_open_logs(pconf, plog, ptemp, server_conf);
ap_post_config_hook(pconf, plog, ptemp, server_conf);
apr_destroy_pool(ptemp);
if (ap_mpm_run(pconf, plog, server_conf)) break;
}
destroy_and_exit_process(process, 0);
return 0; /* Supress compiler warning. */
}
/* 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 apr_validate_password() into the image so that modules like
* mod_auth can use it even if they're dynamically loaded.
*/
void suck_in_apr_validate_password(void);
void suck_in_apr_validate_password(void)
{
apr_validate_password("a", "b");
}
#endif
#ifdef AP_USING_AUTOCONF
/* This ugly little hack pulls any function referenced in exports.c into
* the web server. exports.c is generated during the build, and it
* has all of the APR functions specified by the apr/apr.exports and
* apr-util/aprutil.exports files.
*/
const void *suck_in_APR(void);
const void *suck_in_APR(void)
{
extern const void *ap_ugly_hack;
return ap_ugly_hack;
}
#endif