-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Jean-philippe Martel
committed
Feb 4, 2022
1 parent
4a2279d
commit e8d0e5a
Showing
8 changed files
with
36 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
/* By: jemartel <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2022/01/24 14:58:12 by jemartel #+# #+# */ | ||
/* Updated: 2022/02/03 14:43:04 by jemartel ### ########.fr */ | ||
/* Updated: 2022/02/04 17:51:19 by jemartel ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
|
@@ -26,7 +26,7 @@ int eval(t_jobs *jobs); | |
char *eval_line(char *str, char *output, int lon, int type); | ||
void eval_cmds(t_jobs *job); | ||
char *eval_noquote(char *str, int *append, int type); | ||
void pre_val_redir(t_jobs *jobs, t_dlist *lst); | ||
void pre_val_here(t_jobs *jobs, t_dlist *lst); | ||
char *quote_eval(char *str, int left, char *outcome, int type); | ||
int redir_poll(char *line, char *cmp); | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
/* By: jemartel <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2022/01/15 18:30:49 by jemartel #+# #+# */ | ||
/* Updated: 2022/02/03 16:51:38 by jemartel ### ########.fr */ | ||
/* Updated: 2022/02/04 18:01:41 by jemartel ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
|
@@ -17,7 +17,7 @@ | |
|
||
char *eval_docc(t_redir *temp); | ||
|
||
void squash_delete(t_jobs *job, t_redir *temp, t_dlist *lst, char *str) | ||
void squash_output(t_jobs *job, t_redir *temp, t_dlist *lst, char *str) | ||
{ | ||
int fd; | ||
|
||
|
@@ -45,7 +45,7 @@ void squash_delete(t_jobs *job, t_redir *temp, t_dlist *lst, char *str) | |
exit(130); | ||
} | ||
|
||
void docc_out(t_jobs *job, t_redir *temp, t_dlist *lst) | ||
void here_process(t_jobs *job, t_redir *temp, t_dlist *lst) | ||
{ | ||
int pid; | ||
int status; | ||
|
@@ -56,7 +56,7 @@ void docc_out(t_jobs *job, t_redir *temp, t_dlist *lst) | |
if (pid < 0) | ||
return ; | ||
if (pid == 0) | ||
squash_delete(job, temp, lst, str); | ||
squash_output(job, temp, lst, str); | ||
waitpid(pid, &status, 0); | ||
g_state.output = status; | ||
} | ||
|
@@ -87,7 +87,7 @@ char *eval_docc(t_redir *temp) | |
return (outcome); | ||
} | ||
|
||
void pre_val_redir(t_jobs *jobs, t_dlist *lst) | ||
void pre_val_here(t_jobs *jobs, t_dlist *lst) | ||
{ | ||
t_redir *temp; | ||
|
||
|
@@ -99,10 +99,10 @@ void pre_val_redir(t_jobs *jobs, t_dlist *lst) | |
while (temp) | ||
{ | ||
if (temp->type == 1 && jobs->status == 0) | ||
docc_out(jobs, temp, lst); | ||
here_process(jobs, temp, lst); | ||
temp = temp->next; | ||
} | ||
if (jobs && jobs->next) | ||
pre_val_redir(jobs->next, lst); | ||
pre_val_here(jobs->next, lst); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
/* By: jemartel <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2022/01/14 18:48:26 by jemartel #+# #+# */ | ||
/* Updated: 2022/02/02 23:53:42 by jemartel ### ########.fr */ | ||
/* Updated: 2022/02/04 17:29:13 by jemartel ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
|
@@ -38,6 +38,6 @@ int main(int argc, char **argv, char **envp) | |
{ | ||
fd = open("/tmp/here_docced", O_TRUNC | O_CREAT | O_RDWR, 0644); | ||
close(fd); | ||
parsing(); | ||
igntion_seq(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
/* By: olabrecq <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2022/01/15 02:46:42 by jemartel #+# #+# */ | ||
/* Updated: 2022/02/03 16:56:22 by jemartel ### ########.fr */ | ||
/* Updated: 2022/02/04 17:50:31 by jemartel ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
|
@@ -40,7 +40,7 @@ void handle_pipes(t_pipe *pipes, int status) | |
g_state.output = status; | ||
} | ||
|
||
void parser_muduled(t_jobs *job, t_dlist *lst) | ||
void async_jobs(t_jobs *job, t_dlist *lst) | ||
{ | ||
t_jobs *temp; | ||
t_pipe *pipes; | ||
|
@@ -62,7 +62,7 @@ void parser_muduled(t_jobs *job, t_dlist *lst) | |
free_jobs((t_jobs *)job, 0); | ||
} | ||
|
||
void parser_core(t_dlist *lst) | ||
void job_composer(t_dlist *lst) | ||
{ | ||
t_jobs *job; | ||
t_jobs *temp; | ||
|
@@ -74,14 +74,14 @@ void parser_core(t_dlist *lst) | |
inc = 0; | ||
if (job) | ||
{ | ||
pre_val_redir(job, lst); | ||
pre_val_here(job, lst); | ||
while (temp) | ||
{ | ||
eval(temp); | ||
temp = temp->next; | ||
inc++; | ||
} | ||
parser_muduled(job, lst); | ||
async_jobs(job, lst); | ||
} | ||
} | ||
|
||
|
@@ -93,17 +93,17 @@ void quick_parser(char *str) | |
|
||
if (trimed && ft_strlen(trimed) > 0) | ||
{ | ||
lst = line_parser((char *)trimed); | ||
lst = parser((char *)trimed); | ||
free((char *)trimed); | ||
if (lst != NULL) | ||
{ | ||
parser_core(lst); | ||
job_composer(lst); | ||
free_list(lst); | ||
} | ||
} | ||
} | ||
|
||
void parsing(void) | ||
void igntion_seq(void) | ||
{ | ||
char *trimed; | ||
t_dlist *lst; | ||
|
@@ -113,20 +113,19 @@ void parsing(void) | |
while (1) | ||
{ | ||
signal(SIGINT, sig_cc); | ||
if (parsing_start(&trimed) && ft_strlen(trimed) > 0) | ||
if (prompt(&trimed) && ft_strlen(trimed) > 0) | ||
{ | ||
signal(SIGINT, sig_chi); | ||
lst = line_parser(trimed); | ||
free(trimed); | ||
lst = parser(trimed); | ||
if (lst != NULL) | ||
parser_core(lst); | ||
job_composer(lst); | ||
} | ||
else if (!trimed) | ||
{ | ||
freelist(g_state.env); | ||
freelist(g_state.exprt); | ||
rl_clear_history(); | ||
free(trimed); | ||
rl_clear_history(); | ||
exit(g_state.output); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
/* By: jemartel <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2022/01/24 15:38:44 by jemartel #+# #+# */ | ||
/* Updated: 2022/02/02 14:03:19 by jemartel ### ########.fr */ | ||
/* Updated: 2022/02/04 17:47:53 by jemartel ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
|
@@ -25,14 +25,14 @@ typedef struct s_dlist | |
size_t len; | ||
} t_dlist; | ||
|
||
void parsing(void); | ||
void igntion_seq(void); | ||
void tokens_peek(t_dlist *lst); | ||
char *token_builder(char *str); | ||
char *find_single(char *str, size_t *len); | ||
char *find_dquoted(char *str, size_t *len); | ||
char *find_partner(char *str, size_t *len); | ||
char *line_no_string(char *str, size_t *len); | ||
char *line_handler(char *str, size_t *len); | ||
t_dlist *parser(char *str); | ||
char *token_loop(char *result, char *str, size_t len, size_t offset); | ||
int token_bool(char *str, size_t *len); | ||
int is_quoted(char *str); | ||
|
@@ -44,6 +44,6 @@ void sig_child(int signum, siginfo_t *info, void *unsed); | |
void sig_docc(int signum, siginfo_t *info, void *unsed); | ||
void start_signal(int type); | ||
char *prompt_eval(void); | ||
char *parsing_start(char **trimed); | ||
char *prompt(char **trimed); | ||
void sig_chi(int signum); | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
/* By: jemartel <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2022/01/24 16:08:47 by jemartel #+# #+# */ | ||
/* Updated: 2022/02/02 04:29:15 by jemartel ### ########.fr */ | ||
/* Updated: 2022/02/04 17:34:39 by jemartel ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
#include "../minishell.h" | ||
|
@@ -37,7 +37,7 @@ char *prompt_eval(void) | |
return (out); | ||
} | ||
|
||
char *parsing_start(char **trimed) | ||
char *prompt(char **trimed) | ||
{ | ||
char *line; | ||
char *prompt; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
/* By: olabrecq <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2022/01/15 16:51:53 by jemartel #+# #+# */ | ||
/* Updated: 2022/02/01 16:27:10 by jemartel ### ########.fr */ | ||
/* Updated: 2022/02/04 17:48:54 by jemartel ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
|
@@ -93,13 +93,14 @@ void tokens_lst(char *trimed, size_t total_len, t_dlist **token_lst) | |
} | ||
|
||
/* created a list of token from a string (wrapped function)*/ | ||
t_dlist *line_parser(char *trimed) | ||
t_dlist *parser(char *trimed) | ||
{ | ||
t_dlist *lst; | ||
|
||
lst = NULL; | ||
if (!trimed) | ||
return (NULL); | ||
tokens_lst(trimed, ft_strlen(trimed), &lst); | ||
free(trimed); | ||
return (lst); | ||
} |