mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-30 16:30:41 +00:00
Further config enhancements ... fix a couple of static declarations,
use GNUstep.conf in defaults system, and allow external defaults to be disabled. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@22518 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
96bb9c77af
commit
83e860fbcc
7 changed files with 91 additions and 26 deletions
|
@ -82,6 +82,11 @@
|
|||
#include <sys/types.h>
|
||||
#include <stdio.h>
|
||||
|
||||
NSMutableDictionary* GNUstepConfig(NSDictionary *newConfig);
|
||||
|
||||
void GNUstepUserConfig(NSMutableDictionary *config, NSString *userName);
|
||||
|
||||
|
||||
/* The global configuration file. The real value is read from config.h */
|
||||
#ifndef GNUSTEP_TARGET_CONFIG_FILE
|
||||
# define GNUSTEP_TARGET_CONFIG_FILE "/etc/GNUstep/GNUstep.conf"
|
||||
|
@ -155,14 +160,6 @@ static NSString *localResources = nil;
|
|||
static NSString *localApps = nil;
|
||||
static NSString *localLibs = nil;
|
||||
|
||||
/* ============================= */
|
||||
/* Internal function prototypes. */
|
||||
/* ============================= */
|
||||
|
||||
static NSMutableDictionary* GNUstepConfig(NSDictionary *newConfig);
|
||||
|
||||
static void UserConfig(NSMutableDictionary *config, NSString *userName);
|
||||
|
||||
static BOOL ParseConfigurationFile(NSString *name, NSMutableDictionary *dict,
|
||||
NSString *userName);
|
||||
|
||||
|
@ -363,7 +360,7 @@ static void ExtractValuesFromConfig(NSDictionary *config)
|
|||
}
|
||||
}
|
||||
|
||||
static NSMutableDictionary*
|
||||
NSMutableDictionary*
|
||||
GNUstepConfig(NSDictionary *newConfig)
|
||||
{
|
||||
static NSDictionary *config = nil;
|
||||
|
@ -510,8 +507,8 @@ GNUstepConfig(NSDictionary *newConfig)
|
|||
return AUTORELEASE([config mutableCopy]);
|
||||
}
|
||||
|
||||
static void
|
||||
UserConfig(NSMutableDictionary *config, NSString *userName)
|
||||
void
|
||||
GNUstepUserConfig(NSMutableDictionary *config, NSString *userName)
|
||||
{
|
||||
#ifdef HAVE_GETEUID
|
||||
if (userName != nil)
|
||||
|
@ -568,7 +565,7 @@ static void InitialisePathUtilities(void)
|
|||
[gnustep_global_lock lock];
|
||||
userName = NSUserName();
|
||||
config = GNUstepConfig(nil);
|
||||
UserConfig(config, userName);
|
||||
GNUstepUserConfig(config, userName);
|
||||
ASSIGNCOPY(gnustepUserHome, NSHomeDirectoryForUser(userName));
|
||||
ExtractValuesFromConfig(config);
|
||||
|
||||
|
@ -1154,7 +1151,7 @@ GSDefaultsRootForUser(NSString *userName)
|
|||
NSMutableDictionary *config;
|
||||
|
||||
config = GNUstepConfig(nil);
|
||||
UserConfig(config, userName);
|
||||
GNUstepUserConfig(config, userName);
|
||||
defaultsDir = [config objectForKey: @"GNUSTEP_USER_DEFAULTS_DIR"];
|
||||
if (defaultsDir == nil)
|
||||
{
|
||||
|
|
|
@ -189,6 +189,13 @@ static void updateCache(NSUserDefaults *self)
|
|||
* Constants that help with localization to the users's
|
||||
* language.
|
||||
* </desc>
|
||||
* <term><code>GSConfigDomain</code> ... volatile</term>
|
||||
* <desc>
|
||||
* Information retrieved from the GNUstep configuration system.
|
||||
* Usually the system wide and user specific GNUstep.conf files,
|
||||
* or from information cimplied in when the base library was
|
||||
* built.
|
||||
* </desc>
|
||||
* <term><code>NSRegistrationDomain</code> ... volatile</term>
|
||||
* <desc>
|
||||
* Temporary defaults set up by the application.
|
||||
|
@ -474,6 +481,7 @@ static BOOL setSharedDefaults = NO; /* Flag to prevent infinite recursion */
|
|||
[sharedDefaults->_searchList addObject: NSArgumentDomain];
|
||||
[sharedDefaults->_searchList addObject: processName];
|
||||
[sharedDefaults->_searchList addObject: NSGlobalDomain];
|
||||
[sharedDefaults->_searchList addObject: GSConfigDomain];
|
||||
[sharedDefaults->_searchList addObject: NSRegistrationDomain];
|
||||
|
||||
/*
|
||||
|
@ -707,14 +715,19 @@ static NSString *
|
|||
pathForUser(NSString *user)
|
||||
{
|
||||
NSString *database = @".GNUstepDefaults";
|
||||
NSFileManager *mgr = [NSFileManager defaultManager];
|
||||
NSFileManager *mgr;
|
||||
NSString *path;
|
||||
unsigned desired;
|
||||
NSDictionary *attr;
|
||||
BOOL isDir;
|
||||
|
||||
path = GSDefaultsRootForUser(user);
|
||||
if (path == nil || [path rangeOfString: @":INTERNAL:"].length > 0)
|
||||
{
|
||||
return path;
|
||||
}
|
||||
|
||||
mgr = [NSFileManager defaultManager];
|
||||
#if !(defined(S_IRUSR) && defined(S_IWUSR) && defined(S_IXUSR) \
|
||||
&& defined(S_IRGRP) && defined(S_IXGRP) \
|
||||
&& defined(S_IROTH) && defined(S_IXOTH))
|
||||
|
@ -770,6 +783,7 @@ pathForUser(NSString *user)
|
|||
- (id) initWithContentsOfFile: (NSString*)path
|
||||
{
|
||||
NSFileManager *mgr = [NSFileManager defaultManager];
|
||||
NSRange r;
|
||||
BOOL flag;
|
||||
|
||||
self = [super init];
|
||||
|
@ -787,12 +801,17 @@ pathForUser(NSString *user)
|
|||
path = pathForUser(NSUserName());
|
||||
}
|
||||
|
||||
r = [path rangeOfString: @":INTERNAL:"];
|
||||
if (r.length > 0)
|
||||
{
|
||||
goto skipPathChecks;
|
||||
}
|
||||
#if defined(__MINGW32__)
|
||||
{
|
||||
NSRange r = [path rangeOfString: @":REGISTRY:"];
|
||||
if (r.length > 0)
|
||||
goto skipPathChecks;
|
||||
}
|
||||
r = [path rangeOfString: @":REGISTRY:"];
|
||||
if (r.length > 0)
|
||||
{
|
||||
goto skipPathChecks;
|
||||
}
|
||||
#endif
|
||||
|
||||
path = [path stringByStandardizingPath];
|
||||
|
@ -826,9 +845,7 @@ pathForUser(NSString *user)
|
|||
[_defaultsDatabase stringByAppendingPathExtension: @"lck"]];
|
||||
}
|
||||
|
||||
#if defined(__MINGW32__)
|
||||
skipPathChecks:
|
||||
#endif
|
||||
|
||||
_lock = [GSLazyRecursiveLock new];
|
||||
|
||||
|
@ -866,6 +883,7 @@ skipPathChecks:
|
|||
[_tempDomains
|
||||
setObject: [NSMutableDictionaryClass dictionaryWithCapacity: 10]
|
||||
forKey: NSRegistrationDomain];
|
||||
[_tempDomains setObject: GNUstepConfig(nil) forKey: GSConfigDomain];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserver: self
|
||||
selector: @selector(synchronize)
|
||||
|
|
|
@ -133,6 +133,8 @@ NSString *NSGlobalDomain = @"NSGlobalDomain";
|
|||
|
||||
NSString *NSRegistrationDomain = @"NSRegistrationDomain";
|
||||
|
||||
NSString *GSConfigDomain = @"GSConfigDomain";
|
||||
|
||||
|
||||
/* Public notification */
|
||||
NSString *NSUserDefaultsDidChangeNotification = @"NSUserDefaultsDidChangeNotification";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue