norm errors

This commit is contained in:
whaffman 2025-02-11 17:22:11 +01:00
parent fa04c4e265
commit 486a207834
11 changed files with 69 additions and 69 deletions

View File

@ -6,15 +6,15 @@
/* By: willem <willem@student.codam.nl> +#+ */ /* By: willem <willem@student.codam.nl> +#+ */
/* +#+ */ /* +#+ */
/* Created: 2025/02/08 17:06:07 by willem #+# #+# */ /* Created: 2025/02/08 17:06:07 by willem #+# #+# */
/* Updated: 2025/02/08 17:15:24 by willem ######## odam.nl */ /* Updated: 2025/02/11 17:06:54 by whaffman ######## odam.nl */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
#ifndef EXECUTER_H #ifndef EXECUTOR_H
# define EXECUTER_H # define EXECUTOR_H
# include "minishell.h" # include "minishell.h"
char *executor_absolute_path(t_list *env, char *cmd); char *executor_absolute_path(t_list *env, char *cmd);
#endif // EXECUTER_H #endif // EXECUTOR_H

View File

@ -1,19 +1,19 @@
/* ************************************************************************** */ /* ************************************************************************** */
/* */ /* */
/* ::: :::::::: */ /* :::::::: */
/* parser.h :+: :+: :+: */ /* parser.h :+: :+: */
/* +:+ +:+ +:+ */ /* +:+ */
/* By: qmennen <qmennen@student.codam.nl> +#+ +:+ +#+ */ /* By: qmennen <qmennen@student.codam.nl> +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+ */
/* Created: 2025/02/11 14:03:03 by qmennen #+# #+# */ /* Created: 2025/02/11 14:03:03 by qmennen #+# #+# */
/* Updated: 2025/02/11 16:25:16 by qmennen ### ########.fr */ /* Updated: 2025/02/11 17:19:01 by whaffman ######## odam.nl */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
#ifndef PARSER_H #ifndef PARSER_H
# define PARSER_H # define PARSER_H
#include "minishell.h" # include "minishell.h"
t_command *parser_command_new(char *cmd); t_command *parser_command_new(char *cmd);
char **parser_get_arguments(t_list *list); char **parser_get_arguments(t_list *list);

View File

@ -1,12 +1,12 @@
/* ************************************************************************** */ /* ************************************************************************** */
/* */ /* */
/* :::::::: */ /* :::::::: */
/* environment_add.c :+: :+: */ /* environment_add.c :+: :+: */
/* +:+ */ /* +:+ */
/* By: whaffman <whaffman@student.codam.nl> +#+ */ /* By: whaffman <whaffman@student.codam.nl> +#+ */
/* +#+ */ /* +#+ */
/* Created: 2025/02/04 16:13:33 by whaffman #+# #+# */ /* Created: 2025/02/04 16:13:33 by whaffman #+# #+# */
/* Updated: 2025/02/04 16:15:35 by whaffman ######## odam.nl */ /* Updated: 2025/02/11 17:15:45 by whaffman ######## odam.nl */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -25,7 +25,9 @@ void environment_add(t_list **environment, char *name, char *value)
new_environment->name = ft_strdup(name); new_environment->name = ft_strdup(name);
new_environment->value = ft_strdup(value); new_environment->value = ft_strdup(value);
new_node = ft_lstnew(new_environment); new_node = ft_lstnew(new_environment);
if (new_node == NULL || new_environment->name == NULL || new_environment->value == NULL) if (new_node == NULL
|| new_environment->name == NULL
|| new_environment->value == NULL)
{ {
free(new_environment->name); free(new_environment->name);
free(new_environment->value); free(new_environment->value);
@ -34,4 +36,4 @@ void environment_add(t_list **environment, char *name, char *value)
} }
ft_lstadd_back(environment, new_node); ft_lstadd_back(environment, new_node);
} }
} }

View File

