|
@@ -2,9 +2,9 @@ package sg
|
2
|
2
|
|
3
|
3
|
/*
|
4
|
4
|
#cgo amd64 386 CFLAGS: -DX86=1
|
5
|
|
-#cgo darwin,!arm,!arm64 LDFLAGS: -lpthread
|
6
|
|
-#cgo darwin,arm LDFLAGS: -framework CoreFoundation
|
7
|
|
-#cgo darwin,arm64 LDFLAGS: -framework CoreFoundation
|
|
5
|
+#cgo darwin, 386, !arm,!arm64 LDFLAGS: -lpthread
|
|
6
|
+#cgo darwin,arm,386, LDFLAGS: -framework CoreFoundation
|
|
7
|
+#cgo darwin,arm64,386, LDFLAGS: -framework CoreFoundation
|
8
|
8
|
#cgo dragonfly LDFLAGS: -lpthread
|
9
|
9
|
#cgo freebsd LDFLAGS: -lpthread
|
10
|
10
|
#cgo android LDFLAGS: -llog
|
|
@@ -37,6 +37,8 @@ import (
|
37
|
37
|
"net/http"
|
38
|
38
|
"os"
|
39
|
39
|
"path/filepath"
|
|
40
|
+ "runtime"
|
|
41
|
+ _ "runtime/cgo"
|
40
|
42
|
"strconv"
|
41
|
43
|
"strings"
|
42
|
44
|
"syscall"
|
|
@@ -102,6 +104,8 @@ func (c *HisApiController) TestGetBasBaseInfo() {
|
102
|
104
|
//C.free(unsafe.Pointer(cs2))
|
103
|
105
|
|
104
|
106
|
//
|
|
107
|
+ runtime.GC()
|
|
108
|
+
|
105
|
109
|
DllDef := syscall.MustLoadDLL("SSCard.dll")
|
106
|
110
|
Iinit := DllDef.MustFindProc("Init")
|
107
|
111
|
readCard := DllDef.MustFindProc("ReadCardBas")
|
|
@@ -125,25 +129,20 @@ func (c *HisApiController) TestGetBasBaseInfo() {
|
125
|
129
|
|
126
|
130
|
str1 := make([]byte, 256)
|
127
|
131
|
|
128
|
|
- //s2 := []byte(string(str))
|
129
|
|
- //s3 := []byte(string(str1))
|
130
|
|
-
|
131
|
|
- cData1 := C.CBytes(str)
|
132
|
|
- cData2 := C.CBytes(str1)
|
|
132
|
+ s2 := []byte(string(str))
|
|
133
|
+ s3 := []byte(string(str1))
|
133
|
134
|
|
134
|
|
- ret2, _, err2 := readCard.Call((uintptr)(cData1), IntPtr(256), (uintptr)(cData2), IntPtr(256))
|
|
135
|
+ ret2, _, err2 := readCard.Call((uintptr)(unsafe.Pointer(&s2[0])), IntPtr(256), (uintptr)(unsafe.Pointer(&s3[0])), IntPtr(256))
|
135
|
136
|
fmt.Println(" Add(4,5)的结果为:", ret2)
|
136
|
|
- fmt.Println(" str:", cData1)
|
137
|
|
- fmt.Println(" str1:", cData2)
|
|
137
|
+ fmt.Println(" str:", s2)
|
|
138
|
+ fmt.Println(" str1:", s3)
|
|
139
|
+ runtime.GC()
|
138
|
140
|
if err2 != nil {
|
139
|
141
|
fmt.Println("SSCard的运算结果为:", ret2)
|
140
|
142
|
c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
|
141
|
143
|
return
|
142
|
144
|
}
|
143
|
145
|
|
144
|
|
- //defer C.free(cData1)
|
145
|
|
- //defer C.free(cData2)
|
146
|
|
-
|
147
|
146
|
}
|
148
|
147
|
|
149
|
148
|
func (c *HisApiController) GetOrgInfo() {
|