2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS system libraries
4 * FILE: lib/crtdll/conio/kbhit.c
5 * PURPOSE: Checks for keyboard hits
6 * PROGRAMER: Boudewijn Dekker
10 /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
12 #include <msvcrt/sys/types.h>
13 #include <msvcrt/stdio.h>
14 #include <msvcrt/io.h>
15 #include <msvcrt/fcntl.h>
16 #include <msvcrt/share.h>
17 #include <msvcrt/internal/file.h>
20 FILE* __alloc_file(void);
26 FILE* _fsopen(const char* file, const char* mode, int shflag)
29 int fd, rw, oflags = 0;
43 rw = (mode[1] == '+') || (mode[1] && (mode[2] == '+'));
48 oflags = O_CREAT | (rw ? O_RDWR : O_WRONLY);
51 oflags = rw ? O_RDWR : O_RDONLY;
54 oflags = O_TRUNC | O_CREAT | (rw ? O_RDWR : O_WRONLY);
65 else if (tbchar == 'b')
68 oflags |= (_fmode & (O_TEXT|O_BINARY));
70 if ( shflag == _SH_DENYNO )
71 shf = _S_IREAD | _S_IWRITE;
72 else if( shflag == _SH_DENYRD )
74 else if( shflag == _SH_DENYRW )
76 else if( shflag == _SH_DENYWR )
79 shf = _S_IREAD | _S_IWRITE;
81 fd = _open(file, oflags, shf);
85 // ms crtdll ensures that writes will end up at the end of file in append mode
86 // we just move the file pointer to the end of file initially
88 lseek(fd, 0, SEEK_END);
94 f->_flag = _IOREAD | _IOWRT;
95 else if (*mode == 'r')
100 f->_base = f->_ptr = NULL;