xref: /dpdk/lib/cmdline/cmdline_private.h (revision 99f9d799ce21ab22e922ffec8aad51d56e24d04d)
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 #include <rte_os_shim.h>
12 #ifdef RTE_EXEC_ENV_WINDOWS
13 #include <rte_windows.h>
14 #endif
15 
16 #include <cmdline.h>
17 
18 #ifdef RTE_EXEC_ENV_WINDOWS
19 struct terminal {
20 	DWORD input_mode;
21 	DWORD output_mode;
22 	int is_console_input;
23 	int is_console_output;
24 };
25 
26 struct cmdline {
27 	int s_in;
28 	int s_out;
29 	cmdline_parse_ctx_t *ctx;
30 	struct rdline rdl;
31 	char prompt[RDLINE_PROMPT_SIZE];
32 	struct terminal oldterm;
33 	char repeated_char;
34 	WORD repeat_count;
35 };
36 #endif
37 
38 /* Disable buffering and echoing, save previous settings to oldterm. */
39 void terminal_adjust(struct cmdline *cl);
40 
41 /* Restore terminal settings form oldterm. */
42 void terminal_restore(const struct cmdline *cl);
43 
44 /* Check if a single character can be read from input. */
45 int cmdline_poll_char(struct cmdline *cl);
46 
47 /* Read one character from input. */
48 ssize_t cmdline_read_char(struct cmdline *cl, char *c);
49 
50 /* vdprintf(3) */
51 __rte_format_printf(2, 0)
52 int cmdline_vdprintf(int fd, const char *format, va_list op);
53 
54 #endif
55