func (p *Port) open(mode int) error { if p.opened { panic("already opened") } err := errmsg(C.sp_open(p.p, C.enum_sp_mode(mode))) p.opened = err == nil return p.getConf() }
// Open() opens the database that has been configured in the Environment. // At a minimum, it should be necessary to call Dir() on the Environment to // specify the directory for the database. func (env *Environment) Open() (*Database, error) { db := &Database{} db.Pointer = C.sp_open(env.Pointer) if nil == db.Pointer { return nil, env.Error() } return db, nil }
// Init attempts to initialises the port represented by the port name passed in. func Init(s *Conf, name string) (int32, error) { var result int32 = SP_OK C.sp_new_config(&s.oldConfig) C.sp_new_config(&s.newConfig) cp := C.CString(name) defer C.free(unsafe.Pointer(cp)) result = C.sp_get_port_by_name(cp, &s.Port) checkResult(result) // Open before setting params result = C.sp_open(s.Port, SP_MODE_READ|SP_MODE_WRITE) return result, checkResult(result) }