Index: bus/config-loader-expat.c =================================================================== RCS file: /cvs/dbus/dbus/bus/config-loader-expat.c,v retrieving revision 1.10 diff -u -r1.10 config-loader-expat.c --- bus/config-loader-expat.c 10 Aug 2004 03:06:59 -0000 1.10 +++ bus/config-loader-expat.c 17 Mar 2007 08:26:58 -0000 @@ -203,7 +202,7 @@ goto failed; } - if (!_dbus_string_get_dirname (file, &dirname)) + if (!bus_config_get_base_dir (file, &dirname)) { dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL); goto failed; Index: bus/config-loader-libxml.c =================================================================== RCS file: /cvs/dbus/dbus/bus/config-loader-libxml.c,v retrieving revision 1.8 diff -u -r1.8 config-loader-libxml.c --- bus/config-loader-libxml.c 10 Aug 2004 03:06:59 -0000 1.8 +++ bus/config-loader-libxml.c 17 Mar 2007 08:27:12 -0000 @@ -177,7 +175,7 @@ xmlSetGenericErrorFunc (NULL, xml_shut_up); } - if (!_dbus_string_get_dirname (file, &dirname)) + if (!_dbus_string_get_base_dir (file, &dirname)) { _DBUS_SET_OOM (error); goto failed; Index: bus/config-parser.c =================================================================== RCS file: /cvs/dbus/dbus/bus/config-parser.c,v retrieving revision 1.49 diff -u -r1.49 config-parser.c --- bus/config-parser.c 15 Mar 2007 13:27:01 -0000 1.49 +++ bus/config-parser.c 17 Mar 2007 08:20:53 -0000 @@ -690,6 +690,22 @@ return retval; } + + +dbus_bool_t +bus_config_get_base_dir(const DBusString *file, + const DBusString *dirname) +{ + char *baseDir = _dbus_base_dir_get(); + 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, Index: bus/config-parser.h =================================================================== RCS file: /cvs/dbus/dbus/bus/config-parser.h,v retrieving revision 1.18 diff -u -r1.18 config-parser.h --- bus/config-parser.h 15 Jun 2005 02:31:38 -0000 1.18 +++ bus/config-parser.h 17 Mar 2007 07:59:41 -0000 @@ -82,4 +82,7 @@ const BusConfigParser *parent, DBusError *error); +dbus_bool_t bus_config_get_base_dir (const DBusString *file, + const DBusString *basedir); + #endif /* BUS_CONFIG_PARSER_H */ Index: bus/main.c =================================================================== RCS file: /cvs/dbus/dbus/bus/main.c,v retrieving revision 1.38 diff -u -r1.38 main.c --- bus/main.c 12 Mar 2007 22:52:39 -0000 1.38 +++ bus/main.c 17 Mar 2007 09:15:41 -0000 @@ -254,6 +254,8 @@ dbus_bool_t print_pid; int force_fork; + _dbus_base_dir_init(argv[0]); + if (!_dbus_string_init (&config_file)) return 1; Index: dbus/dbus-sysdeps-unix.c =================================================================== RCS file: /cvs/dbus/dbus/dbus/dbus-sysdeps-unix.c,v retrieving revision 1.25 diff -u -r1.25 dbus-sysdeps-unix.c --- dbus/dbus-sysdeps-unix.c 16 Mar 2007 21:56:33 -0000 1.25 +++ dbus/dbus-sysdeps-unix.c 17 Mar 2007 09:14:34 -0000 @@ -75,6 +75,15 @@ #define socklen_t int #endif +dbus_bool_t _dbus_base_dir_init(char *progpath) +{ +} + +char *_dbus_base_dir_get(void) +{ + return NULL; +} + static dbus_bool_t _dbus_open_socket (int *fd, int domain, Index: dbus/dbus-sysdeps-win.c =================================================================== RCS file: /cvs/dbus/dbus/dbus/dbus-sysdeps-win.c,v retrieving revision 1.9 diff -u -r1.9 dbus-sysdeps-win.c --- dbus/dbus-sysdeps-win.c 16 Mar 2007 21:56:33 -0000 1.9 +++ dbus/dbus-sysdeps-win.c 17 Mar 2007 09:15:07 -0000 @@ -85,43 +85,60 @@ #endif static DBusHashTable *sid_atom_cache = NULL; +static int base_dir_init = 0; +static char baseDir[1024]; -static DBusString dbusdir; -static int working_dir_init = 0; +/** + save the base directory for configuration files. + This directory is used to relocated relative + patches in configuration files. + @progpath full path and application name -int _dbus_init_working_dir(char *s) + @return char pointer to base dir or zero if not set +*/ +dbus_bool_t _dbus_base_dir_init(char *progpath) { - /* 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; + DBusString daemon_path; + char *p; + int found; - if (!_dbus_string_init (&daemon_path)) - return FALSE; - - if (!_dbus_string_init (&bin_path)) - return FALSE; + if (!_dbus_string_init(&daemon_path)) + { + _dbus_string_free(&daemon_path); + return FALSE; + } + _dbus_string_append(&daemon_path,progpath); + if (!_dbus_string_find(&daemon_path,0,"bin",&found)) + { + _dbus_string_free(&daemon_path); + return FALSE; + } + if(!_dbus_string_copy_data_len(&daemon_path,&p,0,found-1)) + { + _dbus_string_free(&daemon_path); + return FALSE; + } + strcpy(baseDir,p); + chdir(baseDir); - if (!_dbus_string_init (&dbusdir)) - return FALSE; - - _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)); - working_dir_init = 1; + _dbus_verbose ("set configuration base dir to %s\n",baseDir); + base_dir_init = 1; + _dbus_string_free(&daemon_path); return TRUE; } -DBusString *_dbus_get_working_dir(void) +/** + return the configuration file base dir for + relocating relative pathes + @return char pointer to base dir or zero if not set +*/ +char *_dbus_base_dir_get(void) { - if (!working_dir_init) + if (!base_dir_init) return NULL; - _dbus_verbose ("retrieving working path %s\n",_dbus_string_get_const_data (&dbusdir)); - return &dbusdir; + _dbus_verbose ("retrieving configuration base dir %s\n",baseDir); + return baseDir; } /** Index: dbus/dbus-sysdeps.h =================================================================== RCS file: /cvs/dbus/dbus/dbus/dbus-sysdeps.h,v retrieving revision 1.73 diff -u -r1.73 dbus-sysdeps.h --- dbus/dbus-sysdeps.h 16 Mar 2007 21:56:33 -0000 1.73 +++ dbus/dbus-sysdeps.h 17 Mar 2007 08:25:52 -0000 @@ -472,6 +473,8 @@ const char *suffix, DBusList **dir_list); +dbus_bool_t _dbus_base_dir_init(char *progname); +char *_dbus_base_dir_get(); /** @} */ DBUS_END_DECLS