a00f84edaf0ae07991d119377d951a813d54b620
[src/app-framework-binder.git] / include / afb / afb-binding-predefs.h
1 /*
2  * Copyright (C) 2018, 2019 "IoT.bzh"
3  * Author: José Bollo <jose.bollo@iot.bzh>
4  *
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
8  *
9  *   http://www.apache.org/licenses/LICENSE-2.0
10  *
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.
16  */
17
18 #pragma once
19
20 /******************************************************************************/
21
22 #if AFB_BINDING_VERSION == 1 || AFB_BINDING_VERSION == 2
23
24 #define afb_req                         afb_req_x1
25 #define afb_req_is_valid                afb_req_x1_is_valid
26 #define afb_req_get                     afb_req_x1_get
27 #define afb_req_value                   afb_req_x1_value
28 #define afb_req_path                    afb_req_x1_path
29 #define afb_req_json                    afb_req_x1_json
30 #define afb_req_reply                   afb_req_x1_reply
31 #define afb_req_reply_f                 afb_req_x1_reply_f
32 #define afb_req_reply_v                 afb_req_x1_reply_v
33 #define afb_req_success(r,o,i)          afb_req_x1_reply(r,o,0,i)
34 #define afb_req_success_f(r,o,...)      afb_req_x1_reply_f(r,o,0,__VA_ARGS__)
35 #define afb_req_success_v(r,o,f,v)      afb_req_x1_reply_v(r,o,0,f,v)
36 #define afb_req_fail(r,e,i)             afb_req_x1_reply(r,0,e,i)
37 #define afb_req_fail_f(r,e,...)         afb_req_x1_reply_f(r,0,e,__VA_ARGS__)
38 #define afb_req_fail_v(r,e,f,v)         afb_req_x1_reply_v(r,0,e,f,v)
39 #define afb_req_context_get             afb_req_x1_context_get
40 #define afb_req_context_set             afb_req_x1_context_set
41 #define afb_req_context                 afb_req_x1_context
42 #define afb_req_context_make            afb_req_x1_context_make
43 #define afb_req_context_clear           afb_req_x1_context_clear
44 #define afb_req_addref                  afb_req_x1_addref
45 #define afb_req_unref                   afb_req_x1_unref
46 #define afb_req_session_close           afb_req_x1_session_close
47 #define afb_req_session_set_LOA         afb_req_x1_session_set_LOA
48 #define afb_req_subscribe               afb_req_x1_subscribe
49 #define afb_req_unsubscribe             afb_req_x1_unsubscribe
50 #define afb_req_subcall                 afb_req_x1_subcall
51 #define afb_req_subcall_req             afb_req_x1_subcall_req
52 #define afb_req_subcall_sync            afb_req_x1_subcall_sync
53 #define afb_req_verbose                 afb_req_x1_verbose
54 #define afb_req_has_permission          afb_req_x1_has_permission
55 #define afb_req_get_application_id      afb_req_x1_get_application_id
56 #define afb_req_get_uid                 afb_req_x1_get_uid
57 #define afb_req_get_client_info         afb_req_x1_get_client_info
58
59 #define afb_event                       afb_event_x1
60 #define afb_event_to_event_x2           afb_event_x1_to_event_x2
61 #define afb_event_is_valid              afb_event_x1_is_valid
62 #define afb_event_broadcast             afb_event_x1_broadcast
63 #define afb_event_push                  afb_event_x1_push
64 #define afb_event_drop                  afb_event_x1_unref
65 #define afb_event_name                  afb_event_x1_name
66 #define afb_event_unref                 afb_event_x1_unref
67 #define afb_event_addref                afb_event_x1_addref
68
69 #define afb_service                     afb_service_x1
70 #define afb_daemon                      afb_daemon_x1
71
72 #define _AFB_SYSLOG_LEVEL_EMERGENCY_    AFB_SYSLOG_LEVEL_EMERGENCY
73 #define _AFB_SYSLOG_LEVEL_ALERT_        AFB_SYSLOG_LEVEL_ALERT
74 #define _AFB_SYSLOG_LEVEL_CRITICAL_     AFB_SYSLOG_LEVEL_CRITICAL
75 #define _AFB_SYSLOG_LEVEL_ERROR_        AFB_SYSLOG_LEVEL_ERROR
76 #define _AFB_SYSLOG_LEVEL_WARNING_      AFB_SYSLOG_LEVEL_WARNING
77 #define _AFB_SYSLOG_LEVEL_NOTICE_       AFB_SYSLOG_LEVEL_NOTICE
78 #define _AFB_SYSLOG_LEVEL_INFO_         AFB_SYSLOG_LEVEL_INFO
79 #define _AFB_SYSLOG_LEVEL_DEBUG_        AFB_SYSLOG_LEVEL_DEBUG
80
81 #endif
82
83 /******************************************************************************/
84 #if AFB_BINDING_VERSION == 1
85
86 #define afb_req_store                   afb_req_x1_store_v1
87 #define afb_req_unstore                 afb_req_x1_unstore_v1
88
89 #define afb_binding                     afb_binding_v1
90 #define afb_binding_interface           afb_binding_interface_v1
91
92 #define afb_daemon_get_event_loop       afb_daemon_get_event_loop_v1
93 #define afb_daemon_get_user_bus         afb_daemon_get_user_bus_v1
94 #define afb_daemon_get_system_bus       afb_daemon_get_system_bus_v1
95 #define afb_daemon_broadcast_event      afb_daemon_broadcast_event_v1
96 #define afb_daemon_make_event           afb_daemon_make_event_v1
97 #define afb_daemon_verbose              afb_daemon_verbose_v1
98 #define afb_daemon_rootdir_get_fd       afb_daemon_rootdir_get_fd_v1
99 #define afb_daemon_rootdir_open_locale  afb_daemon_rootdir_open_locale_v1
100 #define afb_daemon_queue_job            afb_daemon_queue_job_v1
101 #define afb_daemon_require_api          afb_daemon_require_api_v1
102 #define afb_daemon_rename_api           afb_daemon_add_alias_v1
103
104 #define afb_service_call                afb_service_call_v1
105 #define afb_service_call_sync           afb_service_call_sync_v1
106
107 # define AFB_ERROR                      AFB_ERROR_V1
108 # define AFB_WARNING                    AFB_WARNING_V1
109 # define AFB_NOTICE                     AFB_NOTICE_V1
110 # define AFB_INFO                       AFB_INFO_V1
111 # define AFB_DEBUG                      AFB_DEBUG_V1
112
113 # define AFB_REQ_ERROR                  AFB_REQ_ERROR_V1
114 # define AFB_REQ_WARNING                AFB_REQ_WARNING_V1
115 # define AFB_REQ_NOTICE                 AFB_REQ_NOTICE_V1
116 # define AFB_REQ_INFO                   AFB_REQ_INFO_V1
117 # define AFB_REQ_DEBUG                  AFB_REQ_DEBUG_V1
118
119 #define AFB_REQ_VERBOSE                 AFB_REQ_VERBOSE_V1
120
121 # define AFB_SESSION_NONE               AFB_SESSION_NONE_X1
122 # define AFB_SESSION_CREATE             AFB_SESSION_CREATE_X1
123 # define AFB_SESSION_CLOSE              AFB_SESSION_CLOSE_X1
124 # define AFB_SESSION_RENEW              AFB_SESSION_RENEW_X1
125 # define AFB_SESSION_CHECK              AFB_SESSION_CHECK_X1
126
127 # define AFB_SESSION_LOA_GE             AFB_SESSION_LOA_GE_X1
128 # define AFB_SESSION_LOA_LE             AFB_SESSION_LOA_LE_X1
129 # define AFB_SESSION_LOA_EQ             AFB_SESSION_LOA_EQ_X1
130
131 # define AFB_SESSION_LOA_SHIFT          AFB_SESSION_LOA_SHIFT_X1
132 # define AFB_SESSION_LOA_MASK           AFB_SESSION_LOA_MASK_X1
133
134 # define AFB_SESSION_LOA_0              AFB_SESSION_LOA_0_X1
135 # define AFB_SESSION_LOA_1              AFB_SESSION_LOA_1_X1
136 # define AFB_SESSION_LOA_2              AFB_SESSION_LOA_2_X1
137 # define AFB_SESSION_LOA_3              AFB_SESSION_LOA_3_X1
138 # define AFB_SESSION_LOA_4              AFB_SESSION_LOA_4_X1
139
140 # define AFB_SESSION_LOA_LE_0           AFB_SESSION_LOA_LE_0_X1
141 # define AFB_SESSION_LOA_LE_1           AFB_SESSION_LOA_LE_1_X1
142 # define AFB_SESSION_LOA_LE_2           AFB_SESSION_LOA_LE_2_X1
143 # define AFB_SESSION_LOA_LE_3           AFB_SESSION_LOA_LE_3_X1
144
145 # define AFB_SESSION_LOA_EQ_0           AFB_SESSION_LOA_EQ_0_X1
146 # define AFB_SESSION_LOA_EQ_1           AFB_SESSION_LOA_EQ_1_X1
147 # define AFB_SESSION_LOA_EQ_2           AFB_SESSION_LOA_EQ_2_X1
148 # define AFB_SESSION_LOA_EQ_3           AFB_SESSION_LOA_EQ_3_X1
149
150 # define AFB_SESSION_LOA_GE_0           AFB_SESSION_LOA_GE_0_X1
151 # define AFB_SESSION_LOA_GE_1           AFB_SESSION_LOA_GE_1_X1
152 # define AFB_SESSION_LOA_GE_2           AFB_SESSION_LOA_GE_2_X1
153 # define AFB_SESSION_LOA_GE_3           AFB_SESSION_LOA_GE_3_X1
154
155 #endif
156
157 /******************************************************************************/
158 #if AFB_BINDING_VERSION == 2
159
160 #define afb_req_store                   afb_req_x1_store_v2
161 #define afb_req_unstore                 afb_daemon_unstore_req_v2
162
163 #define afb_binding                     afb_binding_v2
164
165 #define afb_get_verbosity               afb_get_verbosity_v2
166 #define afb_get_daemon                  afb_get_daemon_v2
167 #define afb_get_service                 afb_get_service_v2
168
169 #define afb_daemon_get_event_loop       afb_daemon_get_event_loop_v2
170 #define afb_daemon_get_user_bus         afb_daemon_get_user_bus_v2
171 #define afb_daemon_get_system_bus       afb_daemon_get_system_bus_v2
172 #define afb_daemon_broadcast_event      afb_daemon_broadcast_event_v2
173 #define afb_daemon_make_event           afb_daemon_make_event_v2
174 #define afb_daemon_verbose              afb_daemon_verbose_v2
175 #define afb_daemon_rootdir_get_fd       afb_daemon_rootdir_get_fd_v2
176 #define afb_daemon_rootdir_open_locale  afb_daemon_rootdir_open_locale_v2
177 #define afb_daemon_queue_job            afb_daemon_queue_job_v2
178 #define afb_daemon_unstore_req          afb_daemon_unstore_req_v2
179 #define afb_daemon_require_api          afb_daemon_require_api_v2
180 #define afb_daemon_rename_api(x)        afb_daemon_add_alias_v2(0,x)
181 #define afb_daemon_add_alias            afb_daemon_add_alias_v2
182
183 #define afb_service_call                afb_service_call_v2
184 #define afb_service_call_sync           afb_service_call_sync_v2
185
186 #define AFB_ERROR                       AFB_ERROR_V2
187 #define AFB_WARNING                     AFB_WARNING_V2
188 #define AFB_NOTICE                      AFB_NOTICE_V2
189 #define AFB_INFO                        AFB_INFO_V2
190 #define AFB_DEBUG                       AFB_DEBUG_V2
191
192 #define AFB_REQ_ERROR                   AFB_REQ_ERROR_V2
193 #define AFB_REQ_WARNING                 AFB_REQ_WARNING_V2
194 #define AFB_REQ_NOTICE                  AFB_REQ_NOTICE_V2
195 #define AFB_REQ_INFO                    AFB_REQ_INFO_V2
196 #define AFB_REQ_DEBUG                   AFB_REQ_DEBUG_V2
197
198 #define AFB_REQ_VERBOSE                 AFB_REQ_VERBOSE_V2
199
200 #endif
201
202 /******************************************************************************/
203 #if AFB_BINDING_VERSION == 2 || AFB_BINDING_VERSION == 3
204
205 #define AFB_SESSION_NONE                AFB_SESSION_NONE_X2
206 #define AFB_SESSION_CLOSE               AFB_SESSION_CLOSE_X2
207 #define AFB_SESSION_RENEW               AFB_SESSION_REFRESH_X2
208 #define AFB_SESSION_REFRESH             AFB_SESSION_REFRESH_X2
209 #define AFB_SESSION_CHECK               AFB_SESSION_CHECK_X2
210
211 #define AFB_SESSION_LOA_MASK            AFB_SESSION_LOA_MASK_X2
212
213 #define AFB_SESSION_LOA_0               AFB_SESSION_LOA_0_X2
214 #define AFB_SESSION_LOA_1               AFB_SESSION_LOA_1_X2
215 #define AFB_SESSION_LOA_2               AFB_SESSION_LOA_2_X2
216 #define AFB_SESSION_LOA_3               AFB_SESSION_LOA_3_X2
217
218 #endif
219
220 /******************************************************************************/
221 #if AFB_BINDING_VERSION == 2
222
223 #define AFB_SESSION_NONE_V2             AFB_SESSION_NONE_X2
224 #define AFB_SESSION_CLOSE_V2            AFB_SESSION_CLOSE_X2
225 #define AFB_SESSION_RENEW_V2            AFB_SESSION_REFRESH_X2
226 #define AFB_SESSION_REFRESH_V2          AFB_SESSION_REFRESH_X2
227 #define AFB_SESSION_CHECK_V2            AFB_SESSION_CHECK_X2
228
229 #define AFB_SESSION_LOA_MASK_V2 AFB_SESSION_LOA_MASK_X2
230
231 #define AFB_SESSION_LOA_0_V2            AFB_SESSION_LOA_0_X2
232 #define AFB_SESSION_LOA_1_V2            AFB_SESSION_LOA_1_X2
233 #define AFB_SESSION_LOA_2_V2            AFB_SESSION_LOA_2_X2
234 #define AFB_SESSION_LOA_3_V2            AFB_SESSION_LOA_3_X2
235
236 #endif
237
238 /******************************************************************************/
239 #if AFB_BINDING_VERSION == 3
240
241 #define afb_req_x2                      afb_req
242
243 #define afb_req_x2_is_valid             afb_req_is_valid
244 #define afb_req_x2_get_api              afb_req_get_api
245 #define afb_req_x2_get_vcbdata          afb_req_get_vcbdata
246 #define afb_req_x2_get_called_api       afb_req_get_called_api
247 #define afb_req_x2_get_called_verb      afb_req_get_called_verb
248 #define afb_req_x2_wants_log_level      afb_req_wants_log_level
249
250 #define afb_req_x2_get                  afb_req_get
251 #define afb_req_x2_value                afb_req_value
252 #define afb_req_x2_path                 afb_req_path
253 #define afb_req_x2_json                 afb_req_json
254 #define afb_req_x2_reply                afb_req_reply
255 #define afb_req_x2_reply_f              afb_req_reply_f
256 #define afb_req_x2_reply_v              afb_req_reply_v
257 #define afb_req_success(r,o,i)          afb_req_reply(r,o,0,i)
258 #define afb_req_success_f(r,o,...)      afb_req_reply_f(r,o,0,__VA_ARGS__)
259 #define afb_req_success_v(r,o,f,v)      afb_req_reply_v(r,o,0,f,v)
260 #define afb_req_fail(r,e,i)             afb_req_reply(r,0,e,i)
261 #define afb_req_fail_f(r,e,...)         afb_req_reply_f(r,0,e,__VA_ARGS__)
262 #define afb_req_fail_v(r,e,f,v)         afb_req_reply_v(r,0,e,f,v)
263 #define afb_req_x2_context_get          afb_req_context_get
264 #define afb_req_x2_context_set          afb_req_context_set
265 #define afb_req_x2_context              afb_req_context
266 #define afb_req_x2_context_make         afb_req_context_make
267 #define afb_req_x2_context_clear        afb_req_context_clear
268 #define afb_req_x2_addref               afb_req_addref
269 #define afb_req_x2_unref                afb_req_unref
270 #define afb_req_x2_session_close        afb_req_session_close
271 #define afb_req_x2_session_set_LOA      afb_req_session_set_LOA
272 #define afb_req_x2_subscribe            afb_req_subscribe
273 #define afb_req_x2_unsubscribe          afb_req_unsubscribe
274 #define afb_req_x2_subcall              afb_req_subcall
275 #define afb_req_x2_subcall_legacy       afb_req_subcall_legacy
276 #define afb_req_x2_subcall_req          afb_req_subcall_req
277 #define afb_req_x2_subcall_sync_legacy  afb_req_subcall_sync_legacy
278 #define afb_req_x2_subcall_sync         afb_req_subcall_sync
279 #define afb_req_x2_verbose              afb_req_verbose
280 #define afb_req_x2_has_permission       afb_req_has_permission
281 #define afb_req_x2_get_application_id   afb_req_get_application_id
282 #define afb_req_x2_get_uid              afb_req_get_uid
283 #define afb_req_x2_get_client_info      afb_req_get_client_info
284
285 #define afb_req_x2_subcall_flags        afb_req_subcall_flags
286 #define afb_req_x2_subcall_catch_events afb_req_subcall_catch_events
287 #define afb_req_x2_subcall_pass_events  afb_req_subcall_pass_events
288 #define afb_req_x2_subcall_on_behalf    afb_req_subcall_on_behalf
289 #define afb_req_x2_subcall_api_session  afb_req_subcall_api_session
290         
291 #define afb_event_x2                    afb_event
292 #define afb_event_x2_is_valid           afb_event_is_valid
293 #define afb_event_x2_broadcast          afb_event_broadcast
294 #define afb_event_x2_push               afb_event_push
295 #define afb_event_x2_name               afb_event_name
296 #define afb_event_x2_unref              afb_event_unref
297 #define afb_event_x2_addref             afb_event_addref
298
299 #define afb_api_x3                      afb_api
300
301 #define afb_api_x3_name                 afb_api_name
302 #define afb_api_x3_get_userdata         afb_api_get_userdata
303 #define afb_api_x3_set_userdata         afb_api_set_userdata
304 #define afb_api_x3_wants_log_level      afb_api_wants_log_level
305
306 #define afb_api_x3_vverbose             afb_api_vverbose
307 #define afb_api_x3_verbose              afb_api_verbose
308 #define afb_api_x3_get_event_loop       afb_api_get_event_loop
309 #define afb_api_x3_get_user_bus         afb_api_get_user_bus
310 #define afb_api_x3_get_system_bus       afb_api_get_system_bus
311 #define afb_api_x3_rootdir_get_fd       afb_api_rootdir_get_fd
312 #define afb_api_x3_rootdir_open_locale  afb_api_rootdir_open_locale
313 #define afb_api_x3_queue_job            afb_api_queue_job
314 #define afb_api_x3_require_api          afb_api_require_api
315 #define afb_api_x3_broadcast_event      afb_api_broadcast_event
316 #define afb_api_x3_make_event_x2        afb_api_make_event
317 #define afb_api_x3_call                 afb_api_call
318 #define afb_api_x3_call_sync            afb_api_call_sync
319 #define afb_api_x3_call_legacy          afb_api_call_legacy
320 #define afb_api_x3_call_sync_legacy     afb_api_call_sync_legacy
321 #define afb_api_x3_new_api              afb_api_new_api
322 #define afb_api_x3_delete_api           afb_api_delete_api
323 #define afb_api_x3_set_verbs_v2         afb_api_set_verbs_v2
324 #define afb_api_x3_set_verbs_v3         afb_api_set_verbs_v3
325 #define afb_api_x3_add_verb             afb_api_add_verb
326 #define afb_api_x3_del_verb             afb_api_del_verb
327 #define afb_api_x3_on_event             afb_api_on_event
328 #define afb_api_x3_on_init              afb_api_on_init
329 #define afb_api_x3_seal                 afb_api_seal
330 #define afb_api_x3_add_alias            afb_api_add_alias
331 #define afb_api_x3_event_handler_add    afb_api_event_handler_add
332 #define afb_api_x3_event_handler_del    afb_api_event_handler_del
333 #define afb_api_x3_require_class        afb_api_require_class
334 #define afb_api_x3_provide_class        afb_api_provide_class
335 #define afb_api_x3_settings             afb_api_settings
336
337 #define AFB_API_ERROR                   AFB_API_ERROR_V3
338 #define AFB_API_WARNING                 AFB_API_WARNING_V3
339 #define AFB_API_NOTICE                  AFB_API_NOTICE_V3
340 #define AFB_API_INFO                    AFB_API_INFO_V3
341 #define AFB_API_DEBUG                   AFB_API_DEBUG_V3
342
343 #define AFB_REQ_ERROR                   AFB_REQ_ERROR_V3
344 #define AFB_REQ_WARNING                 AFB_REQ_WARNING_V3
345 #define AFB_REQ_NOTICE                  AFB_REQ_NOTICE_V3
346 #define AFB_REQ_INFO                    AFB_REQ_INFO_V3
347 #define AFB_REQ_DEBUG                   AFB_REQ_DEBUG_V3
348
349 #define AFB_REQ_VERBOSE                 AFB_REQ_VERBOSE_V3
350
351 #define afb_stored_req                  afb_req_x2
352 #define afb_req_store(x)                afb_req_x2_addref(x)
353 #define afb_req_unstore(x)              (x)
354
355 #define afb_get_verbosity               afb_get_verbosity_v3
356 #define afb_get_logmask                 afb_get_logmask_v3
357 #define afb_get_daemon                  afb_get_root_api_v3
358 #define afb_get_service                 afb_get_root_api_v3
359
360 #define afb_daemon_get_event_loop       afb_daemon_get_event_loop_v3
361 #define afb_daemon_get_user_bus         afb_daemon_get_user_bus_v3
362 #define afb_daemon_get_system_bus       afb_daemon_get_system_bus_v3
363 #define afb_daemon_broadcast_event      afb_daemon_broadcast_event_v3
364 #define afb_daemon_make_event           afb_daemon_make_event_v3
365 #define afb_daemon_verbose              afb_daemon_verbose_v3
366 #define afb_daemon_rootdir_get_fd       afb_daemon_rootdir_get_fd_v3
367 #define afb_daemon_rootdir_open_locale  afb_daemon_rootdir_open_locale_v3
368 #define afb_daemon_queue_job            afb_daemon_queue_job_v3
369 #define afb_daemon_require_api          afb_daemon_require_api_v3
370 #define afb_daemon_add_alias            afb_daemon_add_alias_v3
371
372 # define afb_service_call               afb_service_call_v3
373 # define afb_service_call_sync          afb_service_call_sync_v3
374 # define afb_service_call_legacy        afb_service_call_legacy_v3
375 # define afb_service_call_sync_legacy   afb_service_call_sync_legacy_v3
376
377 # define AFB_ERROR                      AFB_ERROR_V3
378 # define AFB_WARNING                    AFB_WARNING_V3
379 # define AFB_NOTICE                     AFB_NOTICE_V3
380 # define AFB_INFO                       AFB_INFO_V3
381 # define AFB_DEBUG                      AFB_DEBUG_V3
382
383 #endif
384