X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fafb-evt.c;h=6b94ce8c78e9b16d9b6eda4a9ca250a534aa36bf;hb=c8558c8a28966110aa3a356f95d3c60afe32b64a;hp=18f4bca66388816e37e2e9fdfd5852bcf52e93fc;hpb=7682c2aacb3efd6abed3dee43f8a03d7646d8153;p=src%2Fapp-framework-binder.git diff --git a/src/afb-evt.c b/src/afb-evt.c index 18f4bca6..6b94ce8c 100644 --- a/src/afb-evt.c +++ b/src/afb-evt.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015, 2016, 2017 "IoT.bzh" + * Copyright (C) 2015-2018 "IoT.bzh" * Author José Bollo * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -351,6 +351,26 @@ error: return NULL; } +/* + * 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' */ @@ -653,6 +673,15 @@ struct afb_eventid *afb_evt_eventid_create(const char *fullname) return afb_evt_eventid_from_evtid(afb_evt_evtid_create(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' */ @@ -738,3 +767,12 @@ void afb_evt_eventid_unref(struct afb_eventid *eventid) if (evtid) afb_evt_evtid_unref(evtid); } + +struct afb_eventid *afb_evt_eventid_addref(struct afb_eventid *eventid) +{ + struct afb_evtid *evtid = afb_evt_eventid_to_evtid(eventid); + if (evtid) + afb_evt_evtid_addref(evtid); + return eventid; +} +