Esempio n. 1
0
//export gogpgme_seekfunc
func gogpgme_seekfunc(handle unsafe.Pointer, offset C.off_t, whence C.int) C.off_t {
	d := callbackLookup(uintptr(handle)).(*Data)
	n, err := d.s.Seek(int64(offset), int(whence))
	if err != nil {
		C.gpgme_err_set_errno(C.EIO)
		return -1
	}
	return C.off_t(n)
}
Esempio n. 2
0
//export gogpgme_writefunc
func gogpgme_writefunc(handle, buffer unsafe.Pointer, size C.size_t) C.ssize_t {
	d := callbackLookup(uintptr(handle)).(*Data)
	if len(d.buf) < int(size) {
		d.buf = make([]byte, size)
	}
	C.memcpy(unsafe.Pointer(&d.buf[0]), buffer, C.size_t(size))
	n, err := d.w.Write(d.buf[:size])
	if err != nil && err != io.EOF {
		C.gpgme_err_set_errno(C.EIO)
		return -1
	}
	return C.ssize_t(n)
}