--- bus/config-parser.c Fri Jan 26 17:10:09 2007 +++ bus/config-parser.c Sat Mar 10 15:32:49 2007 @@ -689,6 +690,23 @@ return retval; } + +char *_dbus_get_base_dir(void); + +dbus_bool_t +bus_config_get_base_dir(const DBusString *file, + const DBusString *dirname) +{ + char *baseDir = _dbus_get_base_dir(); + if (baseDir) { + _dbus_string_init_const(dirname,baseDir); + return TRUE; + } + if (_dbus_string_get_dirname (file, dirname)) + return TRUE; + return FALSE; +} + static dbus_bool_t check_no_attributes (BusConfigParser *parser, const char *element_name, --- bus/main.c Sat Mar 10 10:10:36 2007 +++ bus/main.c Wed Mar 14 22:31:53 2007 @@ -254,6 +254,12 @@ dbus_bool_t print_pid; int force_fork; +#ifdef DBUS_WIN + extern int _dbus_base_dir_init(char *s); + if (!_dbus_base_dir_init(argv[0])) + return 1; +#endif + if (!_dbus_string_init (&config_file)) return 1; --- dbus/dbus-sysdeps-win.c Sat Mar 10 10:10:36 2007 +++ dbus/dbus-sysdeps-win.c Sun Mar 11 20:28:47 2007 @@ -88,40 +88,50 @@ static DBusString dbusdir; static int working_dir_init = 0; +static char baseDir[1024]; -int _dbus_init_working_dir(char *s) +int _dbus_base_dir_init(char *s) { /* change working directory to one level above of dbus-daemon executable path. This allows the usage of relative path in config files or command line parameters */ DBusString daemon_path,bin_path; + int result = FALSE; if (!_dbus_string_init (&daemon_path)) - return FALSE; + goto error; if (!_dbus_string_init (&bin_path)) - return FALSE; + goto error; if (!_dbus_string_init (&dbusdir)) - return FALSE; + goto error; _dbus_string_append(&daemon_path,s); _dbus_string_get_dirname(&daemon_path,&bin_path); _dbus_string_get_dirname(&bin_path,&dbusdir); - chdir(_dbus_string_get_const_data(&dbusdir)); - _dbus_verbose ("Change working path to %s\n",_dbus_string_get_const_data (&dbusdir)); + strcpy(baseDir,_dbus_string_get_const_data(&dbusdir)); + chdir(baseDir); + + _dbus_verbose ("Change working path to %s\n",baseDir); working_dir_init = 1; - return TRUE; + result = TRUE; + +error: + _dbus_string_free(&daemon_path); + _dbus_string_free(&bin_path); + _dbus_string_free(&dbusdir); + return result; } -DBusString *_dbus_get_working_dir(void) +char *_dbus_get_base_dir(void) { if (!working_dir_init) return NULL; - _dbus_verbose ("retrieving working path %s\n",_dbus_string_get_const_data (&dbusdir)); - return &dbusdir; + _dbus_verbose ("retrieving working path %s\n",baseDir); + return baseDir; } /**