From 507661351ca718c8a3d8213a0a80f994825fc881 Mon Sep 17 00:00:00 2001 From: Rudy Bousset Date: Tue, 29 Oct 2019 12:25:57 +0100 Subject: libft included --- src/ft_echo.c | 5 +++++ src/main.c | 32 ++++++++++++++++++++++++++++---- 2 files changed, 33 insertions(+), 4 deletions(-) create mode 100644 src/ft_echo.c (limited to 'src') diff --git a/src/ft_echo.c b/src/ft_echo.c new file mode 100644 index 0000000..a7e6303 --- /dev/null +++ b/src/ft_echo.c @@ -0,0 +1,5 @@ +#include +void +ft_echo(const char *arg) +{ +} diff --git a/src/main.c b/src/main.c index afc38aa..a841322 100644 --- a/src/main.c +++ b/src/main.c @@ -11,16 +11,40 @@ /* / */ /* ************************************************************************** */ +#include +#include +#include #include +#include int - main(int argc, char *argv[]) + main(void) { char c; - (void)argc; - (void)argv; - while (read(1, &c, 1) > 0) + char *arg; + uint8_t i; + + i = 0; + while (1) { + if (!(arg = (char*)ft_calloc(129, sizeof(char)))) + return (1); + write(1, "joe-shell~> ", 12); + i = 0; + while (read(1, &c, 1) > 0) + { + if (c == '\n') + break ; + if (i > 128) + { + write(1, "Command too long!\n", 18); + return (2); + } + arg[i] = c; + i++; + } + arg[i] = '\0'; } + free(arg); return (0); } -- cgit v1.2.3