microblaze: added processor reference guide
[ana-net.git] / app / strlcpy.c
blobcb47830fe58c84b07b2df59c6eb36dce6d910cf4
1 /*
2 * Lightweight Autonomic Network Architecture
3 * Copyright 2011 Daniel Borkmann <dborkma@tik.ee.ethz.ch>,
4 * Swiss federal institute of technology (ETH Zurich)
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;