2 * udev_lib - generic stuff used by udev
4 * Copyright (C) 2004 Kay Sievers <kay.sievers@vrfy.org>
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.
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.
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.
27 #define strfieldcpy(to, from) \
29 to[sizeof(to)-1] = '\0'; \
30 strncpy(to, from, sizeof(to)-1); \
33 #define strfieldcat(to, from) \
35 to[sizeof(to)-1] = '\0'; \
36 strncat(to, from, sizeof(to) - strlen(to)-1); \
39 #define strfieldcpymax(to, from, maxsize) \
41 to[maxsize-1] = '\0'; \
42 strncpy(to, from, maxsize-1); \
45 #define strfieldcatmax(to, from, maxsize) \
47 to[maxsize-1] = '\0'; \
48 strncat(to, from, maxsize - strlen(to)-1); \
51 #define strintcat(to, i) \
53 to[sizeof(to)-1] = '\0'; \
54 snprintf((to) + strlen(to), sizeof(to) - strlen(to)-1, "%u", i); \
57 #define strintcatmax(to, i, maxsize) \
59 to[maxsize-1] = '\0'; \
60 snprintf((to) + strlen(to), maxsize - strlen(to)-1, "%u", i); \
63 #define foreach_strpart(str, separator, pos, len) \
64 for(pos = str, len = 0; \
65 (pos) < ((str) + strlen(str)); \
66 pos = pos + len + strspn(pos, separator), len = strcspn(pos, separator)) \
73 # define asmlinkage __attribute__((regparm(0)))
76 # define asmlinkage /* nothing */
79 extern void udev_set_values(struct udevice *udev, const char* devpath,
80 const char *subsystem, const char* action);
81 extern int kernel_release_satisfactory(int version, int patchlevel, int sublevel);
82 extern int create_path(const char *path);
83 extern int file_map(const char *filename, char **buf, size_t *bufsize);
84 extern void file_unmap(char *buf, size_t bufsize);
85 extern size_t buf_get_line(char *buf, size_t buflen, size_t cur);
86 extern void no_trailing_slash(char *path);
87 typedef int (*file_fnct_t)(const char *filename, void *data);
88 extern int call_foreach_file(file_fnct_t fnct, const char *dirname,
89 const char *suffix, void *data);