00001 /* Copyright 2000-2005 The Apache Software Foundation or its licensors, as 00002 * applicable. 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 00017 #include "apr_buckets.h" 00018 00019 APU_DECLARE_NONSTD(apr_status_t) apr_bucket_shared_split(apr_bucket *a, 00020 apr_size_t point) 00021 { 00022 apr_bucket_refcount *r = a->data; 00023 apr_status_t rv; 00024 00025 if ((rv = apr_bucket_simple_split(a, point)) != APR_SUCCESS) { 00026 return rv; 00027 } 00028 r->refcount++; 00029 00030 return APR_SUCCESS; 00031 } 00032 00033 APU_DECLARE_NONSTD(apr_status_t) apr_bucket_shared_copy(apr_bucket *a, 00034 apr_bucket **b) 00035 { 00036 apr_bucket_refcount *r = a->data; 00037 00038 apr_bucket_simple_copy(a, b); 00039 r->refcount++; 00040 00041 return APR_SUCCESS; 00042 } 00043 00044 APU_DECLARE(int) apr_bucket_shared_destroy(void *data) 00045 { 00046 apr_bucket_refcount *r = data; 00047 r->refcount--; 00048 return (r->refcount == 0); 00049 } 00050 00051 APU_DECLARE(apr_bucket *) apr_bucket_shared_make(apr_bucket *b, void *data, 00052 apr_off_t start, 00053 apr_size_t length) 00054 { 00055 apr_bucket_refcount *r = data; 00056 00057 b->data = r; 00058 b->start = start; 00059 b->length = length; 00060 /* caller initializes the type field */ 00061 r->refcount = 1; 00062 00063 return b; 00064 }