source: tests/process/child/child.c@ 908

Last change on this file since 908 was 908, checked in by Dmitry A. Kuminov, 14 years ago

tests: process: Be consistent and use binary file mode everywhere.

  • Property svn:eol-style set to native
File size: 1.3 KB
Line 
1#include <stdio.h>
2#include <stdlib.h>
3#include <fcntl.h>
4
5int main(int argc, char *argv[])
6{
7 int n;
8 FILE *fp;
9 char buffer[4096];
10
11#ifdef __OS2__
12 _fsetmode(stdin, "b");
13 _fsetmode(stdout, "b");
14 _fsetmode(stderr, "b");
15#endif
16
17 if( argc > 2 )
18 {
19 switch( atoi( argv[1] ) )
20 {
21 case 0:
22 if( (fp = fopen(argv[2], "wb" )) != NULL )
23 {
24 while( (n = fread(buffer, 1, sizeof(buffer), stdin)) > 0 )
25 {
26 fwrite(buffer, 1, n, fp);
27 }
28
29 fclose( fp );
30 }
31
32 return 0;
33
34 case 1:
35 if( (fp = fopen(argv[2], "rb" )) != NULL )
36 {
37 while( (n = fread(buffer, 1, sizeof(buffer), fp)) > 0 )
38 {
39 fwrite(buffer, 1, n, stdout);
40 }
41
42 fclose( fp );
43 }
44
45 return 0;
46
47 case 2:
48 if( (fp = fopen(argv[2], "rb" )) != NULL )
49 {
50 while( (n = fread(buffer, 1, sizeof(buffer), fp)) > 0 )
51 {
52 fwrite(buffer, 1, n, stderr);
53 }
54
55 fclose( fp );
56 }
57
58 return 0;
59 }
60 }
61
62 return -1;
63}
Note: See TracBrowser for help on using the repository browser.