commit 6dad92f0fb8e6e46d524c40ae11afd85e7f2108a Author: z3bra <willyatmailoodotorg> Date: Sun Apr 24 19:09:24 2016 cat: initial commit Diffstat: cat.c | 27 +++++++++++++++++++++++++++ makefile | 3 +++ 2 files changed, 30 insertions(+), 0 deletions(-)
diff --git a/cat.c b/cat.c @@ -0,0 +1,27 @@ +#include <fcntl.h> +#include <limits.h> +#include <stdio.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <unistd.h> + +int +main(int argc, char **argv) +{ + int fd = 0; + size_t len = 0; + char buf[LINE_MAX]; + + while (*(++argv) != NULL) { + fd = open(*argv, O_RDONLY); + if (fd < 0) { + perror(*argv); + } else { + while ((len = read(fd, buf, LINE_MAX)) > 0) { + write(1, buf, len); + } + close(fd); + } + } + return 0; +} diff --git a/makefile b/makefile @@ -0,0 +1,3 @@ +you: +clean: + ls *.c | cut -d. -f1 | xargs rm -f