This commit is contained in:
Loic Deridder
2025-01-20 12:58:57 +01:00
parent c36c1550d7
commit cd8c8b36d9
8 changed files with 296 additions and 125 deletions

View File

@@ -2,6 +2,7 @@
# define BUILTINS_H
# include "../lib/libft/libft.h"
# include "env.h"
# include <stdio.h>
# include <sys/types.h>
# include <signal.h>
@@ -9,14 +10,15 @@
# include <unistd.h>
# include <errno.h>
# include <stdlib.h>
# include <string.h>
// void echo(char *msg, int flag);
void builtin_echo(char *arg, char **envp);
void builtin_exit(char *arg, bool depth);
void builtin_pwd(char *arg);
void builtin_env(char *str, char **envp);
void builtin_unset(char *str, char **envp);
char **builtin_cd(char **arg, char **envp);
int builtin_unset(char **arg, t_data *data);
int builtin_cd(char **arg, t_data *data);
char **builtin_export(char **arg, char **envp);
//UTILS
@@ -24,5 +26,6 @@ int count_char(char *str);
int count_args(char **tab);
int extractenv(char *str, char **envp);
char *ft_getenv(char *str, char **envp);
int err_msg_cmd(char *cmd, char *arg, char *msg, int code);
#endif

24
includes/env.h Normal file
View File

@@ -0,0 +1,24 @@
#ifndef ENV_H
# define ENV_H
# include "../lib/libft/libft.h"
# include <unistd.h>
# include <stdlib.h>
# include <stdbool.h>
typedef struct s_data
{
char **env;
} t_data;
//VAR
int count_var(char **envp);
int get_var_index(char *key, char **envp);
void free_null_ptr(void *ptr);
char **copy_env_var(char **envp, int count);
char *get_var_value(char *key, char **envp);
bool is_valid_key(char *key, char **envp);
int remove_env_var(char *key, char **envp);
void set_var_env(char *key, char *value, t_data *t_data);
#endif

View File

@@ -9,6 +9,7 @@
# include "../lib/libft/libft.h"
# include "builtins.h"
# include "env.h"
# define POW1 "\033[1;38;2;21;22;26;48;2;92;106;178m"
# define POW2 "\033[1;38;2;92;106;178;48;2;54;54;54m"