k9core

Unnamed repository
Log | Files | Refs | LICENSE

commit 0e055dbfe12551d11b63e1d32a85d72c9b1bdcc6
Author: qorg11 <qorg@vxempire.xyz>
Date:   Mon,  1 Jun 2020 21:25:45 +0200

Initial commit

Diffstat:
ALICENSE | 12++++++++++++
Asrc/cat.c | 48++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 60 insertions(+), 0 deletions(-)

diff --git a/LICENSE b/LICENSE @@ -0,0 +1,12 @@ +VIRAL PUBLIC LICENSE +Copyleft (ɔ) All Rights Reversed + +This WORK is hereby relinquished of all associated ownership, attribution and copy +rights, and redistribution or use of any kind, with or without modification, is +permitted without restriction subject to the following conditions: + +1. Redistributions of this WORK, or ANY work that makes use of ANY of the + contents of this WORK by ANY kind of copying, dependency, linkage, or ANY + other possible form of DERIVATION or COMBINATION, must retain the ENTIRETY + of this license. +2. No further restrictions of ANY kind may be applied. diff --git a/src/cat.c b/src/cat.c @@ -0,0 +1,48 @@ +#include <stdio.h> +#include <unistd.h> +#include <fcntl.h> + +int +cat(int fd, char *string) +{ + char buf[256]; + long lines; + + while((lines=read(fd, buf, (long)sizeof(buf)))>0) + { + if(write(1,buf,lines)!=lines) + { + fprintf(stderr,"Error copying. %s",string); + return 1; + } + if (lines < 0) + { + fprintf(stderr,"Error reading %s",string); + return 1; + } + } + return 0; +} + +int +main(int argc, char *argv[]) +{ + int fd, i; + + if(argc == 1) + { + cat(0,"<stdin>"); + } + else for(i=1;i<argc; i++) + { + fd = open(argv[i],O_RDONLY); + if(fd<0) + fprintf(stderr,"Cannot open %s",argv[i]); + else + { + cat(fd,argv[i]); + close(fd); + } + } + return 0; +}