X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fafb-apiset.c;h=ae1d9460bfa44ecea0de8a5577978ff94c81722b;hb=ac7a95223a6314cca6250495ea59c3cf7e46e89e;hp=967cd68ad0cb6b4a2e9ecec8e7fa13a6d4c9ef9b;hpb=2e83db0375d44c0b05742e787f6abd4127e2aac8;p=src%2Fapp-framework-binder.git diff --git a/src/afb-apiset.c b/src/afb-apiset.c index 967cd68a..ae1d9460 100644 --- a/src/afb-apiset.c +++ b/src/afb-apiset.c @@ -29,7 +29,6 @@ #include "afb-apiset.h" #include "afb-context.h" #include "afb-xreq.h" -#include "jobs.h" #define INCR 8 /* CAUTION: must be a power of 2 */ @@ -289,8 +288,8 @@ int afb_apiset_del(struct afb_apiset *set, const char *name) * Get from the 'set' the API of 'name' in 'api' with fallback to subset or default api * @param set the set of API * @param name the name of the API to get - * @param api the structure where to store data about the API of name - * @return 0 in case of success or -1 in case of error + * @param rec if not zero look also recursively in subsets + * @return the api pointer in case of success or NULL in case of error */ static struct api_desc *lookup(struct afb_apiset *set, const char *name, int rec) { @@ -303,7 +302,7 @@ static struct api_desc *lookup(struct afb_apiset *set, const char *name, int rec * @param set the set of API * @param name the name of the API to get * @param rec if not zero look also recursively in subsets - * @return 0 in case of success or -1 in case of error + * @return the api pointer in case of success or NULL in case of error */ const struct afb_api *afb_apiset_lookup(struct afb_apiset *set, const char *name, int rec) { @@ -316,18 +315,6 @@ const struct afb_api *afb_apiset_lookup(struct afb_apiset *set, const char *name return NULL; } -/** - * Check whether the 'set' has the API of 'name' - * @param set the set of API - * @param name the name of the API to get - * @param rec if not zero look also recursively in subsets - * @return 1 if the api exist or 0 otherwise - */ -int afb_apiset_has(struct afb_apiset *set, const char *name, int rec) -{ - return !!afb_apiset_lookup(set, name, rec); -} - /** * Starts the service 'api'. * @param api the api @@ -430,7 +417,7 @@ int afb_apiset_start_all_services(struct afb_apiset *set, int share_session) return rc; i++; } - + return set->subset ? afb_apiset_start_all_services(set->subset, share_session) : 0; } @@ -552,11 +539,21 @@ const char **afb_apiset_get_names(struct afb_apiset *set) * @param callback the function to call for each name * @param closure the closure for the callback */ -void afb_apiset_enum(struct afb_apiset *set, void (*callback)(struct afb_apiset *set, const char *name, void *closure), void *closure) +void afb_apiset_enum(struct afb_apiset *set, int rec, void (*callback)(struct afb_apiset *set, const char *name, void *closure), void *closure) { - int i; + struct afb_apiset *iset; + struct api_desc *i, *e; - for (i = 0 ; i < set->count ; i++) - callback(set, set->apis[i].name, closure); + iset = set; + while (iset) { + i = iset->apis; + e = &i[iset->count]; + while (i != e) { + if (lookup(set, i->name, 1) == i) + callback(iset, i->name, closure); + i++; + } + iset = rec ? iset->subset : NULL; + } }