sl@0: /* sl@0: * Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: * All rights reserved. sl@0: * This component and the accompanying materials are made available sl@0: * under the terms of "Eclipse Public License v1.0" sl@0: * which accompanies this distribution, and is available sl@0: * at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: * sl@0: * Initial Contributors: sl@0: * Nokia Corporation - initial contribution. sl@0: * sl@0: * Contributors: sl@0: * sl@0: * Description: sl@0: * FUNCTION sl@0: * <>---copy string sl@0: * INDEX sl@0: * strcpy sl@0: * ANSI_SYNOPSIS sl@0: * #include sl@0: * char *strcpy(char *<[dst]>, const char *<[src]>); sl@0: * TRAD_SYNOPSIS sl@0: * #include sl@0: * char *strcpy(<[dst]>, <[src]>) sl@0: * char *<[dst]>; sl@0: * char *<[src]>; sl@0: * <> copies the string pointed to by <[src]> sl@0: * (including the terminating null character) to the array sl@0: * pointed to by <[dst]>. sl@0: * RETURNS sl@0: * This function returns the initial value of <[dst]>. sl@0: * PORTABILITY sl@0: * <> is ANSI C. sl@0: * <> requires no supporting OS subroutines. sl@0: * QUICKREF sl@0: * strcpy ansi pure sl@0: * sl@0: * sl@0: */ sl@0: sl@0: sl@0: sl@0: #include sl@0: #include sl@0: sl@0: /*SUPPRESS 560*/ sl@0: /*SUPPRESS 530*/ sl@0: sl@0: /** sl@0: Copy string. sl@0: Copies the content pointed by src to dest stopping after the terminating null-character is copied. sl@0: dest should have enough memory space allocated to contain src string. sl@0: @return des is returned sl@0: @param s1 Destination string. Should be enough long to contain s2. sl@0: @param s2 Null-terminated string to copy. sl@0: */ sl@0: EXPORT_C char * sl@0: strcpy (char *s1, const char *s2) sl@0: { sl@0: char *s = s1; sl@0: while ((*s1++ = *s2++)!=0); sl@0: return s; sl@0: } sl@0: sl@0: /** sl@0: Copy the wide-character string pointed to by s2 (including the terminating null sl@0: wide-character code) into the array pointed to by s1. sl@0: @return s1 sl@0: @param s1 wide-character string sl@0: @param s2 wide-character string sl@0: */ sl@0: EXPORT_C wchar_t * wcscpy (wchar_t *s1, const wchar_t *s2) sl@0: { sl@0: wchar_t *s = s1; sl@0: sl@0: while ((*s1++ = *s2++)!=L'\0') sl@0: ; sl@0: sl@0: return s; sl@0: } sl@0: sl@0: /** sl@0: Function shall return a pointer to a new string, sl@0: which is a duplicate of the string pointed to by str. sl@0: @return a pointer to a new string sl@0: @param str string sl@0: */ sl@0: EXPORT_C char * strdup (const char *str) sl@0: { sl@0: size_t len = strlen (str) + 1; sl@0: char *copy = (char *)malloc (len); sl@0: if (copy) sl@0: { sl@0: memcpy (copy, str, len); sl@0: } sl@0: return copy; sl@0: } sl@0: sl@0: EXPORT_C wchar_t * wcsdup (const wchar_t *str) sl@0: { sl@0: size_t len = wcslen(str) + 1; sl@0: wchar_t *copy; sl@0: sl@0: len *= sizeof(wchar_t); sl@0: copy = (wchar_t *)malloc (len); sl@0: if (copy) sl@0: { sl@0: memcpy (copy, str, len); sl@0: } sl@0: return copy; sl@0: }