Share more duplicated functions

svn path=/trunk/; revision=17734
This commit is contained in:
Alex Ionescu 2005-09-08 05:03:34 +00:00
parent 6ce05ab58e
commit 48fe1fb84b
26 changed files with 1099 additions and 1084 deletions

View file

@ -11,6 +11,8 @@
/* DEPENDENCIES **************************************************************/
#include <ntnls.h>
#include "extypes.h"
#include "rtltypes.h"
/* PROTOTYPES ****************************************************************/

View file

@ -42,27 +42,6 @@
<file>sscanf.c</file>
<file>swprintf.c</file>
</directory>
<directory name="stdlib">
<file>abs.c</file>
<file>atoi64.c</file>
<file>atoi.c</file>
<file>atol.c</file>
<file>bsearch.c</file>
<file>itoa.c</file>
<file>itow.c</file>
<file>labs.c</file>
<file>lfind.c</file>
<file>mbstowcs.c</file>
<file>splitp.c</file>
<file>strtol.c</file>
<file>strtoul.c</file>
<file>wcstol.c</file>
<file>wcstombs.c</file>
<file>wcstoul.c</file>
<file>wtoi64.c</file>
<file>wtoi.c</file>
<file>wtol.c</file>
</directory>
<directory name="def">
<file>ntdll.rc</file>
</directory>

View file

@ -1,11 +0,0 @@
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
#include <ntdll.h>
/*
* @implemented
*/
int
abs(int j)
{
return j<0 ? -j : j;
}

View file

@ -1,11 +0,0 @@
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
#include <ntdll.h>
/*
* @implemented
*/
long
labs(long j)
{
return j<0 ? -j : j;
}

10
reactos/lib/string/abs.c Normal file
View file

@ -0,0 +1,10 @@
#include <string.h>
/*
* @implemented
*/
int
abs(int j)
{
return j<0 ? -j : j;
}

View file

@ -1,5 +1,5 @@
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
#include <ntdll.h>
#include <string.h>
#include <stdlib.h>
/*
* @implemented

View file

@ -1,12 +1,5 @@
/* $Id$
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: lib/ntdll/stdlib/atoi64.c
* PURPOSE: converts an ascii string to 64 bit integer
*/
#include <ntdll.h>
#include <string.h>
#include <ctype.h>
/*
* @implemented

View file

@ -1,5 +1,5 @@
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
#include <ntdll.h>
#include <string.h>
#include <stdlib.h>
/*
* @implemented

View file

@ -1,5 +1,4 @@
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
#include <ntdll.h>
#include <string.h>
/*
* @implemented

View file

@ -1,21 +1,5 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/ntdll/stdlib/itoa.c
* PURPOSE: converts an integer to ascii
* PROGRAMER:
* UPDATE HISTORY:
* 1995: Created
* 1998: Added ltoa Boudewijn Dekker
* 2003: Corrected ltoa implementation - Steven Edwards
*/
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details
* Copyright 2000 Alexandre Julliard
* Copyright 2000 Jon Griffiths
* Copyright 2003 Thomas Mertes
*/
#include <ntdll.h>
#include <string.h>
#include <stdlib.h>
/*
* @implemented

View file

@ -1,15 +1,4 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/ntdll/stdlib/itow.c
* PURPOSE: converts an integer to Unicode
* PROGRAMER:
* UPDATE HISTORY:
* 1995: Created
* 1998: Added ltoa Boudewijn Dekker
*/
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
#include <ntdll.h>
#include <string.h>
/*
* @implemented

View file

@ -0,0 +1,9 @@
#include <string.h>
/*
* @implemented
*/
long
labs(long j)
{
return j<0 ? -j : j;
}

View file

@ -1,6 +1,4 @@
#include <ntdll.h>
#include <string.h>
/*
* @implemented
*/

View file

@ -1,16 +1,32 @@
/* $Id$
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: lib/ntdll/stdlib/mbstowcs.c
* PURPOSE: converts a multi byte string to a unicode string
*/
#include <ntdll.h>
#define NDEBUG
#include <debug.h>
#include <stdlib.h>
#include <windows.h>
#define NTOS_MODE_USER
#define _NTSYSTEM_
#include <ndk/umtypes.h>
#include <ndk/rtlfuncs.h>
#include <string.h>
/*
* @implemented
*/
int mbtowc (wchar_t *wchar, const char *mbchar, size_t count)
{
NTSTATUS Status;
ULONG Size;
if (wchar == NULL)
return 0;
Status = RtlMultiByteToUnicodeN (wchar,
sizeof(WCHAR),
&Size,
(char *)mbchar,
count);
if (!NT_SUCCESS(Status))
return -1;
return (int)Size;
}
/*
* @implemented
*/

