sl@0
|
1 |
/*
|
sl@0
|
2 |
* Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
3 |
* All rights reserved.
|
sl@0
|
4 |
* This component and the accompanying materials are made available
|
sl@0
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
sl@0
|
6 |
* which accompanies this distribution, and is available
|
sl@0
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
8 |
*
|
sl@0
|
9 |
* Initial Contributors:
|
sl@0
|
10 |
* Nokia Corporation - initial contribution.
|
sl@0
|
11 |
*
|
sl@0
|
12 |
* Contributors:
|
sl@0
|
13 |
*
|
sl@0
|
14 |
* Description:
|
sl@0
|
15 |
* FUNCTION
|
sl@0
|
16 |
* <<strncat>>---concatenate strings
|
sl@0
|
17 |
* INDEX
|
sl@0
|
18 |
* strncat
|
sl@0
|
19 |
* ANSI_SYNOPSIS
|
sl@0
|
20 |
* #include <string.h>
|
sl@0
|
21 |
* char *strncat(char *<[dst]>, const char *<[src]>, size_t <[length]>);
|
sl@0
|
22 |
* TRAD_SYNOPSIS
|
sl@0
|
23 |
* #include <string.h>
|
sl@0
|
24 |
* char *strncat(<[dst]>, <[src]>, <[length]>)
|
sl@0
|
25 |
* char *<[dst]>;
|
sl@0
|
26 |
* char *<[src]>;
|
sl@0
|
27 |
* size_t <[length]>;
|
sl@0
|
28 |
* <<strncat>> appends not more than <[length]> characters from
|
sl@0
|
29 |
* the string pointed to by <[src]> (including the terminating
|
sl@0
|
30 |
* null character) to the end of the string pointed to by
|
sl@0
|
31 |
* <[dst]>. The initial character of <[src]> overwrites the null
|
sl@0
|
32 |
* character at the end of <[dst]>. A terminating null character
|
sl@0
|
33 |
* is always appended to the result
|
sl@0
|
34 |
* WARNINGS
|
sl@0
|
35 |
* Note that a null is always appended, so that if the copy is
|
sl@0
|
36 |
* limited by the <[length]> argument, the number of characters
|
sl@0
|
37 |
* appended to <[dst]> is <<n + 1>>.
|
sl@0
|
38 |
* RETURNS
|
sl@0
|
39 |
* This function returns the initial value of <[dst]>
|
sl@0
|
40 |
* PORTABILITY
|
sl@0
|
41 |
* <<strncat>> is ANSI C.
|
sl@0
|
42 |
* <<strncat>> requires no supporting OS subroutines.
|
sl@0
|
43 |
* QUICKREF
|
sl@0
|
44 |
* strncat ansi pure
|
sl@0
|
45 |
*
|
sl@0
|
46 |
*
|
sl@0
|
47 |
*/
|
sl@0
|
48 |
|
sl@0
|
49 |
|
sl@0
|
50 |
|
sl@0
|
51 |
#include <string.h>
|
sl@0
|
52 |
|
sl@0
|
53 |
/**
|
sl@0
|
54 |
Append substring to string.
|
sl@0
|
55 |
Appends num characters of src string to dest string.
|
sl@0
|
56 |
If the terminating null-character appears in src string
|
sl@0
|
57 |
before num character have been appended, the function appends
|
sl@0
|
58 |
the null-character to dest and ends.
|
sl@0
|
59 |
The terminating null character in dest is overwritten by the first character of src.
|
sl@0
|
60 |
The resulting string includes a null-character at end.
|
sl@0
|
61 |
@return s1 is returned
|
sl@0
|
62 |
@param s1 Pointer to a null-terminated string with enough space allocated to contain src
|
sl@0
|
63 |
plus num characters.
|
sl@0
|
64 |
@param s2 Null-terminated string containing characters to be appended.
|
sl@0
|
65 |
@param n Number of characters to be appended from src to dest.
|
sl@0
|
66 |
*/
|
sl@0
|
67 |
EXPORT_C char *
|
sl@0
|
68 |
strncat (char *s1, const char *s2, size_t n)
|
sl@0
|
69 |
{
|
sl@0
|
70 |
char *s = s1;
|
sl@0
|
71 |
|
sl@0
|
72 |
while (*s1)
|
sl@0
|
73 |
s1++;
|
sl@0
|
74 |
while (n-- != 0 && (*s1++ = *s2++)!=0)
|
sl@0
|
75 |
{
|
sl@0
|
76 |
if (n == 0)
|
sl@0
|
77 |
*s1 = '\0';
|
sl@0
|
78 |
}
|
sl@0
|
79 |
|
sl@0
|
80 |
return s;
|
sl@0
|
81 |
}
|