--- /dev/null
+#include <bindings.dsl.h>
+#include <bindings.apr.ring.h>
+#include <apr_buckets.h>
+
+module Bindings.APR.Buckets where
+#strict_import
+import Bindings.APR
+import Bindings.APR.Allocator.Types
+import Bindings.APR.ErrNo
+import Bindings.APR.File.Types
+import Bindings.APR.MMap
+import Bindings.APR.Network.IO
+import Bindings.APR.Pools
+import Bindings.APR.Want
+
+#num APR_BUCKET_BUFF_SIZE
+
+#integral_t apr_read_type_e
+#num APR_BLOCK_READ
+#num APR_NONBLOCK_READ
+
+#opaque_t apr_bucket_alloc_t
+
+#num APR_BUCKET_DATA
+#num APR_BUCKET_METADATA
+#starttype struct apr_bucket_type_t
+# field name , Ptr CChar
+# field num_func , CInt
+# field is_metadata, CInt
+# field destroy , FunPtr (Ptr () -> IO ())
+# field read , FunPtr (Ptr <apr_bucket> -> Ptr (Ptr CChar) -> Ptr <apr_size_t> -> <apr_read_type_e> -> IO <apr_status_t>)
+# field setaside , FunPtr (Ptr <apr_bucket> -> Ptr <apr_pool_t> -> IO <apr_status_t>)
+# field split , FunPtr (Ptr <apr_bucket> -> <apr_size_t> -> IO <apr_status_t>)
+# field copy , FunPtr (Ptr <apr_bucket> -> Ptr (Ptr <apr_bucket>) -> IO <apr_status_t>)
+#stoptype
+
+#starttype struct apr_bucket
+# apr_ring_entry_field link, <apr_bucket>
+# field type , Ptr <apr_bucket_type_t>
+# field length, <apr_size_t>
+# field start , <apr_off_t>
+# field data , Ptr ()
+# field free , FunPtr (Ptr () -> IO ())
+# field list , Ptr <apr_bucket_alloc_t>
+#stoptype
+
+#apr_ring_head_t apr_bucket_list, <apr_bucket>
+#starttype struct apr_bucket_brigade
+# field p , Ptr <apr_pool_t>
+# field list , <apr_bucket_list>
+# field bucket_alloc, Ptr <apr_bucket_alloc_t>
+#stoptype
+
+#callback apr_brigade_flush, Ptr <apr_bucket_brigade> -> Ptr () -> IO <apr_status_t>
+
+#cinline APR_BRIGADE_CHECK_CONSISTENCY, Ptr <apr_bucket_brigade> -> IO ()
+#cinline APR_BUCKET_CHECK_CONSISTENCY , Ptr <apr_bucket> -> IO ()
+
+#cinline APR_BRIGADE_SENTINEL , Ptr <apr_bucket_brigade> -> IO (Ptr <apr_bucket>)
+#cinline APR_BRIGADE_EMPTY , Ptr <apr_bucket_brigade> -> IO CInt
+#cinline APR_BRIGADE_FIRST , Ptr <apr_bucket_brigade> -> IO (Ptr <apr_bucket>)
+#cinline APR_BRIGADE_LAST , Ptr <apr_bucket_brigade> -> IO (Ptr <apr_bucket>)
+#cinline APR_BRIGADE_INSERT_HEAD, Ptr <apr_bucket_brigade> -> Ptr <apr_bucket> -> IO ()
+#cinline APR_BRIGADE_INSERT_TAIL, Ptr <apr_bucket_brigade> -> Ptr <apr_bucket> -> IO ()
+#cinline APR_BRIGADE_CONCAT , Ptr <apr_bucket_brigade> -> Ptr <apr_bucket_brigade> -> IO ()
+#cinline APR_BRIGADE_PREPEND , Ptr <apr_bucket_brigade> -> Ptr <apr_bucket_brigade> -> IO ()
+
+#cinline APR_BUCKET_INSERT_BEFORE, Ptr <apr_bucket> -> Ptr <apr_bucket> -> IO ()
+#cinline APR_BUCKET_INSERT_AFTER , Ptr <apr_bucket> -> Ptr <apr_bucket> -> IO ()
+#cinline APR_BUCKET_NEXT , Ptr <apr_bucket> -> IO (Ptr <apr_bucket>)
+#cinline APR_BUCKET_PREV , Ptr <apr_bucket> -> IO (Ptr <apr_bucket>)
+#cinline APR_BUCKET_REMOVE , Ptr <apr_bucket> -> IO ()
+#cinline APR_BUCKET_INIT , Ptr <apr_bucket> -> IO ()
+#cinline APR_BUCKET_IS_METADATA , Ptr <apr_bucket> -> IO CInt
+#cinline APR_BUCKET_IS_FLUSH , Ptr <apr_bucket> -> IO CInt
+#cinline APR_BUCKET_IS_EOS , Ptr <apr_bucket> -> IO CInt
+#cinline APR_BUCKET_IS_FILE , Ptr <apr_bucket> -> IO CInt
+#cinline APR_BUCKET_IS_PIPE , Ptr <apr_bucket> -> IO CInt
+#cinline APR_BUCKET_IS_SOCKET , Ptr <apr_bucket> -> IO CInt
+#cinline APR_BUCKET_IS_HEAP , Ptr <apr_bucket> -> IO CInt
+#cinline APR_BUCKET_IS_TRANSIENT , Ptr <apr_bucket> -> IO CInt
+#cinline APR_BUCKET_IS_IMMORTAL , Ptr <apr_bucket> -> IO CInt
+#if APR_HAS_MMAP
+# cinline APR_BUCKET_IS_MMAP , Ptr <apr_bucket> -> IO CInt
+#endif
+#cinline APR_BUCKET_IS_POOL , Ptr <apr_bucket> -> IO CInt
+
+#starttype struct apr_bucket_refcount
+# field refcount, CInt
+#stoptype
+
+#starttype struct apr_bucket_heap
+# field refcount , <apr_bucket_refcount>
+# field base , Ptr CChar
+# field alloc_len, <apr_size_t>
+# field free_func, FunPtr (Ptr () -> IO ())
+#stoptype
+
+#starttype struct apr_bucket_pool
+# field heap, <apr_bucket_heap>
+# field base, Ptr CChar
+# field pool, Ptr <apr_pool_t>
+# field list, Ptr <apr_bucket_alloc_t>
+#stoptype
+
+#if APR_HAS_MMAP
+# starttype struct apr_bucket_mmap
+# field refcount, <apr_bucket_refcount>
+# field mmap , <apr_mmap_t>
+# stoptype
+#endif
+
+#starttype struct apr_bucket_file
+# field refcount, <apr_bucket_refcount>
+# field fd , Ptr <apr_file_t>
+# field readpool, Ptr <apr_pool_t>
+# if APR_HAS_MMAP
+# field can_mmap, CInt
+# endif
+#stoptype
+
+#starttype union apr_bucket_structs
+# union_field b , <apr_bucket>
+# union_field heap, <apr_bucket_heap>
+# union_field pool, <apr_bucket_pool>
+# if APR_HAS_MMAP
+# union_field mmap, <apr_bucket_mmap>
+# endif
+# union_field file, <apr_bucket_file>
+#stoptype
+
+#num APR_BUCKET_ALLOC_SIZE
+
+#ccall apr_brigade_create , Ptr <apr_pool_t> -> Ptr <apr_bucket_alloc_t> -> IO (Ptr <apr_bucket_brigade>)
+#ccall apr_brigade_destroy , Ptr <apr_bucket_brigade> -> IO <apr_status_t>
+#ccall apr_brigade_cleanup , Ptr () -> IO <apr_status_t>
+#ccall apr_brigade_split_ex , Ptr <apr_bucket_brigade> -> Ptr <apr_bucket> -> Ptr <apr_bucket_brigade> -> IO (Ptr <apr_bucket_brigade>)
+#ccall apr_brigade_split , Ptr <apr_bucket_brigade> -> Ptr <apr_bucket> -> IO (Ptr <apr_bucket_brigade>)
+#ccall apr_brigade_partition , Ptr <apr_bucket_brigade> -> <apr_off_t> -> Ptr (Ptr <apr_bucket>) -> IO <apr_status_t>
+#ccall apr_brigade_length , Ptr <apr_bucket_brigade> -> CInt -> Ptr <apr_off_t> -> IO <apr_status_t>
+#ccall apr_brigade_flatten , Ptr <apr_bucket_brigade> -> Ptr CChar -> Ptr <apr_size_t> -> IO <apr_status_t>
+#ccall apr_brigade_pflatten , Ptr <apr_bucket_brigade> -> Ptr (Ptr CChar) -> Ptr <apr_size_t> -> Ptr <apr_pool_t> -> IO <apr_status_t>
+#ccall apr_brigade_split_line , Ptr <apr_bucket_brigade> -> Ptr <apr_bucket_brigade> -> <apr_read_type_e> -> <apr_off_t> -> IO <apr_status_t>
+#ccall apr_brigade_to_iovec , Ptr <apr_bucket_brigade> -> Ptr <iovec> -> Ptr CInt -> <apr_status_t>
+-- FIXME: apr_brigade_to_vputstrs takes va_list
+#ccall apr_brigade_write , Ptr <apr_bucket_brigade> -> <apr_brigade_flush> -> Ptr () -> Ptr CChar -> <apr_size_t> -> IO <apr_status_t>
+#ccall apr_brigade_writev , Ptr <apr_bucket_brigade> -> <apr_brigade_flush> -> Ptr () -> Ptr <iovec> -> <apr_size_t> -> IO <apr_status_t>
+#ccall apr_brigade_puts , Ptr <apr_bucket_brigade> -> <apr_brigade_flush> -> Ptr () -> Ptr CChar -> IO <apr_status_t>
+#ccall apr_brigade_putc , Ptr <apr_bucket_brigade> -> <apr_brigade_flush> -> Ptr () -> CChar -> IO <apr_status_t>
+-- FIXME: apr_brigade_putstrs takes varargs
+-- FIXME: apr_brigade_printf takes varargs
+-- FIXME: apr_brigade_vprintf takes va_list
+#ccall apr_brigade_insert_file, Ptr <apr_bucket_brigade> -> Ptr <apr_file_t> -> <apr_off_t> -> <apr_off_t> -> Ptr <apr_pool_t> -> IO (Ptr <apr_bucket>)
+
+#ccall apr_bucket_alloc_create , Ptr <apr_pool_t> -> Ptr (<apr_bucket_alloc_t>)
+#ccall apr_bucket_alloc_create_ex, Ptr <apr_allocator_t> -> Ptr (<apr_bucket_alloc_t>)
+#ccall apr_bucket_alloc_destroy , Ptr <apr_bucket_alloc_t> -> IO ()
+#ccall apr_bucket_alloc , <apr_size_t> -> Ptr <apr_bucket_alloc_t> -> IO (Ptr ())
+#ccall apr_bucket_free , Ptr () -> IO ()
+
+#cinline apr_bucket_destroy , Ptr <apr_bucket> -> IO ()
+#cinline apr_bucket_delete , Ptr <apr_bucket> -> IO ()
+#cinline apr_bucket_read , Ptr <apr_bucket> -> Ptr (Ptr CChar) -> Ptr <apr_size_t> -> <apr_read_type_e> -> IO <apr_status_t>
+#cinline apr_bucket_setaside, Ptr <apr_bucket> -> Ptr <apr_pool_t> -> IO <apr_status_t>
+#cinline apr_bucket_split , Ptr <apr_bucket> -> <apr_size_t> -> IO <apr_status_t>
+#cinline apr_bucket_copy , Ptr <apr_bucket> -> Ptr (Ptr <apr_bucket>) -> IO <apr_status_t>
+
+#ccall apr_bucket_setaside_noop , Ptr <apr_bucket> -> Ptr <apr_pool_t> -> IO <apr_status_t>
+#ccall apr_bucket_setaside_notimpl, Ptr <apr_bucket> -> Ptr <apr_pool_t> -> IO <apr_status_t>
+#ccall apr_bucket_split_notimpl , Ptr <apr_bucket> -> <apr_size_t> -> IO <apr_status_t>
+#ccall apr_bucket_copy_notimpl , Ptr <apr_bucket> -> Ptr (Ptr <apr_bucket>) -> IO <apr_status_t>
+#ccall apr_bucket_destroy_noop , Ptr () -> IO ()
+
+#globalvar apr_bucket_type_flush , <apr_bucket_type_t>
+#globalvar apr_bucket_type_eos , <apr_bucket_type_t>
+#globalvar apr_bucket_type_file , <apr_bucket_type_t>
+#globalvar apr_bucket_type_heap , <apr_bucket_type_t>
+#if APR_HAS_MMAP
+# globalvar apr_bucket_type_mmap , <apr_bucket_type_t>
+#endif
+#globalvar apr_bucket_type_pool , <apr_bucket_type_t>
+#globalvar apr_bucket_type_pipe , <apr_bucket_type_t>
+#globalvar apr_bucket_type_immortal , <apr_bucket_type_t>
+#globalvar apr_bucket_type_transient, <apr_bucket_type_t>
+#globalvar apr_bucket_type_socket , <apr_bucket_type_t>
+
+#ccall apr_bucket_simple_split, Ptr <apr_bucket> -> <apr_size_t> -> IO <apr_status_t>
+#ccall apr_bucket_simple_copy , Ptr <apr_bucket> -> Ptr (Ptr <apr_bucket>) -> IO <apr_status_t>
+
+#ccall apr_bucket_shared_make , Ptr <apr_bucket> -> Ptr () -> <apr_off_t> -> <apr_size_t> -> IO (Ptr <apr_bucket>)
+#ccall apr_bucket_shared_destroy, Ptr () -> IO CInt
+#ccall apr_bucket_shared_split , Ptr <apr_bucket> -> <apr_size_t> -> IO <apr_status_t>
+#ccall apr_bucket_shared_copy , Ptr <apr_bucket> -> Ptr (Ptr <apr_bucket>) -> IO <apr_status_t>
+
+#ccall apr_bucket_eos_create , Ptr <apr_bucket_alloc_t> -> IO (Ptr <apr_bucket>)
+#ccall apr_bucket_eos_make , Ptr <apr_bucket> -> IO (Ptr <apr_bucket>)
+#ccall apr_bucket_flush_create , Ptr <apr_bucket_alloc_t> -> IO (Ptr <apr_bucket>)
+#ccall apr_bucket_flush_make , Ptr <apr_bucket> -> IO (Ptr <apr_bucket>)
+#ccall apr_bucket_immortal_create , Ptr CChar -> <apr_size_t> -> Ptr <apr_bucket_alloc_t> -> IO (Ptr <apr_bucket>)
+#ccall apr_bucket_immortal_make , Ptr <apr_bucket> -> Ptr CChar -> <apr_size_t> -> IO (Ptr <apr_bucket>)
+#ccall apr_bucket_transient_create, Ptr CChar -> <apr_size_t> -> Ptr <apr_bucket_alloc_t> -> IO (Ptr <apr_bucket>)
+#ccall apr_bucket_transient_make , Ptr <apr_bucket> -> Ptr CChar -> <apr_size_t> -> IO (Ptr <apr_bucket>)
+#ccall apr_bucket_heap_create , Ptr CChar -> <apr_size_t> -> FunPtr (Ptr () -> IO ()) -> Ptr <apr_bucket_alloc_t> -> IO (Ptr <apr_bucket>)
+#ccall apr_bucket_heap_make , Ptr <apr_bucket> -> Ptr CChar -> <apr_size_t> -> FunPtr (Ptr () -> IO ()) -> IO (Ptr <apr_bucket>)
+#ccall apr_bucket_pool_create , Ptr CChar -> <apr_size_t> -> Ptr <apr_pool_t> -> Ptr <apr_bucket_alloc_t> -> IO (Ptr <apr_bucket>)
+#ccall apr_bucket_pool_make , Ptr <apr_bucket> -> Ptr CChar -> <apr_size_t> -> Ptr <apr_pool_t> -> IO (Ptr <apr_bucket>)
+#if APR_HAS_MMAP
+# ccall apr_bucket_mmap_create , Ptr <apr_mmap_t> -> <apr_off_t> -> <apr_size_t> -> Ptr <apr_bucket_alloc_t> -> IO (Ptr <apr_bucket>)
+# ccall apr_bucket_mmap_make , Ptr <apr_bucket> -> Ptr <apr_mmap_t> -> <apr_off_t> -> <apr_size_t> -> IO (Ptr <apr_bucket>)
+#endif
+#ccall apr_bucket_socket_create , Ptr <apr_socket_t> -> Ptr <apr_bucket_alloc_t> -> IO (Ptr <apr_bucket>)
+#ccall apr_bucket_socket_make , Ptr <apr_bucket> -> Ptr <apr_socket_t> -> IO (Ptr <apr_bucket>)
+#ccall apr_bucket_pipe_create , Ptr <apr_file_t> -> Ptr <apr_bucket_alloc_t> -> IO (Ptr <apr_bucket>)
+#ccall apr_bucket_pipe_make , Ptr <apr_bucket> -> Ptr <apr_file_t> -> IO (Ptr <apr_bucket>)
+#ccall apr_bucket_file_create , Ptr <apr_file_t> -> <apr_off_t> -> <apr_size_t> -> Ptr <apr_pool_t> -> Ptr <apr_bucket_alloc_t> -> IO (Ptr <apr_bucket>)
+#ccall apr_bucket_file_make , Ptr <apr_bucket> -> Ptr <apr_file_t> -> <apr_off_t> -> <apr_size_t> -> Ptr <apr_pool_t> -> IO (Ptr <apr_bucket>)
+#ccall apr_bucket_file_enable_mmap, Ptr <apr_bucket> -> CInt -> IO <apr_status_t>
--- /dev/null
+#include <bindings.cmacros.h>
+#include <apr_buckets.h>
+
+BC_INLINE1VOID(APR_BRIGADE_CHECK_CONSISTENCY, apr_bucket_brigade*)
+BC_INLINE1VOID(APR_BUCKET_CHECK_CONSISTENCY , apr_bucket*)
+
+BC_INLINE1(APR_BRIGADE_SENTINEL, apr_bucket_brigade*, apr_bucket*)
+BC_INLINE1(APR_BRIGADE_EMPTY , apr_bucket_brigade*, int)
+BC_INLINE1(APR_BRIGADE_FIRST , apr_bucket_brigade*, apr_bucket*)
+BC_INLINE1(APR_BRIGADE_LAST , apr_bucket_brigade*, apr_bucket*)
+BC_INLINE2VOID(APR_BRIGADE_INSERT_HEAD, apr_bucket_brigade*, apr_bucket*)
+BC_INLINE2VOID(APR_BRIGADE_INSERT_TAIL, apr_bucket_brigade*, apr_bucket*)
+BC_INLINE2VOID(APR_BRIGADE_CONCAT , apr_bucket_brigade*, apr_bucket_brigade*)
+BC_INLINE2VOID(APR_BRIGADE_PREPEND , apr_bucket_brigade*, apr_bucket_brigade*)
+
+BC_INLINE2VOID(APR_BUCKET_INSERT_BEFORE, apr_bucket*, apr_bucket*)
+BC_INLINE2VOID(APR_BUCKET_INSERT_AFTER , apr_bucket*, apr_bucket*)
+BC_INLINE1 (APR_BUCKET_NEXT , apr_bucket*, apr_bucket*)
+BC_INLINE1 (APR_BUCKET_PREV , apr_bucket*, apr_bucket*)
+BC_INLINE1VOID(APR_BUCKET_REMOVE , apr_bucket*)
+BC_INLINE1VOID(APR_BUCKET_INIT , apr_bucket*)
+BC_INLINE1 (APR_BUCKET_IS_METADATA , apr_bucket*, int)
+BC_INLINE1 (APR_BUCKET_IS_FLUSH , apr_bucket*, int)
+BC_INLINE1 (APR_BUCKET_IS_EOS , apr_bucket*, int)
+BC_INLINE1 (APR_BUCKET_IS_FILE , apr_bucket*, int)
+BC_INLINE1 (APR_BUCKET_IS_PIPE , apr_bucket*, int)
+BC_INLINE1 (APR_BUCKET_IS_SOCKET , apr_bucket*, int)
+BC_INLINE1 (APR_BUCKET_IS_HEAP , apr_bucket*, int)
+BC_INLINE1 (APR_BUCKET_IS_TRANSIENT , apr_bucket*, int)
+BC_INLINE1 (APR_BUCKET_IS_IMMORTAL , apr_bucket*, int)
+#if APR_HAS_MMAP
+ BC_INLINE1 (APR_BUCKET_IS_MMAP , apr_bucket*, int)
+#endif
+BC_INLINE1 (APR_BUCKET_IS_POOL , apr_bucket*, int)
+
+BC_INLINE1VOID(apr_bucket_destroy , apr_bucket*)
+BC_INLINE1VOID(apr_bucket_delete , apr_bucket*)
+BC_INLINE4 (apr_bucket_read , apr_bucket*, const char**, apr_size_t*, apr_read_type_e, apr_status_t)
+BC_INLINE2 (apr_bucket_setaside, apr_bucket*, apr_pool_t*, apr_status_t)
+BC_INLINE2 (apr_bucket_split , apr_bucket*, apr_size_t, apr_status_t)
+BC_INLINE2 (apr_bucket_copy , apr_bucket*, apr_bucket**, apr_status_t)