aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/afb-evt.c29
-rw-r--r--src/afb-evt.h2
-rw-r--r--src/afb-export.c12
3 files changed, 32 insertions, 11 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)
diff --git a/src/afb-evt.h b/src/afb-evt.h
index 901bfbb2..76152a8b 100644
--- a/src/afb-evt.h
+++ b/src/afb-evt.h
@@ -40,6 +40,7 @@ extern struct afb_evt_listener *afb_evt_listener_addref(struct afb_evt_listener
extern void afb_evt_listener_unref(struct afb_evt_listener *listener);
extern struct afb_evtid *afb_evt_evtid_create(const char *fullname);
+extern struct afb_evtid *afb_evt_evtid_create2(const char *prefix, const char *name);
extern struct afb_evtid *afb_evt_evtid_addref(struct afb_evtid *evtid);
extern struct afb_evtid *afb_evt_evtid_hooked_addref(struct afb_evtid *evtid);
@@ -66,6 +67,7 @@ extern void afb_evt_update_hooks();
extern struct afb_eventid *afb_evt_eventid_create(const char *fullname);
+extern struct afb_eventid *afb_evt_eventid_create2(const char *prefix, const char *name);
extern const char *afb_evt_eventid_fullname(struct afb_eventid *eventid);
extern int afb_evt_eventid_id(struct afb_eventid *eventid);
extern struct afb_eventid *afb_evt_eventid_addref(struct afb_eventid *eventid);
diff --git a/src/afb-export.c b/src/afb-export.c
index 98964bf9..840bd919 100644
--- a/src/afb-export.c
+++ b/src/afb-export.c
@@ -153,8 +153,6 @@ static void old_vverbose_cb(void *closure, int level, const char *file, int line
static struct afb_eventid *eventid_make_cb(void *closure, const char *name)
{
- size_t plen, nlen;
- char *event;
struct afb_export *export = closure;
/* check daemon state */
@@ -164,16 +162,8 @@ static struct afb_eventid *eventid_make_cb(void *closure, const char *name)
return NULL;
}
- /* makes the event name */
- plen = strlen(export->apiname);
- nlen = strlen(name);
- event = alloca(nlen + plen + 2);
- memcpy(event, export->apiname, plen);
- event[plen] = '/';
- memcpy(event + plen + 1, name, nlen + 1);
-
/* create the event */
- return afb_evt_eventid_create(event);
+ return afb_evt_eventid_create2(export->apiname, name);
}
static struct afb_event event_make_cb(void *closure, const char *name)