]> git.proxmox.com Git - mirror_lxc.git/blob - src/include/strlcat.c
spelling: output
[mirror_lxc.git] / src / include / strlcat.c
1 /* liblxcapi
2 *
3 * Copyright © 2018 Christian Brauner <christian@brauner.io>.
4 * Copyright © 2018 Canonical Ltd.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2, as
8 * published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * This function has been copied from musl.
20 */
21
22 #include <limits.h>
23 #include <stdint.h>
24 #include <string.h>
25
26 #ifndef HAVE_STRLCPY
27 #include "strlcpy.h"
28 #endif
29
30 size_t strlcat(char *d, const char *s, size_t n)
31 {
32 size_t l = strnlen(d, n);
33 if (l == n)
34 return l + strlen(s);
35
36 return l + strlcpy(d + l, s, n - l);
37 }