X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=include%2Fafb%2Fafb-binding-v2.h;h=e763f1cff300650e5de32d4fa35fd87aabaedd65;hb=6f1126ae2c585afc34d0bb06f3763e3a82ee3d37;hp=f0806a7a6bc2fe64fc5bd5c80190a83040c8b624;hpb=c9ba2ce49808a19a4ef982280a46256797b830ae;p=src%2Fapp-framework-binder.git diff --git a/include/afb/afb-binding-v2.h b/include/afb/afb-binding-v2.h index f0806a7a..e763f1cf 100644 --- a/include/afb/afb-binding-v2.h +++ b/include/afb/afb-binding-v2.h @@ -17,17 +17,17 @@ #pragma once -struct afb_binding_interface; -struct afb_service; -struct json_object; +#include -/* - * A binding V2 MUST have an exported symbol of name - * - * afbBindingV2 - * - */ -extern const struct afb_binding_v2 afbBindingV2; +#include "afb-auth.h" +#include "afb-req-itf.h" +#include "afb-event-itf.h" +#include "afb-service-common.h" +#include "afb-daemon-common.h" + +#include "afb-session-v2.h" + +struct json_object; /* * Description of one verb of the API provided by the binding @@ -37,8 +37,8 @@ struct afb_verb_v2 { const char *verb; /* name of the verb */ void (*callback)(struct afb_req req); /* callback function implementing the verb */ - const char * const *permissions; /* required permissions */ - enum afb_session_v1 session; /* authorisation and session requirements of the verb */ + const struct afb_auth *auth; /* required authorisation */ + uint32_t session; /* authorisation and session requirements of the verb */ }; /* @@ -46,11 +46,70 @@ struct afb_verb_v2 */ struct afb_binding_v2 { - const char *api; /* api name for the binding */ - const char *specification; /* textual specification of the binding */ - const struct afb_verb_v2 *verbs; /* array of descriptions of verbs terminated by a NULL name */ - int (*init)(const struct afb_binding_interface *interface); - int (*start)(const struct afb_binding_interface *interface, struct afb_service service); + const char *api; /* api name for the binding */ + const char *specification; /* textual specification of the binding */ + const struct afb_verb_v2 *verbs; /* array of descriptions of verbs terminated by a NULL name */ + int (*preinit)(); + int (*init)(); void (*onevent)(const char *event, struct json_object *object); + unsigned noconcurrency: 1; /* avoids concurrent requests to verbs */ +}; + +struct afb_binding_data_v2 +{ + int verbosity; /* level of verbosity */ + struct afb_daemon daemon; /* access to daemon APIs */ + struct afb_service service; /* access to service APIs */ }; +/* + * A binding V2 MUST have two exported symbols of name: + * + * - afbBindingV2 + * - afbBindingV2data + * + */ +#if !defined(AFB_BINDING_MAIN_NAME_V2) +extern const struct afb_binding_v2 afbBindingV2; +#endif + +#if !defined(AFB_BINDING_DATA_NAME_V2) +#define AFB_BINDING_DATA_NAME_V2 afbBindingV2data +#endif + +#if AFB_BINDING_VERSION != 2 +extern +#endif +struct afb_binding_data_v2 AFB_BINDING_DATA_NAME_V2 __attribute__ ((weak)); + +#define afb_get_verbosity_v2() (AFB_BINDING_DATA_NAME_V2.verbosity) +#define afb_get_daemon_v2() (AFB_BINDING_DATA_NAME_V2.daemon) +#define afb_get_service_v2() (AFB_BINDING_DATA_NAME_V2.service) + +/* + * Macros for logging messages + */ +#if !defined(AFB_BINDING_PRAGMA_NO_VERBOSE_MACRO) +# if !defined(AFB_BINDING_PRAGMA_NO_VERBOSE_DETAILS) +# define _AFB_LOGGING_V2_(vlevel,llevel,...) \ + do{ \ + if(AFB_BINDING_DATA_NAME_V2.verbosity>=vlevel) \ + afb_daemon_verbose_v2(llevel,__FILE__,__LINE__,__func__,__VA_ARGS__); \ + }while(0) +# else +# define _AFB_LOGGING_V2_(vlevel,llevel,...) \ + do{ \ + if(afbBindingV2data.verbosity>=vlevel) \ + afb_daemon_verbose_v2(llevel,NULL,0,NULL,__VA_ARGS__); \ + }while(0) +# endif +# define AFB_ERROR_V2(...) _AFB_LOGGING_V2_(0,3,__VA_ARGS__) +# define AFB_WARNING_V2(...) _AFB_LOGGING_V2_(1,4,__VA_ARGS__) +# define AFB_NOTICE_V2(...) _AFB_LOGGING_V2_(1,5,__VA_ARGS__) +# define AFB_INFO_V2(...) _AFB_LOGGING_V2_(2,6,__VA_ARGS__) +# define AFB_DEBUG_V2(...) _AFB_LOGGING_V2_(3,7,__VA_ARGS__) +#endif + +#include "afb-daemon-v2.h" +#include "afb-service-v2.h" +