mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-31 00:30:53 +00:00
Restructure to allow programmatic setting of configuration.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@22077 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
e34f1ec8f6
commit
ac8adde2b9
2 changed files with 27 additions and 15 deletions
|
@ -1,3 +1,9 @@
|
||||||
|
2005-11-22 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
|
* Source/NSPathUtilities.m: Restructure so that GNUstepConfig() can
|
||||||
|
be used to set/get the global configuration as suggested by
|
||||||
|
Jeremy Bettis
|
||||||
|
|
||||||
2005-11-22 Richard Frith-Macdonald <rfm@gnu.org>
|
2005-11-22 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
* Source/NSPort.m:
|
* Source/NSPort.m:
|
||||||
|
|
|
@ -174,7 +174,9 @@ static NSString *localLibs = nil;
|
||||||
/* Internal function prototypes. */
|
/* Internal function prototypes. */
|
||||||
/* ============================= */
|
/* ============================= */
|
||||||
|
|
||||||
NSMutableDictionary* GNUstepConfig(NSDictionary *newConfig, NSString *userName);
|
NSMutableDictionary* GNUstepConfig(NSDictionary *newConfig);
|
||||||
|
|
||||||
|
static void UserConfig(NSMutableDictionary *config, NSString *userName);
|
||||||
|
|
||||||
static BOOL ParseConfigurationFile(NSString *name, NSMutableDictionary *dict);
|
static BOOL ParseConfigurationFile(NSString *name, NSMutableDictionary *dict);
|
||||||
|
|
||||||
|
@ -381,7 +383,7 @@ static void ExtractValuesFromConfig(NSDictionary *config)
|
||||||
* configuration.
|
* configuration.
|
||||||
*/
|
*/
|
||||||
NSMutableDictionary*
|
NSMutableDictionary*
|
||||||
GNUstepConfig(NSDictionary *newConfig, NSString *userName)
|
GNUstepConfig(NSDictionary *newConfig)
|
||||||
{
|
{
|
||||||
static NSDictionary *config = nil;
|
static NSDictionary *config = nil;
|
||||||
NSMutableDictionary *conf = nil;
|
NSMutableDictionary *conf = nil;
|
||||||
|
@ -475,6 +477,12 @@ GNUstepConfig(NSDictionary *newConfig, NSString *userName)
|
||||||
InitialisePathUtilities();
|
InitialisePathUtilities();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return AUTORELEASE([config mutableCopy]);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
UserConfig(NSMutableDictionary *config, NSString *userName)
|
||||||
|
{
|
||||||
#ifdef HAVE_GETEUID
|
#ifdef HAVE_GETEUID
|
||||||
if (userName != nil)
|
if (userName != nil)
|
||||||
{
|
{
|
||||||
|
@ -491,26 +499,22 @@ GNUstepConfig(NSDictionary *newConfig, NSString *userName)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (config != nil && userName != nil)
|
if (userName != nil)
|
||||||
{
|
{
|
||||||
NSString *file;
|
NSString *file;
|
||||||
NSString *home;
|
NSString *home;
|
||||||
|
NSString *path;
|
||||||
|
|
||||||
conf = AUTORELEASE([config mutableCopy]);
|
file = RETAIN([config objectForKey: @"GNUSTEP_USER_CONFIG_FILE"]);
|
||||||
file = RETAIN([conf objectForKey: @"GNUSTEP_USER_CONFIG_FILE"]);
|
|
||||||
home = NSHomeDirectoryForUser(userName);
|
home = NSHomeDirectoryForUser(userName);
|
||||||
ParseConfigurationFile([home stringByAppendingPathComponent: file], conf);
|
path = [home stringByAppendingPathComponent: file];
|
||||||
|
ParseConfigurationFile(path, config);
|
||||||
/*
|
/*
|
||||||
* We don't let the user config file override the GNUSTEP_USER_CONFIG_FILE
|
* We don't let the user config file override the GNUSTEP_USER_CONFIG_FILE
|
||||||
* variable ... that would be silly/pointless.
|
* variable ... that would be silly/pointless.
|
||||||
*/
|
*/
|
||||||
[conf setObject: file forKey: @"GNUSTEP_USER_CONFIG_FILE"];
|
[config setObject: file forKey: @"GNUSTEP_USER_CONFIG_FILE"];
|
||||||
RELEASE(file);
|
RELEASE(file);
|
||||||
return conf;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return AUTORELEASE([config mutableCopy]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -530,7 +534,8 @@ static void InitialisePathUtilities(void)
|
||||||
|
|
||||||
[gnustep_global_lock lock];
|
[gnustep_global_lock lock];
|
||||||
userName = NSUserName();
|
userName = NSUserName();
|
||||||
config = GNUstepConfig(nil, userName);
|
config = GNUstepConfig(nil);
|
||||||
|
UserConfig(config, userName);
|
||||||
ASSIGNCOPY(gnustepUserHome, NSHomeDirectoryForUser(userName));
|
ASSIGNCOPY(gnustepUserHome, NSHomeDirectoryForUser(userName));
|
||||||
ExtractValuesFromConfig(config);
|
ExtractValuesFromConfig(config);
|
||||||
|
|
||||||
|
@ -1088,9 +1093,10 @@ GSDefaultsRootForUser(NSString *userName)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
NSDictionary *config;
|
NSMutableDictionary *config;
|
||||||
|
|
||||||
config = GNUstepConfig(nil, userName);
|
config = GNUstepConfig(nil);
|
||||||
|
UserConfig(config, userName);
|
||||||
defaultsDir = [config objectForKey: @"GNUSTEP_USER_DEFAULTS_DIR"];
|
defaultsDir = [config objectForKey: @"GNUSTEP_USER_DEFAULTS_DIR"];
|
||||||
if (defaultsDir == nil)
|
if (defaultsDir == nil)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue