]> git.ipfire.org Git - thirdparty/systemd.git/blame - udev_lib.h
[PATCH] $local user
[thirdparty/systemd.git] / udev_lib.h
CommitLineData
c81b35c0
KS
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
7a947ce5 25#include "udev.h"
c81b35c0
KS
26
27#define strfieldcpy(to, from) \
28do { \
29 to[sizeof(to)-1] = '\0'; \
30 strncpy(to, from, sizeof(to)-1); \
31} while (0)
32
33#define strfieldcat(to, from) \
34do { \
35 to[sizeof(to)-1] = '\0'; \
36 strncat(to, from, sizeof(to) - strlen(to)-1); \
37} while (0)
38
39#define strfieldcpymax(to, from, maxsize) \
40do { \
41 to[maxsize-1] = '\0'; \
42 strncpy(to, from, maxsize-1); \
43} while (0)
44
45#define strfieldcatmax(to, from, maxsize) \
46do { \
47 to[maxsize-1] = '\0'; \
48 strncat(to, from, maxsize - strlen(to)-1); \
49} while (0)
50
51#define strintcat(to, i) \
52do { \
53 to[sizeof(to)-1] = '\0'; \
54 snprintf((to) + strlen(to), sizeof(to) - strlen(to)-1, "%u", i); \
55} while (0)
56
57#define strintcatmax(to, i, maxsize) \
58do { \
59 to[maxsize-1] = '\0'; \
60 snprintf((to) + strlen(to), maxsize - strlen(to)-1, "%u", i); \
61} while (0)
62
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)) \
67 if (len > 0)
68
e5a5b54a
MB
69#ifdef asmlinkage
70# undef asmlinkage
71#endif
72#ifdef __i386__
73# define asmlinkage __attribute__((regparm(0)))
74#endif
75#ifndef asmlinkage
76# define asmlinkage /* nothing */
77#endif
c81b35c0
KS
78
79extern char *get_action(void);
80extern char *get_devpath(void);
4b06c852 81extern char *get_devname(void);
c81b35c0
KS
82extern char *get_seqnum(void);
83extern char *get_subsystem(char *subsystem);
f61d732a 84extern char get_device_type(const char *path, const char *subsystem);
7a947ce5 85extern void udev_set_values(struct udevice *udev, const char* devpath, const char *subsystem);
c81b35c0
KS
86extern int file_map(const char *filename, char **buf, size_t *bufsize);
87extern void file_unmap(char *buf, size_t bufsize);
88extern size_t buf_get_line(char *buf, size_t buflen, size_t cur);
aef6bb13
KS
89extern void leading_slash(char *path);
90extern void no_leading_slash(char *path);
4a539daf 91extern int call_foreach_file(int fnct(char *f) , char *filename, char *extension);
6e3e3c34 92extern int set_cloexec_flag (int desc, int value);
c81b35c0
KS
93
94#endif