test/read_conf: use struct ConfigData
This commit is contained in:
parent
428c2ec0e3
commit
ea5096ac90
|
@ -18,7 +18,9 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "config/Global.hxx"
|
#include "config/Data.hxx"
|
||||||
|
#include "config/Param.hxx"
|
||||||
|
#include "config/File.hxx"
|
||||||
#include "fs/Path.hxx"
|
#include "fs/Path.hxx"
|
||||||
#include "fs/Path.hxx"
|
#include "fs/Path.hxx"
|
||||||
#include "util/PrintException.hxx"
|
#include "util/PrintException.hxx"
|
||||||
|
@ -42,16 +44,14 @@ try {
|
||||||
if (option == ConfigOption::MAX)
|
if (option == ConfigOption::MAX)
|
||||||
throw FormatRuntimeError("Unknown setting: %s", name);
|
throw FormatRuntimeError("Unknown setting: %s", name);
|
||||||
|
|
||||||
config_global_init();
|
ConfigData config;
|
||||||
|
ReadConfigFile(config, config_path);
|
||||||
|
|
||||||
ReadConfigFile(config_path);
|
const auto *param = config.GetParam(option);
|
||||||
|
if (param == nullptr)
|
||||||
const char *value = config_get_string(option);
|
|
||||||
if (value == nullptr)
|
|
||||||
throw FormatRuntimeError("No such setting: %s", name);
|
throw FormatRuntimeError("No such setting: %s", name);
|
||||||
|
|
||||||
printf("%s\n", value);
|
printf("%s\n", param->value.c_str());
|
||||||
config_global_finish();
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
PrintException(std::current_exception());
|
PrintException(std::current_exception());
|
||||||
|
|
Loading…
Reference in New Issue