1 #include <bindings.dsl.h>
4 -- |<http://oss.oetiker.ch/rrdtool/doc/librrd.en.html>
6 module Bindings.Librrd where
7 import Bindings.Posix.Time
8 import System.Posix.Types
11 -- Formerly rrd_nan_inf.h
12 #cinline DNAN, IO CDouble
13 #cinline DINF, IO CDouble
14 #ccall rrd_set_to_DNAN, IO CDouble
15 #ccall rrd_set_to_DINF, IO CDouble
17 -- Transplanted from rrd_format.h
18 #synonym_t rrd_value_t, CDouble
20 -- Information about an rrd file
21 #starttype struct rrd_file_t
22 #field header_len, COff
23 #field file_len , COff
28 -- information used for the conventional file access methods
29 #starttype struct rrd_simple_file_t
32 #field file_start, Ptr CChar
34 #field mm_flags , CInt
39 #starttype struct rrd_blob_t
41 #field ptr , Ptr CUChar
44 #integral_t rrd_info_type_t
51 #starttype union rrd_infoval
52 #union_field u_cnt, CULong
53 #union_field u_val, <rrd_value_t>
54 #union_field u_str, CString
55 #union_field u_int, CInt
56 #union_field u_blo, <rrd_blob_t>
58 #synonym_t rrd_infoval_t, <rrd_infoval>
60 #starttype struct rrd_info_t
62 #field type , <rrd_info_type_t>
63 #field value, <rrd_infoval_t>
64 #field next , Ptr <rrd_info_t>
67 {-|The correct type for this callback should be @'Ptr' a -> 'CSize'
68 -> 'Ptr' b -> 'IO' 'CSize'@ but that's impossible because of
69 bindings-DSL restriction.
71 #callback rrd_output_callback_t, Ptr () -> CSize -> Ptr () -> IO CSize
73 -- main function blocks
74 #ccall rrd_create , CInt -> Ptr CString -> IO CInt
75 #ccall rrd_info , CInt -> Ptr CString -> IO (Ptr <rrd_info_t>)
76 #cinline rrd_info_push , Ptr <rrd_info_t> -> CString -> <rrd_info_type_t> -> Ptr <rrd_infoval_t> -> IO (Ptr <rrd_info_t>)
77 #ccall rrd_info_print , Ptr <rrd_info_t> -> IO ()
78 #ccall rrd_info_free , Ptr <rrd_info_t> -> IO ()
79 #ccall rrd_update , CInt -> Ptr CString -> IO CInt
80 #ccall rrd_update_v , CInt -> Ptr CString -> IO (Ptr <rrd_info_t>)
81 #ccall rrd_graph , CInt -> Ptr CString -> Ptr (Ptr CString) -> Ptr CInt -> Ptr CInt -> Ptr CFile -> Ptr CDouble -> Ptr CDouble -> IO CInt
82 #ccall rrd_graph_v , CInt -> Ptr CString -> IO (Ptr <rrd_info_t>)
83 #ccall rrd_fetch , CInt -> Ptr CString -> Ptr CTime -> Ptr CTime -> Ptr CULong -> Ptr CULong -> Ptr (Ptr CString) -> Ptr (Ptr <rrd_value_t>) -> IO CInt
84 #ccall rrd_restore , CInt -> Ptr CString -> IO CInt
85 #ccall rrd_dump , CInt -> Ptr CString -> IO CInt
86 #ccall rrd_tune , CInt -> Ptr CString -> IO CInt
87 #ccall rrd_last , CInt -> Ptr CString -> IO CTime
88 #ccall rrd_lastupdate , CInt -> Ptr CString -> Ptr CTime -> Ptr CULong -> Ptr (Ptr CString) -> Ptr (Ptr CString) -> IO CInt
89 #ccall rrd_first , CInt -> Ptr CString -> IO CTime
90 #ccall rrd_resize , CInt -> Ptr CString -> IO CInt
91 #ccall rrd_strversion , IO CString
92 #ccall rrd_version , IO CDouble
93 #ccall rrd_xport , CInt -> Ptr CString -> Ptr CInt -> Ptr CTime -> Ptr CTime -> Ptr CULong -> Ptr CULong -> Ptr (Ptr CString) -> Ptr (Ptr <rrd_value_t>) -> IO CInt
94 #ccall rrd_flushcached , CInt -> Ptr CString -> IO CInt
95 #ccall rrd_freemem , Ptr a -> IO ()
97 -- thread-safe (hopefully)
98 #ccall rrd_create_r , CString -> CULong -> CTime -> CInt -> Ptr CString -> IO CInt
99 -- NOTE: rrd_update_r are only thread-safe if no at-style time
100 -- specifications get used!!!
101 #ccall rrd_info_r , CString -> IO (Ptr <rrd_info_t>)
102 #ccall rrd_update_r , CString -> CString -> CInt -> Ptr CString -> IO CInt
103 #ccall rrd_fetch_r , CString -> CString -> Ptr CTime -> Ptr CTime -> Ptr CULong -> Ptr CULong -> Ptr (Ptr CString) -> Ptr (Ptr <rrd_value_t>) -> IO CInt
104 #ccall rrd_dump_r , CString -> CString -> IO CInt
105 #ccall rrd_last_r , CString -> IO CTime
106 #ccall rrd_lastupdate_r, CString -> Ptr CTime -> Ptr CULong -> Ptr (Ptr CString) -> Ptr (Ptr CString) -> IO CInt
107 #ccall rrd_first_r , CString -> CInt -> IO CTime
109 #ccall rrd_dump_cb_r , CString -> CInt -> <rrd_output_callback_t> -> Ptr b -> IO CInt
111 -- Transplanted from rrd_parsetime.h
112 #integral_t rrd_timetype_t
114 #num RELATIVE_TO_START_TIME
115 #num RELATIVE_TO_END_TIME
119 #starttype struct rrd_time_value
120 #field type , <rrd_timetype_t>
124 #synonym_t rrd_time_value_t, <rrd_time_value>
126 #ccall rrd_parsetime, CString -> Ptr <rrd_time_value_t> -> IO CString
128 #starttype struct rrd_context
129 #array_field lib_errstr, CChar
130 #array_field rrd_error , CChar
132 #synonym_t rrd_context_t, <rrd_context>
134 -- returns the current per-thread rrd_context
135 #ccall rrd_get_context, IO (Ptr <rrd_context_t>)
137 #ccall rrd_proc_start_end, Ptr <rrd_time_value_t> -> Ptr <rrd_time_value_t> -> Ptr CTime -> Ptr CTime -> IO CInt
140 -- rrd_set_error() is unavailable as it uses C varargs.
141 #ccall rrd_clear_error, IO ()
142 #ccall rrd_test_error , IO CInt
143 #ccall rrd_get_error , IO CString
144 -- rrd_strerror is thread safe, but still it uses a global buffer (but
145 -- one per thread), thus subsequent calls within a single thread
146 -- overwrite the same buffer
147 #ccall rrd_strerror , CInt -> IO CString
149 -- MULTITHREADED HELPER FUNCTIONS
150 #ccall rrd_new_context , IO (Ptr <rrd_context_t>)
151 #ccall rrd_free_context, Ptr <rrd_context_t> -> IO ()
154 #ccall rrd_random , IO CLong
155 #ccall rrd_add_ptr , Ptr (Ptr (Ptr a)) -> Ptr CSize -> Ptr a -> IO CInt
156 #ccall rrd_add_strdump, Ptr (Ptr CString) -> Ptr CSize -> CString -> IO CInt
157 #ccall rrd_free_ptrs , Ptr (Ptr (Ptr a)) -> CSize -> IO ()
158 #ccall rrd_mkdir_p , CString -> CMode -> IO CInt