Magellan Linux

Contents of /trunk/mkinitrd-magellan/klibc/usr/klibc/strlcat.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: 406 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 * strlcat.c
3 */
4
5 #include <string.h>
6 #include <klibc/compiler.h>
7
8 size_t strlcat(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 (bytes < size && *q) {
16 q++;
17 bytes++;
18 }
19 if (bytes == size)
20 return (bytes + strlen(src));
21
22 while ((ch = *p++)) {
23 if (bytes + 1 < size)
24 *q++ = ch;
25
26 bytes++;
27 }
28
29 *q = '\0';
30 return bytes;
31 }