maxishell
Implementation of a shell for Linux-like systems
Loading...
Searching...
No Matches
initialise.c
Go to the documentation of this file.
1/* ************************************************************************** */
2/* */
3/* ::: :::::::: */
4/* initialise.c :+: :+: :+: */
5/* +:+ +:+ +:+ */
6/* By: rmikhayl <marvin@42.fr> +#+ +:+ +#+ */
7/* +#+#+#+#+#+ +#+ */
8/* Created: 2024/06/06 18:16:59 by rmikhayl #+# #+# */
9/* Updated: 2024/09/06 12:00:14 by dmdemirk ### ########.fr */
10/* */
11/* ************************************************************************** */
12
13#include "tokens.h"
14#include "env.h"
15#include "signals.h"
16
17void init_ms_data(t_ms_data *data, char **argv, char **envp);
18void initialise(int argc, char **argv);
19
20void init_ms_data(t_ms_data *data, char **argv, char **envp)
21{
22 (void)argv;
23 data->args = NULL;
24 data->envp = NULL;
25 init_env(&data->envp, envp);
26 data->shell_variables = NULL;
27 handle_add_set_shell_variable(&data->shell_variables, "_=/usr/bin/env");
28 set_shell_var(&data->shell_variables, "?", "0");
29 data->current_dir = getcwd(NULL, 0);
30 data->exit_status = 0;
31 data->std_in = -1;
32 data->std_out = -1;
33 data->std_err = 2;
34}
35
36void initialise(int argc, char **argv)
37{
38 if (argc > 1)
39 {
40 ft_printf("Usage: %s\n", argv[0]);
41 exit(EXIT_FAILURE);
42 }
43 read_history(HISTORY_PATH);
44}
void init_env(t_env **data_envp, char **envp)
Definition env.c:24
void set_shell_var(t_env **shell_var, const char *key, const char *value)
int handle_add_set_shell_variable(t_env **shell_var, char *line)
#define EXIT_FAILURE
Definition exit_status.h:17
void initialise(int argc, char **argv)
Definition initialise.c:36
void init_ms_data(t_ms_data *data, char **argv, char **envp)
Definition initialise.c:20
int ft_printf(const char *format,...)
Definition ft_printf.c:37
int exit_status
Definition shell.h:30
t_env * envp
Definition shell.h:24
int std_err
Definition shell.h:28
int std_out
Definition shell.h:27
t_env * shell_variables
Definition shell.h:25
char * current_dir
Definition shell.h:29
char ** args
Definition shell.h:23
int std_in
Definition shell.h:26
#define HISTORY_PATH
Definition tokens.h:27