|
|
1.1 root 1: # include <sccs.h>
2:
3: SCCSID(@(#)cat.c 7.1 2/5/81)
4:
5: /*
6: ** CAT -- "cat" a file
7: **
8: ** This function is essentially identical to the UNIX cat(I).
9: **
10: ** Parameters:
11: ** file -- the name of the file to be cat'ed
12: **
13: ** Returns:
14: ** zero -- success
15: ** else -- failure (could not open file)
16: **
17: ** Side Effects:
18: ** "file" is open and read once through; a copy is made
19: ** to the standard output.
20: */
21:
22: cat(file)
23: char *file;
24: {
25: char buf[512];
26: register int i;
27: register int fd;
28:
29: fd = open(file, 0);
30: if (fd < 0)
31: return (1);
32:
33: while ((i = read(fd, buf, 512)) > 0)
34: {
35: write(1, buf, i);
36: }
37:
38: return (0);
39: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.