2f2d8e2cb73e437f8dd6988395d69da8bf568309
[src/app-framework-binder.git] / src / afb-calls.h
1 /*
2  * Copyright (C) 2016-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 struct json_object;
21
22 struct afb_export;
23 struct afb_xreq;
24
25 struct afb_api_x3;
26 struct afb_req_x1;
27 struct afb_req_x2;
28
29 /******************************************************************************/
30 extern
31 void afb_calls_call(
32                 struct afb_export *export,
33                 const char *api,
34                 const char *verb,
35                 struct json_object *args,
36                 void (*callback)(void*, struct json_object*, const char *error, const char *info, struct afb_api_x3*),
37                 void *closure);
38
39 extern
40 int afb_calls_call_sync(
41                 struct afb_export *export,
42                 const char *api,
43                 const char *verb,
44                 struct json_object *args,
45                 struct json_object **object,
46                 char **error,
47                 char **info);
48
49 extern
50 void afb_calls_subcall(
51                         struct afb_xreq *xreq,
52                         const char *api,
53                         const char *verb,
54                         struct json_object *args,
55                         int flags,
56                         void (*callback)(void *closure, struct json_object *object, const char *error, const char * info, struct afb_req_x2 *req),
57                         void *closure);
58
59 extern
60 int afb_calls_subcall_sync(
61                         struct afb_xreq *xreq,
62                         const char *api,
63                         const char *verb,
64                         struct json_object *args,
65                         int flags,
66                         struct json_object **object,
67                         char **error,
68                         char **info);
69
70 /******************************************************************************/
71 #if WITH_AFB_HOOK
72
73 extern
74 void afb_calls_hooked_call(
75                 struct afb_export *export,
76                 const char *api,
77                 const char *verb,
78                 struct json_object *args,
79                 void (*callback)(void*, struct json_object*, const char *error, const char *info, struct afb_api_x3*),
80                 void *closure);
81
82 extern
83 int afb_calls_hooked_call_sync(
84                 struct afb_export *export,
85                 const char *api,
86                 const char *verb,
87                 struct json_object *args,
88                 struct json_object **object,
89                 char **error,
90                 char **info);
91
92 extern
93 void afb_calls_hooked_subcall(
94                         struct afb_xreq *xreq,
95                         const char *api,
96                         const char *verb,
97                         struct json_object *args,
98                         int flags,
99                         void (*callback)(void *closure, struct json_object *object, const char *error, const char * info, struct afb_req_x2 *req),
100                         void *closure);
101
102 extern
103 int afb_calls_hooked_subcall_sync(
104                         struct afb_xreq *xreq,
105                         const char *api,
106                         const char *verb,
107                         struct json_object *args,
108                         int flags,
109                         struct json_object **object,
110                         char **error,
111                         char **info);
112
113 #endif /* WITH_AFB_HOOK */
114 /******************************************************************************/
115
116 extern
117 void afb_calls_legacy_call_v12(
118                 struct afb_export *export,
119                 const char *api,
120                 const char *verb,
121                 struct json_object *args,
122                 void (*callback)(void*, int, struct json_object*),
123                 void *closure);
124
125 extern
126 void afb_calls_legacy_call_v3(
127                 struct afb_export *export,
128                 const char *api,
129                 const char *verb,
130                 struct json_object *args,
131                 void (*callback)(void*, int, struct json_object*, struct afb_api_x3 *),
132                 void *closure);
133
134 extern
135 int afb_calls_legacy_call_sync(
136                 struct afb_export *export,
137                 const char *api,
138                 const char *verb,
139                 struct json_object *args,
140                 struct json_object **result);
141
142 /******************************************************************************/
143 #if WITH_AFB_HOOK
144
145 extern
146 void afb_calls_legacy_hooked_call_v12(
147                 struct afb_export *export,
148                 const char *api,
149                 const char *verb,
150                 struct json_object *args,
151                 void (*callback)(void*, int, struct json_object*),
152                 void *closure);
153
154 extern
155 void afb_calls_legacy_hooked_call_v3(
156                 struct afb_export *export,
157                 const char *api,
158                 const char *verb,
159                 struct json_object *args,
160                 void (*callback)(void*, int, struct json_object*, struct afb_api_x3 *),
161                 void *closure);
162
163 extern
164 int afb_calls_legacy_hooked_call_sync(
165                 struct afb_export *export,
166                 const char *api,
167                 const char *verb,
168                 struct json_object *args,
169                 struct json_object **result);
170
171 #endif /* WITH_AFB_HOOK */
172 /******************************************************************************/
173
174 extern
175 void afb_calls_legacy_subcall_v1(
176                 struct afb_xreq *caller,
177                 const char *api,
178                 const char *verb,
179                 struct json_object *args,
180                 void (*callback)(void*, int, struct json_object*),
181                 void *closure);
182
183 extern
184 void afb_calls_legacy_subcall_v2(
185                 struct afb_xreq *caller,
186                 const char *api,
187                 const char *verb,
188                 struct json_object *args,
189                 void (*callback)(void*, int, struct json_object*, struct afb_req_x1),
190                 void *closure);
191
192 extern
193 void afb_calls_legacy_subcall_v3(
194                 struct afb_xreq *caller,
195                 const char *api,
196                 const char *verb,
197                 struct json_object *args,
198                 void (*callback)(void*, int, struct json_object*, struct afb_req_x2 *),
199                 void *closure);
200
201 extern
202 int afb_calls_legacy_subcall_sync(
203                 struct afb_xreq *caller,
204                 const char *api,
205                 const char *verb,
206                 struct json_object *args,
207                 struct json_object **result);
208
209 /******************************************************************************/
210 #if WITH_AFB_HOOK
211
212 extern
213 void afb_calls_legacy_hooked_subcall_v1(
214                 struct afb_xreq *caller,
215                 const char *api,
216                 const char *verb,
217                 struct json_object *args,
218                 void (*callback)(void*, int, struct json_object*),
219                 void *closure);
220
221 extern
222 void afb_calls_legacy_hooked_subcall_v2(
223                 struct afb_xreq *caller,
224                 const char *api,
225                 const char *verb,
226                 struct json_object *args,
227                 void (*callback)(void*, int, struct json_object*, struct afb_req_x1),
228                 void *closure);
229
230 extern
231 void afb_calls_legacy_hooked_subcall_v3(
232                 struct afb_xreq *caller,
233                 const char *api,
234                 const char *verb,
235                 struct json_object *args,
236                 void (*callback)(void*, int, struct json_object*, struct afb_req_x2 *),
237                 void *closure);
238
239 extern
240 int afb_calls_legacy_hooked_subcall_sync(
241                 struct afb_xreq *caller,
242                 const char *api,
243                 const char *verb,
244                 struct json_object *args,
245                 struct json_object **result);
246
247 #endif /* WITH_AFB_HOOK */
248 /******************************************************************************/