3 * @brief VT100互換の受信用パーサの定義。
5 * An implementation of Paul Williams' DEC compatible state machine parser
6 * This code is in the public domain.
8 * @author Joshua Haberman <joshua@reverberate.org>
9 * @author Shinichiro Nakamura : Modified for Natural Tiny Shell (NT-Shell)
15 #define MAX_INTERMEDIATE_CHARS 2
16 #define ACTION(state_change) (vtrecv_action_t)(state_change & 0x0F)
17 #define STATE(state_change) (vtrecv_state_t)(state_change >> 4)
20 VTRECV_STATE_ANYWHERE = 0,
21 VTRECV_STATE_CSI_ENTRY = 1,
22 VTRECV_STATE_CSI_IGNORE = 2,
23 VTRECV_STATE_CSI_INTERMEDIATE = 3,
24 VTRECV_STATE_CSI_PARAM = 4,
25 VTRECV_STATE_DCS_ENTRY = 5,
26 VTRECV_STATE_DCS_IGNORE = 6,
27 VTRECV_STATE_DCS_INTERMEDIATE = 7,
28 VTRECV_STATE_DCS_PARAM = 8,
29 VTRECV_STATE_DCS_PASSTHROUGH = 9,
30 VTRECV_STATE_ESCAPE = 10,
31 VTRECV_STATE_ESCAPE_INTERMEDIATE = 11,
32 VTRECV_STATE_GROUND = 12,
33 VTRECV_STATE_OSC_STRING = 13,
34 VTRECV_STATE_SOS_PM_APC_STRING = 14,
38 VTRECV_ACTION_CLEAR = 1,
39 VTRECV_ACTION_COLLECT = 2,
40 VTRECV_ACTION_CSI_DISPATCH = 3,
41 VTRECV_ACTION_ESC_DISPATCH = 4,
42 VTRECV_ACTION_EXECUTE = 5,
43 VTRECV_ACTION_HOOK = 6,
44 VTRECV_ACTION_IGNORE = 7,
45 VTRECV_ACTION_OSC_END = 8,
46 VTRECV_ACTION_OSC_PUT = 9,
47 VTRECV_ACTION_OSC_START = 10,
48 VTRECV_ACTION_PARAM = 11,
49 VTRECV_ACTION_PRINT = 12,
50 VTRECV_ACTION_PUT = 13,
51 VTRECV_ACTION_UNHOOK = 14,
54 typedef unsigned char state_change_t;
58 typedef void (*vtrecv_callback_t)(struct vtrecv*, vtrecv_action_t, unsigned char);
60 typedef struct vtrecv {
63 unsigned char intermediate_chars[MAX_INTERMEDIATE_CHARS+1];
74 void vtrecv_init(vtrecv_t *parser, vtrecv_callback_t cb);
75 void vtrecv_execute(vtrecv_t *parser, unsigned char *data, int len);