usbmodeswitch: Updated to v.1.2.6 from shibby's branch.
[tomato.git] / release / src / router / udev / udev_sysdeps.c
blob9447cca9369054dd1fb53b1235e0114f91792f83
1 /*
2 * Copyright (C) 2003 Greg Kroah-Hartman <greg@kroah.com>
3 * Copyright (C) 2005-2006 Kay Sievers <kay.sievers@vrfy.org>
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation version 2 of the License.
8 *
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 #include <stdlib.h>
21 #include <stdio.h>
22 #include <string.h>
23 #include <ctype.h>
24 #include <fcntl.h>
25 #include <errno.h>
26 #include <sys/types.h>
28 #include "udev.h"
30 #ifdef __GLIBC__
31 size_t strlcpy(char *dst, const char *src, size_t size)
33 size_t bytes = 0;
34 char *q = dst;
35 const char *p = src;
36 char ch;
38 while ((ch = *p++)) {
39 if (bytes+1 < size)
40 *q++ = ch;
41 bytes++;
44 /* If size == 0 there is no space for a final null... */
45 if (size)
46 *q = '\0';
47 return bytes;
50 size_t strlcat(char *dst, const char *src, size_t size)
52 size_t bytes = 0;
53 char *q = dst;
54 const char *p = src;
55 char ch;
57 while (bytes < size && *q) {
58 q++;
59 bytes++;
61 if (bytes == size)
62 return (bytes + strlen(src));
64 while ((ch = *p++)) {
65 if (bytes+1 < size)
66 *q++ = ch;
67 bytes++;
70 *q = '\0';
71 return bytes;
73 #endif /* __GLIBC__ */