ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

getch.c
Go to the documentation of this file.
00001 /*
00002  * COPYRIGHT:   See COPYING in the top level directory
00003  * PROJECT:     ReactOS system libraries
00004  * FILE:        lib/msvcrt/conio/getch.c
00005  * PURPOSE:     Writes a character to stdout
00006  * PROGRAMER:   Ariadne
00007  * UPDATE HISTORY:
00008  *              28/12/98: Created
00009  */
00010 
00011 #include <precomp.h>
00012 
00013 /*
00014  * @implemented
00015  */
00016 int _getch(void)
00017 {
00018     DWORD NumberOfCharsRead = 0;
00019     char c;
00020     HANDLE ConsoleHandle;
00021     BOOL RestoreMode;
00022     DWORD ConsoleMode;
00023 
00024     if (char_avail) {
00025         c = ungot_char;
00026         char_avail = 0;
00027     } else {
00028         /*
00029          * _getch() is documented to NOT echo characters. Testing shows it
00030          * doesn't wait for a CR either. So we need to switch off
00031          * ENABLE_ECHO_INPUT and ENABLE_LINE_INPUT if they're currently
00032          * switched on.
00033          */
00034         ConsoleHandle = (HANDLE) _get_osfhandle(stdin->_file);
00035         RestoreMode = GetConsoleMode(ConsoleHandle, &ConsoleMode) &&
00036                       (0 != (ConsoleMode &
00037                              (ENABLE_ECHO_INPUT | ENABLE_LINE_INPUT)));
00038         if (RestoreMode) {
00039             SetConsoleMode(ConsoleHandle,
00040                            ConsoleMode & (~ (ENABLE_ECHO_INPUT | ENABLE_LINE_INPUT)));
00041         }
00042         ReadConsoleA((HANDLE)_get_osfhandle(stdin->_file),
00043                      &c,
00044                      1,
00045                      &NumberOfCharsRead,
00046                      NULL);
00047         if (RestoreMode) {
00048             SetConsoleMode(ConsoleHandle, ConsoleMode);
00049         }
00050     }
00051     if (c == 10)
00052         c = 13;
00053     return c;
00054 }
00055 

Generated on Thu May 24 2012 04:36:55 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.