lib: remove librte_ prefix from directory names
[dpdk.git] / lib / cmdline / cmdline_os_unix.c
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright (c) 2020 Dmitry Kozlyuk
3  */
4
5 #include <poll.h>
6 #include <string.h>
7 #include <unistd.h>
8
9 #include "cmdline_private.h"
10
11 void
12 terminal_adjust(struct cmdline *cl)
13 {
14         struct termios term;
15
16         tcgetattr(0, &cl->oldterm);
17
18         memcpy(&term, &cl->oldterm, sizeof(term));
19         term.c_lflag &= ~(ICANON | ECHO | ISIG);
20         tcsetattr(0, TCSANOW, &term);
21
22         setbuf(stdin, NULL);
23 }
24
25 void
26 terminal_restore(const struct cmdline *cl)
27 {
28         tcsetattr(fileno(stdin), TCSANOW, &cl->oldterm);
29 }
30
31 int
32 cmdline_poll_char(struct cmdline *cl)
33 {
34         struct pollfd pfd;
35
36         pfd.fd = cl->s_in;
37         pfd.events = POLLIN;
38         pfd.revents = 0;
39
40         return poll(&pfd, 1, 0);
41 }
42
43 ssize_t
44 cmdline_read_char(struct cmdline *cl, char *c)
45 {
46         return read(cl->s_in, c, 1);
47 }
48
49 int
50 cmdline_vdprintf(int fd, const char *format, va_list op)
51 {
52         return vdprintf(fd, format, op);
53 }