diff options
| author | Ophestra Umiker <cat@ophivana.moe> | 2024-09-16 20:32:07 +0900 |
|---|---|---|
| committer | Ophestra Umiker <cat@ophivana.moe> | 2024-09-16 20:32:07 +0900 |
| commit | 03c24c51224e85eb96527a512f5f0483464fc810 (patch) | |
| tree | 2feede4d9448fc881b0d4b8a193c0c82f6627221 /internal/xcb | |
| parent | 8bdae74ebe172239573bab9fca634cf350cbd29d (diff) | |
move acl and xcb binding packages to top level
These packages are reasonably clean and do not interact with other packages.
Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
Diffstat (limited to 'internal/xcb')
| -rw-r--r-- | internal/xcb/c.go | 33 | ||||
| -rw-r--r-- | internal/xcb/export.go | 47 |
2 files changed, 0 insertions, 80 deletions
diff --git a/internal/xcb/c.go b/internal/xcb/c.go deleted file mode 100644 index 8fe59d8c..00000000 --- a/internal/xcb/c.go +++ /dev/null @@ -1,33 +0,0 @@ -package xcb - -import ( - "errors" -) - -//#include <stdlib.h> -//#include <xcb/xcb.h> -//#cgo linux LDFLAGS: -lxcb -import "C" - -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 - } -} diff --git a/internal/xcb/export.go b/internal/xcb/export.go deleted file mode 100644 index 72a74131..00000000 --- a/internal/xcb/export.go +++ /dev/null @@ -1,47 +0,0 @@ -package xcb - -//#include <stdlib.h> -//#include <xcb/xcb.h> -//#cgo linux LDFLAGS: -lxcb -import "C" -import ( - "errors" - "unsafe" -) - -const ( - HostModeInsert = C.XCB_HOST_MODE_INSERT - HostModeDelete = C.XCB_HOST_MODE_DELETE - - FamilyInternet = C.XCB_FAMILY_INTERNET - FamilyDecnet = C.XCB_FAMILY_DECNET - FamilyChaos = C.XCB_FAMILY_CHAOS - FamilyServerInterpreted = C.XCB_FAMILY_SERVER_INTERPRETED - FamilyInternet6 = 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 -} |
