mirror of
https://github.com/reactos/reactos.git
synced 2025-07-30 18:12:07 +00:00
- Create another branch for networking fixes
- TSVN choked repeatedly when attempting to merge ~9000 revs into the branch (tried 3 times on 2 different computers) - If someone wants to delete aicom-network-fixes, they are welcome to - Lesson learned: Letting a branch get thousands of revs out of date is a horrible idea svn path=/branches/aicom-network-branch/; revision=44353
This commit is contained in:
parent
6bc24c2625
commit
29fa274d6d
19364 changed files with 0 additions and 964402 deletions
73
lib/sdk/crt/conio/cgets.c
Normal file
73
lib/sdk/crt/conio/cgets.c
Normal file
|
@ -0,0 +1,73 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
* FILE: msvcrt/conio/cgets.c
|
||||
* PURPOSE: C Runtime
|
||||
* PROGRAMMER: Eric Kohl (Imported from DJGPP)
|
||||
*/
|
||||
|
||||
#include <precomp.h>
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
char *_cgets(char *string)
|
||||
{
|
||||
unsigned len = 0;
|
||||
unsigned int maxlen_wanted;
|
||||
char *sp;
|
||||
int c;
|
||||
/*
|
||||
* Be smart and check for NULL pointer.
|
||||
* Don't know wether TURBOC does this.
|
||||
*/
|
||||
if (!string)
|
||||
return(NULL);
|
||||
maxlen_wanted = (unsigned int)((unsigned char)string[0]);
|
||||
sp = &(string[2]);
|
||||
/*
|
||||
* Should the string be shorter maxlen_wanted including or excluding
|
||||
* the trailing '\0' ? We don't take any risk.
|
||||
*/
|
||||
while(len < maxlen_wanted-1)
|
||||
{
|
||||
c=_getch();
|
||||
/*
|
||||
* shold we check for backspace here?
|
||||
* TURBOC does (just checked) but doesn't in cscanf (thats harder
|
||||
* or even impossible). We do the same.
|
||||
*/
|
||||
if (c == '\b')
|
||||
{
|
||||
if (len > 0)
|
||||
{
|
||||
_cputs("\b \b"); /* go back, clear char on screen with space
|
||||
and go back again */
|
||||
len--;
|
||||
sp[len] = '\0'; /* clear the character in the string */
|
||||
}
|
||||
}
|
||||
else if (c == '\r')
|
||||
{
|
||||
sp[len] = '\0';
|
||||
break;
|
||||
}
|
||||
else if (c == 0)
|
||||
{
|
||||
/* special character ends input */
|
||||
sp[len] = '\0';
|
||||
_ungetch(c); /* keep the char for later processing */
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
sp[len] = _putch(c);
|
||||
len++;
|
||||
}
|
||||
}
|
||||
sp[maxlen_wanted-1] = '\0';
|
||||
string[1] = (char)((unsigned char)len);
|
||||
return(sp);
|
||||
}
|
||||
|
||||
|
40
lib/sdk/crt/conio/cprintf.c
Normal file
40
lib/sdk/crt/conio/cprintf.c
Normal file
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* COPYRIGHT: Winehq
|
||||
* PROJECT: wine
|
||||
* FILE: msvcrt/conio/cprintf.c
|
||||
* PURPOSE: C Runtime
|
||||
* PROGRAMMER: Magnus Olsen (Imported from wine cvs 2006-05-23)
|
||||
*/
|
||||
|
||||
#include <precomp.h>
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
int
|
||||
_cprintf(const char *fmt, ...)
|
||||
{
|
||||
char buf[2048], *mem = buf;
|
||||
int written, resize = sizeof(buf), retval;
|
||||
va_list valist;
|
||||
|
||||
va_start( valist, fmt );
|
||||
|
||||
while ((written = _vsnprintf( mem, resize, fmt, valist )) == -1 ||
|
||||
written > resize)
|
||||
{
|
||||
resize = (written == -1 ? resize * 2 : written + 1);
|
||||
if (mem != buf)
|
||||
free (mem);
|
||||
if (!(mem = (char *)malloc(resize)))
|
||||
return EOF;
|
||||
|
||||
va_end ( valist );
|
||||
va_start( valist, fmt );
|
||||
}
|
||||
va_end ( valist );
|
||||
retval = _cputs( mem );
|
||||
if (mem != buf)
|
||||
free (mem);
|
||||
return retval;
|
||||
}
|
35
lib/sdk/crt/conio/cputs.c
Normal file
35
lib/sdk/crt/conio/cputs.c
Normal file
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
* COPYRIGHT: LGPL - See COPYING in the top level directory
|
||||
* PROJECT: ReactOS system libraries
|
||||
* FILE: lib/msvcrt/conio/cputs.c
|
||||
* PURPOSE: Writes a character to stdout
|
||||
* PROGRAMER: Aleksey Bragin
|
||||
*/
|
||||
|
||||
#include <precomp.h>
|
||||
|
||||
extern FDINFO *fdesc;
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
int _cputs(const char *_str)
|
||||
{
|
||||
#if 0
|
||||
DWORD count;
|
||||
int retval = EOF;
|
||||
|
||||
LOCK_CONSOLE;
|
||||
if (WriteConsoleA(console_out, str, strlen(str), &count, NULL)
|
||||
&& count == 1)
|
||||
retval = 0;
|
||||
UNLOCK_CONSOLE;
|
||||
return retval;
|
||||
#else
|
||||
int len = strlen(_str);
|
||||
DWORD written = 0;
|
||||
if (!WriteFile( fdesc[stdout->_file].hFile ,_str,len,&written,NULL))
|
||||
return -1;
|
||||
return 0;
|
||||
#endif
|
||||
}
|
55
lib/sdk/crt/conio/getch.c
Normal file
55
lib/sdk/crt/conio/getch.c
Normal file
|
@ -0,0 +1,55 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS system libraries
|
||||
* FILE: lib/msvcrt/conio/getch.c
|
||||
* PURPOSE: Writes a character to stdout
|
||||
* PROGRAMER: Ariadne
|
||||
* UPDATE HISTORY:
|
||||
* 28/12/98: Created
|
||||
*/
|
||||
|
||||
#include <precomp.h>
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
int _getch(void)
|
||||
{
|
||||
DWORD NumberOfCharsRead = 0;
|
||||
char c;
|
||||
HANDLE ConsoleHandle;
|
||||
BOOL RestoreMode;
|
||||
DWORD ConsoleMode;
|
||||
|
||||
if (char_avail) {
|
||||
c = ungot_char;
|
||||
char_avail = 0;
|
||||
} else {
|
||||
/*
|
||||
* _getch() is documented to NOT echo characters. Testing shows it
|
||||
* doesn't wait for a CR either. So we need to switch off
|
||||
* ENABLE_ECHO_INPUT and ENABLE_LINE_INPUT if they're currently
|
||||
* switched on.
|
||||
*/
|
||||
ConsoleHandle = (HANDLE) _get_osfhandle(stdin->_file);
|
||||
RestoreMode = GetConsoleMode(ConsoleHandle, &ConsoleMode) &&
|
||||
(0 != (ConsoleMode &
|
||||
(ENABLE_ECHO_INPUT | ENABLE_LINE_INPUT)));
|
||||
if (RestoreMode) {
|
||||
SetConsoleMode(ConsoleHandle,
|
||||
ConsoleMode & (~ (ENABLE_ECHO_INPUT | ENABLE_LINE_INPUT)));
|
||||
}
|
||||
ReadConsoleA((HANDLE)_get_osfhandle(stdin->_file),
|
||||
&c,
|
||||
1,
|
||||
&NumberOfCharsRead,
|
||||
NULL);
|
||||
if (RestoreMode) {
|
||||
SetConsoleMode(ConsoleHandle, ConsoleMode);
|
||||
}
|
||||
}
|
||||
if (c == 10)
|
||||
c = 13;
|
||||
return c;
|
||||
}
|
||||
|
29
lib/sdk/crt/conio/getche.c
Normal file
29
lib/sdk/crt/conio/getche.c
Normal file
|
@ -0,0 +1,29 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details
|
||||
* PROJECT: ReactOS system libraries
|
||||
* FILE: lib/msvcrt/conio/getche.c
|
||||
* PURPOSE: Reads a character from stdin
|
||||
* PROGRAMER: DJ Delorie
|
||||
Ariadne
|
||||
* UPDATE HISTORY:
|
||||
* 28/12/98: Created
|
||||
*/
|
||||
|
||||
#include <precomp.h>
|
||||
|
||||
int _getche(void)
|
||||
{
|
||||
if (char_avail)
|
||||
/*
|
||||
* We don't know, wether the ungot char was already echoed
|
||||
* we assume yes (for example in cscanf, probably the only
|
||||
* place where ungetch is ever called.
|
||||
* There is no way to check for this really, because
|
||||
* ungetch could have been called with a character that
|
||||
* hasn't been got by a conio function.
|
||||
* We don't echo again.
|
||||
*/
|
||||
return(_getch());
|
||||
return (_putch(_getch()));
|
||||
}
|
101
lib/sdk/crt/conio/kbhit.c
Normal file
101
lib/sdk/crt/conio/kbhit.c
Normal file
|
@ -0,0 +1,101 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS system libraries
|
||||
* FILE: lib/msvcrt/conio/kbhit.c
|
||||
* PURPOSE: Checks for keyboard hits
|
||||
* PROGRAMERS: Ariadne, Russell
|
||||
* UPDATE HISTORY:
|
||||
* 28/12/98: Created
|
||||
* 27/9/08: An almost 100% working version of _kbhit()
|
||||
*/
|
||||
|
||||
#include <precomp.h>
|
||||
|
||||
static CRITICAL_SECTION CriticalSection;
|
||||
volatile BOOL CriticalSectionInitialized=FALSE;
|
||||
|
||||
/*
|
||||
* FIXME Initial keyboard char not detected on first punch
|
||||
*
|
||||
* @implemented
|
||||
*/
|
||||
|
||||
int _kbhit(void)
|
||||
{
|
||||
PINPUT_RECORD InputRecord = NULL;
|
||||
DWORD NumberRead = 0;
|
||||
DWORD EventsRead = 0;
|
||||
DWORD RecordIndex = 0;
|
||||
DWORD BufferIndex = 0;
|
||||
HANDLE StdInputHandle = 0;
|
||||
DWORD ConsoleInputMode = 0;
|
||||
|
||||
/* Attempt some thread safety */
|
||||
if (!CriticalSectionInitialized)
|
||||
{
|
||||
InitializeCriticalSectionAndSpinCount(&CriticalSection, 0x80000400);
|
||||
CriticalSectionInitialized = TRUE;
|
||||
}
|
||||
|
||||
EnterCriticalSection(&CriticalSection);
|
||||
|
||||
if (char_avail)
|
||||
{
|
||||
LeaveCriticalSection(&CriticalSection);
|
||||
return 1;
|
||||
}
|
||||
|
||||
StdInputHandle = GetStdHandle(STD_INPUT_HANDLE);
|
||||
|
||||
/* Turn off processed input so we get key modifiers as well */
|
||||
GetConsoleMode(StdInputHandle, &ConsoleInputMode);
|
||||
|
||||
SetConsoleMode(StdInputHandle, ConsoleInputMode & ~ENABLE_PROCESSED_INPUT);
|
||||
|
||||
/* Start the process */
|
||||
if (!GetNumberOfConsoleInputEvents(StdInputHandle, &EventsRead))
|
||||
{
|
||||
LeaveCriticalSection(&CriticalSection);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!EventsRead)
|
||||
{
|
||||
LeaveCriticalSection(&CriticalSection);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!(InputRecord = (PINPUT_RECORD)malloc(EventsRead * sizeof(INPUT_RECORD))))
|
||||
{
|
||||
LeaveCriticalSection(&CriticalSection);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!ReadConsoleInput(StdInputHandle, InputRecord, EventsRead, &NumberRead))
|
||||
{
|
||||
free(InputRecord);
|
||||
LeaveCriticalSection(&CriticalSection);
|
||||
return 0;
|
||||
}
|
||||
|
||||
for (RecordIndex = 0; RecordIndex < NumberRead; RecordIndex++)
|
||||
{
|
||||
if (InputRecord[RecordIndex].EventType == KEY_EVENT &&
|
||||
InputRecord[RecordIndex].Event.KeyEvent.bKeyDown)
|
||||
{
|
||||
BufferIndex = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
free(InputRecord);
|
||||
|
||||
/* Restore console input mode */
|
||||
SetConsoleMode(StdInputHandle, ConsoleInputMode);
|
||||
|
||||
LeaveCriticalSection(&CriticalSection);
|
||||
|
||||
return BufferIndex;
|
||||
}
|
||||
|
||||
|
24
lib/sdk/crt/conio/putch.c
Normal file
24
lib/sdk/crt/conio/putch.c
Normal file
|
@ -0,0 +1,24 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS system libraries
|
||||
* FILE: lib/msvcrt/conio/putch.c
|
||||
* PURPOSE: Writes a character to stdout
|
||||
* PROGRAMER: Ariadne
|
||||
* UPDATE HISTORY:
|
||||
* 28/12/98: Created
|
||||
*/
|
||||
|
||||
#include <precomp.h>
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
int _putch(int c)
|
||||
{
|
||||
DWORD NumberOfCharsWritten;
|
||||
|
||||
if (WriteFile(GetStdHandle(STD_OUTPUT_HANDLE),&c,1,&NumberOfCharsWritten,NULL)) {
|
||||
return -1;
|
||||
}
|
||||
return NumberOfCharsWritten;
|
||||
}
|
29
lib/sdk/crt/conio/ungetch.c
Normal file
29
lib/sdk/crt/conio/ungetch.c
Normal file
|
@ -0,0 +1,29 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details
|
||||
* PROJECT: ReactOS system libraries
|
||||
* FILE: lib/msvcrt/conio/ungetch.c
|
||||
* PURPOSE: Ungets a character from stdin
|
||||
* PROGRAMER: DJ Delorie
|
||||
Ariadne [ Adapted from djgpp libc ]
|
||||
* UPDATE HISTORY:
|
||||
* 28/12/98: Created
|
||||
*/
|
||||
|
||||
#include <precomp.h>
|
||||
|
||||
int char_avail = 0;
|
||||
int ungot_char = 0;
|
||||
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
int _ungetch(int c)
|
||||
{
|
||||
if (char_avail)
|
||||
return(EOF);
|
||||
ungot_char = c;
|
||||
char_avail = 1;
|
||||
return(c);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue