mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +00:00
More work on configuration system ... keeping more or less in sync with
make package changes. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@21826 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
679d8e46f0
commit
2368855f8b
6 changed files with 411 additions and 538 deletions
|
@ -1,7 +1,13 @@
|
|||
2005-10-15 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/NSPathUtilities.m: Fix retain/release error exposed by recent
|
||||
changes.
|
||||
changes. Rewrite config handling (work in progress ... keeping in
|
||||
sync with make package changes).
|
||||
* Documentation/base.gsdoc: update somewhat.
|
||||
* configure.ac: use GNUSTEP_CONFIG_FILE rather than
|
||||
GNUSTEP_CONFIGURATION_FILE ... for consistency with make.
|
||||
* Headers/Additions/GNUstepBase/config.h.in: ditto
|
||||
* configure: regenerate
|
||||
|
||||
2005-10-14 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
|
|
|
@ -466,7 +466,7 @@ notice and this notice are preserved.
|
|||
on. On a GNU/Linux system, the default would be
|
||||
/etc/GNUstep/GNUstep.conf, for instance.<br />
|
||||
The location of this file can be overridden using the
|
||||
GNUSTEP_CONFIGURATION_FILE environment variable.<br />
|
||||
GNUSTEP_CONFIG_FILE environment variable.<br />
|
||||
This file is not
|
||||
required. If it does not appear, then default values will
|
||||
be used for the standard path locations. System paths are
|
||||
|
@ -478,23 +478,36 @@ notice and this notice are preserved.
|
|||
<term>GNUSTEP_NETWORK_ROOT</term>
|
||||
<desc>path to network mounted resources.</desc>
|
||||
<term>GNUSTEP_LOCAL_ROOT</term>
|
||||
<desc>path for non-system resources for the specific machine.</desc>
|
||||
<desc>path for non-system resources for the specific
|
||||
machine.</desc>
|
||||
</deflist>
|
||||
<p>
|
||||
Paths for each user are defined by the following:
|
||||
</p>
|
||||
<deflist>
|
||||
<term>USER_GNUSTEP_DIR</term>
|
||||
<desc>Path for user specific GNUstep resources (eg. 'GNUstep').
|
||||
May be either an absolute path or a path relative to the
|
||||
user's home directory.</desc>
|
||||
<term>USER_GNUSTEP_RC</term>
|
||||
<desc>Name of user configuration file (eg. '.GNUsteprc')
|
||||
relative to the user's home directory.</desc>
|
||||
<term>USER_GNUSTEP_DEFAULTS</term>
|
||||
<desc>Name of directory for user defaults files. Either an
|
||||
absolute path or relative to USER_GNUSTEP_DIR.</desc>
|
||||
</deflist>
|
||||
<deflist>
|
||||
<term>GNUSTEP_USER_DIR</term>
|
||||
<desc>Path for user specific GNUstep resources (eg. 'GNUstep').
|
||||
Relative to the user's home directory.</desc>
|
||||
<term>GNUSTEP_USER_CONFIG_FILE</term>
|
||||
<desc>Name of user configuration file (eg. '.GNUsteprc')
|
||||
relative to the user's home directory.</desc>
|
||||
<term>GNUSTEP_USER_DEFAULTS_DIR</term>
|
||||
<desc>Name of directory for user defaults files.
|
||||
Relative to the user's home directory.</desc>
|
||||
</deflist>
|
||||
<p>
|
||||
The user's home directory is normally taken to be the standard
|
||||
home directory for that user on the system, but may be overridden
|
||||
using GNUSTEP_USER_HOME_<em>username</em> to specify an alternative
|
||||
hoem directory for a specific user, or GNUSTEP_USER_HOME to
|
||||
specify a directory for all users not otherwise matched.<br />
|
||||
Specifying an empty string as a directory will cause the standard
|
||||
system idea of the user's home directory to be used as normal.<br />
|
||||
This facility allows you to set up directories to hold GNUstep
|
||||
configuration and defaults information (perhaps readonly files)
|
||||
for a user account which is not normally given a home directory
|
||||
(unix daemons etc).
|
||||
</p>
|
||||
<p>
|
||||
Support is provided to locate OS/PLATFORM directories. A conf file
|
||||
may provide the definitions below:
|
||||
|
@ -511,17 +524,23 @@ notice and this notice are preserved.
|
|||
<term>PLATFORM_APPS</term>
|
||||
<desc>Place for non-gnustep applications (eg. '/usr/bin')</desc>
|
||||
<term>PLATFORM_LIBS</term>
|
||||
<desc>Place for application shared libraries (eg. '/usr/lib')</desc>
|
||||
<desc>Place for application shared libraries
|
||||
(eg. '/usr/lib')</desc>
|
||||
<term>PLATFORM_RESOURCES</term>
|
||||
<desc>Place for shared application resources (eg. '/usr/share')</desc>
|
||||
<desc>Place for shared application resources
|
||||
(eg. '/usr/share')</desc>
|
||||
<term>PLATFORM_ADMIN</term>
|
||||
<desc>Place for non-critical administrative tools (eg. '/usr/sbin')</desc>
|
||||
<desc>Place for non-critical administrative tools
|
||||
(eg. '/usr/sbin')</desc>
|
||||
<term>PLATFORM_LOCAL_APPS</term>
|
||||
<desc>Place for machine local applications (eg. '/usr/local/bin')</desc>
|
||||
<desc>Place for machine local applications
|
||||
(eg. '/usr/local/bin')</desc>
|
||||
<term>PLATFORM_LOCAL_LIBS</term>
|
||||
<desc>Place for machine local shared libraries (eg. '/usr/local/lib/')</desc>
|
||||
<desc>Place for machine local shared libraries
|
||||
(eg. '/usr/local/lib/')</desc>
|
||||
<term>PLATFORM_LOCAL_RESOURCES</term>
|
||||
<desc>Place for machine local resources. (eg. '/usr/local/share')</desc>
|
||||
<desc>Place for machine local resources.
|
||||
(eg. '/usr/local/share')</desc>
|
||||
</deflist>
|
||||
<p>
|
||||
These add to the path for NSSystemDomainMask, or
|
||||
|
@ -530,39 +549,29 @@ notice and this notice are preserved.
|
|||
</subsect>
|
||||
|
||||
<subsect>
|
||||
<heading>.GNUsteprc files</heading>
|
||||
<heading>.GNUstep.conf files</heading>
|
||||
<p>
|
||||
The locations of the directories in which user specific files and
|
||||
the user defaults database are stored may be defined in the
|
||||
file given by USER_GNUSTEP_RC (by default,
|
||||
<code>.GNUsteprc</code>).<br />
|
||||
file given by GNUSTEP_USER_CONFIG_FILE (by default,
|
||||
<code>.GNUstep.conf</code>).<br />
|
||||
If no location is given for user specific files, they are stored
|
||||
in the locaton given by USER_GNUSTEP_DIR (by default, the
|
||||
in the locaton given by GNUSTEP_USER_DIR (by default, the
|
||||
<code>GNUstep</code> subdirectory of the users home
|
||||
directory).<br />
|
||||
If a separate location is not given for the defaults database, it
|
||||
is stored in the subdirectory of USER_GNUSTEP_DIR given by
|
||||
USER_GNUSTEP_DEFAULTS (by default, the <code>Defaults</code>
|
||||
subdirectory).<br />
|
||||
is stored in the subdirectory of the users home directory given by
|
||||
GNUSTEP_USER_DEFAULTS_DIR (by default, the
|
||||
<code>GNUstep/Defaults</code> subdirectory).<br />
|
||||
</p>
|
||||
<p>
|
||||
The presence of a <code>.GNUsteprc</code> file in a users home
|
||||
directory premits the user to customize file locations using
|
||||
two commands -
|
||||
The presence of a <code>.GNUstep.conf</code> file in a users home
|
||||
directory permits the user to customize file locations using all
|
||||
the same commands as the system directory, though any attempt
|
||||
to redefine GNUSTEP_USER_CONFIG_FILE is of course ignored.<br />
|
||||
Attempts to redefine the users home directory at this level
|
||||
are also ignored.
|
||||
</p>
|
||||
<deflist>
|
||||
<term>GNUSTEP_DEFAULTS_ROOT=...</term>
|
||||
<desc>
|
||||
The text after the '=' is taken to be the path to the users
|
||||
defaults files (either absolute or relative to USER_GNUSTEP_DIR).
|
||||
</desc>
|
||||
<term>GNUSTEP_USER_ROOT=...</term>
|
||||
<desc>
|
||||
The text after the '=' is taken to be the path to the users
|
||||
files. This may be an absolute path, or a path relative to
|
||||
the user's home directory.
|
||||
</desc>
|
||||
</deflist>
|
||||
</subsect>
|
||||
</section>
|
||||
</chapter>
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
#undef CON_AUTOLOAD
|
||||
|
||||
/* Set to location of the GNUstep configuration file */
|
||||
#undef GNUSTEP_CONFIGURATION_FILE
|
||||
#undef GNUSTEP_CONFIG_FILE
|
||||
|
||||
/* Define if this constant is defined */
|
||||
#undef HANDLE_LLONG_MAX
|
||||
|
|
|
@ -100,11 +100,9 @@
|
|||
#define stringify(X) lowlevelstringify(X)
|
||||
|
||||
/* The global configuration file. The real value is read from config.h */
|
||||
#ifndef GNUSTEP_CONFIGURATION_FILE
|
||||
# define GNUSTEP_CONFIGURATION_FILE /etc/GNUstep/GNUstep.conf
|
||||
#ifndef GNUSTEP_CONFIG_FILE
|
||||
# define GNUSTEP_CONFIG_FILE /etc/GNUstep/GNUstep.conf
|
||||
#endif
|
||||
/* The name of the user-specific configuration file */
|
||||
#define DEFAULT_STEPRC_FILE @".GNUsteprc"
|
||||
/* The standard path for user Defaults files */
|
||||
#define DEFAULT_DEFAULTS_PATH @"Defaults"
|
||||
/* The standard path to user GNUstep resources */
|
||||
|
@ -151,7 +149,7 @@ static NSString *gnustep_flattened =
|
|||
/* Internal variables */
|
||||
/* ------------------ */
|
||||
|
||||
static NSString *configFile;
|
||||
static NSString *gnustepConfigFile = nil;
|
||||
|
||||
/* We read these four paths only once */
|
||||
static NSString *gnustepUserRoot = nil; /* GNUSTEP_USER_ROOT path */
|
||||
|
@ -159,9 +157,10 @@ static NSString *gnustepLocalRoot = nil; /* GNUSTEP_LOCAL_ROOT path */
|
|||
static NSString *gnustepNetworkRoot = nil; /* GNUSTEP_NETWORK_ROOT path */
|
||||
static NSString *gnustepSystemRoot = nil; /* GNUSTEP_SYSTEM_ROOT path */
|
||||
|
||||
static NSString *gnustepRcFileName = nil;
|
||||
static NSString *gnustepDefaultsPath = nil;
|
||||
static NSString *gnustepUserPath = nil;
|
||||
static NSString *gnustepUserDir = nil;
|
||||
static NSString *gnustepUserHome = nil;
|
||||
static NSString *gnustepUserConfigFile = nil;
|
||||
static NSString *gnustepUserDefaultsDir = nil;
|
||||
|
||||
static NSString *theUserName = nil; /* The user's login name */
|
||||
static NSString *tempDir = nil; /* user's temporary directory */
|
||||
|
@ -203,11 +202,9 @@ static NSString *localLibs = nil;
|
|||
/* Internal function prototypes. */
|
||||
/* ============================= */
|
||||
|
||||
static NSString *setUserGNUstepPath(NSString *userName,
|
||||
NSString **defaultsPath,
|
||||
NSString **userPath);
|
||||
static NSDictionary* GNUstepConfig(void);
|
||||
|
||||
static NSDictionary *ParseConfigurationFile(NSString *name);
|
||||
static BOOL ParseConfigurationFile(NSString *name, NSMutableDictionary *dict);
|
||||
|
||||
static void InitialisePathUtilities(void);
|
||||
static void ShutdownPathUtilities(void);
|
||||
|
@ -248,221 +245,211 @@ getPathConfig(NSDictionary *dict, NSString *key)
|
|||
return path;
|
||||
}
|
||||
|
||||
/*
|
||||
* Read .GNUsteprc file for user and set paths accordingly
|
||||
*/
|
||||
static NSString *setUserGNUstepPath(NSString *userName,
|
||||
NSString **defaultsPath,
|
||||
NSString **userPath)
|
||||
static void ExtractValuesFromConfig(NSDictionary *config)
|
||||
{
|
||||
NSDictionary *dict;
|
||||
NSString *home;
|
||||
NSString *path;
|
||||
NSString *steprcFile;
|
||||
NSString *userRoot;
|
||||
ASSIGN_IF_SET(gnustepSystemRoot, config, @"GNUSTEP_SYSTEM_ROOT");
|
||||
ASSIGN_IF_SET(gnustepNetworkRoot, config, @"GNUSTEP_NETWORK_ROOT");
|
||||
ASSIGN_IF_SET(gnustepLocalRoot, config, @"GNUSTEP_LOCAL_ROOT");
|
||||
|
||||
/* Look for rc file (".GNUsteprc") file in user's home directory */
|
||||
home = NSHomeDirectoryForUser(userName);
|
||||
if (home == nil)
|
||||
ASSIGN_IF_SET(gnustepUserDir, config, @"GNUSTEP_USER_DIR");
|
||||
ASSIGN_IF_SET(gnustepUserHome, config, @"GNUSTEP_USER_HOME");
|
||||
ASSIGN_IF_SET(gnustepUserDefaultsDir, config, @"GNUSTEP_USER_DEFAULTS_DIR");
|
||||
|
||||
#ifdef OPTION_PLATFORM_SUPPORT
|
||||
ASSIGN_IF_SET(osSysPrefs, config, SYS_PREFS);
|
||||
ASSIGN_IF_SET(osSysApps, config, SYS_APPS);
|
||||
ASSIGN_IF_SET(osSysLibs, config, SYS_LIBS);
|
||||
ASSIGN_IF_SET(osSysAdmin, config, SYS_ADMIN);
|
||||
|
||||
ASSIGN_IF_SET(platformResources, config, PLATFORM_RESOURCES);
|
||||
ASSIGN_IF_SET(platformApps, config, PLATFORM_APPS);
|
||||
ASSIGN_IF_SET(platformLibs, config, PLATFORM_LIBS);
|
||||
ASSIGN_IF_SET(platformAdmin, config, PLATFORM_ADMIN);
|
||||
|
||||
ASSIGN_IF_SET(localResources, config, PLATFORM_LOCAL_RESOURCES);
|
||||
ASSIGN_IF_SET(localApps, config, PLATFORM_LOCAL_APPS);
|
||||
ASSIGN_IF_SET(localLibs, config, PLATFORM_LOCAL_LIBS);
|
||||
#endif /* OPTION_PLATFORM SUPPORT */
|
||||
|
||||
/*
|
||||
* Set the user root from the user home and the user dir
|
||||
*/
|
||||
if (gnustepUserDir == nil)
|
||||
{
|
||||
/* It's OK if path is nil. We're might be running as user nobody in
|
||||
* which case we don't want to access user stuff. Possibly it's a
|
||||
* misconfigured Windows environment, though...
|
||||
*/
|
||||
return nil;
|
||||
ASSIGN(gnustepUserDir, @"GNUstep");
|
||||
}
|
||||
ASSIGN(gnustepUserRoot,
|
||||
[gnustepUserHome stringByAppendingPathComponent: gnustepUserDir]);
|
||||
|
||||
if ([gnustepRcFileName length] > 0)
|
||||
/* Finally we check and report problems... */
|
||||
if (gnustepSystemRoot == nil)
|
||||
{
|
||||
steprcFile = [home stringByAppendingPathComponent: gnustepRcFileName];
|
||||
gnustepSystemRoot = [NSString stringWithCString:\
|
||||
STRINGIFY(GNUSTEP_INSTALL_PREFIX)];
|
||||
fprintf (stderr, "Warning - GNUSTEP_SYSTEM_ROOT is not set " \
|
||||
"- using %s\n", [gnustepSystemRoot lossyCString]);
|
||||
}
|
||||
if (gnustepNetworkRoot == nil)
|
||||
{
|
||||
gnustepNetworkRoot = [NSString stringWithCString:\
|
||||
STRINGIFY(GNUSTEP_NETWORK_ROOT)];
|
||||
fprintf (stderr, "Warning - GNUSTEP_NETWORK_ROOT is not set " \
|
||||
"- using %s\n", [gnustepNetworkRoot lossyCString]);
|
||||
}
|
||||
if (gnustepLocalRoot == nil)
|
||||
{
|
||||
gnustepLocalRoot = [NSString stringWithCString:\
|
||||
STRINGIFY(GNUSTEP_LOCAL_ROOT)];
|
||||
fprintf (stderr, "Warning - GNUSTEP_LOCAL_ROOT is not set " \
|
||||
"- using %s\n", [gnustepLocalRoot lossyCString]);
|
||||
}
|
||||
}
|
||||
|
||||
dict = ParseConfigurationFile(steprcFile);
|
||||
if (dict != nil)
|
||||
/*
|
||||
* Function to return the system-wide configuration
|
||||
*/
|
||||
static NSDictionary*
|
||||
GNUstepConfig(void)
|
||||
{
|
||||
static NSDictionary *config = nil;
|
||||
|
||||
if (config == nil)
|
||||
{
|
||||
[gnustep_global_lock lock];
|
||||
if (config == nil)
|
||||
{
|
||||
path = [dict objectForKey: @"GNUSTEP_DEFAULTS_ROOT"];
|
||||
if (path != nil)
|
||||
NSMutableDictionary *conf = nil;
|
||||
|
||||
NS_DURING
|
||||
{
|
||||
/*
|
||||
* Special case for defaults root ... expand leading '~'
|
||||
*/
|
||||
if ([path hasPrefix: @"~"])
|
||||
conf = [[NSMutableDictionary alloc] initWithCapacity: 32];
|
||||
|
||||
/* Now we source the configuration file if it exists */
|
||||
#ifndef OPTION_NO_ENVIRONMENT
|
||||
gnustepConfigFile = [[[NSProcessInfo processInfo] environment]
|
||||
objectForKey: @"GNUSTEP_CONFIG_FILE"];
|
||||
#endif
|
||||
if (gnustepConfigFile == nil)
|
||||
{
|
||||
GSOnceFLog(@"Use of '~' in GNUSTEP_DEFAULTS_ROOT is deprecated");
|
||||
path = [path substringFromIndex: 1];
|
||||
while ([path hasPrefix: @"/"] || [path hasPrefix: @"\\"])
|
||||
{
|
||||
path = [path substringFromIndex: 1];
|
||||
}
|
||||
path = [home stringByAppendingPathComponent: path];
|
||||
gnustepConfigFile = [NSString stringWithCString:
|
||||
stringify(GNUSTEP_CONFIG_FILE)];
|
||||
}
|
||||
ASSIGN(*defaultsPath, path);
|
||||
gnustepConfigFile
|
||||
= RETAIN([gnustepConfigFile stringByStandardizingPath]);
|
||||
ParseConfigurationFile(gnustepConfigFile, conf);
|
||||
|
||||
/* System admins may force the user and defaults paths by
|
||||
* setting GNUSTEP_USER_CONFIG_FILE to be an empty string.
|
||||
* If they simply don't define it at all, we assign a default.
|
||||
*/
|
||||
if ([conf objectForKey: @"GNUSTEP_USER_CONFIG_FILE"] == nil)
|
||||
{
|
||||
[conf setObject: @".GNUstep.conf"
|
||||
forKey: @"GNUSTEP_USER_CONFIG_FILE"];
|
||||
}
|
||||
config = [conf copy];
|
||||
DESTROY(conf);
|
||||
gnustepUserConfigFile
|
||||
= [config objectForKey: @"GNUSTEP_USER_CONFIG_FILE"];
|
||||
}
|
||||
path = [dict objectForKey: @"GNUSTEP_USER_ROOT"];
|
||||
if (path != nil)
|
||||
NS_HANDLER
|
||||
{
|
||||
/*
|
||||
* For backward compatibility, remove leading '~' component
|
||||
* we will prepend the home directory later.
|
||||
*/
|
||||
if ([path hasPrefix: @"~"])
|
||||
{
|
||||
GSOnceFLog(@"Use of '~' in GNUSTEP_USER_ROOT is deprecated");
|
||||
path = [path substringFromIndex: 1];
|
||||
while ([path hasPrefix: @"/"] || [path hasPrefix: @"\\"])
|
||||
{
|
||||
path = [path substringFromIndex: 1];
|
||||
}
|
||||
}
|
||||
ASSIGN(*userPath, path);
|
||||
[gnustep_global_lock unlock];
|
||||
config = nil;
|
||||
DESTROY(conf);
|
||||
[localException raise];
|
||||
}
|
||||
NS_ENDHANDLER
|
||||
}
|
||||
[gnustep_global_lock unlock];
|
||||
}
|
||||
return config;
|
||||
}
|
||||
|
||||
/* set the user path and defaults directory to default values if needed */
|
||||
TEST_ASSIGN(*defaultsPath, DEFAULT_DEFAULTS_PATH);
|
||||
TEST_ASSIGN(*userPath, DEFAULT_USER_ROOT);
|
||||
/*
|
||||
* Function to return the configuration for the named user
|
||||
*/
|
||||
static NSDictionary*
|
||||
GNUstepUserConfig(NSString *name)
|
||||
{
|
||||
NSMutableDictionary *conf;
|
||||
NSString *file;
|
||||
NSString *home;
|
||||
|
||||
/* Now we set the user's root path for the gnustep files. */
|
||||
if ([*userPath isAbsolutePath])
|
||||
userRoot = *userPath;
|
||||
else
|
||||
userRoot = [home stringByAppendingPathComponent: *userPath];
|
||||
return userRoot;
|
||||
conf = [GNUstepConfig() mutableCopy];
|
||||
file = gnustepUserConfigFile;
|
||||
home = NSHomeDirectoryForUser(name);
|
||||
ParseConfigurationFile([home stringByAppendingPathComponent: file], conf);
|
||||
/*
|
||||
* We don't let the user config file override the home directory for
|
||||
* the user ... that would be inconsistent as we have already used
|
||||
* that directory. Similarly, we don't permit overriding of the
|
||||
* users config file name ... we make sure it's the one we just used.
|
||||
*/
|
||||
[conf setObject: home
|
||||
forKey: [@"GNUSTEP_USER_HOME_" stringByAppendingString: name]];
|
||||
[conf setObject: home forKey: @"GNUSTEP_USER_HOME"];
|
||||
[conf setObject: gnustepUserConfigFile forKey: @"GNUSTEP_USER_CONFIG_FILE"];
|
||||
return AUTORELEASE(conf);
|
||||
}
|
||||
|
||||
/* Initialise all things required by this module */
|
||||
static void InitialisePathUtilities(void)
|
||||
{
|
||||
NSMutableDictionary *userConfig = nil;
|
||||
|
||||
if (gnustepSystemRoot != nil)
|
||||
{
|
||||
return; // Protect from multiple calls
|
||||
}
|
||||
|
||||
[gnustep_global_lock lock];
|
||||
|
||||
/* Set up our root paths */
|
||||
NS_DURING
|
||||
{
|
||||
NSDictionary *env = [[NSProcessInfo processInfo] environment];
|
||||
#if defined(__WIN32__)
|
||||
HKEY regkey;
|
||||
#endif
|
||||
|
||||
/* Initialise Win32 things if on that platform */
|
||||
Win32Initialise(); // should be called by DLL_PROCESS_ATTACH
|
||||
|
||||
[gnustep_global_lock lock];
|
||||
|
||||
#ifndef OPTION_NO_ENVIRONMENT
|
||||
/* First we look at the environment */
|
||||
TEST_ASSIGN(gnustepSystemRoot,
|
||||
[env objectForKey: @"GNUSTEP_SYSTEM_ROOT"]);
|
||||
TEST_ASSIGN(gnustepNetworkRoot,
|
||||
[env objectForKey: @"GNUSTEP_NETWORK_ROOT"]);
|
||||
TEST_ASSIGN(gnustepLocalRoot,
|
||||
[env objectForKey: @"GNUSTEP_LOCAL_ROOT"]);
|
||||
#endif /* !OPTION_NO_ENVIRONMENT */
|
||||
userConfig = [GNUstepConfig() mutableCopy];
|
||||
ASSIGNCOPY(gnustepUserHome, NSHomeDirectoryForUser(NSUserName()));
|
||||
ParseConfigurationFile(
|
||||
[gnustepUserHome stringByAppendingPathComponent: gnustepUserConfigFile],
|
||||
userConfig);
|
||||
ExtractValuesFromConfig(userConfig);
|
||||
DESTROY(userConfig);
|
||||
|
||||
#if defined(__WIN32__)
|
||||
regkey = Win32OpenRegistry(HKEY_LOCAL_MACHINE,
|
||||
{
|
||||
HKEY regkey;
|
||||
/* Initialise Win32 things if on that platform */
|
||||
Win32Initialise(); // should be called by DLL_PROCESS_ATTACH
|
||||
|
||||
regkey = Win32OpenRegistry(HKEY_LOCAL_MACHINE,
|
||||
"\\Software\\GNU\\GNUstep");
|
||||
if (regkey != (HKEY)NULL)
|
||||
{
|
||||
TEST_ASSIGN(gnustepSystemRoot,
|
||||
Win32NSStringFromRegistry(regkey, @"GNUSTEP_SYSTEM_ROOT"));
|
||||
TEST_ASSIGN(gnustepNetworkRoot,
|
||||
Win32NSStringFromRegistry(regkey, @"GNUSTEP_NETWORK_ROOT"));
|
||||
TEST_ASSIGN(gnustepLocalRoot,
|
||||
Win32NSStringFromRegistry(regkey, @"GNUSTEP_LOCAL_ROOT"));
|
||||
RegCloseKey(regkey);
|
||||
}
|
||||
if (regkey != (HKEY)NULL)
|
||||
{
|
||||
TEST_ASSIGN(gnustepSystemRoot,
|
||||
Win32NSStringFromRegistry(regkey, @"GNUSTEP_SYSTEM_ROOT"));
|
||||
TEST_ASSIGN(gnustepNetworkRoot,
|
||||
Win32NSStringFromRegistry(regkey, @"GNUSTEP_NETWORK_ROOT"));
|
||||
TEST_ASSIGN(gnustepLocalRoot,
|
||||
Win32NSStringFromRegistry(regkey, @"GNUSTEP_LOCAL_ROOT"));
|
||||
RegCloseKey(regkey);
|
||||
}
|
||||
|
||||
#if 0
|
||||
// Not implemented yet
|
||||
platformApps = Win32FindDirectory(CLSID_APPS);
|
||||
platformLibs = Win32FindDirectory(CLSID_LIBS);
|
||||
// Not implemented yet
|
||||
platformApps = Win32FindDirectory(CLSID_APPS);
|
||||
platformLibs = Win32FindDirectory(CLSID_LIBS);
|
||||
#endif
|
||||
#else
|
||||
/* Now we source the configuration file if it exists */
|
||||
configFile = [env objectForKey: @"GNUSTEP_CONFIGURATION_FILE"];
|
||||
if (configFile == nil)
|
||||
{
|
||||
configFile
|
||||
= [NSString stringWithCString:
|
||||
stringify(GNUSTEP_CONFIGURATION_FILE)];
|
||||
}
|
||||
configFile = RETAIN([configFile stringByStandardizingPath]);
|
||||
if ([MGR() fileExistsAtPath: configFile])
|
||||
{
|
||||
NSDictionary *d = ParseConfigurationFile(configFile);
|
||||
|
||||
if (d != nil)
|
||||
{
|
||||
ASSIGN_IF_SET(gnustepSystemRoot, d, @"GNUSTEP_SYSTEM_ROOT");
|
||||
ASSIGN_IF_SET(gnustepNetworkRoot, d, @"GNUSTEP_NETWORK_ROOT");
|
||||
ASSIGN_IF_SET(gnustepLocalRoot, d, @"GNUSTEP_LOCAL_ROOT");
|
||||
|
||||
ASSIGN_IF_SET(gnustepRcFileName, d, @"USER_GNUSTEP_RC");
|
||||
ASSIGN_IF_SET(gnustepDefaultsPath, d, @"USER_GNUSTEP_DEFAULTS");
|
||||
ASSIGN_IF_SET(gnustepUserPath, d, @"USER_GNUSTEP_DIR");
|
||||
|
||||
#ifdef OPTION_PLATFORM_SUPPORT
|
||||
ASSIGN_IF_SET(osSysPrefs, d, SYS_PREFS);
|
||||
ASSIGN_IF_SET(osSysApps, d, SYS_APPS);
|
||||
ASSIGN_IF_SET(osSysLibs, d, SYS_LIBS);
|
||||
ASSIGN_IF_SET(osSysAdmin, d, SYS_ADMIN);
|
||||
|
||||
ASSIGN_IF_SET(platformResources, d, PLATFORM_RESOURCES);
|
||||
ASSIGN_IF_SET(platformApps, d, PLATFORM_APPS);
|
||||
ASSIGN_IF_SET(platformLibs, d, PLATFORM_LIBS);
|
||||
ASSIGN_IF_SET(platformAdmin, d, PLATFORM_ADMIN);
|
||||
|
||||
ASSIGN_IF_SET(localResources, d, PLATFORM_LOCAL_RESOURCES);
|
||||
ASSIGN_IF_SET(localApps, d, PLATFORM_LOCAL_APPS);
|
||||
ASSIGN_IF_SET(localLibs, d, PLATFORM_LOCAL_LIBS);
|
||||
#endif /* OPTION_PLATFORM SUPPORT */
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* System admins may force the user and defaults paths by
|
||||
* setting USER_GNUSTEP_RC to be an empty string.
|
||||
* If they simply don't define it at all, we assign a default
|
||||
* value here.
|
||||
*/
|
||||
TEST_ASSIGN(gnustepRcFileName, DEFAULT_STEPRC_FILE);
|
||||
|
||||
/* If the user has an rc file we need to source it */
|
||||
gnustepUserRoot = RETAIN(setUserGNUstepPath(NSUserName(),
|
||||
&gnustepDefaultsPath, &gnustepUserPath));
|
||||
|
||||
/* Finally we check and report problems... */
|
||||
if (gnustepSystemRoot == nil)
|
||||
{
|
||||
gnustepSystemRoot = [NSString stringWithCString:\
|
||||
STRINGIFY(GNUSTEP_INSTALL_PREFIX)];
|
||||
fprintf (stderr, "Warning - GNUSTEP_SYSTEM_ROOT is not set " \
|
||||
"- using %s\n", [gnustepSystemRoot lossyCString]);
|
||||
}
|
||||
if (gnustepNetworkRoot == nil)
|
||||
{
|
||||
gnustepNetworkRoot = [NSString stringWithCString:\
|
||||
STRINGIFY(GNUSTEP_NETWORK_ROOT)];
|
||||
fprintf (stderr, "Warning - GNUSTEP_NETWORK_ROOT is not set " \
|
||||
"- using %s\n", [gnustepNetworkRoot lossyCString]);
|
||||
}
|
||||
if (gnustepLocalRoot == nil)
|
||||
{
|
||||
gnustepLocalRoot = [NSString stringWithCString:\
|
||||
STRINGIFY(GNUSTEP_LOCAL_ROOT)];
|
||||
fprintf (stderr, "Warning - GNUSTEP_LOCAL_ROOT is not set " \
|
||||
"- using %s\n", [gnustepLocalRoot lossyCString]);
|
||||
}
|
||||
|
||||
[gnustep_global_lock unlock];
|
||||
}
|
||||
NS_HANDLER
|
||||
{
|
||||
/* unlock then re-raise the exception */
|
||||
[gnustep_global_lock unlock];
|
||||
DESTROY(userConfig);
|
||||
[localException raise];
|
||||
}
|
||||
NS_ENDHANDLER
|
||||
|
@ -478,9 +465,9 @@ static void ShutdownPathUtilities(void)
|
|||
DESTROY(gnustepLocalRoot);
|
||||
DESTROY(gnustepUserRoot);
|
||||
|
||||
DESTROY(gnustepRcFileName);
|
||||
DESTROY(gnustepDefaultsPath);
|
||||
DESTROY(gnustepUserPath);
|
||||
DESTROY(gnustepUserHome);
|
||||
DESTROY(gnustepUserConfigFile);
|
||||
DESTROY(gnustepUserDefaultsDir);
|
||||
|
||||
#ifdef OPTION_PLATFORM_SUPPORT
|
||||
DESTROY(osSysPrefs);
|
||||
|
@ -526,10 +513,9 @@ static void ShutdownPathUtilities(void)
|
|||
* strings to avoid having to double all occurrances of the backslash.<br />
|
||||
* Returns a dictionary of the (key,value) pairs.<br/ >
|
||||
*/
|
||||
static NSDictionary *
|
||||
ParseConfigurationFile(NSString *fileName)
|
||||
static BOOL
|
||||
ParseConfigurationFile(NSString *fileName, NSMutableDictionary *dict)
|
||||
{
|
||||
NSMutableDictionary *dict;
|
||||
NSDictionary *attributes;
|
||||
NSString *file;
|
||||
unsigned l;
|
||||
|
@ -545,7 +531,7 @@ ParseConfigurationFile(NSString *fileName)
|
|||
|
||||
if ([MGR() isReadableFileAtPath: fileName] == NO)
|
||||
{
|
||||
return nil;
|
||||
return NO;
|
||||
}
|
||||
|
||||
attributes = [MGR() fileAttributesAtPath: fileName traverseLink: YES];
|
||||
|
@ -559,13 +545,13 @@ ParseConfigurationFile(NSString *fileName)
|
|||
fprintf(stderr, "The file '%s' is writable by someone other than"
|
||||
" its owner.\nIgnoring it.\n", [fileName fileSystemRepresentation]);
|
||||
#endif
|
||||
return nil;
|
||||
return NO;
|
||||
}
|
||||
|
||||
dict = [NSMutableDictionary dictionaryWithCapacity: 16];
|
||||
if (dict == nil)
|
||||
{
|
||||
return nil; // should throw an exception??
|
||||
[NSException raise: NSInvalidArgumentException
|
||||
format: @"No destination dictionary supplied"];
|
||||
}
|
||||
|
||||
file = [NSString stringWithContentsOfFile: fileName];
|
||||
|
@ -772,7 +758,7 @@ ParseConfigurationFile(NSString *fileName)
|
|||
NSZoneFree(NSDefaultMallocZone(), src);
|
||||
NSZoneFree(NSDefaultMallocZone(), dst);
|
||||
|
||||
return dict;
|
||||
return YES;
|
||||
}
|
||||
|
||||
/* See NSPathUtilities.h for description */
|
||||
|
@ -886,20 +872,31 @@ NSHomeDirectory(void)
|
|||
NSString *
|
||||
NSHomeDirectoryForUser(NSString *loginName)
|
||||
{
|
||||
NSDictionary *config = GNUstepConfig();
|
||||
NSString *s = nil;
|
||||
#if !defined(__MINGW32__)
|
||||
struct passwd *pw;
|
||||
|
||||
[gnustep_global_lock lock];
|
||||
pw = getpwnam ([loginName cString]);
|
||||
if (pw != 0 && pw->pw_dir != NULL)
|
||||
s = [@"GNUSTEP_USER_ROOT_" stringByAppendingString: loginName];
|
||||
s = [config objectForKey: s];
|
||||
if (s == nil)
|
||||
{
|
||||
s = [NSString stringWithCString: pw->pw_dir];
|
||||
s = [config objectForKey: @"GNUSTEP_USER_ROOT"];
|
||||
}
|
||||
[gnustep_global_lock unlock];
|
||||
if ([s length] == 0)
|
||||
{
|
||||
#if !defined(__MINGW32__)
|
||||
struct passwd *pw;
|
||||
|
||||
[gnustep_global_lock lock];
|
||||
pw = getpwnam ([loginName cString]);
|
||||
if (pw != 0 && pw->pw_dir != NULL)
|
||||
{
|
||||
s = [NSString stringWithCString: pw->pw_dir];
|
||||
}
|
||||
[gnustep_global_lock unlock];
|
||||
#else
|
||||
s = Win32GetUserProfileDirectory(loginName);
|
||||
s = Win32GetUserProfileDirectory(loginName);
|
||||
#endif
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
|
@ -936,8 +933,7 @@ NSString *
|
|||
GSDefaultsRootForUser(NSString *userName)
|
||||
{
|
||||
NSString *home;
|
||||
NSString *defaultsPath = nil;
|
||||
NSString *userPath = nil;
|
||||
NSString *defaultsDir = nil;
|
||||
|
||||
if ([userName length] == 0)
|
||||
{
|
||||
|
@ -946,22 +942,18 @@ GSDefaultsRootForUser(NSString *userName)
|
|||
InitialisePathUtilities();
|
||||
if ([userName isEqual: NSUserName()])
|
||||
{
|
||||
home = gnustepUserRoot;
|
||||
defaultsPath = gnustepDefaultsPath;
|
||||
home = gnustepUserHome;
|
||||
defaultsDir = gnustepUserDefaultsDir;
|
||||
}
|
||||
else
|
||||
{
|
||||
home = setUserGNUstepPath(userName, &defaultsPath, &userPath);
|
||||
}
|
||||
NSDictionary *config;
|
||||
|
||||
if ([defaultsPath isAbsolutePath])
|
||||
{
|
||||
home = defaultsPath;
|
||||
}
|
||||
else if (home != nil)
|
||||
{
|
||||
home = [home stringByAppendingPathComponent: defaultsPath];
|
||||
config = GNUstepUserConfig(userName);
|
||||
home = [config objectForKey: @"GNUSTEP_USER_HOME"];
|
||||
defaultsDir = [config objectForKey: @"GNUSTEP_USER_DEFAULTS_DIR"];
|
||||
}
|
||||
home = [home stringByAppendingPathComponent: defaultsDir];
|
||||
|
||||
return home;
|
||||
}
|
||||
|
|
|
@ -1297,7 +1297,7 @@ AC_MSG_CHECKING(for location of GNUstep configuration file)
|
|||
config_file=$(grep GNUSTEP_CONFIG_FILE $GNUSTEP_MAKEFILES/$obj_dir/config.make | sed -e 's/GNUSTEP_CONFIG_FILE = //')
|
||||
#
|
||||
AC_MSG_RESULT($config_file)
|
||||
AC_DEFINE_UNQUOTED(GNUSTEP_CONFIGURATION_FILE, $config_file,
|
||||
AC_DEFINE_UNQUOTED(GNUSTEP_CONFIG_FILE, $config_file,
|
||||
[Set to location of the GNUstep configuration file])
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
|
|
Loading…
Reference in a new issue