File:  [CSRG BSD Unix] / 43BSD / ingres / source / gutil / cat.c
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Tue Apr 24 16:12:55 2018 UTC (8 years, 1 month ago) by root
Branches: MAIN, BSD
CVS tags: HEAD, BSD43
BSD 4.3

# include	<fcntl.h>
# include	<sccs.h>
# include	<useful.h>

SCCSID(@(#)cat.c	8.3	2/8/85)

/*
**  CAT -- "cat" a file
**
**	This function is essentially identical to the UNIX cat(I).
**
**	Parameters:
**		file -- the name of the file to be cat'ed
**
**	Returns:
**		zero -- success
**		else -- failure (could not open file)
**
**	Side Effects:
**		"file" is open and read once through; a copy is made
**			to the standard output.
*/

cat(file)
char	*file;
{
	char		buf[BLOCK_SZ];
	register int	i;
	register int	fd;

	fd = open(file, O_RDONLY);
	if (fd < 0)
		return (1);

	while ((i = read(fd, buf, BLOCK_SZ)) > 0)
	{
		write(1, buf, i);
	}

	return (0);
}

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.