mirror of
https://gitlab.freedesktop.org/libinput/libei.git
synced 2026-01-07 07:40:16 +01:00
tools: make the socket server example take a socket path
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
parent
8078424c14
commit
7e6afe2373
1 changed files with 11 additions and 7 deletions
|
|
@ -43,21 +43,24 @@ static void sighandler(int signal) {
|
|||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char SOCKETNAME[] = "eis.socket";
|
||||
struct eis *eis = eis_socket_new_context(NULL);
|
||||
assert(eis);
|
||||
|
||||
const char *xdgdir = getenv("XDG_RUNTIME_DIR");
|
||||
assert(xdgdir != NULL);
|
||||
|
||||
_cleanup_free_ char *socketpath = xaprintf("%s/%s", xdgdir, SOCKETNAME);
|
||||
unlink(socketpath);
|
||||
_cleanup_free_ char *socketpath = NULL;
|
||||
if (argc < 2) {
|
||||
const char SOCKETNAME[] = "eis.socket";
|
||||
const char *xdgdir = getenv("XDG_RUNTIME_DIR");
|
||||
assert(xdgdir != NULL);
|
||||
socketpath = xaprintf("%s/%s", xdgdir, SOCKETNAME);
|
||||
} else {
|
||||
socketpath = xstrdup(argv[1]);
|
||||
}
|
||||
|
||||
/* This should be handled by libeis */
|
||||
signal(SIGPIPE, SIG_IGN);
|
||||
signal(SIGINT, sighandler);
|
||||
|
||||
int rc = eis_socket_init(eis, SOCKETNAME);
|
||||
int rc = eis_socket_init(eis, socketpath);
|
||||
if (rc != 0) {
|
||||
fprintf(stderr, "init failed: %s\n", strerror(errno));
|
||||
return 1;
|
||||
|
|
@ -129,6 +132,7 @@ int main(int argc, char **argv)
|
|||
}
|
||||
|
||||
eis_unref(eis);
|
||||
unlink(socketpath);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue