⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.c

📁 Apache HTTP Server 是一个功能强大的灵活的与HTTP/1.1相兼容的web服务器.这里给出的是Apache HTTP服务器的源码。
💻 C
📖 第 1 页 / 共 2 页
字号:
/* Copyright 1999-2005 The Apache Software Foundation or its licensors, as * applicable. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * *     http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */#include "apr.h"#include "apr_strings.h"#include "apr_getopt.h"#include "apr_general.h"#include "apr_lib.h"#include "apr_md5.h"#define APR_WANT_STDIO#define APR_WANT_STRFUNC#include "apr_want.h"#define CORE_PRIVATE#include "ap_config.h"#include "httpd.h"#include "http_main.h"#include "http_log.h"#include "http_config.h"#include "http_vhost.h"#include "apr_uri.h"#include "util_ebcdic.h"#include "ap_mpm.h"#include "mpm_common.h"/* WARNING: Win32 binds http_main.c dynamically to the server. Please place *          extern functions and global data in another appropriate module. * * Most significant main() global data can be found in http_config.c *//* XXX - We should be able to grab the per-MPM settings here too */static void show_compile_settings(void){    printf("Server version: %s\n", ap_get_server_version());    printf("Server built:   %s\n", ap_get_server_built());    printf("Server's Module Magic Number: %u:%u\n",           MODULE_MAGIC_NUMBER_MAJOR, MODULE_MAGIC_NUMBER_MINOR);    /* sizeof(foo) is long on some platforms so we might as well     * make it long everywhere to keep the printf format     * consistent     */    printf("Architecture:   %ld-bit\n", 8 * (long)sizeof(void *));    printf("Server compiled with....\n");#ifdef BIG_SECURITY_HOLE    printf(" -D BIG_SECURITY_HOLE\n");#endif#ifdef SECURITY_HOLE_PASS_AUTHORIZATION    printf(" -D SECURITY_HOLE_PASS_AUTHORIZATION\n");#endif#ifdef APACHE_MPM_DIR    printf(" -D APACHE_MPM_DIR=\"%s\"\n", APACHE_MPM_DIR);#endif#ifdef HAVE_SHMGET    printf(" -D HAVE_SHMGET\n");#endif#if APR_FILE_BASED_SHM    printf(" -D APR_FILE_BASED_SHM\n");#endif#if APR_HAS_SENDFILE    printf(" -D APR_HAS_SENDFILE\n");#endif#if APR_HAS_MMAP    printf(" -D APR_HAS_MMAP\n");#endif#ifdef NO_WRITEV    printf(" -D NO_WRITEV\n");#endif#ifdef NO_LINGCLOSE    printf(" -D NO_LINGCLOSE\n");#endif#if APR_HAVE_IPV6    printf(" -D APR_HAVE_IPV6 (IPv4-mapped addresses ");#ifdef AP_ENABLE_V4_MAPPED    printf("enabled)\n");#else    printf("disabled)\n");#endif#endif#if APR_USE_FLOCK_SERIALIZE    printf(" -D APR_USE_FLOCK_SERIALIZE\n");#endif#if APR_USE_SYSVSEM_SERIALIZE    printf(" -D APR_USE_SYSVSEM_SERIALIZE\n");#endif#if APR_USE_POSIXSEM_SERIALIZE    printf(" -D APR_USE_POSIXSEM_SERIALIZE\n");#endif#if APR_USE_FCNTL_SERIALIZE    printf(" -D APR_USE_FCNTL_SERIALIZE\n");#endif#if APR_USE_PROC_PTHREAD_SERIALIZE    printf(" -D APR_USE_PROC_PTHREAD_SERIALIZE\n");#endif#if APR_USE_PTHREAD_SERIALIZE    printf(" -D APR_USE_PTHREAD_SERIALIZE\n");#endif#if APR_PROCESS_LOCK_IS_GLOBAL    printf(" -D APR_PROCESS_LOCK_IS_GLOBAL\n");#endif#ifdef SINGLE_LISTEN_UNSERIALIZED_ACCEPT    printf(" -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT\n");#endif#if APR_HAS_OTHER_CHILD    printf(" -D APR_HAS_OTHER_CHILD\n");#endif#ifdef AP_HAVE_RELIABLE_PIPED_LOGS    printf(" -D AP_HAVE_RELIABLE_PIPED_LOGS\n");#endif#ifdef BUFFERED_LOGS    printf(" -D BUFFERED_LOGS\n");#ifdef PIPE_BUF    printf(" -D PIPE_BUF=%ld\n",(long)PIPE_BUF);#endif#endif#if APR_CHARSET_EBCDIC    printf(" -D APR_CHARSET_EBCDIC\n");#endif#ifdef APACHE_XLATE    printf(" -D APACHE_XLATE\n");#endif#ifdef NEED_HASHBANG_EMUL    printf(" -D NEED_HASHBANG_EMUL\n");#endif#ifdef SHARED_CORE    printf(" -D SHARED_CORE\n");#endif/* This list displays the compiled in default paths: */#ifdef HTTPD_ROOT    printf(" -D HTTPD_ROOT=\"" HTTPD_ROOT "\"\n");#endif#ifdef SUEXEC_BIN    printf(" -D SUEXEC_BIN=\"" SUEXEC_BIN "\"\n");#endif#if defined(SHARED_CORE) && defined(SHARED_CORE_DIR)    printf(" -D SHARED_CORE_DIR=\"" SHARED_CORE_DIR "\"\n");#endif#ifdef DEFAULT_PIDLOG    printf(" -D DEFAULT_PIDLOG=\"" DEFAULT_PIDLOG "\"\n");#endif#ifdef DEFAULT_SCOREBOARD    printf(" -D DEFAULT_SCOREBOARD=\"" DEFAULT_SCOREBOARD "\"\n");#endif#ifdef DEFAULT_LOCKFILE    printf(" -D DEFAULT_LOCKFILE=\"" DEFAULT_LOCKFILE "\"\n");#endif#ifdef DEFAULT_ERRORLOG    printf(" -D DEFAULT_ERRORLOG=\"" DEFAULT_ERRORLOG "\"\n");#endif#ifdef AP_TYPES_CONFIG_FILE    printf(" -D AP_TYPES_CONFIG_FILE=\"" AP_TYPES_CONFIG_FILE "\"\n");#endif#ifdef SERVER_CONFIG_FILE    printf(" -D SERVER_CONFIG_FILE=\"" SERVER_CONFIG_FILE "\"\n");#endif}static void destroy_and_exit_process(process_rec *process,                                     int process_exit_value){    apr_pool_destroy(process->pool); /* and destroy all descendent pools */    apr_terminate();    exit(process_exit_value);}static process_rec *create_process(int argc, const char * const *argv){    process_rec *process;    apr_pool_t *cntx;    apr_status_t stat;    stat = apr_pool_create(&cntx, NULL);    if (stat != APR_SUCCESS) {        /* XXX From the time that we took away the NULL pool->malloc mapping         *     we have been unable to log here without segfaulting.         */        ap_log_error(APLOG_MARK, APLOG_ERR, stat, NULL,                     "apr_pool_create() failed to create "                     "initial context");        apr_terminate();        exit(1);    }    apr_pool_tag(cntx, "process");    ap_open_stderr_log(cntx);    process = apr_palloc(cntx, sizeof(process_rec));    process->pool = cntx;    apr_pool_create(&process->pconf, process->pool);    apr_pool_tag(process->pconf, "pconf");    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, 0, NULL ,                 "Usage: %s [-R directory] [-D name] [-d directory] [-f file]",                 bin);#else    ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,                 "Usage: %s [-D name] [-d directory] [-f file]", bin);#endif    ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,                 "       %s [-C \"directive\"] [-c \"directive\"]", pad);#ifdef WIN32    ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,                 "       %s [-w] [-k start|restart|stop|shutdown]", pad);    ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,                 "       %s [-k install|config|uninstall] [-n service_name]",                 pad);#endif#ifdef AP_MPM_WANT_SIGNAL_SERVER    ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,                 "       %s [-k start|restart|graceful|stop]",                 pad);#endif    ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,                 "       %s [-v] [-V] [-h] [-l] [-L] [-t] [-S]", pad);    ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,                 "Options:");#ifdef SHARED_CORE    ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,                 "  -R directory      : specify an alternate location for "                 "shared object files");#endif    ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,                 "  -D name           : define a name for use in "                 "<IfDefine name> directives");    ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,                 "  -d directory      : specify an alternate initial "                 "ServerRoot");    ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,                 "  -f file           : specify an alternate ServerConfigFile");    ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,                 "  -C \"directive\"    : process directive before reading "                 "config files");    ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,                 "  -c \"directive\"    : process directive after reading "                 "config files");#ifdef NETWARE    ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,                 "  -n name           : set screen name");#endif#ifdef WIN32    ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,                 "  -n name           : set service name and use its "                 "ServerConfigFile");    ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,                 "  -k start          : tell Apache to start");    ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,                 "  -k restart        : tell running Apache to do a graceful "                 "restart");    ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,                 "  -k stop|shutdown  : tell running Apache to shutdown");    ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,                 "  -k install        : install an Apache service");    ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,                 "  -k config         : change startup Options of an Apache "                 "service");    ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,                 "  -k uninstall      : uninstall an Apache service");    ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,                 "  -w                : hold open the console window on error");#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -