mirror of
https://gitlab.freedesktop.org/libinput/libei.git
synced 2026-02-02 19:00:28 +01:00
eis: Add API to add client getting an fd
Creates the socket and adds it; is intended to be used to create client connections that are passed via a secure channel, e.g. via portals. Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
This commit is contained in:
parent
a330b31713
commit
e115c6549b
2 changed files with 31 additions and 1 deletions
|
|
@ -86,3 +86,24 @@ eis_backend_fd_add_fd(struct eis *eis, int fd)
|
|||
|
||||
return 0;
|
||||
}
|
||||
|
||||
_public_ int
|
||||
eis_backend_fd_add_client(struct eis *eis)
|
||||
{
|
||||
assert(eis);
|
||||
assert(eis->backend);
|
||||
|
||||
int fds[2];
|
||||
|
||||
int rc = socketpair(AF_UNIX, SOCK_STREAM|SOCK_NONBLOCK|SOCK_CLOEXEC, 0, fds);
|
||||
if (rc == -1)
|
||||
return -errno;
|
||||
|
||||
struct eis_client *client = eis_client_new(eis, fds[0]);
|
||||
if (client == NULL)
|
||||
return -ENOMEM;
|
||||
|
||||
eis_client_unref(client);
|
||||
|
||||
return fds[1];
|
||||
}
|
||||
|
|
|
|||
11
src/libeis.h
11
src/libeis.h
|
|
@ -403,11 +403,20 @@ int
|
|||
eis_setup_backend_fd(struct eis *ctx);
|
||||
|
||||
/**
|
||||
* Add a new client to a context set up with eis_setup_backend_fd()
|
||||
* Add a new client given a file descriptor to a context set up with
|
||||
* eis_setup_backend_fd()
|
||||
*/
|
||||
int
|
||||
eis_backend_fd_add_fd(struct eis *ctx, int fd);
|
||||
|
||||
/**
|
||||
* Add a new client to a context set up with eis_setup_backend_fd(). Returns
|
||||
* a file descriptor to be passed to ei_setup_backend_fd(), or a negative
|
||||
* errno on failure.
|
||||
*/
|
||||
int
|
||||
eis_backend_fd_add_client(struct eis *ctx);
|
||||
|
||||
/**
|
||||
* libeis keeps a single file descriptor for all events. This fd should be
|
||||
* monitored for events by the caller's mainloop, e.g. using select(). When
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue