-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathblobstorage.go
56 lines (46 loc) · 1.58 KB
/
blobstorage.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/*
// ******************************************************************
// Purpose: exported public functions that handles blobstorage functions
// from libindy
// Author: [email protected]
// Notes:
// Copyright (c): Siemens SRL
// This work is licensed under the terms of the Apache License Version 2.0. See
// the LICENSE.txt file in the top-level directory.
// ******************************************************************
*/
package indySDK
/*
#include <stdlib.h>
*/
import "C"
import (
"github.com/joyride9999/IndySdkGoBindings/blobstorage"
"unsafe"
)
// IndyOpenBlobStorageReader opens blob reader
func IndyOpenBlobStorageReader(blobStorageType string, config string) (blobHandle int, err error) {
upBlobStorageType := unsafe.Pointer(C.CString(blobStorageType))
defer C.free(upBlobStorageType)
upConfig := unsafe.Pointer(C.CString(config))
defer C.free(upConfig)
channel := blobstorage.OpenBlobStorageReader(upBlobStorageType, upConfig)
result := <-channel
if result.Error != nil {
return -1, result.Error
}
return result.Results[0].(int), result.Error
}
// IndyOpenBlobStorageWriter opens blob writer
func IndyOpenBlobStorageWriter(blobStorageType string, config string) (blobHandle int, err error) {
upBlobStorageType := unsafe.Pointer(C.CString(blobStorageType))
defer C.free(upBlobStorageType)
upConfig := unsafe.Pointer(C.CString(config))
defer C.free(upConfig)
channel := blobstorage.OpenBlobStorageWriter(upBlobStorageType, upConfig)
result := <-channel
if result.Error != nil {
return -1, result.Error
}
return result.Results[0].(int), result.Error
}