diff --git a/Makefile b/Makefile index 29a02e8..efc03a2 100644 --- a/Makefile +++ b/Makefile @@ -22,7 +22,7 @@ LIBFT = $(LIBFT_PATH)/libft.a OBJ_PATH = obj -VPATH = src:src/enviroment:src/prompt:src/lexer:src/token:src/utils +VPATH = src:src/environment:src/prompt:src/lexer:src/token:src/utils SOURCES = $(shell basename -a $(shell find $(SRC_PATH) -type f -name "*.c")) OBJECTS = $(addprefix $(OBJ_PATH)/, $(SOURCES:.c=.o)) diff --git a/inc/enviroment.h b/inc/environment.h similarity index 63% rename from inc/enviroment.h rename to inc/environment.h index 7f86da1..66475a7 100644 --- a/inc/enviroment.h +++ b/inc/environment.h @@ -1,7 +1,7 @@ /* ************************************************************************** */ /* */ /* :::::::: */ -/* enviroment.h :+: :+: */ +/* environment.h :+: :+: */ /* +:+ */ /* By: whaffman +#+ */ /* +#+ */ @@ -10,13 +10,13 @@ /* */ /* ************************************************************************** */ -#ifndef ENVIROMENT_H -# define ENVIROMENT_H +#ifndef environment_H +# define environment_H -void add_enviroment(t_enviroment **enviroment, char *name, char *value); -void print_enviroment(t_enviroment *enviroment); -char *get_enviroment(t_enviroment *enviroment, char *name); -void free_enviroment(t_enviroment *enviroment); -int parse_enviroment(char **envp, t_enviroment **enviroment); +void add_environment(t_environment **environment, char *name, char *value); +void print_environment(t_environment *environment); +char *get_environment(t_environment *environment, char *name); +void free_environment(t_environment *environment); +int parse_environment(char **envp, t_environment **environment); -#endif // ENVIROMENT_H +#endif // environment_H diff --git a/inc/minishell.h b/inc/minishell.h index e02e5d8..c347bde 100644 --- a/inc/minishell.h +++ b/inc/minishell.h @@ -16,7 +16,7 @@ # include "allowed.h" # include "libft.h" # include "typedef.h" -# include "enviroment.h" +# include "environment.h" # include "prompt.h" # include "tokenizer.h" # include "utils.h" diff --git a/inc/typedef.h b/inc/typedef.h index 6d13724..d2e70d3 100644 --- a/inc/typedef.h +++ b/inc/typedef.h @@ -24,12 +24,12 @@ typedef enum e_token_type T_ERROR } t_token_type; -typedef struct s_enviroment +typedef struct s_environment { char *name; char *value; - struct s_enviroment *next; -} t_enviroment; + struct s_environment *next; +} t_environment; typedef struct s_token { @@ -48,7 +48,7 @@ typedef struct s_lexer typedef struct s_minishell { - t_enviroment *enviroment; + t_environment *environment; char *line; t_lexer *lexer; t_list *tokens; diff --git a/src/enviroment/add_enviroment.c b/src/environment/add_environment.c similarity index 68% rename from src/enviroment/add_enviroment.c rename to src/environment/add_environment.c index 8ee6ded..8e6d184 100644 --- a/src/enviroment/add_enviroment.c +++ b/src/environment/add_environment.c @@ -1,7 +1,7 @@ /* ************************************************************************** */ /* */ /* :::::::: */ -/* add_enviroment.c :+: :+: */ +/* add_environment.c :+: :+: */ /* +:+ */ /* By: whaffman +#+ */ /* +#+ */ @@ -12,21 +12,21 @@ #include "minishell.h" -void add_enviroment(t_enviroment **enviroment, char *name, char *value) +void add_environment(t_environment **environment, char *name, char *value) { - t_enviroment *new_enviroment; + t_environment *new_environment; if (name != NULL && value != NULL) { - new_enviroment = malloc(sizeof(t_enviroment)); - if (new_enviroment == NULL) + new_environment = malloc(sizeof(t_environment)); + if (new_environment == NULL) { perror("malloc"); return ; } - new_enviroment->name = ft_strdup(name); - new_enviroment->value = ft_strdup(value); - new_enviroment->next = *enviroment; - *enviroment = new_enviroment; + new_environment->name = ft_strdup(name); + new_environment->value = ft_strdup(value); + new_environment->next = *environment; + *environment = new_environment; } } diff --git a/src/enviroment/free_enviroment.c b/src/environment/free_environment.c similarity index 72% rename from src/enviroment/free_enviroment.c rename to src/environment/free_environment.c index b79317b..ccbde2b 100644 --- a/src/enviroment/free_enviroment.c +++ b/src/environment/free_environment.c @@ -1,7 +1,7 @@ /* ************************************************************************** */ /* */ /* :::::::: */ -/* free_enviroment.c :+: :+: */ +/* free_environment.c :+: :+: */ /* +:+ */ /* By: whaffman +#+ */ /* +#+ */ @@ -12,19 +12,19 @@ #include "minishell.h" -void free_enviroment(t_enviroment *enviroment) +void free_environment(t_environment *environment) { - t_enviroment *next; + t_environment *next; - while (enviroment != NULL) + while (environment != NULL) { - if (enviroment->next) - next = enviroment->next; + if (environment->next) + next = environment->next; else next = NULL; - free(enviroment->name); - free(enviroment->value); - free(enviroment); - enviroment = next; + free(environment->name); + free(environment->value); + free(environment); + environment = next; } } diff --git a/src/enviroment/get_enviroment.c b/src/environment/get_environment.c similarity index 75% rename from src/enviroment/get_enviroment.c rename to src/environment/get_environment.c index 0b580a3..2f7053e 100644 --- a/src/enviroment/get_enviroment.c +++ b/src/environment/get_environment.c @@ -1,7 +1,7 @@ /* ************************************************************************** */ /* */ /* :::::::: */ -/* get_enviroment.c :+: :+: */ +/* get_environment.c :+: :+: */ /* +:+ */ /* By: whaffman +#+ */ /* +#+ */ @@ -12,15 +12,15 @@ #include "minishell.h" -char *get_enviroment(t_enviroment *enviroment, char *name) +char *get_environment(t_environment *environment, char *name) { - while (enviroment != NULL) + while (environment != NULL) { - if (ft_strcmp(enviroment->name, name) == 0) + if (ft_strcmp(environment->name, name) == 0) { - return (enviroment->value); + return (environment->value); } - enviroment = enviroment->next; + environment = environment->next; } return (NULL); } diff --git a/src/enviroment/parse_enviroment.c b/src/environment/parse_environment.c similarity index 82% rename from src/enviroment/parse_enviroment.c rename to src/environment/parse_environment.c index 4f7e7b0..49f526f 100644 --- a/src/enviroment/parse_enviroment.c +++ b/src/environment/parse_environment.c @@ -1,7 +1,7 @@ /* ************************************************************************** */ /* */ /* :::::::: */ -/* parse_enviroment.c :+: :+: */ +/* parse_environment.c :+: :+: */ /* +:+ */ /* By: whaffman +#+ */ /* +#+ */ @@ -12,17 +12,17 @@ #include "minishell.h" -int parse_enviroment(char **envp, t_enviroment **enviroment) +int parse_environment(char **envp, t_environment **environment) { char **env; - *enviroment = NULL; + *environment = NULL; if (envp == NULL) return (FAILURE); while (*envp != NULL) { env = ft_split(*envp, '='); - add_enviroment(enviroment, env[0], env[1]); + add_environment(environment, env[0], env[1]); ft_free_arr(env); envp++; } diff --git a/src/enviroment/print_enviroment.c b/src/environment/print_environment.c similarity index 76% rename from src/enviroment/print_enviroment.c rename to src/environment/print_environment.c index 27192ec..2195ab5 100644 --- a/src/enviroment/print_enviroment.c +++ b/src/environment/print_environment.c @@ -1,7 +1,7 @@ /* ************************************************************************** */ /* */ /* :::::::: */ -/* print_enviroment.c :+: :+: */ +/* print_environment.c :+: :+: */ /* +:+ */ /* By: whaffman +#+ */ /* +#+ */ @@ -12,11 +12,11 @@ #include "minishell.h" -void print_enviroment(t_enviroment *enviroment) +void print_environment(t_environment *environment) { - while (enviroment != NULL) + while (environment != NULL) { - printf("%s=%s\n", enviroment->name, enviroment->value); - enviroment = enviroment->next; + printf("%s=%s\n", environment->name, environment->value); + environment = environment->next; } } diff --git a/src/main.c b/src/main.c index 9479f80..cc4a0bf 100644 --- a/src/main.c +++ b/src/main.c @@ -21,7 +21,7 @@ int main(int argc, char **argv, char **envp) print_banner(); ft_load_history(); minishell = init_minishell(); - parse_enviroment(envp, &(minishell->enviroment)); + parse_environment(envp, &(minishell->environment)); while (TRUE) { minishell->line = ft_prompt(minishell); diff --git a/src/prompt/prompt.c b/src/prompt/prompt.c index c37f8bb..089bc0e 100644 --- a/src/prompt/prompt.c +++ b/src/prompt/prompt.c @@ -12,12 +12,12 @@ #include "minishell.h" -char *get_user(t_enviroment *enviroment) +char *get_user(t_environment *environment) { char *str1; char *str2; - str1 = ft_strdup(get_enviroment(enviroment, "USER")); + str1 = ft_strdup(get_environment(environment, "USER")); if (str1 == NULL) { str1 = ft_strdup("guest"); @@ -29,14 +29,14 @@ char *get_user(t_enviroment *enviroment) return (str1); } -char *get_path(t_enviroment *enviroment) +char *get_path(t_environment *environment) { char *home; char *temp; char *cwd; cwd = getcwd(NULL, 0); - home = get_enviroment(enviroment, "HOME"); + home = get_environment(environment, "HOME"); if (cwd == NULL) { perror("getcwd"); @@ -63,10 +63,10 @@ char *ft_prompt(t_minishell *minishell) char *user; char *temp; - cwd = get_path(minishell->enviroment); + cwd = get_path(minishell->environment); if (cwd == NULL) return (NULL); - user = get_user(minishell->enviroment); + user = get_user(minishell->environment); temp = ft_strjoin(user, cwd); free(user); free(cwd); diff --git a/src/utils/free_minishell.c b/src/utils/free_minishell.c index b32f9a1..3a0df96 100644 --- a/src/utils/free_minishell.c +++ b/src/utils/free_minishell.c @@ -16,7 +16,7 @@ void free_minishell(t_minishell *minishell) { if (minishell->line) free_minishell_line(minishell); - if (minishell->enviroment) - free_enviroment(minishell->enviroment); + if (minishell->environment) + free_environment(minishell->environment); free(minishell); } diff --git a/src/utils/init_minishell.c b/src/utils/init_minishell.c index 3deda12..8abc805 100644 --- a/src/utils/init_minishell.c +++ b/src/utils/init_minishell.c @@ -22,7 +22,7 @@ t_minishell *init_minishell(void) perror("failed assigning minishell memory"); exit(EXIT_FAILURE); } - minishell->enviroment = NULL; + minishell->environment = NULL; minishell->line = NULL; minishell->lexer = NULL; minishell->tokens = NULL; diff --git a/src/utils/simple_builtins.c b/src/utils/simple_builtins.c index 0512fe0..7817cfc 100644 --- a/src/utils/simple_builtins.c +++ b/src/utils/simple_builtins.c @@ -28,7 +28,7 @@ void simple_builtins(t_minishell *minishell) if (cmp_value(minishell->tokens, "clear")) printf("\033[2J\033[1;1H"); else if (cmp_value(minishell->tokens, "env")) - print_enviroment(minishell->enviroment); + print_environment(minishell->environment); else if (cmp_value(minishell->tokens, "exit")) { free_minishell(minishell);