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