Cut down on debug, fixed tabs, made process tree be killed when root is killed
[tpg/acess2.git] / Usermode / Applications / cat_src / main.c
1 /*
2  * Acess2 CAT command
3  */
4 #include <acess/sys.h>
5 #include <stdlib.h>
6 #include <stdio.h>
7
8 #define BUF_SIZE        1024
9
10 /**
11  * \fn int main(int argc, char *argv[])
12  * \brief Entrypoint
13  */
14 int main(int argc, char *argv[])
15 {
16          int    fd;
17          int    num;
18         char    buf[BUF_SIZE+1];
19
20         if(argc < 2) {
21                 printf("Usage: cat <file>\n");
22                 return -1;
23         }
24
25         fd = open(argv[1], OPENFLAG_READ);
26         if(fd == -1) {
27                 printf("Unable to open '%s' for reading\n", argv[1]);
28                 return -1;
29         }
30
31         do {
32                 num = read(fd, BUF_SIZE, buf);
33                 buf[num] = '\0';
34                 printf("%s", buf);
35         } while(num == BUF_SIZE);
36
37         close(fd);
38         printf("\n");
39
40         return 0;
41 }

UCC git Repository :: git.ucc.asn.au