aboutsummaryrefslogtreecommitdiffhomepage
path: root/x11.go
diff options
context:
space:
mode:
authorOphestra Umiker <cat@ophivana.moe>2024-09-04 01:20:12 +0900
committerOphestra Umiker <cat@ophivana.moe>2024-09-04 01:20:12 +0900
commitd8f76f3b2594db4687c0203c4f2be8d3e4ef7740 (patch)
treeb1d8bfb5250d71094e397f8afa87710de1f1ca2f /x11.go
parent7e6eb82195c650bc34829e5cca2d2296e78c0707 (diff)
rename to fortify and restructure
More sandbox features will be added and this will no longer track ego's features and behaviour. Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
Diffstat (limited to 'x11.go')
-rw-r--r--x11.go72
1 files changed, 0 insertions, 72 deletions
diff --git a/x11.go b/x11.go
deleted file mode 100644
index d25155e3..00000000
--- a/x11.go
+++ /dev/null
@@ -1,72 +0,0 @@
-package main
-
-import "C"
-import (
- "errors"
- "unsafe"
-)
-
-//#include <stdlib.h>
-//#include <xcb/xcb.h>
-//#cgo linux LDFLAGS: -lxcb
-import "C"
-
-const (
- xcbHostModeInsert = C.XCB_HOST_MODE_INSERT
- xcbHostModeDelete = C.XCB_HOST_MODE_DELETE
-
- xcbFamilyInternet = C.XCB_FAMILY_INTERNET
- xcbFamilyDecnet = C.XCB_FAMILY_DECNET
- xcbFamilyChaos = C.XCB_FAMILY_CHAOS
- xcbFamilyServerInterpreted = C.XCB_FAMILY_SERVER_INTERPRETED
- xcbFamilyInternet6 = C.XCB_FAMILY_INTERNET_6
-)
-
-func changeHosts(mode, family C.uint8_t, address string) error {
- var c *C.xcb_connection_t
- c = C.xcb_connect(nil, nil)
- defer C.xcb_disconnect(c)
-
- if err := xcbHandleConnectionError(c); err != nil {
- return err
- }
-
- addr := C.CString(address)
- cookie := C.xcb_change_hosts_checked(c, mode, family, C.ushort(len(address)), (*C.uchar)(unsafe.Pointer(addr)))
- C.free(unsafe.Pointer(addr))
-
- if err := xcbHandleConnectionError(c); err != nil {
- return err
- }
-
- e := C.xcb_request_check(c, cookie)
- if e != nil {
- defer C.free(unsafe.Pointer(e))
- return errors.New("xcb_change_hosts() failed")
- }
-
- return nil
-}
-
-func xcbHandleConnectionError(c *C.xcb_connection_t) error {
- if errno := C.xcb_connection_has_error(c); errno != 0 {
- switch errno {
- case C.XCB_CONN_ERROR:
- return errors.New("connection error")
- case C.XCB_CONN_CLOSED_EXT_NOTSUPPORTED:
- return errors.New("extension not supported")
- case C.XCB_CONN_CLOSED_MEM_INSUFFICIENT:
- return errors.New("memory not available")
- case C.XCB_CONN_CLOSED_REQ_LEN_EXCEED:
- return errors.New("request length exceeded")
- case C.XCB_CONN_CLOSED_PARSE_ERR:
- return errors.New("invalid display string")
- case C.XCB_CONN_CLOSED_INVALID_SCREEN:
- return errors.New("server has no screen matching display")
- default:
- return errors.New("generic X11 failure")
- }
- } else {
- return nil
- }
-}