summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile8
-rw-r--r--cmd/librrd/rrd_h.go302
2 files changed, 306 insertions, 4 deletions
diff --git a/Makefile b/Makefile
index 43bc7d5..c4f0c55 100644
--- a/Makefile
+++ b/Makefile
@@ -4,12 +4,12 @@ all: bin/rrdcreate
all: bin/rrdinfo
all: bin/rrdtool
all: bin/rrdupdate
-all: bin/librrd.so
+all: bin/librrd.so bin/librrd.h
.PHONY: all
-bin/%.so: cmd/%/
- go build -o $@ -buildmode=c-shared ./cmd/$*
-bin/%: cmd/%/
+bin/%.so bin/%.h: cmd/%/ FORCE
+ go build -o $(@D)/$*.so -buildmode=c-shared ./cmd/$*
+bin/%: cmd/%/ FORCE
go build -o $@ ./cmd/$*
.PHONY: FORCE
diff --git a/cmd/librrd/rrd_h.go b/cmd/librrd/rrd_h.go
new file mode 100644
index 0000000..bdf55aa
--- /dev/null
+++ b/cmd/librrd/rrd_h.go
@@ -0,0 +1,302 @@
+package main
+
+import "unsafe"
+
+//#include <sys/types.h> /* for time_t, size_t, ssize_t, mode_t, off_t */
+//#include <stdio.h> /* for FILE */
+//
+//typedef double rrd_value_t;
+//
+//typedef struct rrd_blob_t {
+// unsigned long size; /* size of the blob */
+// unsigned char * ptr; /* pointer */
+//} rrd_blob_t;
+//
+//typedef enum rrd_info_type {
+// RD_I_VAL = 0,
+// RD_I_CNT,
+// RD_I_STR,
+// RD_I_INT,
+// RD_I_BLO
+//} rrd_info_type_t;
+//
+//typedef union rrd_infoval {
+// unsigned long u_cnt;
+// rrd_value_t u_val;
+// char * u_str;
+// int u_int;
+// rrd_blob_t u_blo;
+//} rrd_infoval_t;
+//
+//typedef size_t (* rrd_output_callback_t)(const void *, size_t, void *);
+//
+//typedef enum {
+// ABSOLUTE_TIME,
+// RELATIVE_TO_START_TIME,
+// RELATIVE_TO_END_TIME,
+// RELATIVE_TO_EPOCH
+//} rrd_timetype_t;
+//
+///* Types for opaque pointers */
+//typedef struct rra_def_t rra_def_t;
+//typedef struct rrd_context_t rrd_context_t;
+//typedef struct rrd_file_t rrd_file_t;
+//typedef struct rrd_info_t rrd_info_t;
+//typedef struct rrd_t rrd_t;
+//typedef struct rrd_time_value_t rrd_time_value_t;
+import "C"
+
+// main function blocks ////////////////////////////////////////////////////////
+
+//export rrd_create
+func rrd_create(_ C.int, _ **C.char) C.int { panic("not implemented") }
+
+//export rrd_info
+func rrd_info(_ C.int, _ **C.char) *C.rrd_info_t { panic("not implemented") }
+
+//export rrd_info_push
+func rrd_info_push(_ *C.rrd_info_t, _ *C.char, _ C.rrd_info_type_t, _ C.rrd_infoval_t) *C.rrd_info_t {
+ panic("not implemented")
+}
+
+//export rrd_info_print
+func rrd_info_print(data *C.rrd_info_t) { panic("not implemented") }
+
+//export rrd_info_free
+func rrd_info_free(_ *C.rrd_info_t) { panic("not implemented") }
+
+//export rrd_list
+func rrd_list(_ C.int, _ **C.char) *C.char { panic("not implemented") }
+
+//export rrd_list_r
+func rrd_list_r(_ C.int, dirname *C.char) *C.char { panic("not implemented") }
+
+//export rrd_update
+func rrd_update(_ C.int, _ **C.char) C.int { panic("not implemented") }
+
+//export rrd_update_v
+func rrd_update_v(_ C.int, _ **C.char) *C.rrd_info_t { panic("not implemented") }
+
+//export rrd_graph
+func rrd_graph(_ C.int, _ **C.char, _ ***C.char, _ *C.int, _ *C.int, _ *C.FILE, _ *C.double, _ *C.double) C.int {
+ panic("not implemented")
+}
+
+//export rrd_graph_v
+func rrd_graph_v(_ C.int, _ **C.char) *C.rrd_info_t { panic("not implemented") }
+
+//export rrd_fetch
+func rrd_fetch(_ C.int, _ **C.char, _ *C.time_t, _ *C.time_t, _ *C.ulong, _ *C.ulong, _ ***C.char, _ **C.rrd_value_t) C.int {
+ panic("not implemented")
+}
+
+//export rrd_restore
+func rrd_restore(_ C.int, _ **C.char) C.int { panic("not implemented") }
+
+//export rrd_dump
+func rrd_dump(_ C.int, _ **C.char) C.int { panic("not implemented") }
+
+//export rrd_tune
+func rrd_tune(_ C.int, _ **C.char) C.int { panic("not implemented") }
+
+//export rrd_last
+func rrd_last(_ C.int, _ **C.char) C.time_t { panic("not implemented") }
+
+//export rrd_lastupdate
+func rrd_lastupdate(argc C.int, argv **C.char) C.int { panic("not implemented") }
+
+//export rrd_first
+func rrd_first(_ C.int, _ **C.char) C.time_t { panic("not implemented") }
+
+//export rrd_resize
+func rrd_resize(_ C.int, _ **C.char) C.int { panic("not implemented") }
+
+//export rrd_strversion
+func rrd_strversion() *C.char { panic("not implemented") }
+
+//export rrd_version
+func rrd_version() C.double { panic("not implemented") }
+
+//export rrd_xport
+func rrd_xport(_ C.int, _ **C.char, _ *C.int, _ *C.time_t, _ *C.time_t, _ *C.ulong, _ *C.ulong, _ ***C.char, _ **C.rrd_value_t) C.int {
+ panic("not implemented")
+}
+
+//export rrd_flushcached
+func rrd_flushcached(argc C.int, argv **C.char) C.int { panic("not implemented") }
+
+//export rrd_freemem
+func rrd_freemem(mem unsafe.Pointer) { panic("not implemented") }
+
+// thread-safe (hopefully) /////////////////////////////////////////////////////
+
+//export rrd_create_r
+func rrd_create_r(filename *C.char, pdp_step C.ulong, last_up C.time_t, argc C.int, argv **C.char) C.int {
+ panic("not implemented")
+}
+
+//export rrd_create_r2
+func rrd_create_r2(filename *C.char, pdp_step C.ulong, last_up C.time_t, no_overwrite C.int, sources **C.char, _template *C.char, argc C.int, argv **C.char) C.int {
+ panic("not implemented")
+}
+
+//export rrd_info_r
+func rrd_info_r(*C.char) *C.rrd_info_t { panic("not implemented") }
+
+//export rrd_update_r
+func rrd_update_r(filename *C.char, _template *C.char, argc C.int, argv **C.char) C.int {
+ panic("not implemented")
+}
+
+//export rrd_update_v_r
+func rrd_update_v_r(filename *C.char, _template *C.char, argc C.int, argv **C.char, pcdp_summary *C.rrd_info_t) C.int {
+ panic("not implemented")
+}
+
+//export rrd_updatex_r
+func rrd_updatex_r(filename *C.char, _template *C.char, extra_flags C.int, argc C.int, argv **C.char) C.int {
+ panic("not implemented")
+}
+
+//export rrd_updatex_v_r
+func rrd_updatex_v_r(filename *C.char, _template *C.char, extra_flags C.int, argc C.int, argv **C.char, pcdp_summary *C.rrd_info_t) C.int {
+ panic("not implemented")
+}
+
+//export rrd_fetch_r
+func rrd_fetch_r(filename *C.char, cf *C.char, start *C.time_t, end *C.time_t, step *C.ulong, ds_cnt *C.ulong, ds_namv ***C.char, data **C.rrd_value_t) C.int {
+ panic("not implemented")
+}
+
+//export rrd_dump_opt_r
+func rrd_dump_opt_r(filename *C.char, outname *C.char, opt_noheader C.int) C.int {
+ panic("not implemented")
+}
+
+//export rrd_dump_r
+func rrd_dump_r(filename *C.char, outname *C.char) C.int { panic("not implemented") }
+
+//export rrd_last_r
+func rrd_last_r(filename *C.char) C.time_t { panic("not implemented") }
+
+//export rrd_lastupdate_r
+func rrd_lastupdate_r(filename *C.char, ret_last_update *C.time_t, ret_ds_count *C.ulong, ret_ds_names ***C.char, ret_last_ds ***C.char) C.int {
+ panic("not implemented")
+}
+
+//export rrd_first_r
+func rrd_first_r(filename *C.char, rraindex C.int) C.time_t { panic("not implemented") }
+
+//export rrd_dump_cb_r
+func rrd_dump_cb_r(filename *C.char, opt_header C.int, cb C.rrd_output_callback_t, user unsafe.Pointer) C.int {
+ panic("not implemented")
+}
+
+//export rrd_parsetime
+func rrd_parsetime(spec *C.char, ptv *C.rrd_time_value_t) *C.char { panic("not implemented") }
+
+//export rrd_get_context
+func rrd_get_context() *C.rrd_context_t { panic("not implemented") }
+
+//export rrd_proc_start_end
+func rrd_proc_start_end(*C.rrd_time_value_t, *C.rrd_time_value_t, *C.time_t, *C.time_t) C.int {
+ panic("not implemented")
+}
+
+// helper functions ////////////////////////////////////////////////////////////
+
+//func rrd_set_error(_ *C.char, args ...TODO) { panic("not implemented") }
+
+//export rrd_clear_error
+func rrd_clear_error() { panic("not implemented") }
+
+//export rrd_test_error
+func rrd_test_error() C.int { panic("not implemented") }
+
+//export rrd_get_error
+func rrd_get_error() *C.char { panic("not implemented") }
+
+//export rrd_strerror
+func rrd_strerror(err C.int) *C.char { panic("not implemented") }
+
+// multithreaded helper functions //////////////////////////////////////////////
+
+//export rrd_new_context
+func rrd_new_context() *C.rrd_context_t { panic("not implemented") }
+
+//export rrd_free_context
+func rrd_free_context(buf *C.rrd_context_t) { panic("not implemented") }
+
+// utility functions ///////////////////////////////////////////////////////////
+
+//export rrd_random
+func rrd_random() C.long { panic("not implemented") }
+
+//export rrd_add_ptr_chunk
+func rrd_add_ptr_chunk(dest **unsafe.Pointer, dest_size *C.size_t, src unsafe.Pointer, alloc *C.size_t, chunk C.size_t) C.int {
+ panic("not implemented")
+}
+
+//export rrd_add_ptr
+func rrd_add_ptr(dest **unsafe.Pointer, dest_size *C.size_t, src unsafe.Pointer) C.int {
+ panic("not implemented")
+}
+
+//export rrd_add_strdup
+func rrd_add_strdup(dest ***C.char, dest_size *C.size_t, src *C.char) C.int { panic("not implemented") }
+
+//export rrd_add_strdup_chunk
+func rrd_add_strdup_chunk(dest ***C.char, dest_size *C.size_t, src *C.char, alloc *C.size_t, chunk C.size_t) C.int {
+ panic("not implemented")
+}
+
+//export rrd_free_ptrs
+func rrd_free_ptrs(src **unsafe.Pointer, cnt *C.size_t) { panic("not implemented") }
+
+//export rrd_mkdir_p
+func rrd_mkdir_p(pathname *C.char, mode C.mode_t) C.int { panic("not implemented") }
+
+//export rrd_scaled_duration
+func rrd_scaled_duration(token *C.char, divisor C.ulong, valuep *C.ulong) *C.char {
+ panic("not implemented")
+}
+
+//export rrd_thread_init
+func rrd_thread_init() { panic("not implemented") }
+
+// internal ////////////////////////////////////////////////////////////////////
+
+//export rrd_free
+func rrd_free(rrd *C.rrd_t) { panic("internal") }
+
+//export rrd_init
+func rrd_init(rrd *C.rrd_t) { panic("internal") }
+
+//export rrd_open
+func rrd_open(file_name *C.char, rrd *C.rrd_t, rdwr C.uint) *C.rrd_file_t { panic("internal") }
+
+//export rrd_dontneed
+func rrd_dontneed(rrd_file *C.rrd_file_t, rrd *C.rrd_t) { panic("internal") }
+
+//export rrd_close
+func rrd_close(rrd_file *C.rrd_file_t) C.int { panic("internal") }
+
+//export rrd_read
+func rrd_read(rrd_file *C.rrd_file_t, buf unsafe.Pointer, count C.size_t) C.ssize_t { panic("internal") }
+
+//export rrd_write
+func rrd_write(rrd_file *C.rrd_file_t, buf unsafe.Pointer, count C.size_t) C.ssize_t {
+ panic("internal")
+}
+
+//export rrd_flush
+func rrd_flush(rrd_file *C.rrd_file_t) { panic("internal") }
+
+//export rrd_seek
+func rrd_seek(rrd_file *C.rrd_file_t, off C.off_t, whence C.int) C.off_t { panic("internal") }
+
+//export rrd_tell
+func rrd_tell(rrd_file *C.rrd_file_t) C.off_t { panic("internal") }
+
+//export rrd_lock
+func rrd_lock(file *C.rrd_file_t) C.int { panic("internal") }