* initialize the module */
| 2357 | * initialize the module |
| 2358 | */ |
| 2359 | static int magic_init(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp, server_rec *main_server) |
| 2360 | { |
| 2361 | int result; |
| 2362 | magic_server_config_rec *conf; |
| 2363 | magic_server_config_rec *main_conf; |
| 2364 | server_rec *s; |
| 2365 | #if MIME_MAGIC_DEBUG |
| 2366 | struct magic *m, *prevm; |
| 2367 | #endif /* MIME_MAGIC_DEBUG */ |
| 2368 | |
| 2369 | main_conf = ap_get_module_config(main_server->module_config, &mime_magic_module); |
| 2370 | for (s = main_server; s; s = s->next) { |
| 2371 | conf = ap_get_module_config(s->module_config, &mime_magic_module); |
| 2372 | if (conf->magicfile == NULL && s != main_server) { |
| 2373 | /* inherits from the parent */ |
| 2374 | *conf = *main_conf; |
| 2375 | } |
| 2376 | else if (conf->magicfile) { |
| 2377 | result = apprentice(s, p); |
| 2378 | if (result == -1) |
| 2379 | return OK; |
| 2380 | #if MIME_MAGIC_DEBUG |
| 2381 | prevm = 0; |
| 2382 | ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s, APLOGNO(01558) |
| 2383 | MODNAME ": magic_init 1 test"); |
| 2384 | for (m = conf->magic; m; m = m->next) { |
| 2385 | if (apr_isprint((((unsigned long) m) >> 24) & 255) && |
| 2386 | apr_isprint((((unsigned long) m) >> 16) & 255) && |
| 2387 | apr_isprint((((unsigned long) m) >> 8) & 255) && |
| 2388 | apr_isprint(((unsigned long) m) & 255)) { |
| 2389 | ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s, APLOGNO(01559) |
| 2390 | MODNAME ": magic_init 1: POINTER CLOBBERED! " |
| 2391 | "m=\"%c%c%c%c\" line=%d", |
| 2392 | (((unsigned long) m) >> 24) & 255, |
| 2393 | (((unsigned long) m) >> 16) & 255, |
| 2394 | (((unsigned long) m) >> 8) & 255, |
| 2395 | ((unsigned long) m) & 255, |
| 2396 | prevm ? prevm->lineno : -1); |
| 2397 | break; |
| 2398 | } |
| 2399 | prevm = m; |
| 2400 | } |
| 2401 | #endif |
| 2402 | } |
| 2403 | } |
| 2404 | return OK; |
| 2405 | } |
| 2406 | |
| 2407 | /* |
| 2408 | * Find the Content-Type from any resource this module has available |
nothing calls this directly
no test coverage detected