-
Notifications
You must be signed in to change notification settings - Fork 2
/
capi_config.cpp
131 lines (104 loc) · 3.37 KB
/
capi_config.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#include "main.h"
#include "elf.h"
#include "package.h"
#include "db.h"
#include "pkgdepdb.h"
using namespace pkgdepdb;
extern "C" {
pkgdepdb_cfg *pkgdepdb_cfg_new() {
return reinterpret_cast<pkgdepdb_cfg*>(new Config);
}
void pkgdepdb_cfg_delete(pkgdepdb_cfg *cfg_) {
auto cfg = reinterpret_cast<Config*>(cfg_);
delete cfg;
}
pkgdepdb_bool pkgdepdb_cfg_load_default(pkgdepdb_cfg *cfg_) {
auto cfg = reinterpret_cast<Config*>(cfg_);
return cfg->ReadConfig();
}
pkgdepdb_bool pkgdepdb_cfg_load(pkgdepdb_cfg *cfg_, const char *filepath)
{
auto cfg = reinterpret_cast<Config*>(cfg_);
return cfg->ReadConfig(filepath);
}
pkgdepdb_bool pkgdepdb_cfg_read(pkgdepdb_cfg *cfg_, const char *name,
const char *data, size_t length)
{
auto cfg = reinterpret_cast<Config*>(cfg_);
return cfg->ReadConfig(name, data, length);
}
const char *pkgdepdb_cfg_database(pkgdepdb_cfg *cfg_) {
auto cfg = reinterpret_cast<Config*>(cfg_);
return cfg->database_.c_str();
}
void pkgdepdb_cfg_set_database(pkgdepdb_cfg *cfg_, const char *path) {
auto cfg = reinterpret_cast<Config*>(cfg_);
cfg->database_ = path;
}
unsigned int pkgdepdb_cfg_verbosity(pkgdepdb_cfg *cfg_) {
auto cfg = reinterpret_cast<Config*>(cfg_);
return cfg->verbosity_;
}
void pkgdepdb_cfg_set_verbosity(pkgdepdb_cfg *cfg_, unsigned int v) {
auto cfg = reinterpret_cast<Config*>(cfg_);
cfg->verbosity_ = v;
}
pkgdepdb_bool pkgdepdb_cfg_quiet(pkgdepdb_cfg *cfg_) {
auto cfg = reinterpret_cast<Config*>(cfg_);
return cfg->quiet_;
}
void pkgdepdb_cfg_set_quiet(pkgdepdb_cfg *cfg_, pkgdepdb_bool v) {
auto cfg = reinterpret_cast<Config*>(cfg_);
cfg->quiet_ = v;
}
pkgdepdb_bool pkgdepdb_cfg_package_depends(pkgdepdb_cfg *cfg_) {
auto cfg = reinterpret_cast<Config*>(cfg_);
return cfg->package_depends_;
}
void pkgdepdb_cfg_set_package_depends(pkgdepdb_cfg *cfg_,
pkgdepdb_bool v)
{
auto cfg = reinterpret_cast<Config*>(cfg_);
cfg->package_depends_ = !!v;
}
pkgdepdb_bool pkgdepdb_cfg_package_file_lists(pkgdepdb_cfg *cfg_) {
auto cfg = reinterpret_cast<Config*>(cfg_);
return cfg->package_filelist_;
}
void pkgdepdb_cfg_set_package_file_lists(pkgdepdb_cfg *cfg_, pkgdepdb_bool v) {
auto cfg = reinterpret_cast<Config*>(cfg_);
cfg->package_filelist_ = !!v;
}
pkgdepdb_bool pkgdepdb_cfg_package_info(pkgdepdb_cfg *cfg_) {
auto cfg = reinterpret_cast<Config*>(cfg_);
return cfg->package_info_;
}
void pkgdepdb_cfg_set_package_info(pkgdepdb_cfg *cfg_, pkgdepdb_bool v) {
auto cfg = reinterpret_cast<Config*>(cfg_);
cfg->package_info_ = !!v;
}
unsigned int pkgdepdb_cfg_max_jobs(pkgdepdb_cfg *cfg_) {
auto cfg = reinterpret_cast<Config*>(cfg_);
return cfg->max_jobs_;
}
void pkgdepdb_cfg_set_max_jobs(pkgdepdb_cfg *cfg_, unsigned int v) {
auto cfg = reinterpret_cast<Config*>(cfg_);
cfg->max_jobs_ = v;
}
unsigned int pkgdepdb_cfg_log_level(pkgdepdb_cfg *cfg_) {
auto cfg = reinterpret_cast<Config*>(cfg_);
return cfg->log_level_;
}
void pkgdepdb_cfg_set_log_level(pkgdepdb_cfg *cfg_, unsigned int v) {
auto cfg = reinterpret_cast<Config*>(cfg_);
cfg->log_level_ = v;
}
unsigned int pkgdepdb_cfg_json(pkgdepdb_cfg *cfg_) {
auto cfg = reinterpret_cast<Config*>(cfg_);
return cfg->json_;
}
void pkgdepdb_cfg_set_json(pkgdepdb_cfg *cfg_, unsigned int v) {
auto cfg = reinterpret_cast<Config*>(cfg_);
cfg->json_ = v;
}
} // extern "C"