aboutsummaryrefslogtreecommitdiff
path: root/c10/bonjour.c
diff options
context:
space:
mode:
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);
+}