diff options
author | (no author) <(no author)@13f79535-47bb-0310-9956-ffa450edef68> | 2000-11-16 00:40:49 +0000 |
---|---|---|
committer | (no author) <(no author)@13f79535-47bb-0310-9956-ffa450edef68> | 2000-11-16 00:40:49 +0000 |
commit | a6adeace9e3f8c6e568bb3d7e29ea634f1e4ca84 (patch) | |
tree | a016846ec13418fe44ba5f1a7fd20d94778ef998 | |
parent | da43eb666e2c04255d0e950047cd1e35cab27975 (diff) | |
download | libapr-util-APACHE_2_0_ALPHA_8.tar.gz |
This commit was manufactured by cvs2svn to create tagAPACHE_2_0_ALPHA_8
'APACHE_2_0_ALPHA_8'.
git-svn-id: http://svn.apache.org/repos/asf/apr/apr-util/tags/APACHE_2_0_ALPHA_8@57922 13f79535-47bb-0310-9956-ffa450edef68
33 files changed, 0 insertions, 6896 deletions
diff --git a/buckets/ap_buckets.c b/buckets/ap_buckets.c deleted file mode 100644 index 892311a2..00000000 --- a/buckets/ap_buckets.c +++ /dev/null @@ -1,245 +0,0 @@ -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2000 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" must - * not be used to endorse or promote products derived from this - * software without prior written permission. For written - * permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * nor may "Apache" appear in their name, without prior written - * permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -#include "httpd.h" -#include "apr_pools.h" -#include "apr_lib.h" -#include "apr_errno.h" -#include <stdlib.h> -#ifdef HAVE_SYS_UIO_H -#include <sys/uio.h> -#endif -#include "ap_buckets.h" - -static apr_array_header_t *bucket_types; - -static apr_status_t ap_brigade_cleanup(void *data) -{ - ap_bucket_brigade *b = data; - ap_bucket *e; - - /* - * Bah! We can't use AP_RING_FOREACH here because this bucket has - * gone away when we dig inside it to get the next one. - */ - while (!AP_BRIGADE_EMPTY(b)) { - e = AP_BRIGADE_FIRST(b); - AP_BUCKET_REMOVE(e); - ap_bucket_destroy(e); - } - /* - * We don't need to free(bb) because it's allocated from a pool. - */ - return APR_SUCCESS; -} -AP_DECLARE(apr_status_t) ap_brigade_destroy(ap_bucket_brigade *b) -{ - apr_kill_cleanup(b->p, b, ap_brigade_cleanup); - return ap_brigade_cleanup(b); -} - -AP_DECLARE(ap_bucket_brigade *) ap_brigade_create(apr_pool_t *p) -{ - ap_bucket_brigade *b; - - b = apr_palloc(p, sizeof(*b)); - b->p = p; - AP_RING_INIT(&b->list, ap_bucket, link); - - apr_register_cleanup(b->p, b, ap_brigade_cleanup, ap_brigade_cleanup); - return b; -} - -AP_DECLARE(ap_bucket_brigade *) ap_brigade_split(ap_bucket_brigade *b, - ap_bucket *e) -{ - ap_bucket_brigade *a; - ap_bucket *f; - - a = ap_brigade_create(b->p); - /* Return an empty brigade if there is nothing left in - * the first brigade to split off - */ - if (e != AP_BRIGADE_SENTINEL(b)) { - f = AP_RING_LAST(&b->list); - AP_RING_UNSPLICE(e, f, link); - AP_RING_SPLICE_HEAD(&a->list, e, f, ap_bucket, link); - } - return a; -} - -AP_DECLARE(int) ap_brigade_to_iovec(ap_bucket_brigade *b, - struct iovec *vec, int nvec) -{ - ap_bucket *e; - struct iovec *orig; - apr_size_t iov_len; - - orig = vec; - AP_BRIGADE_FOREACH(e, b) { - if (nvec-- == 0) - break; - ap_bucket_read(e, (const char **)&vec->iov_base, &iov_len, AP_NONBLOCK_READ); - vec->iov_len = iov_len; /* set indirectly in case size differs */ - ++vec; - } - return vec - orig; -} - -AP_DECLARE(int) ap_brigade_vputstrs(ap_bucket_brigade *b, va_list va) -{ - ap_bucket *r; - const char *x; - int j, k; - apr_size_t i; - - for (k = 0;;) { - x = va_arg(va, const char *); - if (x == NULL) - break; - j = strlen(x); - - /* XXX: copy or not? let the caller decide? */ - r = ap_bucket_create_heap(x, j, 1, &i); - if (i != j) { - /* Do we need better error reporting? */ - return -1; - } - k += i; - - AP_BRIGADE_INSERT_TAIL(b, r); - } - - return k; -} - -AP_DECLARE_NONSTD(int) ap_brigade_putstrs(ap_bucket_brigade *b, ...) -{ - va_list va; - int written; - - va_start(va, b); - written = ap_brigade_vputstrs(b, va); - va_end(va); - return written; -} - -AP_DECLARE_NONSTD(int) ap_brigade_printf(ap_bucket_brigade *b, const char *fmt, ...) -{ - va_list ap; - int res; - - va_start(ap, fmt); - res = ap_brigade_vprintf(b, fmt, ap); - va_end(ap); - return res; -} - -AP_DECLARE(int) ap_brigade_vprintf(ap_bucket_brigade *b, const char *fmt, va_list va) -{ - /* XXX: This needs to be replaced with a function to printf - * directly into a bucket. I'm being lazy right now. RBB - */ - char buf[4096]; - ap_bucket *r; - int res; - - res = apr_vsnprintf(buf, 4096, fmt, va); - - r = ap_bucket_create_heap(buf, strlen(buf), 1, NULL); - AP_BRIGADE_INSERT_TAIL(b, r); - - return res; -} - -void ap_init_bucket_types(apr_pool_t *p) -{ - bucket_types = apr_make_array(p, 8, sizeof(ap_bucket_type)); - - ap_insert_bucket_type(&ap_eos_type); - ap_insert_bucket_type(&ap_file_type); - ap_insert_bucket_type(&ap_heap_type); -#ifdef AP_USE_MMAP_FILES - ap_insert_bucket_type(&ap_mmap_type); -#endif - ap_insert_bucket_type(&ap_pipe_type); - ap_insert_bucket_type(&ap_immortal_type); - ap_insert_bucket_type(&ap_transient_type); - ap_insert_bucket_type(&ap_socket_type); -} - -int ap_insert_bucket_type(const ap_bucket_type *type) -{ - const ap_bucket_type **newone; - - newone = (const ap_bucket_type **)apr_push_array(bucket_types); - newone = &type; - - return bucket_types->nelts - 1; -} - -AP_DECLARE_NONSTD(apr_status_t) ap_bucket_setaside_notimpl(ap_bucket *data) -{ - return APR_ENOTIMPL; -} - -AP_DECLARE_NONSTD(apr_status_t) ap_bucket_split_notimpl(ap_bucket *data, apr_off_t point) -{ - return APR_ENOTIMPL; -} - -AP_DECLARE_NONSTD(void) ap_bucket_destroy_notimpl(void *data) -{ - return; -} diff --git a/buckets/ap_buckets_eos.c b/buckets/ap_buckets_eos.c deleted file mode 100644 index 0502a0e5..00000000 --- a/buckets/ap_buckets_eos.c +++ /dev/null @@ -1,88 +0,0 @@ -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2000 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" must - * not be used to endorse or promote products derived from this - * software without prior written permission. For written - * permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * nor may "Apache" appear in their name, without prior written - * permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -#include "httpd.h" -#include "ap_buckets.h" -#include <stdlib.h> - -static apr_status_t eos_read(ap_bucket *b, const char **str, - apr_size_t *len, ap_read_type block) -{ - *str = NULL; - *len = 0; - return APR_SUCCESS; -} - -AP_DECLARE(ap_bucket *) ap_bucket_make_eos(ap_bucket *b) -{ - b->length = 0; - b->data = NULL; - - b->type = &ap_eos_type; - - return b; -} - -AP_DECLARE(ap_bucket *) ap_bucket_create_eos(void) -{ - ap_bucket_do_create(ap_bucket_make_eos(b)); -} - -const ap_bucket_type ap_eos_type = { - "EOS", 4, - ap_bucket_destroy_notimpl, - eos_read, - ap_bucket_setaside_notimpl, - ap_bucket_split_notimpl -}; diff --git a/buckets/ap_buckets_file.c b/buckets/ap_buckets_file.c deleted file mode 100644 index 782d9352..00000000 --- a/buckets/ap_buckets_file.c +++ /dev/null @@ -1,193 +0,0 @@ -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2000 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" must - * not be used to endorse or promote products derived from this - * software without prior written permission. For written - * permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * nor may "Apache" appear in their name, without prior written - * permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -#include "httpd.h" -#include "ap_buckets.h" -#include <stdlib.h> - -/* Allow Apache to use ap_mmap */ -#ifdef AP_USE_MMAP_FILES -#include "apr_mmap.h" - -/* mmap support for static files based on ideas from John Heidemann's - * patch against 1.0.5. See - * <http://www.isi.edu/~johnh/SOFTWARE/APACHE/index.html>. - */ - -/* Files have to be at least this big before they're mmap()d. This is to deal - * with systems where the expense of doing an mmap() and an munmap() outweighs - * the benefit for small files. It shouldn't be set lower than 1. - */ -#ifndef MMAP_THRESHOLD -# ifdef SUNOS4 -# define MMAP_THRESHOLD (8*1024) -# else -# define MMAP_THRESHOLD 1 -# endif /* SUNOS4 */ -#endif /* MMAP_THRESHOLD */ -#ifndef MMAP_LIMIT -#define MMAP_LIMIT (4*1024*1024) -#endif -#endif /* AP_USE_MMAP_FILES */ - - -/* XXX: We should obey the block flag */ -static apr_status_t file_read(ap_bucket *e, const char **str, - apr_size_t *len, ap_read_type block) -{ - ap_bucket_file *a = (ap_bucket_file *)e->data; - apr_file_t *f = (apr_file_t *) a->fd; - ap_bucket *b = NULL; - char *buf; - apr_status_t rv; -#ifdef AP_USE_MMAP_FILES - apr_mmap_t *mm = NULL; -#endif - -#ifdef AP_USE_MMAP_FILES - if ((e->length >= MMAP_THRESHOLD) - && (e->length < MMAP_LIMIT)) { - /* we need to protect ourselves in case we die while we've got the - * file mmapped */ - apr_status_t status; - if ((status = apr_mmap_create(&mm, f, a->offset, e->length, NULL)) != APR_SUCCESS) { - mm = NULL; - } - } - else { - mm = NULL; - } - if (mm) { - ap_bucket_make_mmap(e, mm, 0, e->length); /*XXX: check for failure? */ - return ap_bucket_read(e, str, len, block); - } - else { -#endif - - buf = malloc(IOBUFSIZE); - *str = buf; - - if (e->length > IOBUFSIZE) { - *len = IOBUFSIZE; - } - else { - *len = e->length; - } - - /* Handle offset ... */ - if (a->offset) { - rv = apr_seek(f, APR_SET, &a->offset); - if (rv != APR_SUCCESS) { - free(buf); - return rv; - } - /* Only need to do seek the first time through */ - a->offset = 0; - } - rv = apr_read(f, buf, len); - if (rv != APR_SUCCESS && rv != APR_EOF) { - free(buf); - return rv; - } - - /* - * Change the current bucket to refer to what we read, - * even if we read nothing because we hit EOF. - */ - ap_bucket_make_heap(e, buf, *len, 0, NULL); /*XXX: check for failure? */ - - /* If we have more to read from the file, then create another bucket */ - if (*len > 0) { - b = ap_bucket_create_file(f, 0, e->length); - AP_BUCKET_INSERT_AFTER(e, b); - } -#ifdef AP_USE_MMAP_FILES - } -#endif - return APR_SUCCESS; -} - -AP_DECLARE(ap_bucket *) ap_bucket_make_file(ap_bucket *b, apr_file_t *fd, - apr_off_t offset, apr_size_t len) -{ - ap_bucket_file *f; - - f = malloc(sizeof(*f)); - if (f == NULL) { - return NULL; - } - - f->fd = fd; - f->offset = offset; - - b->type = &ap_file_type; - b->data = f; - b->length = len; - - return b; -} - -AP_DECLARE(ap_bucket *) ap_bucket_create_file(apr_file_t *fd, - apr_off_t offset, apr_size_t len) -{ - ap_bucket_do_create(ap_bucket_make_file(b, fd, offset, len)); -} - -const ap_bucket_type ap_file_type = { - "FILE", 4, - ap_bucket_destroy_notimpl, - file_read, - ap_bucket_setaside_notimpl, - ap_bucket_split_notimpl -}; diff --git a/buckets/ap_buckets_flush.c b/buckets/ap_buckets_flush.c deleted file mode 100644 index 97f4ac4d..00000000 --- a/buckets/ap_buckets_flush.c +++ /dev/null @@ -1,88 +0,0 @@ -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2000 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" must - * not be used to endorse or promote products derived from this - * software without prior written permission. For written - * permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * nor may "Apache" appear in their name, without prior written - * permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -#include "httpd.h" -#include "ap_buckets.h" -#include <stdlib.h> - -static apr_status_t flush_read(ap_bucket *b, const char **str, - apr_size_t *len, ap_read_type block) -{ - *str = NULL; - *len = 0; - return APR_SUCCESS; -} - -AP_DECLARE(ap_bucket *) ap_bucket_make_flush(ap_bucket *b) -{ - b->length = 0; - b->data = NULL; - - b->type = &ap_flush_type; - - return b; -} - -AP_DECLARE(ap_bucket *) ap_bucket_create_flush(void) -{ - ap_bucket_do_create(ap_bucket_make_flush(b)); -} - -const ap_bucket_type ap_flush_type = { - "FLUSH", 4, - ap_bucket_destroy_notimpl, - flush_read, - ap_bucket_setaside_notimpl, - ap_bucket_split_notimpl -}; diff --git a/buckets/ap_buckets_heap.c b/buckets/ap_buckets_heap.c deleted file mode 100644 index 7813c3ca..00000000 --- a/buckets/ap_buckets_heap.c +++ /dev/null @@ -1,150 +0,0 @@ -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2000 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" must - * not be used to endorse or promote products derived from this - * software without prior written permission. For written - * permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * nor may "Apache" appear in their name, without prior written - * permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -#include "httpd.h" -#include "ap_buckets.h" -#include <stdlib.h> - -/* - * The size of heap bucket memory allocations. - * XXX: This is currently a guess and should be adjusted to an - * empirically good value. - */ -#ifndef DEFAULT_BUCKET_SIZE -#define DEFAULT_BUCKET_SIZE (4096) -#endif - -static apr_status_t heap_read(ap_bucket *b, const char **str, - apr_size_t *len, ap_read_type block) -{ - ap_bucket_shared *s = b->data; - ap_bucket_heap *h = s->data; - - *str = h->base + s->start; - *len = s->end - s->start; - return APR_SUCCESS; -} - -static void heap_destroy(void *data) -{ - ap_bucket_heap *h; - - h = ap_bucket_destroy_shared(data); - if (h == NULL) { - return; - } - free(h->base); - free(h); -} - -AP_DECLARE(ap_bucket *) ap_bucket_make_heap(ap_bucket *b, - const char *buf, apr_size_t length, int copy, apr_size_t *w) -{ - ap_bucket_heap *h; - - h = malloc(sizeof(*h)); - if (h == NULL) { - return NULL; - } - - if (copy) { - h->base = malloc(DEFAULT_BUCKET_SIZE); - if (h->base == NULL) { - free(h); - return NULL; - } - h->alloc_len = DEFAULT_BUCKET_SIZE; - if (length > DEFAULT_BUCKET_SIZE) { - length = DEFAULT_BUCKET_SIZE; - } - memcpy(h->base, buf, length); - } - else { - /* XXX: we lose the const qualifier here which indicates - * there's something screwy with the API... - */ - h->base = (char *) buf; - h->alloc_len = length; - } - - b = ap_bucket_make_shared(b, h, 0, length); - if (b == NULL) { - if (copy) { - free(h->base); - } - free(h); - return NULL; - } - - b->type = &ap_heap_type; - - if (w) - *w = length; - - return b; -} - -AP_DECLARE(ap_bucket *) ap_bucket_create_heap( - const char *buf, apr_size_t length, int copy, apr_size_t *w) -{ - ap_bucket_do_create(ap_bucket_make_heap(b, buf, length, copy, w)); -} - -const ap_bucket_type ap_heap_type = { - "HEAP", 4, - heap_destroy, - heap_read, - ap_bucket_setaside_notimpl, - ap_bucket_split_shared -}; diff --git a/buckets/ap_buckets_mmap.c b/buckets/ap_buckets_mmap.c deleted file mode 100644 index 2ffdab6f..00000000 --- a/buckets/ap_buckets_mmap.c +++ /dev/null @@ -1,125 +0,0 @@ -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2000 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" must - * not be used to endorse or promote products derived from this - * software without prior written permission. For written - * permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * nor may "Apache" appear in their name, without prior written - * permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -#include "httpd.h" -#include "ap_buckets.h" -#include <stdlib.h> - -static apr_status_t mmap_read(ap_bucket *b, const char **str, - apr_size_t *length, ap_read_type block) -{ - ap_bucket_shared *s = b->data; - ap_bucket_mmap *m = s->data; - apr_status_t ok; - void *addr; - - ok = apr_mmap_offset(&addr, m->mmap, s->start); - if (ok != APR_SUCCESS) { - return ok; - } - *str = addr; - *length = s->end - s->start; - return APR_SUCCESS; -} - -static void mmap_destroy(void *data) -{ - ap_bucket_mmap *m; - - m = ap_bucket_destroy_shared(data); - if (m == NULL) { - return; - } - free(m); -} - -/* - * XXX: are the start and length arguments useful? - */ -AP_DECLARE(ap_bucket *) ap_bucket_make_mmap(ap_bucket *b, - apr_mmap_t *mm, apr_off_t start, apr_size_t length) -{ - ap_bucket_mmap *m; - - m = malloc(sizeof(*m)); - if (m == NULL) { - return NULL; - } - m->mmap = mm; - - b = ap_bucket_make_shared(b, m, start, start+length); - if (b == NULL) { - free(m); - return NULL; - } - - b->type = &ap_mmap_type; - - return b; -} - - -AP_DECLARE(ap_bucket *) ap_bucket_create_mmap( - apr_mmap_t *mm, apr_off_t start, apr_size_t length) -{ - ap_bucket_do_create(ap_bucket_make_mmap(b, mm, start, length)); -} - -const ap_bucket_type ap_mmap_type = { - "MMAP", 4, - mmap_destroy, - mmap_read, - ap_bucket_setaside_notimpl, - ap_bucket_split_shared -}; diff --git a/buckets/ap_buckets_pipe.c b/buckets/ap_buckets_pipe.c deleted file mode 100644 index 2067daa4..00000000 --- a/buckets/ap_buckets_pipe.c +++ /dev/null @@ -1,148 +0,0 @@ -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2000 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" must - * not be used to endorse or promote products derived from this - * software without prior written permission. For written - * permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * nor may "Apache" appear in their name, without prior written - * permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -#include "httpd.h" -#include "ap_buckets.h" -#include <stdlib.h> - -/* XXX: We should obey the block flag */ -static apr_status_t pipe_read(ap_bucket *a, const char **str, - apr_size_t *len, ap_read_type block) -{ - apr_file_t *p = a->data; - ap_bucket *b; - char *buf; - apr_status_t rv; - apr_interval_time_t timeout; - - if (block == AP_NONBLOCK_READ) { - apr_get_pipe_timeout(p, &timeout); - apr_set_pipe_timeout(p, 0); - } - - buf = malloc(IOBUFSIZE); /* XXX: check for failure? */ - *str = buf; - *len = IOBUFSIZE; - rv = apr_read(p, buf, len); - - if (block == AP_NONBLOCK_READ) { - apr_set_pipe_timeout(p, timeout); - } - - if (rv != APR_SUCCESS && rv != APR_EOF) { - *str = NULL; - free(buf); - return rv; - } - /* - * Change the current bucket to refer to what we read, - * even if we read nothing because we hit EOF. - */ - ap_bucket_make_heap(a, buf, *len, 0, NULL); /* XXX: check for failure? */ - /* - * If there's more to read we have to keep the rest of the pipe - * for later. Otherwise, we'll close the pipe. - * XXX: Note that more complicated bucket types that - * refer to data not in memory and must therefore have a read() - * function similar to this one should be wary of copying this - * code because if they have a destroy function they probably - * want to migrate the bucket's subordinate structure from the - * old bucket to a raw new one and adjust it as appropriate, - * rather than destroying the old one and creating a completely - * new bucket. - */ - if (*len > 0) { - b = ap_bucket_create_pipe(p); - AP_BUCKET_INSERT_AFTER(a, b); - } - else { - apr_close(p); - } - return APR_SUCCESS; -} - -AP_DECLARE(ap_bucket *) ap_bucket_make_pipe(ap_bucket *b, apr_file_t *p) -{ - /* - * A pipe is closed when the end is reached in pipe_read(). If the - * pipe isn't read to the end (e.g., error path), the pipe will be - * closed when its pool goes away. - * - * Note that typically the pipe is allocated from the request pool - * so it will disappear when the request is finished. However the - * core filter may decide to set aside the tail end of a CGI - * response if the connection is pipelined. This turns out not to - * be a problem because the core will have read to the end of the - * stream so the bucket(s) that it sets aside will be the heap - * buckets created by pipe_read() above. - */ - b->type = &ap_pipe_type; - b->length = -1; - b->data = p; - - return b; -} - -AP_DECLARE(ap_bucket *) ap_bucket_create_pipe(apr_file_t *p) -{ - ap_bucket_do_create(ap_bucket_make_pipe(b, p)); -} - -const ap_bucket_type ap_pipe_type = { - "PIPE", 4, - ap_bucket_destroy_notimpl, - pipe_read, - ap_bucket_setaside_notimpl, - ap_bucket_split_notimpl -}; diff --git a/buckets/ap_buckets_pool.c b/buckets/ap_buckets_pool.c deleted file mode 100644 index 8cf45973..00000000 --- a/buckets/ap_buckets_pool.c +++ /dev/null @@ -1,142 +0,0 @@ -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2000 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" must - * not be used to endorse or promote products derived from this - * software without prior written permission. For written - * permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * nor may "Apache" appear in their name, without prior written - * permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -#include "httpd.h" -#include "ap_buckets.h" -#include <stdlib.h> - -static apr_status_t pool_bucket_cleanup(void *data) -{ - ap_bucket_shared *s = data; - ap_bucket_shared *new; - ap_bucket_pool *h = s->data; - ap_bucket *b = h->b; - apr_size_t w; - - ap_bucket_make_heap(b, h->base, b->length, 1, &w); - new = b->data; - - new->start = s->start; - new->end = s->end; - - ap_bucket_destroy_shared(s); - return APR_SUCCESS; -} - -static apr_status_t pool_read(ap_bucket *b, const char **str, - apr_size_t *len, ap_read_type block) -{ - ap_bucket_shared *s = b->data; - ap_bucket_pool *h = s->data; - - *str = h->base + s->start; - *len = s->end - s->start; - return APR_SUCCESS; -} - -static void pool_destroy(void *data) -{ - ap_bucket_shared *s = data; - ap_bucket_pool *h = s->data; - - apr_kill_cleanup(h->p, data, pool_bucket_cleanup); - h = ap_bucket_destroy_shared(data); - if (h == NULL) { - return; - } - free(h); -} - -AP_DECLARE(ap_bucket *) ap_bucket_make_pool(ap_bucket *b, - const char *buf, apr_size_t length, apr_pool_t *p) -{ - ap_bucket_pool *h; - - h = malloc(sizeof(*h)); - if (h == NULL) { - return NULL; - } - - /* XXX: we lose the const qualifier here which indicates - * there's something screwy with the API... - */ - h->base = (char *) buf; - h->p = p; - - b = ap_bucket_make_shared(b, h, 0, length); - if (b == NULL) { - free(h); - return NULL; - } - - b->type = &ap_pool_type; - h->b = b; - - apr_register_cleanup(h->p, b->data, pool_bucket_cleanup, apr_null_cleanup); - return b; -} - -AP_DECLARE(ap_bucket *) ap_bucket_create_pool( - const char *buf, apr_size_t length, apr_pool_t *p) -{ - ap_bucket_do_create(ap_bucket_make_pool(b, buf, length, p)); -} - -const ap_bucket_type ap_pool_type = { - "POOL", 4, - pool_destroy, - pool_read, - ap_bucket_setaside_notimpl, - ap_bucket_split_shared -}; diff --git a/buckets/ap_buckets_refcount.c b/buckets/ap_buckets_refcount.c deleted file mode 100644 index bb6ca23d..00000000 --- a/buckets/ap_buckets_refcount.c +++ /dev/null @@ -1,134 +0,0 @@ -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2000 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" must - * not be used to endorse or promote products derived from this - * software without prior written permission. For written - * permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * nor may "Apache" appear in their name, without prior written - * permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -#include <stdlib.h> - -#include "apr_errno.h" - -#include "ap_buckets.h" - -AP_DECLARE_NONSTD(apr_status_t) ap_bucket_split_shared(ap_bucket *a, apr_off_t point) -{ - ap_bucket *b; - ap_bucket_shared *ad, *bd; - ap_bucket_refcount *r; - - if (point < 0 || point > a->length) { - return APR_EINVAL; - } - - b = malloc(sizeof(*b)); - if (b == NULL) { - return APR_ENOMEM; - } - bd = malloc(sizeof(*bd)); - if (bd == NULL) { - free(b); - return APR_ENOMEM; - } - *b = *a; - ad = a->data; - b->data = bd; - *bd = *ad; - - r = ad->data; - r->refcount += 1; - - a->length = point; - ad->end = ad->start + point; - b->length -= point; - bd->start += point; - - AP_BUCKET_INSERT_AFTER(a, b); - - return APR_SUCCESS; -} - -AP_DECLARE(void *) ap_bucket_destroy_shared(void *data) -{ - ap_bucket_shared *s = data; - ap_bucket_refcount *r = s->data; - - free(s); - r->refcount -= 1; - if (r->refcount == 0) { - return r; - } - else { - return NULL; - } -} - -AP_DECLARE(ap_bucket *) ap_bucket_make_shared(ap_bucket *b, void *data, - apr_off_t start, apr_off_t end) -{ - ap_bucket_shared *s; - ap_bucket_refcount *r = data; - - s = malloc(sizeof(*s)); - if (s == NULL) { - return NULL; - } - - b->data = s; - b->length = end - start; - /* caller initializes the type field and function pointers */ - s->start = start; - s->end = end; - s->data = r; - r->refcount = 1; - /* caller initializes the rest of r */ - - return b; -} diff --git a/buckets/ap_buckets_simple.c b/buckets/ap_buckets_simple.c deleted file mode 100644 index e092aef3..00000000 --- a/buckets/ap_buckets_simple.c +++ /dev/null @@ -1,189 +0,0 @@ -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2000 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" must - * not be used to endorse or promote products derived from this - * software without prior written permission. For written - * permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * nor may "Apache" appear in their name, without prior written - * permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -#include "httpd.h" -#include "ap_buckets.h" -#include <stdlib.h> - -/* - * We can't simplify this function by using an ap_bucket_make function - * because we aren't sure of the exact type of this bucket. - */ -static apr_status_t simple_split(ap_bucket *a, apr_off_t point) -{ - ap_bucket *b; - ap_bucket_simple *ad, *bd; - - if (point < 0 || point > a->length) { - return APR_EINVAL; - } - - b = malloc(sizeof(*b)); - if (b == NULL) { - return APR_ENOMEM; - } - bd = malloc(sizeof(*bd)); - if (bd == NULL) { - free(b); - return APR_ENOMEM; - } - *b = *a; - ad = a->data; - b->data = bd; - *bd = *ad; - - a->length = point; - ad->end = ad->start + point; - b->length -= point; - bd->start += point; - - AP_BUCKET_INSERT_AFTER(a, b); - - return APR_SUCCESS; -} - -static apr_status_t simple_read(ap_bucket *b, const char **str, - apr_size_t *len, ap_read_type block) -{ - ap_bucket_simple *bd = b->data; - *str = bd->start; - *len = bd->end - bd->start; - return APR_SUCCESS; -} - -AP_DECLARE(ap_bucket *) ap_bucket_make_immortal(ap_bucket *b, - const char *buf, apr_size_t length) -{ - ap_bucket_simple *bd; - - bd = malloc(sizeof(*bd)); - if (bd == NULL) { - return NULL; - } - - bd->start = buf; - bd->end = buf+length; - - b->type = &ap_immortal_type; - b->length = length; - b->data = bd; - - return b; -} - -AP_DECLARE(ap_bucket *) ap_bucket_create_immortal( - const char *buf, apr_size_t length) -{ - ap_bucket_do_create(ap_bucket_make_immortal(b, buf, length)); -} - -/* - * XXX: This function could do with some tweaking to reduce memory - * usage in various cases, e.g. share buffers in the heap between all - * the buckets that are set aside, or even spool set-aside data to - * disk if it gets too voluminous (but if it does then that's probably - * a bug elsewhere). There should probably be a ap_brigade_setaside() - * function that co-ordinates the action of all the bucket setaside - * functions to improve memory efficiency. - */ -static apr_status_t transient_setaside(ap_bucket *b) -{ - ap_bucket_simple *bd; - const char *start, *end; - apr_size_t w; - - bd = b->data; - start = bd->start; - end = bd->end; - /* XXX: handle small heap buckets */ - b = ap_bucket_make_heap(b, start, end-start, 1, &w); - if (b == NULL || w != end-start) { - return APR_ENOMEM; - } - free(bd); - return APR_SUCCESS; -} - -AP_DECLARE(ap_bucket *) ap_bucket_make_transient(ap_bucket *b, - const char *buf, apr_size_t length) -{ - b = ap_bucket_make_immortal(b, buf, length); - if (b == NULL) { - return NULL; - } - b->type = &ap_transient_type; - return b; -} - -AP_DECLARE(ap_bucket *) ap_bucket_create_transient( - const char *buf, apr_size_t length) -{ - ap_bucket_do_create(ap_bucket_make_transient(b, buf, length)); -} - -const ap_bucket_type ap_immortal_type = { - "IMMORTAL", 4, - free, - simple_read, - ap_bucket_setaside_notimpl, - simple_split -}; - -const ap_bucket_type ap_transient_type = { - "TRANSIENT", 4, - ap_bucket_destroy_notimpl, - simple_read, - transient_setaside, - simple_split -}; diff --git a/buckets/ap_buckets_socket.c b/buckets/ap_buckets_socket.c deleted file mode 100644 index e3ec3fea..00000000 --- a/buckets/ap_buckets_socket.c +++ /dev/null @@ -1,143 +0,0 @@ -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2000 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" must - * not be used to endorse or promote products derived from this - * software without prior written permission. For written - * permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * nor may "Apache" appear in their name, without prior written - * permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -#include "httpd.h" -#include "ap_buckets.h" -#include <stdlib.h> - -/* XXX: We should obey the block flag */ -static apr_status_t socket_read(ap_bucket *a, const char **str, - apr_size_t *len, ap_read_type block) -{ - apr_socket_t *p = a->data; - ap_bucket *b; - char *buf; - apr_status_t rv; - apr_int32_t timeout; - - if (block == AP_NONBLOCK_READ) { - apr_getsocketopt(p, APR_SO_TIMEOUT, &timeout); - apr_setsocketopt(p, APR_SO_TIMEOUT, 0); - } - - buf = malloc(IOBUFSIZE); /* XXX: check for failure? */ - *str = buf; - *len = IOBUFSIZE; - rv = apr_recv(p, buf, len); - - if (block == AP_NONBLOCK_READ) { - apr_setsocketopt(p, APR_SO_TIMEOUT, timeout); - } - - if (rv != APR_SUCCESS && rv != APR_EOF) { - *str = NULL; - free(buf); - return rv; - } - /* - * Change the current bucket to refer to what we read, - * even if we read nothing because we hit EOF. - */ - ap_bucket_make_heap(a, buf, *len, 0, NULL); /* XXX: check for failure? */ - /* - * If there's more to read we have to keep the rest of the socket - * for later. XXX: Note that more complicated bucket types that - * refer to data not in memory and must therefore have a read() - * function similar to this one should be wary of copying this - * code because if they have a destroy function they probably - * want to migrate the bucket's subordinate structure from the - * old bucket to a raw new one and adjust it as appropriate, - * rather than destroying the old one and creating a completely - * new bucket. - * - * Even if there is nothing more to read, don't close the socket here - * as we have to use it to send any response :) We could shut it - * down for reading, but there is no benefit to doing so. - */ - if (*len > 0) { - b = ap_bucket_create_socket(p); - AP_BUCKET_INSERT_AFTER(a, b); - } - return APR_SUCCESS; -} - -AP_DECLARE(ap_bucket *) ap_bucket_make_socket(ap_bucket *b, apr_socket_t *p) -{ - /* - * XXX: We rely on a cleanup on some pool or other to actually - * destroy the socket. We should probably explicitly call apr to - * destroy it instead. - * - * Note that typically the socket is allocated from the connection pool - * so it will disappear when the connection is finished. - */ - b->type = &ap_socket_type; - b->length = -1; - b->data = p; - - return b; -} - -AP_DECLARE(ap_bucket *) ap_bucket_create_socket(apr_socket_t *p) -{ - ap_bucket_do_create(ap_bucket_make_socket(b, p)); -} - -const ap_bucket_type ap_socket_type = { - "SOCKET", 4, - ap_bucket_destroy_notimpl, - socket_read, - ap_bucket_setaside_notimpl, - ap_bucket_split_notimpl -}; diff --git a/buckets/apr_buckets.c b/buckets/apr_buckets.c deleted file mode 100644 index 892311a2..00000000 --- a/buckets/apr_buckets.c +++ /dev/null @@ -1,245 +0,0 @@ -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2000 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" must - * not be used to endorse or promote products derived from this - * software without prior written permission. For written - * permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * nor may "Apache" appear in their name, without prior written - * permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -#include "httpd.h" -#include "apr_pools.h" -#include "apr_lib.h" -#include "apr_errno.h" -#include <stdlib.h> -#ifdef HAVE_SYS_UIO_H -#include <sys/uio.h> -#endif -#include "ap_buckets.h" - -static apr_array_header_t *bucket_types; - -static apr_status_t ap_brigade_cleanup(void *data) -{ - ap_bucket_brigade *b = data; - ap_bucket *e; - - /* - * Bah! We can't use AP_RING_FOREACH here because this bucket has - * gone away when we dig inside it to get the next one. - */ - while (!AP_BRIGADE_EMPTY(b)) { - e = AP_BRIGADE_FIRST(b); - AP_BUCKET_REMOVE(e); - ap_bucket_destroy(e); - } - /* - * We don't need to free(bb) because it's allocated from a pool. - */ - return APR_SUCCESS; -} -AP_DECLARE(apr_status_t) ap_brigade_destroy(ap_bucket_brigade *b) -{ - apr_kill_cleanup(b->p, b, ap_brigade_cleanup); - return ap_brigade_cleanup(b); -} - -AP_DECLARE(ap_bucket_brigade *) ap_brigade_create(apr_pool_t *p) -{ - ap_bucket_brigade *b; - - b = apr_palloc(p, sizeof(*b)); - b->p = p; - AP_RING_INIT(&b->list, ap_bucket, link); - - apr_register_cleanup(b->p, b, ap_brigade_cleanup, ap_brigade_cleanup); - return b; -} - -AP_DECLARE(ap_bucket_brigade *) ap_brigade_split(ap_bucket_brigade *b, - ap_bucket *e) -{ - ap_bucket_brigade *a; - ap_bucket *f; - - a = ap_brigade_create(b->p); - /* Return an empty brigade if there is nothing left in - * the first brigade to split off - */ - if (e != AP_BRIGADE_SENTINEL(b)) { - f = AP_RING_LAST(&b->list); - AP_RING_UNSPLICE(e, f, link); - AP_RING_SPLICE_HEAD(&a->list, e, f, ap_bucket, link); - } - return a; -} - -AP_DECLARE(int) ap_brigade_to_iovec(ap_bucket_brigade *b, - struct iovec *vec, int nvec) -{ - ap_bucket *e; - struct iovec *orig; - apr_size_t iov_len; - - orig = vec; - AP_BRIGADE_FOREACH(e, b) { - if (nvec-- == 0) - break; - ap_bucket_read(e, (const char **)&vec->iov_base, &iov_len, AP_NONBLOCK_READ); - vec->iov_len = iov_len; /* set indirectly in case size differs */ - ++vec; - } - return vec - orig; -} - -AP_DECLARE(int) ap_brigade_vputstrs(ap_bucket_brigade *b, va_list va) -{ - ap_bucket *r; - const char *x; - int j, k; - apr_size_t i; - - for (k = 0;;) { - x = va_arg(va, const char *); - if (x == NULL) - break; - j = strlen(x); - - /* XXX: copy or not? let the caller decide? */ - r = ap_bucket_create_heap(x, j, 1, &i); - if (i != j) { - /* Do we need better error reporting? */ - return -1; - } - k += i; - - AP_BRIGADE_INSERT_TAIL(b, r); - } - - return k; -} - -AP_DECLARE_NONSTD(int) ap_brigade_putstrs(ap_bucket_brigade *b, ...) -{ - va_list va; - int written; - - va_start(va, b); - written = ap_brigade_vputstrs(b, va); - va_end(va); - return written; -} - -AP_DECLARE_NONSTD(int) ap_brigade_printf(ap_bucket_brigade *b, const char *fmt, ...) -{ - va_list ap; - int res; - - va_start(ap, fmt); - res = ap_brigade_vprintf(b, fmt, ap); - va_end(ap); - return res; -} - -AP_DECLARE(int) ap_brigade_vprintf(ap_bucket_brigade *b, const char *fmt, va_list va) -{ - /* XXX: This needs to be replaced with a function to printf - * directly into a bucket. I'm being lazy right now. RBB - */ - char buf[4096]; - ap_bucket *r; - int res; - - res = apr_vsnprintf(buf, 4096, fmt, va); - - r = ap_bucket_create_heap(buf, strlen(buf), 1, NULL); - AP_BRIGADE_INSERT_TAIL(b, r); - - return res; -} - -void ap_init_bucket_types(apr_pool_t *p) -{ - bucket_types = apr_make_array(p, 8, sizeof(ap_bucket_type)); - - ap_insert_bucket_type(&ap_eos_type); - ap_insert_bucket_type(&ap_file_type); - ap_insert_bucket_type(&ap_heap_type); -#ifdef AP_USE_MMAP_FILES - ap_insert_bucket_type(&ap_mmap_type); -#endif - ap_insert_bucket_type(&ap_pipe_type); - ap_insert_bucket_type(&ap_immortal_type); - ap_insert_bucket_type(&ap_transient_type); - ap_insert_bucket_type(&ap_socket_type); -} - -int ap_insert_bucket_type(const ap_bucket_type *type) -{ - const ap_bucket_type **newone; - - newone = (const ap_bucket_type **)apr_push_array(bucket_types); - newone = &type; - - return bucket_types->nelts - 1; -} - -AP_DECLARE_NONSTD(apr_status_t) ap_bucket_setaside_notimpl(ap_bucket *data) -{ - return APR_ENOTIMPL; -} - -AP_DECLARE_NONSTD(apr_status_t) ap_bucket_split_notimpl(ap_bucket *data, apr_off_t point) -{ - return APR_ENOTIMPL; -} - -AP_DECLARE_NONSTD(void) ap_bucket_destroy_notimpl(void *data) -{ - return; -} diff --git a/buckets/apr_buckets_eos.c b/buckets/apr_buckets_eos.c deleted file mode 100644 index 0502a0e5..00000000 --- a/buckets/apr_buckets_eos.c +++ /dev/null @@ -1,88 +0,0 @@ -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2000 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" must - * not be used to endorse or promote products derived from this - * software without prior written permission. For written - * permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * nor may "Apache" appear in their name, without prior written - * permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -#include "httpd.h" -#include "ap_buckets.h" -#include <stdlib.h> - -static apr_status_t eos_read(ap_bucket *b, const char **str, - apr_size_t *len, ap_read_type block) -{ - *str = NULL; - *len = 0; - return APR_SUCCESS; -} - -AP_DECLARE(ap_bucket *) ap_bucket_make_eos(ap_bucket *b) -{ - b->length = 0; - b->data = NULL; - - b->type = &ap_eos_type; - - return b; -} - -AP_DECLARE(ap_bucket *) ap_bucket_create_eos(void) -{ - ap_bucket_do_create(ap_bucket_make_eos(b)); -} - -const ap_bucket_type ap_eos_type = { - "EOS", 4, - ap_bucket_destroy_notimpl, - eos_read, - ap_bucket_setaside_notimpl, - ap_bucket_split_notimpl -}; diff --git a/buckets/apr_buckets_file.c b/buckets/apr_buckets_file.c deleted file mode 100644 index 782d9352..00000000 --- a/buckets/apr_buckets_file.c +++ /dev/null @@ -1,193 +0,0 @@ -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2000 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" must - * not be used to endorse or promote products derived from this - * software without prior written permission. For written - * permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * nor may "Apache" appear in their name, without prior written - * permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -#include "httpd.h" -#include "ap_buckets.h" -#include <stdlib.h> - -/* Allow Apache to use ap_mmap */ -#ifdef AP_USE_MMAP_FILES -#include "apr_mmap.h" - -/* mmap support for static files based on ideas from John Heidemann's - * patch against 1.0.5. See - * <http://www.isi.edu/~johnh/SOFTWARE/APACHE/index.html>. - */ - -/* Files have to be at least this big before they're mmap()d. This is to deal - * with systems where the expense of doing an mmap() and an munmap() outweighs - * the benefit for small files. It shouldn't be set lower than 1. - */ -#ifndef MMAP_THRESHOLD -# ifdef SUNOS4 -# define MMAP_THRESHOLD (8*1024) -# else -# define MMAP_THRESHOLD 1 -# endif /* SUNOS4 */ -#endif /* MMAP_THRESHOLD */ -#ifndef MMAP_LIMIT -#define MMAP_LIMIT (4*1024*1024) -#endif -#endif /* AP_USE_MMAP_FILES */ - - -/* XXX: We should obey the block flag */ -static apr_status_t file_read(ap_bucket *e, const char **str, - apr_size_t *len, ap_read_type block) -{ - ap_bucket_file *a = (ap_bucket_file *)e->data; - apr_file_t *f = (apr_file_t *) a->fd; - ap_bucket *b = NULL; - char *buf; - apr_status_t rv; -#ifdef AP_USE_MMAP_FILES - apr_mmap_t *mm = NULL; -#endif - -#ifdef AP_USE_MMAP_FILES - if ((e->length >= MMAP_THRESHOLD) - && (e->length < MMAP_LIMIT)) { - /* we need to protect ourselves in case we die while we've got the - * file mmapped */ - apr_status_t status; - if ((status = apr_mmap_create(&mm, f, a->offset, e->length, NULL)) != APR_SUCCESS) { - mm = NULL; - } - } - else { - mm = NULL; - } - if (mm) { - ap_bucket_make_mmap(e, mm, 0, e->length); /*XXX: check for failure? */ - return ap_bucket_read(e, str, len, block); - } - else { -#endif - - buf = malloc(IOBUFSIZE); - *str = buf; - - if (e->length > IOBUFSIZE) { - *len = IOBUFSIZE; - } - else { - *len = e->length; - } - - /* Handle offset ... */ - if (a->offset) { - rv = apr_seek(f, APR_SET, &a->offset); - if (rv != APR_SUCCESS) { - free(buf); - return rv; - } - /* Only need to do seek the first time through */ - a->offset = 0; - } - rv = apr_read(f, buf, len); - if (rv != APR_SUCCESS && rv != APR_EOF) { - free(buf); - return rv; - } - - /* - * Change the current bucket to refer to what we read, - * even if we read nothing because we hit EOF. - */ - ap_bucket_make_heap(e, buf, *len, 0, NULL); /*XXX: check for failure? */ - - /* If we have more to read from the file, then create another bucket */ - if (*len > 0) { - b = ap_bucket_create_file(f, 0, e->length); - AP_BUCKET_INSERT_AFTER(e, b); - } -#ifdef AP_USE_MMAP_FILES - } -#endif - return APR_SUCCESS; -} - -AP_DECLARE(ap_bucket *) ap_bucket_make_file(ap_bucket *b, apr_file_t *fd, - apr_off_t offset, apr_size_t len) -{ - ap_bucket_file *f; - - f = malloc(sizeof(*f)); - if (f == NULL) { - return NULL; - } - - f->fd = fd; - f->offset = offset; - - b->type = &ap_file_type; - b->data = f; - b->length = len; - - return b; -} - -AP_DECLARE(ap_bucket *) ap_bucket_create_file(apr_file_t *fd, - apr_off_t offset, apr_size_t len) -{ - ap_bucket_do_create(ap_bucket_make_file(b, fd, offset, len)); -} - -const ap_bucket_type ap_file_type = { - "FILE", 4, - ap_bucket_destroy_notimpl, - file_read, - ap_bucket_setaside_notimpl, - ap_bucket_split_notimpl -}; diff --git a/buckets/apr_buckets_flush.c b/buckets/apr_buckets_flush.c deleted file mode 100644 index 97f4ac4d..00000000 --- a/buckets/apr_buckets_flush.c +++ /dev/null @@ -1,88 +0,0 @@ -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2000 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" must - * not be used to endorse or promote products derived from this - * software without prior written permission. For written - * permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * nor may "Apache" appear in their name, without prior written - * permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -#include "httpd.h" -#include "ap_buckets.h" -#include <stdlib.h> - -static apr_status_t flush_read(ap_bucket *b, const char **str, - apr_size_t *len, ap_read_type block) -{ - *str = NULL; - *len = 0; - return APR_SUCCESS; -} - -AP_DECLARE(ap_bucket *) ap_bucket_make_flush(ap_bucket *b) -{ - b->length = 0; - b->data = NULL; - - b->type = &ap_flush_type; - - return b; -} - -AP_DECLARE(ap_bucket *) ap_bucket_create_flush(void) -{ - ap_bucket_do_create(ap_bucket_make_flush(b)); -} - -const ap_bucket_type ap_flush_type = { - "FLUSH", 4, - ap_bucket_destroy_notimpl, - flush_read, - ap_bucket_setaside_notimpl, - ap_bucket_split_notimpl -}; diff --git a/buckets/apr_buckets_heap.c b/buckets/apr_buckets_heap.c deleted file mode 100644 index 7813c3ca..00000000 --- a/buckets/apr_buckets_heap.c +++ /dev/null @@ -1,150 +0,0 @@ -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2000 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" must - * not be used to endorse or promote products derived from this - * software without prior written permission. For written - * permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * nor may "Apache" appear in their name, without prior written - * permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -#include "httpd.h" -#include "ap_buckets.h" -#include <stdlib.h> - -/* - * The size of heap bucket memory allocations. - * XXX: This is currently a guess and should be adjusted to an - * empirically good value. - */ -#ifndef DEFAULT_BUCKET_SIZE -#define DEFAULT_BUCKET_SIZE (4096) -#endif - -static apr_status_t heap_read(ap_bucket *b, const char **str, - apr_size_t *len, ap_read_type block) -{ - ap_bucket_shared *s = b->data; - ap_bucket_heap *h = s->data; - - *str = h->base + s->start; - *len = s->end - s->start; - return APR_SUCCESS; -} - -static void heap_destroy(void *data) -{ - ap_bucket_heap *h; - - h = ap_bucket_destroy_shared(data); - if (h == NULL) { - return; - } - free(h->base); - free(h); -} - -AP_DECLARE(ap_bucket *) ap_bucket_make_heap(ap_bucket *b, - const char *buf, apr_size_t length, int copy, apr_size_t *w) -{ - ap_bucket_heap *h; - - h = malloc(sizeof(*h)); - if (h == NULL) { - return NULL; - } - - if (copy) { - h->base = malloc(DEFAULT_BUCKET_SIZE); - if (h->base == NULL) { - free(h); - return NULL; - } - h->alloc_len = DEFAULT_BUCKET_SIZE; - if (length > DEFAULT_BUCKET_SIZE) { - length = DEFAULT_BUCKET_SIZE; - } - memcpy(h->base, buf, length); - } - else { - /* XXX: we lose the const qualifier here which indicates - * there's something screwy with the API... - */ - h->base = (char *) buf; - h->alloc_len = length; - } - - b = ap_bucket_make_shared(b, h, 0, length); - if (b == NULL) { - if (copy) { - free(h->base); - } - free(h); - return NULL; - } - - b->type = &ap_heap_type; - - if (w) - *w = length; - - return b; -} - -AP_DECLARE(ap_bucket *) ap_bucket_create_heap( - const char *buf, apr_size_t length, int copy, apr_size_t *w) -{ - ap_bucket_do_create(ap_bucket_make_heap(b, buf, length, copy, w)); -} - -const ap_bucket_type ap_heap_type = { - "HEAP", 4, - heap_destroy, - heap_read, - ap_bucket_setaside_notimpl, - ap_bucket_split_shared -}; diff --git a/buckets/apr_buckets_mmap.c b/buckets/apr_buckets_mmap.c deleted file mode 100644 index 2ffdab6f..00000000 --- a/buckets/apr_buckets_mmap.c +++ /dev/null @@ -1,125 +0,0 @@ -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2000 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" must - * not be used to endorse or promote products derived from this - * software without prior written permission. For written - * permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * nor may "Apache" appear in their name, without prior written - * permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -#include "httpd.h" -#include "ap_buckets.h" -#include <stdlib.h> - -static apr_status_t mmap_read(ap_bucket *b, const char **str, - apr_size_t *length, ap_read_type block) -{ - ap_bucket_shared *s = b->data; - ap_bucket_mmap *m = s->data; - apr_status_t ok; - void *addr; - - ok = apr_mmap_offset(&addr, m->mmap, s->start); - if (ok != APR_SUCCESS) { - return ok; - } - *str = addr; - *length = s->end - s->start; - return APR_SUCCESS; -} - -static void mmap_destroy(void *data) -{ - ap_bucket_mmap *m; - - m = ap_bucket_destroy_shared(data); - if (m == NULL) { - return; - } - free(m); -} - -/* - * XXX: are the start and length arguments useful? - */ -AP_DECLARE(ap_bucket *) ap_bucket_make_mmap(ap_bucket *b, - apr_mmap_t *mm, apr_off_t start, apr_size_t length) -{ - ap_bucket_mmap *m; - - m = malloc(sizeof(*m)); - if (m == NULL) { - return NULL; - } - m->mmap = mm; - - b = ap_bucket_make_shared(b, m, start, start+length); - if (b == NULL) { - free(m); - return NULL; - } - - b->type = &ap_mmap_type; - - return b; -} - - -AP_DECLARE(ap_bucket *) ap_bucket_create_mmap( - apr_mmap_t *mm, apr_off_t start, apr_size_t length) -{ - ap_bucket_do_create(ap_bucket_make_mmap(b, mm, start, length)); -} - -const ap_bucket_type ap_mmap_type = { - "MMAP", 4, - mmap_destroy, - mmap_read, - ap_bucket_setaside_notimpl, - ap_bucket_split_shared -}; diff --git a/buckets/apr_buckets_pipe.c b/buckets/apr_buckets_pipe.c deleted file mode 100644 index 2067daa4..00000000 --- a/buckets/apr_buckets_pipe.c +++ /dev/null @@ -1,148 +0,0 @@ -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2000 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" must - * not be used to endorse or promote products derived from this - * software without prior written permission. For written - * permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * nor may "Apache" appear in their name, without prior written - * permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -#include "httpd.h" -#include "ap_buckets.h" -#include <stdlib.h> - -/* XXX: We should obey the block flag */ -static apr_status_t pipe_read(ap_bucket *a, const char **str, - apr_size_t *len, ap_read_type block) -{ - apr_file_t *p = a->data; - ap_bucket *b; - char *buf; - apr_status_t rv; - apr_interval_time_t timeout; - - if (block == AP_NONBLOCK_READ) { - apr_get_pipe_timeout(p, &timeout); - apr_set_pipe_timeout(p, 0); - } - - buf = malloc(IOBUFSIZE); /* XXX: check for failure? */ - *str = buf; - *len = IOBUFSIZE; - rv = apr_read(p, buf, len); - - if (block == AP_NONBLOCK_READ) { - apr_set_pipe_timeout(p, timeout); - } - - if (rv != APR_SUCCESS && rv != APR_EOF) { - *str = NULL; - free(buf); - return rv; - } - /* - * Change the current bucket to refer to what we read, - * even if we read nothing because we hit EOF. - */ - ap_bucket_make_heap(a, buf, *len, 0, NULL); /* XXX: check for failure? */ - /* - * If there's more to read we have to keep the rest of the pipe - * for later. Otherwise, we'll close the pipe. - * XXX: Note that more complicated bucket types that - * refer to data not in memory and must therefore have a read() - * function similar to this one should be wary of copying this - * code because if they have a destroy function they probably - * want to migrate the bucket's subordinate structure from the - * old bucket to a raw new one and adjust it as appropriate, - * rather than destroying the old one and creating a completely - * new bucket. - */ - if (*len > 0) { - b = ap_bucket_create_pipe(p); - AP_BUCKET_INSERT_AFTER(a, b); - } - else { - apr_close(p); - } - return APR_SUCCESS; -} - -AP_DECLARE(ap_bucket *) ap_bucket_make_pipe(ap_bucket *b, apr_file_t *p) -{ - /* - * A pipe is closed when the end is reached in pipe_read(). If the - * pipe isn't read to the end (e.g., error path), the pipe will be - * closed when its pool goes away. - * - * Note that typically the pipe is allocated from the request pool - * so it will disappear when the request is finished. However the - * core filter may decide to set aside the tail end of a CGI - * response if the connection is pipelined. This turns out not to - * be a problem because the core will have read to the end of the - * stream so the bucket(s) that it sets aside will be the heap - * buckets created by pipe_read() above. - */ - b->type = &ap_pipe_type; - b->length = -1; - b->data = p; - - return b; -} - -AP_DECLARE(ap_bucket *) ap_bucket_create_pipe(apr_file_t *p) -{ - ap_bucket_do_create(ap_bucket_make_pipe(b, p)); -} - -const ap_bucket_type ap_pipe_type = { - "PIPE", 4, - ap_bucket_destroy_notimpl, - pipe_read, - ap_bucket_setaside_notimpl, - ap_bucket_split_notimpl -}; diff --git a/buckets/apr_buckets_pool.c b/buckets/apr_buckets_pool.c deleted file mode 100644 index 8cf45973..00000000 --- a/buckets/apr_buckets_pool.c +++ /dev/null @@ -1,142 +0,0 @@ -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2000 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" must - * not be used to endorse or promote products derived from this - * software without prior written permission. For written - * permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * nor may "Apache" appear in their name, without prior written - * permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -#include "httpd.h" -#include "ap_buckets.h" -#include <stdlib.h> - -static apr_status_t pool_bucket_cleanup(void *data) -{ - ap_bucket_shared *s = data; - ap_bucket_shared *new; - ap_bucket_pool *h = s->data; - ap_bucket *b = h->b; - apr_size_t w; - - ap_bucket_make_heap(b, h->base, b->length, 1, &w); - new = b->data; - - new->start = s->start; - new->end = s->end; - - ap_bucket_destroy_shared(s); - return APR_SUCCESS; -} - -static apr_status_t pool_read(ap_bucket *b, const char **str, - apr_size_t *len, ap_read_type block) -{ - ap_bucket_shared *s = b->data; - ap_bucket_pool *h = s->data; - - *str = h->base + s->start; - *len = s->end - s->start; - return APR_SUCCESS; -} - -static void pool_destroy(void *data) -{ - ap_bucket_shared *s = data; - ap_bucket_pool *h = s->data; - - apr_kill_cleanup(h->p, data, pool_bucket_cleanup); - h = ap_bucket_destroy_shared(data); - if (h == NULL) { - return; - } - free(h); -} - -AP_DECLARE(ap_bucket *) ap_bucket_make_pool(ap_bucket *b, - const char *buf, apr_size_t length, apr_pool_t *p) -{ - ap_bucket_pool *h; - - h = malloc(sizeof(*h)); - if (h == NULL) { - return NULL; - } - - /* XXX: we lose the const qualifier here which indicates - * there's something screwy with the API... - */ - h->base = (char *) buf; - h->p = p; - - b = ap_bucket_make_shared(b, h, 0, length); - if (b == NULL) { - free(h); - return NULL; - } - - b->type = &ap_pool_type; - h->b = b; - - apr_register_cleanup(h->p, b->data, pool_bucket_cleanup, apr_null_cleanup); - return b; -} - -AP_DECLARE(ap_bucket *) ap_bucket_create_pool( - const char *buf, apr_size_t length, apr_pool_t *p) -{ - ap_bucket_do_create(ap_bucket_make_pool(b, buf, length, p)); -} - -const ap_bucket_type ap_pool_type = { - "POOL", 4, - pool_destroy, - pool_read, - ap_bucket_setaside_notimpl, - ap_bucket_split_shared -}; diff --git a/buckets/apr_buckets_refcount.c b/buckets/apr_buckets_refcount.c deleted file mode 100644 index bb6ca23d..00000000 --- a/buckets/apr_buckets_refcount.c +++ /dev/null @@ -1,134 +0,0 @@ -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2000 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" must - * not be used to endorse or promote products derived from this - * software without prior written permission. For written - * permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * nor may "Apache" appear in their name, without prior written - * permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -#include <stdlib.h> - -#include "apr_errno.h" - -#include "ap_buckets.h" - -AP_DECLARE_NONSTD(apr_status_t) ap_bucket_split_shared(ap_bucket *a, apr_off_t point) -{ - ap_bucket *b; - ap_bucket_shared *ad, *bd; - ap_bucket_refcount *r; - - if (point < 0 || point > a->length) { - return APR_EINVAL; - } - - b = malloc(sizeof(*b)); - if (b == NULL) { - return APR_ENOMEM; - } - bd = malloc(sizeof(*bd)); - if (bd == NULL) { - free(b); - return APR_ENOMEM; - } - *b = *a; - ad = a->data; - b->data = bd; - *bd = *ad; - - r = ad->data; - r->refcount += 1; - - a->length = point; - ad->end = ad->start + point; - b->length -= point; - bd->start += point; - - AP_BUCKET_INSERT_AFTER(a, b); - - return APR_SUCCESS; -} - -AP_DECLARE(void *) ap_bucket_destroy_shared(void *data) -{ - ap_bucket_shared *s = data; - ap_bucket_refcount *r = s->data; - - free(s); - r->refcount -= 1; - if (r->refcount == 0) { - return r; - } - else { - return NULL; - } -} - -AP_DECLARE(ap_bucket *) ap_bucket_make_shared(ap_bucket *b, void *data, - apr_off_t start, apr_off_t end) -{ - ap_bucket_shared *s; - ap_bucket_refcount *r = data; - - s = malloc(sizeof(*s)); - if (s == NULL) { - return NULL; - } - - b->data = s; - b->length = end - start; - /* caller initializes the type field and function pointers */ - s->start = start; - s->end = end; - s->data = r; - r->refcount = 1; - /* caller initializes the rest of r */ - - return b; -} diff --git a/buckets/apr_buckets_simple.c b/buckets/apr_buckets_simple.c deleted file mode 100644 index e092aef3..00000000 --- a/buckets/apr_buckets_simple.c +++ /dev/null @@ -1,189 +0,0 @@ -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2000 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" must - * not be used to endorse or promote products derived from this - * software without prior written permission. For written - * permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * nor may "Apache" appear in their name, without prior written - * permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -#include "httpd.h" -#include "ap_buckets.h" -#include <stdlib.h> - -/* - * We can't simplify this function by using an ap_bucket_make function - * because we aren't sure of the exact type of this bucket. - */ -static apr_status_t simple_split(ap_bucket *a, apr_off_t point) -{ - ap_bucket *b; - ap_bucket_simple *ad, *bd; - - if (point < 0 || point > a->length) { - return APR_EINVAL; - } - - b = malloc(sizeof(*b)); - if (b == NULL) { - return APR_ENOMEM; - } - bd = malloc(sizeof(*bd)); - if (bd == NULL) { - free(b); - return APR_ENOMEM; - } - *b = *a; - ad = a->data; - b->data = bd; - *bd = *ad; - - a->length = point; - ad->end = ad->start + point; - b->length -= point; - bd->start += point; - - AP_BUCKET_INSERT_AFTER(a, b); - - return APR_SUCCESS; -} - -static apr_status_t simple_read(ap_bucket *b, const char **str, - apr_size_t *len, ap_read_type block) -{ - ap_bucket_simple *bd = b->data; - *str = bd->start; - *len = bd->end - bd->start; - return APR_SUCCESS; -} - -AP_DECLARE(ap_bucket *) ap_bucket_make_immortal(ap_bucket *b, - const char *buf, apr_size_t length) -{ - ap_bucket_simple *bd; - - bd = malloc(sizeof(*bd)); - if (bd == NULL) { - return NULL; - } - - bd->start = buf; - bd->end = buf+length; - - b->type = &ap_immortal_type; - b->length = length; - b->data = bd; - - return b; -} - -AP_DECLARE(ap_bucket *) ap_bucket_create_immortal( - const char *buf, apr_size_t length) -{ - ap_bucket_do_create(ap_bucket_make_immortal(b, buf, length)); -} - -/* - * XXX: This function could do with some tweaking to reduce memory - * usage in various cases, e.g. share buffers in the heap between all - * the buckets that are set aside, or even spool set-aside data to - * disk if it gets too voluminous (but if it does then that's probably - * a bug elsewhere). There should probably be a ap_brigade_setaside() - * function that co-ordinates the action of all the bucket setaside - * functions to improve memory efficiency. - */ -static apr_status_t transient_setaside(ap_bucket *b) -{ - ap_bucket_simple *bd; - const char *start, *end; - apr_size_t w; - - bd = b->data; - start = bd->start; - end = bd->end; - /* XXX: handle small heap buckets */ - b = ap_bucket_make_heap(b, start, end-start, 1, &w); - if (b == NULL || w != end-start) { - return APR_ENOMEM; - } - free(bd); - return APR_SUCCESS; -} - -AP_DECLARE(ap_bucket *) ap_bucket_make_transient(ap_bucket *b, - const char *buf, apr_size_t length) -{ - b = ap_bucket_make_immortal(b, buf, length); - if (b == NULL) { - return NULL; - } - b->type = &ap_transient_type; - return b; -} - -AP_DECLARE(ap_bucket *) ap_bucket_create_transient( - const char *buf, apr_size_t length) -{ - ap_bucket_do_create(ap_bucket_make_transient(b, buf, length)); -} - -const ap_bucket_type ap_immortal_type = { - "IMMORTAL", 4, - free, - simple_read, - ap_bucket_setaside_notimpl, - simple_split -}; - -const ap_bucket_type ap_transient_type = { - "TRANSIENT", 4, - ap_bucket_destroy_notimpl, - simple_read, - transient_setaside, - simple_split -}; diff --git a/buckets/apr_buckets_socket.c b/buckets/apr_buckets_socket.c deleted file mode 100644 index e3ec3fea..00000000 --- a/buckets/apr_buckets_socket.c +++ /dev/null @@ -1,143 +0,0 @@ -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2000 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" must - * not be used to endorse or promote products derived from this - * software without prior written permission. For written - * permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * nor may "Apache" appear in their name, without prior written - * permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -#include "httpd.h" -#include "ap_buckets.h" -#include <stdlib.h> - -/* XXX: We should obey the block flag */ -static apr_status_t socket_read(ap_bucket *a, const char **str, - apr_size_t *len, ap_read_type block) -{ - apr_socket_t *p = a->data; - ap_bucket *b; - char *buf; - apr_status_t rv; - apr_int32_t timeout; - - if (block == AP_NONBLOCK_READ) { - apr_getsocketopt(p, APR_SO_TIMEOUT, &timeout); - apr_setsocketopt(p, APR_SO_TIMEOUT, 0); - } - - buf = malloc(IOBUFSIZE); /* XXX: check for failure? */ - *str = buf; - *len = IOBUFSIZE; - rv = apr_recv(p, buf, len); - - if (block == AP_NONBLOCK_READ) { - apr_setsocketopt(p, APR_SO_TIMEOUT, timeout); - } - - if (rv != APR_SUCCESS && rv != APR_EOF) { - *str = NULL; - free(buf); - return rv; - } - /* - * Change the current bucket to refer to what we read, - * even if we read nothing because we hit EOF. - */ - ap_bucket_make_heap(a, buf, *len, 0, NULL); /* XXX: check for failure? */ - /* - * If there's more to read we have to keep the rest of the socket - * for later. XXX: Note that more complicated bucket types that - * refer to data not in memory and must therefore have a read() - * function similar to this one should be wary of copying this - * code because if they have a destroy function they probably - * want to migrate the bucket's subordinate structure from the - * old bucket to a raw new one and adjust it as appropriate, - * rather than destroying the old one and creating a completely - * new bucket. - * - * Even if there is nothing more to read, don't close the socket here - * as we have to use it to send any response :) We could shut it - * down for reading, but there is no benefit to doing so. - */ - if (*len > 0) { - b = ap_bucket_create_socket(p); - AP_BUCKET_INSERT_AFTER(a, b); - } - return APR_SUCCESS; -} - -AP_DECLARE(ap_bucket *) ap_bucket_make_socket(ap_bucket *b, apr_socket_t *p) -{ - /* - * XXX: We rely on a cleanup on some pool or other to actually - * destroy the socket. We should probably explicitly call apr to - * destroy it instead. - * - * Note that typically the socket is allocated from the connection pool - * so it will disappear when the connection is finished. - */ - b->type = &ap_socket_type; - b->length = -1; - b->data = p; - - return b; -} - -AP_DECLARE(ap_bucket *) ap_bucket_create_socket(apr_socket_t *p) -{ - ap_bucket_do_create(ap_bucket_make_socket(b, p)); -} - -const ap_bucket_type ap_socket_type = { - "SOCKET", 4, - ap_bucket_destroy_notimpl, - socket_read, - ap_bucket_setaside_notimpl, - ap_bucket_split_notimpl -}; diff --git a/crypto/ap_sha1.c b/crypto/ap_sha1.c deleted file mode 100644 index 08d8054e..00000000 --- a/crypto/ap_sha1.c +++ /dev/null @@ -1,412 +0,0 @@ -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2000 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" must - * not be used to endorse or promote products derived from this - * software without prior written permission. For written - * permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * nor may "Apache" appear in their name, without prior written - * permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/* - * The exported function: - * - * ap_sha1_base64(const char *clear, int len, char *out); - * - * provides a means to SHA1 crypt/encode a plaintext password in - * a way which makes password files compatible with those commonly - * used in netscape web and ldap installations. It was put together - * by Clinton Wong <clintdw@netcom.com>, who also notes that: - * - * Note: SHA1 support is useful for migration purposes, but is less - * secure than Apache's password format, since Apache's (MD5) - * password format uses a random eight character salt to generate - * one of many possible hashes for the same password. Netscape - * uses plain SHA1 without a salt, so the same password - * will always generate the same hash, making it easier - * to break since the search space is smaller. - * - * See also the documentation in support/SHA1 as to hints on how to - * migrate an existing netscape installation and other supplied utitlites. - * - * This software also makes use of the following component: - * - * NIST Secure Hash Algorithm - * heavily modified by Uwe Hollerbach uh@alumni.caltech edu - * from Peter C. Gutmann's implementation as found in - * Applied Cryptography by Bruce Schneier - * This code is hereby placed in the public domain - */ - -#include "ap_config.h" -#include "ap_sha1.h" -#include "ap_base64.h" -#include "apr_strings.h" -#include "apr_lib.h" -#ifdef CHARSET_EBCDIC -#include "apr_xlate.h" -#endif /*CHARSET_EBCDIC*/ - -/* a bit faster & bigger, if defined */ -#define UNROLL_LOOPS - -/* NIST's proposed modification to SHA, 7/11/94 */ -#define USE_MODIFIED_SHA - -/* SHA f()-functions */ -#define f1(x,y,z) ((x & y) | (~x & z)) -#define f2(x,y,z) (x ^ y ^ z) -#define f3(x,y,z) ((x & y) | (x & z) | (y & z)) -#define f4(x,y,z) (x ^ y ^ z) - -/* SHA constants */ -#define CONST1 0x5a827999L -#define CONST2 0x6ed9eba1L -#define CONST3 0x8f1bbcdcL -#define CONST4 0xca62c1d6L - -/* 32-bit rotate */ - -#define ROT32(x,n) ((x << n) | (x >> (32 - n))) - -#define FUNC(n,i) \ - temp = ROT32(A,5) + f##n(B,C,D) + E + W[i] + CONST##n; \ - E = D; D = C; C = ROT32(B,30); B = A; A = temp - -#define SHA_BLOCKSIZE 64 - -#ifdef CHARSET_EBCDIC -static apr_xlate_t *ebcdic2ascii_xlate; - -AP_DECLARE(apr_status_t) ap_SHA1InitEBCDIC(apr_xlate_t *x) -{ - apr_status_t rv; - int onoff; - - /* Only single-byte conversion is supported. - */ - rv = apr_xlate_get_sb(x, &onoff); - if (rv) { - return rv; - } - if (!onoff) { /* If conversion is not single-byte-only */ - return APR_EINVAL; - } - ebcdic2ascii_xlate = x; - return APR_SUCCESS; -} -#endif - -typedef unsigned char AP_BYTE; - -/* do SHA transformation */ -static void sha_transform(AP_SHA1_CTX *sha_info) -{ - int i; - apr_uint32_t temp, A, B, C, D, E, W[80]; - - for (i = 0; i < 16; ++i) { - W[i] = sha_info->data[i]; - } - for (i = 16; i < 80; ++i) { - W[i] = W[i-3] ^ W[i-8] ^ W[i-14] ^ W[i-16]; -#ifdef USE_MODIFIED_SHA - W[i] = ROT32(W[i], 1); -#endif /* USE_MODIFIED_SHA */ - } - A = sha_info->digest[0]; - B = sha_info->digest[1]; - C = sha_info->digest[2]; - D = sha_info->digest[3]; - E = sha_info->digest[4]; -#ifdef UNROLL_LOOPS - FUNC(1, 0); FUNC(1, 1); FUNC(1, 2); FUNC(1, 3); FUNC(1, 4); - FUNC(1, 5); FUNC(1, 6); FUNC(1, 7); FUNC(1, 8); FUNC(1, 9); - FUNC(1,10); FUNC(1,11); FUNC(1,12); FUNC(1,13); FUNC(1,14); - FUNC(1,15); FUNC(1,16); FUNC(1,17); FUNC(1,18); FUNC(1,19); - - FUNC(2,20); FUNC(2,21); FUNC(2,22); FUNC(2,23); FUNC(2,24); - FUNC(2,25); FUNC(2,26); FUNC(2,27); FUNC(2,28); FUNC(2,29); - FUNC(2,30); FUNC(2,31); FUNC(2,32); FUNC(2,33); FUNC(2,34); - FUNC(2,35); FUNC(2,36); FUNC(2,37); FUNC(2,38); FUNC(2,39); - - FUNC(3,40); FUNC(3,41); FUNC(3,42); FUNC(3,43); FUNC(3,44); - FUNC(3,45); FUNC(3,46); FUNC(3,47); FUNC(3,48); FUNC(3,49); - FUNC(3,50); FUNC(3,51); FUNC(3,52); FUNC(3,53); FUNC(3,54); - FUNC(3,55); FUNC(3,56); FUNC(3,57); FUNC(3,58); FUNC(3,59); - - FUNC(4,60); FUNC(4,61); FUNC(4,62); FUNC(4,63); FUNC(4,64); - FUNC(4,65); FUNC(4,66); FUNC(4,67); FUNC(4,68); FUNC(4,69); - FUNC(4,70); FUNC(4,71); FUNC(4,72); FUNC(4,73); FUNC(4,74); - FUNC(4,75); FUNC(4,76); FUNC(4,77); FUNC(4,78); FUNC(4,79); -#else /* !UNROLL_LOOPS */ - for (i = 0; i < 20; ++i) { - FUNC(1,i); - } - for (i = 20; i < 40; ++i) { - FUNC(2,i); - } - for (i = 40; i < 60; ++i) { - FUNC(3,i); - } - for (i = 60; i < 80; ++i) { - FUNC(4,i); - } -#endif /* !UNROLL_LOOPS */ - sha_info->digest[0] += A; - sha_info->digest[1] += B; - sha_info->digest[2] += C; - sha_info->digest[3] += D; - sha_info->digest[4] += E; -} - -union endianTest { - long Long; - char Char[sizeof(long)]; -}; - -static char isLittleEndian(void) -{ - static union endianTest u; - u.Long = 1; - return (u.Char[0] == 1); -} - -/* change endianness of data */ - -/* count is the number of bytes to do an endian flip */ -static void maybe_byte_reverse(apr_uint32_t *buffer, int count) -{ - int i; - AP_BYTE ct[4], *cp; - - if (isLittleEndian()) { /* do the swap only if it is little endian */ - count /= sizeof(apr_uint32_t); - cp = (AP_BYTE *) buffer; - for (i = 0; i < count; ++i) { - ct[0] = cp[0]; - ct[1] = cp[1]; - ct[2] = cp[2]; - ct[3] = cp[3]; - cp[0] = ct[3]; - cp[1] = ct[2]; - cp[2] = ct[1]; - cp[3] = ct[0]; - cp += sizeof(apr_uint32_t); - } - } -} - -/* initialize the SHA digest */ - -AP_DECLARE(void) ap_SHA1Init(AP_SHA1_CTX *sha_info) -{ - sha_info->digest[0] = 0x67452301L; - sha_info->digest[1] = 0xefcdab89L; - sha_info->digest[2] = 0x98badcfeL; - sha_info->digest[3] = 0x10325476L; - sha_info->digest[4] = 0xc3d2e1f0L; - sha_info->count_lo = 0L; - sha_info->count_hi = 0L; - sha_info->local = 0; -} - -/* update the SHA digest */ - -AP_DECLARE(void) ap_SHA1Update_binary(AP_SHA1_CTX *sha_info, - const unsigned char *buffer, - unsigned int count) -{ - unsigned int i; - - if ((sha_info->count_lo + ((apr_uint32_t) count << 3)) < sha_info->count_lo) { - ++sha_info->count_hi; - } - sha_info->count_lo += (apr_uint32_t) count << 3; - sha_info->count_hi += (apr_uint32_t) count >> 29; - if (sha_info->local) { - i = SHA_BLOCKSIZE - sha_info->local; - if (i > count) { - i = count; - } - memcpy(((AP_BYTE *) sha_info->data) + sha_info->local, buffer, i); - count -= i; - buffer += i; - sha_info->local += i; - if (sha_info->local == SHA_BLOCKSIZE) { - maybe_byte_reverse(sha_info->data, SHA_BLOCKSIZE); - sha_transform(sha_info); - } - else { - return; - } - } - while (count >= SHA_BLOCKSIZE) { - memcpy(sha_info->data, buffer, SHA_BLOCKSIZE); - buffer += SHA_BLOCKSIZE; - count -= SHA_BLOCKSIZE; - maybe_byte_reverse(sha_info->data, SHA_BLOCKSIZE); - sha_transform(sha_info); - } - memcpy(sha_info->data, buffer, count); - sha_info->local = count; -} - -AP_DECLARE(void) ap_SHA1Update(AP_SHA1_CTX *sha_info, const char *buf, - unsigned int count) -{ -#ifdef CHARSET_EBCDIC - int i; - const AP_BYTE *buffer = (const AP_BYTE *) buf; - apr_size_t inbytes_left, outbytes_left; - - if ((sha_info->count_lo + ((apr_uint32_t) count << 3)) < sha_info->count_lo) { - ++sha_info->count_hi; - } - sha_info->count_lo += (apr_uint32_t) count << 3; - sha_info->count_hi += (apr_uint32_t) count >> 29; - /* Is there a remainder of the previous Update operation? */ - if (sha_info->local) { - i = SHA_BLOCKSIZE - sha_info->local; - if (i > count) { - i = count; - } - inbytes_left = outbytes_left = i; - apr_xlate_conv_buffer(ebcdic2ascii_xlate, buffer, &inbytes_left, - ((AP_BYTE *) sha_info->data) + sha_info->local, - &outbytes_left); - count -= i; - buffer += i; - sha_info->local += i; - if (sha_info->local == SHA_BLOCKSIZE) { - maybe_byte_reverse(sha_info->data, SHA_BLOCKSIZE); - sha_transform(sha_info); - } - else { - return; - } - } - while (count >= SHA_BLOCKSIZE) { - inbytes_left = outbytes_left = SHA_BLOCKSIZE; - apr_xlate_conv_buffer(ebcdic2ascii_xlate, buffer, &inbytes_left, - (AP_BYTE *) sha_info->data, &outbytes_left); - buffer += SHA_BLOCKSIZE; - count -= SHA_BLOCKSIZE; - maybe_byte_reverse(sha_info->data, SHA_BLOCKSIZE); - sha_transform(sha_info); - } - inbytes_left = outbytes_left = count; - apr_xlate_conv_buffer(ebcdic2ascii_xlate, buffer, &inbytes_left, - (AP_BYTE *) sha_info->data, &outbytes_left); - sha_info->local = count; -#else - ap_SHA1Update_binary(sha_info, (const unsigned char *) buf, count); -#endif -} - -/* finish computing the SHA digest */ - -AP_DECLARE(void) ap_SHA1Final(unsigned char digest[SHA_DIGESTSIZE], - AP_SHA1_CTX *sha_info) -{ - int count, i, j; - apr_uint32_t lo_bit_count, hi_bit_count, k; - - lo_bit_count = sha_info->count_lo; - hi_bit_count = sha_info->count_hi; - count = (int) ((lo_bit_count >> 3) & 0x3f); - ((AP_BYTE *) sha_info->data)[count++] = 0x80; - if (count > SHA_BLOCKSIZE - 8) { - memset(((AP_BYTE *) sha_info->data) + count, 0, SHA_BLOCKSIZE - count); - maybe_byte_reverse(sha_info->data, SHA_BLOCKSIZE); - sha_transform(sha_info); - memset((AP_BYTE *) sha_info->data, 0, SHA_BLOCKSIZE - 8); - } - else { - memset(((AP_BYTE *) sha_info->data) + count, 0, - SHA_BLOCKSIZE - 8 - count); - } - maybe_byte_reverse(sha_info->data, SHA_BLOCKSIZE); - sha_info->data[14] = hi_bit_count; - sha_info->data[15] = lo_bit_count; - sha_transform(sha_info); - - for (i = 0, j = 0; j < SHA_DIGESTSIZE; i++) { - k = sha_info->digest[i]; - digest[j++] = (unsigned char) ((k >> 24) & 0xff); - digest[j++] = (unsigned char) ((k >> 16) & 0xff); - digest[j++] = (unsigned char) ((k >> 8) & 0xff); - digest[j++] = (unsigned char) (k & 0xff); - } -} - - -AP_DECLARE(void) ap_sha1_base64(const char *clear, int len, char *out) -{ - int l; - AP_SHA1_CTX context; - AP_BYTE digest[SHA_DIGESTSIZE]; - - if (strncmp(clear, AP_SHA1PW_ID, AP_SHA1PW_IDLEN) == 0) { - clear += AP_SHA1PW_IDLEN; - } - - ap_SHA1Init(&context); - ap_SHA1Update(&context, clear, len); - ap_SHA1Final(digest, &context); - - /* private marker. */ - apr_cpystrn(out, AP_SHA1PW_ID, AP_SHA1PW_IDLEN + 1); - - /* SHA1 hash is always 20 chars */ - l = ap_base64encode_binary(out + AP_SHA1PW_IDLEN, digest, sizeof(digest)); - out[l + AP_SHA1PW_IDLEN] = '\0'; - - /* - * output of base64 encoded SHA1 is always 28 chars + AP_SHA1PW_IDLEN - */ -} diff --git a/crypto/apr_sha1.c b/crypto/apr_sha1.c deleted file mode 100644 index 08d8054e..00000000 --- a/crypto/apr_sha1.c +++ /dev/null @@ -1,412 +0,0 @@ -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2000 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" must - * not be used to endorse or promote products derived from this - * software without prior written permission. For written - * permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * nor may "Apache" appear in their name, without prior written - * permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/* - * The exported function: - * - * ap_sha1_base64(const char *clear, int len, char *out); - * - * provides a means to SHA1 crypt/encode a plaintext password in - * a way which makes password files compatible with those commonly - * used in netscape web and ldap installations. It was put together - * by Clinton Wong <clintdw@netcom.com>, who also notes that: - * - * Note: SHA1 support is useful for migration purposes, but is less - * secure than Apache's password format, since Apache's (MD5) - * password format uses a random eight character salt to generate - * one of many possible hashes for the same password. Netscape - * uses plain SHA1 without a salt, so the same password - * will always generate the same hash, making it easier - * to break since the search space is smaller. - * - * See also the documentation in support/SHA1 as to hints on how to - * migrate an existing netscape installation and other supplied utitlites. - * - * This software also makes use of the following component: - * - * NIST Secure Hash Algorithm - * heavily modified by Uwe Hollerbach uh@alumni.caltech edu - * from Peter C. Gutmann's implementation as found in - * Applied Cryptography by Bruce Schneier - * This code is hereby placed in the public domain - */ - -#include "ap_config.h" -#include "ap_sha1.h" -#include "ap_base64.h" -#include "apr_strings.h" -#include "apr_lib.h" -#ifdef CHARSET_EBCDIC -#include "apr_xlate.h" -#endif /*CHARSET_EBCDIC*/ - -/* a bit faster & bigger, if defined */ -#define UNROLL_LOOPS - -/* NIST's proposed modification to SHA, 7/11/94 */ -#define USE_MODIFIED_SHA - -/* SHA f()-functions */ -#define f1(x,y,z) ((x & y) | (~x & z)) -#define f2(x,y,z) (x ^ y ^ z) -#define f3(x,y,z) ((x & y) | (x & z) | (y & z)) -#define f4(x,y,z) (x ^ y ^ z) - -/* SHA constants */ -#define CONST1 0x5a827999L -#define CONST2 0x6ed9eba1L -#define CONST3 0x8f1bbcdcL -#define CONST4 0xca62c1d6L - -/* 32-bit rotate */ - -#define ROT32(x,n) ((x << n) | (x >> (32 - n))) - -#define FUNC(n,i) \ - temp = ROT32(A,5) + f##n(B,C,D) + E + W[i] + CONST##n; \ - E = D; D = C; C = ROT32(B,30); B = A; A = temp - -#define SHA_BLOCKSIZE 64 - -#ifdef CHARSET_EBCDIC -static apr_xlate_t *ebcdic2ascii_xlate; - -AP_DECLARE(apr_status_t) ap_SHA1InitEBCDIC(apr_xlate_t *x) -{ - apr_status_t rv; - int onoff; - - /* Only single-byte conversion is supported. - */ - rv = apr_xlate_get_sb(x, &onoff); - if (rv) { - return rv; - } - if (!onoff) { /* If conversion is not single-byte-only */ - return APR_EINVAL; - } - ebcdic2ascii_xlate = x; - return APR_SUCCESS; -} -#endif - -typedef unsigned char AP_BYTE; - -/* do SHA transformation */ -static void sha_transform(AP_SHA1_CTX *sha_info) -{ - int i; - apr_uint32_t temp, A, B, C, D, E, W[80]; - - for (i = 0; i < 16; ++i) { - W[i] = sha_info->data[i]; - } - for (i = 16; i < 80; ++i) { - W[i] = W[i-3] ^ W[i-8] ^ W[i-14] ^ W[i-16]; -#ifdef USE_MODIFIED_SHA - W[i] = ROT32(W[i], 1); -#endif /* USE_MODIFIED_SHA */ - } - A = sha_info->digest[0]; - B = sha_info->digest[1]; - C = sha_info->digest[2]; - D = sha_info->digest[3]; - E = sha_info->digest[4]; -#ifdef UNROLL_LOOPS - FUNC(1, 0); FUNC(1, 1); FUNC(1, 2); FUNC(1, 3); FUNC(1, 4); - FUNC(1, 5); FUNC(1, 6); FUNC(1, 7); FUNC(1, 8); FUNC(1, 9); - FUNC(1,10); FUNC(1,11); FUNC(1,12); FUNC(1,13); FUNC(1,14); - FUNC(1,15); FUNC(1,16); FUNC(1,17); FUNC(1,18); FUNC(1,19); - - FUNC(2,20); FUNC(2,21); FUNC(2,22); FUNC(2,23); FUNC(2,24); - FUNC(2,25); FUNC(2,26); FUNC(2,27); FUNC(2,28); FUNC(2,29); - FUNC(2,30); FUNC(2,31); FUNC(2,32); FUNC(2,33); FUNC(2,34); - FUNC(2,35); FUNC(2,36); FUNC(2,37); FUNC(2,38); FUNC(2,39); - - FUNC(3,40); FUNC(3,41); FUNC(3,42); FUNC(3,43); FUNC(3,44); - FUNC(3,45); FUNC(3,46); FUNC(3,47); FUNC(3,48); FUNC(3,49); - FUNC(3,50); FUNC(3,51); FUNC(3,52); FUNC(3,53); FUNC(3,54); - FUNC(3,55); FUNC(3,56); FUNC(3,57); FUNC(3,58); FUNC(3,59); - - FUNC(4,60); FUNC(4,61); FUNC(4,62); FUNC(4,63); FUNC(4,64); - FUNC(4,65); FUNC(4,66); FUNC(4,67); FUNC(4,68); FUNC(4,69); - FUNC(4,70); FUNC(4,71); FUNC(4,72); FUNC(4,73); FUNC(4,74); - FUNC(4,75); FUNC(4,76); FUNC(4,77); FUNC(4,78); FUNC(4,79); -#else /* !UNROLL_LOOPS */ - for (i = 0; i < 20; ++i) { - FUNC(1,i); - } - for (i = 20; i < 40; ++i) { - FUNC(2,i); - } - for (i = 40; i < 60; ++i) { - FUNC(3,i); - } - for (i = 60; i < 80; ++i) { - FUNC(4,i); - } -#endif /* !UNROLL_LOOPS */ - sha_info->digest[0] += A; - sha_info->digest[1] += B; - sha_info->digest[2] += C; - sha_info->digest[3] += D; - sha_info->digest[4] += E; -} - -union endianTest { - long Long; - char Char[sizeof(long)]; -}; - -static char isLittleEndian(void) -{ - static union endianTest u; - u.Long = 1; - return (u.Char[0] == 1); -} - -/* change endianness of data */ - -/* count is the number of bytes to do an endian flip */ -static void maybe_byte_reverse(apr_uint32_t *buffer, int count) -{ - int i; - AP_BYTE ct[4], *cp; - - if (isLittleEndian()) { /* do the swap only if it is little endian */ - count /= sizeof(apr_uint32_t); - cp = (AP_BYTE *) buffer; - for (i = 0; i < count; ++i) { - ct[0] = cp[0]; - ct[1] = cp[1]; - ct[2] = cp[2]; - ct[3] = cp[3]; - cp[0] = ct[3]; - cp[1] = ct[2]; - cp[2] = ct[1]; - cp[3] = ct[0]; - cp += sizeof(apr_uint32_t); - } - } -} - -/* initialize the SHA digest */ - -AP_DECLARE(void) ap_SHA1Init(AP_SHA1_CTX *sha_info) -{ - sha_info->digest[0] = 0x67452301L; - sha_info->digest[1] = 0xefcdab89L; - sha_info->digest[2] = 0x98badcfeL; - sha_info->digest[3] = 0x10325476L; - sha_info->digest[4] = 0xc3d2e1f0L; - sha_info->count_lo = 0L; - sha_info->count_hi = 0L; - sha_info->local = 0; -} - -/* update the SHA digest */ - -AP_DECLARE(void) ap_SHA1Update_binary(AP_SHA1_CTX *sha_info, - const unsigned char *buffer, - unsigned int count) -{ - unsigned int i; - - if ((sha_info->count_lo + ((apr_uint32_t) count << 3)) < sha_info->count_lo) { - ++sha_info->count_hi; - } - sha_info->count_lo += (apr_uint32_t) count << 3; - sha_info->count_hi += (apr_uint32_t) count >> 29; - if (sha_info->local) { - i = SHA_BLOCKSIZE - sha_info->local; - if (i > count) { - i = count; - } - memcpy(((AP_BYTE *) sha_info->data) + sha_info->local, buffer, i); - count -= i; - buffer += i; - sha_info->local += i; - if (sha_info->local == SHA_BLOCKSIZE) { - maybe_byte_reverse(sha_info->data, SHA_BLOCKSIZE); - sha_transform(sha_info); - } - else { - return; - } - } - while (count >= SHA_BLOCKSIZE) { - memcpy(sha_info->data, buffer, SHA_BLOCKSIZE); - buffer += SHA_BLOCKSIZE; - count -= SHA_BLOCKSIZE; - maybe_byte_reverse(sha_info->data, SHA_BLOCKSIZE); - sha_transform(sha_info); - } - memcpy(sha_info->data, buffer, count); - sha_info->local = count; -} - -AP_DECLARE(void) ap_SHA1Update(AP_SHA1_CTX *sha_info, const char *buf, - unsigned int count) -{ -#ifdef CHARSET_EBCDIC - int i; - const AP_BYTE *buffer = (const AP_BYTE *) buf; - apr_size_t inbytes_left, outbytes_left; - - if ((sha_info->count_lo + ((apr_uint32_t) count << 3)) < sha_info->count_lo) { - ++sha_info->count_hi; - } - sha_info->count_lo += (apr_uint32_t) count << 3; - sha_info->count_hi += (apr_uint32_t) count >> 29; - /* Is there a remainder of the previous Update operation? */ - if (sha_info->local) { - i = SHA_BLOCKSIZE - sha_info->local; - if (i > count) { - i = count; - } - inbytes_left = outbytes_left = i; - apr_xlate_conv_buffer(ebcdic2ascii_xlate, buffer, &inbytes_left, - ((AP_BYTE *) sha_info->data) + sha_info->local, - &outbytes_left); - count -= i; - buffer += i; - sha_info->local += i; - if (sha_info->local == SHA_BLOCKSIZE) { - maybe_byte_reverse(sha_info->data, SHA_BLOCKSIZE); - sha_transform(sha_info); - } - else { - return; - } - } - while (count >= SHA_BLOCKSIZE) { - inbytes_left = outbytes_left = SHA_BLOCKSIZE; - apr_xlate_conv_buffer(ebcdic2ascii_xlate, buffer, &inbytes_left, - (AP_BYTE *) sha_info->data, &outbytes_left); - buffer += SHA_BLOCKSIZE; - count -= SHA_BLOCKSIZE; - maybe_byte_reverse(sha_info->data, SHA_BLOCKSIZE); - sha_transform(sha_info); - } - inbytes_left = outbytes_left = count; - apr_xlate_conv_buffer(ebcdic2ascii_xlate, buffer, &inbytes_left, - (AP_BYTE *) sha_info->data, &outbytes_left); - sha_info->local = count; -#else - ap_SHA1Update_binary(sha_info, (const unsigned char *) buf, count); -#endif -} - -/* finish computing the SHA digest */ - -AP_DECLARE(void) ap_SHA1Final(unsigned char digest[SHA_DIGESTSIZE], - AP_SHA1_CTX *sha_info) -{ - int count, i, j; - apr_uint32_t lo_bit_count, hi_bit_count, k; - - lo_bit_count = sha_info->count_lo; - hi_bit_count = sha_info->count_hi; - count = (int) ((lo_bit_count >> 3) & 0x3f); - ((AP_BYTE *) sha_info->data)[count++] = 0x80; - if (count > SHA_BLOCKSIZE - 8) { - memset(((AP_BYTE *) sha_info->data) + count, 0, SHA_BLOCKSIZE - count); - maybe_byte_reverse(sha_info->data, SHA_BLOCKSIZE); - sha_transform(sha_info); - memset((AP_BYTE *) sha_info->data, 0, SHA_BLOCKSIZE - 8); - } - else { - memset(((AP_BYTE *) sha_info->data) + count, 0, - SHA_BLOCKSIZE - 8 - count); - } - maybe_byte_reverse(sha_info->data, SHA_BLOCKSIZE); - sha_info->data[14] = hi_bit_count; - sha_info->data[15] = lo_bit_count; - sha_transform(sha_info); - - for (i = 0, j = 0; j < SHA_DIGESTSIZE; i++) { - k = sha_info->digest[i]; - digest[j++] = (unsigned char) ((k >> 24) & 0xff); - digest[j++] = (unsigned char) ((k >> 16) & 0xff); - digest[j++] = (unsigned char) ((k >> 8) & 0xff); - digest[j++] = (unsigned char) (k & 0xff); - } -} - - -AP_DECLARE(void) ap_sha1_base64(const char *clear, int len, char *out) -{ - int l; - AP_SHA1_CTX context; - AP_BYTE digest[SHA_DIGESTSIZE]; - - if (strncmp(clear, AP_SHA1PW_ID, AP_SHA1PW_IDLEN) == 0) { - clear += AP_SHA1PW_IDLEN; - } - - ap_SHA1Init(&context); - ap_SHA1Update(&context, clear, len); - ap_SHA1Final(digest, &context); - - /* private marker. */ - apr_cpystrn(out, AP_SHA1PW_ID, AP_SHA1PW_IDLEN + 1); - - /* SHA1 hash is always 20 chars */ - l = ap_base64encode_binary(out + AP_SHA1PW_IDLEN, digest, sizeof(digest)); - out[l + AP_SHA1PW_IDLEN] = '\0'; - - /* - * output of base64 encoded SHA1 is always 28 chars + AP_SHA1PW_IDLEN - */ -} diff --git a/encoding/ap_base64.c b/encoding/ap_base64.c deleted file mode 100644 index 7a8362fc..00000000 --- a/encoding/ap_base64.c +++ /dev/null @@ -1,311 +0,0 @@ -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2000 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" must - * not be used to endorse or promote products derived from this - * software without prior written permission. For written - * permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * nor may "Apache" appear in their name, without prior written - * permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - * - * Portions of this software are based upon public domain software - * originally written at the National Center for Supercomputing Applications, - * University of Illinois, Urbana-Champaign. - */ - -/* base64 encoder/decoder. Originally part of main/util.c - * but moved here so that support/ab and ap_sha1.c could - * use it. This meant removing the apr_palloc()s and adding - * ugly 'len' functions, which is quite a nasty cost. - */ - -#include "ap_config.h" -#include "ap_base64.h" -#ifdef CHARSET_EBCDIC -#include "apr_xlate.h" -#endif /* CHARSET_EBCDIC */ - -/* aaaack but it's fast and const should make it shared text page. */ -static const unsigned char pr2six[256] = -{ -#ifndef CHARSET_EBCDIC - /* ASCII table */ - 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 62, 64, 64, 64, 63, - 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 64, 64, 64, 64, 64, 64, - 64, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, - 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 64, 64, 64, 64, 64, - 64, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, - 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64 -#else /*CHARSET_EBCDIC*/ - /* EBCDIC table */ - 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 62, 64, - 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, - 64, 63, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, - 64, 26, 27, 28, 29, 30, 31, 32, 33, 34, 64, 64, 64, 64, 64, 64, - 64, 35, 36, 37, 38, 39, 40, 41, 42, 43, 64, 64, 64, 64, 64, 64, - 64, 64, 44, 45, 46, 47, 48, 49, 50, 51, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, - 64, 0, 1, 2, 3, 4, 5, 6, 7, 8, 64, 64, 64, 64, 64, 64, - 64, 9, 10, 11, 12, 13, 14, 15, 16, 17, 64, 64, 64, 64, 64, 64, - 64, 64, 18, 19, 20, 21, 22, 23, 24, 25, 64, 64, 64, 64, 64, 64, - 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 64, 64, 64, 64, 64, 64 -#endif /*CHARSET_EBCDIC*/ -}; - -#ifdef CHARSET_EBCDIC -static apr_xlate_t *xlate_to_ebcdic; -static unsigned char os_toascii[256]; - -AP_DECLARE(apr_status_t) ap_base64init_ebcdic(apr_xlate_t *to_ascii, - apr_xlate_t *to_ebcdic) -{ - int i; - apr_size_t inbytes_left, outbytes_left; - apr_status_t rv; - int onoff; - - /* Only single-byte conversion is supported. - */ - rv = apr_xlate_get_sb(to_ascii, &onoff); - if (rv) { - return rv; - } - if (!onoff) { /* If conversion is not single-byte-only */ - return APR_EINVAL; - } - rv = apr_xlate_get_sb(to_ebcdic, &onoff); - if (rv) { - return rv; - } - if (!onoff) { /* If conversion is not single-byte-only */ - return APR_EINVAL; - } - xlate_to_ebcdic = to_ebcdic; - for (i = 0; i < sizeof(os_toascii); i++) { - os_toascii[i] = i; - } - inbytes_left = outbytes_left = sizeof(os_toascii); - apr_xlate_conv_buffer(to_ascii, os_toascii, &inbytes_left, - os_toascii, &outbytes_left); - - return APR_SUCCESS; -} -#endif /*CHARSET_EBCDIC*/ - -AP_DECLARE(int) ap_base64decode_len(const char *bufcoded) -{ - int nbytesdecoded; - register const unsigned char *bufin; - register int nprbytes; - - bufin = (const unsigned char *) bufcoded; - while (pr2six[*(bufin++)] <= 63); - - nprbytes = (bufin - (const unsigned char *) bufcoded) - 1; - nbytesdecoded = ((nprbytes + 3) / 4) * 3; - - return nbytesdecoded + 1; -} - -AP_DECLARE(int) ap_base64decode(char *bufplain, const char *bufcoded) -{ -#ifdef CHARSET_EBCDIC - apr_size_t inbytes_left, outbytes_left; -#endif /* CHARSET_EBCDIC */ - int len; - - len = ap_base64decode_binary((unsigned char *) bufplain, bufcoded); -#ifdef CHARSET_EBCDIC - inbytes_left = outbytes_left = len; - apr_xlate_conv_buffer(xlate_to_ebcdic, bufplain, &inbytes_left, - bufplain, &outbytes_left); -#endif /* CHARSET_EBCDIC */ - bufplain[len] = '\0'; - return len; -} - -/* This is the same as ap_base64decode() except on EBCDIC machines, where - * the conversion of the output to ebcdic is left out. - */ -AP_DECLARE(int) ap_base64decode_binary(unsigned char *bufplain, - const char *bufcoded) -{ - int nbytesdecoded; - register const unsigned char *bufin; - register unsigned char *bufout; - register int nprbytes; - - bufin = (const unsigned char *) bufcoded; - while (pr2six[*(bufin++)] <= 63); - nprbytes = (bufin - (const unsigned char *) bufcoded) - 1; - nbytesdecoded = ((nprbytes + 3) / 4) * 3; - - bufout = (unsigned char *) bufplain; - bufin = (const unsigned char *) bufcoded; - - while (nprbytes > 4) { - *(bufout++) = - (unsigned char) (pr2six[*bufin] << 2 | pr2six[bufin[1]] >> 4); - *(bufout++) = - (unsigned char) (pr2six[bufin[1]] << 4 | pr2six[bufin[2]] >> 2); - *(bufout++) = - (unsigned char) (pr2six[bufin[2]] << 6 | pr2six[bufin[3]]); - bufin += 4; - nprbytes -= 4; - } - - /* Note: (nprbytes == 1) would be an error, so just ingore that case */ - if (nprbytes > 1) { - *(bufout++) = - (unsigned char) (pr2six[*bufin] << 2 | pr2six[bufin[1]] >> 4); - } - if (nprbytes > 2) { - *(bufout++) = - (unsigned char) (pr2six[bufin[1]] << 4 | pr2six[bufin[2]] >> 2); - } - if (nprbytes > 3) { - *(bufout++) = - (unsigned char) (pr2six[bufin[2]] << 6 | pr2six[bufin[3]]); - } - - nbytesdecoded -= (4 - nprbytes) & 3; - return nbytesdecoded; -} - -static const char basis_64[] = - "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; - -AP_DECLARE(int) ap_base64encode_len(int len) -{ - return ((len + 2) / 3 * 4) + 1; -} - -AP_DECLARE(int) ap_base64encode(char *encoded, const char *string, int len) -{ -#ifndef CHARSET_EBCDIC - return ap_base64encode_binary(encoded, (const unsigned char *) string, len); -#else /* CHARSET_EBCDIC */ - int i; - char *p; - - p = encoded; - for (i = 0; i < len - 2; i += 3) { - *p++ = basis_64[(os_toascii[string[i]] >> 2) & 0x3F]; - *p++ = basis_64[((os_toascii[string[i]] & 0x3) << 4) | - ((int) (os_toascii[string[i + 1]] & 0xF0) >> 4)]; - *p++ = basis_64[((os_toascii[string[i + 1]] & 0xF) << 2) | - ((int) (os_toascii[string[i + 2]] & 0xC0) >> 6)]; - *p++ = basis_64[os_toascii[string[i + 2]] & 0x3F]; - } - if (i < len) { - *p++ = basis_64[(os_toascii[string[i]] >> 2) & 0x3F]; - if (i == (len - 1)) { - *p++ = basis_64[((os_toascii[string[i]] & 0x3) << 4)]; - *p++ = '='; - } - else { - *p++ = basis_64[((os_toascii[string[i]] & 0x3) << 4) | - ((int) (os_toascii[string[i + 1]] & 0xF0) >> 4)]; - *p++ = basis_64[((os_toascii[string[i + 1]] & 0xF) << 2)]; - } - *p++ = '='; - } - - *p++ = '\0'; - return p - encoded; -#endif /* CHARSET_EBCDIC */ -} - -/* This is the same as ap_base64encode() except on EBCDIC machines, where - * the conversion of the input to ascii is left out. - */ -AP_DECLARE(int) ap_base64encode_binary(char *encoded, - const unsigned char *string, int len) -{ - int i; - char *p; - - p = encoded; - for (i = 0; i < len - 2; i += 3) { - *p++ = basis_64[(string[i] >> 2) & 0x3F]; - *p++ = basis_64[((string[i] & 0x3) << 4) | - ((int) (string[i + 1] & 0xF0) >> 4)]; - *p++ = basis_64[((string[i + 1] & 0xF) << 2) | - ((int) (string[i + 2] & 0xC0) >> 6)]; - *p++ = basis_64[string[i + 2] & 0x3F]; - } - if (i < len) { - *p++ = basis_64[(string[i] >> 2) & 0x3F]; - if (i == (len - 1)) { - *p++ = basis_64[((string[i] & 0x3) << 4)]; - *p++ = '='; - } - else { - *p++ = basis_64[((string[i] & 0x3) << 4) | - ((int) (string[i + 1] & 0xF0) >> 4)]; - *p++ = basis_64[((string[i + 1] & 0xF) << 2)]; - } - *p++ = '='; - } - - *p++ = '\0'; - return p - encoded; -} diff --git a/encoding/apr_base64.c b/encoding/apr_base64.c deleted file mode 100644 index 7a8362fc..00000000 --- a/encoding/apr_base64.c +++ /dev/null @@ -1,311 +0,0 @@ -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2000 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" must - * not be used to endorse or promote products derived from this - * software without prior written permission. For written - * permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * nor may "Apache" appear in their name, without prior written - * permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - * - * Portions of this software are based upon public domain software - * originally written at the National Center for Supercomputing Applications, - * University of Illinois, Urbana-Champaign. - */ - -/* base64 encoder/decoder. Originally part of main/util.c - * but moved here so that support/ab and ap_sha1.c could - * use it. This meant removing the apr_palloc()s and adding - * ugly 'len' functions, which is quite a nasty cost. - */ - -#include "ap_config.h" -#include "ap_base64.h" -#ifdef CHARSET_EBCDIC -#include "apr_xlate.h" -#endif /* CHARSET_EBCDIC */ - -/* aaaack but it's fast and const should make it shared text page. */ -static const unsigned char pr2six[256] = -{ -#ifndef CHARSET_EBCDIC - /* ASCII table */ - 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 62, 64, 64, 64, 63, - 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 64, 64, 64, 64, 64, 64, - 64, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, - 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 64, 64, 64, 64, 64, - 64, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, - 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64 -#else /*CHARSET_EBCDIC*/ - /* EBCDIC table */ - 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 62, 64, - 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, - 64, 63, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, - 64, 26, 27, 28, 29, 30, 31, 32, 33, 34, 64, 64, 64, 64, 64, 64, - 64, 35, 36, 37, 38, 39, 40, 41, 42, 43, 64, 64, 64, 64, 64, 64, - 64, 64, 44, 45, 46, 47, 48, 49, 50, 51, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, - 64, 0, 1, 2, 3, 4, 5, 6, 7, 8, 64, 64, 64, 64, 64, 64, - 64, 9, 10, 11, 12, 13, 14, 15, 16, 17, 64, 64, 64, 64, 64, 64, - 64, 64, 18, 19, 20, 21, 22, 23, 24, 25, 64, 64, 64, 64, 64, 64, - 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 64, 64, 64, 64, 64, 64 -#endif /*CHARSET_EBCDIC*/ -}; - -#ifdef CHARSET_EBCDIC -static apr_xlate_t *xlate_to_ebcdic; -static unsigned char os_toascii[256]; - -AP_DECLARE(apr_status_t) ap_base64init_ebcdic(apr_xlate_t *to_ascii, - apr_xlate_t *to_ebcdic) -{ - int i; - apr_size_t inbytes_left, outbytes_left; - apr_status_t rv; - int onoff; - - /* Only single-byte conversion is supported. - */ - rv = apr_xlate_get_sb(to_ascii, &onoff); - if (rv) { - return rv; - } - if (!onoff) { /* If conversion is not single-byte-only */ - return APR_EINVAL; - } - rv = apr_xlate_get_sb(to_ebcdic, &onoff); - if (rv) { - return rv; - } - if (!onoff) { /* If conversion is not single-byte-only */ - return APR_EINVAL; - } - xlate_to_ebcdic = to_ebcdic; - for (i = 0; i < sizeof(os_toascii); i++) { - os_toascii[i] = i; - } - inbytes_left = outbytes_left = sizeof(os_toascii); - apr_xlate_conv_buffer(to_ascii, os_toascii, &inbytes_left, - os_toascii, &outbytes_left); - - return APR_SUCCESS; -} -#endif /*CHARSET_EBCDIC*/ - -AP_DECLARE(int) ap_base64decode_len(const char *bufcoded) -{ - int nbytesdecoded; - register const unsigned char *bufin; - register int nprbytes; - - bufin = (const unsigned char *) bufcoded; - while (pr2six[*(bufin++)] <= 63); - - nprbytes = (bufin - (const unsigned char *) bufcoded) - 1; - nbytesdecoded = ((nprbytes + 3) / 4) * 3; - - return nbytesdecoded + 1; -} - -AP_DECLARE(int) ap_base64decode(char *bufplain, const char *bufcoded) -{ -#ifdef CHARSET_EBCDIC - apr_size_t inbytes_left, outbytes_left; -#endif /* CHARSET_EBCDIC */ - int len; - - len = ap_base64decode_binary((unsigned char *) bufplain, bufcoded); -#ifdef CHARSET_EBCDIC - inbytes_left = outbytes_left = len; - apr_xlate_conv_buffer(xlate_to_ebcdic, bufplain, &inbytes_left, - bufplain, &outbytes_left); -#endif /* CHARSET_EBCDIC */ - bufplain[len] = '\0'; - return len; -} - -/* This is the same as ap_base64decode() except on EBCDIC machines, where - * the conversion of the output to ebcdic is left out. - */ -AP_DECLARE(int) ap_base64decode_binary(unsigned char *bufplain, - const char *bufcoded) -{ - int nbytesdecoded; - register const unsigned char *bufin; - register unsigned char *bufout; - register int nprbytes; - - bufin = (const unsigned char *) bufcoded; - while (pr2six[*(bufin++)] <= 63); - nprbytes = (bufin - (const unsigned char *) bufcoded) - 1; - nbytesdecoded = ((nprbytes + 3) / 4) * 3; - - bufout = (unsigned char *) bufplain; - bufin = (const unsigned char *) bufcoded; - - while (nprbytes > 4) { - *(bufout++) = - (unsigned char) (pr2six[*bufin] << 2 | pr2six[bufin[1]] >> 4); - *(bufout++) = - (unsigned char) (pr2six[bufin[1]] << 4 | pr2six[bufin[2]] >> 2); - *(bufout++) = - (unsigned char) (pr2six[bufin[2]] << 6 | pr2six[bufin[3]]); - bufin += 4; - nprbytes -= 4; - } - - /* Note: (nprbytes == 1) would be an error, so just ingore that case */ - if (nprbytes > 1) { - *(bufout++) = - (unsigned char) (pr2six[*bufin] << 2 | pr2six[bufin[1]] >> 4); - } - if (nprbytes > 2) { - *(bufout++) = - (unsigned char) (pr2six[bufin[1]] << 4 | pr2six[bufin[2]] >> 2); - } - if (nprbytes > 3) { - *(bufout++) = - (unsigned char) (pr2six[bufin[2]] << 6 | pr2six[bufin[3]]); - } - - nbytesdecoded -= (4 - nprbytes) & 3; - return nbytesdecoded; -} - -static const char basis_64[] = - "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; - -AP_DECLARE(int) ap_base64encode_len(int len) -{ - return ((len + 2) / 3 * 4) + 1; -} - -AP_DECLARE(int) ap_base64encode(char *encoded, const char *string, int len) -{ -#ifndef CHARSET_EBCDIC - return ap_base64encode_binary(encoded, (const unsigned char *) string, len); -#else /* CHARSET_EBCDIC */ - int i; - char *p; - - p = encoded; - for (i = 0; i < len - 2; i += 3) { - *p++ = basis_64[(os_toascii[string[i]] >> 2) & 0x3F]; - *p++ = basis_64[((os_toascii[string[i]] & 0x3) << 4) | - ((int) (os_toascii[string[i + 1]] & 0xF0) >> 4)]; - *p++ = basis_64[((os_toascii[string[i + 1]] & 0xF) << 2) | - ((int) (os_toascii[string[i + 2]] & 0xC0) >> 6)]; - *p++ = basis_64[os_toascii[string[i + 2]] & 0x3F]; - } - if (i < len) { - *p++ = basis_64[(os_toascii[string[i]] >> 2) & 0x3F]; - if (i == (len - 1)) { - *p++ = basis_64[((os_toascii[string[i]] & 0x3) << 4)]; - *p++ = '='; - } - else { - *p++ = basis_64[((os_toascii[string[i]] & 0x3) << 4) | - ((int) (os_toascii[string[i + 1]] & 0xF0) >> 4)]; - *p++ = basis_64[((os_toascii[string[i + 1]] & 0xF) << 2)]; - } - *p++ = '='; - } - - *p++ = '\0'; - return p - encoded; -#endif /* CHARSET_EBCDIC */ -} - -/* This is the same as ap_base64encode() except on EBCDIC machines, where - * the conversion of the input to ascii is left out. - */ -AP_DECLARE(int) ap_base64encode_binary(char *encoded, - const unsigned char *string, int len) -{ - int i; - char *p; - - p = encoded; - for (i = 0; i < len - 2; i += 3) { - *p++ = basis_64[(string[i] >> 2) & 0x3F]; - *p++ = basis_64[((string[i] & 0x3) << 4) | - ((int) (string[i + 1] & 0xF0) >> 4)]; - *p++ = basis_64[((string[i + 1] & 0xF) << 2) | - ((int) (string[i + 2] & 0xC0) >> 6)]; - *p++ = basis_64[string[i + 2] & 0x3F]; - } - if (i < len) { - *p++ = basis_64[(string[i] >> 2) & 0x3F]; - if (i == (len - 1)) { - *p++ = basis_64[((string[i] & 0x3) << 4)]; - *p++ = '='; - } - else { - *p++ = basis_64[((string[i] & 0x3) << 4) | - ((int) (string[i + 1] & 0xF0) >> 4)]; - *p++ = basis_64[((string[i + 1] & 0xF) << 2)]; - } - *p++ = '='; - } - - *p++ = '\0'; - return p - encoded; -} diff --git a/hooks/ap_hooks.c b/hooks/ap_hooks.c deleted file mode 100644 index fa4dac61..00000000 --- a/hooks/ap_hooks.c +++ /dev/null @@ -1,291 +0,0 @@ -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2000 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" must - * not be used to endorse or promote products derived from this - * software without prior written permission. For written - * permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * nor may "Apache" appear in their name, without prior written - * permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -#include "ap_config.h" -#include "ap_hooks.h" -#include <assert.h> - -#if 0 -#define apr_palloc(pool,size) malloc(size) -#endif - -AP_DECLARE_DATA apr_pool_t *ap_global_hook_pool = NULL; -AP_DECLARE_DATA int ap_debug_module_hooks = FALSE; -AP_DECLARE_DATA const char *ap_debug_module_name = NULL; - -/* NB: This must echo the LINK_##name structure */ -typedef struct -{ - void (*dummy)(void *); - const char *szName; - const char * const *aszPredecessors; - const char * const *aszSuccessors; - int nOrder; -} TSortData; - -typedef struct tsort_ -{ - void *pData; - int nPredecessors; - struct tsort_ **ppPredecessors; - struct tsort_ *pNext; -} TSort; - -static int crude_order(const void *a_,const void *b_) -{ - const TSortData *a=a_; - const TSortData *b=b_; - - return a->nOrder-b->nOrder; -} - -static TSort *prepare(apr_pool_t *p,TSortData *pItems,int nItems) -{ - TSort *pData=apr_palloc(p,nItems*sizeof *pData); - int n; - - qsort(pItems,nItems,sizeof *pItems,crude_order); - for(n=0 ; n < nItems ; ++n) { - pData[n].nPredecessors=0; - pData[n].ppPredecessors=apr_pcalloc(p,nItems*sizeof *pData[n].ppPredecessors); - pData[n].pNext=NULL; - pData[n].pData=&pItems[n]; - } - - for(n=0 ; n < nItems ; ++n) { - int i,k; - - for(i=0 ; pItems[n].aszPredecessors && pItems[n].aszPredecessors[i] ; ++i) - for(k=0 ; k < nItems ; ++k) - if(!strcmp(pItems[k].szName,pItems[n].aszPredecessors[i])) { - int l; - - for(l=0 ; l < pData[n].nPredecessors ; ++l) - if(pData[n].ppPredecessors[l] == &pData[k]) - goto got_it; - pData[n].ppPredecessors[pData[n].nPredecessors]=&pData[k]; - ++pData[n].nPredecessors; - got_it: - break; - } - for(i=0 ; pItems[n].aszSuccessors && pItems[n].aszSuccessors[i] ; ++i) - for(k=0 ; k < nItems ; ++k) - if(!strcmp(pItems[k].szName,pItems[n].aszSuccessors[i])) { - int l; - - for(l=0 ; l < pData[k].nPredecessors ; ++l) - if(pData[k].ppPredecessors[l] == &pData[n]) - goto got_it2; - pData[k].ppPredecessors[pData[k].nPredecessors]=&pData[n]; - ++pData[k].nPredecessors; - got_it2: - break; - } - } - - return pData; -} - -static TSort *tsort(TSort *pData,int nItems) -{ - int nTotal; - TSort *pHead=NULL; - TSort *pTail=NULL; - - for(nTotal=0 ; nTotal < nItems ; ++nTotal) { - int n,i,k; - - for(n=0 ; ; ++n) { - if(n == nItems) - assert(0); /* // we have a loop... */ - if(!pData[n].pNext && !pData[n].nPredecessors) - break; - } - if(pTail) - pTail->pNext=&pData[n]; - else - pHead=&pData[n]; - pTail=&pData[n]; - pTail->pNext=pTail; /* // fudge it so it looks linked */ - for(i=0 ; i < nItems ; ++i) - for(k=0 ; pData[i].ppPredecessors[k] ; ++k) - if(pData[i].ppPredecessors[k] == &pData[n]) { - --pData[i].nPredecessors; - break; - } - } - pTail->pNext=NULL; /* // unfudge the tail */ - return pHead; -} - -static apr_array_header_t *sort_hook(apr_array_header_t *pHooks,const char *szName) -{ - apr_pool_t *p; - TSort *pSort; - apr_array_header_t *pNew; - int n; - - apr_create_pool(&p, ap_global_hook_pool); - pSort=prepare(p,(TSortData *)pHooks->elts,pHooks->nelts); - pSort=tsort(pSort,pHooks->nelts); - pNew=apr_make_array(ap_global_hook_pool,pHooks->nelts,sizeof(TSortData)); - if(ap_debug_module_hooks) - printf("Sorting %s:",szName); - for(n=0 ; pSort ; pSort=pSort->pNext,++n) { - TSortData *pHook; - assert(n < pHooks->nelts); - pHook=apr_push_array(pNew); - memcpy(pHook,pSort->pData,sizeof *pHook); - if(ap_debug_module_hooks) - printf(" %s",pHook->szName); - } - if(ap_debug_module_hooks) - fputc('\n',stdout); - return pNew; -} - -static apr_array_header_t *s_aHooksToSort; -typedef struct -{ - const char *szHookName; - apr_array_header_t **paHooks; -} HookSortEntry; - -AP_DECLARE(void) ap_hook_sort_register(const char *szHookName, - apr_array_header_t **paHooks) -{ - HookSortEntry *pEntry; - - if(!s_aHooksToSort) - s_aHooksToSort=apr_make_array(ap_global_hook_pool,1,sizeof(HookSortEntry)); - pEntry=apr_push_array(s_aHooksToSort); - pEntry->szHookName=szHookName; - pEntry->paHooks=paHooks; -} - -AP_DECLARE(void) ap_sort_hooks() -{ - int n; - - for(n=0 ; n < s_aHooksToSort->nelts ; ++n) { - HookSortEntry *pEntry=&((HookSortEntry *)s_aHooksToSort->elts)[n]; - *pEntry->paHooks=sort_hook(*pEntry->paHooks,pEntry->szHookName); - } -} - -AP_DECLARE(void) ap_hook_deregister_all(void) -{ - int n; - - for(n=0 ; n < s_aHooksToSort->nelts ; ++n) { - HookSortEntry *pEntry=&((HookSortEntry *)s_aHooksToSort->elts)[n]; - *pEntry->paHooks=NULL; - } - s_aHooksToSort=NULL; -} - -AP_DECLARE(void) ap_show_hook(const char *szName,const char * const *aszPre, - const char * const *aszSucc) -{ - int nFirst; - - printf(" Hooked %s",szName); - if(aszPre) { - fputs(" pre(",stdout); - nFirst=1; - while(*aszPre) { - if(!nFirst) - fputc(',',stdout); - nFirst=0; - fputs(*aszPre,stdout); - ++aszPre; - } - fputc(')',stdout); - } - if(aszSucc) { - fputs(" succ(",stdout); - nFirst=1; - while(*aszSucc) { - if(!nFirst) - fputc(',',stdout); - nFirst=0; - fputs(*aszSucc,stdout); - ++aszSucc; - } - fputc(')',stdout); - } - fputc('\n',stdout); -} - -#if 0 -void main() -{ - const char *aszAPre[]={"b","c",NULL}; - const char *aszBPost[]={"a",NULL}; - const char *aszCPost[]={"b",NULL}; - TSortData t1[]= - { - { "a",aszAPre,NULL }, - { "b",NULL,aszBPost }, - { "c",NULL,aszCPost } - }; - TSort *pResult; - - pResult=prepare(t1,3); - pResult=tsort(pResult,3); - - for( ; pResult ; pResult=pResult->pNext) - printf("%s\n",pResult->pData->szName); -} -#endif diff --git a/hooks/apr_hooks.c b/hooks/apr_hooks.c deleted file mode 100644 index fa4dac61..00000000 --- a/hooks/apr_hooks.c +++ /dev/null @@ -1,291 +0,0 @@ -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2000 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" must - * not be used to endorse or promote products derived from this - * software without prior written permission. For written - * permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * nor may "Apache" appear in their name, without prior written - * permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -#include "ap_config.h" -#include "ap_hooks.h" -#include <assert.h> - -#if 0 -#define apr_palloc(pool,size) malloc(size) -#endif - -AP_DECLARE_DATA apr_pool_t *ap_global_hook_pool = NULL; -AP_DECLARE_DATA int ap_debug_module_hooks = FALSE; -AP_DECLARE_DATA const char *ap_debug_module_name = NULL; - -/* NB: This must echo the LINK_##name structure */ -typedef struct -{ - void (*dummy)(void *); - const char *szName; - const char * const *aszPredecessors; - const char * const *aszSuccessors; - int nOrder; -} TSortData; - -typedef struct tsort_ -{ - void *pData; - int nPredecessors; - struct tsort_ **ppPredecessors; - struct tsort_ *pNext; -} TSort; - -static int crude_order(const void *a_,const void *b_) -{ - const TSortData *a=a_; - const TSortData *b=b_; - - return a->nOrder-b->nOrder; -} - -static TSort *prepare(apr_pool_t *p,TSortData *pItems,int nItems) -{ - TSort *pData=apr_palloc(p,nItems*sizeof *pData); - int n; - - qsort(pItems,nItems,sizeof *pItems,crude_order); - for(n=0 ; n < nItems ; ++n) { - pData[n].nPredecessors=0; - pData[n].ppPredecessors=apr_pcalloc(p,nItems*sizeof *pData[n].ppPredecessors); - pData[n].pNext=NULL; - pData[n].pData=&pItems[n]; - } - - for(n=0 ; n < nItems ; ++n) { - int i,k; - - for(i=0 ; pItems[n].aszPredecessors && pItems[n].aszPredecessors[i] ; ++i) - for(k=0 ; k < nItems ; ++k) - if(!strcmp(pItems[k].szName,pItems[n].aszPredecessors[i])) { - int l; - - for(l=0 ; l < pData[n].nPredecessors ; ++l) - if(pData[n].ppPredecessors[l] == &pData[k]) - goto got_it; - pData[n].ppPredecessors[pData[n].nPredecessors]=&pData[k]; - ++pData[n].nPredecessors; - got_it: - break; - } - for(i=0 ; pItems[n].aszSuccessors && pItems[n].aszSuccessors[i] ; ++i) - for(k=0 ; k < nItems ; ++k) - if(!strcmp(pItems[k].szName,pItems[n].aszSuccessors[i])) { - int l; - - for(l=0 ; l < pData[k].nPredecessors ; ++l) - if(pData[k].ppPredecessors[l] == &pData[n]) - goto got_it2; - pData[k].ppPredecessors[pData[k].nPredecessors]=&pData[n]; - ++pData[k].nPredecessors; - got_it2: - break; - } - } - - return pData; -} - -static TSort *tsort(TSort *pData,int nItems) -{ - int nTotal; - TSort *pHead=NULL; - TSort *pTail=NULL; - - for(nTotal=0 ; nTotal < nItems ; ++nTotal) { - int n,i,k; - - for(n=0 ; ; ++n) { - if(n == nItems) - assert(0); /* // we have a loop... */ - if(!pData[n].pNext && !pData[n].nPredecessors) - break; - } - if(pTail) - pTail->pNext=&pData[n]; - else - pHead=&pData[n]; - pTail=&pData[n]; - pTail->pNext=pTail; /* // fudge it so it looks linked */ - for(i=0 ; i < nItems ; ++i) - for(k=0 ; pData[i].ppPredecessors[k] ; ++k) - if(pData[i].ppPredecessors[k] == &pData[n]) { - --pData[i].nPredecessors; - break; - } - } - pTail->pNext=NULL; /* // unfudge the tail */ - return pHead; -} - -static apr_array_header_t *sort_hook(apr_array_header_t *pHooks,const char *szName) -{ - apr_pool_t *p; - TSort *pSort; - apr_array_header_t *pNew; - int n; - - apr_create_pool(&p, ap_global_hook_pool); - pSort=prepare(p,(TSortData *)pHooks->elts,pHooks->nelts); - pSort=tsort(pSort,pHooks->nelts); - pNew=apr_make_array(ap_global_hook_pool,pHooks->nelts,sizeof(TSortData)); - if(ap_debug_module_hooks) - printf("Sorting %s:",szName); - for(n=0 ; pSort ; pSort=pSort->pNext,++n) { - TSortData *pHook; - assert(n < pHooks->nelts); - pHook=apr_push_array(pNew); - memcpy(pHook,pSort->pData,sizeof *pHook); - if(ap_debug_module_hooks) - printf(" %s",pHook->szName); - } - if(ap_debug_module_hooks) - fputc('\n',stdout); - return pNew; -} - -static apr_array_header_t *s_aHooksToSort; -typedef struct -{ - const char *szHookName; - apr_array_header_t **paHooks; -} HookSortEntry; - -AP_DECLARE(void) ap_hook_sort_register(const char *szHookName, - apr_array_header_t **paHooks) -{ - HookSortEntry *pEntry; - - if(!s_aHooksToSort) - s_aHooksToSort=apr_make_array(ap_global_hook_pool,1,sizeof(HookSortEntry)); - pEntry=apr_push_array(s_aHooksToSort); - pEntry->szHookName=szHookName; - pEntry->paHooks=paHooks; -} - -AP_DECLARE(void) ap_sort_hooks() -{ - int n; - - for(n=0 ; n < s_aHooksToSort->nelts ; ++n) { - HookSortEntry *pEntry=&((HookSortEntry *)s_aHooksToSort->elts)[n]; - *pEntry->paHooks=sort_hook(*pEntry->paHooks,pEntry->szHookName); - } -} - -AP_DECLARE(void) ap_hook_deregister_all(void) -{ - int n; - - for(n=0 ; n < s_aHooksToSort->nelts ; ++n) { - HookSortEntry *pEntry=&((HookSortEntry *)s_aHooksToSort->elts)[n]; - *pEntry->paHooks=NULL; - } - s_aHooksToSort=NULL; -} - -AP_DECLARE(void) ap_show_hook(const char *szName,const char * const *aszPre, - const char * const *aszSucc) -{ - int nFirst; - - printf(" Hooked %s",szName); - if(aszPre) { - fputs(" pre(",stdout); - nFirst=1; - while(*aszPre) { - if(!nFirst) - fputc(',',stdout); - nFirst=0; - fputs(*aszPre,stdout); - ++aszPre; - } - fputc(')',stdout); - } - if(aszSucc) { - fputs(" succ(",stdout); - nFirst=1; - while(*aszSucc) { - if(!nFirst) - fputc(',',stdout); - nFirst=0; - fputs(*aszSucc,stdout); - ++aszSucc; - } - fputc(')',stdout); - } - fputc('\n',stdout); -} - -#if 0 -void main() -{ - const char *aszAPre[]={"b","c",NULL}; - const char *aszBPost[]={"a",NULL}; - const char *aszCPost[]={"b",NULL}; - TSortData t1[]= - { - { "a",aszAPre,NULL }, - { "b",NULL,aszBPost }, - { "c",NULL,aszCPost } - }; - TSort *pResult; - - pResult=prepare(t1,3); - pResult=tsort(pResult,3); - - for( ; pResult ; pResult=pResult->pNext) - printf("%s\n",pResult->pData->szName); -} -#endif diff --git a/include/apr_base64.h b/include/apr_base64.h deleted file mode 100644 index dc4f42d0..00000000 --- a/include/apr_base64.h +++ /dev/null @@ -1,143 +0,0 @@ -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2000 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" must - * not be used to endorse or promote products derived from this - * software without prior written permission. For written - * permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * nor may "Apache" appear in their name, without prior written - * permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - * - * The apr_vsnprintf/apr_snprintf functions are based on, and used with the - * permission of, the SIO stdio-replacement strx_* functions by Panos - * Tsirigotis <panos@alumni.cs.colorado.edu> for xinetd. - */ - -#ifndef APACHE_BASE64_H -#define APACHE_BASE64_H - -#include "ap_config.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @package Base64 Encoding - */ - -/* Simple BASE64 encode/decode functions. - * - * As we might encode binary strings, hence we require the length of - * the incoming plain source. And return the length of what we decoded. - * - * The decoding function takes any non valid char (i.e. whitespace, \0 - * or anything non A-Z,0-9 etc as terminal. - * - * plain strings/binary sequences are not assumed '\0' terminated. Encoded - * strings are neither. But probably should. - * - */ - -/** - * Given the length of an un-encrypted string, get the length of the encrypted string. - * @param the length of an unencrypted string. - * @return the length of the string after it is encrypted - * @deffunc int ap_base64encode_len(int len) - */ -AP_DECLARE(int) ap_base64encode_len(int len); - -/** - * Encode a text string using base64encoding. - * @param The destination string for the encoded string. - * @param The original string in plain text - * @param The length of the plain text string - * @return the length of the encoded string - * @deffunc int ap_base64encode(char *coded_dst, const char *plain_src, int len_plain_src) - */ -AP_DECLARE(int) ap_base64encode(char * coded_dst, const char *plain_src,int len_plain_src); - -/** - * Encode an EBCDIC string using base64encoding. - * @param The destination string for the encoded string. - * @param The original string in plain text - * @param The length of the plain text string - * @return the length of the encoded string - * @deffunc int ap_base64encode_binary(char *coded_dst, const char *plain_src, int len_plain_src) - */ -AP_DECLARE(int) ap_base64encode_binary(char * coded_dst, const unsigned char *plain_src,int len_plain_src); - -/** - * Determine the length of a plain text string given the encoded version - * @param The encoded string - * @return the length of the plain text string - * @deffunc int ap_base64decode_len(const char *coded_src) - */ -AP_DECLARE(int) ap_base64decode_len(const char * coded_src); - -/** - * Decode a string to plain text - * @param The destination string for the plain text - * @param The encoded string - * @return the length of the plain text string - * @deffunc int ap_base64decode(char *plain_dst, const char *coded_src) - */ -AP_DECLARE(int) ap_base64decode(char * plain_dst, const char *coded_src); - -/** - * Decode an EBCDIC string to plain text - * @param The destination string for the plain text - * @param The encoded string - * @return the length of the plain text string - * @deffunc int ap_base64decode_binary(char *plain_dst, const char *coded_src) - */ -AP_DECLARE(int) ap_base64decode_binary(unsigned char * plain_dst, const char *coded_src); - -#ifdef __cplusplus -} -#endif - -#endif /* !APACHE_BASE64_H */ diff --git a/include/apr_buckets.h b/include/apr_buckets.h deleted file mode 100644 index b8c2e4af..00000000 --- a/include/apr_buckets.h +++ /dev/null @@ -1,754 +0,0 @@ -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2000 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" must - * not be used to endorse or promote products derived from this - * software without prior written permission. For written - * permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * nor may "Apache" appear in their name, without prior written - * permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -#ifndef AP_BUCKETS_H -#define AP_BUCKETS_H - -#include "httpd.h" -#include "apr_general.h" -#include "apr_mmap.h" -#include "apr_errno.h" -#include "ap_ring.h" -#ifdef HAVE_SYS_UIO_H -#include <sys/uio.h> /* for struct iovec */ -#endif -#ifdef HAVE_STDARG_H -#include <stdarg.h> -#endif - -/** - * @package Bucket Brigades - */ - -typedef enum {AP_NONBLOCK_READ, AP_BLOCK_READ} ap_read_type; - -/* - * The one-sentence buzzword-laden overview: Bucket brigades represent - * a complex data stream that can be passed through a layered IO - * system without unnecessary copying. A longer overview follows... - * - * A bucket brigade is a doubly linked list of buckets, so we - * aren't limited to inserting at the front and removing at the end. - * Buckets are only passed around as members of a brigade, although - * singleton buckets can occur for short periods of time. - * - * Buckets are data stores of varous types. They can refer to data in - * memory, or part of a file or mmap area, or the output of a process, - * etc. Buckets also have some type-dependent accessor functions: - * read, split, setaside, and destroy. - * - * read returns the address and size of the data in the bucket. If the - * data isn't in memory then it is read in and the bucket changes type - * so that it can refer to the new location of the data. If all the - * data doesn't fit in the bucket then a new bucket is inserted into - * the brigade to hold the rest of it. - * - * split divides the data in a bucket into two regions. After a split - * the original bucket refers to the first part of the data and a new - * bucket inserted into the brigade after the original bucket refers - * to the second part of the data. Reference counts are maintained as - * necessary. - * - * setaside ensures that the data in the bucket has a long enough - * lifetime. Sometimes it is convenient to create a bucket referring - * to data on the stack in the expectation that it will be consumed - * (output to the network) before the stack is unwound. If that - * expectation turns out not to be valid, the setaside function is - * called to move the data somewhere safer. - * - * destroy maintains the reference counts on the resources used by a - * bucket and frees them if necessary. - * - * To write a bucket brigade, they are first made into an iovec, so that we - * don't write too little data at one time. Currently we ignore compacting the - * buckets into as few buckets as possible, but if we really want good - * performance, then we need to compact the buckets before we convert to an - * iovec, or possibly while we are converting to an iovec. - */ - -/* The types of bucket brigades the code knows about. We don't really need - * this enum. All access to the bucket brigades is done through function - * pointers in the bucket type. - */ - -/** - * Forward declaration of the main types. - */ - -typedef struct ap_bucket_brigade ap_bucket_brigade; - -typedef struct ap_bucket ap_bucket; - -typedef struct ap_bucket_type ap_bucket_type; -struct ap_bucket_type { - /** - * The name of the bucket type - */ - const char *name; - /** - * The number of functions this bucket understands. Can not be less than - * four. - */ - int num_func; - /** - * Free the private data and any resources used by the bucket - * (if they aren't shared with another bucket). - * @param data The private data pointer from the bucket to be destroyed - */ - void (*destroy)(void *data); - - /** Read the data from the bucket. - * @param b The bucket to read from - * @param str A place to store the data read. Allocation should only be - * done if absolutely necessary. - * @param len The amount of data read. - * @param block Should this read function block if there is more data that - * cannot be read immediately. - * @deffunc apr_status_t read(ap_bucket *b, const char **str, apr_size_t *len, ap_read_type block) - */ - apr_status_t (*read)(ap_bucket *b, const char **str, apr_size_t *len, ap_read_type block); - - /** Make it possible to set aside the data. For most bucket types this is - * a no-op; buckets containing data that dies when the stack is un-wound - * must convert the bucket into a heap bucket. - * @param e The bucket to convert - * @deffunc apr_status_t setaside(ap_bucket *e) - */ - apr_status_t (*setaside)(ap_bucket *e); - - /** Split one bucket in two at the specified position - * @param e The bucket to split - * @param point The offset of the first byte in the new bucket - * @deffunc apr_status_t split(ap_bucket *e, apr_off_t point) - */ - apr_status_t (*split)(ap_bucket *e, apr_off_t point); -}; - -/** - * ap_bucket_t structures are allocated on the malloc() heap and - * their lifetime is controlled by the parent ap_bucket_brigade - * structure. Buckets can move from one brigade to another e.g. by - * calling ap_brigade_concat(). In general the data in a bucket has - * the same lifetime as the bucket and is freed when the bucket is - * destroyed; if the data is shared by more than one bucket (e.g. - * after a split) the data is freed when the last bucket goes away. - */ -struct ap_bucket { - /** Links to the rest of the brigade */ - AP_RING_ENTRY(ap_bucket) link; - /** The type of bucket. */ - const ap_bucket_type *type; - /** The length of the data in the bucket. This could have been implemented - * with a function, but this is an optimization, because the most - * common thing to do will be to get the length. If the length is unknown, - * the value of this field will be -1. - */ - apr_off_t length; - /** type-dependent data hangs off this pointer */ - void *data; -}; - -/** A list of buckets */ -struct ap_bucket_brigade { - /** The pool to associate the brigade with. The data is not allocated out - * of the pool, but a cleanup is registered with this pool. If the - * brigade is destroyed by some mechanism other than pool destruction, - * the destroying function is responsible for killing the cleanup. - */ - apr_pool_t *p; - /** The buckets in the brigade are on this list. */ - /* - * XXX: the ap_bucket_list structure doesn't actually need a name tag - * because it has no existence independent of struct ap_bucket_brigade; - * the ring macros are designed so that you can leave the name tag - * argument empty in this situation but apparently the Windows compiler - * doesn't like that. - */ - AP_RING_HEAD(ap_bucket_list, ap_bucket) list; -}; - -/** - * Wrappers around the RING macros to reduce the verbosity of the code - * that handles bucket brigades. - */ -#define AP_BRIGADE_SENTINEL(b) AP_RING_SENTINEL(&(b)->list, ap_bucket, link) - -#define AP_BRIGADE_EMPTY(b) AP_RING_EMPTY(&(b)->list, ap_bucket, link) - -#define AP_BRIGADE_FIRST(b) AP_RING_FIRST(&(b)->list) -#define AP_BRIGADE_LAST(b) AP_RING_LAST(&(b)->list) - -#define AP_BRIGADE_FOREACH(e, b) \ - AP_RING_FOREACH((e), &(b)->list, ap_bucket, link) - -#define AP_BRIGADE_INSERT_HEAD(b, e) \ - AP_RING_INSERT_HEAD(&(b)->list, (e), ap_bucket, link) -#define AP_BRIGADE_INSERT_TAIL(b, e) \ - AP_RING_INSERT_TAIL(&(b)->list, (e), ap_bucket, link) - -#define AP_BRIGADE_CONCAT(a, b) \ - AP_RING_CONCAT(&(a)->list, &(b)->list, ap_bucket, link) - -#define AP_BUCKET_INSERT_BEFORE(a, b) \ - AP_RING_INSERT_BEFORE((a), (b), link) -#define AP_BUCKET_INSERT_AFTER(a, b) \ - AP_RING_INSERT_AFTER((a), (b), link) - -#define AP_BUCKET_NEXT(e) AP_RING_NEXT((e), link) -#define AP_BUCKET_PREV(e) AP_RING_PREV((e), link) - -#define AP_BUCKET_REMOVE(e) AP_RING_REMOVE((e), link) - -#define AP_BUCKET_IS_FLUSH(e) (e->type == &ap_flush_type) -#define AP_BUCKET_IS_EOS(e) (e->type == &ap_eos_type) -#define AP_BUCKET_IS_FILE(e) (e->type == &ap_file_type) -#define AP_BUCKET_IS_PIPE(e) (e->type == &ap_pipe_type) -#define AP_BUCKET_IS_SOCKET(e) (e->type == &ap_socket_type) -#define AP_BUCKET_IS_HEAP(e) (e->type == &ap_heap_type) -#define AP_BUCKET_IS_TRANSIENT(e) (e->type == &ap_transient_type) -#define AP_BUCKET_IS_IMMORTAL(e) (e->type == &ap_immortal_type) -#define AP_BUCKET_IS_MMAP(e) (e->type == &ap_mmap_type) -#define AP_BUCKET_IS_POOL(e) (e->type == &ap_pool_type) - -/** - * General-purpose reference counting for the varous bucket types. - * - * Any bucket type that keeps track of the resources it uses (i.e. - * most of them except for IMMORTAL, TRANSIENT, and EOS) needs to - * attach a reference count to the resource so that it can be freed - * when the last bucket that uses it goes away. Resource-sharing may - * occur because of bucket splits or buckets that refer to globally - * cached data. */ - -/** - * The structure used to manage the shared resource must start with an - * ap_bucket_refcount which is updated by the general-purpose refcount - * code. A pointer to the bucket-type-dependent private data structure - * can be cast to a pointer to an ap_bucket_refcount and vice versa. - */ -typedef struct ap_bucket_refcount ap_bucket_refcount; -struct ap_bucket_refcount { - int refcount; -}; - -/** - * The data pointer of a refcounted bucket points to an - * ap_bucket_shared structure which describes the region of the shared - * object that this bucket refers to. The ap_bucket_shared isn't a - * fully-fledged bucket type: it is a utility type that proper bucket - * types are based on. - */ -typedef struct ap_bucket_shared ap_bucket_shared; -struct ap_bucket_shared { - /** start of the data in the bucket relative to the private base pointer */ - apr_off_t start; - /** end of the data in the bucket relative to the private base pointer */ - apr_off_t end; - /** pointer to the real private data of the bucket, - * which starts with an ap_bucket_refcount */ - void *data; -}; - - -/* ***** Non-reference-counted bucket types ***** */ - - -typedef struct ap_bucket_simple ap_bucket_simple; - -/** - * TRANSIENT and IMMORTAL buckets don't have much to do with looking - * after the memory that they refer to so they share a lot of their - * implementation. - */ -struct ap_bucket_simple { - /** The start of the data in the bucket */ - const char *start; - /** The end of the data in the bucket */ - const char *end; -}; - -typedef struct ap_bucket_pool ap_bucket_pool; - -/** - * A bucket referring to data allocated out of a pool - */ -struct ap_bucket_pool { - /** Number of buckets using this memory */ - ap_bucket_refcount refcount; - /** The start of the data actually allocated. This should never be - * modified, it is only used to free the bucket. - */ - const char *base; - /** The pool the data was allocated out of */ - apr_pool_t *p; - /** This is a hack, because we call ap_destroy_bucket with the ->data - * pointer, so the pool cleanup needs to be registered with that pointer, - * but the whole point of the cleanup is to convert the bucket to another - * type. To do that conversion, we need a pointer to the bucket itself. - * This gives us a pointer to the original bucket. - */ - ap_bucket *b; -}; - -/* ***** Reference-counted bucket types ***** */ - - -typedef struct ap_bucket_heap ap_bucket_heap; - -/** - * A bucket referring to data allocated off the heap. - */ -struct ap_bucket_heap { - /** Number of buckets using this memory */ - ap_bucket_refcount refcount; - /** The start of the data actually allocated. This should never be - * modified, it is only used to free the bucket. - */ - char *base; - /** how much memory was allocated. This may not be necessary */ - size_t alloc_len; -}; - -typedef struct ap_bucket_mmap ap_bucket_mmap; - -/** - * A bucket referring to an mmap()ed file - */ -struct ap_bucket_mmap { - /** Number of buckets using this memory */ - ap_bucket_refcount refcount; - /** The mmap this sub_bucket refers to */ - apr_mmap_t *mmap; -}; - -typedef struct ap_bucket_file ap_bucket_file; - -/** - * A bucket referring to an file - */ -struct ap_bucket_file { - /** The file this bucket refers to */ - apr_file_t *fd; - /** The offset into the file */ - apr_off_t offset; -}; - -/* ***** Bucket Brigade Functions ***** */ - -/** - * Create a new bucket brigade. The bucket brigade is originally empty. - * @param The pool to associate with the brigade. Data is not allocated out - * of the pool, but a cleanup is registered. - * @return The empty bucket brigade - * @deffunc ap_bucket_brigade *ap_brigade_create(apr_pool_t *p) - */ -AP_DECLARE(ap_bucket_brigade *) ap_brigade_create(apr_pool_t *p); - -/** - * destroy an entire bucket brigade. This includes destroying all of the - * buckets within the bucket brigade's bucket list. - * @param b The bucket brigade to destroy - * @deffunc apr_status_t ap_brigade_destroy(ap_bucket_brigade *b) - */ -AP_DECLARE(apr_status_t) ap_brigade_destroy(ap_bucket_brigade *b); - -/** - * Split a bucket brigade into two, such that the given bucket is the - * first in the new bucket brigade. This function is useful when a - * filter wants to pass only the initial part of a brigade to the next - * filter. - * @param b The brigade to split - * @param e The first element of the new brigade - * @return The new brigade - * @deffunc ap_bucket_brigade *ap_brigade_split(ap_bucket_brigade *b, ap_bucket *e) - */ -AP_DECLARE(ap_bucket_brigade *) ap_brigade_split(ap_bucket_brigade *b, - ap_bucket *e); - -/** - * consume nbytes from beginning of b -- call ap_bucket_destroy as - * appropriate, and/or modify start on last element - * @param b The brigade to consume data from - * @param nbytes The number of bytes to consume - * @deffunc void ap_brigade_consume(ap_bucket_brigade *b, int nbytes) */ -AP_DECLARE(void) ap_brigade_consume(ap_bucket_brigade *b, int nbytes); - -/** - * create an iovec of the elements in a bucket_brigade... return number - * of elements used. This is useful for writing to a file or to the - * network efficiently. - * @param The bucket brigade to create the iovec out of - * @param The iovec to create - * @param The number of elements in the iovec - * @return The number of iovec elements actually filled out. - * @deffunc int ap_brigade_to_iovec(ap_bucket_brigade *b, struct iovec *vec, int nvec); - */ -AP_DECLARE(int) ap_brigade_to_iovec(ap_bucket_brigade *b, - struct iovec *vec, int nvec); - -/** - * This function writes a list of strings into a bucket brigade. We just - * allocate a new heap bucket for each string. - * @param b The bucket brigade to add to - * @param va A list of strings to add - * @return The number of bytes added to the brigade - * @deffunc int ap_brigade_vputstrs(ap_bucket_brigade *b, va_list va) - */ -AP_DECLARE(int) ap_brigade_vputstrs(ap_bucket_brigade *b, va_list va); - -/** - * This function writes an unspecified number of strings into a bucket brigade. - * We just allocate a new heap bucket for each string. - * @param b The bucket brigade to add to - * @param ... The strings to add - * @return The number of bytes added to the brigade - * @deffunc int ap_brigade_putstrs(ap_bucket_brigade *b, ...) - */ -AP_DECLARE_NONSTD(int) ap_brigade_putstrs(ap_bucket_brigade *b, ...); - -/** - * Evaluate a printf and put the resulting string into a bucket at the end - * of the bucket brigade. - * @param b The brigade to write to - * @param fmt The format of the string to write - * @param ... The arguments to fill out the format - * @return The number of bytes added to the brigade - * @deffunc int ap_brigade_printf(ap_bucket_brigade *b, const char *fmt, ...) - */ -AP_DECLARE_NONSTD(int) ap_brigade_printf(ap_bucket_brigade *b, const char *fmt, ...); - -/** - * Evaluate a printf and put the resulting string into a bucket at the end - * of the bucket brigade. - * @param b The brigade to write to - * @param fmt The format of the string to write - * @param va The arguments to fill out the format - * @return The number of bytes added to the brigade - * @deffunc int ap_brigade_vprintf(ap_bucket_brigade *b, const char *fmt, va_list va) - */ -AP_DECLARE(int) ap_brigade_vprintf(ap_bucket_brigade *b, const char *fmt, va_list va); - - -/* ***** Bucket Functions ***** */ - -/** - * Initialize the core implemented bucket types. Once this is done, - * it is possible to add new bucket types to the server - * @param p The pool to allocate the array out of. - * @deffunc void ap_init_bucket_types(apr_pool_t *p) - */ -void ap_init_bucket_types(apr_pool_t *p); - -/** - * free the resources used by a bucket. If multiple buckets refer to - * the same resource it is freed when the last one goes away. - * @param e The bucket to destroy - * @deffunc void ap_bucket_destroy(ap_bucket *e) - */ -#define ap_bucket_destroy(e) \ - { \ - e->type->destroy(e->data); \ - free(e); \ - } - -/** - * read the data from the bucket - * @param e The bucket to read from - * @param str The location to store the data in - * @param len The amount of data read - * @param block Whether the read function blocks - * @deffunc apr_status_t ap_bucket_read(ap_bucket *e, const char **str, apr_size_t *len, ap_read_type block) - */ -#define ap_bucket_read(e,str,len,block) e->type->read(e, str, len, block) - -/** - * Setaside data so that stack data is not destroyed on returning from - * the function - * @param e The bucket to setaside - * @deffunc apr_status_t ap_bucket_setaside(ap_bucket *e) - */ -#define ap_bucket_setaside(e) e->type->setaside(e) - -/** - * Split one bucket in two. - * @param e The bucket to split - * @param point The location to split the bucket at - * @deffunc apr_status_t ap_bucket_split(ap_bucket *e, apr_off_t point) - */ -#define ap_bucket_split(e,point) e->type->split(e, point) - - -/* Bucket type handling */ - -AP_DECLARE_NONSTD(apr_status_t) ap_bucket_setaside_notimpl(ap_bucket *data); -AP_DECLARE_NONSTD(apr_status_t) ap_bucket_split_notimpl(ap_bucket *data, - apr_off_t point); -AP_DECLARE_NONSTD(void) ap_bucket_destroy_notimpl(void *data); -/* There is no ap_bucket_read_notimpl, because it is a required function - */ -int ap_insert_bucket_type(const ap_bucket_type *type); - -/* All of the bucket types implemented by the core */ -extern const ap_bucket_type ap_flush_type; -extern const ap_bucket_type ap_eos_type; -extern const ap_bucket_type ap_file_type; -extern const ap_bucket_type ap_heap_type; -extern const ap_bucket_type ap_mmap_type; -extern const ap_bucket_type ap_pool_type; -extern const ap_bucket_type ap_pipe_type; -extern const ap_bucket_type ap_immortal_type; -extern const ap_bucket_type ap_transient_type; -extern const ap_bucket_type ap_socket_type; - - -/* ***** Shared reference-counted buckets ***** */ - -/** - * Initialize a bucket containing reference-counted data that may be - * shared. The caller must allocate the bucket if necessary and - * initialize its type-dependent fields, and allocate and initialize - * its own private data structure. This function should only be called - * by type-specific bucket creation functions. - * @param b The bucket to initialize, - * or NULL if a new one should be allocated - * @param data A pointer to the private data structure - * with the reference count at the start - * @param start The start of the data in the bucket - * relative to the private base pointer - * @param end The end of the data in the bucket - * relative to the private base pointer - * @return The new bucket, or NULL if allocation failed - * @deffunc AP_DECLARE(ap_bucket *) ap_bucket_shared_create(ap_bucket_refcount *r, apr_off_t start, apr_off_t end) */ -AP_DECLARE(ap_bucket *) ap_bucket_make_shared(ap_bucket *b, void *data, - apr_off_t start, apr_off_t end); - -/** - * Decrement the refcount of the data in the bucket and free the - * ap_bucket_shared structure. This function should only be called by - * type-specific bucket destruction functions. - * @param data The private data pointer from the bucket to be destroyed - * @return NULL if nothing needs to be done, - * otherwise a pointer to the private data structure which - * must be destroyed because its reference count is zero - * @deffunc AP_DECLARE(void *) ap_bucket_shared_destroy(ap_bucket *b) */ -AP_DECLARE(void *) ap_bucket_destroy_shared(void *data); - -/** - * Split a bucket into two at the given point, and adjust the refcount - * to the underlying data. Most reference-counting bucket types will - * be able to use this function as their split function without any - * additional type-specific handling. - * @param b The bucket to be split - * @param point The offset of the first byte in the new bucket - * @return APR_EINVAL if the point is not within the bucket; - * APR_ENOMEM if allocation failed; - * or APR_SUCCESS - * @deffunc AP_DECLARE(apr_status_t) ap_bucket_shared_split(ap_bucket *b, apr_off_t point) - */ -AP_DECLARE_NONSTD(apr_status_t) ap_bucket_split_shared(ap_bucket *b, apr_off_t point); - - -/* ***** Functions to Create Buckets of varying type ***** */ - -/** - * Each bucket type foo has two initialization functions: - * ap_bucket_make_foo which sets up some already-allocated memory as a - * bucket of type foo; and ap_bucket_create_foo which allocates memory - * for the bucket, calls ap_bucket_make_foo, and initializes the - * bucket's list pointers. The ap_bucket_make_foo functions are used - * inside the bucket code to change the type of buckets in place; - * other code should call ap_bucket_create_foo. All the initialization - * functions change nothing if they fail. - */ - -/* - * This macro implements the guts of ap_bucket_create_foo - */ -#define ap_bucket_do_create(do_make) \ - do { \ - ap_bucket *b, *ap__b; \ - b = calloc(1, sizeof(*b)); \ - if (b == NULL) { \ - return NULL; \ - } \ - ap__b = do_make; \ - if (ap__b == NULL) { \ - free(b); \ - return NULL; \ - } \ - AP_RING_ELEM_INIT(ap__b, link); \ - return ap__b; \ - } while(0) - - -/** - * Create an End of Stream bucket. This indicates that there is no more data - * coming from down the filter stack. All filters should flush at this point. - * @return The new bucket, or NULL if allocation failed - * @deffunc ap_bucket *ap_bucket_create_eos(void) - */ -AP_DECLARE(ap_bucket *) ap_bucket_create_eos(void); -AP_DECLARE(ap_bucket *) ap_bucket_make_eos(ap_bucket *b); - -/** - * Create a flush bucket. This indicates that filters should flush their - * data. There is no guarantee that they will flush it, but this is the - * best we can do. - * @return The new bucket, or NULL if allocation failed - * @deffunc ap_bucket *ap_bucket_create_flush(void) - */ -AP_DECLARE(ap_bucket *) ap_bucket_create_flush(void); -AP_DECLARE(ap_bucket *) ap_bucket_make_flush(ap_bucket *b); - -/** - * Create a bucket referring to long-lived data. - * @param buf The data to insert into the bucket - * @param nbyte The size of the data to insert. - * @return The new bucket, or NULL if allocation failed - * @deffunc ap_bucket *ap_bucket_create_transient(const char *buf, apr_size_t nbyte, apr_size_t *w) - */ -AP_DECLARE(ap_bucket *) ap_bucket_create_immortal( - const char *buf, apr_size_t nbyte); -AP_DECLARE(ap_bucket *) ap_bucket_make_immortal(ap_bucket *b, - const char *buf, apr_size_t nbyte); - -/** - * Create a bucket referring to data on the stack. - * @param buf The data to insert into the bucket - * @param nbyte The size of the data to insert. - * @return The new bucket, or NULL if allocation failed - * @deffunc ap_bucket *ap_bucket_create_transient(const char *buf, apr_size_t nbyte, apr_size_t *w) - */ -AP_DECLARE(ap_bucket *) ap_bucket_create_transient( - const char *buf, apr_size_t nbyte); -AP_DECLARE(ap_bucket *) ap_bucket_make_transient(ap_bucket *b, - const char *buf, apr_size_t nbyte); - -/** - * Create a bucket referring to memory on the heap. If the caller asks - * for the data to be copied, this function always allocates 4K of - * memory so that more data can be added to the bucket without - * requiring another allocation. Therefore not all the data may be put - * into the bucket. If copying is not requested then the bucket takes - * over responsibility for free()ing the memory. - * @param buf The buffer to insert into the bucket - * @param nbyte The size of the buffer to insert. - * @param copy Whether to copy the data into newly-allocated memory or not - * @param w The number of bytes actually copied into the bucket. - * If copy is zero then this return value can be ignored by passing a NULL pointer. - * @return The new bucket, or NULL if allocation failed - * @deffunc ap_bucket *ap_bucket_create_heap(const char *buf, apr_size_t nbyte, int copy, apr_size_t *w) - */ -AP_DECLARE(ap_bucket *) ap_bucket_create_heap( - const char *buf, apr_size_t nbyte, int copy, apr_size_t *w); -AP_DECLARE(ap_bucket *) ap_bucket_make_heap(ap_bucket *b, - const char *buf, apr_size_t nbyte, int copy, apr_size_t *w); - -/** - * Create a bucket referring to memory allocated out of a pool. - * @param buf The buffer to insert into the bucket - * @param p The pool the memory was allocated out of - * @return The new bucket, or NULL if allocation failed - * @deffunc ap_bucket *ap_bucket_create_pool(const char *buf, apr_size_t *length, apr_pool_t *p) - */ -AP_DECLARE(ap_bucket *) ap_bucket_create_pool(const char *buf, - apr_size_t length, apr_pool_t *p); -AP_DECLARE(ap_bucket *) ap_bucket_make_pool(ap_bucket *b, - const char *buf, apr_size_t length, apr_pool_t *p); - -/** - * Create a bucket referring to mmap()ed memory. - * @param mmap The mmap to insert into the bucket - * @param start The offset of the first byte in the mmap - * that this bucket refers to - * @param length The number of bytes referred to by this bucket - * @return The new bucket, or NULL if allocation failed - * @deffunc ap_bucket *ap_bucket_create_mmap(const apr_mmap_t *buf, apr_size_t nbyte, apr_size_t *w) - */ -AP_DECLARE(ap_bucket *) ap_bucket_create_mmap( - apr_mmap_t *mm, apr_off_t start, apr_size_t length); -AP_DECLARE(ap_bucket *) ap_bucket_make_mmap(ap_bucket *b, - apr_mmap_t *mm, apr_off_t start, apr_size_t length); - -/** - * Create a bucket referring to a socket. - * @param thissocket The socket to put in the bucket - * @return The new bucket, or NULL if allocation failed - * @deffunc ap_bucket *ap_bucket_create_socket(apr_socket_t *thissocket) - */ -AP_DECLARE(ap_bucket *) ap_bucket_create_socket(apr_socket_t *thissock); -AP_DECLARE(ap_bucket *) ap_bucket_make_socket(ap_bucket *b, apr_socket_t *thissock); - -/** - * Create a bucket referring to a pipe. - * @param thispipe The pipe to put in the bucket - * @return The new bucket, or NULL if allocation failed - * @deffunc ap_bucket *ap_bucket_create_pipe(apr_file_t *thispipe) - */ -AP_DECLARE(ap_bucket *) ap_bucket_create_pipe(apr_file_t *thispipe); -AP_DECLARE(ap_bucket *) ap_bucket_make_pipe(ap_bucket *b, apr_file_t *thispipe); - -/** - * Create a bucket referring to a file. - * @param fd The file to put in the bucket - * @param offset The offset where the data of interest begins in the file - * @param len The amount of data in the file we are interested in - * @return The new bucket, or NULL if allocation failed - * @deffunc ap_bucket *ap_bucket_create_file(apr_file_t *thispipe) - */ -AP_DECLARE(ap_bucket *) ap_bucket_create_file(apr_file_t *fd, apr_off_t offset, apr_size_t len); -AP_DECLARE(ap_bucket *) ap_bucket_make_file(ap_bucket *b, apr_file_t *fd, - apr_off_t offset, apr_size_t len); - -#endif /* !AP_BUCKETS_H */ diff --git a/include/apr_hooks.h b/include/apr_hooks.h deleted file mode 100644 index eeec6f0d..00000000 --- a/include/apr_hooks.h +++ /dev/null @@ -1,246 +0,0 @@ -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2000 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" must - * not be used to endorse or promote products derived from this - * software without prior written permission. For written - * permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * nor may "Apache" appear in their name, without prior written - * permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -#ifndef APACHE_AP_HOOKS_H -#define APACHE_AP_HOOKS_H - -#include "ap_config.h" - -/* For apr_array_header_t */ -#include "apr_lib.h" - -/** - * @package Apache hooks functions - */ - -#define AP_DECLARE_EXTERNAL_HOOK(link,ret,name,args) \ -typedef ret HOOK_##name args; \ -link##_DECLARE(void) ap_hook_##name(HOOK_##name *pf, const char* const* aszPre, \ - const char * const *aszSucc, int nOrder); \ -link##_DECLARE(ret) ap_run_##name args; \ -typedef struct _LINK_##name \ - { \ - HOOK_##name *pFunc; \ - const char *szName; \ - const char * const *aszPredecessors; \ - const char * const *aszSuccessors; \ - int nOrder; \ - } LINK_##name; - -#define AP_DECLARE_HOOK(ret,name,args) \ -AP_DECLARE_EXTERNAL_HOOK(AP,ret,name,args) - -#define AP_HOOK_STRUCT(members) \ -static struct { members } _hooks; - -#define AP_HOOK_LINK(name) \ - apr_array_header_t *link_##name; - -#define AP_IMPLEMENT_EXTERNAL_HOOK_BASE(link,name) \ -link##_DECLARE(void) ap_hook_##name(HOOK_##name *pf,const char * const *aszPre, \ - const char * const *aszSucc,int nOrder) \ - { \ - LINK_##name *pHook; \ - if(!_hooks.link_##name) \ - { \ - _hooks.link_##name=apr_make_array(ap_global_hook_pool,1,sizeof(LINK_##name)); \ - ap_hook_sort_register(#name,&_hooks.link_##name); \ - } \ - pHook=apr_push_array(_hooks.link_##name); \ - pHook->pFunc=pf; \ - pHook->aszPredecessors=aszPre; \ - pHook->aszSuccessors=aszSucc; \ - pHook->nOrder=nOrder; \ - pHook->szName=ap_debug_module_name; \ - if(ap_debug_module_hooks) \ - ap_show_hook(#name,aszPre,aszSucc); \ - } - -#define AP_IMPLEMENT_HOOK_BASE(name) \ -AP_IMPLEMENT_EXTERNAL_HOOK_BASE(AP,name) - -/* RUN_ALL runs to the first one to return other than ok or decline - RUN_FIRST runs to the first one to return other than decline - VOID runs all -*/ - -#define AP_IMPLEMENT_EXTERNAL_HOOK_VOID(link,name,args_decl,args_use) \ -AP_IMPLEMENT_EXTERNAL_HOOK_BASE(link,name) \ -link##_DECLARE(void) ap_run_##name args_decl \ - { \ - LINK_##name *pHook; \ - int n; \ -\ - if(!_hooks.link_##name) \ - return; \ -\ - pHook=(LINK_##name *)_hooks.link_##name->elts; \ - for(n=0 ; n < _hooks.link_##name->nelts ; ++n) \ - pHook[n].pFunc args_use; \ - } - -#define AP_IMPLEMENT_HOOK_VOID(name,args_decl,args_use) \ -AP_IMPLEMENT_EXTERNAL_HOOK_VOID(AP,name,args_decl,args_use) - -/* FIXME: note that this returns ok when nothing is run. I suspect it should - really return decline, but that breaks Apache currently - Ben -*/ -#define AP_IMPLEMENT_EXTERNAL_HOOK_RUN_ALL(link,ret,name,args_decl,args_use,ok,decline) \ -AP_IMPLEMENT_EXTERNAL_HOOK_BASE(link,name) \ -link##_DECLARE(ret) ap_run_##name args_decl \ - { \ - LINK_##name *pHook; \ - int n; \ - ret rv; \ -\ - if(!_hooks.link_##name) \ - return ok; \ -\ - pHook=(LINK_##name *)_hooks.link_##name->elts; \ - for(n=0 ; n < _hooks.link_##name->nelts ; ++n) \ - { \ - rv=pHook[n].pFunc args_use; \ -\ - if(rv != ok && rv != decline) \ - return rv; \ - } \ - return ok; \ - } - -#define AP_IMPLEMENT_HOOK_RUN_ALL(ret,name,args_decl,args_use,ok,decline) \ -AP_IMPLEMENT_EXTERNAL_HOOK_RUN_ALL(AP,ret,name,args_decl,args_use,ok,decline) - -#define AP_IMPLEMENT_EXTERNAL_HOOK_RUN_FIRST(link,ret,name,args_decl,args_use,decline) \ -AP_IMPLEMENT_EXTERNAL_HOOK_BASE(link,name) \ -link##_DECLARE(ret) ap_run_##name args_decl \ - { \ - LINK_##name *pHook; \ - int n; \ - ret rv; \ -\ - if(!_hooks.link_##name) \ - return decline; \ -\ - pHook=(LINK_##name *)_hooks.link_##name->elts; \ - for(n=0 ; n < _hooks.link_##name->nelts ; ++n) \ - { \ - rv=pHook[n].pFunc args_use; \ -\ - if(rv != decline) \ - return rv; \ - } \ - return decline; \ - } - -#define AP_IMPLEMENT_HOOK_RUN_FIRST(ret,name,args_decl,args_use,decline) \ -AP_IMPLEMENT_EXTERNAL_HOOK_RUN_FIRST(AP,ret,name,args_decl,args_use,decline) - - /* Hook orderings */ -#define AP_HOOK_REALLY_FIRST (-10) -#define AP_HOOK_FIRST 0 -#define AP_HOOK_MIDDLE 10 -#define AP_HOOK_LAST 20 -#define AP_HOOK_REALLY_LAST 30 - -/** - * The global pool used to allocate any memory needed by the hooks. - * @defvar apr_pool_t *ap_global_hook_pool - */ -extern AP_DECLARE_DATA apr_pool_t *ap_global_hook_pool; - -/** - * A global variable to determine if debugging information about the - * hooks functions should be printed - * @defvar apr_pool_t *ap_debug_module_hooks - */ -extern AP_DECLARE_DATA int ap_debug_module_hooks; - -/** - * The name of the module that is currently registering a function - * @defvar apr_pool_t *ap_debug_module_name - */ -extern AP_DECLARE_DATA const char *ap_debug_module_name; - -/** - * Register a hook function to be sorted - * @param szHookName The name of the Hook the function is registered for - * @param aHooks The array which stores all of the functions for this hook - * @deffunc void ap_hook_sort_register(const char *szHookName, ap_arry_header_t **aHooks) - */ -AP_DECLARE(void) ap_hook_sort_register(const char *szHookName, - apr_array_header_t **aHooks); -/** - * Sort all of the registerd functions for a given hook - * @deffunc void ap_sort_hooks(void) - */ -AP_DECLARE(void) ap_sort_hooks(void); - -/** - * Print all of the information about the current hook. This is used for - * debugging purposes. - * @param szName The name of the hook - * @param aszPre All of the functions in the predecessor array - * @param aszSucc All of the functions in the successor array - * @deffunc void ap_show_hook(const char *szName, const char *const *aszPre, const char *const *aszSucc) - */ -AP_DECLARE(void) ap_show_hook(const char *szName,const char * const *aszPre, - const char * const *aszSucc); - -/** - * Remove all currently registered functions. - * @deffunc void ap_hook_deregister_all(void) - */ -AP_DECLARE(void) ap_hook_deregister_all(void); - -#endif /* ndef(AP_HOOKS_H) */ diff --git a/include/apr_ring.h b/include/apr_ring.h deleted file mode 100644 index 614c28e6..00000000 --- a/include/apr_ring.h +++ /dev/null @@ -1,274 +0,0 @@ -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2000 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" must - * not be used to endorse or promote products derived from this - * software without prior written permission. For written - * permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * nor may "Apache" appear in their name, without prior written - * permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/* - * This code draws heavily from the 4.4BSD <sys/queue.h> macros - * and Dean Gaudet's "splim/ring.h". - * <http://www.freebsd.org/cgi/cvsweb.cgi/src/sys/sys/queue.h> - * <http://www.arctic.org/~dean/splim/> - * - * We'd use Dean's code directly if we could guarantee the - * availability of inline functions. - */ - -#ifndef AP_RING_H -#define AP_RING_H - -/* - * for offsetof() - */ -#include <stddef.h> - -/* - * A ring is a kind of doubly-linked list that can be manipulated - * without knowing where its head is. - */ - -/* - * A struct on a ring contains a field linking it to the other - * elements in the ring, e.g. - * - * struct my_item_t { - * AP_RING_ENTRY(my_item_t) link; - * int foo; - * char *bar; - * }; - * - * A struct may be put on more than one ring if it has more than one - * AP_RING_ENTRY field. - */ -#define AP_RING_ENTRY(elem) \ - struct { \ - struct elem *next; \ - struct elem *prev; \ - } - -/* - * Each ring is managed via its head, which is a struct declared like this: - * - * AP_RING_HEAD(my_ring_t, my_item_t); - * struct my_ring_t ring, *ringp; - * - * This struct looks just like the element link struct so that we can - * be sure that the typecasting games will work as expected. - * - * The first element in the ring is next after the head, and the last - * element is just before the head. - */ -#define AP_RING_HEAD(head, elem) \ - struct head { \ - struct elem *next; \ - struct elem *prev; \ - } - -/* - * The head itself isn't an element, but in order to get rid of all - * the special cases when dealing with the ends of the ring, we play - * typecasting games to make it look like one. The sentinel is the - * magic pointer value that occurs before the first and after the last - * elements in the ring, computed from the address of the ring's head. - * - * Note that for strict C standards compliance you should put the - * AP_RING_ENTRY first in struct elem unless the head is always part - * of a larger object with enough earlier fields to accommodate the - * offsetof() computed below. You can usually ignore this caveat. - */ -#define AP_RING_SENTINEL(hp, elem, link) \ - (struct elem *)((char *)(hp) - offsetof(struct elem, link)) - -/* - * Accessor macros. Use these rather than footling inside the - * structures directly so that you can more easily change to a - * different flavour of list from BSD's <sys/queue.h>. - */ -#define AP_RING_FIRST(hp) (hp)->next -#define AP_RING_LAST(hp) (hp)->prev -#define AP_RING_NEXT(ep, link) (ep)->link.next -#define AP_RING_PREV(ep, link) (ep)->link.prev - -/* - * Empty rings and singleton elements. - */ -#define AP_RING_INIT(hp, elem, link) do { \ - AP_RING_FIRST((hp)) = AP_RING_SENTINEL((hp), elem, link); \ - AP_RING_LAST((hp)) = AP_RING_SENTINEL((hp), elem, link); \ - } while (0) - -#define AP_RING_EMPTY(hp, elem, link) \ - (AP_RING_FIRST((hp)) == AP_RING_SENTINEL((hp), elem, link)) - -#define AP_RING_ELEM_INIT(ep, link) do { \ - AP_RING_NEXT((ep), link) = (ep); \ - AP_RING_PREV((ep), link) = (ep); \ - } while (0) - -/* - * Adding elements. - */ -#define AP_RING_SPLICE_BEFORE(lep, ep1, epN, link) do { \ - AP_RING_NEXT((epN), link) = (lep); \ - AP_RING_PREV((ep1), link) = AP_RING_PREV((lep), link); \ - AP_RING_NEXT(AP_RING_PREV((lep), link), link) = (ep1); \ - AP_RING_PREV((lep), link) = (epN); \ - } while (0) - -#define AP_RING_SPLICE_AFTER(lep, ep1, epN, link) do { \ - AP_RING_PREV((ep1), link) = (lep); \ - AP_RING_NEXT((epN), link) = AP_RING_NEXT((lep), link); \ - AP_RING_PREV(AP_RING_NEXT((lep), link), link) = (epN); \ - AP_RING_NEXT((lep), link) = (ep1); \ - } while (0) - -#define AP_RING_INSERT_BEFORE(lep, nep, link) \ - AP_RING_SPLICE_BEFORE((lep), (nep), (nep), link) - -#define AP_RING_INSERT_AFTER(lep, nep, link) \ - AP_RING_SPLICE_AFTER((lep), (nep), (nep), link) - -/* - * These macros work when the ring is empty: inserting before the head - * or after the tail of an empty ring using the macros above doesn't work. - */ -#define AP_RING_SPLICE_HEAD(hp, ep1, epN, elem, link) \ - AP_RING_SPLICE_AFTER(AP_RING_SENTINEL((hp), elem, link), \ - (ep1), (epN), link) - -#define AP_RING_SPLICE_TAIL(hp, ep1, epN, elem, link) \ - AP_RING_SPLICE_BEFORE(AP_RING_SENTINEL((hp), elem, link), \ - (ep1), (epN), link) - -#define AP_RING_INSERT_HEAD(hp, nep, elem, link) \ - AP_RING_SPLICE_HEAD((hp), (nep), (nep), elem, link) - -#define AP_RING_INSERT_TAIL(hp, nep, elem, link) \ - AP_RING_SPLICE_TAIL((hp), (nep), (nep), elem, link) - -/* - * Concatenating ring h2 onto the end of ring h1 leaves h2 empty. - */ -#define AP_RING_CONCAT(h1, h2, elem, link) do { \ - if (!AP_RING_EMPTY((h2), elem, link)) { \ - AP_RING_SPLICE_BEFORE(AP_RING_SENTINEL((h1), elem, link), \ - AP_RING_FIRST((h2)), \ - AP_RING_LAST((h2)), link); \ - AP_RING_INIT((h2), elem, link); \ - } \ - } while (0) - -/* - * Removing elements. Be warned that the unspliced elements are left - * with dangling pointers at either end! - */ -#define AP_RING_UNSPLICE(ep1, epN, link) do { \ - AP_RING_NEXT(AP_RING_PREV((ep1), link), link) = \ - AP_RING_NEXT((epN), link); \ - AP_RING_PREV(AP_RING_NEXT((epN), link), link) = \ - AP_RING_PREV((ep1), link); \ - } while (0) - -#define AP_RING_REMOVE(ep, link) \ - AP_RING_UNSPLICE((ep), (ep), link) - -/* - * Iteration. - */ -#define AP_RING_FOREACH(ep, hp, elem, link) \ - for ((ep) = AP_RING_FIRST((hp)); \ - (ep) != AP_RING_SENTINEL((hp), elem, link); \ - (ep) = AP_RING_NEXT((ep), link)) - -#define AP_RING_FOREACH_REVERSE(ep, hp, elem, link) \ - for ((ep) = AP_RING_LAST((hp)); \ - (ep) != AP_RING_SENTINEL((hp), elem, link); \ - (ep) = AP_RING_PREV((ep), link)) - -#ifdef AP_RING_DEBUG -#include <stdio.h> -#define AP_RING_CHECK_ONE(msg, ptr) \ - fprintf(stderr, "*** %s %p\n", msg, ptr) -#define AP_RING_CHECK(hp, elem, link, msg) \ - AP_RING_CHECK_ELEM(AP_RING_SENTINEL(hp, elem, link), elem, link, msg) -#define AP_RING_CHECK_ELEM(ep, elem, link, msg) do { \ - struct elem *start = (ep); \ - struct elem *this = start; \ - fprintf(stderr, "*** ring check start -- %s\n", msg); \ - do { \ - fprintf(stderr, "\telem %p\n", this); \ - fprintf(stderr, "\telem->next %p\n", \ - AP_RING_NEXT(this, link)); \ - fprintf(stderr, "\telem->prev %p\n", \ - AP_RING_PREV(this, link)); \ - fprintf(stderr, "\telem->next->prev %p\n", \ - AP_RING_PREV(AP_RING_NEXT(this, link), link)); \ - fprintf(stderr, "\telem->prev->next %p\n", \ - AP_RING_NEXT(AP_RING_PREV(this, link), link)); \ - if (AP_RING_PREV(AP_RING_NEXT(this, link), link) != this) { \ - fprintf(stderr, "\t*** this->next->prev != this\n"); \ - break; \ - } \ - if (AP_RING_NEXT(AP_RING_PREV(this, link), link) != this) { \ - fprintf(stderr, "\t*** this->prev->next != this\n"); \ - break; \ - } \ - this = AP_RING_NEXT(this, link); \ - } while (this != start); \ - fprintf(stderr, "*** ring check end\n"); \ - } while (0) -#else -#define AP_RING_CHECK_ONE(msg, ptr) -#define AP_RING_CHECK(hp, elem, link, msg) -#define AP_RING_CHECK_ELEM(ep, elem, link, msg) -#endif - -#endif /* !AP_RING_H */ diff --git a/include/apr_sha1.h b/include/apr_sha1.h deleted file mode 100644 index c040b149..00000000 --- a/include/apr_sha1.h +++ /dev/null @@ -1,161 +0,0 @@ -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2000 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" must - * not be used to endorse or promote products derived from this - * software without prior written permission. For written - * permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * nor may "Apache" appear in their name, without prior written - * permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - * - * NIST Secure Hash Algorithm - * heavily modified by Uwe Hollerbach uh@alumni.caltech edu - * from Peter C. Gutmann's implementation as found in - * Applied Cryptography by Bruce Schneier - * This code is hereby placed in the public domain - */ - -#ifndef APACHE_SHA1_H -#define APACHE_SHA1_H - -#include "ap_config.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @package SHA1 library - */ - -#define SHA_DIGESTSIZE 20 - -/** - * Define the Magic String prefix that identifies a password as being - * hashed using our algorithm. - * @defvar AP_SHA1PW_ID "{SHA}" - */ -#define AP_SHA1PW_ID "{SHA}" -#define AP_SHA1PW_IDLEN 5 - -typedef struct AP_SHA1_CTX AP_SHA1_CTX; - -/** - * SHA1 context structure - */ -struct AP_SHA1_CTX { - /** - * message digest - */ - apr_uint32_t digest[5]; - /** 64-bit bit counts */ - apr_uint32_t count_lo, count_hi; - /** SHA data buffer */ - apr_uint32_t data[16]; - /** unprocessed amount in data */ - int local; -}; - -/** - * Provide a means to SHA1 crypt/encode a plaintext password in a way which - * makes password file compatible with those commonly use in netscape web - * and ldap installations. - * @param clear The plaintext password - * @param len The length of the plaintext password - * @param out The encrypted/encoded password - * @tip SHA1 support is useful for migration purposes, but is less - * secure than Apache's password format, since Apache's (MD5) - * password format uses a random eight character salt to generate - * one of many possible hashes for the same password. Netscape - * uses plain SHA1 without a salt, so the same password - * will always generate the same hash, making it easier - * to break since the search space is smaller. - * @deffunc void ap_sha1_base64(const char *clear, int len, char *out) - */ -AP_DECLARE(void) ap_sha1_base64(const char *clear, int len, char *out); - -/** - * Initialize the SHA digest - * @param context The SHA context to initialize - * @deffunc void ap_SHA1Init(AP_SHA1_CTX *context); - */ -AP_DECLARE(void) ap_SHA1Init(AP_SHA1_CTX *context); - -/** - * Update the SHA digest - * @param context The SHA1 context to update - * @param input The buffer to add to the SHA digest - * @param inputLen The length of the input buffer - * @deffunc void ap_SHA1Update(AP_SHA1_CTX *context, const char *input, unsigned int inputLen) - */ -AP_DECLARE(void) ap_SHA1Update(AP_SHA1_CTX *context, const char *input, - unsigned int inputLen); - -/** - * Update the SHA digest with binary data - * @param context The SHA1 context to update - * @param input The buffer to add to the SHA digest - * @param inputLen The length of the input buffer - * @deffunc void ap_SHA1Update_binary(AP_SHA1_CTX *context, const unsigned char *input, unsigned int inputLen) - */ -AP_DECLARE(void) ap_SHA1Update_binary(AP_SHA1_CTX *context, - const unsigned char *input, - unsigned int inputLen); - -/** - * Finish computing the SHA digest - * @param digest the output buffer in which to store the digest - * @param context The context to finalize - * @deffunc void ap_SHA1Final(unsigned char digest[SHA_DIGESTSIZE], AP_SHA1_CTX *context) - */ -AP_DECLARE(void) ap_SHA1Final(unsigned char digest[SHA_DIGESTSIZE], - AP_SHA1_CTX *context); - -#ifdef __cplusplus -} -#endif - -#endif /* !APACHE_SHA1_H */ |