@ -6,13 +6,13 @@
/* By: whaffman <whaffman@student.codam.nl> +#+ */ /* By: whaffman <whaffman@student.codam.nl> +#+ */
/* +#+ */ /* +#+ */
/* Created: 2025/02/11 14:17:53 by whaffman #+# #+# */ /* Created: 2025/02/11 14:17:53 by whaffman #+# #+# */
/* Updated: 2025/02/11 15:40:09 by whaffman ######## odam.nl */ /* Updated: 2025/02/11 17:20:26 by whaffman ######## odam.nl */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
#include "minishell.h" #include "minishell.h"
void environment_del(t_list **environment, char *name) void environment_del(t_list **environment, char *name)
{ {
t_list *prev; t_list *prev;
t_list *current; t_list *current;

View File

@ -1,12 +1,12 @@
/* ************************************************************************** */ /* ************************************************************************** */
/* */ /* */
/* :::::::: */ /* :::::::: */
/* environment_free_list.c :+: :+: */ /* environment_free_list.c :+: :+: */
/* +:+ */ /* +:+ */
/* By: whaffman <whaffman@student.codam.nl> +#+ */ /* By: whaffman <whaffman@student.codam.nl> +#+ */
/* +#+ */ /* +#+ */
/* Created: 2025/02/04 16:13:59 by whaffman #+# #+# */ /* Created: 2025/02/04 16:13:59 by whaffman #+# #+# */
/* Updated: 2025/02/04 16:14:04 by whaffman ######## odam.nl */ /* Updated: 2025/02/11 17:18:27 by whaffman ######## odam.nl */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View File

@ -1,12 +1,12 @@
/* ************************************************************************** */ /* ************************************************************************** */
/* */ /* */
/* :::::::: */ /* :::::::: */
/* environment_get.c :+: :+: */ /* environment_get.c :+: :+: */
/* +:+ */ /* +:+ */
/* By: whaffman <whaffman@student.codam.nl> +#+ */ /* By: whaffman <whaffman@student.codam.nl> +#+ */
/* +#+ */ /* +#+ */
/* Created: 2025/02/04 16:15:05 by whaffman #+# #+# */ /* Created: 2025/02/04 16:15:05 by whaffman #+# #+# */
/* Updated: 2025/02/04 16:15:10 by whaffman ######## odam.nl */ /* Updated: 2025/02/11 17:04:28 by whaffman ######## odam.nl */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -15,6 +15,7 @@
t_environment *environment_get(t_list *environment, char *name) t_environment *environment_get(t_list *environment, char *name)
{ {
t_environment *env; t_environment *env;
while (environment != NULL) while (environment != NULL)
{ {
env = (t_environment *)environment->content; env = (t_environment *)environment->content;

View File

@ -6,37 +6,35 @@
/* By: willem <willem@student.codam.nl> +#+ */ /* By: willem <willem@student.codam.nl> +#+ */
/* +#+ */ /* +#+ */
/* Created: 2025/02/08 13:59:48 by willem #+# #+# */ /* Created: 2025/02/08 13:59:48 by willem #+# #+# */
/* Updated: 2025/02/08 13:59:49 by willem ######## odam.nl */ /* Updated: 2025/02/11 17:18:15 by whaffman ######## odam.nl */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
# include "minishell.h" #include "minishell.h"
char **environment_get_arr(t_list *environment) char **environment_get_arr(t_list *environment)
{ {
char **arr; char **arr;
t_environment *env; t_environment *env;
int i; int i;
arr = malloc(sizeof(char *) * (ft_lstsize(environment) + 1)); arr = malloc(sizeof(char *) * (ft_lstsize(environment) + 1));
if (arr == NULL) if (arr == NULL)
return (NULL); return (NULL);
i = 0; i = 0;
while (environment != NULL) while (environment != NULL)
{ {
env = (t_environment *)environment->content; env = (t_environment *)environment->content;
arr[i] = malloc(ft_strlen(env->name) + ft_strlen(env->value) + 2); arr[i] = malloc(ft_strlen(env->name) + ft_strlen(env->value) + 2);
if (arr[i] == NULL) if (arr[i] == NULL)
{ return (ft_free_arr(arr), NULL);
ft_free_arr(arr); ft_strlcpy(arr[i], env->name, ft_strlen(env->name) + 1);
return (NULL); ft_strlcat(arr[i], "=", ft_strlen(env->name) + 2);
} ft_strlcat(arr[i], env->value,
ft_strlcpy(arr[i], env->name, ft_strlen(env->name) + 1); ft_strlen(env->name) + ft_strlen(env->value) + 2);
ft_strlcat(arr[i], "=", ft_strlen(env->name) + 2); environment = environment->next;
ft_strlcat(arr[i], env->value, ft_strlen(env->name) + ft_strlen(env->value) + 2); i++;
environment = environment->next; }
i++; arr[i] = NULL;
} return (arr);
arr[i] = NULL;
return (arr);
} }

View File

@ -1,12 +1,12 @@
/* ************************************************************************** */ /* ************************************************************************** */
/* */ /* */
/* :::::::: */ /* :::::::: */
/* environment_parse.c :+: :+: */ /* environment_parse.c :+: :+: */
/* +:+ */ /* +:+ */
/* By: whaffman <whaffman@student.codam.nl> +#+ */ /* By: whaffman <whaffman@student.codam.nl> +#+ */
/* +#+ */ /* +#+ */
/* Created: 2025/02/05 15:52:33 by whaffman #+# #+# */ /* Created: 2025/02/05 15:52:33 by whaffman #+# #+# */
/* Updated: 2025/02/05 15:52:34 by whaffman ######## odam.nl */ /* Updated: 2025/02/11 17:18:43 by whaffman ######## odam.nl */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View File

@ -6,7 +6,7 @@
/* By: willem <willem@student.codam.nl> +#+ */ /* By: willem <willem@student.codam.nl> +#+ */
/* +#+ */ /* +#+ */
/* Created: 2025/02/08 13:52:08 by willem #+# #+# */ /* Created: 2025/02/08 13:52:08 by willem #+# #+# */
/* Updated: 2025/02/08 14:24:20 by willem ######## odam.nl */ /* Updated: 2025/02/11 17:05:10 by whaffman ######## odam.nl */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -14,8 +14,8 @@
void environment_print(t_list *environment) void environment_print(t_list *environment)
{ {
char **arr; char **arr;
int i; int i;
arr = environment_get_arr(environment); arr = environment_get_arr(environment);
if (arr == NULL) if (arr == NULL)
@ -30,4 +30,4 @@ void environment_print(t_list *environment)
i++; i++;
} }
ft_free_arr(arr); ft_free_arr(arr);
} }

View File

@ -6,18 +6,18 @@
/* By: willem <willem@student.codam.nl> +#+ */ /* By: willem <willem@student.codam.nl> +#+ */
/* +#+ */ /* +#+ */
/* Created: 2025/02/08 17:00:24 by willem #+# #+# */ /* Created: 2025/02/08 17:00:24 by willem #+# #+# */
/* Updated: 2025/02/11 16:45:17 by whaffman ######## odam.nl */ /* Updated: 2025/02/11 17:20:17 by whaffman ######## odam.nl */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
#include "minishell.h" #include "minishell.h"
char *executor_absolute_path(t_list *env, char *cmd) char *executor_absolute_path(t_list *env, char *cmd)
{ {
char **path; char **path;
t_environment *path_env; t_environment *path_env;
char *executable; char *executable;
int i; int i;
if (cmd[0] == '/' || cmd[0] == '.') if (cmd[0] == '/' || cmd[0] == '.')
{ {

View File

@ -6,17 +6,17 @@
/* By: whaffman <whaffman@student.codam.nl> +#+ */ /* By: whaffman <whaffman@student.codam.nl> +#+ */
/* +#+ */ /* +#+ */
/* Created: 2025/02/05 16:21:39 by whaffman #+# #+# */ /* Created: 2025/02/05 16:21:39 by whaffman #+# #+# */
/* Updated: 2025/02/11 14:30:38 by whaffman ######## odam.nl */ /* Updated: 2025/02/11 17:11:16 by whaffman ######## odam.nl */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
#include "minishell.h" #include "minishell.h"
void builtin_export(t_minishell *minishell) void builtin_export(t_minishell *minishell)
{ {
t_list *tmp; t_list *tmp;
t_environment *env; t_environment *env;
char **arr; char **arr;
tmp = minishell->tokens->next; tmp = minishell->tokens->next;
while (tmp != NULL) while (tmp != NULL)
@ -41,7 +41,6 @@ void builtin_export(t_minishell *minishell)
} }
} }
static int cmp_value(t_list *list, char *str) static int cmp_value(t_list *list, char *str)
{ {
if (list != NULL if (list != NULL
@ -53,7 +52,7 @@ static int cmp_value(t_list *list, char *str)
return (FALSE); return (FALSE);
} }
void fork_execve(t_minishell *minishell, char *path, char **argv) void fork_execve(t_minishell *minishell, char *path, char **argv)
{ {
pid_t pid; pid_t pid;
int status; int status;
@ -83,6 +82,7 @@ void fork_execve(t_minishell *minishell, char *path, char **argv)
void simple_builtins(t_minishell *minishell) void simple_builtins(t_minishell *minishell)
{ {
char *path; char *path;
if (!minishell->tokens) if (!minishell->tokens)
return ; return ;
if (cmp_value(minishell->tokens, "clear")) if (cmp_value(minishell->tokens, "clear"))
@ -109,5 +109,4 @@ void simple_builtins(t_minishell *minishell)
fork_execve(minishell, path, ft_split(((t_token *)minishell->tokens->content)->value, ' ')); fork_execve(minishell, path, ft_split(((t_token *)minishell->tokens->content)->value, ' '));
} }
} }
} }