diff options
author | José Bollo <jose.bollo@iot.bzh> | 2018-01-31 17:15:27 +0100 |
---|---|---|
committer | José Bollo <jose.bollo@iot.bzh> | 2018-01-31 17:17:16 +0100 |
commit | a3245aed48dca435b437089bc81353da352fc0ce (patch) | |
tree | 99b0751a499b20d5396ff8e98d02647cce93249e /src/afb-evt.c | |
parent | 3535d4cb73628c720da1bf74627ded2aec6f2ca1 (diff) |
afb-evt: Add event creation with prefix
Change-Id: I2fd35e8ed59c28f4283be698a2586cdae5f7c8cf
Signed-off-by: José Bollo <jose.bollo@iot.bzh>
Diffstat (limited to 'src/afb-evt.c')
-rw-r--r-- | src/afb-evt.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/afb-evt.c b/src/afb-evt.c index 9937c1a6..0f24b8e9 100644 --- a/src/afb-evt.c +++ b/src/afb-evt.c @@ -352,6 +352,26 @@ error: } /* + * Creates an event of name 'prefix'/'name' and returns it or NULL on error. + */ +struct afb_evtid *afb_evt_evtid_create2(const char *prefix, const char *name) +{ + size_t prelen, postlen; + char *fullname; + + /* makes the event fullname */ + prelen = strlen(prefix); + postlen = strlen(name); + fullname = alloca(prelen + postlen + 2); + memcpy(fullname, prefix, prelen); + fullname[prelen] = '/'; + memcpy(fullname + prelen + 1, name, postlen + 1); + + /* create the event */ + return afb_evt_evtid_create(fullname); +} + +/* * increment the reference count of the event 'evtid' */ struct afb_evtid *afb_evt_evtid_addref(struct afb_evtid *evtid) @@ -654,6 +674,15 @@ struct afb_eventid *afb_evt_eventid_create(const char *fullname) } /* + * Creates an event of name 'prefix'/'name' and returns it. + * Returns an event with closure==NULL in case of error. + */ +struct afb_eventid *afb_evt_eventid_create2(const char *prefix, const char *name) +{ + return afb_evt_eventid_from_evtid(afb_evt_evtid_create2(prefix, name)); +} + +/* * Returns the fullname of the 'eventid' */ const char *afb_evt_eventid_fullname(struct afb_eventid *eventid) |