Apache HTTPD
apr_buckets_simple.c
Go to the documentation of this file.
1/* Licensed to the Apache Software Foundation (ASF) under one or more
2 * contributor license agreements. See the NOTICE file distributed with
3 * this work for additional information regarding copyright ownership.
4 * The ASF licenses this file to You under the Apache License, Version 2.0
5 * (the "License"); you may not use this file except in compliance with
6 * the License. You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include "apr_buckets.h"
18
20 apr_bucket **b)
21{
22 *b = apr_bucket_alloc(sizeof(**b), a->list); /* XXX: check for failure? */
23 **b = *a;
24
25 return APR_SUCCESS;
26}
27
30{
32
33 if (point > a->length) {
34 return APR_EINVAL;
35 }
36
38
39 a->length = point;
40 b->length -= point;
41 b->start += point;
42
44
45 return APR_SUCCESS;
46}
47
50{
51 *str = (char *)b->data + b->start;
52 *len = b->length;
53 return APR_SUCCESS;
54}
55
57 const char *buf,
59{
60 b->data = (char *)buf;
61 b->length = length;
62 b->start = 0;
64
65 return b;
66}
67
71{
72 apr_bucket *b = apr_bucket_alloc(sizeof(*b), list);
73
75 b->free = apr_bucket_free;
76 b->list = list;
78}
79
80/*
81 * XXX: This function could do with some tweaking to reduce memory
82 * usage in various cases, e.g. share buffers in the heap between all
83 * the buckets that are set aside, or even spool set-aside data to
84 * disk if it gets too voluminous (but if it does then that's probably
85 * a bug elsewhere). There should probably be a apr_brigade_setaside()
86 * function that co-ordinates the action of all the bucket setaside
87 * functions to improve memory efficiency.
88 */
90{
91 b = apr_bucket_heap_make(b, (char *)b->data + b->start, b->length, NULL);
92 if (b == NULL) {
93 return APR_ENOMEM;
94 }
95 return APR_SUCCESS;
96}
97
99 const char *buf,
101{
102 b->data = (char *)buf;
103 b->length = length;
104 b->start = 0;
106 return b;
107}
108
112{
113 apr_bucket *b = apr_bucket_alloc(sizeof(*b), list);
114
116 b->free = apr_bucket_free;
117 b->list = list;
119}
120
129
const char apr_size_t len
Definition ap_regex.h:187
APR-UTIL Buckets/Bucket Brigades.
static apr_status_t transient_bucket_setaside(apr_bucket *b, apr_pool_t *pool)
static apr_status_t simple_bucket_read(apr_bucket *b, const char **str, apr_size_t *len, apr_read_type_e block)
APU_DECLARE(void)
Computes SipHash-2-4, producing a 64bit (APR_SIPHASH_DSIZE) hash from a message and a 128bit (APR_SIP...
Definition apr_sha1.c:206
const unsigned char * buf
Definition util_md5.h:50
#define APR_ENOMEM
Definition apr_errno.h:683
#define APR_EINVAL
Definition apr_errno.h:711
#define APR_BUCKET_INIT(e)
APU_DECLARE_DATA const apr_bucket_type_t apr_bucket_type_transient
#define APR_BUCKET_INSERT_AFTER(a, b)
apr_read_type_e
Definition apr_buckets.h:57
apr_off_t point
APU_DECLARE_NONSTD(void)
Definition apr_buckets.c:43
apr_bucket apr_bucket_brigade * a
const apr_bucket_type_t apr_bucket_type_immortal
int apr_off_t * length
apr_size_t size
const char int apr_pool_t * pool
Definition apr_cstr.h:84
const apr_array_header_t * list
Definition apr_cstr.h:105
#define APR_SUCCESS
Definition apr_errno.h:225
int apr_status_t
Definition apr_errno.h:44
apr_pool_t * b
Definition apr_pools.h:529
return NULL
Definition mod_so.c:359
apr_size_t length
apr_bucket_alloc_t * list
#define str