21626eed8e0273afe3a474b2ceab18a9db12ac3c
[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         void *vcbdata;
31         const struct afb_auth *auth;
32         const char *info;
33         int session;
34         char verb[1];
35 };
36
37 struct afb_api_dyn;
38
39 extern int afb_api_dyn_add(
40                 struct afb_apiset *apiset,
41                 const char *name,
42                 const char *info,
43                 int noconcurrency,
44                 int (*preinit)(void*, struct afb_dynapi*),
45                 void *closure);
46
47 extern void afb_api_dyn_set_verbs_v2(
48                 struct afb_api_dyn *dynapi,
49                 const struct afb_verb_v2 *verbs);
50
51 extern int afb_api_dyn_add_verb(
52                 struct afb_api_dyn *dynapi,
53                 const char *verb,
54                 const char *info,
55                 void (*callback)(struct afb_request *request),
56                 void *vcbdata,
57                 const struct afb_auth *auth,
58                 uint32_t session);
59
60 extern int afb_api_dyn_sub_verb(
61                 struct afb_api_dyn *dynapi,
62                 const char *verb);
63