1 /* Copyright (c) 1985 Ceriel J.H. Jacobs */
4 static char rcsid
[] = "$Header$";
14 # include <sys/file.h>
17 # include <sys/types.h>
20 # include <sys/types.h>
21 # include <sys/stat.h>
23 # include "commands.h"
31 static int nfiles
; /* Number of filenames on command line */
34 * Visit a file, file name is "fn".
38 visitfile(fn
) char *fn
; {
43 * Close old input file
48 # if USG_OPEN || BSD4_2_OPEN || POSIX_OPEN
49 if ((stdf
= open(fn
,O_RDONLY
,0)) < 0) {
51 if ((stdf
= open(fn
,0)) < 0) {
53 error(": could not open");
56 else { /* Get size for percentage in prompt */
57 (VOID
) fstat(stdf
, &statbuf
);
58 maxpos
= statbuf
.st_size
;
65 * process the input files, one by one.
66 * If there is none, input is from a pipe.
70 processfiles(n
,argv
) char ** argv
; {
72 static char *dummies
[3];
79 currentfile
= "standard-input";
81 * Take care that *(filenames - 1) and *(filenames + 1) are 0
83 filenames
= &dummies
[1];
94 if (commands
[n
].c_flags
& NEEDS_SCREEN
) {
101 if (setjmp(SetJmpBuf
)) {
114 * Get the next file the user asks for.
121 if ((i
= filecount
+ n
) >= nfiles
|| i
< 0) {
125 visitfile(filenames
[i
]);