|
|
1.1 root 1: #include <stdio.h>
2: #define BUFSIZE (20*512)
3:
4: char buf[BUFSIZE];
5:
6: void
7: fatal(s)
8: char *s;
9: {
10: fprintf(stderr, "%s\n", s);
11: exit(1);
12: }
13:
14: main(argc, argv)
15: int argc; char *argv[];
16: {
17: register int ifd, ofd;
18: register unsigned int n;
19:
20: if (argc != 3)
21: fatal("Usage: open source destination");
22: if ((ifd = open(argv[1], 0)) == -1)
23: fatal("cannot open input file");
24: if ((ofd = creat(argv[2], 0)) == -1)
25: fatal("cannot open output file");
26:
27: while ((n = read(ifd, buf, BUFSIZE)) != 0) {
28: if (n == -1)
29: fatal("read error");
30: if (write(ofd, buf, n) != n)
31: fatal("write error");
32: }
33:
34: if (close(ifd) == -1 || close(ofd) == -1)
35: fatal("cannot close");
36: exit(0);
37: }
38:
39:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.