ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

string.c
Go to the documentation of this file.
00001 /*
00002  * PROJECT:         ReactOS CRT library
00003  * LICENSE:         LGPL - See COPYING in the top level directory
00004  * FILE:            lib/sdk/crt/string/string.c
00005  * PURPOSE:         string CRT functions
00006  * PROGRAMMERS:     Wine team
00007  *                  Ported to ReactOS by Christoph von Wittich (christoph_vw@reactos.org)
00008  */
00009 
00010 /*
00011  * msvcrt.dll string functions
00012  *
00013  * Copyright 1996,1998 Marcus Meissner
00014  * Copyright 1996 Jukka Iivonen
00015  * Copyright 1997,2000 Uwe Bonnes
00016  * Copyright 2000 Jon Griffiths
00017  *
00018  * This library is free software; you can redistribute it and/or
00019  * modify it under the terms of the GNU Lesser General Public
00020  * License as published by the Free Software Foundation; either
00021  * version 2.1 of the License, or (at your option) any later version.
00022  *
00023  * This library is distributed in the hope that it will be useful,
00024  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00025  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00026  * Lesser General Public License for more details.
00027  *
00028  * You should have received a copy of the GNU Lesser General Public
00029  * License along with this library; if not, write to the Free Software
00030  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
00031  */
00032  
00033 
00034 #include <precomp.h>
00035 
00036 
00037 /*********************************************************************
00038  *      strcat_s (MSVCRT.@)
00039  */
00040 int CDECL strcat_s( char* dst, size_t elem, const char* src )
00041 {
00042     size_t i, j;
00043     if(!dst) return EINVAL;
00044     if(elem == 0) return EINVAL;
00045     if(!src)
00046     {
00047         dst[0] = '\0';
00048         return EINVAL;
00049     }
00050 
00051     for(i = 0; i < elem; i++)
00052     {
00053         if(dst[i] == '\0')
00054         {
00055             for(j = 0; (j + i) < elem; j++)
00056             {
00057                 if((dst[j + i] = src[j]) == '\0') return 0;
00058             }
00059         }
00060     }
00061     /* Set the first element to 0, not the first element after the skipped part */
00062     dst[0] = '\0';
00063     return ERANGE;
00064 }
00065 
00066 /*********************************************************************
00067  *      strcpy_s (MSVCRT.@)
00068  */
00069 int CDECL strcpy_s( char* dst, size_t elem, const char* src )
00070 {
00071     size_t i;
00072     if(!elem) return EINVAL;
00073     if(!dst) return EINVAL;
00074     if(!src)
00075     {
00076         dst[0] = '\0';
00077         return EINVAL;
00078     }
00079 
00080     for(i = 0; i < elem; i++)
00081     {
00082         if((dst[i] = src[i]) == '\0') return 0;
00083     }
00084     dst[0] = '\0';
00085     return ERANGE;
00086 }
00087 

Generated on Sat May 26 2012 04:16:32 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.