mirror of
https://github.com/rwinkhart/cmutton.git
synced 2026-08-28 04:46:46 -04:00
Add helper function for passing Go string slices to C; document some functions that won't be ported
This commit is contained in:
@@ -4,8 +4,6 @@ package main
|
||||
// #include "types.h"
|
||||
import "C"
|
||||
import (
|
||||
"unsafe"
|
||||
|
||||
"github.com/rwinkhart/libmutton/crypt"
|
||||
"github.com/rwinkhart/rcw/wrappers"
|
||||
)
|
||||
@@ -28,16 +26,7 @@ func DecryptFileToSlice(realPath, rcwPassword C.PascalString) (*C.char, *C.Pasca
|
||||
return nil, nil, 0
|
||||
}
|
||||
|
||||
// allocate C array for PascalStrings
|
||||
cLinesPtr := (*C.PascalString)(C.malloc(C.size_t(len(lines)) * C.size_t(C.sizeof_PascalString)))
|
||||
|
||||
// populate the array with the decrypted lines
|
||||
cLinesSlice := (*[1 << 30]C.PascalString)(unsafe.Pointer(cLinesPtr))[:len(lines):len(lines)]
|
||||
for i, line := range lines {
|
||||
cLinesSlice[i] = getPascalString(line)
|
||||
}
|
||||
|
||||
return nil, cLinesPtr, C.int(len(lines))
|
||||
return nil, getCPascalStringArrayFromStringSlice(lines), C.int(len(lines))
|
||||
}
|
||||
|
||||
// EncryptBytes returns:
|
||||
|
||||
Reference in New Issue
Block a user