Kernel/debug - Panic to VT for the first nested panic
[tpg/acess2.git] / Usermode / Applications / cat_src / main.c
1 /*
2  * Acess2 CAT command
3  */
4 #include <stdlib.h>
5 #include <stdio.h>
6
7 #define BUF_SIZE        1024
8
9 /**
10  * \fn int main(int argc, char *argv[])
11  * \brief Entrypoint
12  */
13 int main(int argc, char *argv[])
14 {
15          int    num;
16         char    buf[BUF_SIZE];
17
18         if(argc < 2) {
19                 printf("Usage: cat <file>\n");
20                 return -1;
21         }
22
23         FILE *fp = fopen(argv[1], "r");
24         if(!fp) {
25                 printf("Unable to open '%s' for reading\n", argv[1]);
26                 return -1;
27         }
28
29         do {
30                 num = fread(buf, BUF_SIZE, 1, fp);
31                 if(num < 0)     break;
32                 fwrite(buf, num, 1, stdout);
33         } while(num == BUF_SIZE);
34
35         fclose(fp);
36         printf("\n");
37
38         return 0;
39 }

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