2024-10-28 20:57:59 +09:00
|
|
|
// Package xcb implements X11 ChangeHosts via libxcb.
|
2024-09-04 01:20:12 +09:00
|
|
|
package xcb
|
|
|
|
|
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
)
|
|
|
|
|
2024-12-17 12:46:36 +09:00
|
|
|
var ErrChangeHosts = errors.New("xcb_change_hosts() failed")
|
2024-09-04 01:20:12 +09:00
|
|
|
|
2024-12-17 12:46:36 +09:00
|
|
|
func ChangeHosts(mode HostMode, family Family, address string) error {
|
|
|
|
var conn *connection
|
2024-09-04 01:20:12 +09:00
|
|
|
|
2024-12-17 12:46:36 +09:00
|
|
|
if c, err := connect(); err != nil {
|
|
|
|
c.disconnect()
|
|
|
|
return err
|
|
|
|
} else {
|
|
|
|
defer c.disconnect()
|
|
|
|
conn = c
|
2024-09-04 01:20:12 +09:00
|
|
|
}
|
|
|
|
|
2024-12-17 12:46:36 +09:00
|
|
|
return conn.changeHostsChecked(mode, family, address)
|
2024-09-04 01:20:12 +09:00
|
|
|
}
|