1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright (c) 2020 Dmitry Kozlyuk
3  */
4 
5 #ifndef _CMDLINE_PRIVATE_H_
6 #define _CMDLINE_PRIVATE_H_
7 
8 #include <stdarg.h>
9 
10 #include <rte_common.h>
11 #ifdef RTE_EXEC_ENV_WINDOWS
12 #include <rte_windows.h>
13 #endif
14 
15 #include <cmdline.h>
16 
17 #ifdef RTE_EXEC_ENV_WINDOWS
18 struct terminal {
19 	DWORD input_mode;
20 	DWORD output_mode;
21 	int is_console_input;
22 	int is_console_output;
23 };
24 
25 struct cmdline {
26 	int s_in;
27 	int s_out;
28 	cmdline_parse_ctx_t *ctx;
29 	struct rdline rdl;
30 	char prompt[RDLINE_PROMPT_SIZE];
31 	struct terminal oldterm;
32 	char repeated_char;
33 	WORD repeat_count;
34 };
35 #endif
36 
37 /* Disable buffering and echoing, save previous settings to oldterm. */
38 void terminal_adjust(struct cmdline *cl);
39 
40 /* Restore terminal settings form oldterm. */
41 void terminal_restore(const struct cmdline *cl);
42 
43 /* Check if a single character can be read from input. */
44 int cmdline_poll_char(struct cmdline *cl);
45 
46 /* Read one character from input. */
47 ssize_t cmdline_read_char(struct cmdline *cl, char *c);
48 
49 /* vdprintf(3) */
50 __rte_format_printf(2, 0)
51 int cmdline_vdprintf(int fd, const char *format, va_list op);
52 
53 #endif
54