1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2014 Intel Corporation.
3 * Copyright (c) 2009, Olivier MATZ <zer0@droids-corp.org>
14 #include "cmdline_vt100.h"
16 const char *cmdline_vt100_commands[] = {
47 vt100_init(struct cmdline_vt100 *vt)
51 vt->state = CMDLINE_VT100_INIT;
56 match_command(char *buf, unsigned int size)
62 for (i=0 ; i<sizeof(cmdline_vt100_commands)/sizeof(const char *) ; i++) {
63 cmd = *(cmdline_vt100_commands + i);
65 cmdlen = strnlen(cmd, CMDLINE_VT100_BUF_SIZE);
67 !strncmp(buf, cmd, cmdlen)) {
76 vt100_parser(struct cmdline_vt100 *vt, char ch)
79 uint8_t c = (uint8_t) ch;
84 if (vt->bufpos >= CMDLINE_VT100_BUF_SIZE) {
85 vt->state = CMDLINE_VT100_INIT;
89 vt->buf[vt->bufpos++] = c;
93 case CMDLINE_VT100_INIT:
95 vt->state = CMDLINE_VT100_ESCAPE;
103 case CMDLINE_VT100_ESCAPE:
105 vt->state = CMDLINE_VT100_ESCAPE_CSI;
107 else if (c >= 060 && c <= 0177) { /* XXX 0177 ? */
109 vt->state = CMDLINE_VT100_INIT;
114 case CMDLINE_VT100_ESCAPE_CSI:
115 if (c >= 0100 && c <= 0176) {
117 vt->state = CMDLINE_VT100_INIT;
130 return match_command(vt->buf, size);