All moving on the shcat_c folder

This commit is contained in:
Raphaël 2024-04-13 17:08:08 +02:00
parent dffb6ea577
commit 20391637b6
19 changed files with 36 additions and 39 deletions

4
.clangd Normal file
View file

@ -0,0 +1,4 @@
CompileFlags: # Tweak the parse settings
Add:
- "-I/usr/include"

View file

@ -6,7 +6,7 @@
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */ /* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2024/03/28 14:41:15 by rparodi #+# #+# */ /* Created: 2024/03/28 14:41:15 by rparodi #+# #+# */
/* Updated: 2024/04/01 01:51:57 by rparodi ### ########.fr */ /* Updated: 2024/04/13 17:05:26 by rparodi ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -39,7 +39,7 @@ typedef struct s_utils
t_i32 main(t_i32 argc, t_str argv[], t_str arge[]); t_i32 main(t_i32 argc, t_str argv[], t_str arge[]);
void ft_other_cmd(t_utils *shcat, t_usize i); void ft_other_cmd(t_utils *shcat, t_usize i);
t_i32 ft_strcmp(const char *s1, const char *s2); t_i32 ft_strcmp(const char *s1, const char *s2);
t_i32 ft_check_type_operators(t_i8 **operators); t_i32 ft_check_type_operators(t_str operators);
t_str *ft_split(t_const_str s, t_i8 c); t_str *ft_split(t_const_str s, t_i8 c);
t_str ft_strdup(t_const_str s); t_str ft_strdup(t_const_str s);
void *ft_calloc(t_usize nmemb, t_usize size); void *ft_calloc(t_usize nmemb, t_usize size);

View file

@ -6,47 +6,40 @@
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */ /* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2024/03/28 14:40:38 by rparodi #+# #+# */ /* Created: 2024/03/28 14:40:38 by rparodi #+# #+# */
/* Updated: 2024/04/01 18:17:41 by rparodi ### ########.fr */ /* Updated: 2024/04/13 17:05:11 by rparodi ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
#include "../includes/minishell.h" #include "../includes/minishell.h"
t_i32 ft_check_type_operators(t_str *operators) t_i32 ft_check_type_operators(t_str operators)
{ {
t_usize i; if (ft_strcmp(operators, ">") == 0)
i = 0;
while (operators[i])
{
if (ft_strcmp(operators[i], ">") == 0)
printf("Have to redirect in the file\n"); printf("Have to redirect in the file\n");
else if (ft_strcmp(operators[i], ">>") == 0) else if (ft_strcmp(operators, ">>") == 0)
printf("Have to redirect at the end of the file after\n"); printf("Have to redirect at the end of the file after\n");
else if (ft_strcmp(operators[i], ">&") == 0) else if (ft_strcmp(operators, ">&") == 0)
printf("Have to redirect the stdout in the file\n"); printf("Have to redirect the stdout in the file\n");
else if (ft_strcmp(operators[i], "<") == 0) else if (ft_strcmp(operators, "<") == 0)
printf("Have to redirect at the end of the file before\n"); printf("Have to redirect at the end of the file before\n");
else if (ft_strcmp(operators[i], "<<") == 0) else if (ft_strcmp(operators, "<<") == 0)
printf("Have to redirect at the end of the file after\n"); printf("Have to redirect at the end of the file after\n");
else if (ft_strcmp(operators[i], "<&") == 0) else if (ft_strcmp(operators, "<&") == 0)
printf("Have to redirect the stdout in the file\n"); printf("Have to redirect the stdout in the file\n");
else if (ft_strcmp(operators[i], ";") == 0) else if (ft_strcmp(operators, ";") == 0)
printf("Have to execute one more command\n"); printf("Have to execute one more command\n");
else if (ft_strcmp(operators[i], ";") == 0) else if (ft_strcmp(operators, ";") == 0)
printf("Have to execute one more command\n"); printf("Have to execute one more command\n");
else if (ft_strcmp(operators[i], "|") == 0) else if (ft_strcmp(operators, "|") == 0)
printf("I have to pipe a operators !\n"); printf("I have to pipe a operators !\n");
else if (ft_strcmp(operators[i], "||") == 0) else if (ft_strcmp(operators, "||") == 0)
printf("Or something\n"); printf("Or something\n");
else if (ft_strcmp(operators[i], "&&") == 0) else if (ft_strcmp(operators, "&&") == 0)
printf("Only if the first has exit status 0\n"); printf("Only if the first has exit status 0\n");
else if (ft_strcmp(operators[i], "&") == 0) else if (ft_strcmp(operators, "&") == 0)
printf("Parreil mais chelou\n"); printf("Parreil mais chelou\n");
else else
return (0); return (0);
i++;
}
return (1); return (1);
} }
@ -57,7 +50,7 @@ void ft_check(t_utils *shcat, char **input)
i = 0; i = 0;
while (input[i] != NULL) while (input[i] != NULL)
{ {
if (ft_check_type_operators(input) == 1) if (ft_check_type_operators(input[i]) == 1)
printf("Operateur\n"); printf("Operateur\n");
else else
{ {
@ -65,7 +58,7 @@ void ft_check(t_utils *shcat, char **input)
ft_exit(shcat, 0); ft_exit(shcat, 0);
else if (ft_strcmp(input[i], "pwd") == 0) else if (ft_strcmp(input[i], "pwd") == 0)
ft_pwd(); ft_pwd();
else if (ft_strcmp(input[i], "cmd") == 0) else if (ft_strcmp(input[i], "echo") == 0)
ft_echo("ECHO MAIS PAS ARG BORDEL !\n", "flag"); ft_echo("ECHO MAIS PAS ARG BORDEL !\n", "flag");
else else
ft_other_cmd(shcat, i); ft_other_cmd(shcat, i);