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 **************************************************************/ /* DEPENDENCIES **************************************************************/
#include <ntnls.h> #include <ntnls.h>
#include "extypes.h"
#include "rtltypes.h"
/* PROTOTYPES ****************************************************************/ /* PROTOTYPES ****************************************************************/

View file

@ -42,27 +42,6 @@
<file>sscanf.c</file> <file>sscanf.c</file>
<file>swprintf.c</file> <file>swprintf.c</file>
</directory> </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"> <directory name="def">
<file>ntdll.rc</file> <file>ntdll.rc</file>
</directory> </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 <string.h>
#include <ntdll.h> #include <stdlib.h>
/* /*
* @implemented * @implemented

View file

@ -1,12 +1,5 @@
/* $Id$ #include <string.h>
* #include <ctype.h>
* 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>
/* /*
* @implemented * @implemented

View file

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

View file

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

View file

@ -1,21 +1,5 @@
/* #include <string.h>
* COPYRIGHT: See COPYING in the top level directory #include <stdlib.h>
* 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>
/* /*
* @implemented * @implemented

View file

@ -1,15 +1,4 @@
/* #include <string.h>
* 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>
/* /*
* @implemented * @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 * @implemented
*/ */

View file

@ -1,16 +1,32 @@
/* $Id$ #include <windows.h>
* #define NTOS_MODE_USER
* COPYRIGHT: See COPYING in the top level directory #define _NTSYSTEM_
* PROJECT: ReactOS kernel #include <ndk/umtypes.h>
* FILE: lib/ntdll/stdlib/mbstowcs.c #include <ndk/rtlfuncs.h>
* PURPOSE: converts a multi byte string to a unicode string
*/
#include <ntdll.h>
#define NDEBUG
#include <debug.h>
#include <stdlib.h>
#include <string.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 * @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 * @implemented
*/ */

View file

@ -76,4 +76,24 @@
<file>wstring.c</file> <file>wstring.c</file>
<file>wcsrev.c</file> <file>wcsrev.c</file>
<file>wcsnset.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> </module>

View file

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

View file

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

View file

@ -1,16 +1,30 @@
/* $Id$ #include <windows.h>
* #define NTOS_MODE_USER
* COPYRIGHT: See COPYING in the top level directory #define _NTSYSTEM_
* PROJECT: ReactOS kernel #include <ndk/umtypes.h>
* FILE: lib/ntdll/stdlib/wcstombs.c #include <ndk/rtlfuncs.h>
* PURPOSE: converts a unicode string to a multi byte string
*/
#include <ntdll.h> /*
#define NDEBUG * @implemented
#include <debug.h> */
#include <stdlib.h> int wctomb (char *mbchar, wchar_t wchar)
#include <string.h> {
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 * @implemented

View file

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

View file

@ -1,12 +1,6 @@
/* $Id$ #include <string.h>
* #include <ctype.h>
* 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 <ntdll.h>
/* /*
* @implemented * @implemented

View file

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

View file

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