search for: implgetsize

Displaying 3 results from an estimated 3 matches for "implgetsize".

2020 Apr 21
0
Re: [PATCH nbdkit v2] Add the ability to write plugins in golang.
...ce { id := uint(uintptr(handle)) conn, ok = connectionMap[id] if !ok { panic("Connection %d was not open", id) } } //export implClose func implClose(handle unsafe.Pointer) { conn := getConn(handle) conn.Close() delete(connectionMap, id) } //export implGetSize func implGetSize(handle unsafe.Pointer) C.int64_t { conn := getConn(handle) size, err := conn.GetSize() if err != nil { set_error(err) return -1 } return C.int64_t(size) } > diff --git a/plugins/golang/test/test.go b/plugins/golang/test/test.go > new file mode 100644...
2020 Apr 21
2
[PATCH nbdkit v2] Add the ability to write plugins in golang.
...:= pluginImpl.Open(readonly) + if err != nil { + set_error(err) + return nil + } + if h == 0 { + panic("Open method: handle must be != 0") + } + return unsafe.Pointer(h) +} + +//export implClose +func implClose(handle unsafe.Pointer) { + pluginImpl.Close(uintptr(handle)) +} + +//export implGetSize +func implGetSize(handle unsafe.Pointer) C.int64_t { + size, err := pluginImpl.GetSize(uintptr(handle)) + if err != nil { + set_error(err) + return -1 + } + return C.int64_t(size) +} + +//export implPRead +func implPRead(handle unsafe.Pointer, buf unsafe.Pointer, + count C.uint32_t, offset C.uint...
2020 Apr 23
2
Re: [PATCH nbdkit v2] Add the ability to write plugins in golang.
...tr(handle) + h, ok := connectionMap[id] + if !ok { + panic(fmt.Sprintf("connection %d was not open", id)) + } + return h +} + +//export implClose +func implClose(handle unsafe.Pointer) { + h := getConn(handle) + h.Close() + id := uintptr(handle) + delete(connectionMap, id) +} + +//export implGetSize +func implGetSize(handle unsafe.Pointer) C.int64_t { + h := getConn(handle) + size, err := h.GetSize() + if err != nil { + set_error(err) + return -1 + } + return C.int64_t(size) +} + +//export implPRead +func implPRead(handle unsafe.Pointer, buf unsafe.Pointer, + count C.uint32_t, offset C.uint6...