diff options
author | Rudy Bousset <rbousset@z2r5p6.le-101.fr> | 2019-10-29 12:25:57 +0100 |
---|---|---|
committer | Rudy Bousset <rbousset@z2r5p6.le-101.fr> | 2019-10-29 12:25:57 +0100 |
commit | 507661351ca718c8a3d8213a0a80f994825fc881 (patch) | |
tree | eb9192a57e884e5bcf96f79d98cf7659924ce1df /src/main.c | |
parent | Makefile complete (diff) | |
download | 42-minishell-507661351ca718c8a3d8213a0a80f994825fc881.tar.gz 42-minishell-507661351ca718c8a3d8213a0a80f994825fc881.tar.bz2 42-minishell-507661351ca718c8a3d8213a0a80f994825fc881.tar.xz 42-minishell-507661351ca718c8a3d8213a0a80f994825fc881.tar.zst 42-minishell-507661351ca718c8a3d8213a0a80f994825fc881.zip |
libft included
Diffstat (limited to 'src/main.c')
-rw-r--r-- | src/main.c | 32 |
1 files changed, 28 insertions, 4 deletions
@@ -11,16 +11,40 @@ /* / */ /* ************************************************************************** */ +#include <libft.h> +#include <stdlib.h> +#include <stddef.h> #include <unistd.h> +#include <inttypes.h> 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); } |