-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathkeycard_go.nim
65 lines (51 loc) · 2.08 KB
/
keycard_go.nim
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
57
58
59
60
61
62
63
64
65
import ./keycard_go/impl as go_shim
export KeycardSignalCallback
proc keycardInitFlow*(storageDir: string): string =
var funcOut = go_shim.keycardInitFlow(storageDir.cstring)
defer: go_shim.free(funcOut)
return $funcOut
proc keycardStartFlow*(flowType: int, jsonParams: string): string =
var funcOut = go_shim.keycardStartFlow(flowType.cint, jsonParams.cstring)
defer: go_shim.free(funcOut)
return $funcOut
proc keycardResumeFlow*(jsonParams: string): string =
var funcOut = go_shim.keycardResumeFlow(jsonParams.cstring)
defer: go_shim.free(funcOut)
return $funcOut
proc keycardCancelFlow*(): string =
var funcOut = go_shim.keycardCancelFlow()
defer: go_shim.free(funcOut)
return $funcOut
proc keycardInitializeRPC*(): string =
var funcOut = go_shim.keycardInitializeRPC()
defer: go_shim.free(funcOut)
return $funcOut
proc keycardCallRPC*(params: string): string =
var funcOut = go_shim.keycardCallRPC(params.cstring)
defer: go_shim.free(funcOut)
return $funcOut
proc setSignalEventCallback*(callback: KeycardSignalCallback) =
go_shim.setSignalEventCallback(callback)
# availale in test mode only
proc mockedLibRegisterKeycard*(cardIndex: int, readerState: int, keycardState: int, mockedKeycard: string, mockedKeycardHelper: string): string =
var funcOut = go_shim.mockedLibRegisterKeycard(cardIndex.cint, readerState.cint, keycardState.cint, mockedKeycard.cstring, mockedKeycardHelper.cstring)
defer: go_shim.free(funcOut)
return $funcOut
proc mockedLibReaderPluggedIn*(): string =
var funcOut = go_shim.mockedLibReaderPluggedIn()
defer: go_shim.free(funcOut)
return $funcOut
proc mockedLibReaderUnplugged*(): string =
var funcOut = go_shim.mockedLibReaderUnplugged()
defer: go_shim.free(funcOut)
return $funcOut
proc mockedLibKeycardInserted*(cardIndex: int): string =
var funcOut = go_shim.mockedLibKeycardInserted(cardIndex.cint)
defer: go_shim.free(funcOut)
return $funcOut
proc mockedLibKeycardRemoved*(): string =
var funcOut = go_shim.mockedLibKeycardRemoved()
defer: go_shim.free(funcOut)
return $funcOut
proc ResetAPI*() =
go_shim.resetAPI()