forked from gokalkan/gokalkan
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkc_init.go
More file actions
46 lines (39 loc) · 880 Bytes
/
kc_init.go
File metadata and controls
46 lines (39 loc) · 880 Bytes
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
package gokalkan
// #cgo LDFLAGS: -ldl
// #include <dlfcn.h>
// #include <stdio.h>
// #include "KalkanCrypt.h"
//
// void getFunctionList(void *f) {
// void (*KC_GetFunctionList)(stKCFunctionsType **);
// KC_GetFunctionList = (void (*)(stKCFunctionsType **))f;
// KC_GetFunctionList(&kc_funcs);
// }
//
// int init() {
// int rv = (kc_funcs)->KC_Init();
// return rv;
// }
import "C"
import (
"fmt"
)
// KCInit инициализирует библиотеку
func (cli *KCClient) KCInit() (err error) {
defer func() {
if r := recover(); r != nil {
if err != nil {
err = fmt.Errorf("%w: panic: %s", err, r)
return
}
err = fmt.Errorf("%w: %s", ErrPanic, r)
}
}()
f, err := cli.handler.GetSymbolPointer("KC_GetFunctionList")
if err != nil {
return err
}
C.getFunctionList(f)
rc := int(C.init())
return cli.wrapError(rc)
}