Commit 5c1e5078 authored by William A. Rowe Jr's avatar William A. Rowe Jr
Browse files

  Accomodate the change to the apr_read_dir() arguments, and change all
  apr_dirfoo() and apr_foodir() commands to apr_dir_foo() to match the
  earlier-renamed apr_dir_open().


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@87790 13f79535-47bb-0310-9956-ffa450edef68
parent 89473e52
Loading
Loading
Loading
Loading
+13 −11
Original line number Diff line number Diff line
@@ -1315,6 +1315,7 @@ static dav_error * dav_fs_walker(dav_fs_walker_context *fsctx, int depth)
    apr_pool_t *pool = params->pool;
    dav_error *err = NULL;
    int isdir = fsctx->res1.collection;
    apr_finfo_t dirent;
    apr_dir_t *dirp;

    /* ensure the context is prepared properly, then call the func */
@@ -1357,15 +1358,14 @@ static dav_error * dav_fs_walker(dav_fs_walker_context *fsctx, int depth)
	/* ### need a better error */
	return dav_new_error(pool, HTTP_NOT_FOUND, 0, NULL);
    }
    while ((apr_readdir(dirp)) == APR_SUCCESS) {
	const char *name;
    while ((apr_dir_read(&dirent, APR_FINFO_DIRENT, dirp)) == APR_SUCCESS) {
	apr_size_t len;

	apr_get_dir_filename(&name, dirp);
	len = strlen(name);
	len = strlen(dirent.name);

	/* avoid recursing into our current, parent, or state directories */
	if (name[0] == '.' && (len == 1 || (name[1] == '.' && len == 2))) {
	if (dirent.name[0] == '.' 
              && (len == 1 || (dirent.name[1] == '.' && len == 2))) {
	    continue;
	}

@@ -1374,19 +1374,21 @@ static dav_error * dav_fs_walker(dav_fs_walker_context *fsctx, int depth)
	    /* ### example: .htaccess is normally configured to fail auth */

	    /* stuff in the state directory is never authorized! */
	    if (!strcmp(name, DAV_FS_STATE_DIR)) {
	    if (!strcmp(dirent.name, DAV_FS_STATE_DIR)) {
		continue;
	    }
	}
	/* skip the state dir unless a HIDDEN is performed */
	if (!(params->walk_type & DAV_WALKTYPE_HIDDEN)
	    && !strcmp(name, DAV_FS_STATE_DIR)) {
	    && !strcmp(dirent.name, DAV_FS_STATE_DIR)) {
	    continue;
	}

	/* append this file onto the path buffer (copy null term) */
	dav_buffer_place_mem(pool, &fsctx->path1, name, len + 1, 0);
	dav_buffer_place_mem(pool, &fsctx->path1, dirent.name, len + 1, 0);


        /* ### Optimize me, dirent can give us what we need! */
        if (apr_lstat(&fsctx->info1.finfo, fsctx->path1.buf, 
                      APR_FINFO_NORM, pool) != APR_SUCCESS) {
	    /* woah! where'd it go? */
@@ -1397,11 +1399,11 @@ static dav_error * dav_fs_walker(dav_fs_walker_context *fsctx, int depth)

	/* copy the file to the URI, too. NOTE: we will pad an extra byte
	   for the trailing slash later. */
	dav_buffer_place_mem(pool, &fsctx->uri_buf, name, len + 1, 1);
	dav_buffer_place_mem(pool, &fsctx->uri_buf, dirent.name, len + 1, 1);

	/* if there is a secondary path, then do that, too */
	if (fsctx->path2.buf != NULL) {
	    dav_buffer_place_mem(pool, &fsctx->path2, name, len + 1, 0);
	    dav_buffer_place_mem(pool, &fsctx->path2, dirent.name, len + 1, 0);
	}

	/* set up the (internal) pathnames for the two resources */
@@ -1458,7 +1460,7 @@ static dav_error * dav_fs_walker(dav_fs_walker_context *fsctx, int depth)
    }

    /* ### check the return value of this? */
    apr_closedir(dirp);
    apr_dir_close(dirp);

    if (err != NULL)
	return err;
+7 −9
Original line number Diff line number Diff line
@@ -1540,8 +1540,8 @@ static int index_directory(request_rec *r,
    char *title_name = ap_escape_html(r->pool, r->uri);
    char *title_endp;
    char *name = r->filename;

    apr_dir_t *d;
    apr_finfo_t dirent;
    apr_dir_t *thedir;
    apr_status_t status;
    int num_ent = 0, x;
    struct ent *head, *p;
@@ -1551,7 +1551,7 @@ static int index_directory(request_rec *r,
    char keyid;
    char direction;

    if ((status = apr_dir_open(&d, name, r->pool)) != APR_SUCCESS) {
    if ((status = apr_dir_open(&thedir, name, r->pool)) != APR_SUCCESS) {
	ap_log_rerror(APLOG_MARK, APLOG_ERR, status, r,
		    "Can't open directory for index: %s", r->filename);
	return HTTP_FORBIDDEN;
@@ -1569,7 +1569,7 @@ static int index_directory(request_rec *r,
    ap_send_http_header(r);

    if (r->header_only) {
	apr_closedir(d);
	apr_dir_close(thedir);
	return 0;
    }

@@ -1621,10 +1621,8 @@ static int index_directory(request_rec *r,
     * linked list and then arrayificate them so qsort can use them. 
     */
    head = NULL;
    while (apr_readdir(d) == APR_SUCCESS) {
        const char *d_name;
        apr_get_dir_filename(&d_name, d);
	p = make_autoindex_entry(d_name, autoindex_opts,
    while (apr_dir_read(&dirent, APR_FINFO_DIRENT, thedir) == APR_SUCCESS) {
	p = make_autoindex_entry(dirent.name, autoindex_opts,
				 autoindex_conf, r, keyid, direction);
	if (p != NULL) {
	    p->next = head;
@@ -1647,7 +1645,7 @@ static int index_directory(request_rec *r,
    }
    output_directories(ar, num_ent, autoindex_conf, r, autoindex_opts, keyid,
		       direction);
    apr_closedir(d);
    apr_dir_close(thedir);

    if (autoindex_opts & FANCY_INDEXING) {
	ap_rputs("<HR>\n", r);
+9 −11
Original line number Diff line number Diff line
@@ -912,6 +912,7 @@ static int read_types_multi(negotiation_state *neg)
    char *filp;
    int prefix_len;
    apr_dir_t *dirp;
    apr_finfo_t dirent;
    apr_status_t status;
    struct var_rec mime_info;
    struct accept_rec accept_info;
@@ -936,17 +937,14 @@ static int read_types_multi(negotiation_state *neg)
        return HTTP_FORBIDDEN;
    }

    while (apr_readdir(dirp) == APR_SUCCESS) {
    while (apr_dir_read(&dirent, APR_FINFO_DIRENT, dirp) == APR_SUCCESS) {
        request_rec *sub_req;
        const char *d_name;
        
        apr_get_dir_filename(&d_name, dirp);
        /* Do we have a match? */

        if (strncmp(d_name, filp, prefix_len)) {
        if (strncmp(dirent.name, filp, prefix_len)) {
            continue;
        }
        if (d_name[prefix_len] != '.') {
        if (dirent.name[prefix_len] != '.') {
            continue;
        }

@@ -955,7 +953,7 @@ static int read_types_multi(negotiation_state *neg)
         * which we'll be slapping default_type on later).
         */

        sub_req = ap_sub_req_lookup_file(d_name, r, NULL);
        sub_req = ap_sub_req_lookup_file(dirent.name, r, NULL);

        /* If it has a handler, we'll pretend it's a CGI script,
         * since that's a good indication of the sort of thing it
@@ -979,7 +977,7 @@ static int read_types_multi(negotiation_state *neg)
            ((sub_req->handler) &&
             !strcmp(sub_req->handler, "type-map"))) {

            apr_closedir(dirp);
            apr_dir_close(dirp);
            neg->avail_vars->nelts = 0;
            if (sub_req->status != HTTP_OK) {
                return sub_req->status;
@@ -990,7 +988,7 @@ static int read_types_multi(negotiation_state *neg)
        /* Have reasonable variant --- gather notes. */

        mime_info.sub_req = sub_req;
        mime_info.file_name = apr_pstrdup(neg->pool, d_name);
        mime_info.file_name = apr_pstrdup(neg->pool, dirent.name);
        if (sub_req->content_encoding) {
            mime_info.content_encoding = sub_req->content_encoding;
        }
@@ -1009,7 +1007,7 @@ static int read_types_multi(negotiation_state *neg)
        clean_var_rec(&mime_info);
    }

    apr_closedir(dirp);
    apr_dir_close(dirp);

    set_vlist_validator(r, r);

+13 −14
Original line number Diff line number Diff line
@@ -237,7 +237,7 @@ static int check_speling(request_rec *r)
{
    spconfig *cfg;
    char *good, *bad, *postgood, *url;
    const char *fname;
    apr_finfo_t dirent;
    int filoc, dotloc, urlen, pglen;
    apr_array_header_t *candidates = NULL;
    apr_dir_t          *dir;
@@ -310,8 +310,7 @@ static int check_speling(request_rec *r)
        dotloc = strlen(bad);
    }

    while (apr_readdir(dir) == APR_SUCCESS &&
	   apr_get_dir_filename(&fname, dir) == APR_SUCCESS) {
    while (apr_dir_read(&dirent, APR_FINFO_DIRENT, dir) == APR_SUCCESS) {
        sp_reason q;

        /*
@@ -319,8 +318,8 @@ static int check_speling(request_rec *r)
         * requested one, we must have found a broken symlink or some such.
         * Do _not_ try to redirect this, it causes a loop!
         */
        if (strcmp(bad, fname) == 0) {
            apr_closedir(dir);
        if (strcmp(bad, dirent.name) == 0) {
            apr_dir_close(dir);
            return OK;
        }

@@ -328,11 +327,11 @@ static int check_speling(request_rec *r)
         * miscapitalization errors are checked first (like, e.g., lower case
         * file, upper case request)
         */
        else if (strcasecmp(bad, fname) == 0) {
        else if (strcasecmp(bad, dirent.name) == 0) {
            misspelled_file *sp_new;

	    sp_new = (misspelled_file *) apr_push_array(candidates);
            sp_new->name = apr_pstrdup(r->pool, fname);
            sp_new->name = apr_pstrdup(r->pool, dirent.name);
            sp_new->quality = SP_MISCAPITALIZED;
        }

@@ -340,11 +339,11 @@ static int check_speling(request_rec *r)
         * simple typing errors are checked next (like, e.g.,
         * missing/extra/transposed char)
         */
        else if ((q = spdist(bad, fname)) != SP_VERYDIFFERENT) {
        else if ((q = spdist(bad, dirent.name)) != SP_VERYDIFFERENT) {
            misspelled_file *sp_new;

	    sp_new = (misspelled_file *) apr_push_array(candidates);
            sp_new->name = apr_pstrdup(r->pool, fname);
            sp_new->name = apr_pstrdup(r->pool, dirent.name);
            sp_new->quality = q;
        }

@@ -380,23 +379,23 @@ static int check_speling(request_rec *r)
             * (e.g. foo.gif and foo.html) This code will pick the first one
             * it finds. Better than a Not Found, though.
             */
            int entloc = ap_ind(fname, '.');
            int entloc = ap_ind(dirent.name, '.');
            if (entloc == -1) {
                entloc = strlen(fname);
                entloc = strlen(dirent.name);
	    }

            if ((dotloc == entloc)
                && !strncasecmp(bad, fname, dotloc)) {
                && !strncasecmp(bad, dirent.name, dotloc)) {
                misspelled_file *sp_new;

		sp_new = (misspelled_file *) apr_push_array(candidates);
                sp_new->name = apr_pstrdup(r->pool, fname);
                sp_new->name = apr_pstrdup(r->pool, dirent.name);
                sp_new->quality = SP_VERYDIFFERENT;
            }
#endif
        }
    }
    apr_closedir(dir);
    apr_dir_close(dir);

    if (candidates->nelts != 0) {
        /* Wow... we found us a mispelling. Construct a fixed url */
+7 −8
Original line number Diff line number Diff line
@@ -1280,6 +1280,7 @@ void ap_process_resource_config(server_rec *s, const char *fname,
     */
    if (ap_is_rdirectory(ptemp, fname)) {
        apr_dir_t *dirp;
        apr_finfo_t dirent;
	int current;
	apr_array_header_t *candidates = NULL;
	fnames *fnew;
@@ -1300,17 +1301,15 @@ void ap_process_resource_config(server_rec *s, const char *fname,
	    exit(1);
	}
	candidates = apr_make_array(p, 1, sizeof(fnames));
        while (apr_readdir(dirp) == APR_SUCCESS) {
            const char *d_name;
	    apr_get_dir_filename(&d_name, dirp);
        while (apr_dir_read(&dirent, APR_FINFO_DIRENT, dirp) == APR_SUCCESS) {
            /* strip out '.' and '..' */
	    if (strcmp(d_name, ".") &&
		strcmp(d_name, "..")) {
	    if (strcmp(dirent.name, ".") &&
		strcmp(dirent.name, "..")) {
		fnew = (fnames *) apr_push_array(candidates);
		fnew->fname = ap_make_full_path(p, fname, d_name);
		fnew->fname = ap_make_full_path(p, fname, dirent.name);
	    }
	}
	apr_closedir(dirp);
	apr_dir_close(dirp);
	if (candidates->nelts != 0) {
            qsort((void *) candidates->elts, candidates->nelts,
              sizeof(fnames), fname_alphasort);