From: PHO Date: Tue, 31 Aug 2010 16:13:29 +0000 (+0900) Subject: Bindings.APR.Buckets X-Git-Tag: RELEASE-0.1~20 X-Git-Url: https://git.cielonegro.org/gitweb.cgi?a=commitdiff_plain;h=346d352c063ef3b357f065b4e7e5f87b6d954fa6;p=bindings-apr-util.git Bindings.APR.Buckets --- diff --git a/Bindings/APR/Buckets.hsc b/Bindings/APR/Buckets.hsc new file mode 100644 index 0000000..5bf77e6 --- /dev/null +++ b/Bindings/APR/Buckets.hsc @@ -0,0 +1,217 @@ +#include +#include +#include + +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 -> Ptr (Ptr CChar) -> Ptr -> -> IO ) +# field setaside , FunPtr (Ptr -> Ptr -> IO ) +# field split , FunPtr (Ptr -> -> IO ) +# field copy , FunPtr (Ptr -> Ptr (Ptr ) -> IO ) +#stoptype + +#starttype struct apr_bucket +# apr_ring_entry_field link, +# field type , Ptr +# field length, +# field start , +# field data , Ptr () +# field free , FunPtr (Ptr () -> IO ()) +# field list , Ptr +#stoptype + +#apr_ring_head_t apr_bucket_list, +#starttype struct apr_bucket_brigade +# field p , Ptr +# field list , +# field bucket_alloc, Ptr +#stoptype + +#callback apr_brigade_flush, Ptr -> Ptr () -> IO + +#cinline APR_BRIGADE_CHECK_CONSISTENCY, Ptr -> IO () +#cinline APR_BUCKET_CHECK_CONSISTENCY , Ptr -> IO () + +#cinline APR_BRIGADE_SENTINEL , Ptr -> IO (Ptr ) +#cinline APR_BRIGADE_EMPTY , Ptr -> IO CInt +#cinline APR_BRIGADE_FIRST , Ptr -> IO (Ptr ) +#cinline APR_BRIGADE_LAST , Ptr -> IO (Ptr ) +#cinline APR_BRIGADE_INSERT_HEAD, Ptr -> Ptr -> IO () +#cinline APR_BRIGADE_INSERT_TAIL, Ptr -> Ptr -> IO () +#cinline APR_BRIGADE_CONCAT , Ptr -> Ptr -> IO () +#cinline APR_BRIGADE_PREPEND , Ptr -> Ptr -> IO () + +#cinline APR_BUCKET_INSERT_BEFORE, Ptr -> Ptr -> IO () +#cinline APR_BUCKET_INSERT_AFTER , Ptr -> Ptr -> IO () +#cinline APR_BUCKET_NEXT , Ptr -> IO (Ptr ) +#cinline APR_BUCKET_PREV , Ptr -> IO (Ptr ) +#cinline APR_BUCKET_REMOVE , Ptr -> IO () +#cinline APR_BUCKET_INIT , Ptr -> IO () +#cinline APR_BUCKET_IS_METADATA , Ptr -> IO CInt +#cinline APR_BUCKET_IS_FLUSH , Ptr -> IO CInt +#cinline APR_BUCKET_IS_EOS , Ptr -> IO CInt +#cinline APR_BUCKET_IS_FILE , Ptr -> IO CInt +#cinline APR_BUCKET_IS_PIPE , Ptr -> IO CInt +#cinline APR_BUCKET_IS_SOCKET , Ptr -> IO CInt +#cinline APR_BUCKET_IS_HEAP , Ptr -> IO CInt +#cinline APR_BUCKET_IS_TRANSIENT , Ptr -> IO CInt +#cinline APR_BUCKET_IS_IMMORTAL , Ptr -> IO CInt +#if APR_HAS_MMAP +# cinline APR_BUCKET_IS_MMAP , Ptr -> IO CInt +#endif +#cinline APR_BUCKET_IS_POOL , Ptr -> IO CInt + +#starttype struct apr_bucket_refcount +# field refcount, CInt +#stoptype + +#starttype struct apr_bucket_heap +# field refcount , +# field base , Ptr CChar +# field alloc_len, +# field free_func, FunPtr (Ptr () -> IO ()) +#stoptype + +#starttype struct apr_bucket_pool +# field heap, +# field base, Ptr CChar +# field pool, Ptr +# field list, Ptr +#stoptype + +#if APR_HAS_MMAP +# starttype struct apr_bucket_mmap +# field refcount, +# field mmap , +# stoptype +#endif + +#starttype struct apr_bucket_file +# field refcount, +# field fd , Ptr +# field readpool, Ptr +# if APR_HAS_MMAP +# field can_mmap, CInt +# endif +#stoptype + +#starttype union apr_bucket_structs +# union_field b , +# union_field heap, +# union_field pool, +# if APR_HAS_MMAP +# union_field mmap, +# endif +# union_field file, +#stoptype + +#num APR_BUCKET_ALLOC_SIZE + +#ccall apr_brigade_create , Ptr -> Ptr -> IO (Ptr ) +#ccall apr_brigade_destroy , Ptr -> IO +#ccall apr_brigade_cleanup , Ptr () -> IO +#ccall apr_brigade_split_ex , Ptr -> Ptr -> Ptr -> IO (Ptr ) +#ccall apr_brigade_split , Ptr -> Ptr -> IO (Ptr ) +#ccall apr_brigade_partition , Ptr -> -> Ptr (Ptr ) -> IO +#ccall apr_brigade_length , Ptr -> CInt -> Ptr -> IO +#ccall apr_brigade_flatten , Ptr -> Ptr CChar -> Ptr -> IO +#ccall apr_brigade_pflatten , Ptr -> Ptr (Ptr CChar) -> Ptr -> Ptr -> IO +#ccall apr_brigade_split_line , Ptr -> Ptr -> -> -> IO +#ccall apr_brigade_to_iovec , Ptr -> Ptr -> Ptr CInt -> +-- FIXME: apr_brigade_to_vputstrs takes va_list +#ccall apr_brigade_write , Ptr -> -> Ptr () -> Ptr CChar -> -> IO +#ccall apr_brigade_writev , Ptr -> -> Ptr () -> Ptr -> -> IO +#ccall apr_brigade_puts , Ptr -> -> Ptr () -> Ptr CChar -> IO +#ccall apr_brigade_putc , Ptr -> -> Ptr () -> CChar -> IO +-- 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 -> Ptr -> -> -> Ptr -> IO (Ptr ) + +#ccall apr_bucket_alloc_create , Ptr -> Ptr () +#ccall apr_bucket_alloc_create_ex, Ptr -> Ptr () +#ccall apr_bucket_alloc_destroy , Ptr -> IO () +#ccall apr_bucket_alloc , -> Ptr -> IO (Ptr ()) +#ccall apr_bucket_free , Ptr () -> IO () + +#cinline apr_bucket_destroy , Ptr -> IO () +#cinline apr_bucket_delete , Ptr -> IO () +#cinline apr_bucket_read , Ptr -> Ptr (Ptr CChar) -> Ptr -> -> IO +#cinline apr_bucket_setaside, Ptr -> Ptr -> IO +#cinline apr_bucket_split , Ptr -> -> IO +#cinline apr_bucket_copy , Ptr -> Ptr (Ptr ) -> IO + +#ccall apr_bucket_setaside_noop , Ptr -> Ptr -> IO +#ccall apr_bucket_setaside_notimpl, Ptr -> Ptr -> IO +#ccall apr_bucket_split_notimpl , Ptr -> -> IO +#ccall apr_bucket_copy_notimpl , Ptr -> Ptr (Ptr ) -> IO +#ccall apr_bucket_destroy_noop , Ptr () -> IO () + +#globalvar apr_bucket_type_flush , +#globalvar apr_bucket_type_eos , +#globalvar apr_bucket_type_file , +#globalvar apr_bucket_type_heap , +#if APR_HAS_MMAP +# globalvar apr_bucket_type_mmap , +#endif +#globalvar apr_bucket_type_pool , +#globalvar apr_bucket_type_pipe , +#globalvar apr_bucket_type_immortal , +#globalvar apr_bucket_type_transient, +#globalvar apr_bucket_type_socket , + +#ccall apr_bucket_simple_split, Ptr -> -> IO +#ccall apr_bucket_simple_copy , Ptr -> Ptr (Ptr ) -> IO + +#ccall apr_bucket_shared_make , Ptr -> Ptr () -> -> -> IO (Ptr ) +#ccall apr_bucket_shared_destroy, Ptr () -> IO CInt +#ccall apr_bucket_shared_split , Ptr -> -> IO +#ccall apr_bucket_shared_copy , Ptr -> Ptr (Ptr ) -> IO + +#ccall apr_bucket_eos_create , Ptr -> IO (Ptr ) +#ccall apr_bucket_eos_make , Ptr -> IO (Ptr ) +#ccall apr_bucket_flush_create , Ptr -> IO (Ptr ) +#ccall apr_bucket_flush_make , Ptr -> IO (Ptr ) +#ccall apr_bucket_immortal_create , Ptr CChar -> -> Ptr -> IO (Ptr ) +#ccall apr_bucket_immortal_make , Ptr -> Ptr CChar -> -> IO (Ptr ) +#ccall apr_bucket_transient_create, Ptr CChar -> -> Ptr -> IO (Ptr ) +#ccall apr_bucket_transient_make , Ptr -> Ptr CChar -> -> IO (Ptr ) +#ccall apr_bucket_heap_create , Ptr CChar -> -> FunPtr (Ptr () -> IO ()) -> Ptr -> IO (Ptr ) +#ccall apr_bucket_heap_make , Ptr -> Ptr CChar -> -> FunPtr (Ptr () -> IO ()) -> IO (Ptr ) +#ccall apr_bucket_pool_create , Ptr CChar -> -> Ptr -> Ptr -> IO (Ptr ) +#ccall apr_bucket_pool_make , Ptr -> Ptr CChar -> -> Ptr -> IO (Ptr ) +#if APR_HAS_MMAP +# ccall apr_bucket_mmap_create , Ptr -> -> -> Ptr -> IO (Ptr ) +# ccall apr_bucket_mmap_make , Ptr -> Ptr -> -> -> IO (Ptr ) +#endif +#ccall apr_bucket_socket_create , Ptr -> Ptr -> IO (Ptr ) +#ccall apr_bucket_socket_make , Ptr -> Ptr -> IO (Ptr ) +#ccall apr_bucket_pipe_create , Ptr -> Ptr -> IO (Ptr ) +#ccall apr_bucket_pipe_make , Ptr -> Ptr -> IO (Ptr ) +#ccall apr_bucket_file_create , Ptr -> -> -> Ptr -> Ptr -> IO (Ptr ) +#ccall apr_bucket_file_make , Ptr -> Ptr -> -> -> Ptr -> IO (Ptr ) +#ccall apr_bucket_file_enable_mmap, Ptr -> CInt -> IO diff --git a/bindings-apr-util.cabal b/bindings-apr-util.cabal index 4c8d66a..d67ab9c 100644 --- a/bindings-apr-util.cabal +++ b/bindings-apr-util.cabal @@ -32,9 +32,11 @@ Library Bindings.APU Bindings.APR.AnyLock Bindings.APR.Base64 + Bindings.APR.Buckets C-Sources: cbits/helper_apr_anylock.c + cbits/helper_apr_buckets.c Extensions: ForeignFunctionInterface diff --git a/cbits/helper_apr_buckets.c b/cbits/helper_apr_buckets.c new file mode 100644 index 0000000..5454bac --- /dev/null +++ b/cbits/helper_apr_buckets.c @@ -0,0 +1,41 @@ +#include +#include + +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)