basic functions to make
This commit is contained in:
parent
1a34e2f64b
commit
a0ad80a375
52 changed files with 2964 additions and 3 deletions
46
include/include.h
Normal file
46
include/include.h
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* include.h :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: mcolonna <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/04/23 14:15:12 by mcolonna #+# #+# */
|
||||
/* Updated: 2024/04/23 14:54:39 by mcolonna ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef INCLUDE_H
|
||||
# define INCLUDE_H
|
||||
|
||||
# include <stdbool.h>
|
||||
|
||||
// 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;
|
||||
|
||||
// Represents a command given by the user.
|
||||
typedef struct s_command
|
||||
{
|
||||
bool error; // true means an error occured in interpret_command().
|
||||
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;
|
||||
|
||||
// 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);
|
||||
|
||||
// Execute the command given. Return the exit status.
|
||||
int execute_command(t_command command);
|
||||
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue