all tasks
This commit is contained in:
parent
b83f433714
commit
68f8f3e56b
14735 changed files with 178959 additions and 0 deletions
|
|
@ -0,0 +1,10 @@
|
|||
#include <stdio.h>
|
||||
#include "_cgo_export.h"
|
||||
|
||||
void Run()
|
||||
{
|
||||
char Buffer [1024];
|
||||
size_t Size = sizeof (Buffer);
|
||||
|
||||
if (0 == Query (Buffer, &Size))
|
||||
...
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
package main
|
||||
|
||||
// #include <stdlib.h>
|
||||
// extern void Run();
|
||||
import "C"
|
||||
import "unsafe"
|
||||
|
||||
func main() {
|
||||
C.Run()
|
||||
}
|
||||
|
||||
const msg = "Here am I"
|
||||
|
||||
//export Query
|
||||
func Query(cbuf *C.char, csiz *C.size_t) C.int {
|
||||
if int(*csiz) <= len(msg) {
|
||||
return 0
|
||||
}
|
||||
pbuf := uintptr(unsafe.Pointer(cbuf))
|
||||
for i := 0; i < len(msg); i++ {
|
||||
*((*byte)(unsafe.Pointer(pbuf))) = msg[i]
|
||||
pbuf++
|
||||
}
|
||||
*((*byte)(unsafe.Pointer(pbuf))) = 0
|
||||
*csiz = C.size_t(len(msg) + 1)
|
||||
return 1
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue