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 <crtdll/sys/types.h>
13 #include <crtdll/stdio.h>
14 #include <crtdll/io.h>
15 #include <crtdll/fcntl.h>
16 #include <crtdll/internal/file.h>
17 #include <crtdll/share.h>
20 FILE * __alloc_file(void);
23 FILE* _fsopen(const char *file, const char *mode, int shflag)
26 int fd, rw, oflags = 0;
40 rw = (mode[1] == '+') || (mode[1] && (mode[2] == '+'));
45 oflags = O_CREAT | (rw ? O_RDWR : O_WRONLY);
48 oflags = rw ? O_RDWR : O_RDONLY;
51 oflags = O_TRUNC | O_CREAT | (rw ? O_RDWR : O_WRONLY);
62 else if (tbchar == 'b')
65 oflags |= (_fmode & (O_TEXT|O_BINARY));
69 if ( shflag == _SH_DENYNO )
70 shf = _S_IREAD | _S_IWRITE;
71 else if( shflag == _SH_DENYRD )
73 else if( shflag == _SH_DENYRW )
75 else if( shflag == _SH_DENYWR )
78 shf = _S_IREAD | _S_IWRITE;
80 fd = _open(file, oflags, shf);
84 // ms crtdll ensures that writes will end up at the end of file in append mode
85 // we just move the file pointer to the end of file initially
87 lseek(fd, 0, SEEK_END);
93 f->_flag = _IOREAD | _IOWRT;
94 else if (*mode == 'r')
99 f->_base = f->_ptr = NULL;