[ROSAPPS]
[reactos.git] / rosapps / applications / sysutils / tcat / cat.c
1 /*
2 * FILE : cat.c
3 * NATIVE NAME: tcat "tappak's cat" :)
4 * AUTHOR : Semyon Novikov (tappak)
5 * PROJECT : ReactOS Operating System
6 * DESCRIPTION: file concatenation tool
7 * DATE : 2004-01-21
8 * LICENSE : GPL
9 */
10
11 #include <stdio.h>
12 #include <string.h>
13 #define F_O_ERR "can not open file"
14
15 void help(void)
16 {
17 puts("File concatenation tool");
18 puts("Usage: cat [file]");
19 }
20
21 int main(int argc, char *argv[])
22 {
23 FILE *srcf;
24 char *keys[]={"--help","/help"};
25 int i=0,ret=0;
26 switch(argc)
27 {
28 case 1:puts("Usage: cat [file]");break;
29 case 2:
30 if ((!strcmp(argv[1],keys[0]))||(!strcmp(argv[1],keys[1])))
31 help();
32 else
33 {
34 if((srcf=fopen(argv[1],"r"))!=NULL)
35 {
36 while(i!=EOF)
37 { i=fgetc(srcf);
38 putchar(i);
39 }
40 fclose(srcf);
41 }
42 else
43 {
44 printf("%s %s %s\n",argv[0],F_O_ERR,argv[1]);
45 ret=-1;
46 }
47 }
48 break;
49 }
50 return ret;
51 }
52