aboutsummaryrefslogtreecommitdiff
path: root/c10/bonjour.c
diff options
context:
space:
mode:
authorCharles <sircharlesaze@gmail.com>2019-07-21 15:26:32 +0200
committerCharles <sircharlesaze@gmail.com>2019-07-21 15:26:32 +0200
commit23ad79e8b41c25bb4992d103d29a17612a52e351 (patch)
tree9de3cde07cc38e59f08885171e9f99eeab8ab71b /c10/bonjour.c
parent8b6e91bdb56bc01a588718472546f2a88e750b48 (diff)
downloadpiscine-23ad79e8b41c25bb4992d103d29a17612a52e351.tar.gz
piscine-23ad79e8b41c25bb4992d103d29a17612a52e351.tar.bz2
piscine-23ad79e8b41c25bb4992d103d29a17612a52e351.zip
c10 done, c11 on going, rush02 probably finished, bsq start
Diffstat (limited to 'c10/bonjour.c')
-rw-r--r--c10/bonjour.c38
1 files changed, 38 insertions, 0 deletions
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 <charles.cabergs@gmail.com> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* 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);
+}