config_libconfig: rename xdg* functions

To fit our naming convention.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
Yuxuan Shui 2020-03-01 13:48:04 +00:00
parent 7161296872
commit 2f0b7cd992
No known key found for this signature in database
GPG Key ID: 37C999F617EA1A47
1 changed files with 7 additions and 7 deletions

View File

@ -36,7 +36,7 @@ static inline int lcfg_lookup_bool(const config_t *config, const char *path, boo
return ret; return ret;
} }
const char *xdgConfigHome(void) { const char *xdg_config_home(void) {
char *xdgh = getenv("XDG_CONFIG_HOME"); char *xdgh = getenv("XDG_CONFIG_HOME");
char *home = getenv("HOME"); char *home = getenv("HOME");
@ -52,7 +52,7 @@ const char *xdgConfigHome(void) {
return xdgh; return xdgh;
} }
char **xdgConfigDirectories(void) { char **xdg_config_dirs(void) {
char *xdgd = getenv("XDG_CONFIG_DIRS"); char *xdgd = getenv("XDG_CONFIG_DIRS");
size_t count = 0; size_t count = 0;
@ -100,20 +100,20 @@ TEST_CASE(xdg_config_dirs) {
} }
unsetenv("XDG_CONFIG_DIRS"); unsetenv("XDG_CONFIG_DIRS");
auto result = xdgConfigDirectories(); auto result = xdg_config_dirs();
TEST_STREQUAL(result[0], "/etc/xdg"); TEST_STREQUAL(result[0], "/etc/xdg");
TEST_EQUAL(result[1], NULL); TEST_EQUAL(result[1], NULL);
free(result); free(result);
setenv("XDG_CONFIG_DIRS", ".:.:/etc/xdg:.:/:", 1); setenv("XDG_CONFIG_DIRS", ".:.:/etc/xdg:.:/:", 1);
result = xdgConfigDirectories(); result = xdg_config_dirs();
TEST_STREQUAL(result[0], "/etc/xdg"); TEST_STREQUAL(result[0], "/etc/xdg");
TEST_STREQUAL(result[1], "/"); TEST_STREQUAL(result[1], "/");
TEST_EQUAL(result[2], NULL); TEST_EQUAL(result[2], NULL);
free(result); free(result);
setenv("XDG_CONFIG_DIRS", ":", 1); setenv("XDG_CONFIG_DIRS", ":", 1);
result = xdgConfigDirectories(); result = xdg_config_dirs();
TEST_EQUAL(result[0], NULL); TEST_EQUAL(result[0], NULL);
free(result); free(result);
@ -164,7 +164,7 @@ FILE *open_config_file(const char *cpath, char **ppath) {
} }
// First search for config file in user config directory // First search for config file in user config directory
auto config_home = xdgConfigHome(); auto config_home = xdg_config_home();
auto ret = open_config_file_at(config_home, ppath); auto ret = open_config_file_at(config_home, ppath);
free((void *)config_home); free((void *)config_home);
if (ret) { if (ret) {
@ -187,7 +187,7 @@ FILE *open_config_file(const char *cpath, char **ppath) {
} }
// Fall back to config file in system config directory // Fall back to config file in system config directory
auto config_dirs = xdgConfigDirectories(); auto config_dirs = xdg_config_dirs();
for (int i = 0; config_dirs[i]; i++) { for (int i = 0; config_dirs[i]; i++) {
ret = open_config_file_at(config_dirs[i], ppath); ret = open_config_file_at(config_dirs[i], ppath);
if (ret) { if (ret) {