diff options
| author | Joel Klinghed <the_jk@spawned.biz> | 2025-10-10 10:01:01 +0200 |
|---|---|---|
| committer | Joel Klinghed <the_jk@spawned.biz> | 2025-10-19 00:13:47 +0200 |
| commit | dad0aaa9b33a5a217ac115334a94fe299dce9e08 (patch) | |
| tree | baeffb1e3ef6a6e100bc2f255581d77c4b9a45d3 /src/unique_pipe.cc | |
| parent | 86ec0b5386fc2078891a829026844d2ec21ea7db (diff) | |
Add bluetooth module
Can't really do anything yet, but finds the bluetooth adapter
and registers an agent to make it pairable.
Diffstat (limited to 'src/unique_pipe.cc')
| -rw-r--r-- | src/unique_pipe.cc | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/unique_pipe.cc b/src/unique_pipe.cc new file mode 100644 index 0000000..28c106d --- /dev/null +++ b/src/unique_pipe.cc @@ -0,0 +1,32 @@ +#include "unique_pipe.hh" + +#include <unistd.h> +#include <utility> + +unique_pipe::unique_pipe() { + int fd[2]; + if (pipe(fd)) + return; + fd_[0] = unique_fd(fd[0]); + fd_[1] = unique_fd(fd[1]); +} + +unique_pipe::unique_pipe(unique_pipe&& fd) { + fd_[0] = unique_fd(fd.fd_[0].release()); + fd_[1] = unique_fd(fd.fd_[1].release()); +} + +unique_pipe& unique_pipe::operator=(unique_pipe&& fd) { + fd_[0].reset(fd.fd_[0].release()); + fd_[1].reset(fd.fd_[1].release()); + return *this; +} + +void unique_pipe::reset() { + fd_[0].reset(); + fd_[1].reset(); +} + +unique_fd unique_pipe::release_reader() { return std::move(fd_[0]); } + +unique_fd unique_pipe::release_writer() { return std::move(fd_[1]); } |
