Line data Source code
1 : /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
2 :
3 : #pragma once
4 :
5 : /***
6 : This file is part of systemd.
7 :
8 : Copyright 2014-2015 Tom Gundersen <teg@jklm.no>
9 :
10 : systemd is free software; you can redistribute it and/or modify it
11 : under the terms of the GNU Lesser General Public License as published by
12 : the Free Software Foundation; either version 2.1 of the License, or
13 : (at your option) any later version.
14 :
15 : systemd is distributed in the hope that it will be useful, but
16 : WITHOUT ANY WARRANTY; without even the implied warranty of
17 : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 : Lesser General Public License for more details.
19 :
20 : You should have received a copy of the GNU Lesser General Public License
21 : along with systemd; If not, see <http://www.gnu.org/licenses/>.
22 : ***/
23 :
24 : #include "util.h"
25 :
26 1145 : DEFINE_TRIVIAL_CLEANUP_FUNC(sd_device*, sd_device_unref);
27 : #define _cleanup_device_unref_ _cleanup_(sd_device_unrefp)
28 :
29 10 : DEFINE_TRIVIAL_CLEANUP_FUNC(sd_device_enumerator*, sd_device_enumerator_unref);
30 : #define _cleanup_device_enumerator_unref_ _cleanup_(sd_device_enumerator_unrefp)
31 :
32 : #define FOREACH_DEVICE_PROPERTY(device, key, value) \
33 : for (key = sd_device_get_property_first(device, &(value)); \
34 : key; \
35 : key = sd_device_get_property_next(device, &(value)))
36 :
37 : #define FOREACH_DEVICE_TAG(device, tag) \
38 : for (tag = sd_device_get_tag_first(device); \
39 : tag; \
40 : tag = sd_device_get_tag_next(device))
41 :
42 : #define FOREACH_DEVICE_SYSATTR(device, attr) \
43 : for (attr = sd_device_get_sysattr_first(device); \
44 : attr; \
45 : attr = sd_device_get_sysattr_next(device))
46 :
47 : #define FOREACH_DEVICE_DEVLINK(device, devlink) \
48 : for (devlink = sd_device_get_devlink_first(device); \
49 : devlink; \
50 : devlink = sd_device_get_devlink_next(device))
51 :
52 : #define FOREACH_DEVICE(enumerator, device) \
53 : for (device = sd_device_enumerator_get_device_first(enumerator); \
54 : device; \
55 : device = sd_device_enumerator_get_device_next(enumerator))
56 :
57 : #define FOREACH_SUBSYSTEM(enumerator, device) \
58 : for (device = sd_device_enumerator_get_subsystem_first(enumerator); \
59 : device; \
60 : device = sd_device_enumerator_get_subsystem_next(enumerator))
|