Skip to content
Extraits de code Groupes Projets
Vérifiée Valider dbe81551 rédigé par Kubat's avatar Kubat
Parcourir les fichiers

Differentiate optional and non optional settings in config.inc

parent d72f3a1d
Aucune branche associée trouvée
Aucune étiquette associée trouvée
1 requête de fusion!93Config rewrite
......@@ -10,10 +10,12 @@ struct lkt_state;
#define section(sct) "\n[" sct "]\n"
#define value(key, val) key " = " val "\n"
#define value_opt(key, val) value(key, val)
static const char *const lkt_default_config_file =
#include <lektor/config.inc>
;
#undef value
#undef value_opt
#undef section
/* It is just an alias to the consecutive use of config_detect_file and
......
......@@ -11,7 +11,7 @@ value("kara_dir", "/home/kara")
value("db_path", "/home/kara/kara.db")
section("repo")
value("path", "STATIC")
value_opt("path", "STATIC")
value("load_function", "load_repo_https")
value("name", "Kurisu")
value("url", "https://kurisu.iiens.net")
......@@ -20,7 +20,7 @@ value("id_json", "https://kurisu.iiens.net/api?id=%ld")
value("id_kara", "https://kurisu.iiens.net/download.php?id=%ld")
section("player")
value("path", "STATIC")
value_opt("path", "STATIC")
value("load_function", "load_sdl2")
value("autoclear", "true")
value("def_random", "false")
......
......@@ -139,9 +139,14 @@ load_module_by_name(struct lkt_state *srv, const char *name, void *mod)
{
char mod_path[PATH_MAX], mod_load[INI_MAX_LINE_LEN];
if (!database_config_get_text(srv->db, name, "path", mod_path, PATH_MAX) ||
!database_config_get_text(srv->db, name, "load_function", mod_load, INI_MAX_LINE_LEN)) {
LOG_ERROR("Module named %s is incomplete or is not defined in config file", name);
/* When, don't mind if its not here */
if (!database_config_get_text(srv->db, name, "path", mod_path, PATH_MAX)) {
LOG_WARN_SCT("CONFIG", "No setting 'path' in section '%s'", name);
mod_path[0] = '\0';
}
if (!database_config_get_text(srv->db, name, "load_function", mod_load, INI_MAX_LINE_LEN)) {
LOG_ERROR_SCT("CONFIG", "Module named %s is incomplete or is not defined in config file", name);
return 1;
}
......@@ -153,6 +158,7 @@ validate_conf(volatile sqlite3 *db)
{
const char *section;
#define section(_sct) section = _sct;
#define value_opt(name, value)
#define value(name, value) \
if (!database_config_exists(db, section, name)) { \
LOG_ERROR_SCT("CONFIG", "Missing option \""name"\" in section \"%s\"", \
......@@ -162,6 +168,7 @@ validate_conf(volatile sqlite3 *db)
#include <lektor/config.inc>
#undef section
#undef value
#undef value_opt
return 0;
}
......
......@@ -17,7 +17,7 @@ reg_pick(const char *file, void **handle, const char *symbol)
return NULL;
/* Use the register instead of dlfcn? */
if (!file || STR_MATCH(file, "STATIC") || handle == NULL)
if (!file || file[0] == '\0' || STR_MATCH(file, "STATIC") || handle == NULL)
goto use_reg;
/* Use dlsym */
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter