/*
 * cat:  do what you'd expect
 *
 * This code is in the public domain.
 */
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

void
cat(char* file)
{
    int fd;
    char bfr[5120];
    int siz;

    if (file ? ((fd = open(file, O_RDONLY)) != -1) : ((fd = 0), 1)) {
	while ((siz = read(fd, bfr, sizeof bfr)) > 0)
	    write(1,bfr,siz);
	close(fd);
    }
    else
	perror(file);
}


void
main(int argc, char ** argv)
{

    int x;

    if (argc <= 1)
	cat(0);
    for (x=1; x < argc; x++)
	cat(argv[x]);
}
