1: # include <fcntl.h>
2: # include <sccs.h>
3: # include <useful.h>
4:
5: SCCSID(@(#)cat.c 8.3 2/8/85)
6:
7: /*
8: ** CAT -- "cat" a file
9: **
10: ** This function is essentially identical to the UNIX cat(I).
11: **
12: ** Parameters:
13: ** file -- the name of the file to be cat'ed
14: **
15: ** Returns:
16: ** zero -- success
17: ** else -- failure (could not open file)
18: **
19: ** Side Effects:
20: ** "file" is open and read once through; a copy is made
21: ** to the standard output.
22: */
23:
24: cat(file)
25: char *file;
26: {
27: char buf[BLOCK_SZ];
28: register int i;
29: register int fd;
30:
31: fd = open(file, O_RDONLY);
32: if (fd < 0)
33: return (1);
34:
35: while ((i = read(fd, buf, BLOCK_SZ)) > 0)
36: {
37: write(1, buf, i);
38: }
39:
40: return (0);
41: }
Defined functions
cat
defined in line
5;
never used