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: * <>---concatenate strings sl@0: * INDEX sl@0: * strncat sl@0: * ANSI_SYNOPSIS sl@0: * #include sl@0: * char *strncat(char *<[dst]>, const char *<[src]>, size_t <[length]>); sl@0: * TRAD_SYNOPSIS sl@0: * #include sl@0: * char *strncat(<[dst]>, <[src]>, <[length]>) sl@0: * char *<[dst]>; sl@0: * char *<[src]>; sl@0: * size_t <[length]>; sl@0: * <> appends not more than <[length]> characters from sl@0: * the string pointed to by <[src]> (including the terminating sl@0: * null character) to the end of the string pointed to by sl@0: * <[dst]>. The initial character of <[src]> overwrites the null sl@0: * character at the end of <[dst]>. A terminating null character sl@0: * is always appended to the result sl@0: * WARNINGS sl@0: * Note that a null is always appended, so that if the copy is sl@0: * limited by the <[length]> argument, the number of characters sl@0: * appended to <[dst]> is <>. 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: * strncat ansi pure sl@0: * sl@0: * sl@0: */ sl@0: sl@0: sl@0: sl@0: #include sl@0: sl@0: /** sl@0: Append substring to string. sl@0: Appends num characters of src string to dest string. sl@0: If the terminating null-character appears in src string sl@0: before num character have been appended, the function appends sl@0: the null-character to dest and ends. sl@0: The terminating null character in dest is overwritten by the first character of src. sl@0: The resulting string includes a null-character at end. sl@0: @return s1 is returned sl@0: @param s1 Pointer to a null-terminated string with enough space allocated to contain src sl@0: plus num characters. sl@0: @param s2 Null-terminated string containing characters to be appended. sl@0: @param n Number of characters to be appended from src to dest. sl@0: */ sl@0: EXPORT_C char * sl@0: strncat (char *s1, const char *s2, size_t n) sl@0: { sl@0: char *s = s1; sl@0: sl@0: while (*s1) sl@0: s1++; sl@0: while (n-- != 0 && (*s1++ = *s2++)!=0) sl@0: { sl@0: if (n == 0) sl@0: *s1 = '\0'; sl@0: } sl@0: sl@0: return s; sl@0: }