summaryrefslogtreecommitdiff
path: root/src/libsystemd/sd-event
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2014-08-28 15:47:39 +0200
committerTom Gundersen <teg@jklm.no>2014-08-28 21:19:17 +0200
commitf7f53e9e6ebb9f656d880f5e779fc174a1d983bf (patch)
tree536c9c216d265f0773dfd4c683b5d1a19cf790de /src/libsystemd/sd-event
parent5968b1c304188e466759b8ba419fc10f150e5541 (diff)
sd-event: allow naming event sources
Diffstat (limited to 'src/libsystemd/sd-event')
-rw-r--r--src/libsystemd/sd-event/sd-event.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/libsystemd/sd-event/sd-event.c b/src/libsystemd/sd-event/sd-event.c
index 32777e386b..a2935abd64 100644
--- a/src/libsystemd/sd-event/sd-event.c
+++ b/src/libsystemd/sd-event/sd-event.c
@@ -66,6 +66,8 @@ struct sd_event_source {
void *userdata;
sd_event_handler_t prepare;
+ char *name;
+
EventSourceType type:5;
int enabled:3;
bool pending:1;
@@ -685,6 +687,7 @@ static void source_free(sd_event_source *s) {
assert(s);
source_disconnect(s);
+ free(s->name);
free(s);
}
@@ -1223,6 +1226,32 @@ _public_ sd_event_source* sd_event_source_unref(sd_event_source *s) {
return NULL;
}
+_public_ int sd_event_source_set_name(sd_event_source *s, const char *name) {
+ char *new_name = NULL;
+
+ assert_return(s, -EINVAL);
+
+ if (name) {
+ new_name = strdup(name);
+ if (!new_name)
+ return -ENOMEM;
+ }
+
+ free(s->name);
+ s->name = new_name;
+
+ return 0;
+}
+
+_public_ int sd_event_source_get_name(sd_event_source *s, const char **name) {
+ assert_return(s, -EINVAL);
+ assert_return(name, -EINVAL);
+
+ *name = s->name;
+
+ return 0;
+}
+
_public_ sd_event *sd_event_source_get_event(sd_event_source *s) {
assert_return(s, NULL);