/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* include.h :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: mcolonna +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/04/23 14:15:12 by mcolonna #+# #+# */ /* Updated: 2024/04/24 13:19:28 by mcolonna ### ########.fr */ /* */ /* ************************************************************************** */ #ifndef INCLUDE_H # define INCLUDE_H # include # include # include # include # include # include # include # include # include # include "libft.h" # include "libtf.h" ///// ASK COMMAND ///// // Show the prompt and ask a command to the user. // Return the command. const char *ask_command(t_memclass mc); ///// PARSE_COMMAND ///// // 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 const char *const *argv; // arguments given // (argc and argv must include the program name) } t_call; // Represents a command given by the user. typedef struct s_command { bool error; // true means an error occured in interpret_command(). const t_call *calls; // all calls to programs. int input_fd; // fd to use with '<' redirection (0 by default) int output_fd; // fd to use with '>' redirection (1 by default) } t_command; // Return the t_command representing the command given by the user. // If error, return a t_command wth the value .error = true. t_command parse_command(const char *command); ///// EXECUTE COMMAND ///// // Execute the command given. Return the exit status. int execute_command(t_command command); ///// ERROR ///// // Call to show an error. // If msg == "errno", use strerror(errno) void minishell_error(const char *msg); ///// PATH ///// // Get the PATH values. // Return a list of strings ended by NULL. const char **get_path(const char **envp); #endif