Initial commit
This commit is contained in:
commit
0e055dbfe1
|
@ -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.
|
|
@ -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;
|
||||||
|
}
|
Loading…
Reference in New Issue