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

📄 core.c

📁 Apache HTTP Server 是一个功能强大的灵活的与HTTP/1.1相兼容的web服务器.这里给出的是Apache HTTP服务器的源码。
💻 C
📖 第 1 页 / 共 5 页
字号:
        return errmsg;    conf->d = apr_pstrdup(cmd->pool, cmd->path);     /* No mangling, please */    conf->d_is_fnmatch = apr_fnmatch_test(conf->d) != 0;    conf->r = r;    ap_add_per_url_conf(cmd->server, new_url_conf);    if (*arg != '\0') {        return apr_pstrcat(cmd->pool, "Multiple ", thiscmd->name,                           "> arguments not (yet) supported.", NULL);    }    cmd->path = old_path;    cmd->override = old_overrides;    return NULL;}static const char *filesection(cmd_parms *cmd, void *mconfig, const char *arg){    const char *errmsg;    const char *endp = ap_strrchr_c(arg, '>');    int old_overrides = cmd->override;    char *old_path = cmd->path;    core_dir_config *conf;    regex_t *r = NULL;    const command_rec *thiscmd = cmd->cmd;    core_dir_config *c = mconfig;    ap_conf_vector_t *new_file_conf = ap_create_per_dir_config(cmd->pool);    const char *err = ap_check_cmd_context(cmd, NOT_IN_LIMIT|NOT_IN_LOCATION);    if (err != NULL) {        return err;    }    if (endp == NULL) {        return unclosed_directive(cmd);    }    arg = apr_pstrndup(cmd->pool, arg, endp - arg);    cmd->path = ap_getword_conf(cmd->pool, &arg);    /* Only if not an .htaccess file */    if (!old_path) {        cmd->override = OR_ALL|ACCESS_CONF;    }    if (thiscmd->cmd_data) { /* <FilesMatch> */        r = ap_pregcomp(cmd->pool, cmd->path, REG_EXTENDED|USE_ICASE);        if (!r) {            return "Regex could not be compiled";        }    }    else if (!strcmp(cmd->path, "~")) {        cmd->path = ap_getword_conf(cmd->pool, &arg);        r = ap_pregcomp(cmd->pool, cmd->path, REG_EXTENDED|USE_ICASE);        if (!r) {            return "Regex could not be compiled";        }    }    else {        char *newpath;        /* Ensure that the pathname is canonical, but we         * can't test the case/aliases without a fixed path */        if (apr_filepath_merge(&newpath, "", cmd->path,                               0, cmd->pool) != APR_SUCCESS)                return apr_pstrcat(cmd->pool, "<Files \"", cmd->path,                               "\"> is invalid.", NULL);        cmd->path = newpath;    }    /* initialize our config and fetch it */    conf = ap_set_config_vectors(cmd->server, new_file_conf, cmd->path,                                 &core_module, cmd->pool);    errmsg = ap_walk_config(cmd->directive->first_child, cmd, new_file_conf);    if (errmsg != NULL)        return errmsg;    conf->d = cmd->path;    conf->d_is_fnmatch = apr_fnmatch_test(conf->d) != 0;    conf->r = r;    ap_add_file_conf(c, new_file_conf);    if (*arg != '\0') {        return apr_pstrcat(cmd->pool, "Multiple ", thiscmd->name,                           "> arguments not (yet) supported.", NULL);    }    cmd->path = old_path;    cmd->override = old_overrides;    return NULL;}static const char *start_ifmod(cmd_parms *cmd, void *mconfig, const char *arg){    const char *endp = ap_strrchr_c(arg, '>');    int not = (arg[0] == '!');    module *found;    if (endp == NULL) {        return unclosed_directive(cmd);    }    arg = apr_pstrndup(cmd->pool, arg, endp - arg);    if (not) {        arg++;    }    found = ap_find_linked_module(arg);    if ((!not && found) || (not && !found)) {        ap_directive_t *parent = NULL;        ap_directive_t *current = NULL;        const char *retval;        retval = ap_build_cont_config(cmd->pool, cmd->temp_pool, cmd,                                      &current, &parent, "<IfModule");        *(ap_directive_t **)mconfig = current;        return retval;    }    else {        *(ap_directive_t **)mconfig = NULL;        return ap_soak_end_container(cmd, "<IfModule");    }}AP_DECLARE(int) ap_exists_config_define(const char *name){    char **defines;    int i;    defines = (char **)ap_server_config_defines->elts;    for (i = 0; i < ap_server_config_defines->nelts; i++) {        if (strcmp(defines[i], name) == 0) {            return 1;        }    }    return 0;}static const char *start_ifdefine(cmd_parms *cmd, void *dummy, const char *arg){    const char *endp;    int defined;    int not = 0;    endp = ap_strrchr_c(arg, '>');    if (endp == NULL) {        return unclosed_directive(cmd);    }    arg = apr_pstrndup(cmd->pool, arg, endp - arg);    if (arg[0] == '!') {        not = 1;        arg++;    }    defined = ap_exists_config_define(arg);    if ((!not && defined) || (not && !defined)) {        ap_directive_t *parent = NULL;        ap_directive_t *current = NULL;        const char *retval;        retval = ap_build_cont_config(cmd->pool, cmd->temp_pool, cmd,                                      &current, &parent, "<IfDefine");        *(ap_directive_t **)dummy = current;        return retval;    }    else {        *(ap_directive_t **)dummy = NULL;        return ap_soak_end_container(cmd, "<IfDefine");    }}/* httpd.conf commands... beginning with the <VirtualHost> business */static const char *virtualhost_section(cmd_parms *cmd, void *dummy,                                       const char *arg){    server_rec *main_server = cmd->server, *s;    const char *errmsg;    const char *endp = ap_strrchr_c(arg, '>');    apr_pool_t *p = cmd->pool;    const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);    if (err != NULL) {        return err;    }    if (endp == NULL) {        return unclosed_directive(cmd);    }    arg = apr_pstrndup(cmd->pool, arg, endp - arg);    /* FIXME: There's another feature waiting to happen here -- since you        can now put multiple addresses/names on a single <VirtualHost>        you might want to use it to group common definitions and then        define other "subhosts" with their individual differences.  But        personally I'd rather just do it with a macro preprocessor. -djg */    if (main_server->is_virtual) {        return "<VirtualHost> doesn't nest!";    }    errmsg = ap_init_virtual_host(p, arg, main_server, &s);    if (errmsg) {        return errmsg;    }    s->next = main_server->next;    main_server->next = s;    s->defn_name = cmd->directive->filename;    s->defn_line_number = cmd->directive->line_num;    cmd->server = s;    errmsg = ap_walk_config(cmd->directive->first_child, cmd,                            s->lookup_defaults);    cmd->server = main_server;    return errmsg;}static const char *set_server_alias(cmd_parms *cmd, void *dummy,                                    const char *arg){    if (!cmd->server->names) {        return "ServerAlias only used in <VirtualHost>";    }    while (*arg) {        char **item, *name = ap_getword_conf(cmd->pool, &arg);        if (ap_is_matchexp(name)) {            item = (char **)apr_array_push(cmd->server->wild_names);        }        else {            item = (char **)apr_array_push(cmd->server->names);        }        *item = name;    }    return NULL;}static const char *set_server_string_slot(cmd_parms *cmd, void *dummy,                                          const char *arg){    /* This one's pretty generic... */    int offset = (int)(long)cmd->info;    char *struct_ptr = (char *)cmd->server;    const char *err = ap_check_cmd_context(cmd,                                           NOT_IN_DIR_LOC_FILE|NOT_IN_LIMIT);    if (err != NULL) {        return err;    }    *(const char **)(struct_ptr + offset) = arg;    return NULL;}static const char *server_hostname_port(cmd_parms *cmd, void *dummy, const char *arg){    const char *err = ap_check_cmd_context(cmd, NOT_IN_DIR_LOC_FILE|NOT_IN_LIMIT);    const char *portstr;    int port;    if (err != NULL) {        return err;    }    portstr = ap_strchr_c(arg, ':');    if (portstr) {        cmd->server->server_hostname = apr_pstrndup(cmd->pool, arg,                                                    portstr - arg);        portstr++;        port = atoi(portstr);        if (port <= 0 || port >= 65536) { /* 65536 == 1<<16 */            return apr_pstrcat(cmd->temp_pool, "The port number \"", arg,                          "\" is outside the appropriate range "                          "(i.e., 1..65535).", NULL);        }    }    else {        cmd->server->server_hostname = apr_pstrdup(cmd->pool, arg);        port = 0;    }    cmd->server->port = port;    return NULL;}static const char *set_signature_flag(cmd_parms *cmd, void *d_,                                      const char *arg){    core_dir_config *d = d_;    const char *err = ap_check_cmd_context(cmd, NOT_IN_LIMIT);    if (err != NULL) {        return err;    }    if (strcasecmp(arg, "On") == 0) {        d->server_signature = srv_sig_on;    }    else if (strcasecmp(arg, "Off") == 0) {        d->server_signature = srv_sig_off;    }    else if (strcasecmp(arg, "EMail") == 0) {        d->server_signature = srv_sig_withmail;    }    else {        return "ServerSignature: use one of: off | on | email";    }    return NULL;}static const char *set_server_root(cmd_parms *cmd, void *dummy,                                   const char *arg){    const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);    if (err != NULL) {        return err;    }    if ((apr_filepath_merge((char**)&ap_server_root, NULL, arg,                            APR_FILEPATH_TRUENAME, cmd->pool) != APR_SUCCESS)        || !ap_is_directory(cmd->pool, ap_server_root)) {        return "ServerRoot must be a valid directory";    }    return NULL;}static const char *set_timeout(cmd_parms *cmd, void *dummy, const char *arg){    const char *err = ap_check_cmd_context(cmd, NOT_IN_DIR_LOC_FILE|NOT_IN_LIMIT);    if (err != NULL) {        return err;    }    cmd->server->timeout = apr_time_from_sec(atoi(arg));    return NULL;}static const char *set_idcheck(cmd_parms *cmd, void *d_, int arg){    core_dir_config *d = d_;    const char *err = ap_check_cmd_context(cmd, NOT_IN_LIMIT);    if (err != NULL) {        return err;    }    d->do_rfc1413 = arg != 0;    return NULL;}static const char *set_allow2f(cmd_parms *cmd, void *d_, int arg){    core_dir_config *d = d_;    const char *err = ap_check_cmd_context(cmd, NOT_IN_LIMIT);    if (err != NULL) {        return err;    }    d->allow_encoded_slashes = arg != 0;    return NULL;}static const char *set_hostname_lookups(cmd_parms *cmd, void *d_,                                        const char *arg){    core_dir_config *d = d_;    const char *err = ap_check_cmd_context(cmd, NOT_IN_LIMIT);    if (err != NULL) {        return err;    }    if (!strcasecmp(arg, "on")) {        d->hostname_lookups = HOSTNAME_LOOKUP_ON;    }    else if (!strcasecmp(arg, "off")) {        d->hostname_lookups = HOSTNAME_LOOKUP_OFF;    }    else if (!strcasecmp(arg, "double")) {        d->hostname_lookups = HOSTNAME_LOOKUP_DOUBLE;    }    else {        return "parameter must be 'on', 'off', or 'double'";    }    return NULL;}static const char *set_serverpath(cmd_parms *cmd, void *dummy,                                  const char *arg){    const char *err = ap_check_cmd_context(cmd, NOT_IN_DIR_LOC_FILE|NOT_IN_LIMIT);    if (err != NULL) {        return err;    }    cmd->server->path = arg;    cmd->server->pathlen = strlen(arg);    return NULL;}static const char *set_content_md5(cmd_parms *cmd, void *d_, int arg){    core_dir_config *d = d_;    const char *err = ap_check_cmd_context(cmd, NOT_IN_LIMIT);    if (err != NULL) {        return err;    }    d->content_md5 = arg != 0;    return NULL;}static const char *set_accept_path_info(cmd_parms *cmd, void *d_, const char *arg){    core_dir_config *d = d_;    if (strcasecmp(arg, "on") == 0) {        d->accept_path_info = AP_REQ_ACCEPT_PATH

⌨️ 快捷键说明

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