mirror of
https://github.com/KeyZox71/ft_minipowershell.git
synced 2025-03-15 03:16:51 +01:00
「🔨」 fix: fixed some things.
This commit is contained in:
@ -6,7 +6,11 @@
|
||||
/* By: mmoussou <mmoussou@student.42angouleme.fr +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/04/26 09:38:51 by mmoussou #+# #+# */
|
||||
<<<<<<< HEAD
|
||||
/* Updated: 2024/05/06 20:30:42 by mmoussou ### ########.fr */
|
||||
=======
|
||||
/* Updated: 2024/05/03 10:24:15 by adjoly ### ########.fr */
|
||||
>>>>>>> e1ba625 (「🏗️」 wip: testing things, might broke.)
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -26,5 +30,6 @@ char set_env(char **env, const char *name, char *content);
|
||||
char *get_hostname(void);
|
||||
char *get_prompt(void);
|
||||
char *get_pwd(void);
|
||||
bool is_str(char *src, char *dst);
|
||||
|
||||
#endif
|
||||
|
35
include/minishell.h.orig
Normal file
35
include/minishell.h.orig
Normal file
@ -0,0 +1,35 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* minishell.h :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: mmoussou <mmoussou@student.42angouleme.fr +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/04/26 09:38:51 by mmoussou #+# #+# */
|
||||
<<<<<<< HEAD
|
||||
/* Updated: 2024/05/06 20:30:42 by mmoussou ### ########.fr */
|
||||
=======
|
||||
/* Updated: 2024/05/03 10:24:15 by adjoly ### ########.fr */
|
||||
>>>>>>> e1ba625 (「🏗️」 wip: testing things, might broke.)
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef MINISHELL_H
|
||||
# define MINISHELL_H
|
||||
|
||||
# include <readline/readline.h>
|
||||
# include <stdio.h>
|
||||
# include <stdlib.h>
|
||||
# include <stdint.h>
|
||||
# include "libft.h"
|
||||
|
||||
# include "parsing.h"
|
||||
# include "execution.h"
|
||||
|
||||
char set_env(char **env, const char *name, char *content);
|
||||
char *get_hostname(void);
|
||||
char *get_prompt(void);
|
||||
char *get_pwd(void);
|
||||
bool is_str(char *src, char *dst);
|
||||
|
||||
#endif
|
@ -6,7 +6,7 @@
|
||||
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/04/25 12:20:26 by adjoly #+# #+# */
|
||||
/* Updated: 2024/04/25 14:30:50 by adjoly ### ########.fr */
|
||||
/* Updated: 2024/05/04 13:54:02 by adjoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -19,4 +19,11 @@ typedef struct s_cmd
|
||||
char **argv;
|
||||
} t_cmd;
|
||||
|
||||
typedef struct s_parsing
|
||||
{
|
||||
|
||||
} t_parsing;
|
||||
|
||||
t_cmd split_cmd(char *cmd_av);
|
||||
|
||||
#endif
|
||||
|
25
src/is_str.c
Normal file
25
src/is_str.c
Normal file
@ -0,0 +1,25 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* is_str.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/03 10:23:40 by adjoly #+# #+# */
|
||||
/* Updated: 2024/05/03 10:23:55 by adjoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
bool is_str(char *src, char *dst)
|
||||
{
|
||||
while (*src && *dst && *src == *dst)
|
||||
{
|
||||
src++;
|
||||
dst++;
|
||||
}
|
||||
if (*dst)
|
||||
return (false);
|
||||
return (true);
|
||||
}
|
22
src/main.c
22
src/main.c
@ -6,28 +6,25 @@
|
||||
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/04/24 11:18:04 by adjoly #+# #+# */
|
||||
/* Updated: 2024/05/02 15:53:21 by adjoly ### ########.fr */
|
||||
/* Updated: 2024/05/04 15:33:54 by adjoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include <readline/readline.h>
|
||||
#include <readline/history.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include <fcntl.h>
|
||||
#include "minishell.h"
|
||||
|
||||
bool is_str(char *src, char *dst)
|
||||
void print_cmd(t_cmd cmd)
|
||||
{
|
||||
while (*src && *dst && *src == *dst)
|
||||
ft_putendl_fd(cmd.cmd, 1);
|
||||
while (*(cmd.argv))
|
||||
{
|
||||
src++;
|
||||
dst++;
|
||||
ft_putendl_fd(*(cmd.argv), 1);
|
||||
(cmd.argv)++;
|
||||
}
|
||||
if (*dst)
|
||||
return (false);
|
||||
return (true);
|
||||
}
|
||||
|
||||
int main(int ac, char **av, char **env)
|
||||
@ -35,6 +32,7 @@ int main(int ac, char **av, char **env)
|
||||
char *test;
|
||||
char **lll;
|
||||
char *prompt;
|
||||
t_cmd *cmd;
|
||||
|
||||
(void)ac;
|
||||
(void)av;
|
||||
@ -50,7 +48,11 @@ int main(int ac, char **av, char **env)
|
||||
continue;
|
||||
if (is_str(test, "exit"))
|
||||
break;
|
||||
cmd = ft_calloc(sizeof(t_cmd), 1);
|
||||
*cmd = split_cmd(test);
|
||||
print_cmd(*cmd);
|
||||
ft_free("a", &lll);
|
||||
}
|
||||
//ft_free("a", &lll);
|
||||
ft_free("a", &lll);
|
||||
return (0);
|
||||
}
|
||||
|
27
src/parsing/split_cmd.c
Normal file
27
src/parsing/split_cmd.c
Normal file
@ -0,0 +1,27 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* split_cmd.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/04 15:00:32 by adjoly #+# #+# */
|
||||
/* Updated: 2024/05/04 15:20:29 by adjoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "parsing.h"
|
||||
#include "libft.h"
|
||||
|
||||
t_cmd split_cmd(char *cmd_av)
|
||||
{
|
||||
char **split;
|
||||
char **tmp_split;
|
||||
t_cmd cmd;
|
||||
|
||||
split = ft_split(cmd_av, 32);
|
||||
tmp_split = split;
|
||||
cmd.cmd = ft_strdup(*tmp_split);
|
||||
cmd.argv = tmp_split;
|
||||
return (cmd);
|
||||
}
|
@ -6,7 +6,7 @@
|
||||
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/02 10:36:31 by adjoly #+# #+# */
|
||||
/* Updated: 2024/05/02 13:42:24 by adjoly ### ########.fr */
|
||||
/* Updated: 2024/05/03 10:32:07 by adjoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -29,7 +29,7 @@ char *get_hostname(void)
|
||||
free(buf);
|
||||
return (buf);
|
||||
}
|
||||
hostname = ft_calloc(delimiter - buf, sizeof(char));
|
||||
hostname = ft_calloc(delimiter - buf + 1, sizeof(char));
|
||||
ft_strlcpy(hostname, buf, delimiter - buf + 1);
|
||||
free(buf);
|
||||
return (hostname);
|
||||
|
Reference in New Issue
Block a user