1
/* Copyright 2001-2004 The Apache Software Foundation
3
* Licensed under the Apache License, Version 2.0 (the "License");
4
* you may not use this file except in compliance with the License.
5
* You may obtain a copy of the License at
7
* http://www.apache.org/licenses/LICENSE-2.0
9
* Unless required by applicable law or agreed to in writing, software
10
* distributed under the License is distributed on an "AS IS" BASIS,
11
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
* See the License for the specific language governing permissions and
13
* limitations under the License.
2
17
apr_bucket_brigade *mpxs_apr_brigade_create(pTHX_ SV *CLASS,
67
82
return APR_BRIGADE_EMPTY(brigade);
86
apr_pool_t *mpxs_APR__Brigade_pool(apr_bucket_brigade *brigade)
88
/* eesh, it's r->pool, and c->pool, but bb->p
89
* let's make Perl consistent, otherwise this could be autogenerated
96
SV *mpxs_APR__Brigade_length(pTHX_ apr_bucket_brigade *bb,
101
apr_status_t rv = apr_brigade_length(bb, read_all, &length);
103
/* XXX - we're deviating from the API here a bit in order to
104
* make it more perlish - returning the length instead of
105
* the return code. maybe that's not such a good idea, though...
107
if (rv == APR_SUCCESS) {
108
return newSViv((int)length);
114
#define mp_xs_sv2_bb mp_xs_sv2_APR__Brigade
117
SV *mpxs_APR__Brigade_flatten(pTHX_ I32 items,
121
apr_bucket_brigade *bb;
126
mpxs_usage_va_1(bb, "$bb->flatten([$length])");
129
/* APR::Brigade->flatten($length); */
130
length = SvIV(*MARK);
133
/* APR::Brigade->flatten(); */
134
/* can't use pflatten, because we can't realloc() memory
135
* allocated by pflatten. and we need to append '\0' to it in
136
* SvPVX. so we copy pflatten's guts here.
139
apr_brigade_length(bb, 1, &actual);
140
length = (apr_size_t)actual;
144
mpxs_sv_grow(data, length);
146
status = apr_brigade_flatten(bb, SvPVX(data), &length);
147
if (status != APR_SUCCESS) {
149
* note that reading from an empty brigade will return
150
* an empty string, not undef, so there is a difference
155
mpxs_sv_cur_set(data, length);