-
-
Save PuercoPop/709ac450430cc7097d50d4c02554d304 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun write-counted-string (string out) | |
(write-short (length string) out) | |
(dotimes (index (length string)) | |
(write-byte (char-code (aref string index)) | |
out))) | |
(defun write-counted-octet (data out) | |
(write-short (length data) out) | |
(dotimes (index (length data)) | |
(write-byte (aref data index) out))) | |
(defvar *xcb-stream*) | |
(defun display-socket (&optional (display (sb-posix:getenv "DISPLAY"))) | |
"Translate the contents of $DISPLAY to a socket address." | |
(declare (ignore display)) | |
"/tmp/.X11-unix/X0") | |
(defun open-connection (&optional (path (display-socket))) | |
(let ((socket (make-instance 'local-socket :type :stream))) | |
(socket-connect socket path) | |
(socket-make-stream socket | |
:element-type 'octet | |
:input t | |
:output t | |
:timeout 1 ; This is for read operations | |
;; CLX ues :buffering :none and use their own buffer | |
:buffering :none #+(or):full))) | |
(defun handshake (auth-name auth-data) | |
(write-byte +LSB+ *xcb-stream*) | |
(write-byte 0 *xcb-stream*) | |
(write-byte +xcb-protocol-major-version+ *xcb-stream*) | |
(write-byte +xcb-protocol-minor-version+ *xcb-stream*) | |
(write-counted-string auth-name *xcb-stream*) | |
(write-counted-octet auth-data *xcb-stream*) | |
(write-byte 0 *xcb-stream*) | |
(write-byte 0 *xcb-stream*) | |
(finish-output *xcb-stream*)) | |
(defun slurp-stream () | |
(loop | |
:for byte := (read-byte *xcb-stream* nil 'eof) | |
:until (eq byte 'eof) | |
:collect byte)) | |
(read-byte *xcb-stream*) | |
(handshake "MIT-MAGIC-COOKIE-1" #(94 228 175 242 86 170 191 222 17 145 96 98 251 240 2 95)) | |
;; Through 'ss -l -x src /tmp/.X11-unix/*' I can see that handshake is not writing to the socket |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment