chiark / gitweb /
move udevmonitor to /usr/sbin
[elogind.git] / udev_libc_wrapper.h
1 /*
2  * udev_libc_wrapper - wrapping of functions missing in a specific libc
3  *                     or not working in a statically compiled binary
4  *
5  * Copyright (C) 2005 Kay Sievers <kay.sievers@vrfy.org>
6  *
7  *      This program is free software; you can redistribute it and/or modify it
8  *      under the terms of the GNU General Public License as published by the
9  *      Free Software Foundation version 2 of the License.
10  * 
11  *      This program is distributed in the hope that it will be useful, but
12  *      WITHOUT ANY WARRANTY; without even the implied warranty of
13  *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  *      General Public License for more details.
15  * 
16  *      You should have received a copy of the GNU General Public License along
17  *      with this program; if not, write to the Free Software Foundation, Inc.,
18  *      675 Mass Ave, Cambridge, MA 02139, USA.
19  *
20  */
21
22 #ifndef _UDEV_LIBC_WRAPPER_H_
23 #define _UDEV_LIBC_WRAPPER_H_
24
25 #include <string.h>
26 #include <unistd.h>
27 #include <linux/types.h>
28
29 /* needed for our signal handlers to work */
30 #undef asmlinkage
31 #ifdef __i386__
32 #define asmlinkage      __attribute__((regparm(0)))
33 #else
34 #define asmlinkage
35 #endif
36
37 /* headers are broken on some lazy platforms */
38 #ifndef __FD_SET
39 #define __FD_SET(d, set) ((set)->fds_bits[__FDELT(d)] |= __FDMASK(d))
40 #endif
41 #ifndef __FD_CLR
42 #define __FD_CLR(d, set) ((set)->fds_bits[__FDELT(d)] &= ~__FDMASK(d))
43 #endif
44 #ifndef __FD_ISSET
45 #define __FD_ISSET(d, set) (((set)->fds_bits[__FDELT(d)] & __FDMASK(d)) != 0)
46 #endif
47 #ifndef __FD_ZERO
48 #define __FD_ZERO(set) ((void) memset ((void*) (set), 0, sizeof (fd_set)))
49 #endif
50
51 /* missing in some lazy distros */
52 #ifndef NETLINK_KOBJECT_UEVENT
53 #define NETLINK_KOBJECT_UEVENT 15
54 #endif
55
56 #ifdef __KLIBC__
57 static inline int clearenv(void)
58 {
59         environ[0] = NULL;
60         return 0;
61 }
62 #endif
63
64 extern uid_t lookup_user(const char *user);
65 extern gid_t lookup_group(const char *group);
66
67 extern size_t strlcpy(char *dst, const char *src, size_t size);
68 extern size_t strlcat(char *dst, const char *src, size_t size);
69
70 #endif /* _UDEV_LIBC_WRAPPER_H_ */