go-ncurses/libc.go

24 lines
478 B
Go

package ncurses
import (
"github.com/ebitengine/purego"
)
var libc uintptr = 0
func libcFunction[T any](name string) T {
if libc == 0 {
var err error
libc, err = purego.Dlopen(LIBC_PATH, purego.RTLD_GLOBAL | purego.RTLD_NOW)
if err != nil {
panic(err)
}
}
var tmp = new(T)
purego.RegisterLibFunc(tmp, libc, name)
return *tmp
}
2024-04-24 01:18:32 -06:00
type setlocaleFP func(category int, locale string) string
var SetLocale = libcFunction[setlocaleFP]("setlocale")