aboutsummaryrefslogtreecommitdiff
path: root/dcs.c
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2019-07-19 07:55:07 +0000
committerDaniel Eklöf <daniel@ekloef.se>2019-07-19 07:55:07 +0000
commitb95332676863d902e410b04305ceb20760297fa3 (patch)
tree51b3feb3c474c7fe5c9e7bffd040a23e05ce5952 /dcs.c
parentosc: allocate data buffer dynamically (diff)
dcs: sort of implement DCS passthrough
We now store the passthrough characters in a buffer, and call dcs_passthrough() on unhook. However, dcs_passthrough() doesn't do anything.
Diffstat (limited to 'dcs.c')
-rw-r--r--dcs.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/dcs.c b/dcs.c
new file mode 100644
index 00000000..c591974a
--- /dev/null
+++ b/dcs.c
@@ -0,0 +1,32 @@
+#include "dcs.h"
+
+#define LOG_MODULE "dcs"
+#define LOG_ENABLE_DBG 0
+#include "log.h"
+
+void
+dcs_passthrough(struct terminal *term)
+{
+ LOG_DBG("DCS passthrough: %.*s (%zu bytes)",
+ (int)term->vt.dcs.idx, term->vt.dcs.data, term->vt.dcs.idx);
+}
+
+bool
+dcs_ensure_size(struct terminal *term, size_t required_size)
+{
+ if (required_size <= term->vt.dcs.size)
+ return true;
+
+ size_t new_size = (required_size + 127) / 128 * 128;
+ assert(new_size > 0);
+
+ uint8_t *new_data = realloc(term->vt.dcs.data, new_size);
+ if (new_data == NULL) {
+ LOG_ERRNO("failed to increase size of DCS buffer");
+ return false;
+ }
+
+ term->vt.dcs.data = new_data;
+ term->vt.dcs.size = new_size;
+ return true;
+}