/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* utils.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: narnaud +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/05/03 08:57:53 by narnaud #+# #+# */ /* Updated: 2022/05/03 09:00:40 by narnaud ### ########.fr */ /* */ /* ************************************************************************** */ #include "minishell.h" int is_empty(char *line) { while (*line) { if (*line <= 9 || (*line >= 13 && *line != 32)) return (0); line++; } return (1); } void termios(int ctl) { struct termios termios_p; int tty; tty = ttyslot(); if (tcgetattr(tty, &termios_p) < 0) exit ((perror("stdin"), EXIT_FAILURE)); //termios_p.c_oflag &= CRDLY; //termios_p.c_lflag &= ICANON; if (ctl) termios_p.c_lflag |= ECHOCTL; else termios_p.c_lflag &= ~(ECHOCTL); termios_p.c_cc[VQUIT] = ctl * 28; tcsetattr(tty, TCSANOW, &termios_p); } void sigs_handler(int sig_num) { if (sig_num == SIGQUIT) printf("QUIT: 3\n"); else if (sig_num == SIGINT) printf("\n"); rl_on_new_line(); rl_replace_line("", 0); rl_redisplay(); return ; } void halt(int ret_code) { printf("exit"); exit(ret_code); }