cleaned up stuff, added dht lib
[netyack.git] / src / strlcpy.c
blob471d11fdbe1b39063399ce9d248c507da802892e
1 /*
2 * netyack
3 * By Daniel Borkmann <daniel@netyack.org>
4 * Copyright 2009, 2010 Daniel Borkmann.
5 * Subject to the GPL.
6 */
8 /*
9 * Copyright (C) 1991, 1992 Linus Torvalds
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or (at
14 * your option) any later version.
16 * This program is distributed in the hope that it will be useful, but
17 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
18 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19 * for more details.
21 * You should have received a copy of the GNU General Public License along
22 * with this program; if not, write to the Free Software Foundation, Inc.,
23 * 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
26 #include <string.h>
28 #include "strlcpy.h"
30 size_t strlcpy(char *dest, const char *src, size_t size)
32 size_t ret = strlen(src);
34 if (size) {
35 size_t len = (ret >= size) ? size - 1 : ret;
36 memcpy(dest, src, len);
37 dest[len] = '\0';
40 return ret;