Magellan Linux

Contents of /trunk/mkinitrd-magellan/klibc/usr/klibc/strlcpy.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 532 - (show annotations) (download)
Sat Sep 1 22:45:15 2007 UTC (16 years, 8 months ago) by niro
File MIME type: text/plain
File size: 373 byte(s)
-import if magellan mkinitrd; it is a fork of redhats mkinitrd-5.0.8 with all magellan patches and features; deprecates magellan-src/mkinitrd

1 /*
2 * strlcpy.c
3 */
4
5 #include <string.h>
6 #include <klibc/compiler.h>
7
8 size_t strlcpy(char *dst, const char *src, size_t size)
9 {
10 size_t bytes = 0;
11 char *q = dst;
12 const char *p = src;
13 char ch;
14
15 while ((ch = *p++)) {
16 if (bytes + 1 < size)
17 *q++ = ch;
18
19 bytes++;
20 }
21
22 /* If size == 0 there is no space for a final null... */
23 if (size)
24 *q = '\0';
25
26 return bytes;
27 }