mirror of
https://github.com/kairos-io/openamt.git
synced 2025-04-27 18:25:12 +00:00
30 lines
548 B
Go
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)
|
|
}
|