os/ossrv/genericopenlibs/cstdlib/LCHAR/STRNCAT.C
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/ossrv/genericopenlibs/cstdlib/LCHAR/STRNCAT.C	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,81 @@
     1.4 +/*
     1.5 +* Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.6 +* All rights reserved.
     1.7 +* This component and the accompanying materials are made available
     1.8 +* under the terms of "Eclipse Public License v1.0"
     1.9 +* which accompanies this distribution, and is available
    1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.11 +*
    1.12 +* Initial Contributors:
    1.13 +* Nokia Corporation - initial contribution.
    1.14 +*
    1.15 +* Contributors:
    1.16 +*
    1.17 +* Description:
    1.18 +* FUNCTION
    1.19 +* <<strncat>>---concatenate strings
    1.20 +* INDEX
    1.21 +* strncat
    1.22 +* ANSI_SYNOPSIS
    1.23 +* #include <string.h>
    1.24 +* char *strncat(char *<[dst]>, const char *<[src]>, size_t <[length]>);
    1.25 +* TRAD_SYNOPSIS
    1.26 +* #include <string.h>
    1.27 +* char *strncat(<[dst]>, <[src]>, <[length]>)
    1.28 +* char *<[dst]>;
    1.29 +* char *<[src]>;
    1.30 +* size_t <[length]>;
    1.31 +* <<strncat>> appends not more than <[length]> characters from
    1.32 +* the string pointed to by <[src]> (including the	terminating
    1.33 +* null character) to the end of the string pointed to by
    1.34 +* <[dst]>.  The initial character of <[src]> overwrites the null
    1.35 +* character at the end of <[dst]>.  A terminating null character
    1.36 +* is always appended to the result
    1.37 +* WARNINGS
    1.38 +* Note that a null is always appended, so that if the copy is
    1.39 +* limited by the <[length]> argument, the number of characters
    1.40 +* appended to <[dst]> is <<n + 1>>.
    1.41 +* RETURNS
    1.42 +* This function returns the initial value of <[dst]>
    1.43 +* PORTABILITY
    1.44 +* <<strncat>> is ANSI C.
    1.45 +* <<strncat>> requires no supporting OS subroutines.
    1.46 +* QUICKREF
    1.47 +* strncat ansi pure
    1.48 +* 
    1.49 +*
    1.50 +*/
    1.51 +
    1.52 +
    1.53 +
    1.54 +#include <string.h>
    1.55 +
    1.56 +/**
    1.57 +Append substring to string.
    1.58 +Appends num characters of src string to dest string. 
    1.59 +If the terminating null-character appears in src string 
    1.60 +before num character have been appended, the function appends 
    1.61 +the null-character to dest and ends.
    1.62 +The terminating null character in dest is overwritten by the first character of src.
    1.63 +The resulting string includes a null-character at end.
    1.64 +@return s1 is returned
    1.65 +@param s1 Pointer to a null-terminated string with enough space allocated to contain src
    1.66 +plus num characters. 
    1.67 +@param s2 Null-terminated string containing characters to be appended. 
    1.68 +@param n Number of characters to be appended from src to dest.
    1.69 +*/
    1.70 +EXPORT_C char *
    1.71 +strncat (char *s1, const char *s2, size_t n)
    1.72 +{
    1.73 +  char *s = s1;
    1.74 +
    1.75 +  while (*s1)
    1.76 +    s1++;
    1.77 +  while (n-- != 0 && (*s1++ = *s2++)!=0)
    1.78 +    {
    1.79 +      if (n == 0)
    1.80 +	*s1 = '\0';
    1.81 +    }
    1.82 +
    1.83 +  return s;
    1.84 +}