2 * Copy the files given as arguments to the standard output. The file
3 * name "-" refers to the standard input.
5 * Copyright (C) 1989 by Kenneth Almquist. All rights reserved.
6 * This file is part of ash, which is distributed under the terms specified
7 * by the Ash General Public License. See the file named LICENSE.
14 #include <sys/param.h>
19 #define BUFSIZE() SBUFSIZE
22 #define BUFSIZE() MAXBSIZE
24 #define BUFSIZE() BSIZE
29 main(argc
, argv
) char **argv
; {
31 char *buf
= stalloc(BUFSIZE());
37 struct jmploc
*volatile savehandler
;
43 if (setjmp(jmploc
.loc
)) {
45 handler
= savehandler
;
48 savehandler
= handler
;
51 while ((filename
= *++argv
) != NULL
) {
52 if (filename
[0] == '-' && filename
[1] == '\0') {
57 if ((fd
= open(filename
, O_RDONLY
)) < 0)
58 error("Can't open %s", filename
);
62 if ((fd
= open(filename
, O_RDONLY
)) < 0) {
63 fprintf(stderr
, "catf: Can't open %s\n", filename
);
68 while ((i
= read(fd
, buf
, BUFSIZE())) > 0) {
70 if (out1
== &memout
) {
72 for (p
= buf
; --i
>= 0 ; p
++) {
86 handler
= savehandler
;