From 23ad79e8b41c25bb4992d103d29a17612a52e351 Mon Sep 17 00:00:00 2001 From: Charles Date: Sun, 21 Jul 2019 15:26:32 +0200 Subject: c10 done, c11 on going, rush02 probably finished, bsq start --- c10/bonjour.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 c10/bonjour.c (limited to 'c10/bonjour.c') diff --git a/c10/bonjour.c b/c10/bonjour.c new file mode 100644 index 0000000..1b6f283 --- /dev/null +++ b/c10/bonjour.c @@ -0,0 +1,38 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* bonjour.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: cacharle +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/07/20 17:20:22 by cacharle #+# #+# */ +/* Updated: 2019/07/20 17:31:22 by cacharle ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "../includes/ft.h" + +int main(int argc, char **argv) +{ + int fd; + char buff[BUFF_SIZE + 1]; + int ret; + if (argc < 2) + write(2, "File name missing.\n", 19); + else if (argc > 2) + write(2, "Too many arguments.\n", 20); + else + { + fd = open(argv[1], O_RDONLY); + if (fd == -1) + { + write(2, "Cannot read file.\n", 18); + return (1); + } + while ((ret = read(fd, buff, BUFF_SIZE))) + write(1, buff, ret); + if (close(fd)) + return (1); + } + return (0); +} -- cgit