29
reactos/lib/string/rand.c Normal file
View file

@ -0,0 +1,29 @@
#include <stdlib.h>
#if defined(__GNUC__)
static unsigned long long next = 0;
#else
static unsigned __int64 next = 0;
#endif
/*
* @implemented
*/
int rand(void)
{
#if defined(__GNUC__)
next = next * 0x5deece66dLL + 11;
#else
next = next * 0x5deece66di64 + 11;
#endif
return (int)((next >> 16) & RAND_MAX);
}
/*
* @implemented
*/
void srand(unsigned seed)
{
next = seed;
}

View file

@ -1,5 +1,4 @@
#include <ntdll.h>
#include <string.h>
/*
* @implemented
*/

View file

@ -76,4 +76,24 @@
<file>wstring.c</file>
<file>wcsrev.c</file>
<file>wcsnset.c</file>
<file>abs.c</file>
<file>atoi64.c</file>
<file>atoi.c</file>
<file>atol.c</file>
<file>bsearch.c</file>
<file>itoa.c</file>
<file>itow.c</file>
<file>labs.c</file>
<file>lfind.c</file>
<file>mbstowcs.c</file>
<file>splitp.c</file>
<file>strtol.c</file>
<file>strtoul.c</file>
<file>wcstol.c</file>
<file>wcstombs.c</file>
<file>wcstoul.c</file>
<file>wtoi64.c</file>
<file>wtoi.c</file>
<file>wtol.c</file>
<file>rand.c</file>
</module>

View file

@ -1,5 +1,6 @@
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
#include <ntdll.h>
#include <string.h>
#include <limits.h>
#include <ctype.h>
/*
* @implemented

View file

@ -1,6 +1,6 @@
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
#include <ntdll.h>
#include <string.h>
#include <limits.h>
#include <ctype.h>
/*
* Convert a string to an unsigned long integer.

View file

@ -1,6 +1,6 @@
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
#include <ntdll.h>
#include <string.h>
#include <ctype.h>
#include <limits.h>
/*
* @implemented

View file

@ -1,16 +1,30 @@
/* $Id$
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: lib/ntdll/stdlib/wcstombs.c
* PURPOSE: converts a unicode string to a multi byte string
*/
#include <windows.h>
#define NTOS_MODE_USER
#define _NTSYSTEM_
#include <ndk/umtypes.h>
#include <ndk/rtlfuncs.h>
#include <ntdll.h>
#define NDEBUG
#include <debug.h>
#include <stdlib.h>
#include <string.h>
/*
* @implemented
*/
int wctomb (char *mbchar, wchar_t wchar)
{
NTSTATUS Status;
ULONG Size;
if (mbchar == NULL)
return 0;
Status = RtlUnicodeToMultiByteN (mbchar,
1,
&Size,
&wchar,
sizeof(WCHAR));
if (!NT_SUCCESS(Status))
return -1;
return (int)Size;
}
/*
* @implemented

View file

@ -1,5 +1,7 @@
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
#include <ntdll.h>
#include <string.h>
#include <ctype.h>
#include <limits.h>
/*
* Convert a unicode string to an unsigned long integer.

View file

@ -1,5 +1,5 @@
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
#include <ntdll.h>
#include <string.h>
#include <stdlib.h>
/*
* @implemented

View file

@ -1,12 +1,6 @@
/* $Id$
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: lib/ntdll/stdlib/wtoi64.c
* PURPOSE: converts a unicode string to 64 bit integer
*/
#include <string.h>
#include <ctype.h>
#include <ntdll.h>
/*
* @implemented

View file

@ -1,5 +1,5 @@
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
#include <ntdll.h>
#include <string.h>
#include <stdlib.h>
/*
* @implemented

View file

@ -321,7 +321,6 @@
<file>purecall.c</file>
<file>regio.c</file>
<file>sprintf.c</file>
<file>stdlib.c</file>
<file>strtok.c</file>
<file>swprintf.c</file>
</directory>