Initial commit

This commit is contained in:
qorg11 2020-06-01 21:25:45 +02:00
commit 0e055dbfe1
Signed by: qorg11
GPG Key ID: 343FC20A4ACA62B9
2 changed files with 60 additions and 0 deletions

12
LICENSE Normal file
View File

@ -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.

48
src/cat.c Normal file
View File

@ -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;
}