SOURCES := main.c \
env.c \
vars.c \
+ termios.c \
input_handling.c \
wildcards.c \
wildcards_inner.c \
/* By: lnikolov <lnikolov@student.42prague.com +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/05/02 13:22:57 by ljiriste #+# #+# */
-/* Updated: 2024/09/01 09:13:19 by ljiriste ### ########.fr */
+/* Updated: 2024/09/01 09:47:19 by ljiriste ### ########.fr */
/* */
/* ************************************************************************** */
char *get_line(void);
void terminate_input(void);
void set_input_handler(void);
+void setup_terminal(void);
+void regenerate_terminal(void);
void handle_input(char **line, t_execution_env *env);
/* By: lnikolov <lnikolov@student.42prague.com +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/04/26 13:11:47 by ljiriste #+# #+# */
-/* Updated: 2024/09/01 08:25:02 by ljiriste ### ########.fr */
+/* Updated: 2024/09/01 09:47:36 by ljiriste ### ########.fr */
/* */
/* ************************************************************************** */
#include <stdlib.h>
#include <signal.h>
-#include <termios.h>
-#include <unistd.h>
volatile sig_atomic_t g_last_signal;
return ;
}
-typedef enum e_termios_action
-{
- term_save,
- term_load,
-} t_termios_action;
-
-void termios_control(t_termios_action action, struct termios *termios)
-{
- static struct termios saved;
-
- if (action == term_save)
- saved = *termios;
- else if (action == term_load)
- *termios = saved;
- return ;
-}
-
-void setup_terminal(void)
-{
- struct termios termios;
-
- tcgetattr(STDIN_FILENO, &termios);
- termios_control(term_save, &termios);
- termios.c_lflag |= NOFLSH;
- tcsetattr(STDIN_FILENO, TCSANOW, &termios);
- return ;
-}
-
-void regenerate_terminal(void)
-{
- struct termios termios;
-
- termios_control(term_load, &termios);
- tcsetattr(STDIN_FILENO, TCSANOW, &termios);
- return ;
-}
-
/*
// This would be more portable than the main with 3 input args
extern char **environ;
--- /dev/null
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* termios.c :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: ljiriste <marvin@42.fr> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2024/09/01 09:46:34 by ljiriste #+# #+# */
+/* Updated: 2024/09/01 09:47:37 by ljiriste ### ########.fr */
+/* */
+/* ************************************************************************** */
+
+#include "minishell.h"
+#include <unistd.h>
+#include <termios.h>
+
+static struct termios *access_termios_saved(void)
+{
+ static struct termios saved;
+
+ return (&saved);
+}
+
+void setup_terminal(void)
+{
+ struct termios termios;
+
+ tcgetattr(STDIN_FILENO, &termios);
+ *access_termios_saved() = termios;
+ termios.c_lflag |= NOFLSH;
+ tcsetattr(STDIN_FILENO, TCSANOW, &termios);
+ return ;
+}
+
+void regenerate_terminal(void)
+{
+ struct termios termios;
+
+ termios = *access_termios_saved();
+ tcsetattr(STDIN_FILENO, TCSANOW, &termios);
+ return ;
+}