Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 139451 | Differences between
and this patch

Collapse All | Expand All

(-)httpd-2.2.6-r2.orig/modules/mappers/mod_dir.c (-5 / +78 lines)
Lines 39-57 Link Here
39
39
40
typedef struct dir_config_struct {
40
typedef struct dir_config_struct {
41
    apr_array_header_t *index_names;
41
    apr_array_header_t *index_names;
42
    apr_array_header_t *index_names_base;
43
    apr_array_header_t *index_names_incr;
42
    slash_cfg do_slash;
44
    slash_cfg do_slash;
43
} dir_config_rec;
45
} dir_config_rec;
44
46
45
#define DIR_CMD_PERMS OR_INDEXES
47
#define DIR_CMD_PERMS OR_INDEXES
46
48
49
static void update_index(dir_config_rec *d, apr_pool_t *p)
50
{
51
    if ((!d->index_names_base) && (!d->index_names_incr))
52
    {
53
        if (d->index_names)
54
        {
55
            // clear old entries
56
            while (apr_array_pop(d->index_names))
57
                ;
58
            // I think it should be freed, but I don't know how
59
            d->index_names = NULL;
60
        }
61
62
        return;
63
    }
64
65
    if (d->index_names)
66
        // clear old entries
67
        while (apr_array_pop(d->index_names))
68
            ;
69
    else
70
        // allocate
71
        d->index_names = apr_array_make(p, 2, sizeof(char *));
72
73
    if (d->index_names_base)
74
        apr_array_cat(d->index_names, d->index_names_base);
75
76
    if (d->index_names_incr)
77
        apr_array_cat(d->index_names, d->index_names_incr);
78
}
79
47
static const char *add_index(cmd_parms *cmd, void *dummy, const char *arg)
80
static const char *add_index(cmd_parms *cmd, void *dummy, const char *arg)
48
{
81
{
49
    dir_config_rec *d = dummy;
82
    dir_config_rec *d = dummy;
50
83
51
    if (!d->index_names) {
84
    if (!d->index_names_base) {
52
        d->index_names = apr_array_make(cmd->pool, 2, sizeof(char *));
85
        d->index_names_base = apr_array_make(cmd->pool, 2, sizeof(char *));
53
    }
86
    }
54
    *(const char **)apr_array_push(d->index_names) = arg;
87
    *(const char **)apr_array_push(d->index_names_base) = arg;
88
89
    update_index(d, cmd->pool);
90
91
    return NULL;
92
}
93
94
static const char *add_index_incr(cmd_parms *cmd, void *dummy, const char *arg)
95
{
96
    dir_config_rec *d = dummy;
97
98
    if (!d->index_names_incr) {
99
        d->index_names_incr = apr_array_make(cmd->pool, 2, sizeof(char *));
100
    }
101
    *(const char **)apr_array_push(d->index_names_incr) = arg;
102
103
    update_index(d, cmd->pool);
104
55
    return NULL;
105
    return NULL;
56
}
106
}
57
107
Lines 67-72 Link Here
67
{
117
{
68
    AP_INIT_ITERATE("DirectoryIndex", add_index, NULL, DIR_CMD_PERMS,
118
    AP_INIT_ITERATE("DirectoryIndex", add_index, NULL, DIR_CMD_PERMS,
69
                    "a list of file names"),
119
                    "a list of file names"),
120
    AP_INIT_ITERATE("AddDirectoryIndex", add_index_incr, NULL, DIR_CMD_PERMS,
121
                    "a list of file names"),
70
    AP_INIT_FLAG("DirectorySlash", configure_slash, NULL, DIR_CMD_PERMS,
122
    AP_INIT_FLAG("DirectorySlash", configure_slash, NULL, DIR_CMD_PERMS,
71
                 "On or Off"),
123
                 "On or Off"),
72
    {NULL}
124
    {NULL}
Lines 77-93 Link Here
77
    dir_config_rec *new = apr_pcalloc(p, sizeof(dir_config_rec));
129
    dir_config_rec *new = apr_pcalloc(p, sizeof(dir_config_rec));
78
130
79
    new->index_names = NULL;
131
    new->index_names = NULL;
132
    new->index_names_base = NULL;
133
    new->index_names_incr = NULL;
80
    new->do_slash = SLASH_UNSET;
134
    new->do_slash = SLASH_UNSET;
81
    return (void *) new;
135
    return (void *) new;
82
}
136
}
83
137
84
static void *merge_dir_configs(apr_pool_t *p, void *basev, void *addv)
138
static void *merge_dir_configs(apr_pool_t *p, void *basev, void *addv)
85
{
139
{
86
    dir_config_rec *new = apr_pcalloc(p, sizeof(dir_config_rec));
140
    dir_config_rec *new = (dir_config_rec *)create_dir_config(p, NULL);
87
    dir_config_rec *base = (dir_config_rec *)basev;
141
    dir_config_rec *base = (dir_config_rec *)basev;
88
    dir_config_rec *add = (dir_config_rec *)addv;
142
    dir_config_rec *add = (dir_config_rec *)addv;
89
143
90
    new->index_names = add->index_names ? add->index_names : base->index_names;
144
    if (add->index_names_base)
145
        new->index_names_base = add->index_names_base;
146
    else
147
        new->index_names_base = base->index_names_base;
148
149
    if ((!add->index_names_base) && base->index_names_incr)
150
    {
151
        new->index_names_incr = apr_array_make(p, 2, sizeof(char *));
152
        apr_array_cat(new->index_names_incr, base->index_names_incr);
153
    }
154
155
    if (add->index_names_incr)
156
    {
157
        if (!new->index_names_incr)
158
            new->index_names_incr = apr_array_make(p, 2, sizeof(char *));
159
        apr_array_cat(new->index_names_incr, add->index_names_incr);
160
    }
161
162
    update_index(new, p);
163
91
    new->do_slash =
164
    new->do_slash =
92
        (add->do_slash == SLASH_UNSET) ? base->do_slash : add->do_slash;
165
        (add->do_slash == SLASH_UNSET) ? base->do_slash : add->do_slash;
93
    return new;
166
    return new;

Return to bug 139451