]> git.ipfire.org Git - thirdparty/systemd.git/blob - udev_lib.h
[PATCH] Makefile fix
[thirdparty/systemd.git] / udev_lib.h
1 /*
2 * udev_lib - generic stuff used by udev
3 *
4 * Copyright (C) 2004 Kay Sievers <kay.sievers@vrfy.org>
5 *
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_LIB_H_
23 #define _UDEV_LIB_H_
24
25
26 #define strfieldcpy(to, from) \
27 do { \
28 to[sizeof(to)-1] = '\0'; \
29 strncpy(to, from, sizeof(to)-1); \
30 } while (0)
31
32 #define strfieldcat(to, from) \
33 do { \
34 to[sizeof(to)-1] = '\0'; \
35 strncat(to, from, sizeof(to) - strlen(to)-1); \
36 } while (0)
37
38 #define strfieldcpymax(to, from, maxsize) \
39 do { \
40 to[maxsize-1] = '\0'; \
41 strncpy(to, from, maxsize-1); \
42 } while (0)
43
44 #define strfieldcatmax(to, from, maxsize) \
45 do { \
46 to[maxsize-1] = '\0'; \
47 strncat(to, from, maxsize - strlen(to)-1); \
48 } while (0)
49
50 #define strintcat(to, i) \
51 do { \
52 to[sizeof(to)-1] = '\0'; \
53 snprintf((to) + strlen(to), sizeof(to) - strlen(to)-1, "%u", i); \
54 } while (0)
55
56 #define strintcatmax(to, i, maxsize) \
57 do { \
58 to[maxsize-1] = '\0'; \
59 snprintf((to) + strlen(to), maxsize - strlen(to)-1, "%u", i); \
60 } while (0)
61
62 #define foreach_strpart(str, separator, pos, len) \
63 for(pos = str, len = 0; \
64 (pos) < ((str) + strlen(str)); \
65 pos = pos + len + strspn(pos, separator), len = strcspn(pos, separator)) \
66 if (len > 0)
67
68 #ifdef asmlinkage
69 # undef asmlinkage
70 #endif
71 #ifdef __i386__
72 # define asmlinkage __attribute__((regparm(0)))
73 #endif
74 #ifndef asmlinkage
75 # define asmlinkage /* nothing */
76 #endif
77
78 extern char *get_action(void);
79 extern char *get_devpath(void);
80 extern char *get_devname(void);
81 extern char *get_seqnum(void);
82 extern char *get_subsystem(char *subsystem);
83 extern char get_device_type(const char *path, const char *subsystem);
84 extern int file_map(const char *filename, char **buf, size_t *bufsize);
85 extern void file_unmap(char *buf, size_t bufsize);
86 extern size_t buf_get_line(char *buf, size_t buflen, size_t cur);
87 extern void leading_slash(char *path);
88 extern void no_leading_slash(char *path);
89 extern int call_foreach_file(int fnct(char *f) , char *filename, char *extension);
90 extern int set_cloexec_flag (int desc, int value);
91
92 #endif