norm
This commit is contained in:
parent
0bcb738496
commit
147743058d
4 changed files with 29 additions and 28 deletions
|
@ -6,7 +6,7 @@
|
|||
/* By: jschaft <cecile.schaft@orange.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/04/23 14:15:12 by mcolonna #+# #+# */
|
||||
/* Updated: 2024/06/28 14:01:25 by mcolonna ### ########.fr */
|
||||
/* Updated: 2024/07/01 11:12:51 by mcolonna ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
@ -17,11 +17,11 @@
|
|||
|
||||
typedef struct s_env
|
||||
{
|
||||
t_memclass mc_global; // open during all the runtime
|
||||
t_memclass mc_command; // open during the execution of a command
|
||||
int errorstatus; // Error status of the last executed command
|
||||
t_list *variables; // Shell variables
|
||||
bool exit; // Set to true to exit minishell
|
||||
t_memclass mc_global;
|
||||
t_memclass mc_command;
|
||||
int errorstatus;
|
||||
t_list *variables;
|
||||
bool exit;
|
||||
} t_env;
|
||||
|
||||
#endif
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jschaft <cecile.schaft@orange.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/04/23 14:15:12 by mcolonna #+# #+# */
|
||||
/* Updated: 2024/06/27 13:47:56 by mcolonna ### ########.fr */
|
||||
/* Updated: 2024/07/01 11:16:02 by mcolonna ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
@ -18,26 +18,25 @@
|
|||
// Represents a call to a program (the program name and its arguments)
|
||||
typedef struct s_call
|
||||
{
|
||||
const char *program; // path of the program to call.
|
||||
int argc; // number of arguments given
|
||||
char *const *argv; // arguments given (ended by NULL)
|
||||
// (argc and argv must include the program name)
|
||||
const char *program;
|
||||
int argc;
|
||||
char *const *argv;
|
||||
} t_call;
|
||||
|
||||
// Represents a command given by the user.
|
||||
typedef struct s_command
|
||||
{
|
||||
int error; // 0 if parse_command() succeded, error status if not
|
||||
bool empty; // true if there isn't anything to do
|
||||
const t_call *calls; // all calls to programs (ended by .program == NULL)
|
||||
int input_fd; // fd to use with '<' redirection (0 by default)
|
||||
int output_fd; // fd to use with '>' redirection (1 by default)
|
||||
int error;
|
||||
bool empty;
|
||||
const t_call *calls;
|
||||
int input_fd;
|
||||
int output_fd;
|
||||
} t_command;
|
||||
|
||||
// An element of a list of pipes
|
||||
typedef struct s_pipes
|
||||
{
|
||||
int pipe[2]; // Simple pipe, we write on pipe[1] and we read on pipe[0]
|
||||
int pipe[2];
|
||||
} t_pipes;
|
||||
|
||||
// Return the t_command representing the command given by the user.
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
/* By: mcolonna <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/04/24 13:47:40 by mcolonna #+# #+# */
|
||||
/* Updated: 2024/06/27 14:47:14 by mcolonna ### ########.fr */
|
||||
/* Updated: 2024/07/01 11:15:33 by mcolonna ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
@ -20,13 +20,13 @@
|
|||
// Global variables for all the parsing functions
|
||||
typedef struct s_parsing_args
|
||||
{
|
||||
t_memclass mc; // mc freed given to parse_command
|
||||
t_command r; // t_command that parse_command will return
|
||||
t_stream stream; // stream reading the command string
|
||||
t_list calls; // list of calls
|
||||
bool got_first_call; // already got at least the first program call?
|
||||
const char *heredoc; // EOF line for heredoc. NULL if no heredoc
|
||||
t_list *variables; // list of current variables
|
||||
t_memclass mc;
|
||||
t_command r;
|
||||
t_stream stream;
|
||||
t_list calls;
|
||||
bool got_first_call;
|
||||
const char *heredoc;
|
||||
t_list *variables;
|
||||
t_env *env;
|
||||
} t_parsing_args;
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
/* By: mcolonna <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/04/24 13:47:40 by mcolonna #+# #+# */
|
||||
/* Updated: 2024/06/28 14:33:14 by mcolonna ### ########.fr */
|
||||
/* Updated: 2024/07/01 13:38:03 by mcolonna ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
@ -15,8 +15,10 @@
|
|||
|
||||
void variables_set(t_list *variables, const char *name, const char *value)
|
||||
{
|
||||
variables_find(variables, name)->value = (
|
||||
str_dup(fatal_error, variables->mc, value));
|
||||
t_variable *var;
|
||||
|
||||
var = variables_find(variables, name);
|
||||
var->value = str_dup(fatal_error, variables->mc, value);
|
||||
}
|
||||
|
||||
const char *variables_get(t_list *variables, const char *name)
|
||||
|
|
Loading…
Add table
Reference in a new issue