示例#1
0
文件: data.go 项目: proglottis/gpgme
// NewDataWriter returns a new callback based data buffer
func NewDataWriter(w io.Writer) (*Data, error) {
	d := newData()
	d.w = w
	d.cbs.write = C.gpgme_data_write_cb_t(C.gogpgme_writefunc)
	cbc := callbackAdd(d)
	d.cbc = cbc
	return d, handleError(C.gogpgme_data_new_from_cbs(&d.dh, &d.cbs, C.uintptr_t(cbc)))
}
示例#2
0
文件: data.go 项目: proglottis/gpgme
// NewDataReader returns a new callback based data buffer
func NewDataReader(r io.Reader) (*Data, error) {
	d := newData()
	d.r = r
	d.cbs.read = C.gpgme_data_read_cb_t(C.gogpgme_readfunc)
	cbc := callbackAdd(d)
	d.cbc = cbc
	return d, handleError(C.gogpgme_data_new_from_cbs(&d.dh, &d.cbs, C.uintptr_t(cbc)))
}
示例#3
0
文件: data.go 项目: proglottis/gpgme
// NewDataReadWriteSeeker returns a new callback based data buffer
func NewDataReadWriteSeeker(rw io.ReadWriteSeeker) (*Data, error) {
	d := newData()
	d.r = rw
	d.w = rw
	d.s = rw
	d.cbs.read = C.gpgme_data_read_cb_t(C.gogpgme_readfunc)
	d.cbs.write = C.gpgme_data_write_cb_t(C.gogpgme_writefunc)
	d.cbs.seek = C.gpgme_data_seek_cb_t(C.gogpgme_seekfunc)
	cbc := callbackAdd(d)
	d.cbc = cbc
	return d, handleError(C.gogpgme_data_new_from_cbs(&d.dh, &d.cbs, C.uintptr_t(cbc)))
}