|
|
82e8e7 |
/*********************************************************/
|
|
|
82e8e7 |
/* ptycon: a pty-console bridge */
|
|
|
f25e99 |
/* Copyright (C) 2016--2017 SysDeer Technologies, LLC */
|
|
|
82e8e7 |
/* Released under GPLv2 and GPLv3; see COPYING.PTYCON. */
|
|
|
82e8e7 |
/*********************************************************/
|
|
|
82e8e7 |
|
|
|
82e8e7 |
#include <psxtypes/psxtypes.h>
|
|
|
82e8e7 |
|
|
|
82e8e7 |
#include <ptycon/ptycon.h>
|
|
|
82e8e7 |
#include "ptycon_bridge_impl.h"
|
|
|
82e8e7 |
|
|
|
82e8e7 |
/* forward declarations */
|
|
|
82e8e7 |
static ptyc_term_handler esi_illegal_code;
|
|
|
82e8e7 |
static ptyc_term_handler esi_left_bracket;
|
|
|
82e8e7 |
static ptyc_term_handler esi_right_bracket;
|
|
|
82e8e7 |
static ptyc_term_handler esi_left_parenthesis;
|
|
|
82e8e7 |
static ptyc_term_handler esi_right_parenthesis;
|
|
|
82e8e7 |
|
|
|
82e8e7 |
ptyc_term_handler * const ptyc_esi_handlers[PTYC_ESI_ARRAY_SIZE] = {
|
|
|
82e8e7 |
esi_illegal_code, /* 0x00 */
|
|
|
82e8e7 |
esi_illegal_code, /* 0x01 */
|
|
|
82e8e7 |
esi_illegal_code, /* 0x02 */
|
|
|
82e8e7 |
esi_illegal_code, /* 0x03 */
|
|
|
82e8e7 |
esi_illegal_code, /* 0x04 */
|
|
|
82e8e7 |
esi_illegal_code, /* 0x05 */
|
|
|
82e8e7 |
esi_illegal_code, /* 0x06 */
|
|
|
82e8e7 |
esi_illegal_code, /* 0x07 */
|
|
|
82e8e7 |
esi_illegal_code, /* 0x08 */
|
|
|
82e8e7 |
esi_illegal_code, /* 0x09 */
|
|
|
82e8e7 |
esi_illegal_code, /* 0x0a */
|
|
|
82e8e7 |
esi_illegal_code, /* 0x0b */
|
|
|
82e8e7 |
esi_illegal_code, /* 0x0c */
|
|
|
82e8e7 |
esi_illegal_code, /* 0x0d */
|
|
|
82e8e7 |
esi_illegal_code, /* 0x0e */
|
|
|
82e8e7 |
esi_illegal_code, /* 0x0f */
|
|
|
82e8e7 |
esi_illegal_code, /* 0x10 */
|
|
|
82e8e7 |
esi_illegal_code, /* 0x11 */
|
|
|
82e8e7 |
esi_illegal_code, /* 0x12 */
|
|
|
82e8e7 |
esi_illegal_code, /* 0x13 */
|
|
|
82e8e7 |
esi_illegal_code, /* 0x14 */
|
|
|
82e8e7 |
esi_illegal_code, /* 0x15 */
|
|
|
82e8e7 |
esi_illegal_code, /* 0x16 */
|
|
|
82e8e7 |
esi_illegal_code, /* 0x17 */
|
|
|
82e8e7 |
esi_illegal_code, /* 0x18 */
|
|
|
82e8e7 |
esi_illegal_code, /* 0x19 */
|
|
|
82e8e7 |
esi_illegal_code, /* 0x1a */
|
|
|
82e8e7 |
esi_illegal_code, /* 0x1b */
|
|
|
82e8e7 |
esi_illegal_code, /* 0x1c */
|
|
|
82e8e7 |
esi_illegal_code, /* 0x1d */
|
|
|
82e8e7 |
esi_illegal_code, /* 0x1e */
|
|
|
82e8e7 |
esi_illegal_code, /* 0x1f */
|
|
|
82e8e7 |
esi_illegal_code, /* 0x20 */
|
|
|
82e8e7 |
esi_illegal_code, /* 0x21 */
|
|
|
82e8e7 |
esi_illegal_code, /* 0x22 */
|
|
|
82e8e7 |
esi_illegal_code, /* 0x23 */
|
|
|
82e8e7 |
esi_illegal_code, /* 0x24 */
|
|
|
82e8e7 |
esi_illegal_code, /* 0x25 */
|
|
|
82e8e7 |
esi_illegal_code, /* 0x26 */
|
|
|
82e8e7 |
esi_illegal_code, /* 0x27 */
|
|
|
82e8e7 |
esi_left_parenthesis, /* 0x28 */ /* TODO: */
|
|
|
82e8e7 |
esi_right_parenthesis, /* 0x29 */ /* TODO: */
|
|
|
82e8e7 |
esi_illegal_code, /* 0x2a */
|
|
|
82e8e7 |
esi_illegal_code, /* 0x2b */
|
|
|
82e8e7 |
esi_illegal_code, /* 0x2c */
|
|
|
82e8e7 |
esi_illegal_code, /* 0x2d */
|
|
|
82e8e7 |
esi_illegal_code, /* 0x2e */
|
|
|
82e8e7 |
esi_illegal_code, /* 0x2f */
|
|
|
82e8e7 |
esi_illegal_code, /* 0x30 */
|
|
|
82e8e7 |
esi_illegal_code, /* 0x31 */
|
|
|
82e8e7 |
esi_illegal_code, /* 0x32 */
|
|
|
82e8e7 |
esi_illegal_code, /* 0x33 */
|
|
|
82e8e7 |
esi_illegal_code, /* 0x34 */
|
|
|
82e8e7 |
esi_illegal_code, /* 0x35 */
|
|
|
82e8e7 |
esi_illegal_code, /* 0x36 */
|
|
|
82e8e7 |
esi_illegal_code, /* 0x37 */
|
|
|
82e8e7 |
esi_illegal_code, /* 0x38 */
|
|
|
82e8e7 |
esi_illegal_code, /* 0x39 */
|
|
|
82e8e7 |
esi_illegal_code, /* 0x3a */
|
|
|
82e8e7 |
esi_illegal_code, /* 0x3b */
|
|
|
82e8e7 |
esi_illegal_code, /* 0x3c */
|
|
|
82e8e7 |
esi_illegal_code, /* 0x3d */
|
|
|
82e8e7 |
esi_illegal_code, /* 0x3e */
|
|
|
82e8e7 |
esi_illegal_code, /* 0x3f */
|
|
|
82e8e7 |
esi_illegal_code, /* 0x40 */
|
|
|
82e8e7 |
esi_illegal_code, /* 0x41 */
|
|
|
82e8e7 |
esi_illegal_code, /* 0x42 */
|
|
|
82e8e7 |
esi_illegal_code, /* 0x43 */
|
|
|
82e8e7 |
esi_illegal_code, /* 0x44 */
|
|
|
82e8e7 |
esi_illegal_code, /* 0x45 */
|
|
|
82e8e7 |
esi_illegal_code, /* 0x46 */
|
|
|
82e8e7 |
esi_illegal_code, /* 0x47 */
|
|
|
82e8e7 |
esi_illegal_code, /* 0x48 */
|
|
|
82e8e7 |
esi_illegal_code, /* 0x49 */
|
|
|
82e8e7 |
esi_illegal_code, /* 0x4a */
|
|
|
82e8e7 |
esi_illegal_code, /* 0x4b */
|
|
|
82e8e7 |
esi_illegal_code, /* 0x4c */
|
|
|
82e8e7 |
esi_illegal_code, /* 0x4d */
|
|
|
82e8e7 |
esi_illegal_code, /* 0x4e */
|
|
|
82e8e7 |
esi_illegal_code, /* 0x4f */
|
|
|
82e8e7 |
esi_illegal_code, /* 0x50 */
|
|
|
82e8e7 |
esi_illegal_code, /* 0x51 */
|
|
|
82e8e7 |
esi_illegal_code, /* 0x52 */
|
|
|
82e8e7 |
esi_illegal_code, /* 0x53 */
|
|
|
82e8e7 |
esi_illegal_code, /* 0x54 */
|
|
|
82e8e7 |
esi_illegal_code, /* 0x55 */
|
|
|
82e8e7 |
esi_illegal_code, /* 0x56 */
|
|
|
82e8e7 |
esi_illegal_code, /* 0x57 */
|
|
|
82e8e7 |
esi_illegal_code, /* 0x58 */
|
|
|
82e8e7 |
esi_illegal_code, /* 0x59 */
|
|
|
82e8e7 |
esi_illegal_code, /* 0x5a */
|
|
|
82e8e7 |
esi_left_bracket, /* 0x5b */ /* CSI */
|
|
|
82e8e7 |
esi_illegal_code, /* 0x5c */
|
|
|
82e8e7 |
esi_right_bracket, /* 0x5d */ /* TODO: */
|
|
|
82e8e7 |
esi_illegal_code /* 0x5e */
|
|
|
82e8e7 |
};
|
|
|
82e8e7 |
|
|
|
82e8e7 |
|
|
|
82e8e7 |
static void * __fastcall esi_illegal_code(struct ptyc_term_ctx * tctx)
|
|
|
82e8e7 |
{
|
|
|
82e8e7 |
/* defer to the screen handler routine */
|
|
|
82e8e7 |
return tctx->char_handler;
|
|
|
82e8e7 |
}
|
|
|
82e8e7 |
|
|
|
82e8e7 |
|
|
|
82e8e7 |
static void * __fastcall esi_select(
|
|
|
82e8e7 |
struct ptyc_term_ctx * tctx,
|
|
|
82e8e7 |
ptyc_term_handler * const * handlers,
|
|
|
82e8e7 |
unsigned int ctrl_cap)
|
|
|
82e8e7 |
{
|
|
|
82e8e7 |
/* set state to param handlers */
|
|
|
82e8e7 |
tctx->ctrl_state = PTYC_CTRL_STATE_PARAM_HANDLERS;
|
|
|
82e8e7 |
|
|
|
82e8e7 |
/* select param handler array */
|
|
|
82e8e7 |
tctx->ctrl_handlers[tctx->ctrl_state] = handlers;
|
|
|
82e8e7 |
tctx->ctrl_cap = ctrl_cap;
|
|
|
82e8e7 |
|
|
|
82e8e7 |
/* prepare to read the first ctrl param */
|
|
|
82e8e7 |
tctx->ctrl_param = tctx->ctrl_params;
|
|
|
82e8e7 |
tctx->ctrl_params[0] = 0;
|
|
|
82e8e7 |
|
|
|
82e8e7 |
/* advance the stream pointer */
|
|
|
82e8e7 |
tctx->wch_pty++;
|
|
|
82e8e7 |
|
|
|
82e8e7 |
/* retain mode */
|
|
|
82e8e7 |
return tctx->ctrl_handler;
|
|
|
82e8e7 |
}
|
|
|
82e8e7 |
|
|
|
82e8e7 |
|
|
|
82e8e7 |
static void * __fastcall esi_left_bracket(struct ptyc_term_ctx * tctx)
|
|
|
82e8e7 |
{
|
|
|
3d2f26 |
return esi_select(tctx,ptyc_csi_handlers,PTYC_CSI_ARRAY_SIZE);
|
|
|
82e8e7 |
}
|
|
|
82e8e7 |
|
|
|
82e8e7 |
|
|
|
82e8e7 |
static void * __fastcall esi_right_bracket(struct ptyc_term_ctx * tctx)
|
|
|
82e8e7 |
{
|
|
|
82e8e7 |
/* todo: */
|
|
|
82e8e7 |
return esi_illegal_code(tctx);
|
|
|
82e8e7 |
}
|
|
|
82e8e7 |
|
|
|
82e8e7 |
|
|
|
82e8e7 |
static void * __fastcall esi_left_parenthesis(struct ptyc_term_ctx * tctx)
|
|
|
82e8e7 |
{
|
|
|
82e8e7 |
/* todo: */
|
|
|
82e8e7 |
return esi_illegal_code(tctx);
|
|
|
82e8e7 |
}
|
|
|
82e8e7 |
|
|
|
82e8e7 |
|
|
|
82e8e7 |
static void * __fastcall esi_right_parenthesis(struct ptyc_term_ctx * tctx)
|
|
|
82e8e7 |
{
|
|
|
82e8e7 |
/* todo: */
|
|
|
82e8e7 |
return esi_illegal_code(tctx);
|
|
|
82e8e7 |
}
|