openamt/pkg/amtrpc/amtrpc.go

29 lines
545 B
Go
Raw Normal View History

2023-03-20 16:28:45 +00:00
//go:build !fake
package amtrpc
/*
2023-04-12 18:48:32 +00:00
#cgo LDFLAGS: -L/usr/local/lib -lrpc -Wl,-rpath=/usr/local/lib
2023-03-20 16:28:45 +00:00
#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)
}