mirror of
https://github.com/reactos/reactos.git
synced 2024-09-29 05:54:05 +00:00
add wcsncpy_s, strcat_s (from wine)
and _ftol2 and _ftol2_sse required by vmware tools svn path=/trunk/; revision=39384
This commit is contained in:
parent
98b23c7c52
commit
8cd3b76387
|
@ -848,5 +848,9 @@ EXPORTS
|
|||
wscanf @842
|
||||
|
||||
_mbsnbcpy_s
|
||||
|
||||
wcsncpy_s
|
||||
_ftol2=_ftol
|
||||
_ftol2_sse=_ftol
|
||||
strcat_s
|
||||
|
||||
_swprintf=swprintf
|
||||
|
|
|
@ -399,6 +399,7 @@
|
|||
<file>strdup.c</file>
|
||||
<file>strerror.c</file>
|
||||
<file>stricmp.c</file>
|
||||
<file>string.c</file>
|
||||
<file>strlwr.c</file>
|
||||
<file>strncoll.c</file>
|
||||
<file>strnicmp.c</file>
|
||||
|
|
64
reactos/lib/sdk/crt/string/string.c
Normal file
64
reactos/lib/sdk/crt/string/string.c
Normal file
|
@ -0,0 +1,64 @@
|
|||
/*
|
||||
* PROJECT: ReactOS CRT library
|
||||
* LICENSE: LGPL - See COPYING in the top level directory
|
||||
* FILE: lib/sdk/crt/string/string.c
|
||||
* PURPOSE: string CRT functions
|
||||
* PROGRAMMERS: Wine team
|
||||
* Ported to ReactOS by Christoph von Wittich (christoph_vw@reactos.org)
|
||||
*/
|
||||
|
||||
/*
|
||||
* msvcrt.dll string functions
|
||||
*
|
||||
* Copyright 1996,1998 Marcus Meissner
|
||||
* Copyright 1996 Jukka Iivonen
|
||||
* Copyright 1997,2000 Uwe Bonnes
|
||||
* Copyright 2000 Jon Griffiths
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
|
||||
#include <precomp.h>
|
||||
|
||||
|
||||
/*********************************************************************
|
||||
* strcat_s (MSVCRT.@)
|
||||
*/
|
||||
int CDECL strcat_s( char* dst, size_t elem, const char* src )
|
||||
{
|
||||
size_t i, j;
|
||||
if(!dst) return EINVAL;
|
||||
if(elem == 0) return EINVAL;
|
||||
if(!src)
|
||||
{
|
||||
dst[0] = '\0';
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
for(i = 0; i < elem; i++)
|
||||
{
|
||||
if(dst[i] == '\0')
|
||||
{
|
||||
for(j = 0; (j + i) < elem; j++)
|
||||
{
|
||||
if((dst[j + i] = src[j]) == '\0') return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* Set the first element to 0, not the first element after the skipped part */
|
||||
dst[0] = '\0';
|
||||
return ERANGE;
|
||||
}
|
|
@ -1138,3 +1138,36 @@ INT CDECL wcscpy_s( wchar_t* wcDest, size_t numElement, const wchar_t *wcSrc)
|
|||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
/******************************************************************
|
||||
* wcsncpy_s (MSVCRT.@)
|
||||
*/
|
||||
INT CDECL wcsncpy_s( wchar_t* wcDest, size_t numElement, const wchar_t *wcSrc,
|
||||
size_t count )
|
||||
{
|
||||
size_t size = 0;
|
||||
|
||||
if (!wcDest || !numElement)
|
||||
return EINVAL;
|
||||
|
||||
wcDest[0] = 0;
|
||||
|
||||
if (!wcSrc)
|
||||
{
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
size = min(strlenW(wcSrc), count);
|
||||
|
||||
if (size >= numElement)
|
||||
{
|
||||
return ERANGE;
|
||||
}
|
||||
|
||||
memcpy( wcDest, wcSrc, size*sizeof(WCHAR) );
|
||||
wcDest[size] = '\0';
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue