1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2014 Intel Corporation.
3 * Copyright (c) 2009, Olivier MATZ <zer0@droids-corp.org>
15 #include "cmdline_vt100.h"
17 const char *cmdline_vt100_commands[] = {
48 vt100_init(struct cmdline_vt100 *vt)
52 vt->state = CMDLINE_VT100_INIT;
57 match_command(char *buf, unsigned int size)
63 for (i=0 ; i<sizeof(cmdline_vt100_commands)/sizeof(const char *) ; i++) {
64 cmd = *(cmdline_vt100_commands + i);
66 cmdlen = strnlen(cmd, CMDLINE_VT100_BUF_SIZE);
68 !strncmp(buf, cmd, cmdlen)) {
77 vt100_parser(struct cmdline_vt100 *vt, char ch)
80 uint8_t c = (uint8_t) ch;
85 if (vt->bufpos >= CMDLINE_VT100_BUF_SIZE) {
86 vt->state = CMDLINE_VT100_INIT;
90 vt->buf[vt->bufpos++] = c;
94 case CMDLINE_VT100_INIT:
96 vt->state = CMDLINE_VT100_ESCAPE;
104 case CMDLINE_VT100_ESCAPE:
106 vt->state = CMDLINE_VT100_ESCAPE_CSI;
108 else if (c >= 060 && c <= 0177) { /* XXX 0177 ? */
110 vt->state = CMDLINE_VT100_INIT;
115 case CMDLINE_VT100_ESCAPE_CSI:
116 if (c >= 0100 && c <= 0176) {
118 vt->state = CMDLINE_VT100_INIT;
131 return match_command(vt->buf, size);