Renamed files, updated header comments
[transsip-mirror.git] / src / strlcpy.c
blob6ca8f670672ede267c5da81fa55a4a960f02d278
1 /*
2 * transsip - the telephony network
3 * By Daniel Borkmann <daniel@transsip.org>
4 * Copyright 2011 Daniel Borkmann <dborkma@tik.ee.ethz.ch>,
5 * Swiss federal institute of technology (ETH Zurich)
6 * Subject to the GPL, version 2.
7 */
9 /*
10 * Copyright (C) 1991, 1992 Linus Torvalds
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or (at
15 * your option) any later version.
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
19 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
20 * for more details.
22 * You should have received a copy of the GNU General Public License along
23 * with this program; if not, write to the Free Software Foundation, Inc.,
24 * 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
27 #include <string.h>
29 #include "strlcpy.h"
31 size_t strlcpy(char *dest, const char *src, size_t size)
33 size_t ret = strlen(src);
35 if (size) {
36 size_t len = (ret >= size) ? size - 1 : ret;
37 memcpy(dest, src, len);
38 dest[len] = '\0';
41 return ret;