アットウィキロゴ

httpd-2.0.63_server_config.c_ap_process_resource_config

source

config.c

line

1530 - 1627

function


  1530 AP_DECLARE(void) ap_process_resource_config(server_rec *s, const char *fname,
  1531                                             ap_directive_t **conftree,
  1532                                             apr_pool_t *p,
  1533                                             apr_pool_t *ptemp)
  1534 {
  1535     /* XXX: lstat() won't work on the wildcard pattern...
  1536      */
  1537
  1538     /* don't require conf/httpd.conf if we have a -C or -c switch */
  1539     if ((ap_server_pre_read_config->nelts
  1540         || ap_server_post_read_config->nelts)
  1541         && !(strcmp(fname, ap_server_root_relative(p, SERVER_CONFIG_FILE)))) {
  1542         apr_finfo_t finfo;
  1543
  1544         if (apr_lstat(&finfo, fname, APR_FINFO_TYPE, p) != APR_SUCCESS)
  1545             return;
  1546     }
  1547
  1548     if (!apr_fnmatch_test(fname)) {
  1549         process_resource_config_nofnmatch(s, fname, conftree, p, ptemp, 0);
  1550     }
  1551     else {
  1552         apr_dir_t *dirp;
  1553         apr_finfo_t dirent;
  1554         int current;
  1555         apr_array_header_t *candidates = NULL;
  1556         fnames *fnew;
  1557         apr_status_t rv;
  1558         char errmsg[120], *path = apr_pstrdup(p, fname), *pattern = NULL;
  1559
  1560         pattern = ap_strrchr(path, '/');
  1561
  1562         AP_DEBUG_ASSERT(pattern != NULL); /* path must be absolute. */
  1563
  1564         *pattern++ = '\0';
  1565
  1566         if (apr_fnmatch_test(path)) {
  1567             fprintf(stderr, "%s: wildcard patterns not allowed in Include "
  1568                     "%s\n", ap_server_argv0, fname);
  1569             exit(1);
  1570         }
  1571
  1572         if (!ap_is_directory(p, path)){
  1573             fprintf(stderr, "%s: Include directory '%s' not found",
  1574                     ap_server_argv0, path);
  1575             exit(1);
  1576         }
  1577
  1578         if (!apr_fnmatch_test(pattern)) {
  1579             fprintf(stderr, "%s: must include a wildcard pattern "
  1580                     "for Include %s\n", ap_server_argv0, fname);
  1581             exit(1);
  1582         }
  1583
  1584         /*
  1585          * first course of business is to grok all the directory
  1586          * entries here and store 'em away. Recall we need full pathnames
  1587          * for this.
  1588          */
  1589         rv = apr_dir_open(&dirp, path, p);
  1590         if (rv != APR_SUCCESS) {
  1591             fprintf(stderr, "%s: could not open config directory %s: %s\n",
  1592                     ap_server_argv0, path,
  1593                     apr_strerror(rv, errmsg, sizeof errmsg));
  1594             exit(1);
  1595         }
  1596
  1597         candidates = apr_array_make(p, 1, sizeof(fnames));
  1598         while (apr_dir_read(&dirent, APR_FINFO_DIRENT, dirp) == APR_SUCCESS) {
  1599             /* strip out '.' and '..' */
  1600             if (strcmp(dirent.name, ".")
  1601                 && strcmp(dirent.name, "..")
  1602                 && (apr_fnmatch(pattern, dirent.name,
  1603                                 FNM_PERIOD) == APR_SUCCESS)) {
  1604                 fnew = (fnames *) apr_array_push(candidates);
  1605                 fnew->fname = ap_make_full_path(p, path, dirent.name);
  1606             }
  1607         }
  1608
  1609         apr_dir_close(dirp);
  1610         if (candidates->nelts != 0) {
  1611             qsort((void *) candidates->elts, candidates->nelts,
  1612                   sizeof(fnames), fname_alphasort);
  1613
  1614             /*
  1615              * Now recurse these... we handle errors and subdirectories
  1616              * via the recursion, which is nice
  1617              */
  1618             for (current = 0; current < candidates->nelts; ++current) {
  1619                 fnew = &((fnames *) candidates->elts)[current];
  1620                 process_resource_config_nofnmatch(s, fnew->fname, conftree, p,
  1621                                                   ptemp, 0);
  1622             }
  1623         }
  1624     }
  1625
  1626     return;
  1627 }
最終更新:2009年02月08日 16:51
ツールボックス

下から選んでください:

新しいページを作成する
ヘルプ / FAQ もご覧ください。