1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright (c) 2020 Dmitry Kozlyuk
5 #ifndef _CMDLINE_PRIVATE_H_
6 #define _CMDLINE_PRIVATE_H_
10 #include <rte_common.h>
11 #include <rte_os_shim.h>
12 #ifdef RTE_EXEC_ENV_WINDOWS
13 #include <rte_windows.h>
20 #define RDLINE_BUF_SIZE 512
21 #define RDLINE_PROMPT_SIZE 32
22 #define RDLINE_VT100_BUF_SIZE 8
23 #define RDLINE_HISTORY_BUF_SIZE BUFSIZ
24 #define RDLINE_HISTORY_MAX_LINE 64
33 enum rdline_status status;
37 char left_buf[RDLINE_BUF_SIZE+2]; /* reserve 2 chars for the \n\0 */
38 char right_buf[RDLINE_BUF_SIZE];
40 char prompt[RDLINE_PROMPT_SIZE];
41 unsigned int prompt_size;
43 char kill_buf[RDLINE_BUF_SIZE];
44 unsigned int kill_size;
47 struct cirbuf history;
48 char history_buf[RDLINE_HISTORY_BUF_SIZE];
51 /* callbacks and func pointers */
52 rdline_write_char_t *write_char;
53 rdline_validate_t *validate;
54 rdline_complete_t *complete;
57 struct cmdline_vt100 vt100;
63 #ifdef RTE_EXEC_ENV_WINDOWS
68 int is_console_output;
75 cmdline_parse_ctx_t *ctx;
77 char prompt[RDLINE_PROMPT_SIZE];
78 #ifdef RTE_EXEC_ENV_WINDOWS
79 struct terminal oldterm;
83 struct termios oldterm;
87 /* Disable buffering and echoing, save previous settings to oldterm. */
88 void terminal_adjust(struct cmdline *cl);
90 /* Restore terminal settings form oldterm. */
91 void terminal_restore(const struct cmdline *cl);
93 /* Check if a single character can be read from input. */
94 int cmdline_poll_char(struct cmdline *cl);
96 /* Read one character from input. */
97 ssize_t cmdline_read_char(struct cmdline *cl, char *c);
100 __rte_format_printf(2, 0)
101 int cmdline_vdprintf(int fd, const char *format, va_list op);
103 int rdline_init(struct rdline *rdl,
104 rdline_write_char_t *write_char,
105 rdline_validate_t *validate,
106 rdline_complete_t *complete,