ea184df14a256ac974801e2d73b5df707e73ff39
[src/app-framework-binder.git] / src / afb-api-dyn.h
1 /*
2  * Copyright (C) 2016, 2017 "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
19 #pragma once
20
21 struct afb_apiset;
22 struct afb_dynapi;
23 struct afb_auth;
24 struct afb_request;
25 struct afb_verb_v2;
26
27 struct afb_api_dyn_verb
28 {
29         void (*callback)(struct afb_request *request);
30         const struct afb_auth *auth;
31         const char *info;
32         int session;
33         char verb[1];
34 };
35
36 struct afb_api_dyn;
37
38 extern int afb_api_dyn_add(struct afb_apiset *apiset, const char *name, const char *info, int (*preinit)(void*, struct afb_dynapi*), void *closure);
39
40 extern void afb_api_dyn_set_verbs_v2(
41                 struct afb_api_dyn *dynapi,
42                 const struct afb_verb_v2 *verbs);
43
44 extern int afb_api_dyn_add_verb(
45                 struct afb_api_dyn *dynapi,
46                 const char *verb,
47                 const char *info,
48                 void (*callback)(struct afb_request *request),
49                 const struct afb_auth *auth,
50                 uint32_t session);
51
52 extern int afb_api_dyn_sub_verb(
53                 struct afb_api_dyn *dynapi,
54                 const char *verb);
55