diff --git a/inc/lektor/config.h b/inc/lektor/config.h index afba36ba0eb6bdd0f8d491a45374daed0220b786..7a2bf0fbf92181e3cbe6c47dff566239def8b205 100644 --- a/inc/lektor/config.h +++ b/inc/lektor/config.h @@ -8,12 +8,14 @@ /* Forward definition of the lkt_state structure */ struct lkt_state; -#define section(sct) "\n[" sct "]\n" -#define value(key, val) key " = " val "\n" +#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 diff --git a/inc/lektor/config.inc b/inc/lektor/config.inc index 35f4b1bf132d8eff07aee3f3749debc968bc3529..fc0ba35475ef56cb60b14923504ddbc9bd6b09a4 100644 --- a/inc/lektor/config.inc +++ b/inc/lektor/config.inc @@ -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") diff --git a/src/config.c b/src/config.c index 7fd1c905259f1bdf0005c8619da272c4ae61900c..4a59d05c405d83f8219caf8af707a10ba01447ef 100644 --- a/src/config.c +++ b/src/config.c @@ -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; } @@ -152,7 +157,8 @@ inline static int validate_conf(volatile sqlite3 *db) { const char *section; -#define section(_sct) section = _sct; +#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; } diff --git a/src/reg.c b/src/reg.c index 69bc8afa6850de3aa40dcdf4e232de8cd6ddb1ab..3a4546fd08944cd9cc3b9055392a12c906181f19 100644 --- a/src/reg.c +++ b/src/reg.c @@ -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 */