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.
31 #define AFB_BINDING_LOWER_VERSION 1
32 #define AFB_BINDING_UPPER_VERSION 2
34 #ifndef AFB_BINDING_VERSION
35 #define AFB_BINDING_VERSION 1
36 #pragma GCC warning "\
39 AFB_BINDING_VERSION should be defined before including <afb/afb-binding.h>\n\
40 AFB_BINDING_VERSION defines the version of binding that you use.\n\
41 Currently, known versions are 1 or 2.\n\
42 Setting now AFB_BINDING_VERSION to 1 (version 1 by default)\n\
43 NOTE THAT VERSION 2 IS NOW RECOMMENDED!\n\
44 Consider to add one of the following define before including <afb/afb-binding.h>:\n\
46 #define AFB_BINDING_VERSION 1\n\
47 #define AFB_BINDING_VERSION 2\n\
49 Note that in some case it will enforce you to include <stdio.h>\n\
51 #include <stdio.h> /* old version side effect */
53 # if AFB_BINDING_VERSION == 1
54 # pragma GCC warning "Using binding version 1, consider to switch to version 2"
58 #if AFB_BINDING_VERSION != 0
59 # if AFB_BINDING_VERSION < AFB_BINDING_LOWER_VERSION || AFB_BINDING_VERSION > AFB_BINDING_UPPER_VERSION
60 # error "Unsupported binding version AFB_BINDING_VERSION " #AFB_BINDING_VERSION
65 * Some function of the library are exported to afb-daemon.
68 #include "afb-binding-v1.h"
69 #include "afb-binding-v2.h"
71 typedef struct afb_verb_desc_v1 afb_verb_desc_v1;
72 typedef struct afb_binding_desc_v1 afb_binding_desc_v1;
73 typedef struct afb_binding_v1 afb_binding_v1;
74 typedef struct afb_binding_interface_v1 afb_binding_interface_v1;
76 typedef struct afb_verb_v2 afb_verb_v2;
77 typedef struct afb_binding_v2 afb_binding_v2;
79 typedef enum afb_auth_type afb_auth_type;
80 typedef struct afb_auth afb_auth;
81 typedef struct afb_daemon afb_daemon;
82 typedef struct afb_event afb_event;
83 typedef struct afb_arg afb_arg;
84 typedef struct afb_req afb_req;
85 typedef struct afb_service afb_service;
88 /* these typedef's shouldn't be needed */
89 typedef enum afb_binding_type_v1 afb_binding_type_v1;
90 typedef enum afb_mode_v1 afb_mode_v1;
91 typedef enum afb_session_flags_v1 afb_session_flags_v1;
92 typedef enum afb_session_flags_v2 afb_session_flags_v2;
93 typedef struct afb_binding_data_v2 afb_binding_data_v2;
94 typedef struct afb_daemon_itf afb_daemon_itf;
95 typedef struct afb_event_itf afb_event_itf;
96 typedef struct afb_req_itf afb_req_itf;
97 typedef struct afb_service_itf afb_service_itf;
100 /***************************************************************************************************/
102 #if AFB_BINDING_VERSION == 1
104 # define afb_binding afb_binding_v1
105 # define afb_binding_interface afb_binding_interface_v1
107 # define AFB_SESSION_NONE AFB_SESSION_NONE_V1
108 # define AFB_SESSION_CREATE AFB_SESSION_CREATE_V1
109 # define AFB_SESSION_CLOSE AFB_SESSION_CLOSE_V1
110 # define AFB_SESSION_RENEW AFB_SESSION_RENEW_V1
111 # define AFB_SESSION_CHECK AFB_SESSION_CHECK_V1
113 # define AFB_SESSION_LOA_GE AFB_SESSION_LOA_GE_V1
114 # define AFB_SESSION_LOA_LE AFB_SESSION_LOA_LE_V1
115 # define AFB_SESSION_LOA_EQ AFB_SESSION_LOA_EQ_V1
117 # define AFB_SESSION_LOA_SHIFT AFB_SESSION_LOA_SHIFT_V1
118 # define AFB_SESSION_LOA_MASK AFB_SESSION_LOA_MASK_V1
120 # define AFB_SESSION_LOA_0 AFB_SESSION_LOA_0_V1
121 # define AFB_SESSION_LOA_1 AFB_SESSION_LOA_1_V1
122 # define AFB_SESSION_LOA_2 AFB_SESSION_LOA_2_V1
123 # define AFB_SESSION_LOA_3 AFB_SESSION_LOA_3_V1
124 # define AFB_SESSION_LOA_4 AFB_SESSION_LOA_4_V1
126 # define AFB_SESSION_LOA_LE_0 AFB_SESSION_LOA_LE_0_V1
127 # define AFB_SESSION_LOA_LE_1 AFB_SESSION_LOA_LE_1_V1
128 # define AFB_SESSION_LOA_LE_2 AFB_SESSION_LOA_LE_2_V1
129 # define AFB_SESSION_LOA_LE_3 AFB_SESSION_LOA_LE_3_V1
131 # define AFB_SESSION_LOA_EQ_0 AFB_SESSION_LOA_EQ_0_V1
132 # define AFB_SESSION_LOA_EQ_1 AFB_SESSION_LOA_EQ_1_V1
133 # define AFB_SESSION_LOA_EQ_2 AFB_SESSION_LOA_EQ_2_V1
134 # define AFB_SESSION_LOA_EQ_3 AFB_SESSION_LOA_EQ_3_V1
136 # define AFB_SESSION_LOA_GE_0 AFB_SESSION_LOA_GE_0_V1
137 # define AFB_SESSION_LOA_GE_1 AFB_SESSION_LOA_GE_1_V1
138 # define AFB_SESSION_LOA_GE_2 AFB_SESSION_LOA_GE_2_V1
139 # define AFB_SESSION_LOA_GE_3 AFB_SESSION_LOA_GE_3_V1
141 # if !defined(AFB_BINDING_PRAGMA_NO_VERBOSE_MACRO)
143 # define ERROR AFB_ERROR_V1
144 # define WARNING AFB_WARNING_V1
145 # define NOTICE AFB_NOTICE_V1
146 # define INFO AFB_INFO_V1
147 # define DEBUG AFB_DEBUG_V1
149 # define REQ_ERROR AFB_REQ_ERROR_V1
150 # define REQ_WARNING AFB_REQ_WARNING_V1
151 # define REQ_NOTICE AFB_REQ_NOTICE_V1
152 # define REQ_INFO AFB_REQ_INFO_V1
153 # define REQ_DEBUG AFB_REQ_DEBUG_V1
157 #define afb_daemon_get_event_loop afb_daemon_get_event_loop_v1
158 #define afb_daemon_get_user_bus afb_daemon_get_user_bus_v1
159 #define afb_daemon_get_system_bus afb_daemon_get_system_bus_v1
160 #define afb_daemon_broadcast_event afb_daemon_broadcast_event_v1
161 #define afb_daemon_make_event afb_daemon_make_event_v1
162 #define afb_daemon_verbose afb_daemon_verbose_v1
163 #define afb_daemon_rootdir_get_fd afb_daemon_rootdir_get_fd_v1
164 #define afb_daemon_rootdir_open_locale afb_daemon_rootdir_open_locale_v1
165 #define afb_daemon_queue_job afb_daemon_queue_job_v1
167 #define afb_service_call afb_service_call_v1
168 #define afb_service_call_sync afb_service_call_sync_v1
172 /***************************************************************************************************/
174 #if AFB_BINDING_VERSION == 2
176 # define afb_binding afb_binding_v2
178 # define AFB_SESSION_NONE AFB_SESSION_NONE_V2
179 # define AFB_SESSION_CLOSE AFB_SESSION_CLOSE_V2
180 # define AFB_SESSION_RENEW AFB_SESSION_REFRESH_V2
181 # define AFB_SESSION_REFRESH AFB_SESSION_REFRESH_V2
182 # define AFB_SESSION_CHECK AFB_SESSION_CHECK_V2
184 # define AFB_SESSION_LOA_MASK AFB_SESSION_LOA_MASK_V2
186 # define AFB_SESSION_LOA_0 AFB_SESSION_LOA_0_V2
187 # define AFB_SESSION_LOA_1 AFB_SESSION_LOA_1_V2
188 # define AFB_SESSION_LOA_2 AFB_SESSION_LOA_2_V2
189 # define AFB_SESSION_LOA_3 AFB_SESSION_LOA_3_V2
191 # if !defined(AFB_BINDING_PRAGMA_NO_VERBOSE_MACRO)
193 # define ERROR AFB_ERROR_V2
194 # define WARNING AFB_WARNING_V2
195 # define NOTICE AFB_NOTICE_V2
196 # define INFO AFB_INFO_V2
197 # define DEBUG AFB_DEBUG_V2
199 # define REQ_ERROR AFB_REQ_ERROR_V2
200 # define REQ_WARNING AFB_REQ_WARNING_V2
201 # define REQ_NOTICE AFB_REQ_NOTICE_V2
202 # define REQ_INFO AFB_REQ_INFO_V2
203 # define REQ_DEBUG AFB_REQ_DEBUG_V2
207 #define afb_daemon_get_event_loop afb_daemon_get_event_loop_v2
208 #define afb_daemon_get_user_bus afb_daemon_get_user_bus_v2
209 #define afb_daemon_get_system_bus afb_daemon_get_system_bus_v2
210 #define afb_daemon_broadcast_event afb_daemon_broadcast_event_v2
211 #define afb_daemon_make_event afb_daemon_make_event_v2
212 #define afb_daemon_verbose afb_daemon_verbose_v2
213 #define afb_daemon_rootdir_get_fd afb_daemon_rootdir_get_fd_v2
214 #define afb_daemon_rootdir_open_locale afb_daemon_rootdir_open_locale_v2
215 #define afb_daemon_queue_job afb_daemon_queue_job_v2
217 #define afb_service_call afb_service_call_v2
218 #define afb_service_call_sync afb_service_call_sync_v2