Example #1
0
func (cons *TrailDBConstructor) GetOpt(key int, value int) (int, error) {
	var opt_value *C.tdb_opt_value
	err := C.tdb_cons_set_opt(cons.cons, C.tdb_opt_key(key), *opt_value)
	if err != 0 {
		return -1, errors.New(errToString(err))
	}
	buf := (*C.uint64_t)(unsafe.Pointer(opt_value))
	return int(*buf), nil
}
Example #2
0
func (db *TrailDB) SetFilter(filter *EventFilter) error {
	var val C.tdb_opt_value
	ptr := (*uintptr)(unsafe.Pointer(&val[0]))
	*ptr = (uintptr)(unsafe.Pointer(filter.filter))
	err := C.tdb_set_opt(db.db, C.tdb_opt_key(TDB_OPT_EVENT_FILTER), val)
	if err != 0 {
		return errors.New("Could not set event filter")
	}
	return nil
}
Example #3
0
func (cons *TrailDBConstructor) SetOpt(key int, value int) error {
	var buf []byte

	binary.BigEndian.PutUint64(buf, uint64(value))
	opt_value := *make_tdb_opt_value(buf)

	err := C.tdb_cons_set_opt(cons.cons, C.tdb_opt_key(key), opt_value)
	if err != 0 {
		return errors.New(errToString(err))
	}
	return nil
}