diff options
author | Max Kellermann <max@duempel.org> | 2013-04-09 01:17:47 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2013-04-09 01:17:47 +0200 |
commit | 3f3b26fb0ee090bfc1321572904aa94deca42a84 (patch) | |
tree | f0fe8f98c86ac29782e8c3b5b57dcadcc23f20c4 /src | |
parent | 0921180b9020c2a83d0c1e6636d32278770de5d9 (diff) | |
download | mpd-3f3b26fb0ee090bfc1321572904aa94deca42a84.tar.gz mpd-3f3b26fb0ee090bfc1321572904aa94deca42a84.tar.xz mpd-3f3b26fb0ee090bfc1321572904aa94deca42a84.zip |
utils: convert to C++
Diffstat (limited to 'src')
-rw-r--r-- | src/ConfigData.cxx | 5 | ||||
-rw-r--r-- | src/ConfigGlobal.cxx | 6 | ||||
-rw-r--r-- | src/ConfigPath.cxx (renamed from src/utils.c) | 26 | ||||
-rw-r--r-- | src/ConfigPath.hxx (renamed from src/utils.h) | 6 |
4 files changed, 18 insertions, 25 deletions
diff --git a/src/ConfigData.cxx b/src/ConfigData.cxx index 48e9612d4..dd102a19a 100644 --- a/src/ConfigData.cxx +++ b/src/ConfigData.cxx @@ -19,12 +19,9 @@ #include "ConfigData.hxx" #include "ConfigParser.hxx" +#include "ConfigPath.hxx" #include "mpd_error.h" -extern "C" { -#include "utils.h" -} - #include <glib.h> #include <assert.h> diff --git a/src/ConfigGlobal.cxx b/src/ConfigGlobal.cxx index 9786690d0..a66c03748 100644 --- a/src/ConfigGlobal.cxx +++ b/src/ConfigGlobal.cxx @@ -22,11 +22,7 @@ #include "ConfigParser.hxx" #include "ConfigData.hxx" #include "ConfigFile.hxx" - -extern "C" { -#include "utils.h" -} - +#include "ConfigPath.hxx" #include "mpd_error.h" #include <glib.h> diff --git a/src/utils.c b/src/ConfigPath.cxx index 776813c4b..767115d19 100644 --- a/src/utils.c +++ b/src/ConfigPath.cxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2011 The Music Player Daemon Project + * Copyright (C) 2003-2013 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify @@ -18,7 +18,7 @@ */ #include "config.h" -#include "utils.h" +#include "ConfigPath.hxx" #include "conf.h" #include <glib.h> @@ -55,35 +55,35 @@ parse_path_quark(void) char * parsePath(const char *path, G_GNUC_UNUSED GError **error_r) { - assert(path != NULL); - assert(error_r == NULL || *error_r == NULL); + assert(path != nullptr); + assert(error_r == nullptr || *error_r == nullptr); #ifndef WIN32 if (!g_path_is_absolute(path) && path[0] != '~') { g_set_error(error_r, parse_path_quark(), 0, "not an absolute path: %s", path); - return NULL; + return nullptr; } else if (path[0] == '~') { const char *home; if (path[1] == '/' || path[1] == '\0') { - const char *user = config_get_string(CONF_USER, NULL); - if (user != NULL) { + const char *user = config_get_string(CONF_USER, nullptr); + if (user != nullptr) { struct passwd *passwd = getpwnam(user); if (!passwd) { g_set_error(error_r, parse_path_quark(), 0, "no such user: %s", user); - return NULL; + return nullptr; } home = passwd->pw_dir; } else { home = g_get_home_dir(); - if (home == NULL) { + if (home == nullptr) { g_set_error_literal(error_r, parse_path_quark(), 0, "problems getting home " "for current user"); - return NULL; + return nullptr; } } @@ -92,7 +92,7 @@ parsePath(const char *path, G_GNUC_UNUSED GError **error_r) ++path; const char *slash = strchr(path, '/'); - char *user = slash != NULL + char *user = slash != nullptr ? g_strndup(path, slash - path) : g_strdup(path); @@ -101,7 +101,7 @@ parsePath(const char *path, G_GNUC_UNUSED GError **error_r) g_set_error(error_r, parse_path_quark(), 0, "no such user: %s", user); g_free(user); - return NULL; + return nullptr; } g_free(user); @@ -110,7 +110,7 @@ parsePath(const char *path, G_GNUC_UNUSED GError **error_r) path = slash; } - return g_strconcat(home, path, NULL); + return g_strconcat(home, path, nullptr); } else { #endif return g_strdup(path); diff --git a/src/utils.h b/src/ConfigPath.hxx index 059d44fa3..42e51215f 100644 --- a/src/utils.h +++ b/src/ConfigPath.hxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2011 The Music Player Daemon Project + * Copyright (C) 2003-2013 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify @@ -17,8 +17,8 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#ifndef MPD_UTILS_H -#define MPD_UTILS_H +#ifndef MPD_CONFIG_PATH_HXX +#define MPD_CONFIG_PATH_HXX #include "gerror.h" |