-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #504 from biralavor/502-apply-norminette-at-headers
applying norminette at headers
- Loading branch information
Showing
8 changed files
with
79 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
/* By: umeneses <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2024/07/16 14:57:00 by umeneses #+# #+# */ | ||
/* Updated: 2024/10/08 16:43:23 by umeneses ### ########.fr */ | ||
/* Updated: 2024/10/08 22:52:58 by umeneses ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
|
@@ -18,63 +18,64 @@ | |
# define LONG_MAX_CODE "9223372036854775807" | ||
# define LONG_MIN_CODE "-9223372036854775807" | ||
|
||
void execute_multiple_args(t_token_list *args, void (*func)(char *)); | ||
void execute_multiple_args(t_token_list *args, | ||
void (*func)(char *)); | ||
|
||
/** | ||
* @brief: Calls the qqrespective builtin function. | ||
*/ | ||
void builtins_manager(t_token_list *cmd); | ||
void builtins_manager(t_token_list *cmd); | ||
|
||
/** | ||
* @brief: Builtins manager for EXPORT and UNSET. | ||
*/ | ||
void builtins_with_possible_args_manager(t_token_list *cmd); | ||
void builtins_with_possible_args_manager(t_token_list *cmd); | ||
|
||
/** | ||
* @brief: Builtins detector for EXPORT and UNSET, | ||
* which could handle possible arguments. | ||
*/ | ||
bool builtins_detector_with_possible_args(t_token_list *cmd); | ||
bool builtins_detector_with_possible_args(t_token_list *cmd); | ||
|
||
/** | ||
* @brief: Checks if there are any builtins in the token list. | ||
*/ | ||
bool builtins_detector(t_token_list *cmd); | ||
bool builtins_detector(t_token_list *cmd); | ||
|
||
/** | ||
* @brief: Runs the echo - imitate words - builtin command. | ||
*/ | ||
void builtins_runner_echo(t_token_list *lst, bool arg_option); | ||
void builtins_runner_echo(t_token_list *lst, bool arg_option); | ||
|
||
/** | ||
* @brief: Runs the pwd - print work directory - builtin command. | ||
*/ | ||
void builtins_runner_pwd(t_token_list *lst); | ||
void builtins_runner_pwd(t_token_list *lst); | ||
|
||
/** | ||
* @brief: Runs the cd - change directory - builtin command. | ||
* TODO: Implement update_envs() after calling chdir(). | ||
*/ | ||
void builtins_runner_cd(t_token_list *lst); | ||
void builtins_runner_cd(t_token_list *lst); | ||
|
||
/** | ||
* @brief: Switches to the new directory. | ||
* @param destiny_path the path to be switched. | ||
*/ | ||
void builtins_cd_switch_new_dir(char *destiny_path); | ||
void builtins_cd_switch_new_dir(char *destiny_path); | ||
|
||
/** | ||
* @brief: Switches to the home directory, if user input is `cd ~`. | ||
*/ | ||
void builtins_cd_switch_home_dir(void); | ||
void builtins_cd_switch_home_dir(void); | ||
|
||
bool is_path_a_directory(char *path); | ||
bool is_path_a_directory(char *path); | ||
|
||
/** | ||
* @brief: Prints an error message when the cd command fails. | ||
*/ | ||
void cd_error_msg(int destiny_len, char *destiny_path, | ||
int chdir_status); | ||
void cd_error_msg(int destiny_len, char *destiny_path, | ||
int chdir_status); | ||
|
||
/** | ||
* @brief: Checks if the builtin command has an argument. | ||
|
@@ -86,118 +87,119 @@ t_token_list *checking_cmd_arg_options(t_token_list **cmd, char *arg); | |
* @param var_key the name of the variable to export. | ||
* @param var_value the value to be setted in the var_key. | ||
*/ | ||
void builtins_runner_export(char *arg); | ||
void builtins_runner_export(char *arg); | ||
|
||
/** | ||
* @brief: Handles the arguments of the export command. | ||
* @param env_vars the environment variables. | ||
* @param arg the argument to be handled, a lexeme from t_token_list. | ||
*/ | ||
void arg_handle_runner(t_env_entry *env_vars, char *arg); | ||
void arg_handle_runner(t_env_entry *env_vars, char *arg); | ||
|
||
/** | ||
* @brief: Handles the state of the argument to be exported. | ||
* @param arg the argument to be handled, a lexeme from t_token_list. | ||
* @param state the handler state of the argument. | ||
*/ | ||
int arg_handle_state_detector(int state, char *arg); | ||
int arg_handle_state_detector(int state, char *arg); | ||
|
||
void replace_env_var(t_env_entry *env_vars, char *var_key, char *var_value); | ||
void replace_env_var(t_env_entry *env_vars, char *var_key, | ||
char *var_value); | ||
|
||
t_env_entry *copy_env_table(t_env_entry *env_vars); | ||
t_env_entry *copy_env_table(t_env_entry *env_vars); | ||
|
||
/** | ||
* @brief: Runs the unset - remove an environment variable - builtin command. | ||
* @param env_vars the environment variables. | ||
* @param arg the argument to be searched and later, removed. | ||
*/ | ||
void builtins_runner_unset(char *arg); | ||
void builtins_runner_unset(char *arg); | ||
|
||
/** | ||
* @brief: Removes an environment variable from the environment table. | ||
* @param env_vars the environment variables. | ||
* @param arg the argument to be removed. | ||
*/ | ||
void ft_lst_remove_node(t_env_entry *tmp, t_env_entry *next, | ||
const char *var_key); | ||
void ft_lst_remove_node(t_env_entry *tmp, t_env_entry *next, | ||
const char *var_key); | ||
|
||
/** | ||
* @brief: Runs the env, which prints environment variables - builtin command. | ||
*/ | ||
void builtins_runner_env(void); | ||
void builtins_runner_env(void); | ||
|
||
/** | ||
* @brief: Prints the environment variables in the classic bash format. | ||
*/ | ||
void ft_env_printer_classic(t_env_entry *env_vars); | ||
void ft_env_printer_classic(t_env_entry *env_vars); | ||
|
||
/** | ||
* @brief: Sorts the environment variables. | ||
*/ | ||
t_env_entry *builtins_env_sort_manager(t_env_entry *env_vars); | ||
t_env_entry *builtins_env_sort_manager(t_env_entry *env_vars); | ||
|
||
/** | ||
* @brief: Checks if the environment variables are sorted. | ||
*/ | ||
bool builtins_is_env_sorted(t_env_entry *env_vars); | ||
bool builtins_is_env_sorted(t_env_entry *env_vars); | ||
|
||
/** | ||
* @brief: Sort the environment variables list. | ||
*/ | ||
t_env_entry *sorted_env_insert(t_env_entry **head, t_env_entry *new); | ||
t_env_entry *sorted_env_insert(t_env_entry **head, t_env_entry *new); | ||
|
||
/** | ||
* @brief: Runs the exit - exit the shell - builtin command. | ||
* @return the exit code, with an expected behaviour code from 0 to 255. | ||
*/ | ||
void builtins_runner_exit(t_token_list *lst); | ||
void builtins_runner_exit(t_token_list *lst); | ||
|
||
/** | ||
* @brief: Manages the exit error messages. | ||
* @param cmd the command to be checked. | ||
* @param exit_code the exit code to be saved, if error. | ||
* @return the error exit code, with an expected behaviour code from 1 to 2. | ||
*/ | ||
int exit_error_manager(t_token_list *cmd, int exit_code); | ||
int exit_error_manager(t_token_list *cmd, int exit_code); | ||
|
||
int exit_valid_code_manager(char *lexeme); | ||
int exit_valid_code_manager(char *lexeme); | ||
|
||
bool long_long_min_detected(bool update, bool status); | ||
bool long_long_min_detected(bool update, bool status); | ||
|
||
/** | ||
* @brief: Manages the exit code, with a long long modulo operation. | ||
* @param lexeme the lexeme to be converted to a long long, if necessary. | ||
* @return the exit code, with an expected behaviour code from 0 to 255. | ||
*/ | ||
int long_long_overflow_validation(const char *lexeme); | ||
int long_long_overflow_validation(const char *lexeme); | ||
|
||
/** | ||
* @brief: Checks if the exit code is not numeric, in the string. | ||
* @param lexeme the string to be checked. | ||
*/ | ||
bool exit_code_not_numeric(const char *lexeme); | ||
bool exit_code_not_numeric(const char *lexeme); | ||
|
||
/** | ||
* @brief: Holds the exit status of the shell. | ||
* @param exit_status Exit status number. | ||
*/ | ||
int exit_status_holder(int exit_status, bool update); | ||
int exit_status_holder(int exit_status, bool update); | ||
|
||
/** | ||
* @brief: Calls the exit status of the subprocess - fork. | ||
*/ | ||
void pid_exit_status_caller(pid_t pid); | ||
void pid_exit_status_caller(pid_t pid); | ||
|
||
/** | ||
* @brief: Clears all the memory allocated to exit the minishell smoothly. | ||
*/ | ||
void clear_all_to_exit_smoothly(void); | ||
void clear_all_to_exit_smoothly(void); | ||
|
||
/** | ||
* @brief: Holds the argument option status. | ||
* @param update the update the statict arg status variable. | ||
* @param call_status the call the statict arg status variable. | ||
*/ | ||
bool arg_option_holder(bool update, bool call_status); | ||
bool arg_option_holder(bool update, bool call_status); | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
/* By: umeneses <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2024/08/16 16:34:20 by umeneses #+# #+# */ | ||
/* Updated: 2024/09/15 13:31:36 by umeneses ### ########.fr */ | ||
/* Updated: 2024/10/08 22:32:41 by umeneses ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
|
@@ -38,12 +38,12 @@ typedef struct s_env_entry | |
* it copies the string before the '=' to KEY (at position equal_sign - *envp) | ||
* and the string after the '=' to VALUE. | ||
*/ | ||
void environment_init(char **envp); | ||
void environment_init(char **envp); | ||
|
||
/** | ||
* @brief Allocates memory for the environment table, by a size. | ||
*/ | ||
t_env_entry *alloc_table(int init_size); | ||
t_env_entry *alloc_table(int init_size); | ||
|
||
t_env_entry *create_new_entry(const char *key, const char *value, int size); | ||
|
||
|
@@ -58,17 +58,17 @@ void addto_env_table(t_env_entry **table, t_env_entry *new_entry); | |
* @param update -> if true, updates the static environment table. | ||
* @param clear_table -> if true, clears the static environment table. | ||
*/ | ||
t_env_entry *env_holder(t_env_entry *table, bool update, bool clear_table); | ||
t_env_entry *env_holder(t_env_entry *table, bool update, bool clear_table); | ||
|
||
/** | ||
* @brief: Goes to the head of the environment table. | ||
*/ | ||
t_env_entry *goto_head_env_table(t_env_entry *table); | ||
t_env_entry *goto_head_env_table(t_env_entry *table); | ||
|
||
/** | ||
* @brief: Goes to the end of the environment table. | ||
*/ | ||
t_env_entry *goto_end_env_table(t_env_entry *table); | ||
t_env_entry *goto_end_env_table(t_env_entry *table); | ||
|
||
/* ENVIRONMENT UTILS FUNCTIONS */ | ||
/** | ||
|
@@ -77,12 +77,12 @@ t_env_entry *goto_end_env_table(t_env_entry *table); | |
* @param key -> the key to be searched. | ||
* @return The pointer (t_env_entry) where KEY was found. | ||
*/ | ||
t_env_entry *lookup_table(t_env_entry *table, char *key); | ||
t_env_entry *lookup_table(t_env_entry *table, char *key); | ||
|
||
void ft_env_printer(t_env_entry *env_table); | ||
void ft_env_printer(t_env_entry *env_table); | ||
|
||
void free_env_table(t_env_entry **env_vars); | ||
void free_env_table(t_env_entry **env_vars); | ||
|
||
void free_array(char **array); | ||
void free_array(char **array); | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
/* By: umeneses <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2024/07/01 22:17:27 by umeneses #+# #+# */ | ||
/* Updated: 2024/09/26 14:55:06 by umeneses ### ########.fr */ | ||
/* Updated: 2024/10/08 22:33:28 by umeneses ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
|
@@ -62,7 +62,8 @@ void list_not_created(void); | |
* @param error_id -> error number defined in enum e_error in this header. | ||
* @param lst -> the token list. | ||
*/ | ||
void error_manager_parser(int error_id, t_token_list *lst, int syntax_state); | ||
void error_manager_parser(int error_id, t_token_list *lst, | ||
int syntax_state); | ||
|
||
char *get_metachar_type_as_str(int type); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
/* By: umeneses <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2024/06/27 12:53:52 by tmalheir #+# #+# */ | ||
/* Updated: 2024/10/04 11:27:27 by umeneses ### ########.fr */ | ||
/* Updated: 2024/10/08 22:45:42 by umeneses ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
|
@@ -126,10 +126,12 @@ t_token_list *find_dst_node(t_token_list *lst, int dst_idx); | |
|
||
void check_heredoc(t_token_list *lst); | ||
void path_file(t_token_list *lst); | ||
int check_delimiter(char *delimiter, int fd, char *input, int line); | ||
int check_delimiter(char *delimiter, int fd, char *input, | ||
int line); | ||
|
||
void heredoc_fd_reset(int *heredoc_fd); | ||
bool is_heredoc_running(bool update, bool caller); | ||
void heredoc_forcing_exit_warning(char *input, char *delimiter, int line, int fd); | ||
void heredoc_forcing_exit_warning(char *input, char *delimiter, | ||
int line, int fd); | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
/* By: umeneses <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2024/09/13 09:47:06 by umeneses #+# #+# */ | ||
/* Updated: 2024/10/07 15:15:11 by umeneses ### ########.fr */ | ||
/* Updated: 2024/10/08 22:53:27 by umeneses ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
|
@@ -67,7 +67,7 @@ void interrupt_signal_runner(int sig) | |
if (is_heredoc_running(false, true)) | ||
{ | ||
close(STDIN_FILENO); | ||
close(STDERR_FILENO); | ||
close(STDERR_FILENO); | ||
} | ||
ft_putstr_fd("\n", STDOUT_FILENO); | ||
rl_on_new_line(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
/* By: umeneses <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2024/08/07 10:58:32 by umeneses #+# #+# */ | ||
/* Updated: 2024/10/08 17:10:37 by umeneses ### ########.fr */ | ||
/* Updated: 2024/10/08 22:49:50 by umeneses ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
|
@@ -27,7 +27,8 @@ void environment_init(char **envp) | |
{ | ||
key = ft_substr(*envp, 0, equal_sign - *envp); | ||
value = ft_strdup(equal_sign + 1); | ||
addto_env_table(&env_table, create_new_entry(key, value, ft_array_len(envp))); | ||
addto_env_table(&env_table, create_new_entry(key, value, | ||
ft_array_len(envp))); | ||
free(key); | ||
free(value); | ||
} | ||
|
@@ -104,17 +105,3 @@ void addto_env_table(t_env_entry **table, t_env_entry *new_entry) | |
} | ||
} | ||
} | ||
|
||
t_env_entry *lookup_table(t_env_entry *table, char *key) | ||
{ | ||
t_env_entry *entry; | ||
|
||
entry = goto_head_env_table(table); | ||
while (entry != NULL) | ||
{ | ||
if (ft_strcmp(entry->key, key) == 0) | ||
return (entry); | ||
entry = entry->next; | ||
} | ||
return (NULL); | ||
} |
Oops, something went wrong.