00001
00002
00003
00004
00005
00006 #include <stdio.h>
00007 #include <syscall.h>
00008
00009 int
00010 main (int argc, char *argv[])
00011 {
00012 bool success = true;
00013 int i;
00014
00015 for (i = 1; i < argc; i++)
00016 {
00017 int fd = open (argv[i]);
00018 if (fd < 0)
00019 {
00020 printf ("%s: open failed\n", argv[i]);
00021 success = false;
00022 continue;
00023 }
00024 for (;;)
00025 {
00026 char buffer[1024];
00027 int bytes_read = read (fd, buffer, sizeof buffer);
00028 if (bytes_read == 0)
00029 break;
00030 write (STDOUT_FILENO, buffer, bytes_read);
00031 }
00032 close (fd);
00033 }
00034 return success ? EXIT_SUCCESS : EXIT_FAILURE;
00035 }