Exemplo n.º 1
0
func main() {
	cstr := C.CString("hello , world")
	defer C.free(unsafe.Pointer(cstr))
	C.puts(cstr)
	//C.printf("test")
	C.myprintstr(cstr)
}
Exemplo n.º 2
0
func ConnectionState(session *C.sp_session) C.sp_connectionstate {

	connection_state := C.sp_session_connectionstate(session)
	fmt.Printf("ConnectionState: %d\n", connection_state)
	if connection_state == C.SP_CONNECTION_STATE_LOGGED_IN {
		C.puts(C.CString("Logged_in"))
	} else if connection_state == C.SP_CONNECTION_STATE_LOGGED_OUT {
		C.puts(C.CString("Logged_out"))
	} else if connection_state == C.SP_CONNECTION_STATE_DISCONNECTED {
		C.puts(C.CString("Disconnected"))
	} else if connection_state == C.SP_CONNECTION_STATE_UNDEFINED {
		C.puts(C.CString("Undefined"))
	} else if connection_state == C.SP_CONNECTION_STATE_OFFLINE {
		C.puts(C.CString("Offline"))
	}
	return connection_state
}
Exemplo n.º 3
0
func main() {

	cs := C.CString(`
  wokao
  `)
	C.puts((cs))

	defer C.free(unsafe.Pointer(cs))

}
Exemplo n.º 4
0
func Authentifaction(login string, password string) *C.sp_session {

	sc := initSessionConfig()
	session := new(C.sp_session)
	err := C.sp_session_create(sc, &session)
	fmt.Printf("%d\n", err)
	C.puts(C.sp_error_message(err))
	C.sp_session_set_connection_rules(session, C.SP_CONNECTION_RULE_NETWORK)
	return session
}
Exemplo n.º 5
0
func TracksSearch(res *C.sp_search) []string {
	nb := C.sp_search_num_tracks(res)
	tab := make([]string, nb)
	var i C.int = 0
	for ; i < nb; i++ {
		C.puts(C.sp_track_name(C.sp_search_track(res, i)))
		tab[i] = C.GoString(C.sp_track_name(C.sp_search_track(res, i)))
	}
	return tab
}
Exemplo n.º 6
0
func DemoCgo() {
	// call functions from libc
	msg := C.CString("Hello, 世界")
	defer C.free(unsafe.Pointer(msg))
	C.puts(msg)

	// call function from libfoo
	var cmsg *C.char = C.CString("进入 print2()")
	defer C.free(unsafe.Pointer(cmsg))
	C.print2(cmsg)
}
Exemplo n.º 7
0
func main() {
	total := C.add(10, 20)
	fmt.Printf("Go says: result is %v\n", total)

	gostr := "Go can call C's puts from stdio"
	// C.CString uses C heap, we must free it
	var cstr *C.char = C.CString(gostr)
	// defer is convenient for clean-up
	defer C.free(unsafe.Pointer(cstr))
	C.puts(cstr)
}
Exemplo n.º 8
0
func main() {

	Seed(1000)

	fmt.Println(int(C.random()))
	time.Sleep(time.Duration(1) * time.Second)
	fmt.Println(int(C.random()))

	fmt.Println("getpid:", int(C.getpid()))
	C.puts(C.CString("call C puts"))

	Hello("call C's go wrapper func")
	C.hello(C.CString("call C hello func"))
}
Exemplo n.º 9
0
func PrintHello() {
	C.puts(C.CString("Hello, world\n"))

}
Exemplo n.º 10
0
func main() {
	cstr := C.CString("Hello, world!")
	C.puts(cstr)
	C.free(unsafe.Pointer(cstr))
}
Exemplo n.º 11
0
func main() {
	cstr := C.CString("Hello, world")
	C.puts(cstr)
}
Exemplo n.º 12
0
func Puts(s string) {
	p := C.CString(s)
	C.puts(p)
	C.free(unsafe.Pointer(p))
	C.fflushstdout()
}
Exemplo n.º 13
0
func PrintHello() {
	C.puts(C.CString("Hello, world\n"))
	C.f**k()
	C.tid()
}