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 ssize_t 32 cmdline_read_char(struct cmdline *cl, char *c) 33 { 34 return read(cl->s_in, c, 1); 35 } 36 37 int 38 cmdline_vdprintf(int fd, const char *format, va_list op) 39 { 40 return vdprintf(fd, format, op); 41 } 42 43 /* This function is not needed on Linux, instead use sigaction() */ 44 void 45 cmdline_cancel(__rte_unused struct cmdline *cl) 46 { 47 } 48