1 | #include <stdio.h>
|
---|
2 | #include <stdlib.h>
|
---|
3 | #include <fcntl.h>
|
---|
4 | #include <io.h>
|
---|
5 |
|
---|
6 | #ifdef __OS2__
|
---|
7 |
|
---|
8 | #define INCL_DOSFILEMGR
|
---|
9 | #include <os2.h>
|
---|
10 |
|
---|
11 | void doDosQueryHType(HFILE hfile)
|
---|
12 | {
|
---|
13 | ULONG type, attr;
|
---|
14 | APIRET arc = DosQueryHType(hfile, &type, &attr);
|
---|
15 | if (arc == 0)
|
---|
16 | printf("DosQueryHType(%ld) type %lx attr %lx\r\n", hfile, type, attr);
|
---|
17 | else
|
---|
18 | printf("DosQueryHType(%ld) rc %ld\r\n", hfile, arc);
|
---|
19 | }
|
---|
20 |
|
---|
21 | #endif
|
---|
22 |
|
---|
23 | int main(int argc, char *argv[])
|
---|
24 | {
|
---|
25 | int n;
|
---|
26 | FILE *fp;
|
---|
27 | char buffer[4096];
|
---|
28 |
|
---|
29 | #ifdef __OS2__
|
---|
30 | _fsetmode(stdin, "b");
|
---|
31 | _fsetmode(stdout, "b");
|
---|
32 | _fsetmode(stderr, "b");
|
---|
33 | #endif
|
---|
34 |
|
---|
35 | printf("isatty(stdin) %d\r\n", isatty(fileno(stdin)));
|
---|
36 | printf("isatty(stdout) %d\r\n", isatty(fileno(stdout)));
|
---|
37 | printf("isatty(stderr) %d\r\n", isatty(fileno(stderr)));
|
---|
38 |
|
---|
39 | #ifdef __OS2__
|
---|
40 | doDosQueryHType((HFILE)0);
|
---|
41 | doDosQueryHType((HFILE)1);
|
---|
42 | doDosQueryHType((HFILE)2);
|
---|
43 | #endif
|
---|
44 |
|
---|
45 | if( argc > 2 )
|
---|
46 | {
|
---|
47 | switch( atoi( argv[1] ) )
|
---|
48 | {
|
---|
49 | case 0:
|
---|
50 | if( (fp = fopen(argv[2], "wb" )) != NULL )
|
---|
51 | {
|
---|
52 | while( (n = fread(buffer, 1, sizeof(buffer), stdin)) > 0 )
|
---|
53 | {
|
---|
54 | fwrite(buffer, 1, n, fp);
|
---|
55 | }
|
---|
56 |
|
---|
57 | fclose( fp );
|
---|
58 | }
|
---|
59 |
|
---|
60 | return 0;
|
---|
|
---|