source: tests/process/child/child.c

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

tests: Add testing sync process access on a GUI thread.

  • Property svn:eol-style set to native
File size: 2.4 KB
Line 
1#include <stdio.h>
2#include <stdlib.h>
3#include <fcntl.h>
4#include <unistd.h>
5
6#ifdef __OS2__
7
8#include <io.h>
9
10#define INCL_DOSFILEMGR
11#include <os2.h>
12
13void doDosQueryHType(HFILE hfile)
14{
15 ULONG type, attr;
16 APIRET arc = DosQueryHType(hfile, &type, &attr);
17 if (arc == 0)
18 printf("DosQueryHType(%ld) type %lx attr %lx\r\n", hfile, type, attr);
19 else
20 printf("DosQueryHType(%ld) rc %ld\r\n", hfile, arc);
21}
22
23#endif
24
25int main(int argc, char *argv[])
26{
27 int n;
28 FILE *fp;
29 char buffer[65536];
30
31#ifdef __OS2__
32 _fsetmode(stdin, "b");
33 _fsetmode(stdout, "b");
34 _fsetmode(stderr, "b");
35#endif
36
37#if 0
38 printf("isatty(stdin) %d\r\n", isatty(fileno(stdin)));
39 printf("isatty(stdout) %d\r\n", isatty(fileno(stdout)));
40 printf("isatty(stderr) %d\r\n", isatty(fileno(stderr)));
41
42#ifdef __OS2__
43 doDosQueryHType((HFILE)0);
44 doDosQueryHType((HFILE)1);
45 doDosQueryHType((HFILE)2);
46#endif
47#endif
48
49 if( argc > 2 )
50 {
51 switch( atoi( argv[1] ) )
52 {
53 case 0:
54 if( (fp = fopen(argv[2], "wb" )) != NULL )
55 {
56 while( (n = fread(buffer, 1, sizeof(buffer), stdin)) > 0 )
57 {
58 fwrite(buffer, 1, n, fp);
59 }
60
61 fclose( fp );
62 }
63
64 return 0;
65
66 case 1:
67 if( (fp = fopen(argv[2], "rb" )) != NULL )
68 {
69 while( (n = fread(buffer, 1, sizeof(buffer), fp)) > 0 )
70 {
71 fwrite(buffer, 1, n, stdout);
72 }
73
74 fclose( fp );
75 }
76
77 return 0;
78
79 case 2:
80 if( (fp = fopen(argv[2], "rb" )) != NULL )
81 {
82 while( (n = fread(buffer, 1, sizeof(buffer), fp)) > 0 )
83 {
84 fwrite(buffer, 1, n, stderr);
85 }
86
87 fclose( fp );
88 }
89
90 return 0;
91 }
92 }
93 else if (argc == 2)
94 {
95 switch (atoi (argv[1]))
96 {
97 case 3:
98 while ((n = fread (buffer, 1, sizeof (buffer), stdin)) > 0)
99 {
100 fwrite (buffer, 1, n, stdout);
101 }
102
103 return 0;
104
105 case 4:
106 while (!feof (stdin) && !ferror (stdin))
107 {
108 n = fread (buffer, 1, sizeof (buffer), stdin);
109 fwrite (buffer, 1, n, stdout);
110 }
111
112 return 0;
113 }
114 }
115
116 return -1;
117}
Note: See TracBrowser for help on using the repository browser.