summaryrefslogtreecommitdiff
path: root/chardev.hpp
diff options
context:
space:
mode:
authorOxore <oxore@protonmail.com>2024-04-30 01:38:42 +0300
committerOxore <oxore@protonmail.com>2024-05-19 18:21:40 +0300
commit71b89bc9ceb59f2603cf4b0635849269597a4823 (patch)
tree7b53520d3f1306f71c2083cf8b6d9dbb749249da /chardev.hpp
parent47ffe952bcfc31a78c16be8620109955fdc17f2f (diff)
Impl --stop and --gdb options
Diffstat (limited to 'chardev.hpp')
-rw-r--r--chardev.hpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/chardev.hpp b/chardev.hpp
new file mode 100644
index 0000000..0a0d9df
--- /dev/null
+++ b/chardev.hpp
@@ -0,0 +1,32 @@
+/* SPDX-License-Identifier: Unlicense
+ */
+
+#pragma once
+
+#include <cstdint>
+#include <cstddef>
+
+enum class CharDevType: uint8_t {
+ kUndefined = 0,
+ kPty, ///< Creates new PTY
+ kTcp, ///< Binds and listens to specified address and port
+};
+
+struct CharDev {
+ CharDevType type{};
+ const char* path{};
+ int fd{-1};
+ size_t path_len{};
+ uint16_t port{};
+ static CharDev Invalid(const char* path = nullptr)
+ {
+ return CharDev{CharDevType::kUndefined, path};
+ }
+ static CharDev Pty(void) { return CharDev{CharDevType::kPty}; }
+ static CharDev Tcp(const char* host, size_t path_len, uint16_t port)
+ {
+ return CharDev{CharDevType::kTcp, host, -1, path_len, port};
+ }
+ static CharDev Parse(const char* path);
+};
+