-
Notifications
You must be signed in to change notification settings - Fork 2
/
SETUPIO.INC
103 lines (86 loc) · 2.16 KB
/
SETUPIO.INC
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#include <io.h>
#include <fcntl.h>
#include <stdio.h>
/* Import: NFILE, NOSTDIO, NOBUFFER */
#ifndef NFILE
# define NFILE 6
#endif
/*----------------------------------------------------------------------*/
#ifdef __cplusplus
extern "C"
#endif
unsigned _Cdecl _nfile = NFILE;
#ifdef __cplusplus
extern "C"
#endif
unsigned int _Cdecl _openfd [NFILE] =
{
O_RDONLY | O_DEVICE | O_TEXT,
O_WRONLY | O_DEVICE | O_TEXT,
O_WRONLY | O_DEVICE | O_TEXT,
O_RDWR | O_DEVICE | O_BINARY,
O_WRONLY | O_DEVICE | O_BINARY
};
/*----------------------------------------------------------------------*/
#ifndef NOSTDIO
# ifdef __cplusplus
extern "C"
# endif
FILE _Cdecl _streams [NFILE] =
{
{ 0, _F_READ|_F_TERM|_F_LBUF, 0, 0, 0, NULL, NULL, 0, (short)stdin },
{ 0, _F_WRIT|_F_TERM|_F_LBUF, 1, 0, 0, NULL, NULL, 0, (short)stdout },
{ 0, _F_WRIT|_F_TERM, 2, 0, 0, NULL, NULL, 0, (short)stderr },
{ 0, _F_RDWR|_F_TERM|_F_BIN, 3, 0, 0, NULL, NULL, 0, (short)stdaux },
{ 0, _F_WRIT|_F_TERM|_F_BIN, 4, 0, 0, NULL, NULL, 0, (short)stdprn },
# if NFILE > 5
{ 0, 0, -1, 0, 0, NULL, NULL, 0, (short)&_streams[5] },
# endif
# if NFILE > 6
{ 0, 0, -1, 0, 0, NULL, NULL, 0, (short)&_streams[6] },
# endif
# if NFILE > 7
{ 0, 0, -1, 0, 0, NULL, NULL, 0, (short)&_streams[7] },
# endif
};
#endif
/*----------------------------------------------------------------------*/
/* "Check for stack overflow" off for BC++ 3.1 */
/* "Suppress redundant load" on for BC++ 3.1 */
#pragma option -N- -Z
#ifndef NOSTDIO
# ifdef NOBUFFER
static void near __fastcall _setbuf_ (FILE *fp) {
if (!isatty (fp->fd))
fp->flags &= ~_F_TERM;
}
# else
static void near __fastcall _setbuf_ (FILE *fp) {
unsigned type;
if (!isatty (fp->fd)){
fp->flags &= ~_F_TERM,
type = _IOFBF;
} else type = _IONBF;
setvbuf (fp, NULL, type, BUFSIZ);
}
# endif
#endif
#ifdef __cplusplus
extern "C"
#endif
void near _Cdecl _setupio (void) {
#ifndef NOSTDIO
# if NFILE > 8
FILE *fp = &_streams [8];
do { /*_openfd[i] = 0,*/
fp->fd = -1, fp->token = (short)fp, fp++;
} while (fp < &_streams [NFILE]);
# endif
_setbuf_ (stdin);
_setbuf_ (stdout);
#endif
}
#pragma option -N. -Z.
#ifndef NOSTDIO
# pragma startup _setupio 2
#endif