mirror of
https://github.com/reactos/reactos.git
synced 2025-06-20 01:35:22 +00:00
Create a branch for header work.
svn path=/branches/header-work/; revision=45691
This commit is contained in:
parent
14fe274b1c
commit
9ea495ba33
19538 changed files with 0 additions and 1063950 deletions
87
lib/sdk/crt/string/string.c
Normal file
87
lib/sdk/crt/string/string.c
Normal file
|
@ -0,0 +1,87 @@
|
|||
/*
|
||||
* 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;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* strcpy_s (MSVCRT.@)
|
||||
*/
|
||||
int CDECL strcpy_s( char* dst, size_t elem, const char* src )
|
||||
{
|
||||
size_t i;
|
||||
if(!elem) return EINVAL;
|
||||
if(!dst) return EINVAL;
|
||||
if(!src)
|
||||
{
|
||||
dst[0] = '\0';
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
for(i = 0; i < elem; i++)
|
||||
{
|
||||
if((dst[i] = src[i]) == '\0') return 0;
|
||||
}
|
||||
dst[0] = '\0';
|
||||
return ERANGE;
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue