From b7e0fde00230c86f20c66ef6b40bc628478f9bf6 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 18 Sep 2015 17:52:07 +0100 Subject: [PATCH 6/7] Rename getters for session, system config files It turns out to be easier to implement the Windows version of these in a relocatable way if it can assume that the argument starts empty, which is in fact true in practice. --- bus/main.c | 4 ++-- dbus/dbus-sysdeps-util-unix.c | 16 ++++++++++------ dbus/dbus-sysdeps-util-win.c | 16 ++++++++++------ dbus/dbus-sysdeps.h | 4 ++-- 4 files changed, 24 insertions(+), 16 deletions(-) diff --git a/bus/main.c b/bus/main.c index ee5e1eb..612b4a6 100644 --- a/bus/main.c +++ b/bus/main.c @@ -440,14 +440,14 @@ main (int argc, char **argv) { check_two_config_files (&config_file, "system"); - if (!_dbus_append_system_config_file (&config_file)) + if (!_dbus_get_system_config_file (&config_file)) exit (1); } else if (strcmp (arg, "--session") == 0) { check_two_config_files (&config_file, "session"); - if (!_dbus_append_session_config_file (&config_file)) + if (!_dbus_get_session_config_file (&config_file)) exit (1); } else if (strstr (arg, "--config-file=") == arg) diff --git a/dbus/dbus-sysdeps-util-unix.c b/dbus/dbus-sysdeps-util-unix.c index 1a4fa07..8e61e5b 100644 --- a/dbus/dbus-sysdeps-util-unix.c +++ b/dbus/dbus-sysdeps-util-unix.c @@ -1438,27 +1438,31 @@ _dbus_get_standard_system_servicedirs (DBusList **dirs) } /** - * Append the absolute path of the system.conf file + * Get the absolute path of the system.conf file * (there is no system bus on Windows so this can just * return FALSE and print a warning or something) * - * @param str the string to append to + * @param str the string to append to, which must be empty on entry * @returns #FALSE if no memory */ dbus_bool_t -_dbus_append_system_config_file (DBusString *str) +_dbus_get_system_config_file (DBusString *str) { + _dbus_assert (_dbus_string_get_length (str) == 0); + return _dbus_string_append (str, DBUS_SYSTEM_CONFIG_FILE); } /** - * Append the absolute path of the session.conf file. + * Get the absolute path of the session.conf file. * - * @param str the string to append to + * @param str the string to append to, which must be empty on entry * @returns #FALSE if no memory */ dbus_bool_t -_dbus_append_session_config_file (DBusString *str) +_dbus_get_session_config_file (DBusString *str) { + _dbus_assert (_dbus_string_get_length (str) == 0); + return _dbus_string_append (str, DBUS_SESSION_CONFIG_FILE); } diff --git a/dbus/dbus-sysdeps-util-win.c b/dbus/dbus-sysdeps-util-win.c index f2ed1a7..244c7d8 100644 --- a/dbus/dbus-sysdeps-util-win.c +++ b/dbus/dbus-sysdeps-util-win.c @@ -1710,27 +1710,31 @@ _dbus_get_config_file_name (DBusString *str, } /** - * Append the absolute path of the system.conf file + * Get the absolute path of the system.conf file * (there is no system bus on Windows so this can just * return FALSE and print a warning or something) * - * @param str the string to append to + * @param str the string to append to, which must be empty on entry * @returns #FALSE if no memory */ dbus_bool_t -_dbus_append_system_config_file (DBusString *str) +_dbus_get_system_config_file (DBusString *str) { + _dbus_assert (_dbus_string_get_length (str) == 0); + return _dbus_get_config_file_name(str, "system.conf"); } /** - * Append the absolute path of the session.conf file. + * Get the absolute path of the session.conf file. * - * @param str the string to append to + * @param str the string to append to, which must be empty on entry * @returns #FALSE if no memory */ dbus_bool_t -_dbus_append_session_config_file (DBusString *str) +_dbus_get_session_config_file (DBusString *str) { + _dbus_assert (_dbus_string_get_length (str) == 0); + return _dbus_get_config_file_name(str, "session.conf"); } diff --git a/dbus/dbus-sysdeps.h b/dbus/dbus-sysdeps.h index 4afe065..260417d 100644 --- a/dbus/dbus-sysdeps.h +++ b/dbus/dbus-sysdeps.h @@ -432,8 +432,8 @@ dbus_bool_t _dbus_path_is_absolute (const DBusString *filename); dbus_bool_t _dbus_get_standard_session_servicedirs (DBusList **dirs); dbus_bool_t _dbus_get_standard_system_servicedirs (DBusList **dirs); -dbus_bool_t _dbus_append_system_config_file (DBusString *str); -dbus_bool_t _dbus_append_session_config_file (DBusString *str); +dbus_bool_t _dbus_get_system_config_file (DBusString *str); +dbus_bool_t _dbus_get_session_config_file (DBusString *str); /** Opaque type for reading a directory listing */ typedef struct DBusDirIter DBusDirIter; -- 2.5.1