add ask_command() and minishell_error()
This commit is contained in:
parent
fa1301d41f
commit
2da8cbabdd
5 changed files with 82 additions and 17 deletions
|
|
@ -6,7 +6,7 @@
|
|||
/* By: mcolonna <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/04/23 14:15:12 by mcolonna #+# #+# */
|
||||
/* Updated: 2024/04/23 14:54:39 by mcolonna ### ########.fr */
|
||||
/* Updated: 2024/04/23 16:01:17 by mcolonna ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -14,14 +14,27 @@
|
|||
# define INCLUDE_H
|
||||
|
||||
# include <stdbool.h>
|
||||
# include <stdio.h>
|
||||
# include <errno.h>
|
||||
# include <string.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
|
||||
{
|
||||
char *program; // path of the program to call.
|
||||
int argc; // number of arguments given (including the program's name)
|
||||
char **argv; // arguments given (including the program's name)
|
||||
} t_call;
|
||||
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
|
||||
|
|
@ -32,15 +45,19 @@ typedef struct s_command
|
|||
int output_fd; // fd to use with '>' redirection (1 by default)
|
||||
} t_command;
|
||||
|
||||
// Show the prompt and ask a command to the user.
|
||||
// Return the command.
|
||||
char *ask_command(void);
|
||||
|
||||
// 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(char *command);
|
||||
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);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue