#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
-#include <sys/stat.h>
#include "splice.h"
int main(int argc, char *argv[])
{
- struct stat sb;
int fd, index;
- if (fstat(STDIN_FILENO, &sb) < 0)
- return error("stat");
- if (!S_ISFIFO(sb.st_mode)) {
- fprintf(stderr, "stdin must be a pipe\n");
+ if (check_input_pipe())
return usage(argv[0]);
- }
index = parse_options(argc, argv);
if (index == -1 || index + 1 > argc)
return usage(argv[0]);
- fd = open(argv[1], O_WRONLY | O_CREAT | O_TRUNC, 0644);
+ fd = open(argv[index], O_WRONLY | O_CREAT | O_TRUNC, 0644);
if (fd < 0)
return error("open");