Skip to content
This repository was archived by the owner on Apr 12, 2022. It is now read-only.

Commit e3341a5

Browse files
author
shugo
committed
supported Apache 2.2. Thanks, Michael Sullivan.
1 parent 7d691e0 commit e3341a5

13 files changed

+349
-276
lines changed

apache_cookie.c

+14-14
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ char *ApacheCookie_expires(ApacheCookie *c, char *time_str)
2929

3030
#define cookie_get_set(thing,val) \
3131
retval = thing; \
32-
if(val) thing = ap_pstrdup(c->r->pool, val)
32+
if(val) thing = apr_pstrdup(c->r->pool, val)
3333

3434
char *ApacheCookie_attr(ApacheCookie *c, char *key, char *val)
3535
{
@@ -73,11 +73,11 @@ ApacheCookie *ApacheCookie_new(request_rec *r, ...)
7373
va_list args;
7474
ApacheRequest req;
7575
ApacheCookie *c =
76-
ap_pcalloc(r->pool, sizeof(ApacheCookie));
76+
apr_pcalloc(r->pool, sizeof(ApacheCookie));
7777

7878
req.r = r;
7979
c->r = r;
80-
c->values = ap_make_array(r->pool, 1, sizeof(char *));
80+
c->values = apr_array_make(r->pool, 1, sizeof(char *));
8181
c->secure = 0;
8282
c->name = c->expires = NULL;
8383

@@ -103,17 +103,17 @@ ApacheCookieJar *ApacheCookie_parse(request_rec *r, const char *data)
103103
{
104104
const char *pair;
105105
ApacheCookieJar *retval =
106-
ap_make_array(r->pool, 1, sizeof(ApacheCookie *));
106+
apr_array_make(r->pool, 1, sizeof(ApacheCookie *));
107107

108108
if (!data)
109-
if (!(data = ap_table_get(r->headers_in, "Cookie")))
109+
if (!(data = apr_table_get(r->headers_in, "Cookie")))
110110
return retval;
111111

112112
while (*data && (pair = ap_getword(r->pool, &data, ';'))) {
113113
const char *key, *val;
114114
ApacheCookie *c;
115115

116-
while (ap_isspace(*data))
116+
while (apr_isspace(*data))
117117
++data;
118118

119119
key = ap_getword(r->pool, &pair, '=');
@@ -123,7 +123,7 @@ ApacheCookieJar *ApacheCookie_parse(request_rec *r, const char *data)
123123
if (c->values)
124124
c->values->nelts = 0;
125125
else
126-
c->values = ap_make_array(r->pool, 4, sizeof(char *));
126+
c->values = apr_array_make(r->pool, 4, sizeof(char *));
127127

128128
if (!*pair)
129129
ApacheCookieAdd(c, "");
@@ -144,11 +144,11 @@ ApacheCookieJar *ApacheCookie_parse(request_rec *r, const char *data)
144144
}
145145

146146
#define cookie_push_arr(arr, val) \
147-
*(char **)ap_push_array(arr) = (char *)val
147+
*(char **)apr_array_push(arr) = (char *)val
148148

149149
#define cookie_push_named(arr, name, val) \
150150
if(val && strlen(val) > 0) { \
151-
cookie_push_arr(arr, ap_pstrcat(p, name, "=", val, NULL)); \
151+
cookie_push_arr(arr, apr_pstrcat(p, name, "=", val, NULL)); \
152152
}
153153

154154
static char * escape_url(pool *p, char *val)
@@ -195,25 +195,25 @@ char *ApacheCookie_as_string(ApacheCookie *c)
195195
if (!c->name)
196196
return "";
197197

198-
values = ap_make_array(p, 6, sizeof(char *));
198+
values = apr_array_make(p, 6, sizeof(char *));
199199
cookie_push_named(values, "domain", c->domain);
200200
cookie_push_named(values, "path", c->path);
201201
cookie_push_named(values, "expires", c->expires);
202202
if (c->secure) {
203203
cookie_push_arr(values, "secure");
204204
}
205205

206-
cookie = ap_pstrcat(p, escape_url(p, c->name), "=", NULL);
206+
cookie = apr_pstrcat(p, escape_url(p, c->name), "=", NULL);
207207
for (i=0; i<c->values->nelts; i++) {
208-
cookie = ap_pstrcat(p, cookie,
208+
cookie = apr_pstrcat(p, cookie,
209209
escape_url(p, ((char**)c->values->elts)[i]),
210210
(i < (c->values->nelts -1) ? "&" : NULL),
211211
NULL);
212212
}
213213

214214
retval = cookie;
215215
for (i=0; i<values->nelts; i++) {
216-
retval = ap_pstrcat(p, retval, "; ",
216+
retval = apr_pstrcat(p, retval, "; ",
217217
((char**)values->elts)[i], NULL);
218218
}
219219

@@ -222,6 +222,6 @@ char *ApacheCookie_as_string(ApacheCookie *c)
222222

223223
void ApacheCookie_bake(ApacheCookie *c)
224224
{
225-
ap_table_add(c->r->err_headers_out, "Set-Cookie",
225+
apr_table_add(c->r->err_headers_out, "Set-Cookie",
226226
ApacheCookie_as_string(c));
227227
}

apache_cookie.h

+21
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,29 @@ typedef struct {
4141
#define ApacheCookieJarFetch(arr,i) \
4242
((ApacheCookie *)(((ApacheCookie **)arr->elts)[i]))
4343

44+
#ifdef APACHE2
45+
#define ApacheCookieJarAdd(arr,c) \
46+
*(ApacheCookie **)apr_array_push(arr) = c
47+
#else /* Apache 1.x */
4448
#define ApacheCookieJarAdd(arr,c) \
4549
*(ApacheCookie **)ap_push_array(arr) = c
50+
#endif
4651

4752
#define ApacheCookieItems(c) c->values->nelts
4853

4954
#define ApacheCookieFetch(c,i) \
5055
((char *)(((char **)c->values->elts)[i]))
5156

57+
#ifdef APACHE2
58+
#define ApacheCookieAddn(c,val) \
59+
if(val) *(char **)apr_array_push(c->values) = (char *)val
60+
61+
#define ApacheCookieAdd(c,val) \
62+
ApacheCookieAddn(c, apr_pstrdup(c->r->pool, val))
63+
64+
#define ApacheCookieAddLen(c,val,len) \
65+
ApacheCookieAddn(c, apr_pstrndup(c->r->pool, val, len))
66+
#else /* Apache 1.x */
5267
#define ApacheCookieAddn(c,val) \
5368
if(val) *(char **)ap_push_array(c->values) = (char *)val
5469

@@ -57,6 +72,12 @@ typedef struct {
5772

5873
#define ApacheCookieAddLen(c,val,len) \
5974
ApacheCookieAddn(c, ap_pstrndup(c->r->pool, val, len))
75+
#endif
76+
77+
78+
#ifdef APACHE2
79+
#else
80+
#endif
6081

6182
ApacheCookie *ApacheCookie_new(request_rec *r, ...);
6283
ApacheCookieJar *ApacheCookie_parse(request_rec *r, const char *data);

apache_multipart_buffer.c

+9-9
Original file line numberDiff line numberDiff line change
@@ -172,17 +172,17 @@ static int find_boundary(multipart_buffer *self, char *boundary)
172172
multipart_buffer *multipart_buffer_new(char *boundary, long length, request_rec *r)
173173
{
174174
multipart_buffer *self = (multipart_buffer *)
175-
ap_pcalloc(r->pool, sizeof(multipart_buffer));
175+
apr_pcalloc(r->pool, sizeof(multipart_buffer));
176176

177177
int minsize = strlen(boundary)+6;
178178
if(minsize < FILLUNIT) minsize = FILLUNIT;
179179

180180
self->r = r;
181-
self->buffer = (char *) ap_pcalloc(r->pool, minsize+1);
181+
self->buffer = (char *) apr_pcalloc(r->pool, minsize+1);
182182
self->bufsize = minsize;
183183
self->request_length = length;
184-
self->boundary = ap_pstrcat(r->pool, "--", boundary, NULL);
185-
self->boundary_next = ap_pstrcat(r->pool, "\n", self->boundary, NULL);
184+
self->boundary = apr_pstrcat(r->pool, "--", boundary, NULL);
185+
self->boundary_next = apr_pstrcat(r->pool, "\n", self->boundary, NULL);
186186
self->buf_begin = self->buffer;
187187
self->bytes_in_buffer = 0;
188188

@@ -199,31 +199,31 @@ table *multipart_buffer_headers(multipart_buffer *self)
199199
if(!find_boundary(self, self->boundary)) return NULL;
200200

201201
/* get lines of text, or CRLF_CRLF */
202-
tab = ap_make_table(self->r->pool, 10);
202+
tab = apr_table_make(self->r->pool, 10);
203203
while( (line = get_line(self)) && strlen(line) > 0 ) {
204204
/* add header to table */
205205
char *key = line;
206206
char *value = strchr(line, ':');
207207

208208
if(value) {
209209
*value = 0;
210-
do { value++; } while(ap_isspace(*value));
210+
do { value++; } while(apr_isspace(*value));
211211

212212
#ifdef DEBUG
213213
ap_log_rerror(MPB_ERROR,
214214
"multipart_buffer_headers: '%s' = '%s'",
215215
key, value);
216216
#endif
217217

218-
ap_table_add(tab, key, value);
218+
apr_table_add(tab, key, value);
219219
}
220220
else {
221221
#ifdef DEBUG
222222
ap_log_rerror(MPB_ERROR,
223223
"multipart_buffer_headers: '%s' = ''", key);
224224
#endif
225225

226-
ap_table_add(tab, key, "");
226+
apr_table_add(tab, key, "");
227227
}
228228
}
229229

@@ -277,7 +277,7 @@ char *multipart_buffer_read_body(multipart_buffer *self)
277277
char buf[FILLUNIT], *out = "";
278278

279279
while(multipart_buffer_read(self, buf, sizeof(buf)))
280-
out = ap_pstrcat(self->r->pool, out, buf, NULL);
280+
out = apr_pstrcat(self->r->pool, out, buf, NULL);
281281

282282
#ifdef DEBUG
283283
ap_log_rerror(MPB_ERROR, "multipart_buffer_read_body: '%s'", out);

0 commit comments

Comments
 (0)