summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2018-03-14 16:11:51 -0700
committerOri Bernstein <ori@eigenstate.org>2018-03-14 16:11:51 -0700
commita681ea0a49944112060fe1e0a5d6e0081dc010a7 (patch)
tree26552e2382d893cfca5dd8d1dc7d495081797406
parent6d6ba431f9c585104b4374db6fd45ff9a7b90c96 (diff)
downloadlibxmyrb-a681ea0a49944112060fe1e0a5d6e0081dc010a7.tar.gz
Fix up a initial packet with no auth.
-rw-r--r--conn.myr19
-rw-r--r--display.myr4
-rw-r--r--xevdump.myr1
3 files changed, 10 insertions, 14 deletions
diff --git a/conn.myr b/conn.myr
index f4ab90c..c96b86b 100644
--- a/conn.myr
+++ b/conn.myr
@@ -193,7 +193,7 @@ const ensureread = {c , sz : std.size
std.slcp(c.rbuf[0:rem], c.rbuf[c.roff:c.rlen])
c.rlen = rem
c.roff = 0
- c.wbound -= rem
+ c.rbound -= rem
r = 0
while r < sz
@@ -207,10 +207,7 @@ const ensureread = {c , sz : std.size
}
const ensurewrite = {c , sz : std.size
- var rem
-
- rem = c.wbuf.len - c.woff
- if rem < sz
+ if c.wbuf.len - c.woff < sz
flush(c)
;;
}
@@ -226,22 +223,20 @@ const donepack = {c
if sz != 0
//std.assert(sz < c.msgsz, "big requests not yet supported")
std.assert(sz & 0x3 == 0, "misaligned request: {}:{}\n", c.wbound, c.woff)
- std.put("pack len: {}\n", sz)
std.putle16(c.wbuf[c.wbound + 2 : c.wbound + 4], sz >> 2)
;;
c.wbound = c.woff
}
const flush = {c
- var r
+ var w
- r = 0
- std.put("flush {}\n", c.woff)
- while r != c.woff
- match std.write(c.fd, c.wbuf[r:c.woff])
+ w = 0
+ while w != c.woff
+ match std.write(c.fd, c.wbuf[w:c.woff])
| `std.Err e: std.fatal("failed read: {}\n", e)
| `std.Ok 0: std.fatal("unexpected eof\n")
- | `std.Ok n: r += n
+ | `std.Ok n: w += n
;;
;;
c.woff = 0
diff --git a/display.myr b/display.myr
index 7543cea..6db5583 100644
--- a/display.myr
+++ b/display.myr
@@ -181,7 +181,9 @@ const handshake = {dpy
std.putle16(req[sz:sz+2], auth.data.len); sz += 2 /* auth data len */
std.putle16(req[sz:sz+2], 0); sz += 2 /* pad */
std.slcp(req[sz:sz+auth.name.len], auth.name); sz += auth.name.len
- std.slfill(req[sz:sz+4-(sz%4)], 0); sz += 4-(sz%4)
+ if sz % 4 != 0
+ std.slfill(req[sz:sz+4-(sz%4)], 0); sz += 4-(sz%4)
+ ;;
std.slcp(req[sz:sz+auth.data.len], auth.data); sz += auth.data.len
std.writeall(dpy.fd, req[:sz])
diff --git a/xevdump.myr b/xevdump.myr
index f6a5369..75b17de 100644
--- a/xevdump.myr
+++ b/xevdump.myr
@@ -19,7 +19,6 @@ const main = {
std.put("window up\n")
while true
- std.put("roff: {}, rlen: {}\n", dpy.roff, dpy.rlen)
xmyrb.event(dpy, &ev)
std.put("ev: {}\n", ev)
;;