Beispiel #1
0
// 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)))
}
Beispiel #2
0
// 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)))
}
Beispiel #3
0
// 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)))
}