3 * ReactOS msvcrt library
7 * Copyright (C) 2002 Robert Dickenson <robd@reactos.org>
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
38 // check for invalid stream
39 if ( !__validfp (fp
) ) {
43 // check for read access on stream
44 if ( !OPEN4READING(fp
) ) {
50 c
= (int)(*fp
->_ptr
++ & 0377);
60 wint_t getwc(FILE *fp
)
64 // check for invalid stream
69 // check for read access on stream
70 //#define OPEN4READING(f) ((((f)->_flag & _IOREAD) == _IOREAD ) )
71 if (!OPEN4READING(fp
)) {
75 // might check on multi bytes if text mode
76 if (fp
->_flag
& _IOBINARY
) {
78 fp
->_cnt
-= sizeof(wchar_t);
79 c
= *((wchar_t*)fp
->_ptr
);
80 fp
->_ptr
+= sizeof(wchar_t);
83 // need to fix by one values of fp->_ptr and fp->_cnt
93 char mbchar
[MB_CUR_MAX
];
98 mbchar
[mb_cnt
] = *fp
->_ptr
++ & 0377;
100 mbchar
[mb_cnt
] = _filbuf(fp
);
102 if (isleadbyte(mbchar
[mb_cnt
])) {
107 if (_ismbblead(mbchar
[mb_cnt
])) {
113 // Convert a multibyte character to a corresponding wide character.
114 mb_cnt
= mbtowc(&c
, mbchar
, mb_cnt
);
122 c
= *fp
->_ptr
++ &0377;