MCPcopy Create free account
hub / github.com/apache/httpd / ap_if_walk_sub

Function ap_if_walk_sub

server/request.c:1852–1990  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1850}
1851
1852static int ap_if_walk_sub(request_rec *r, core_dir_config* dconf)
1853{
1854 ap_conf_vector_t *now_merged = NULL;
1855 ap_conf_vector_t **sec_ent = NULL;
1856 int num_sec = 0;
1857 walk_cache_t *cache;
1858 int cached;
1859 int sec_idx;
1860 int matches;
1861 int cached_matches;
1862 int prev_result = -1;
1863 walk_walked_t *last_walk;
1864
1865 if (dconf && dconf->sec_if) {
1866 sec_ent = (ap_conf_vector_t **)dconf->sec_if->elts;
1867 num_sec = dconf->sec_if->nelts;
1868 }
1869
1870 /* No tricks here, there are just no <If > to parse in this context.
1871 * We won't destroy the cache, just in case _this_ redirect is later
1872 * redirected again to a context containing the same or similar <If >.
1873 */
1874 if (!num_sec) {
1875 return OK;
1876 }
1877
1878 cache = prep_walk_cache(AP_NOTE_IF_WALK, r);
1879 cached = (cache->cached != NULL);
1880 cache->cached = (void *)1;
1881 matches = cache->walked->nelts;
1882 cached_matches = matches;
1883 last_walk = (walk_walked_t*)cache->walked->elts;
1884
1885 cached &= auth_internal_per_conf;
1886
1887 /* Go through the if entries, and check for matches */
1888 for (sec_idx = 0; sec_idx < num_sec; ++sec_idx) {
1889 const char *err = NULL;
1890 core_dir_config *entry_core;
1891 int rc;
1892 entry_core = ap_get_core_module_config(sec_ent[sec_idx]);
1893
1894 AP_DEBUG_ASSERT(entry_core->condition_ifelse != 0);
1895 if (entry_core->condition_ifelse & AP_CONDITION_ELSE) {
1896 AP_DEBUG_ASSERT(prev_result != -1);
1897 if (prev_result == 1)
1898 continue;
1899 }
1900
1901 if (entry_core->condition_ifelse & AP_CONDITION_IF) {
1902 rc = ap_expr_exec(r, entry_core->condition, &err);
1903 if (rc <= 0) {
1904 if (rc < 0)
1905 ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(00039)
1906 "Failed to evaluate <If > condition: %s",
1907 err);
1908 prev_result = 0;
1909 continue;

Callers 1

ap_if_walkFunction · 0.85

Calls 4

prep_walk_cacheFunction · 0.85
ap_expr_execFunction · 0.85
ap_merge_per_dir_configsFunction · 0.85

Tested by

no test coverage detected