reactos/reactos/lib/crtdll/stdio/getc.c
Boudewijn Dekker 6becb71b7c Replaced old version of printf and added some long long and
long double support.

svn path=/trunk/; revision=393
1999-04-17 09:10:25 +00:00

55 lines
773 B
C

#include <windows.h>
#include <crtdll/stdio.h>
#include <crtdll/wchar.h>
#include <crtdll/errno.h>
#include <crtdll/internal/file.h>
int getc(FILE *fp)
{
// check for invalid stream
if ( (int)fp == NULL ) {
__set_errno(EINVAL);
return -1;
}
// check for read access on stream
// if ( (fp->_flag & _IOREAD) != _IOREAD ) {
// __set_errno(EINVAL);
// return -1;
// }
if(fp->_cnt > 0) {
fp->_cnt--;
return (int)*fp->_ptr++;
}
else {
return _filbuf(fp);
}
return -1;
}
// not exported
wint_t getwc(FILE *fp)
{
// might check on multi bytes if text mode
if(fp->_cnt > 0) {
fp->_cnt -= sizeof(wchar_t);
return (wint_t )*((wchar_t *)(fp->_ptr))++;
}
else {
return _filwbuf(fp);
}
// never reached
return -1;
}