Minishell
 
Loading...
Searching...
No Matches
minishell.h
Go to the documentation of this file.
1/* ************************************************************************** */
2/* */
3/* ::: :::::::: */
4/* minishell.h :+: :+: :+: */
5/* +:+ +:+ +:+ */
6/* By: ppontet <ppontet@student.42lyon.fr> +#+ +:+ +#+ */
7/* +#+#+#+#+#+ +#+ */
8/* Created: 2025/03/18 17:09:50 by ppontet #+# #+# */
9/* Updated: 2025/05/30 10:55:55 by ppontet ### ########lyon.fr */
10/* */
11/* ************************************************************************** */
12
13#ifndef MINISHELL_H
14# define MINISHELL_H
15
24# ifndef PROMPT_MESSAGE_CUSTOM
25# define PROMPT_MESSAGE_CUSTOM 1
26# endif
27
32# ifndef FOLLOW_ZSH
33# define FOLLOW_ZSH 1
34# endif
35
36# include "data_structure.h"
37# include "libft.h"
38# include <stddef.h>
39# include <stdio.h>
40# include <stdlib.h>
41# include <unistd.h>
42# include <wait.h>
43
49int minishell(t_data *data);
50int is_interactive(void);
52char *get_prompt_message(t_garbage *garbage);
54
60int signal_init(void);
61void reset_signal_default(void);
62void ignore_signal(void);
64
70char **init_lexer_state(t_garbage *garbage, t_lexer_state *lex_st,
71 const char *line);
72char **lexer(t_garbage *garbage, const char *line);
73t_command *tokeniser(t_data *data, char **tokens);
74char *ft_substr_end_gb(t_garbage *garbage, char const *src,
75 unsigned int start, size_t end);
76int is_operator_char(char c);
78
84char **parse_line(t_data *data, char *line);
86
92void free_array(t_garbage *garbage, char **array);
93void free_command(t_garbage *garbage, t_command *command);
94void free_commands(t_garbage *garbage, t_command **command);
95void free_files_struct(t_garbage *garbage, t_file *file);
96void free_heredoc(t_garbage *garbage, t_tmp *tmp);
97void free_tokens(t_garbage *garbage, t_token *token);
99
105void print_list_files(t_command *command);
106void print_perm_files(t_command *command);
107void print_toks(char **tokens);
109ssize_t print_command(t_command *command);
110ssize_t print_commands(t_command **command);
112
113#endif
struct s_data t_data
Definition data_structure.h:38
struct s_command t_command
Definition data_structure.h:35
struct s_garbage t_garbage
Definition data_structure.h:26
struct s_tmp t_tmp
Definition data_structure.h:21
struct s_file t_file
Definition data_structure.h:22
struct s_token t_token
Definition data_structure.h:37
struct s_lexer_state t_lexer_state
Definition data_structure.h:33
int minishell(t_data *data)
Minishell that handles all the shell functions.
Definition minishell.c:93
char * get_prompt_message(t_garbage *garbage)
Build the prompt message If an error occurs, returns the static default prompt message.
Definition prompt.c:133
int short_minishell_no_tty(t_data *data)
Executes the shell in a restricted area where there is no prompt Should work exactly as the minishell...
Definition read_context.c:43
int is_interactive(void)
Function to read the context where this function is called Verify if it's used in a tty or not,...
Definition read_context.c:30
void print_perm_files(t_command *command)
Print the list of permissions of files in the command structure.
Definition file_print.c:55
ssize_t print_command(t_command *command)
Print the command structure with it's tokens.
Definition command-utils.c:23
void print_command_fd(t_command *command)
void print_list_files(t_command *command)
Print the list of files in the command structure.
Definition file_print.c:25
void print_toks(char **tokens)
Print tokens indexed.
Definition token-utils.c:60
ssize_t print_commands(t_command **command)
Print the commands structure with it's tokens.
Definition command-utils.c:47
char ** lexer(t_garbage *garbage, const char *line)
Create tokens (small chunks) a line with the quotes and operators.
Definition lexer.c:33
char * ft_substr_end_gb(t_garbage *garbage, char const *src, unsigned int start, size_t end)
Allocate memory for a string and copy the content from src.
Definition lexer-utils.c:64
char ** init_lexer_state(t_garbage *garbage, t_lexer_state *lex_st, const char *line)
Initialize the lexer structure.
Definition lexer-utils.c:32
int is_operator_char(char c)
Is |, < or >
Definition lexer-utils.c:50
t_command * tokeniser(t_data *data, char **tokens)
Creates a t_command structure that contains all the tokens Fills the command with the environment.
Definition tokens.c:34
void free_heredoc(t_garbage *garbage, t_tmp *tmp)
Free heredoc structure.
Definition ft_free.c:124
void free_command(t_garbage *garbage, t_command *command)
Free one t_command structure with all that it contains.
Definition ft_free.c:23
void free_tokens(t_garbage *garbage, t_token *token)
Free t_tokens linked list structure.
Definition ft_free.c:66
void free_files_struct(t_garbage *garbage, t_file *file)
Free linked list of t_file structure.
Definition ft_free.c:95
void free_commands(t_garbage *garbage, t_command **command)
Free t_command linked list structure with all that it contains.
Definition ft_free.c:45
void free_array(t_garbage *garbage, char **array)
Free array of strings.
Definition ft_free-utils.c:23
char ** parse_line(t_data *data, char *line)
Prototype for parsing.
Definition parsing.c:25
int signal_init(void)
Main function for initialising signals.
Definition signals.c:30
void ignore_signal(void)
Function to ignore certain signals.
Definition signals.c:89
void reset_signal_default(void)
Function to reset signals to default.
Definition signals.c:74