2 * Copyright (C) 2016, 2017 "IoT.bzh"
3 * Author: José Bollo <jose.bollo@iot.bzh>
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
22 /*****************************************************************************
23 * This files is the main file to include for writing bindings dedicated to
27 * Functions of bindings of afb-daemon are accessible by authorized clients
28 * through the apis module of afb-daemon.
30 * A binding is a shared library. This shared library must have at least one
31 * exported symbol for being registered in afb-daemon.
35 #define AFB_BINDING_LOWER_VERSION 1
36 #define AFB_BINDING_UPPER_VERSION 2
37 #define AFB_BINDING_DEFAULT_VERSION 1
39 #ifndef AFB_BINDING_VERSION
40 #define AFB_BINDING_VERSION AFB_BINDING_DEFAULT_VERSION
43 #if AFB_BINDING_VERSION != 0
44 # if AFB_BINDING_VERSION < AFB_BINDING_LOWER_VERSION || AFB_BINDING_VERSION > AFB_BINDING_UPPER_VERSION
45 # error "Unsupported binding version AFB_BINDING_VERSION " #AFB_BINDING_VERSION
50 * Some function of the library are exported to afb-daemon.
53 #include "afb-binding-v1.h"
54 #include "afb-binding-v2.h"
56 typedef struct afb_verb_desc_v1 afb_verb_desc_v1;
57 typedef struct afb_binding_desc_v1 afb_binding_desc_v1;
58 typedef struct afb_binding_v1 afb_binding_v1;
59 typedef struct afb_binding_interface_v1 afb_binding_interface_v1;
61 typedef struct afb_verb_v2 afb_verb_v2;
62 typedef struct afb_binding_v2 afb_binding_v2;
64 typedef enum afb_auth_type afb_auth_type;
65 typedef struct afb_auth afb_auth;
66 typedef struct afb_daemon afb_daemon;
67 typedef struct afb_event afb_event;
68 typedef struct afb_arg afb_arg;
69 typedef struct afb_req afb_req;
70 typedef struct afb_service afb_service;
73 /* these typedef's shouldn't be needed */
74 typedef enum afb_binding_type_v1 afb_binding_type_v1;
75 typedef enum afb_mode_v1 afb_mode_v1;
76 typedef enum afb_session_flags_v1 afb_session_flags_v1;
77 typedef enum afb_session_flags_v2 afb_session_flags_v2;
78 typedef struct afb_binding_data_v2 afb_binding_data_v2;
79 typedef struct afb_daemon_itf afb_daemon_itf;
80 typedef struct afb_event_itf afb_event_itf;
81 typedef struct afb_req_itf afb_req_itf;
82 typedef struct afb_service_itf afb_service_itf;
85 /***************************************************************************************************/
87 #if AFB_BINDING_VERSION == 1
89 # define afb_binding afb_binding_v1
90 # define afb_binding_interface afb_binding_interface_v1
92 # define AFB_SESSION_NONE AFB_SESSION_NONE_V1
93 # define AFB_SESSION_CREATE AFB_SESSION_CREATE_V1
94 # define AFB_SESSION_CLOSE AFB_SESSION_CLOSE_V1
95 # define AFB_SESSION_RENEW AFB_SESSION_RENEW_V1
96 # define AFB_SESSION_CHECK AFB_SESSION_CHECK_V1
98 # define AFB_SESSION_LOA_GE AFB_SESSION_LOA_GE_V1
99 # define AFB_SESSION_LOA_LE AFB_SESSION_LOA_LE_V1
100 # define AFB_SESSION_LOA_EQ AFB_SESSION_LOA_EQ_V1
102 # define AFB_SESSION_LOA_SHIFT AFB_SESSION_LOA_SHIFT_V1
103 # define AFB_SESSION_LOA_MASK AFB_SESSION_LOA_MASK_V1
105 # define AFB_SESSION_LOA_0 AFB_SESSION_LOA_0_V1
106 # define AFB_SESSION_LOA_1 AFB_SESSION_LOA_1_V1
107 # define AFB_SESSION_LOA_2 AFB_SESSION_LOA_2_V1
108 # define AFB_SESSION_LOA_3 AFB_SESSION_LOA_3_V1
109 # define AFB_SESSION_LOA_4 AFB_SESSION_LOA_4_V1
111 # define AFB_SESSION_LOA_LE_0 AFB_SESSION_LOA_LE_0_V1
112 # define AFB_SESSION_LOA_LE_1 AFB_SESSION_LOA_LE_1_V1
113 # define AFB_SESSION_LOA_LE_2 AFB_SESSION_LOA_LE_2_V1
114 # define AFB_SESSION_LOA_LE_3 AFB_SESSION_LOA_LE_3_V1
116 # define AFB_SESSION_LOA_EQ_0 AFB_SESSION_LOA_EQ_0_V1
117 # define AFB_SESSION_LOA_EQ_1 AFB_SESSION_LOA_EQ_1_V1
118 # define AFB_SESSION_LOA_EQ_2 AFB_SESSION_LOA_EQ_2_V1
119 # define AFB_SESSION_LOA_EQ_3 AFB_SESSION_LOA_EQ_3_V1
121 # define AFB_SESSION_LOA_GE_0 AFB_SESSION_LOA_GE_0_V1
122 # define AFB_SESSION_LOA_GE_1 AFB_SESSION_LOA_GE_1_V1
123 # define AFB_SESSION_LOA_GE_2 AFB_SESSION_LOA_GE_2_V1
124 # define AFB_SESSION_LOA_GE_3 AFB_SESSION_LOA_GE_3_V1
126 # if !defined(AFB_BINDING_PRAGMA_NO_VERBOSE_MACRO)
128 # define ERROR AFB_ERROR_V1
129 # define WARNING AFB_WARNING_V1
130 # define NOTICE AFB_NOTICE_V1
131 # define INFO AFB_INFO_V1
132 # define DEBUG AFB_DEBUG_V1
134 # define REQ_ERROR AFB_REQ_ERROR_V1
135 # define REQ_WARNING AFB_REQ_WARNING_V1
136 # define REQ_NOTICE AFB_REQ_NOTICE_V1
137 # define REQ_INFO AFB_REQ_INFO_V1
138 # define REQ_DEBUG AFB_REQ_DEBUG_V1
142 #define afb_daemon_get_event_loop afb_daemon_get_event_loop_v1
143 #define afb_daemon_get_user_bus afb_daemon_get_user_bus_v1
144 #define afb_daemon_get_system_bus afb_daemon_get_system_bus_v1
145 #define afb_daemon_broadcast_event afb_daemon_broadcast_event_v1
146 #define afb_daemon_make_event afb_daemon_make_event_v1
147 #define afb_daemon_verbose afb_daemon_verbose_v1
148 #define afb_daemon_rootdir_get_fd afb_daemon_rootdir_get_fd_v1
149 #define afb_daemon_rootdir_open_locale afb_daemon_rootdir_open_locale_v1
150 #define afb_daemon_queue_job afb_daemon_queue_job_v1
152 #define afb_service_call afb_service_call_v1
153 #define afb_service_call_sync afb_service_call_sync_v1
157 /***************************************************************************************************/
159 #if AFB_BINDING_VERSION == 2
161 # define afb_binding afb_binding_v2
163 # define AFB_SESSION_NONE AFB_SESSION_NONE_V2
164 # define AFB_SESSION_CLOSE AFB_SESSION_CLOSE_V2
165 # define AFB_SESSION_RENEW AFB_SESSION_REFRESH_V2
166 # define AFB_SESSION_REFRESH AFB_SESSION_REFRESH_V2
167 # define AFB_SESSION_CHECK AFB_SESSION_CHECK_V2
169 # define AFB_SESSION_LOA_MASK AFB_SESSION_LOA_MASK_V2
171 # define AFB_SESSION_LOA_0 AFB_SESSION_LOA_0_V2
172 # define AFB_SESSION_LOA_1 AFB_SESSION_LOA_1_V2
173 # define AFB_SESSION_LOA_2 AFB_SESSION_LOA_2_V2
174 # define AFB_SESSION_LOA_3 AFB_SESSION_LOA_3_V2
176 # if !defined(AFB_BINDING_PRAGMA_NO_VERBOSE_MACRO)
178 # define ERROR AFB_ERROR_V2
179 # define WARNING AFB_WARNING_V2
180 # define NOTICE AFB_NOTICE_V2
181 # define INFO AFB_INFO_V2
182 # define DEBUG AFB_DEBUG_V2
184 # define REQ_ERROR AFB_REQ_ERROR_V2
185 # define REQ_WARNING AFB_REQ_WARNING_V2
186 # define REQ_NOTICE AFB_REQ_NOTICE_V2
187 # define REQ_INFO AFB_REQ_INFO_V2
188 # define REQ_DEBUG AFB_REQ_DEBUG_V2
192 #define afb_daemon_get_event_loop afb_daemon_get_event_loop_v2
193 #define afb_daemon_get_user_bus afb_daemon_get_user_bus_v2
194 #define afb_daemon_get_system_bus afb_daemon_get_system_bus_v2
195 #define afb_daemon_broadcast_event afb_daemon_broadcast_event_v2
196 #define afb_daemon_make_event afb_daemon_make_event_v2
197 #define afb_daemon_verbose afb_daemon_verbose_v2
198 #define afb_daemon_rootdir_get_fd afb_daemon_rootdir_get_fd_v2
199 #define afb_daemon_rootdir_open_locale afb_daemon_rootdir_open_locale_v2
200 #define afb_daemon_queue_job afb_daemon_queue_job_v2
202 #define afb_service_call afb_service_call_v2
203 #define afb_service_call_sync afb_service_call_sync_v2