89b1f78edf4bcefe7e25b74776591e3d7dfe8f33
[src/app-framework-binder.git] / src / afb-config.h
1 /*
2  * Copyright (C) 2015-2018 "IoT.bzh"
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *   http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #pragma once
18
19 struct json_object;
20
21 /*
22  * other definitions ---------------------------------------------------
23  */
24
25 struct afb_config_list {
26         struct afb_config_list *next;
27         char *value;
28 };
29
30 // main config structure
31 struct afb_config {
32         char *console;          // console device name (can be a file or a tty)
33         char *rootdir;          // base dir for files
34         char *roothttp;         // directory for http files
35         char *rootbase;         // Angular HTML5 base URL
36         char *rootapi;          // Base URL for REST APIs
37         char *workdir;          // where to run the program
38         char *uploaddir;        // where to store transient files
39         char *token;            // initial authentication token [default NULL no session]
40         char *name;             /* name to set to the daemon */
41
42         struct afb_config_list *aliases;
43 #if defined(WITH_DBUS_TRANSPARENCY)
44         struct afb_config_list *dbus_clients;
45         struct afb_config_list *dbus_servers;
46 #endif
47         struct afb_config_list *ws_clients;
48         struct afb_config_list *ws_servers;
49         struct afb_config_list *so_bindings;
50         struct afb_config_list *ldpaths;
51         struct afb_config_list *weak_ldpaths;
52         struct afb_config_list *calls;
53
54         char **exec;
55
56         /* integers */
57         int httpdPort;
58         int cacheTimeout;
59         int apiTimeout;
60         int cntxTimeout;        // Client Session Context timeout
61         int nbSessionMax;       // max count of sessions
62
63         /* enums */
64         int mode;               // mode of listening
65         int tracereq;
66         int traceditf;
67         int tracesvc;
68         int traceevt;
69         int traceses;
70
71         /* booleans */
72         unsigned no_ldpaths: 1;         /* disable default ldpaths */
73         unsigned noHttpd: 1;
74         unsigned background: 1;         /* run in backround mode */
75 #if defined(WITH_MONITORING_OPTION)
76         unsigned monitoring: 1;         /* activates monitoring */
77 #endif
78         unsigned random_token: 1;       /* expects a random token */
79 };
80
81 extern struct afb_config *afb_config_parse_arguments(int argc, char **argv);
82 extern void afb_config_dump(struct afb_config *config);
83 extern struct json_object *afb_config_json(struct afb_config *config);
84