From 65f07f77003b6d22637548428d464dff0b773b40 Mon Sep 17 00:00:00 2001 From: Boris Faure Date: Wed, 17 Apr 2013 22:55:37 +0200 Subject: [PATCH] handle DCS status string requests --- src/bin/termptyesc.c | 51 +++++++++++++++++++++++++++++++++++++++----- 1 file changed, 46 insertions(+), 5 deletions(-) diff --git a/src/bin/termptyesc.c b/src/bin/termptyesc.c index 5528351b..aed0dfac 100644 --- a/src/bin/termptyesc.c +++ b/src/bin/termptyesc.c @@ -1015,7 +1015,8 @@ _handle_esc_dcs(Termpty *ty __UNUSED__, const Eina_Unicode *c, const Eina_Unicod { const Eina_Unicode *cc, *be; Eina_Unicode buf[4096], *b; - + int len; + cc = c; b = buf; be = buf + sizeof(buf) / sizeof(buf[0]); @@ -1030,11 +1031,12 @@ _handle_esc_dcs(Termpty *ty __UNUSED__, const Eina_Unicode *c, const Eina_Unicod b++; cc++; } + len = cc - c; if (b == be) - { + { ERR("dcs parsing overflowed (binary data?)"); - return cc - c; - } + goto end; + } *b = 0; if ((*cc == ST) || (*cc == '\\')) cc++; else return 0; @@ -1043,12 +1045,51 @@ _handle_esc_dcs(Termpty *ty __UNUSED__, const Eina_Unicode *c, const Eina_Unicod case '+': /* TODO: Set request termcap/terminfo */ break; + case '$': + /* Request status string */ + if (len > 1 && buf[1] != 'q') + { + ERR("invalid/unhandled dsc esc '$%c' (expected '$q')", buf[1]); + goto end; + } + if (len < 4) + goto end; + switch (buf[2]) + { + case '"': + if (buf[3] == 'p') /* DECSCL */ + { + char bf[32]; + snprintf(bf, sizeof(bf), "\033P1$r64;1\"p\033\\"); + termpty_write(ty, bf, strlen(bf)); + } + else if (buf[3] == 'q') /* DECSCA */ + { + /* TODO: */ + } + else + { + ERR("invalid/unhandled dsc esc '$q\"%c'", buf[3]); + goto end; + } + break; + case 'm': /* SGR */ + /* TODO: */ + case 'r': /* DECSTBM */ + /* TODO: */ + default: + ERR("unhandled dsc request status string '$q%c'", buf[2]); + goto end; + } + /* TODO */ + break; default: // many others ERR("unhandled dcs esc '%c'", buf[0]); break; } - return cc - c; +end: + return len; } static int