Release 5.5.35
[platform/core/system/crash-worker.git] / src / shared / config.h
1 /*
2  * crash-manager
3  * Copyright (c) 2019 Samsung Electronics Co., Ltd.
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 #ifndef __DEF_CONFIG_H_
18 #define __DEF_CONFIG_H_
19
20 #include <stdbool.h>
21
22 /* Configuration default values */
23 /* note: 0 means unlimited */
24 #define SYSTEM_MAX_USE       0
25 #define SYSTEM_KEEP_FREE     0
26 #define MAX_RETENTION_SEC    0
27 #define MAX_CRASH_DUMP       0
28 #define DUMP_CORE            1
29 #define DUMP_SO_INFO         1
30 #define ALLOW_ZIP            1
31 #define LEGACY_NOTIFICATION  0
32
33 #define CRASH_SECTION        "CrashManager"
34
35 /* ExcludePaths section name must be lowercase with iniparser 3.x.
36  *
37  * This is to workaround for iniparser 3.x bug, where loaded strings
38  * are converted to lowercase, but query string is not, precisely
39  * getsecnkeys() does strcmp(lowercase-key-in-db, user-provided-str).
40  */
41 #define EXCLUDEPATHS_SECTION "excludepaths"
42
43 enum ReportType {
44         REP_TYPE_INVALID = -1,
45         REP_TYPE_INFO = 0,
46         REP_TYPE_FULL,
47         REP_TYPE_DEFAULT = REP_TYPE_FULL,
48 };
49
50 typedef struct config {
51         bool allow_zip;
52         bool dump_core;
53         bool dump_so_info;
54         bool legacy_notification;
55         enum ReportType report_type;
56         int system_max_use;
57         int system_keep_free;
58         int max_retention_sec;
59         int max_crash_dump;
60         int n_exclude_paths;
61         char **exclude_paths;
62         char *crash_root_path;
63         char *extra_script;
64
65 } config_t;
66
67
68 #ifdef __cplusplus
69 extern "C" {
70 #endif
71
72 bool config_init(config_t *c, const char *const path);
73 void config_free(config_t *c);
74
75 bool config_is_path_excluded(config_t *c, const char *const path);
76
77 #ifdef __cplusplus
78 }
79 #endif
80
81 /**
82  * @}
83  */
84 #endif