X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=include%2Fafb%2Fafb-binding.h;h=41ce0c521548a9f6b13e2bab394c21172a435a19;hb=69affc2edb055f6cd65fa1d55689272c28446d63;hp=ac63d36b1429938170eeae44e19b780cf8ad1eda;hpb=7059e59cddc1c81321639875636e88895bc14309;p=src%2Fapp-framework-binder.git diff --git a/include/afb/afb-binding.h b/include/afb/afb-binding.h index ac63d36b..41ce0c52 100644 --- a/include/afb/afb-binding.h +++ b/include/afb/afb-binding.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016 "IoT.bzh" + * Copyright (C) 2016, 2017 "IoT.bzh" * Author: José Bollo * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -147,6 +147,8 @@ struct afb_daemon_itf { struct sd_bus *(*get_system_bus)(void *closure); /* gets the common systemd's system d-bus */ void (*vverbose)(void*closure, int level, const char *file, int line, const char *fmt, va_list args); struct afb_event (*event_make)(void *closure, const char *name); /* creates an event of 'name' */ + int (*rootdir_get_fd)(void *closure); + int (*rootdir_open_locale)(void *closure, const char *filename, int flags, const char *locale); }; /* @@ -170,6 +172,23 @@ struct afb_binding_interface /* * Function for registering the binding + * + * A binding V1 MUST have a function of this name and signature. + * This function is called during loading of the binding. It + * receives an 'interface' that should be recorded for later access to + * functions provided by the framework. + * + * This function MUST return the address of a structure that describes + * the binding and its implemented verbs. + * + * In case of initialisation error, NULL must be returned. + * + * Be aware that the given 'interface' is not fully functionnal + * because no provision is given to the name and description + * of the binding. Check the function 'afbBindingV1ServiceInit' + * defined in the file because when + * the function 'afbBindingV1ServiceInit' is called, the 'interface' + * is fully functionnal. */ extern const struct afb_binding *afbBindingV1Register (const struct afb_binding_interface *interface); @@ -205,7 +224,7 @@ static inline struct sd_bus *afb_daemon_get_system_bus(struct afb_daemon daemon) * 'object' can be NULL. * 'daemon' MUST be the daemon given in interface when activating the binding. * - * For conveniency, the function calls 'json_object_put' for 'object'. + * For convenience, the function calls 'json_object_put' for 'object'. * Thus, in the case where 'object' should remain available after * the function returns, the function 'json_object_get' shall be used. * @@ -236,7 +255,7 @@ static inline void afb_daemon_verbose(struct afb_daemon daemon, int level, const { va_list args; va_start(args, fmt); - return daemon.itf->vverbose(daemon.closure, level, file, line, fmt, args); + daemon.itf->vverbose(daemon.closure, level, file, line, fmt, args); va_end(args); } @@ -259,3 +278,23 @@ static inline void afb_daemon_verbose(struct afb_daemon daemon, int level, const # endif #endif +/* + * Get the root directory file descriptor. This file descriptor can + * be used with functions 'openat', 'fstatat', ... + */ +static inline int afb_daemon_rootdir_get_fd(struct afb_daemon daemon) +{ + return daemon.itf->rootdir_get_fd(daemon.closure); +} + +/* + * Opens 'filename' within the root directory with 'flags' (see function openat) + * using the 'locale' definition (example: "jp,en-US") that can be NULL. + * Returns the file descriptor or -1 in case of error. + */ +static inline int afb_daemon_rootdir_open_locale(struct afb_daemon daemon, const char *filename, int flags, const char *locale) +{ + return daemon.itf->rootdir_open_locale(daemon.closure, filename, flags, locale); +} + +