/** * @file conf.hpp * @brief Reading the .conf files, and interpreting the values they carry * * @copyright Copyright (c) 2026 SILO GROUP LLC * @author Chris Punches * * Part of the Dark Horse Linux Package Manager (DPM) * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ #pragma once #include struct dpm_ctx; namespace dpm_core { /** * @brief Reads every .conf file in a context's configuration directory * * Each file becomes one namespace in the store, named after the file * without its extension, so core.conf fills "core" and mymodule.conf * fills "mymodule". Files with any other extension are ignored. * * A missing or unreadable directory leaves the store empty, which * leaves every setting at its default. * * @param ctx The libdpm-core.so context */ void load_config_dir(dpm_ctx* ctx); /** * @brief Interprets a configured boolean value * * @param v The configured value * @param fallback Returned when the value matches no known spelling * @return The interpreted boolean, or the fallback */ bool parse_bool(const std::string& v, bool fallback); /** * @brief Maps a configured log level name to its numeric level * * @param v The level name read from configuration * @param fallback Returned when the name is unrecognized * @return A DPM_LOG_* value, or the fallback */ int log_level_str2enum(const std::string& v, int fallback); } // namespace dpm_core