openamt/pkg/amtrpc/amtrpc.go
2023-03-21 10:30:41 -07:00

30 lines
548 B
Go

//go:build !fake
package amtrpc
/*
#cgo CFLAGS: -I./src
#cgo LDFLAGS: -L./lib -lrpc -Wl,-rpath=./lib
#include <stdlib.h>
#include "librpc.h"
*/
import "C" //nolint:typecheck
import "unsafe"
type AMTRPC struct{}
func (A AMTRPC) CheckAccess() int {
return int(C.rpcCheckAccess())
}
func (A AMTRPC) Exec(command string) (string, int) {
ccmd := C.CString(command)
cresponse := C.CString("")
cstatus := C.rpcExec(ccmd, &cresponse)
C.free(unsafe.Pointer(ccmd))
C.free(unsafe.Pointer(cresponse))
return C.GoString(cresponse), int(cstatus)
}