module Bindings.Librrd where
import Bindings.Posix.Time
import System.Posix.Types
import Foreign.Ptr (Ptr,FunPtr,plusPtr)
import Foreign.Ptr (wordPtrToPtr,castPtrToFunPtr)
import Foreign.Storable
import Foreign.C.Types
import Foreign.C.String (CString,CStringLen,CWString,CWStringLen)
import Foreign.Marshal.Alloc (alloca)
import Foreign.Marshal.Array (peekArray,pokeArray)
import Data.Int
import Data.Word
foreign import ccall "inline_DNAN" c'DNAN
:: IO CDouble
foreign import ccall "inline_DINF" c'DINF
:: IO CDouble
foreign import ccall "rrd_set_to_DNAN" c'rrd_set_to_DNAN
:: IO CDouble
foreign import ccall "&rrd_set_to_DNAN" p'rrd_set_to_DNAN
:: FunPtr (IO CDouble)
foreign import ccall "rrd_set_to_DINF" c'rrd_set_to_DINF
:: IO CDouble
foreign import ccall "&rrd_set_to_DINF" p'rrd_set_to_DINF
:: FunPtr (IO CDouble)
type C'rrd_value_t = CDouble
data C'rrd_file_t = C'rrd_file_t{
c'rrd_file_t'header_len :: COff
,
c'rrd_file_t'file_len :: COff
,
c'rrd_file_t'pos :: COff
,
c'rrd_file_t'pvt :: Ptr ()
} deriving (Eq,Show)
instance Storable C'rrd_file_t where
sizeOf _ = 16
alignment = sizeOf
peek p = do
v0 <- peekByteOff p 0
v1 <- peekByteOff p 4
v2 <- peekByteOff p 8
v3 <- peekByteOff p 12
return $ C'rrd_file_t v0 v1 v2 v3
poke p (C'rrd_file_t v0 v1 v2 v3) = do
pokeByteOff p 0 v0
pokeByteOff p 4 v1
pokeByteOff p 8 v2
pokeByteOff p 12 v3
return ()
data C'rrd_simple_file_t = C'rrd_simple_file_t{
c'rrd_simple_file_t'fd :: CInt
} deriving (Eq,Show)
instance Storable C'rrd_simple_file_t where
sizeOf _ = 4
alignment = sizeOf
peek p = do
v0 <- peekByteOff p 0
return $ C'rrd_simple_file_t v0
poke p (C'rrd_simple_file_t v0) = do
pokeByteOff p 0 v0
return ()
data C'rrd_blob_t = C'rrd_blob_t{
c'rrd_blob_t'size :: CULong
,
c'rrd_blob_t'ptr :: Ptr CUChar
} deriving (Eq,Show)
instance Storable C'rrd_blob_t where
sizeOf _ = 8
alignment = sizeOf
peek p = do
v0 <- peekByteOff p 0
v1 <- peekByteOff p 4
return $ C'rrd_blob_t v0 v1
poke p (C'rrd_blob_t v0 v1) = do
pokeByteOff p 0 v0
pokeByteOff p 4 v1
return ()
type C'rrd_info_type_t = CUInt
c'RD_I_VAL = 0
c'RD_I_VAL :: (Num a) => a
c'RD_I_CNT = 1
c'RD_I_CNT :: (Num a) => a
c'RD_I_STR = 2
c'RD_I_STR :: (Num a) => a
c'RD_I_INT = 3
c'RD_I_INT :: (Num a) => a
c'RD_I_BLO = 4
c'RD_I_BLO :: (Num a) => a
data C'rrd_infoval = C'rrd_infoval{
c'rrd_infoval'u_cnt :: CULong
,
c'rrd_infoval'u_val :: C'rrd_value_t
,
c'rrd_infoval'u_str :: CString
,
c'rrd_infoval'u_int :: CInt
,
c'rrd_infoval'u_blo :: C'rrd_blob_t
} deriving (Eq,Show)
u'rrd_infoval'u_cnt v vf = alloca $ \p -> do
poke p v
pokeByteOff p 0 vf
vu <- peek p
return $ v
{c'rrd_infoval'u_cnt = c'rrd_infoval'u_cnt vu}
{c'rrd_infoval'u_val = c'rrd_infoval'u_val vu}
{c'rrd_infoval'u_str = c'rrd_infoval'u_str vu}
{c'rrd_infoval'u_int = c'rrd_infoval'u_int vu}
{c'rrd_infoval'u_blo = c'rrd_infoval'u_blo vu}
u'rrd_infoval'u_cnt :: C'rrd_infoval -> CULong -> IO C'rrd_infoval
u'rrd_infoval'u_val v vf = alloca $ \p -> do
poke p v
pokeByteOff p 0 vf
vu <- peek p
return $ v
{c'rrd_infoval'u_cnt = c'rrd_infoval'u_cnt vu}
{c'rrd_infoval'u_val = c'rrd_infoval'u_val vu}
{c'rrd_infoval'u_str = c'rrd_infoval'u_str vu}
{c'rrd_infoval'u_int = c'rrd_infoval'u_int vu}
{c'rrd_infoval'u_blo = c'rrd_infoval'u_blo vu}
u'rrd_infoval'u_val :: C'rrd_infoval -> C'rrd_value_t -> IO C'rrd_infoval
u'rrd_infoval'u_str v vf = alloca $ \p -> do
poke p v
pokeByteOff p 0 vf
vu <- peek p
return $ v
{c'rrd_infoval'u_cnt = c'rrd_infoval'u_cnt vu}
{c'rrd_infoval'u_val = c'rrd_infoval'u_val vu}
{c'rrd_infoval'u_str = c'rrd_infoval'u_str vu}
{c'rrd_infoval'u_int = c'rrd_infoval'u_int vu}
{c'rrd_infoval'u_blo = c'rrd_infoval'u_blo vu}
u'rrd_infoval'u_str :: C'rrd_infoval -> CString -> IO C'rrd_infoval
u'rrd_infoval'u_int v vf = alloca $ \p -> do
poke p v
pokeByteOff p 0 vf
vu <- peek p
return $ v
{c'rrd_infoval'u_cnt = c'rrd_infoval'u_cnt vu}
{c'rrd_infoval'u_val = c'rrd_infoval'u_val vu}
{c'rrd_infoval'u_str = c'rrd_infoval'u_str vu}
{c'rrd_infoval'u_int = c'rrd_infoval'u_int vu}
{c'rrd_infoval'u_blo = c'rrd_infoval'u_blo vu}
u'rrd_infoval'u_int :: C'rrd_infoval -> CInt -> IO C'rrd_infoval
u'rrd_infoval'u_blo v vf = alloca $ \p -> do
poke p v
pokeByteOff p 0 vf
vu <- peek p
return $ v
{c'rrd_infoval'u_cnt = c'rrd_infoval'u_cnt vu}
{c'rrd_infoval'u_val = c'rrd_infoval'u_val vu}
{c'rrd_infoval'u_str = c'rrd_infoval'u_str vu}
{c'rrd_infoval'u_int = c'rrd_infoval'u_int vu}
{c'rrd_infoval'u_blo = c'rrd_infoval'u_blo vu}
u'rrd_infoval'u_blo :: C'rrd_infoval -> C'rrd_blob_t -> IO C'rrd_infoval
instance Storable C'rrd_infoval where
sizeOf _ = 8
alignment = sizeOf
peek p = do
v0 <- peekByteOff p 0
v1 <- peekByteOff p 0
v2 <- peekByteOff p 0
v3 <- peekByteOff p 0
v4 <- peekByteOff p 0
return $ C'rrd_infoval v0 v1 v2 v3 v4
poke p (C'rrd_infoval v0 v1 v2 v3 v4) = do
pokeByteOff p 0 v0
pokeByteOff p 0 v1
pokeByteOff p 0 v2
pokeByteOff p 0 v3
pokeByteOff p 0 v4
return ()
type C'rrd_infoval_t = C'rrd_infoval
data C'rrd_info_t = C'rrd_info_t{
c'rrd_info_t'key :: CString
,
c'rrd_info_t'type :: C'rrd_info_type_t
,
c'rrd_info_t'value :: C'rrd_infoval_t
,
c'rrd_info_t'next :: Ptr C'rrd_info_t
} deriving (Eq,Show)
instance Storable C'rrd_info_t where
sizeOf _ = 20
alignment = sizeOf
peek p = do
v0 <- peekByteOff p 0
v1 <- peekByteOff p 4
v2 <- peekByteOff p 8
v3 <- peekByteOff p 16
return $ C'rrd_info_t v0 v1 v2 v3
poke p (C'rrd_info_t v0 v1 v2 v3) = do
pokeByteOff p 0 v0
pokeByteOff p 4 v1
pokeByteOff p 8 v2
pokeByteOff p 16 v3
return ()
type C'rrd_output_callback_t = FunPtr (Ptr () -> CSize -> Ptr () -> IO CSize)
foreign import ccall "wrapper" mk'rrd_output_callback_t
:: (Ptr () -> CSize -> Ptr () -> IO CSize) -> IO C'rrd_output_callback_t
foreign import ccall "dynamic" mK'rrd_output_callback_t
:: C'rrd_output_callback_t -> (Ptr () -> CSize -> Ptr () -> IO CSize)
foreign import ccall "rrd_create" c'rrd_create
:: CInt -> Ptr CString -> IO CInt
foreign import ccall "&rrd_create" p'rrd_create
:: FunPtr (CInt -> Ptr CString -> IO CInt)
foreign import ccall "rrd_info" c'rrd_info
:: CInt -> Ptr CString -> IO (Ptr C'rrd_info_t)
foreign import ccall "&rrd_info" p'rrd_info
:: FunPtr (CInt -> Ptr CString -> IO (Ptr C'rrd_info_t))
foreign import ccall "inline_rrd_info_push" c'rrd_info_push
:: Ptr C'rrd_info_t -> CString -> C'rrd_info_type_t -> Ptr C'rrd_infoval_t -> IO (Ptr C'rrd_info_t)
foreign import ccall "rrd_info_print" c'rrd_info_print
:: Ptr C'rrd_info_t -> IO ()
foreign import ccall "&rrd_info_print" p'rrd_info_print
:: FunPtr (Ptr C'rrd_info_t -> IO ())
foreign import ccall "rrd_info_free" c'rrd_info_free
:: Ptr C'rrd_info_t -> IO ()
foreign import ccall "&rrd_info_free" p'rrd_info_free
:: FunPtr (Ptr C'rrd_info_t -> IO ())
foreign import ccall "rrd_update" c'rrd_update
:: CInt -> Ptr CString -> IO CInt
foreign import ccall "&rrd_update" p'rrd_update
:: FunPtr (CInt -> Ptr CString -> IO CInt)
foreign import ccall "rrd_update_v" c'rrd_update_v
:: CInt -> Ptr CString -> IO (Ptr C'rrd_info_t)
foreign import ccall "&rrd_update_v" p'rrd_update_v
:: FunPtr (CInt -> Ptr CString -> IO (Ptr C'rrd_info_t))
foreign import ccall "rrd_graph" c'rrd_graph
:: CInt -> Ptr CString -> Ptr (Ptr CString) -> Ptr CInt -> Ptr CInt -> Ptr CFile -> Ptr CDouble -> Ptr CDouble -> IO CInt
foreign import ccall "&rrd_graph" p'rrd_graph
:: FunPtr (CInt -> Ptr CString -> Ptr (Ptr CString) -> Ptr CInt -> Ptr CInt -> Ptr CFile -> Ptr CDouble -> Ptr CDouble -> IO CInt)
foreign import ccall "rrd_graph_v" c'rrd_graph_v
:: CInt -> Ptr CString -> IO (Ptr C'rrd_info_t)
foreign import ccall "&rrd_graph_v" p'rrd_graph_v
:: FunPtr (CInt -> Ptr CString -> IO (Ptr C'rrd_info_t))
foreign import ccall "rrd_fetch" c'rrd_fetch
:: CInt -> Ptr CString -> Ptr CTime -> Ptr CTime -> Ptr CULong -> Ptr CULong -> Ptr (Ptr CString) -> Ptr (Ptr C'rrd_value_t) -> IO CInt
foreign import ccall "&rrd_fetch" p'rrd_fetch
:: FunPtr (CInt -> Ptr CString -> Ptr CTime -> Ptr CTime -> Ptr CULong -> Ptr CULong -> Ptr (Ptr CString) -> Ptr (Ptr C'rrd_value_t) -> IO CInt)
foreign import ccall "rrd_restore" c'rrd_restore
:: CInt -> Ptr CString -> IO CInt
foreign import ccall "&rrd_restore" p'rrd_restore
:: FunPtr (CInt -> Ptr CString -> IO CInt)
foreign import ccall "rrd_dump" c'rrd_dump
:: CInt -> Ptr CString -> IO CInt
foreign import ccall "&rrd_dump" p'rrd_dump
:: FunPtr (CInt -> Ptr CString -> IO CInt)
foreign import ccall "rrd_tune" c'rrd_tune
:: CInt -> Ptr CString -> IO CInt
foreign import ccall "&rrd_tune" p'rrd_tune
:: FunPtr (CInt -> Ptr CString -> IO CInt)
foreign import ccall "rrd_last" c'rrd_last
:: CInt -> Ptr CString -> IO CTime
foreign import ccall "&rrd_last" p'rrd_last
:: FunPtr (CInt -> Ptr CString -> IO CTime)
foreign import ccall "rrd_lastupdate" c'rrd_lastupdate
:: CInt -> Ptr CString -> Ptr CTime -> Ptr CULong -> Ptr (Ptr CString) -> Ptr (Ptr CString) -> IO CInt
foreign import ccall "&rrd_lastupdate" p'rrd_lastupdate
:: FunPtr (CInt -> Ptr CString -> Ptr CTime -> Ptr CULong -> Ptr (Ptr CString) -> Ptr (Ptr CString) -> IO CInt)
foreign import ccall "rrd_first" c'rrd_first
:: CInt -> Ptr CString -> IO CTime
foreign import ccall "&rrd_first" p'rrd_first
:: FunPtr (CInt -> Ptr CString -> IO CTime)
foreign import ccall "rrd_resize" c'rrd_resize
:: CInt -> Ptr CString -> IO CInt
foreign import ccall "&rrd_resize" p'rrd_resize
:: FunPtr (CInt -> Ptr CString -> IO CInt)
foreign import ccall "rrd_strversion" c'rrd_strversion
:: IO CString
foreign import ccall "&rrd_strversion" p'rrd_strversion
:: FunPtr (IO CString)
foreign import ccall "rrd_version" c'rrd_version
:: IO CDouble
foreign import ccall "&rrd_version" p'rrd_version
:: FunPtr (IO CDouble)
foreign import ccall "rrd_xport" c'rrd_xport
:: CInt -> Ptr CString -> Ptr CInt -> Ptr CTime -> Ptr CTime -> Ptr CULong -> Ptr CULong -> Ptr (Ptr CString) -> Ptr (Ptr C'rrd_value_t) -> IO CInt
foreign import ccall "&rrd_xport" p'rrd_xport
:: FunPtr (CInt -> Ptr CString -> Ptr CInt -> Ptr CTime -> Ptr CTime -> Ptr CULong -> Ptr CULong -> Ptr (Ptr CString) -> Ptr (Ptr C'rrd_value_t) -> IO CInt)
foreign import ccall "rrd_flushcached" c'rrd_flushcached
:: CInt -> Ptr CString -> IO CInt
foreign import ccall "&rrd_flushcached" p'rrd_flushcached
:: FunPtr (CInt -> Ptr CString -> IO CInt)
foreign import ccall "rrd_freemem" c'rrd_freemem
:: Ptr a -> IO ()
foreign import ccall "&rrd_freemem" p'rrd_freemem
:: FunPtr (Ptr a -> IO ())
foreign import ccall "rrd_create_r" c'rrd_create_r
:: CString -> CULong -> CTime -> CInt -> Ptr CString -> IO CInt
foreign import ccall "&rrd_create_r" p'rrd_create_r
:: FunPtr (CString -> CULong -> CTime -> CInt -> Ptr CString -> IO CInt)
foreign import ccall "rrd_info_r" c'rrd_info_r
:: CString -> IO (Ptr C'rrd_info_t)
foreign import ccall "&rrd_info_r" p'rrd_info_r
:: FunPtr (CString -> IO (Ptr C'rrd_info_t))
foreign import ccall "rrd_update_r" c'rrd_update_r
:: CString -> CString -> CInt -> Ptr CString -> IO CInt
foreign import ccall "&rrd_update_r" p'rrd_update_r
:: FunPtr (CString -> CString -> CInt -> Ptr CString -> IO CInt)
foreign import ccall "rrd_fetch_r" c'rrd_fetch_r
:: CString -> CString -> Ptr CTime -> Ptr CTime -> Ptr CULong -> Ptr CULong -> Ptr (Ptr CString) -> Ptr (Ptr C'rrd_value_t) -> IO CInt
foreign import ccall "&rrd_fetch_r" p'rrd_fetch_r
:: FunPtr (CString -> CString -> Ptr CTime -> Ptr CTime -> Ptr CULong -> Ptr CULong -> Ptr (Ptr CString) -> Ptr (Ptr C'rrd_value_t) -> IO CInt)
foreign import ccall "rrd_dump_r" c'rrd_dump_r
:: CString -> CString -> IO CInt
foreign import ccall "&rrd_dump_r" p'rrd_dump_r
:: FunPtr (CString -> CString -> IO CInt)
foreign import ccall "rrd_last_r" c'rrd_last_r
:: CString -> IO CTime
foreign import ccall "&rrd_last_r" p'rrd_last_r
:: FunPtr (CString -> IO CTime)
foreign import ccall "rrd_lastupdate_r" c'rrd_lastupdate_r
:: CString -> Ptr CTime -> Ptr CULong -> Ptr (Ptr CString) -> Ptr (Ptr CString) -> IO CInt
foreign import ccall "&rrd_lastupdate_r" p'rrd_lastupdate_r
:: FunPtr (CString -> Ptr CTime -> Ptr CULong -> Ptr (Ptr CString) -> Ptr (Ptr CString) -> IO CInt)
foreign import ccall "rrd_first_r" c'rrd_first_r
:: CString -> CInt -> IO CTime
foreign import ccall "&rrd_first_r" p'rrd_first_r
:: FunPtr (CString -> CInt -> IO CTime)
foreign import ccall "rrd_dump_cb_r" c'rrd_dump_cb_r
:: CString -> CInt -> C'rrd_output_callback_t -> Ptr b -> IO CInt
foreign import ccall "&rrd_dump_cb_r" p'rrd_dump_cb_r
:: FunPtr (CString -> CInt -> C'rrd_output_callback_t -> Ptr b -> IO CInt)
type C'rrd_timetype_t = CUInt
c'ABSOLUTE_TIME = 0
c'ABSOLUTE_TIME :: (Num a) => a
c'RELATIVE_TO_START_TIME = 1
c'RELATIVE_TO_START_TIME :: (Num a) => a
c'RELATIVE_TO_END_TIME = 2
c'RELATIVE_TO_END_TIME :: (Num a) => a
c'TIME_OK = wordPtrToPtr 0
c'TIME_OK :: Ptr a
data C'rrd_time_value = C'rrd_time_value{
c'rrd_time_value'type :: C'rrd_timetype_t
,
c'rrd_time_value'offset :: CLong
,
c'rrd_time_value'tm :: C'tm
} deriving (Eq,Show)
instance Storable C'rrd_time_value where
sizeOf _ = 52
alignment = sizeOf
peek p = do
v0 <- peekByteOff p 0
v1 <- peekByteOff p 4
v2 <- peekByteOff p 8
return $ C'rrd_time_value v0 v1 v2
poke p (C'rrd_time_value v0 v1 v2) = do
pokeByteOff p 0 v0
pokeByteOff p 4 v1
pokeByteOff p 8 v2
return ()
type C'rrd_time_value_t = C'rrd_time_value
foreign import ccall "rrd_parsetime" c'rrd_parsetime
:: CString -> Ptr C'rrd_time_value_t -> IO CString
foreign import ccall "&rrd_parsetime" p'rrd_parsetime
:: FunPtr (CString -> Ptr C'rrd_time_value_t -> IO CString)
data C'rrd_context = C'rrd_context{
c'rrd_context'lib_errstr :: [CChar]
,
c'rrd_context'rrd_error :: [CChar]
} deriving (Eq,Show)
instance Storable C'rrd_context where
sizeOf _ = 4352
alignment = sizeOf
peek p = do
v0 <- peekArray 256 (plusPtr p 0)
v1 <- peekArray 4096 (plusPtr p 256)
return $ C'rrd_context v0 v1
poke p (C'rrd_context v0 v1) = do
pokeArray (plusPtr p 0) (take 256 v0)
pokeArray (plusPtr p 256) (take 4096 v1)
return ()
type C'rrd_context_t = C'rrd_context
foreign import ccall "rrd_get_context" c'rrd_get_context
:: IO (Ptr C'rrd_context_t)
foreign import ccall "&rrd_get_context" p'rrd_get_context
:: FunPtr (IO (Ptr C'rrd_context_t))
foreign import ccall "rrd_proc_start_end" c'rrd_proc_start_end
:: Ptr C'rrd_time_value_t -> Ptr C'rrd_time_value_t -> Ptr CTime -> Ptr CTime -> IO CInt
foreign import ccall "&rrd_proc_start_end" p'rrd_proc_start_end
:: FunPtr (Ptr C'rrd_time_value_t -> Ptr C'rrd_time_value_t -> Ptr CTime -> Ptr CTime -> IO CInt)
foreign import ccall "rrd_clear_error" c'rrd_clear_error
:: IO ()
foreign import ccall "&rrd_clear_error" p'rrd_clear_error
:: FunPtr (IO ())
foreign import ccall "rrd_test_error" c'rrd_test_error
:: IO CInt
foreign import ccall "&rrd_test_error" p'rrd_test_error
:: FunPtr (IO CInt)
foreign import ccall "rrd_get_error" c'rrd_get_error
:: IO CString
foreign import ccall "&rrd_get_error" p'rrd_get_error
:: FunPtr (IO CString)
foreign import ccall "rrd_strerror" c'rrd_strerror
:: CInt -> IO CString
foreign import ccall "&rrd_strerror" p'rrd_strerror
:: FunPtr (CInt -> IO CString)
foreign import ccall "rrd_new_context" c'rrd_new_context
:: IO (Ptr C'rrd_context_t)
foreign import ccall "&rrd_new_context" p'rrd_new_context
:: FunPtr (IO (Ptr C'rrd_context_t))
foreign import ccall "rrd_free_context" c'rrd_free_context
:: Ptr C'rrd_context_t -> IO ()
foreign import ccall "&rrd_free_context" p'rrd_free_context
:: FunPtr (Ptr C'rrd_context_t -> IO ())
foreign import ccall "rrd_random" c'rrd_random
:: IO CLong
foreign import ccall "&rrd_random" p'rrd_random
:: FunPtr (IO CLong)
foreign import ccall "rrd_add_ptr" c'rrd_add_ptr
:: Ptr (Ptr (Ptr a)) -> Ptr CSize -> Ptr a -> IO CInt
foreign import ccall "&rrd_add_ptr" p'rrd_add_ptr
:: FunPtr (Ptr (Ptr (Ptr a)) -> Ptr CSize -> Ptr a -> IO CInt)
foreign import ccall "rrd_add_strdump" c'rrd_add_strdump
:: Ptr (Ptr CString) -> Ptr CSize -> CString -> IO CInt
foreign import ccall "&rrd_add_strdump" p'rrd_add_strdump
:: FunPtr (Ptr (Ptr CString) -> Ptr CSize -> CString -> IO CInt)
foreign import ccall "rrd_free_ptrs" c'rrd_free_ptrs
:: Ptr (Ptr (Ptr a)) -> CSize -> IO ()
foreign import ccall "&rrd_free_ptrs" p'rrd_free_ptrs
:: FunPtr (Ptr (Ptr (Ptr a)) -> CSize -> IO ())
foreign import ccall "rrd_mkdir_p" c'rrd_mkdir_p
:: CString -> CMode -> IO CInt
foreign import ccall "&rrd_mkdir_p" p'rrd_mkdir_p
:: FunPtr (CString -> CMode -> IO CInt)