61180e27dc0afc3e649cfa0774a00834be496416
[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(struct afb_apiset *apiset, const char *name, const char *info, int (*preinit)(void*, struct afb_dynapi*), void *closure);
40
41 extern void afb_api_dyn_set_verbs_v2(
42                 struct afb_api_dyn *dynapi,
43                 const struct afb_verb_v2 *verbs);
44
45 extern int afb_api_dyn_add_verb(
46                 struct afb_api_dyn *dynapi,
47                 const char *verb,
48                 const char *info,
49                 void (*callback)(struct afb_request *request),
50                 void *vcbdata,
51                 const struct afb_auth *auth,
52                 uint32_t session);
53
54 extern int afb_api_dyn_sub_verb(
55                 struct afb_api_dyn *dynapi,
56                 const char *verb);
57