Commit graph

16 commits

Author SHA1 Message Date
Peter Hutterer
6ffdaab8f3 util: use xclose for the _cleanup_close_
Silences the valgrind warnings for fds that are initialized with -1

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-09-14 19:41:14 +10:00
Peter Hutterer
f6c2f24a22 util: add xconnect to connect to a socket
Makes this re-usable.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-25 11:47:07 +10:00
Peter Hutterer
b49e4a48c9 test: move the sources and io tests to the util unit tests
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-25 11:37:18 +10:00
Peter Hutterer
e238a5d049 util: fix receiving of multiple fds
Initial implementation only handled this correctly if the fds were over
multiple message headers, not multiple fds in the same message header.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-24 11:01:01 +10:00
Peter Hutterer
65c069e6a0 util: fix a valgrind warning in xsend_with_fd
valgrind complains about uninitialized bytes

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-24 08:53:49 +10:00
Peter Hutterer
dabd48c028 util: add fd passing to the iobufs
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-21 14:51:53 +10:00
Peter Hutterer
56ca4b4ac7 util: add sending and receiving fds to the io utilities
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-21 11:49:53 +10:00
Peter Hutterer
9e42b579d9 util: typo fix in comment
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-21 10:04:43 +10:00
Peter Hutterer
ce91763683 util: add a errno wrapper
Converts into a negative errno or the respective value

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-13 16:15:09 +10:00
Peter Hutterer
427d58a664 util: add a missing include to util-io.h
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-08-07 16:06:23 +10:00
Peter Hutterer
40682a0420 Use send() instead of write() to prevent SIGPIPE
We're in a library here, so expecting the caller to handle SIGPIPE just in
case we get it is a bit demanding. Let's use send() instead so we can just
prevent that altogether.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-07-31 14:27:18 +10:00
Peter Hutterer
0426c99278 util: add some documentation for the iobuf helpers
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-07-31 13:05:11 +10:00
Peter Hutterer
2931f0fd13 util: fix the fd reading
buf is the iobuf pointer, we need to check whether we read sizeof(data) bytes
before looping around to fetch more.

And fix the return value for a zero read, because that could either be EAGAIN
or EOF.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-07-31 13:05:11 +10:00
Peter Hutterer
6a0f25e72a utils: update the buffer length when appending data
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-07-30 21:02:07 +10:00
Peter Hutterer
23c34fc77d client: handle the case of zero data bytes
When terminating the connection, we might get a read of zero

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-07-29 09:42:42 +10:00
Peter Hutterer
f7a24b2fbd Add the minimal implementation for a UNIX socket libeis server
This is the minimum framework to support new clients, added devices and
pointer relative motion events. It's missing a bunch of checks and
verification, most of the server hooks aren't there yet, the only
implementation is a UNIX socket and the protocol is plain text (but at least
the last two makes it netcat-compatible).

Protocol is plain text for now and interaction is like this (S is server, C is client):
S: hello
C: connect myclientname
S: connected
C: add 2 4
S: accept 2
C: rel 2 -1 1
C: rel 2 5 4

Where the last two lines are: add device with id 2 and capability mask 0x4,
send a relative pointer motion event for device 2 with coordinates -1/1, then
5/4.

The implementation relies heavily on some abstraction and macros galore, see
the various util-* files. These are largely copied from libinput, with a few
parts removed and a few other parts added.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-07-28 19:33:34 +10:00