summaryrefslogtreecommitdiff
path: root/dbus.h
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2010-04-10 17:38:58 +0200
committerLennart Poettering <lennart@poettering.net>2010-04-10 18:00:27 +0200
commit6f4706b79e37754c83677e81396e783dde243b39 (patch)
tree5f49ef66202cb26e57ab36964b81c233335f9c54 /dbus.h
parentb152adec93b05c0d01b240e0f28326eb1d8e18e9 (diff)
dbus: add generic DEFINE_BUS_PROPERTY_APPEND_ENUM() macro for enum properties
Diffstat (limited to 'dbus.h')
-rw-r--r--dbus.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/dbus.h b/dbus.h
index 1e71971f05..06b7e20602 100644
--- a/dbus.h
+++ b/dbus.h
@@ -86,4 +86,21 @@ void bus_unit_send_removed_signal(Unit *u);
void bus_job_send_change_signal(Job *j);
void bus_job_send_removed_signal(Job *j);
+#define DEFINE_BUS_PROPERTY_APPEND_ENUM(function,name,type) \
+ static int function(Manager *m, DBusMessageIter *i, const char *property, void *data) { \
+ const char *value; \
+ type *field = data; \
+ \
+ assert(m); \
+ assert(i); \
+ assert(property); \
+ \
+ value = name##_to_string(*field); \
+ \
+ if (!dbus_message_iter_append_basic(i, DBUS_TYPE_STRING, &value)) \
+ return -ENOMEM; \
+ \
+ return 0; \
+ }
+
#endif