c39000822380b28223422130ec6fee98fc95cf8c
[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 /**
26  * list of configuration values
27  */
28 struct afb_config_list {
29         struct afb_config_list *next;
30         char *value;
31 };
32
33 /**
34  * main config structure
35  */
36 struct afb_config {
37         char *console;          /*< console device name (can be a file or a tty) */
38         char *rootdir;          /*< base dir for files */
39         char *roothttp;         /*< directory for http files */
40         char *rootbase;         /*< Angular HTML5 base URL */
41         char *rootapi;          /*< Base URL for REST APIs */
42         char *workdir;          /*< where to run the program */
43         char *uploaddir;        /*< where to store transient files */
44         char *token;            /*< initial authentication token [default NULL no session] */
45         char *name;             /*< name to set to the daemon */
46
47         struct afb_config_list *aliases;
48 #if defined(WITH_DBUS_TRANSPARENCY)
49         struct afb_config_list *dbus_clients;
50         struct afb_config_list *dbus_servers;
51 #endif
52         struct afb_config_list *ws_clients;
53         struct afb_config_list *ws_servers;
54         struct afb_config_list *so_bindings;
55         struct afb_config_list *ldpaths;
56         struct afb_config_list *weak_ldpaths;
57         struct afb_config_list *calls;
58         struct afb_config_list *auto_api;
59
60         char **exec;
61
62         /* integers */
63         int http_port;
64         int cache_timeout;
65         int api_timeout;
66         int session_timeout;    /*< session timeout */
67         int max_session_count;  /*< max count of sessions */
68
69         /* enums */
70 #if defined(KEEP_LEGACY_MODE)
71         int mode;               // mode of listening
72 #endif
73         int tracereq;
74 #if !defined(REMOVE_LEGACY_TRACE)
75         int traceditf;
76         int tracesvc;
77 #endif
78         int traceevt;
79         int traceses;
80         int traceapi;
81
82         /* booleans */
83         unsigned no_ldpaths: 1;         /**< disable default ldpaths */
84         unsigned no_httpd: 1;
85         unsigned background: 1;         /**< run in backround mode */
86         unsigned random_token: 1;       /**< expects a random token */
87 #if defined(WITH_MONITORING_OPTION)
88         unsigned monitoring: 1;         /**< activates monitoring */
89 #endif
90 };
91
92 extern struct afb_config *afb_config_parse_arguments(int argc, char **argv);
93 extern void afb_config_dump(struct afb_config *config);
94 extern struct json_object *afb_config_json(struct afb_config *config);
95