Merge exec_command and parse_command modifications
This commit is contained in:
commit
2ce36c258e
12 changed files with 358 additions and 119 deletions
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jschaft <cecile.schaft@orange.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/04/23 14:15:12 by mcolonna #+# #+# */
|
||||
/* Updated: 2024/05/16 17:34:49 by mcolonna ### ########.fr */
|
||||
/* Updated: 2024/05/16 18:18:16 by mcolonna ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -23,6 +23,7 @@
|
|||
# include <fcntl.h>
|
||||
# include <stdlib.h>
|
||||
# include <strings.h>
|
||||
# include <sys/wait.h>
|
||||
# include "libft.h"
|
||||
# include "libtf.h"
|
||||
|
||||
|
|
@ -46,7 +47,8 @@ typedef struct s_call
|
|||
// Represents a command given by the user.
|
||||
typedef struct s_command
|
||||
{
|
||||
bool error; // true if an error occured in interpret_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)
|
||||
|
|
@ -71,21 +73,29 @@ int execute_command(t_memclass mc, t_command command,
|
|||
///// ERROR /////
|
||||
|
||||
// Call to show an error.
|
||||
// If msg == "errno", use strerror(errno)
|
||||
// If msg == "errno", use perror()
|
||||
void minishell_error(const char *msg);
|
||||
|
||||
// Call to write the error and exit the program.
|
||||
// Call perror() and exit the program.
|
||||
void fatal_error(const char *msg);
|
||||
|
||||
// Call strerror() and exit the program.
|
||||
void fatal_error_msg(const char *msg);
|
||||
|
||||
///// PATH /////
|
||||
|
||||
// Get the PATH values.
|
||||
// Return a list of strings ended by NULL.
|
||||
char **get_path(char *const envp[]);
|
||||
const char **get_path(const t_memclass mc, char *const envp[]);
|
||||
|
||||
// Search the program in PATH.
|
||||
// Search the program in $PATH.
|
||||
// Returns the path of the program to use, or NULL if there is none.
|
||||
// If there is several possibilities, it returns the one from the first path
|
||||
// given in $PATH.
|
||||
const char *search_path(
|
||||
const t_memclass mc, const char **path, const char *prog);
|
||||
|
||||
///// MAIN /////
|
||||
extern t_memclass g_mc;
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue