-: 0:Source:modperl_pcw.c -: 0:Object:modperl_pcw.bb -: 1:/* Copyright 2001-2004 The Apache Software Foundation -: 2: * -: 3: * Licensed under the Apache License, Version 2.0 (the "License"); -: 4: * you may not use this file except in compliance with the License. -: 5: * You may obtain a copy of the License at -: 6: * -: 7: * http://www.apache.org/licenses/LICENSE-2.0 -: 8: * -: 9: * Unless required by applicable law or agreed to in writing, software -: 10: * distributed under the License is distributed on an "AS IS" BASIS, -: 11: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -: 12: * See the License for the specific language governing permissions and -: 13: * limitations under the License. -: 14: */ -: 15: -: 16:#include "mod_perl.h" -: 17: -: 18:/* -: 19: * pcw == Parsed Config Walker -: 20: * generic functions for walking parsed config using callbacks -: 21: */ -: 22: -: 23:void ap_pcw_walk_location_config(apr_pool_t *pconf, server_rec *s, -: 24: core_server_config *sconf, -: 25: module *modp, -: 26: ap_pcw_dir_cb_t dir_cb, void *data) 92: 27:{ 92: 28: int i; 92: 29: ap_conf_vector_t **urls = (ap_conf_vector_t **)sconf->sec_url->elts; -: 30: 15028: 31: for (i = 0; i < sconf->sec_url->nelts; i++) { 14936: 32: core_dir_config *conf = 14936: 33: ap_get_module_config(urls[i], &core_module); 14936: 34: void *dir_cfg = ap_get_module_config(urls[i], modp); -: 35: 14936: 36: if (!dir_cb(pconf, s, dir_cfg, conf->d, data)) { 14936: 37: break; -: 38: } -: 39: } -: 40:} -: 41: -: 42:void ap_pcw_walk_directory_config(apr_pool_t *pconf, server_rec *s, -: 43: core_server_config *sconf, -: 44: module *modp, -: 45: ap_pcw_dir_cb_t dir_cb, void *data) 92: 46:{ 92: 47: int i; 92: 48: ap_conf_vector_t **dirs = (ap_conf_vector_t **)sconf->sec_dir->elts; -: 49: 364: 50: for (i = 0; i < sconf->sec_dir->nelts; i++) { 272: 51: core_dir_config *conf = 272: 52: ap_get_module_config(dirs[i], &core_module); 272: 53: void *dir_cfg = ap_get_module_config(dirs[i], modp); -: 54: 272: 55: if (!dir_cb(pconf, s, dir_cfg, conf->d, data)) { 272: 56: break; -: 57: } -: 58: } -: 59:} -: 60: -: 61:void ap_pcw_walk_files_config(apr_pool_t *pconf, server_rec *s, -: 62: core_dir_config *dconf, -: 63: module *modp, -: 64: ap_pcw_dir_cb_t dir_cb, void *data) 92: 65:{ 92: 66: int i; 92: 67: ap_conf_vector_t **dirs = (ap_conf_vector_t **)dconf->sec_file->elts; -: 68: 92: 69: for (i = 0; i < dconf->sec_file->nelts; i++) { #####: 70: core_dir_config *conf = #####: 71: ap_get_module_config(dirs[i], &core_module); #####: 72: void *dir_cfg = ap_get_module_config(dirs[i], modp); -: 73: #####: 74: if (!dir_cb(pconf, s, dir_cfg, conf->d, data)) { #####: 75: break; -: 76: } -: 77: } -: 78:} -: 79: -: 80:void ap_pcw_walk_default_config(apr_pool_t *pconf, server_rec *s, -: 81: module *modp, -: 82: ap_pcw_dir_cb_t dir_cb, void *data) 92: 83:{ 92: 84: core_dir_config *conf = 92: 85: ap_get_module_config(s->lookup_defaults, &core_module); 92: 86: void *dir_cfg = 92: 87: ap_get_module_config(s->lookup_defaults, modp); -: 88: 92: 89: dir_cb(pconf, s, dir_cfg, conf->d, data); -: 90:} -: 91: -: 92:void ap_pcw_walk_server_config(apr_pool_t *pconf, server_rec *s, -: 93: module *modp, -: 94: ap_pcw_srv_cb_t srv_cb, void *data) 92: 95:{ 92: 96: void *cfg = ap_get_module_config(s->module_config, modp); -: 97: 92: 98: if (!cfg) { 92: 99: return; -: 100: } -: 101: 92: 102: srv_cb(pconf, s, cfg, data); -: 103:} -: 104: -: 105:void ap_pcw_walk_config(apr_pool_t *pconf, server_rec *s, -: 106: module *modp, void *data, -: 107: ap_pcw_dir_cb_t dir_cb, ap_pcw_srv_cb_t srv_cb) 8: 108:{ 100: 109: for (; s; s = s->next) { 92: 110: core_dir_config *dconf = -: 111: ap_get_module_config(s->lookup_defaults, 92: 112: &core_module); -: 113: 92: 114: core_server_config *sconf = -: 115: ap_get_module_config(s->module_config, 92: 116: &core_module); -: 117: 92: 118: if (dir_cb) { 92: 119: ap_pcw_walk_location_config(pconf, s, sconf, modp, dir_cb, data); 92: 120: ap_pcw_walk_directory_config(pconf, s, sconf, modp, dir_cb, data); 92: 121: ap_pcw_walk_files_config(pconf, s, dconf, modp, dir_cb, data); 92: 122: ap_pcw_walk_default_config(pconf, s, modp, dir_cb, data); -: 123: } -: 124: 92: 125: if (srv_cb) { 92: 126: ap_pcw_walk_server_config(pconf, s, modp, srv_cb, data); -: 127: } -: 128: } -: 129:}