diff --git a/reactos/include/msvcrt/stdio.h b/reactos/include/msvcrt/stdio.h index 8ddce7d8c82..ca291f05b1f 100644 --- a/reactos/include/msvcrt/stdio.h +++ b/reactos/include/msvcrt/stdio.h @@ -22,9 +22,9 @@ * DISCLAIMED. This includes but is not limited to warranties of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * $Revision: 1.7 $ - * $Author: sedwards $ - * $Date: 2003/08/25 01:37:47 $ + * $Revision: 1.8 $ + * $Author: hbirr $ + * $Date: 2004/04/21 21:40:43 $ * */ /* Appropriated for Reactos Crtdll by Ariadne */ @@ -46,26 +46,22 @@ extern "C" { #include -/* Some flags for the iobuf structure provided by djgpp stdio.h */ -#define _IOREAD 0x000010 -#define _IOWRT 0x000020 -#define _IOMYBUF 0x000040 -#define _IOEOF 0x000100 -#define _IOERR 0x000200 -#define _IOSTRG 0x000400 +#define _IOREAD 0x0001 +#define _IOWRT 0x0002 +#define _IOMYBUF 0x0008 /* stdio malloc()'d buffer */ +#define _IOEOF 0x0010 /* EOF reached on read */ +#define _IOERR 0x0020 /* I/O error from system */ +#define _IOSTRG 0x0040 /* Strange or no file descriptor */ -#define _IOBINARY 0x000800 +#define _IOBINARY 0x040000 #define _IOTEXT 0x000000 -#define _IOAPPEND 0x002000 -#define _IORMONCL 0x004000 /* remove on close, for temp files */ -/* if _flag & _IORMONCL, ._name_to_remove needs freeing */ -#define _IOUNGETC 0x010000 /* there is an ungetc'ed character in the buffer */ -#define _IOCOMMIT 0x008000 +#define _IOCOMMIT 0x100000 + +#define _IODIRTY 0x010000 +#define _IOAHEAD 0x020000 + -#define _IODIRTY 0x000080 -#define _IOAHEAD 0x000008 -#define _IORW (_IOREAD | _IOWRITE ) /* @@ -180,9 +176,13 @@ wchar_t *_wtempnam(const wchar_t *dir,const wchar_t *prefix); * NOTE: _IOFBF works, but _IOLBF seems to work like unbuffered... * maybe I'm testing it wrong? */ -#define _IOFBF 0 /* fully buffered */ -#define _IOLBF 1 /* line buffered */ -#define _IONBF 2 /* unbuffered */ +#define _IOFBF 0x0000 /* full buffered */ +#define _IOLBF 0x0040 /* line buffered */ +#define _IONBF 0x0004 /* not buffered */ + +#define _IO_LBF 0x80000 /* this value is used insteat of _IOLBF within the + structure FILE as value for _flags, + because _IOLBF has the same value as _IOSTRG */ int setvbuf(FILE* fileSetBuffer, char* caBuffer, int nMode, size_t sizeBuffer); diff --git a/reactos/lib/msvcrt/stdio/fflush.c b/reactos/lib/msvcrt/stdio/fflush.c index 6ce5e09ae73..e70e4cf41ef 100644 --- a/reactos/lib/msvcrt/stdio/fflush.c +++ b/reactos/lib/msvcrt/stdio/fflush.c @@ -81,7 +81,7 @@ int fflush(FILE *f) f->_flag &= ~_IOAHEAD; - f->_cnt = (f->_flag&(_IOLBF|_IONBF)) ? 0 : f->_bufsiz; + f->_cnt = (f->_flag&(_IO_LBF|_IONBF)) ? 0 : f->_bufsiz; // how can write return less than rn without being on error ??? diff --git a/reactos/lib/msvcrt/stdio/filbuf.c b/reactos/lib/msvcrt/stdio/filbuf.c index 306c8bd976c..64b2134f5c3 100644 --- a/reactos/lib/msvcrt/stdio/filbuf.c +++ b/reactos/lib/msvcrt/stdio/filbuf.c @@ -34,7 +34,7 @@ int _filbuf(FILE* f) if ((f->_base = malloc(size+1)) == NULL) { // error ENOMEM f->_flag |= _IONBF; - f->_flag &= ~(_IOFBF|_IOLBF); + f->_flag &= ~(_IOFBF|_IO_LBF); } else { f->_flag |= _IOMYBUF; f->_bufsiz = size; @@ -45,9 +45,9 @@ int _filbuf(FILE* f) // flush stdout before reading from stdin if (f == stdin) { - if (stdout->_flag&_IOLBF) + if (stdout->_flag&_IO_LBF) fflush(stdout); - if (stderr->_flag&_IOLBF) + if (stderr->_flag&_IO_LBF) fflush(stderr); } diff --git a/reactos/lib/msvcrt/stdio/flsbuf.c b/reactos/lib/msvcrt/stdio/flsbuf.c index 5d01507772f..e0b4154b902 100644 --- a/reactos/lib/msvcrt/stdio/flsbuf.c +++ b/reactos/lib/msvcrt/stdio/flsbuf.c @@ -40,19 +40,19 @@ int _flsbuf(int c, FILE* f) size = 4096; if ((f->_base = base = malloc(size)) == NULL) { f->_flag |= _IONBF; - f->_flag &= ~(_IOFBF|_IOLBF); + f->_flag &= ~(_IOFBF|_IO_LBF); } else { f->_flag |= _IOMYBUF; f->_cnt = f->_bufsiz = size; f->_ptr = base; rn = 0; if (f == stdout && isatty(fileno(stdout))) { - f->_flag |= _IOLBF; + f->_flag |= _IO_LBF; } } } - if (f->_flag & _IOLBF) { + if (f->_flag & _IO_LBF) { /* in line-buffering mode we get here on each character */ *f->_ptr++ = c; rn = f->_ptr - base; @@ -90,7 +90,7 @@ int _flsbuf(int c, FILE* f) rn -= n; base += n; } - if ((f->_flag & (_IOLBF|_IONBF)) == 0) { + if ((f->_flag & (_IO_LBF|_IONBF)) == 0) { f->_cnt--; *f->_ptr++ = c; } diff --git a/reactos/lib/msvcrt/stdio/fwrite.c b/reactos/lib/msvcrt/stdio/fwrite.c index 7d6e23d2c5a..24d5739a01c 100644 --- a/reactos/lib/msvcrt/stdio/fwrite.c +++ b/reactos/lib/msvcrt/stdio/fwrite.c @@ -44,7 +44,7 @@ size_t fwrite(const void *vptr, size_t size, size_t count, FILE *iop) return 1; } - if (iop->_flag & _IOLBF) + if (iop->_flag & _IO_LBF) { while (to_write > 0) { diff --git a/reactos/lib/msvcrt/stdio/putchar.c b/reactos/lib/msvcrt/stdio/putchar.c index 911e29e4db9..7c3030cc9c4 100644 --- a/reactos/lib/msvcrt/stdio/putchar.c +++ b/reactos/lib/msvcrt/stdio/putchar.c @@ -21,7 +21,7 @@ int putchar(int c) { int r = putc(c, stdout); - if (stdout->_flag & _IOLBF) + if (stdout->_flag & _IO_LBF) fflush(stdout); return r; } @@ -32,7 +32,7 @@ int putchar(int c) wint_t putwchar(wint_t c) { wint_t r = putwc(c, stdout); - if (stdout->_flag & _IOLBF) + if (stdout->_flag & _IO_LBF) fflush(stdout); return r; } diff --git a/reactos/lib/msvcrt/stdio/setvbuf.c b/reactos/lib/msvcrt/stdio/setvbuf.c index 8447b35602d..d0dadf0c786 100644 --- a/reactos/lib/msvcrt/stdio/setvbuf.c +++ b/reactos/lib/msvcrt/stdio/setvbuf.c @@ -20,10 +20,14 @@ int setvbuf(FILE *f, char *buf, int type, size_t len) } if ( f->_base != NULL ) fflush(f); + /* Cannot use _IOLBF as flag value because _IOLBF is equal to _IOSTRG */ + if (type == _IOLBF) + type = _IO_LBF; + switch (type) { case _IOFBF: - case _IOLBF: + case _IO_LBF: if (len <= 0) { __set_errno (EINVAL); return EOF; @@ -43,7 +47,7 @@ int setvbuf(FILE *f, char *buf, int type, size_t len) free(f->_base); f->_cnt = 0; - f->_flag &= ~(_IONBF|_IOFBF|_IOLBF|_IOUNGETC); + f->_flag &= ~(_IONBF|_IOFBF|_IO_LBF|_IOUNGETC); f->_flag |= type; if (type != _IONBF) { diff --git a/reactos/lib/msvcrt/stdio/stdhnd.c b/reactos/lib/msvcrt/stdio/stdhnd.c index 3d594870e1f..012cd481599 100644 --- a/reactos/lib/msvcrt/stdio/stdhnd.c +++ b/reactos/lib/msvcrt/stdio/stdhnd.c @@ -7,13 +7,13 @@ FILE _iob[5] = // stdin { NULL, 0, NULL, - _IOREAD | _IOLBF , + _IOREAD | _IO_LBF , 0, 0,0, NULL }, // stdout { NULL, 0, NULL, - _IOWRT | _IOLBF |_IOSTRG, + _IOWRT | _IO_LBF |_IOSTRG, 1,0,0, NULL }, // stderr